Files
FreeCADWasmDev/tools/run_p6_help_boundary_probe.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

48 lines
2.8 KiB
JavaScript

#!/usr/bin/env node
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
const sourceRoot = path.join(root, "freecad-source");
const docsRoot = path.join(root, "docs");
const sourceRevision = "4f4e9244e613ea2df06e70027074a562695048cb";
const files = ["src/Mod/Help/CMakeLists.txt", "src/Mod/Help/Help.py", "src/Mod/Help/InitGui.py", "src/Mod/Help/dlgPreferencesHelp.ui"];
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(path.join(sourceRoot, file))).digest("hex");
const inputs = Object.fromEntries(files.map((file) => [file, sha256(file)]));
const line = (file, pattern) => {
const text = fs.readFileSync(path.join(sourceRoot, file), "utf8").split(/\r?\n/);
const index = text.findIndex((value) => value.includes(pattern));
if (index < 0) throw new Error(`pattern not found: ${file}:${pattern}`);
return { file, line: index + 1, pattern };
};
const currentSourceRevision = execFileSync("git", ["-C", sourceRoot, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
const report = {
schema: "freecad-web-p6-help-source-boundary/v1",
module: "Help",
result: "pass_probe_only",
sourceRevision,
currentSourceRevision,
cmake: {
target: "Help",
kind: "custom_target",
nativeTarget: null,
buildCondition: "always (custom target)",
guiResources: "BUILD_GUI only",
lines: [line("src/Mod/Help/CMakeLists.txt", "ADD_CUSTOM_TARGET(Help ALL"), line("src/Mod/Help/CMakeLists.txt", "IF (BUILD_GUI)")],
},
dependencies: ["FreeCADApp (Python module)", "Python stdlib: os, re, urllib"],
actions: {
"inspect/source-inventory": { entry: "src/Mod/Help/Help.py", operation: "read-only source/API inventory", lines: [line("src/Mod/Help/Help.py", "def show(")] },
"python-api": { entry: "src/Mod/Help/Help.py", operation: "read-only Python helper API", apiCount: 14, lines: [line("src/Mod/Help/Help.py", "def get_location("), line("src/Mod/Help/Help.py", "def convert(")] },
},
guiExcluded: ["InitGui.py", "PySide", "QtWebEngineWidgets", "pivy.coin", "Help_rc.py"],
runtimeBoundary: { objectTypes: [], registeredFormats: [], persistence: "not applicable: read-only documentation helpers" },
inputs,
};
fs.mkdirSync(path.join(docsRoot, "p6"), { recursive: true });
fs.writeFileSync(path.join(docsRoot, "p6/help-source-boundary.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(docsRoot, "freecad-p6-help-a-rg.log"), `result=${report.result}\nfiles=${files.length}\ntarget=Help\nnativeTarget=none\ncurrentSourceRevision=${currentSourceRevision}\n`);
console.log(JSON.stringify({ result: report.result, files: files.length, target: report.cmake.target }));