Files
workinf_Blender_Wasm/tools/web/check-manifest-assets.mjs
2026-08-12 04:47:48 -04:00

18 lines
828 B
JavaScript

import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
const [manifestPath, publicRoot] = process.argv.slice(2);
if (!manifestPath || !publicRoot) throw new Error("usage: check-manifest-assets.mjs MANIFEST PUBLIC_ROOT");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
for (const resource of manifest.wasm ?? []) {
const relativePath = resource.url.replace(/^\/+/, "");
const filePath = path.join(publicRoot, relativePath);
const actual = crypto.createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
if (actual !== String(resource.sha256).toLowerCase()) {
throw new Error(`manifest hash mismatch: ${resource.id} expected=${resource.sha256} actual=${actual}`);
}
}
console.log(`manifest-assets-ok resources=${(manifest.wasm ?? []).length}`);