Versions 37 to 38
new file, 214 lines
4+// - runs the client: a plain-JS bundle of it in this process when one matches the checkout's commit,
5+// otherwise client/abso.ts in a second node. Node strips types from every client file on every run,
7+// - at most every 5 minutes, and within 30 seconds of a stale bundle, starts a background step that
8+// fast-forwards the checkout (on main only), runs npm install when package-lock.json changed, and
11+// stdin, stdout, stderr, the arguments and the exit code pass through untouched: the exit codes carry
12+// meaning (2 refused, 3 still queued). The launcher's own notices go only to ~/.abso/launcher.log.
14+// The bundle is client/dist/abso.mjs, with the commit it was built from in client/dist/abso.mjs.commit.
15+// It sits one folder under client/, so the client's own folder (client-version.ts) is still client/.
16+// It is built with esbuild when the checkout has it (in worker/ or at the root): bundled, for node24,
17+// as an ES module, with no build commit stamped in, since a stamped client calls itself a downloaded
18+// copy. It is built to a temporary file and renamed into place, and marked current only after every
19+// require left in it resolves and it runs --version. If it still fails to load, the same run falls
24+import { appendFileSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
29+
38+/** Set by the bundle's first line: an error after it came from the command, so it's never run again. */
40+
59+
63+ if (Date.now() - statSync(lock).mtimeMs > 10 * 60 * 1000) rmSync(lock, { recursive: true, force: true });
76+
81+ appendFileSync(join(state, "launcher.log"), `${new Date().toISOString()} abso launch: ${text}\n`);
84+
86+ * The background step, one at a time under a lock (a second one finds it taken and exits): fast-forward,
90+ const git = (...a) => execFileSync("git", ["-C", repo, ...a], { encoding: "utf8", windowsHide: true });
110+ note(`the bundle wasn't built (${String(e?.message).split("\n")[0]}); client/abso.ts runs until it is`);
114+
115+/** Builds the bundle for this commit, unless it's already current or the checkout has no esbuild. */
146+ js: `globalThis.${STARTED} = true; import { createRequire as __absoCreateRequire } from "node:module"; const require = __absoCreateRequire(import.meta.url);`,
150+ for (const m of readFileSync(tmp, "utf8").matchAll(/__require\("([^"]+)"\)/g)) from.resolve(m[1]);
151+ execFileSync(process.execPath, [tmp, "--version"], { cwd: repo, stdio: "ignore", windowsHide: true });
158+
161+ const child = spawn(process.execPath, [join(repo, "client", "abso.ts"), ...process.argv.slice(2)], {
166+
167+/** Starts the background step when it's due: every 5 minutes, or within 30 seconds of a stale bundle. */
185+
195+ // In this process: the client reads its arguments from process.argv, as if run as `node client/dist/abso.mjs`.
205+ e instanceof SyntaxError || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_ESM_URL_SCHEME";
207+ note(`the bundle didn't load (${code ?? e?.name}: ${String(e?.message).split("\n")[0]}), ran client/abso.ts`);
212+
- MCP
- compare on this site's /mcp
- CLI
- abso diff 37 38 client/launch.mjs --json
- JSON
- /christopher/abso-core/compare/37..38?file=client%2Flaunch.mjs&format=json