Files
workinf_Blender_Wasm/tools/web/generate-io-format-runtime-receipts.mjs
mes123456 380cbed4ff
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

40 lines
1.8 KiB
JavaScript

import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const inventoryPath = path.join(repoRoot, "tests/golden/M12-05A/format-inventory.json");
const outputArgument = process.argv.indexOf("--output");
const outputPath = outputArgument === -1 ? path.join(repoRoot, "tests/golden/M12-05D/runtime-receipts.json") : path.resolve(process.argv[outputArgument + 1] ?? "");
if (!outputPath) throw new Error("--output requires a file");
const inventoryBytes = fs.readFileSync(inventoryPath);
const inventory = JSON.parse(inventoryBytes);
if (inventory.schemaVersion !== 1 || inventory.task !== "M12-05A") throw new Error("M12-05A inventory header is invalid");
const receipts = inventory.formats.flatMap((entry) => ["IMPORT", "EXPORT"].map((operation) => {
const source = entry[operation.toLowerCase()];
return {
format: entry.format,
family: entry.family,
operation,
operator: source.operator,
registered: source.registered,
rnaIdentifier: source.rnaIdentifier,
buildOption: source.buildOption,
buildOptionEnabled: source.buildOptionEnabled,
runtimeStatus: source.runtimeStatus,
variants: [...entry.variants],
extensions: [...entry.extensions],
};
}));
const output = {
schemaVersion: 1,
task: "M12-05D",
inventorySha256: crypto.createHash("sha256").update(inventoryBytes).digest("hex"),
runtime: inventory.runtime,
receipts,
};
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, `${JSON.stringify(output, null, 2)}\n`);
process.stdout.write(`io-format-runtime-receipts-generated formats=${inventory.formats.length} receipts=${receipts.length} output=${path.relative(repoRoot, outputPath)}\n`);