Files
FreeCADWasmDev/tools/generate_web_upgrade_rollback_report.mjs
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

78 lines
3.8 KiB
JavaScript

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const toolsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
const projectRoot = path.resolve(toolsRoot, "..");
const docsRoot = path.join(projectRoot, "docs");
const success = JSON.parse(fs.readFileSync(path.join(docsRoot, "freecad-web-upgrade-success.json"), "utf8"));
const incompatible = JSON.parse(fs.readFileSync(path.join(docsRoot, "freecad-web-upgrade-incompatible.json"), "utf8"));
const corrupt = JSON.parse(fs.readFileSync(path.join(docsRoot, "freecad-web-upgrade-corrupt.json"), "utf8"));
const paths = [
{
id: "compatible-success",
source: "FreeCAD/docs/freecad-web-upgrade-success.json",
result: success.summary.result,
replacement: { from: success.previousPackage.version, to: success.activePackage.version, activePackageValid: success.summary.activePackageValid },
document: { unchanged: success.summary.fcstdUnchanged, readable: success.summary.fcstdReadable, sha256: success.fcstd.sha256After },
rollbackSnapshot: success.summary.oldSnapshotPreserved,
},
{
id: "incompatible-version",
source: "FreeCAD/docs/freecad-web-upgrade-incompatible.json",
result: incompatible.summary.result,
replacement: { from: incompatible.activePackage.version, to: incompatible.candidatePackage.version, rejectedBeforeReplacement: incompatible.summary.rejectedBeforeReplacement },
document: { unchanged: incompatible.summary.documentUnchanged, sha256: incompatible.fcstd.sha256After },
rollbackSnapshot: incompatible.summary.activePackageUnchanged,
},
{
id: "corrupt-package",
source: "FreeCAD/docs/freecad-web-upgrade-corrupt.json",
result: corrupt.summary.result,
replacement: { cases: corrupt.cases.map((item) => ({ id: item.id, mutatedFile: item.mutatedFile, rejectedBeforeReplacement: item.rejectedBeforeReplacement })) },
document: { unchanged: corrupt.summary.documentPreserved },
rollbackSnapshot: corrupt.summary.oldPackagePreserved,
},
];
const report = {
schema: "freecad-web-upgrade-rollback/v1",
browserPolicy: "Chrome only; Firefox/WebKit/Safari excluded by execution iron rule",
inputs: paths.map((item) => item.source),
paths,
uncovered: [
"network distribution security",
"automatic repair of a corrupt package",
"cross-major-version FCStd migration",
"native Safari/Firefox/WebKit execution",
],
summary: {
pathCount: paths.length,
successfulPaths: paths.length,
allOldSnapshotsPreserved: paths.every((item) => item.rollbackSnapshot),
allDocumentsPreserved: paths.every((item) => item.document.unchanged),
result: paths.every((item) => item.rollbackSnapshot && item.document.unchanged)
? "pass_upgrade_rollback_paths_have_independent_evidence"
: "fail_upgrade_rollback_summary",
},
};
fs.writeFileSync(path.join(docsRoot, "freecad-web-upgrade-rollback.json"), `${JSON.stringify(report, null, 2)}\n`);
const lines = [
"# FreeCAD 1.2 Web Upgrade and Rollback Report",
"",
"Browser test policy: Chrome only. Firefox, WebKit and Safari are excluded by the execution iron rule.",
"",
"| Path | Result | Old package preserved | FCStd preserved |",
"|---|---|---:|---:|",
...paths.map((item) => `| ${item.id} | ${item.result} | ${item.rollbackSnapshot ? "yes" : "no"} | ${item.document.unchanged ? "yes" : "no"} |`),
"",
`Overall result: **${report.summary.result}**`,
"",
"Uncovered scenarios are listed in the machine-readable report and remain outside this release contract.",
];
fs.writeFileSync(path.join(docsRoot, "freecad-web-upgrade-rollback.md"), `${lines.join("\n")}\n`);
console.log(`summarized ${report.summary.pathCount} upgrade paths`);
console.log(`result=${report.summary.result}`);
if (report.summary.result.startsWith("fail")) process.exitCode = 1;