Advance M7 workflows and release operations
This commit is contained in:
@@ -6,12 +6,20 @@ 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 ?? []) {
|
||||
if (manifest.schemaVersion === 2 &&
|
||||
(typeof manifest.releaseId !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(manifest.releaseId))) {
|
||||
throw new Error("schema v2 engine manifest has no valid releaseId");
|
||||
}
|
||||
const resources = manifest.schemaVersion === 2
|
||||
? manifest.variants.flatMap((variant) => Object.values(variant.resources))
|
||||
: manifest.wasm ?? [];
|
||||
const uniqueResources = [...new Map(resources.map((resource) => [resource.url, resource])).values()];
|
||||
for (const resource of uniqueResources) {
|
||||
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}`);
|
||||
throw new Error(`manifest hash mismatch: ${resource.url} expected=${resource.sha256} actual=${actual}`);
|
||||
}
|
||||
}
|
||||
console.log(`manifest-assets-ok resources=${(manifest.wasm ?? []).length}`);
|
||||
console.log(`manifest-assets-ok resources=${uniqueResources.length}`);
|
||||
|
||||
Reference in New Issue
Block a user