Files
supergeometry.app/scripts/live.ts
T
superGeometry 60c66fd731 Tools for checking the app: sg in the console, a project checker, pictures without a browser, a shared test kit, version.json
- sg (the browser's console): the project, tool, hint, open window,
  selection, errors and bodies in one look; pick things by name; list and
  run what's offered; read and set the open window's rows (slots, numbers,
  choices, toggles); give a waiting slot a face or edge; Done / Cancel;
  wait for the engine; each body's health; open a project. sg.help() lists it.
- npm run check <project>: rebuilds it step by step and says what each step
  made, changed or took away, its error, and how sound each body is.
- npm run render <project> <out.png>: a shaded picture with edges from any
  side, drawn without a browser.
- tests/kit.ts: the engine started once, check / done, and quick sketches,
  shapes and steps (wrap.test.ts uses it).
- version.json on the site: the commit it was built from; npm run live says
  whether main is live (--wait until it is).
- The engine measures each body's health on request (valid, closed, solids,
  faces, volume, box).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 21:23:25 +02:00

53 lines
1.7 KiB
TypeScript

// Is the push live? Compares the commit supergeometry.app was built from
// (its /version.json) with main here.
//
// npx tsx scripts/live.ts once
// npx tsx scripts/live.ts --wait until it is (up to 20 minutes)
// npx tsx scripts/live.ts --site http://localhost:4173
import { execSync } from "node:child_process";
const args = process.argv.slice(2);
const site = (args.includes("--site") ? args[args.indexOf("--site") + 1] : "https://supergeometry.app").replace(/\/$/, "");
const git = (cmd: string) => {
try {
return execSync(`git ${cmd}`, { stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
} catch {
return "";
}
};
const want = git("rev-parse origin/main");
const short = (c: string) => c.slice(0, 7);
interface Version {
version: string;
commit: string;
subject: string;
script: string;
built: string;
}
async function live(): Promise<Version | null> {
try {
const r = await fetch(`${site}/version.json?t=${Date.now()}`, { cache: "no-store" });
if (!r.ok) return null;
return (await r.json()) as Version;
} catch {
return null;
}
}
const until = Date.now() + 20 * 60_000;
for (;;) {
const v = await live();
if (v?.commit && v.commit === want) {
console.log(`Live: ${short(v.commit)} ${v.subject} (built ${v.built}, ${v.script})`);
process.exit(0);
}
if (!args.includes("--wait") || Date.now() > until) {
if (!v) console.log(`${site} has no version.json yet (built before it was added), main is ${short(want)}`);
else console.log(`Not live yet: the site is ${short(v.commit)} ${v.subject} (built ${v.built}), main is ${short(want)} ${git(`log -1 --format=%s ${want}`)}`);
process.exit(1);
}
await new Promise((r) => setTimeout(r, 20_000));
}