33 lines · 1.7 KB · TypeScriptRaw
import { mkdirSync, writeFileSync } from "node:fs";import { join } from "node:path";// Tiny generator/compiler stand-ins let landing guards exercise real git pushes// without building Rust in every synthetic checkout. Their failures stay fatal.export function installLandingExtraction(repo: string, scratch: string) { mkdirSync(join(repo, "crates/cotton-core/kits/personal/tables"), { recursive: true }); mkdirSync(join(repo, "crates/cotton-store/src/schema"), { recursive: true }); writeFileSync(join(repo, "crates/cotton-store/src/schema/builtin_tables.json"), "{}\n"); writeFileSync(join(repo, "crates/cotton-core/kits/personal/tables/synthetic.json"), "seed\n"); writeFileSync(join(repo, "scripts/package-tables.py"), `import osfrom pathlib import Pathif os.environ.get('LAND_GENERATOR_FAIL'): raise SystemExit(1)source = Path('input.txt')if source.exists(): Path('crates/cotton-core/kits/personal/tables/synthetic.json').write_text(source.read_text())log = os.environ.get('LAND_EVENTS')if log: with open(log, 'a') as stream: stream.write('generate\\n')`); const bin = join(scratch, "bin"); mkdirSync(bin); writeFileSync(join(bin, "cargo"), `#!/bin/bash[ "$*" = "+1.98.1 check -p cotton-store" ] || exit 90[ "$(cat cotton-core/kits/personal/tables/synthetic.json)" = "$(cat ../input.txt 2>/dev/null || echo seed)" ] || exit 91[ -z "$LAND_EVENTS" ] || echo compile >> "$LAND_EVENTS"[ -z "$LAND_COMPILE_FAIL" ]`, { mode: 0o755 }); // The fake compiler must also satisfy the toolchain admission guard on Linux, // where scratch HOME has no rustup installation and PATH may omit the host one. writeFileSync(join(bin, "rustc"), "#!/bin/bash\nexit 0\n", { mode: 0o755 }); return bin;}