Files
vercel-labs--zerolang/scripts/convert-stdlib-graphs-to-binary.mts
wehub-resource-sync e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:29:30 +08:00

43 lines
1.6 KiB
TypeScript

#!/usr/bin/env -S node --experimental-strip-types --disable-warning=ExperimentalWarning
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const zeroBin = path.join(repoRoot, "bin/zero");
const stdRoot = path.join(repoRoot, "std");
const tmpRoot = path.join(os.tmpdir(), `zero-stdlib-binary-graphs-${process.pid}`);
function runZero(args: string[]) {
const result = spawnSync(zeroBin, args, {
cwd: repoRoot,
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
});
if (result.status !== 0) {
const command = ["bin/zero", ...args].join(" ");
const output = `${result.stdout || ""}${result.stderr || ""}`.trim();
throw new Error(`${command} failed\n${output}`);
}
}
fs.mkdirSync(tmpRoot, { recursive: true });
const graphs = fs.readdirSync(stdRoot)
.filter((name) => name.endsWith(".graph"))
.sort((a, b) => a.localeCompare(b));
for (const name of graphs) {
const relative = `std/${name}`;
const tmp = path.join(tmpRoot, name);
runZero(["validate", "--format", "binary", "--out", tmp, relative]);
const magic = fs.readFileSync(tmp).subarray(0, 8).toString("latin1");
if (magic !== "ZRGBIN1\0") throw new Error(`${relative}: generated graph is not a binary graph store`);
fs.renameSync(tmp, path.join(repoRoot, relative));
}
fs.rmSync(tmpRoot, { recursive: true, force: true });
console.log(`converted ${graphs.length} std graph store(s) to binary`);