Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920212223242526// CLI for src/node/snapshot.ts (the format and pruning rules are documented there), which// it re-exports for the repo's tests.// Usage: node scripts/snapshot.mjs <appDir> <out.snap> [--mount /app]import { mkdirSync, writeFileSync } from "node:fs";import { dirname, resolve } from "node:path";import { fileURLToPath } from "node:url";import { snapshot, encodeSnapshot } from "../src/node/snapshot.ts";
export { snapshot, encodeSnapshot };
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { const args = process.argv.slice(2); const mountAt = args.indexOf("--mount"); const mount = mountAt === -1 ? "/app" : args[mountAt + 1]; const [appDir, out] = args.filter((_, i) => mountAt === -1 || (i !== mountAt && i !== mountAt + 1)); if (!appDir || !out || !mount) { console.error("usage: node scripts/snapshot.mjs <appDir> <out.snap> [--mount /app]"); process.exit(2); } const snap = snapshot(appDir, mount); const encoded = encodeSnapshot(snap); mkdirSync(dirname(resolve(out)), { recursive: true }); writeFileSync(out, encoded); console.log(`snapshot ${appDir} → ${out}: ${snap.files.length} files, ${encoded.length} bytes`);}