Versions 96 to 97
new file, 239 lines
1+// The check for what a change reaches, for running by hand before a publish. The full check (abso.json's)
2+// still runs on every publish, in the merge queue; this one is only the quick local run, so agents don't run
5+// npm run check:changed [-- file ...] (paths from the repo root; none: this folder's draft, from abso diff
9+// - tests: every test file that imports a changed file, through any number of imports, plus changed test
10+// files themselves. A changed file that isn't code (a fixture, a saved log) brings in the test files that
12+// - typecheck: tsconfig.json, when it includes a changed file or anything that imports one, incrementally
15+// A change to setup (package.json, the lockfile, tsconfig.json, abso.json, biome.json) runs the full check.
22+
24+
25+/** Test runs: a folder, the test globs its npm test uses (from that folder), and node's extra arguments. */
29+ globs: ["src/**/*.test.ts", "worker/project/**/*.test.ts", "client/test/**/*.test.ts", "scripts/**/*.test.ts"],
47+
50+
51+/** Every file under the repo, posix paths from the root, skipping dependency and build folders. */
62+
64+ * Each code file's imports, kept between runs in node_modules/.cache by the file's time and size, so a run
88+
89+/** The files a code file imports, as repo paths (relative imports only; packages can't change in a draft). */
93+ const re = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["'](\.{1,2}\/[^"']+)["']/g;
97+ for (const c of [base, `${stem}.ts`, `${stem}.tsx`, `${stem}.mts`, `${base}.ts`, `${base}.tsx`, `${base}/index.ts`])
105+
106+/** This folder's changed files: the draft's, from abso diff, and edits not yet recorded, from abso status. */
109+ // One command string: abso is a .cmd on Windows, which needs a shell, and the args are fixed words.
111+ if (r.status !== 0) throw new Error(`abso ${args.join(" ")} failed: ${(r.stderr || r.stdout).trim()}`);
115+ for (const m of run(["diff"]).matchAll(/^(?:\+\+\+ b|--- a)\/(.+)$/gm)) files.add(m[1].trim());
120+
121+/** What the changed files reach: test files to run per test group, tsconfigs to check, files for biome. */
124+ if (changed.some((f) => matches(f, SETUP))) return { full: changed.filter((f) => matches(f, SETUP)) };
131+ for (const by of importers.get(queue.pop()) ?? []) if (!reached.has(by)) reached.add(by), queue.push(by);
137+ (t.cwd === "." || f.startsWith(`${t.cwd}/`)) && matches(t.cwd === "." ? f : f.slice(t.cwd.length + 1), t.globs),
142+ for (const t of allTests) if (readFileSync(join(root, t), "utf8").includes(name)) reached.add(t);
149+ const cfg = ts.readConfigFile(join(root, c.tsconfig), (p) => readFileSync(p, "utf8")).config ?? {};
155+ const lint = changed.filter((f) => known.has(f) && /\.(m?[jt]sx?|cjs|json|jsonc|css)$/.test(f));
158+
170+
217+ args: [join(root, "node_modules/@biomejs/biome/bin/biome"), "check", "--no-errors-on-unmatched", ...p.lint],
223+ ` ${j.name}${j.name.startsWith("test") ? `: ${j.args.filter((a) => /\.test\./.test(a)).join(" ")}` : ""}`,
230+ results.push(...(await Promise.all(jobs.slice(i, i + slots).map((j) => runOne(j.name, j.cmd, j.args, j.cwd)))));
231+ for (const r of results.filter((r) => r.code !== 0)) console.log(`\n--- ${r.name} failed ---\n${r.out.trimEnd()}`);
234+ console.log(`${r.code === 0 ? "ok " : "FAIL"} ${(r.ms / 1000).toFixed(1).padStart(6)} s ${r.name}`);
235+ console.log(`${((Date.now() - started) / 1000).toFixed(1)} s in all. The full check runs when you publish.`);
238+
239+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();
- MCP
- compare on this site's /mcp
- CLI
- abso diff 96 97 scripts/check-changed.mjs --json
- JSON
- /christopher/abso-core/compare/96..97?file=scripts%2Fcheck-changed.mjs&format=json