chore(#1925): generalize golden-install-parity generator to all runtimes + args
Support regenerating a single runtime (node scripts/gen-golden-install-parity-zcode.cjs zcode) or all runtimes (no args). Needed when a shared payload file changes and every fixture must be recaptured.
This commit is contained in:
@@ -16,7 +16,7 @@ const path = require('node:path');
|
|||||||
const crypto = require('node:crypto');
|
const crypto = require('node:crypto');
|
||||||
|
|
||||||
const ROOT = path.resolve(__dirname, '..');
|
const ROOT = path.resolve(__dirname, '..');
|
||||||
const { walk, runMinimalInstall } = require(path.join(ROOT, 'tests', 'helpers', 'install-shared.cjs'));
|
const { walk, runMinimalInstall, RUNTIME_META } = require(path.join(ROOT, 'tests', 'helpers', 'install-shared.cjs'));
|
||||||
const PKG_VERSION = require(path.join(ROOT, 'package.json')).version;
|
const PKG_VERSION = require(path.join(ROOT, 'package.json')).version;
|
||||||
const FIXTURE_DIR = path.join(ROOT, 'tests', 'fixtures', 'golden-install-parity');
|
const FIXTURE_DIR = path.join(ROOT, 'tests', 'fixtures', 'golden-install-parity');
|
||||||
|
|
||||||
@@ -51,15 +51,27 @@ function cleanup(root) {
|
|||||||
try { fs.rmSync(root, { recursive: true, force: true }); } catch { /* best effort */ }
|
try { fs.rmSync(root, { recursive: true, force: true }); } catch { /* best effort */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
const runtime = 'zcode';
|
// Regenerate the fixture for every runtime in RUNTIME_META. Needed when a
|
||||||
const { configDir, root } = runMinimalInstall({ runtime, scope: 'global' });
|
// SHARED gsd-core payload file (e.g. model-catalog.json, capability-registry)
|
||||||
let actual;
|
// changes content — its hash appears in every runtime's manifest, so all
|
||||||
try {
|
// fixtures must be recaptured together. Usage:
|
||||||
actual = buildParityManifest(configDir, root);
|
// node scripts/gen-golden-install-parity-zcode.cjs [runtime ...]
|
||||||
} finally {
|
// With no args, regenerates ALL runtimes. With args, only the named runtimes.
|
||||||
cleanup(root);
|
const targets = process.argv.slice(2).length > 0 ? process.argv.slice(2) : Object.keys(RUNTIME_META);
|
||||||
}
|
|
||||||
fs.mkdirSync(FIXTURE_DIR, { recursive: true });
|
fs.mkdirSync(FIXTURE_DIR, { recursive: true });
|
||||||
const fixturePath = path.join(FIXTURE_DIR, `${runtime}.json`);
|
for (const runtime of targets) {
|
||||||
fs.writeFileSync(fixturePath, JSON.stringify(actual, null, 2) + '\n', 'utf8');
|
if (!Object.prototype.hasOwnProperty.call(RUNTIME_META, runtime)) {
|
||||||
process.stdout.write(`[gen] ${runtime}: wrote ${Object.keys(actual).length} file hashes -> ${fixturePath}\n`);
|
process.stderr.write(`[gen] unknown runtime '${runtime}' (not in RUNTIME_META) — skipping\n`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const { configDir, root } = runMinimalInstall({ runtime, scope: 'global' });
|
||||||
|
let actual;
|
||||||
|
try {
|
||||||
|
actual = buildParityManifest(configDir, root);
|
||||||
|
} finally {
|
||||||
|
cleanup(root);
|
||||||
|
}
|
||||||
|
const fixturePath = path.join(FIXTURE_DIR, `${runtime}.json`);
|
||||||
|
fs.writeFileSync(fixturePath, JSON.stringify(actual, null, 2) + '\n', 'utf8');
|
||||||
|
process.stdout.write(`[gen] ${runtime}: wrote ${Object.keys(actual).length} file hashes -> ${fixturePath}\n`);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user