Advance M7 workflows and release operations
This commit is contained in:
@@ -1,12 +1,51 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const [manifestPath, wasmHash] = process.argv.slice(2);
|
||||
if (!manifestPath || !/^[a-f0-9]{64}$/.test(wasmHash ?? "")) {
|
||||
throw new Error("usage: update-engine-manifest.mjs <manifest.json> <wasm-sha256>");
|
||||
const [manifestPath, singleDirectory, pthreadDirectory] = process.argv.slice(2);
|
||||
if (!manifestPath || !singleDirectory || !pthreadDirectory) {
|
||||
throw new Error(
|
||||
"usage: update-engine-manifest.mjs <manifest.json> <single-directory> <pthread-directory>",
|
||||
);
|
||||
}
|
||||
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
const resource = manifest.wasm?.find((entry) => entry.id === "web-engine-bootstrap");
|
||||
if (!resource) throw new Error("web-engine-bootstrap resource is missing from the engine manifest");
|
||||
resource.sha256 = wasmHash;
|
||||
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
if (typeof manifest.engineVersion !== "string" || manifest.engineVersion.length === 0) {
|
||||
throw new Error("engineVersion is missing from the existing engine manifest");
|
||||
}
|
||||
|
||||
function resource(directory, variant, fileName) {
|
||||
const filePath = path.join(directory, fileName);
|
||||
const bytes = fs.readFileSync(filePath);
|
||||
if (bytes.byteLength === 0) throw new Error(`${variant} ${fileName} is empty`);
|
||||
return {
|
||||
fileName,
|
||||
url: `/vendor/blender/${variant}/${fileName}`,
|
||||
sha256: crypto.createHash("sha256").update(bytes).digest("hex"),
|
||||
};
|
||||
}
|
||||
|
||||
const singleJs = resource(singleDirectory, "single", "web_engine.js");
|
||||
const singleWasm = resource(singleDirectory, "single", "web_engine.wasm");
|
||||
const pthreadJs = resource(pthreadDirectory, "pthread", "web_engine.js");
|
||||
const pthreadWasm = resource(pthreadDirectory, "pthread", "web_engine.wasm");
|
||||
const updated = {
|
||||
schemaVersion: 2,
|
||||
protocolVersion: 1,
|
||||
releaseId: typeof manifest.releaseId === "string" ? manifest.releaseId : manifest.engineVersion,
|
||||
engineVersion: manifest.engineVersion,
|
||||
engine: "blender-wasm",
|
||||
variants: [
|
||||
{
|
||||
id: "single",
|
||||
memory: { initialPages: 256, maximumPages: 32768, shared: false },
|
||||
resources: { js: singleJs, wasm: singleWasm },
|
||||
},
|
||||
{
|
||||
id: "pthread",
|
||||
memory: { initialPages: 256, maximumPages: 32768, shared: true },
|
||||
resources: { js: pthreadJs, wasm: pthreadWasm, pthreadWorker: pthreadJs },
|
||||
},
|
||||
],
|
||||
};
|
||||
fs.writeFileSync(manifestPath, `${JSON.stringify(updated, null, 2)}\n`);
|
||||
|
||||
Reference in New Issue
Block a user