17 lines
1.2 KiB
JavaScript
17 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
|
|
const protocol = fs.readFileSync(new URL("../../web/protocol/web-engine.ts", import.meta.url), "utf8");
|
|
const registry = fs.readFileSync(new URL("../../web/protocol/web-engine-capabilities.ts", import.meta.url), "utf8");
|
|
const commandUnion = protocol.split("export type WebEngineEditCommand =", 2)[1]?.split("/** JSON values", 1)[0] ?? "";
|
|
const commands = new Set([...commandUnion.matchAll(/type:\s*"([A-Za-z0-9]+)"/gu)].map((match) => match[1]));
|
|
commands.add("moveNLAStrip");
|
|
const registered = new Set([...registry.matchAll(/^ ([A-Za-z0-9]+): \{/gmu)].map((match) => match[1]));
|
|
registered.delete("listBlenderOperators");
|
|
registered.delete("invokeBlenderOperator");
|
|
const missing = [...commands].filter((command) => !registered.has(command)).sort();
|
|
const stale = [...registered].filter((command) => !commands.has(command)).sort();
|
|
assert.deepEqual(missing, [], `WebEngine edit commands missing capabilities: ${missing.join(",")}`);
|
|
assert.deepEqual(stale, [], `WebEngine capabilities without edit commands: ${stale.join(",")}`);
|
|
process.stdout.write(`web-engine-command-registry-ok commands=${commands.size}\n`);
|