@stll/oxlint-config 0.12.2 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +234 -1
  2. package/dist/cloud-setup-cli.cjs +6 -4
  3. package/dist/cloud-setup-cli.cjs.map +1 -1
  4. package/dist/cloud-setup-cli.mjs +3 -1
  5. package/dist/cloud-setup-cli.mjs.map +1 -1
  6. package/dist/compiler-packages.cjs +28 -0
  7. package/dist/compiler-packages.cjs.map +1 -0
  8. package/dist/compiler-packages.mjs +17 -0
  9. package/dist/compiler-packages.mjs.map +1 -0
  10. package/dist/consumer-compat-cli.cjs +1091 -0
  11. package/dist/consumer-compat-cli.cjs.map +1 -0
  12. package/dist/consumer-compat-cli.d.cts +1 -0
  13. package/dist/consumer-compat-cli.d.mts +1 -0
  14. package/dist/consumer-compat-cli.mjs +1089 -0
  15. package/dist/consumer-compat-cli.mjs.map +1 -0
  16. package/dist/publish-build-target-nuxt-helper.cjs +71 -0
  17. package/dist/publish-build-target-nuxt-helper.cjs.map +1 -0
  18. package/dist/publish-build-target-nuxt-helper.d.cts +10 -0
  19. package/dist/publish-build-target-nuxt-helper.d.mts +10 -0
  20. package/dist/publish-build-target-nuxt-helper.mjs +68 -0
  21. package/dist/publish-build-target-nuxt-helper.mjs.map +1 -0
  22. package/dist/publish-build-target-vite-dts-helper.cjs +3 -0
  23. package/dist/publish-build-target-vite-dts-helper.d.cts +24 -0
  24. package/dist/publish-build-target-vite-dts-helper.d.mts +24 -0
  25. package/dist/publish-build-target-vite-dts-helper.mjs +2 -0
  26. package/dist/publish-build-target-vite-dts-helper2.cjs +372 -0
  27. package/dist/publish-build-target-vite-dts-helper2.cjs.map +1 -0
  28. package/dist/publish-build-target-vite-dts-helper2.mjs +359 -0
  29. package/dist/publish-build-target-vite-dts-helper2.mjs.map +1 -0
  30. package/dist/publish-contract-cli.cjs +983 -0
  31. package/dist/publish-contract-cli.cjs.map +1 -0
  32. package/dist/publish-contract-cli.d.cts +1 -0
  33. package/dist/publish-contract-cli.d.mts +1 -0
  34. package/dist/publish-contract-cli.mjs +981 -0
  35. package/dist/publish-contract-cli.mjs.map +1 -0
  36. package/dist/publish-contract.cjs +431 -0
  37. package/dist/publish-contract.cjs.map +1 -0
  38. package/dist/publish-contract.mjs +396 -0
  39. package/dist/publish-contract.mjs.map +1 -0
  40. package/dist/rolldown-runtime.cjs +28 -0
  41. package/dist/toolchain-changed-cli.cjs +34 -0
  42. package/dist/toolchain-changed-cli.cjs.map +1 -0
  43. package/dist/toolchain-changed-cli.d.cts +1 -0
  44. package/dist/toolchain-changed-cli.d.mts +1 -0
  45. package/dist/toolchain-changed-cli.mjs +34 -0
  46. package/dist/toolchain-changed-cli.mjs.map +1 -0
  47. package/dist/toolchain-changed.cjs +1470 -0
  48. package/dist/toolchain-changed.cjs.map +1 -0
  49. package/dist/toolchain-changed.mjs +1463 -0
  50. package/dist/toolchain-changed.mjs.map +1 -0
  51. package/dist/toolchain-check-cli.cjs +2 -1
  52. package/dist/toolchain-check-cli.cjs.map +1 -1
  53. package/dist/toolchain-check-cli.mjs +2 -1
  54. package/dist/toolchain-check-cli.mjs.map +1 -1
  55. package/dist/toolchain-guard.cjs +360 -1161
  56. package/dist/toolchain-guard.cjs.map +1 -1
  57. package/dist/toolchain-guard.mjs +338 -1100
  58. package/dist/toolchain-guard.mjs.map +1 -1
  59. package/dist/toolchain-inputs.cjs +926 -0
  60. package/dist/toolchain-inputs.cjs.map +1 -0
  61. package/dist/toolchain-inputs.mjs +816 -0
  62. package/dist/toolchain-inputs.mjs.map +1 -0
  63. package/dist/toolchain-schema.cjs +702 -0
  64. package/dist/toolchain-schema.cjs.map +1 -0
  65. package/dist/toolchain-schema.mjs +580 -0
  66. package/dist/toolchain-schema.mjs.map +1 -0
  67. package/dist/typecheck-parity-cli.cjs +38 -898
  68. package/dist/typecheck-parity-cli.cjs.map +1 -1
  69. package/dist/typecheck-parity-cli.mjs +39 -899
  70. package/dist/typecheck-parity-cli.mjs.map +1 -1
  71. package/dist/typecheck-parity.cjs +905 -0
  72. package/dist/typecheck-parity.cjs.map +1 -0
  73. package/dist/typecheck-parity.mjs +894 -0
  74. package/dist/typecheck-parity.mjs.map +1 -0
  75. package/dist/typecheck-probe-cli.cjs +176 -0
  76. package/dist/typecheck-probe-cli.cjs.map +1 -0
  77. package/dist/typecheck-probe-cli.d.cts +1 -0
  78. package/dist/typecheck-probe-cli.d.mts +1 -0
  79. package/dist/typecheck-probe-cli.mjs +174 -0
  80. package/dist/typecheck-probe-cli.mjs.map +1 -0
  81. package/package.json +43 -5
  82. package/toolchain.json +9 -1
@@ -1,912 +1,48 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- import { readFileSync, realpathSync, statSync } from "node:fs";
4
- import { spawnSync } from "node:child_process";
5
- import { basename, dirname, join, relative, resolve } from "node:path";
6
- import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";
7
- import { tmpdir } from "node:os";
8
- import { performance } from "node:perf_hooks";
9
- import { stripVTControlCharacters } from "node:util";
10
- //#region src/typecheck-parity.ts
11
- const fixtures = [
12
- {
13
- name: "module-detection",
14
- flags: ["noUnusedLocals"],
15
- files: { "input.ts": "const unused = 1;" },
16
- codes: [6133]
17
- },
18
- {
19
- name: "skip-declaration-check",
20
- flags: ["skipLibCheck"],
21
- files: { "input.d.ts": "export declare const value: MissingType;" },
22
- codes: []
23
- },
24
- {
25
- name: "json-import",
26
- flags: ["resolveJsonModule"],
27
- files: {
28
- "data.json": "{ \"name\": \"value\" }",
29
- "input.ts": "import data from \"./data.json\"; export const value: string = data.name;"
30
- },
31
- codes: []
32
- },
33
- {
34
- name: "interop-import",
35
- flags: ["esModuleInterop"],
36
- files: {
37
- "types.d.cts": "declare const value: string; export = value;",
38
- "input.ts": "import value from \"./types.cjs\"; export const result: string = value;"
39
- },
40
- codes: []
41
- },
42
- {
43
- name: "valid-control",
44
- flags: [],
45
- files: { "input.ts": "export const value: string = \"correct\";" },
46
- codes: []
47
- },
48
- {
49
- name: "type-mismatch",
50
- flags: [],
51
- files: { "input.ts": "export const value: number = \"wrong\";" },
52
- codes: [2322]
53
- },
54
- {
55
- name: "missing-property",
56
- flags: [],
57
- files: { "input.ts": "export const value: { name: string } = {};" },
58
- codes: [2741]
59
- },
60
- {
61
- name: "strict-null",
62
- flags: ["strictNullChecks"],
63
- files: { "input.ts": "export const value: string = null;" },
64
- codes: [2322]
65
- },
66
- {
67
- name: "unchecked-index",
68
- flags: ["noUncheckedIndexedAccess"],
69
- files: { "input.ts": "export const value: string = [\"value\"][1];" },
70
- codes: [2322]
71
- },
72
- {
73
- name: "unused-local",
74
- flags: ["noUnusedLocals"],
75
- files: { "input.ts": "const unused = 1; export {};" },
76
- codes: [6133]
77
- },
78
- {
79
- name: "unused-parameter",
80
- flags: ["noUnusedParameters"],
81
- files: { "input.ts": "export const value = (unused: string) => 1;" },
82
- codes: [6133]
83
- },
84
- {
85
- name: "implicit-any",
86
- flags: ["noImplicitAny"],
87
- files: { "input.ts": "export const value = (input) => input;" },
88
- codes: [7006]
89
- },
90
- {
91
- name: "missing-import",
92
- flags: [],
93
- files: { "input.ts": "import { value } from \"./missing.js\"; export { value };" },
94
- codes: [2307]
95
- },
96
- {
97
- name: "side-effect-import",
98
- flags: ["noUncheckedSideEffectImports"],
99
- files: { "input.ts": "import \"./missing.js\";" },
100
- codes: [2882]
101
- },
102
- {
103
- name: "generic-constraint",
104
- flags: [],
105
- files: { "input.ts": "type Box<T extends string> = { value: T }; export type Value = Box<number>;" },
106
- codes: [2344]
107
- },
108
- {
109
- name: "exact-optional",
110
- flags: ["exactOptionalPropertyTypes"],
111
- files: { "input.ts": "export const value: { optional?: string } = { optional: undefined };" },
112
- codes: [2375]
113
- },
114
- {
115
- name: "fallthrough",
116
- flags: ["noFallthroughCasesInSwitch"],
117
- files: { "input.ts": "export const run = (value: number) => { switch (value) { case 0: value++; case 1: return value; default: return 0; } };" },
118
- codes: [7029]
119
- },
120
- {
121
- name: "implicit-override",
122
- flags: ["noImplicitOverride"],
123
- files: { "input.ts": "class Base { value = 1; } export class Child extends Base { value = 2; }" },
124
- codes: [4114]
125
- },
126
- {
127
- name: "implicit-return",
128
- flags: ["noImplicitReturns"],
129
- files: { "input.ts": "export const run = (value: boolean) => { if (value) return 1; };" },
130
- codes: [7030]
131
- },
132
- {
133
- name: "unknown-catch",
134
- flags: ["useUnknownInCatchVariables"],
135
- files: { "input.ts": "export const run = () => { try { return 1; } catch (error) { return error.message; } };" },
136
- codes: [18046]
137
- },
138
- {
139
- name: "index-property",
140
- flags: ["noPropertyAccessFromIndexSignature"],
141
- files: { "input.ts": "export const run = (value: Record<string, string>) => value.name;" },
142
- codes: [4111]
143
- },
144
- {
145
- name: "erasable-syntax",
146
- flags: ["erasableSyntaxOnly"],
147
- files: { "input.ts": "export enum Value { First }" },
148
- codes: [1294]
149
- },
150
- {
151
- name: "type-only-import",
152
- flags: ["verbatimModuleSyntax"],
153
- files: {
154
- "types.ts": "export type Value = string;",
155
- "input.ts": "import { Value } from \"./types.js\"; export const value: Value = \"value\";"
156
- },
157
- codes: [1484]
158
- },
159
- {
160
- name: "checked-javascript",
161
- flags: ["allowJs", "checkJs"],
162
- files: { "input.js": "/** @type {number} */\nexport const value = \"wrong\";" },
163
- codes: [2322]
164
- },
165
- {
166
- name: "strict-function",
167
- flags: ["strictFunctionTypes"],
168
- files: { "input.ts": "export const value: (input: string | number) => void = (input: string) => { input.toUpperCase(); };" },
169
- codes: [2322]
170
- },
171
- {
172
- name: "strict-initialization",
173
- flags: ["strictPropertyInitialization"],
174
- files: { "input.ts": "export class Value { name: string; }" },
175
- codes: [2564]
176
- },
177
- {
178
- name: "strict-bind",
179
- flags: ["strictBindCallApply"],
180
- files: { "input.ts": "const value = (input: string) => input; export const result = value.call(undefined, 1);" },
181
- codes: [2345]
182
- },
183
- {
184
- name: "implicit-this",
185
- flags: ["noImplicitThis"],
186
- files: { "input.ts": "export function value() { return this.name; }" },
187
- codes: [2683]
188
- },
189
- {
190
- name: "strict-iterator",
191
- flags: ["strictBuiltinIteratorReturn"],
192
- files: { "input.ts": "export const value: string = [\"value\"].values().next().value;" },
193
- codes: [2322]
194
- },
195
- {
196
- name: "always-strict",
197
- flags: ["alwaysStrict"],
198
- files: { "input.ts": "export const value = (eval: string) => eval;" },
199
- codes: [1215]
200
- },
201
- {
202
- name: "file-casing",
203
- flags: ["forceConsistentCasingInFileNames"],
204
- files: {
205
- "named.ts": "export const name = \"value\";",
206
- "Named.ts": "export const name = \"value\";",
207
- "input.ts": "import { name } from \"./named.js\"; import { name as other } from \"./Named.js\"; export const value = name + other;"
208
- },
209
- codes: [1149, 1261],
210
- anyCode: true
211
- }
212
- ];
213
- const diagnosticCodes = (text) => [...new Set([...text.matchAll(/(?:TS|(?:error|warning)\s+)(\d{4,5})/g)].map((match) => Number(match.at(1))))].sort((a, b) => a - b);
214
- const diagnosticParity = ({ expected, match, baseline, candidate }) => {
215
- const tscCodes = diagnosticCodes(baseline.output);
216
- const bunCodes = diagnosticCodes(candidate.output);
217
- const seeded = match === "any" ? expected.some((code) => tscCodes.includes(code)) : expected.every((code) => tscCodes.includes(code));
218
- const missing = tscCodes.filter((code) => !bunCodes.includes(code));
219
- const extra = bunCodes.filter((code) => !tscCodes.includes(code));
220
- const exitsMatch = expected.length === 0 ? baseline.status === 0 && candidate.status === 0 && tscCodes.length === 0 && bunCodes.length === 0 : baseline.status !== null && baseline.status !== 0 && candidate.status !== null && candidate.status !== 0;
221
- return {
222
- tscCodes,
223
- bunCodes,
224
- missing,
225
- extra,
226
- passed: seeded && exitsMatch && baseline.status === candidate.status && missing.length === 0 && extra.length === 0
227
- };
228
- };
229
- const configurationDiagnostics = (output, repo) => diagnosticSet(output, repo).filter((diagnostic) => /^(?:<config>:0:|.*\.json:[0-9]+:)(?:[56][0-9]{3}|1800[23]|2688)(?::|$)/.test(diagnostic) || /:1800[23](?::|$)/.test(diagnostic));
230
- const fixtureParity = (options) => {
231
- const result = diagnosticParity(options);
232
- const { baseline, candidate, expected, match } = options;
233
- const identityParity = compareDiagnosticSets({
234
- status: baseline.status,
235
- diagnostics: diagnosticSet(baseline.output, options.repo ?? process.cwd())
236
- }, {
237
- status: candidate.status,
238
- diagnostics: diagnosticSet(candidate.output, options.repo ?? process.cwd())
239
- });
240
- const configDiagnostics = [...configurationDiagnostics(baseline.output, options.repo ?? process.cwd()).map((diagnostic) => `TypeScript: ${diagnostic}`), ...configurationDiagnostics(candidate.output, options.repo ?? process.cwd()).map((diagnostic) => `Bun: ${diagnostic}`)];
241
- const seedFiles = new Set(options.seedFiles.map((file) => resolve(options.repo ?? process.cwd(), file)));
242
- const seededCodes = new Set(diagnosticSet(baseline.output, options.repo ?? process.cwd()).flatMap((diagnostic) => {
243
- const diagnosticMatch = /^(.*):[0-9]+:([0-9]+)$/.exec(diagnostic);
244
- const file = diagnosticMatch?.at(1);
245
- const code = diagnosticMatch?.at(2);
246
- return file !== void 0 && code !== void 0 && seedFiles.has(resolve(options.repo ?? process.cwd(), file)) ? [Number(code)] : [];
247
- }));
248
- const active = expected.length > 0 && (match === "any" ? expected.some((code) => seededCodes.has(code)) : expected.every((code) => seededCodes.has(code)));
249
- const validExits = baseline.status !== null && candidate.status !== null && (result.tscCodes.length === 0 ? baseline.status === 0 : baseline.status !== 0) && (result.bunCodes.length === 0 ? candidate.status === 0 : candidate.status !== 0);
250
- return {
251
- ...result,
252
- active,
253
- configurationDiagnostics: configDiagnostics,
254
- identityMissing: identityParity.missing,
255
- identityExtra: identityParity.extra,
256
- passed: configDiagnostics.length === 0 && identityParity.passed && validExits && baseline.status === candidate.status && result.missing.length === 0 && result.extra.length === 0
257
- };
258
- };
259
- const fixtureRunPassed = (results) => results.some(({ active }) => active) && results.every(({ passed }) => passed);
260
- const diagnosticLocation = (file, repo) => {
261
- const normalized = file.replaceAll("\\", "/");
262
- const bundled = /^bundled:\/\/\/libs\/(lib\.[^/]+\.d\.ts)$/.exec(normalized);
263
- const installed = /(?:^|\/)node_modules\/(?:typescript|@typescript\/(?:native|typescript-[^/]+))\/(?:.*\/)?(lib\.[^/]+\.d\.ts)$/.exec(normalized);
264
- const library = bundled?.at(1) ?? installed?.at(1);
265
- return library === void 0 ? relative(repo, resolve(repo, file)).replaceAll("\\", "/") : `<lib>/${library}`;
266
- };
267
- const globalDiagnosticKey = (code, message) => `<config>:0:${code}:${message.trim().replaceAll(/\s+/g, " ")}`;
268
- const diagnosticSet = (output, repo) => {
269
- const clean = stripVTControlCharacters(output);
270
- const diagnostics = /* @__PURE__ */ new Set();
271
- for (const block of clean.matchAll(/<error\b([^>]*)>([\s\S]*?)<\/error>/g)) {
272
- const attributes = new Map([...(block.at(1) ?? "").matchAll(/(\w+)="([^"]*)"/g)].map((match) => [match.at(1), match.at(2)]));
273
- const file = attributes.get("file");
274
- const row = attributes.get("line");
275
- const code = attributes.get("code");
276
- if (code === void 0 || !/^TS\d+$/.test(code)) continue;
277
- if (file !== void 0 && row !== void 0 && row !== "0") diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code.slice(2)}`);
278
- else {
279
- const message = (block.at(2) ?? "").split(/<(?:source|related)\b/).at(0) ?? "";
280
- diagnostics.add(globalDiagnosticKey(code.slice(2), message));
281
- }
282
- }
283
- for (const line of clean.split("\n")) {
284
- if (line.startsWith("<error ")) continue;
285
- const match = /^(.*?)\((\d+),\d+\):\s*(?:error|warning) TS(\d+)/.exec(line) ?? /^(.*?):(\d+):\d+:\s*(?:error|warning) (?:TS)?(\d+)/.exec(line);
286
- if (match) {
287
- const [, file = "", row = "", code = ""] = match;
288
- diagnostics.add(`${diagnosticLocation(file, repo)}:${row}:${code}`);
289
- } else {
290
- const global = /^(?:error|warning) TS(\d+):\s*(.*)/.exec(line);
291
- if (global) diagnostics.add(globalDiagnosticKey(global.at(1) ?? "", global.at(2) ?? ""));
292
- }
293
- }
294
- return [...diagnostics].sort();
295
- };
296
- const compareDiagnosticSets = (baseline, candidate) => {
297
- const missing = baseline.diagnostics.filter((item) => !candidate.diagnostics.includes(item));
298
- const extra = candidate.diagnostics.filter((item) => !baseline.diagnostics.includes(item));
299
- const valid = (result) => result.status !== null && (result.diagnostics.length === 0 ? result.status === 0 : result.status !== 0);
300
- return {
301
- missing,
302
- extra,
303
- passed: valid(baseline) && valid(candidate) && baseline.status === candidate.status && missing.length === 0 && extra.length === 0
304
- };
305
- };
306
- const assertUnshadowedCheck = async (repo) => {
307
- const manifest = JSON.parse(await readFile(join(repo, "package.json"), "utf8"));
308
- if (typeof manifest !== "object" || manifest === null) throw new Error("Invalid repository package.json");
309
- if ("scripts" in manifest && typeof manifest.scripts === "object" && manifest.scripts !== null && "check" in manifest.scripts) throw new Error("Repository package.json must not define a \"check\" script: it shadows Bun typechecking; rename that script before running parity");
310
- };
311
- const resolveCompiler = async (repo, policy) => {
312
- if (typeof policy !== "object" || policy === null || !("typescriptInstallLayouts" in policy) || !Array.isArray(policy.typescriptInstallLayouts)) throw new Error("toolchain.json must define typescriptInstallLayouts");
313
- const manifest = JSON.parse(await readFile(join(repo, "package.json"), "utf8"));
314
- if (typeof manifest !== "object" || manifest === null) throw new Error("Invalid repository package.json");
315
- const dependencies = /* @__PURE__ */ new Map();
316
- for (const key of ["dependencies", "devDependencies"]) {
317
- if (!(key in manifest)) continue;
318
- const section = Reflect.get(manifest, key);
319
- if (typeof section === "object" && section !== null) for (const [name, specifier] of Object.entries(section)) dependencies.set(name, specifier);
320
- }
321
- const require = createRequire(join(repo, "package.json"));
322
- for (const layout of [...policy.typescriptInstallLayouts].reverse()) {
323
- if (typeof layout !== "object" || layout === null || !("compilerPackage" in layout) || typeof layout.compilerPackage !== "string") throw new Error("Invalid TypeScript install layout");
324
- if (!dependencies.has(layout.compilerPackage)) continue;
325
- const packagePath = require.resolve(`${layout.compilerPackage}/package.json`);
326
- const installed = JSON.parse(await readFile(packagePath, "utf8"));
327
- if (typeof installed !== "object" || installed === null || !("bin" in installed) || typeof installed.bin !== "object" || installed.bin === null || !("tsc" in installed.bin) || typeof installed.bin.tsc !== "string") throw new Error(`${layout.compilerPackage} must expose a tsc binary`);
328
- if (!("compilerSpecifier" in layout) || typeof layout.compilerSpecifier !== "string") throw new Error("TypeScript install layout must define compilerSpecifier");
329
- const expectedVersion = layout.compilerSpecifier.replace(/^npm:typescript@/, "");
330
- if (!("version" in installed) || installed.version !== expectedVersion) throw new Error(`${layout.compilerPackage} must install TypeScript ${expectedVersion}`);
331
- return resolve(packagePath, "..", installed.bin.tsc);
332
- }
333
- throw new Error("Repository must declare a compiler from typescriptInstallLayouts");
334
- };
335
- const assertBunVersion = (bun, policy) => {
336
- if (typeof policy !== "object" || policy === null || !("bun" in policy) || typeof policy.bun !== "string") throw new Error("toolchain.json must define bun");
337
- const result = spawnSync(bun, ["--version"], { encoding: "utf8" });
338
- if (result.error) throw result.error;
339
- const installed = result.stdout.trim();
340
- if (result.status !== 0 || installed !== policy.bun) throw new Error(`Bun must be ${policy.bun}; selected runtime reports ${installed || "no version"}`);
341
- };
342
- const bunCheckArgs = (project, build = false) => [
343
- "check",
344
- "--no-pretty",
345
- "--all",
346
- ...build ? ["--build"] : [],
347
- ...project === void 0 ? [] : [`--project=${project}`]
348
- ];
349
- const canonicalOptions = (value) => {
350
- if (Array.isArray(value)) return `[${value.map(canonicalOptions).join(",")}]`;
351
- if (typeof value === "object" && value !== null) return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalOptions(Reflect.get(value, key))}`).join(",")}}`;
352
- if (value !== null && typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") throw new Error("Invalid effective compiler option");
353
- return JSON.stringify(value);
354
- };
355
- const EMIT_ONLY_OPTIONS = /* @__PURE__ */ new Set([
356
- "composite",
357
- "declaration",
358
- "declarationDir",
359
- "declarationMap",
360
- "emitDeclarationOnly",
361
- "outDir",
362
- "outFile",
363
- "rootDir",
364
- "sourceMap",
365
- "inlineSourceMap",
366
- "inlineSources",
367
- "incremental",
368
- "tsBuildInfoFile",
369
- "noEmitOnError",
370
- "importHelpers",
371
- "noEmitHelpers",
372
- "emitBOM",
373
- "mapRoot",
374
- "sourceRoot",
375
- "newLine",
376
- "preserveConstEnums",
377
- "removeComments",
378
- "stripInternal",
379
- "downlevelIteration",
380
- "isolatedDeclarations",
381
- "noEmit"
382
- ]);
383
- const resolvedCompilerOptions = ({ compilerOptions, configPath }) => {
384
- if (typeof compilerOptions !== "object" || compilerOptions === null || Array.isArray(compilerOptions)) throw new Error(`Invalid compiler options: ${configPath}`);
385
- const options = Object.fromEntries(Object.entries(compilerOptions));
386
- const directory = dirname(configPath);
387
- const rootDir = options["rootDir"];
388
- if (rootDir !== void 0 && typeof rootDir !== "string") throw new Error(`Invalid rootDir: ${configPath}`);
389
- if (typeof rootDir === "string") options["rootDir"] = resolve(directory, rootDir);
390
- let resolutionDirectory = directory;
391
- const absolutePaths = (value) => {
392
- if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) throw new Error(`Invalid compiler path option: ${configPath}`);
393
- return value.map((entry) => resolve(resolutionDirectory, entry));
394
- };
395
- for (const name of ["rootDirs", "typeRoots"]) if (name in options) options[name] = absolutePaths(options[name]);
396
- if ("baseUrl" in options) {
397
- const baseUrl = options["baseUrl"];
398
- if (typeof baseUrl !== "string") throw new Error(`Invalid baseUrl: ${configPath}`);
399
- resolutionDirectory = resolve(directory, baseUrl);
400
- options["baseUrl"] = resolutionDirectory;
401
- }
402
- if ("paths" in options) {
403
- const paths = options["paths"];
404
- if (typeof paths !== "object" || paths === null || Array.isArray(paths)) throw new Error(`Invalid paths: ${configPath}`);
405
- options["paths"] = Object.fromEntries(Object.entries(paths).map(([key, value]) => [key, absolutePaths(value)]));
406
- }
407
- return options;
408
- };
409
- const fixtureCompilerOptions = (args) => {
410
- const options = Object.fromEntries(Object.entries(resolvedCompilerOptions(args)).filter(([name]) => !EMIT_ONLY_OPTIONS.has(name)));
411
- options["noEmit"] = true;
412
- return options;
413
- };
414
- const fixtureInputs = ({ files, compilerOptions }) => {
415
- const inputs = files.filter((file) => /\.(?:[cm]?[jt]sx?|json)$/.test(file));
416
- for (const input of inputs) {
417
- if (/\.[cm]?jsx?$/.test(input) && compilerOptions["allowJs"] !== true) return {
418
- status: "inapplicable",
419
- reason: `${input} requires allowJs`
420
- };
421
- if (input.endsWith(".json") && compilerOptions["resolveJsonModule"] !== true) return {
422
- status: "inapplicable",
423
- reason: `${input} requires resolveJsonModule`
424
- };
425
- }
426
- return {
427
- status: "applicable",
428
- files: inputs
429
- };
430
- };
431
- const fixturePackageContext = (configPath) => {
432
- for (let folder = dirname(configPath);; folder = dirname(folder)) {
433
- try {
434
- const manifest = JSON.parse(readFileSync(join(folder, "package.json"), "utf8"));
435
- if (typeof manifest !== "object" || manifest === null) throw new Error(`Invalid package.json: ${folder}`);
436
- if (!("type" in manifest)) return {};
437
- if (manifest.type !== "module" && manifest.type !== "commonjs") throw new Error(`Invalid package type: ${folder}`);
438
- return { type: manifest.type };
439
- } catch (error) {
440
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
441
- }
442
- if (dirname(folder) === folder) return {};
443
- }
444
- };
445
- const groupCompilerConfigs = (configs) => {
446
- const groups = /* @__PURE__ */ new Map();
447
- for (const config of configs) {
448
- const compilerOptions = fixtureCompilerOptions({
449
- compilerOptions: config.compilerOptions,
450
- configPath: config.path
451
- });
452
- const key = canonicalOptions({
453
- compilerOptions,
454
- resolutionContext: "typeRoots" in compilerOptions ? null : dirname(config.path),
455
- packageContext: config.packageContext ?? {}
456
- });
457
- const existing = groups.get(key);
458
- if (existing) existing.projects.push(config.path);
459
- else groups.set(key, {
460
- path: config.path,
461
- projects: [config.path],
462
- compilerOptions: config.compilerOptions,
463
- ...config.packageContext === void 0 ? {} : { packageContext: config.packageContext }
464
- });
465
- }
466
- return [...groups.values()];
467
- };
468
- const discoverConfigGroups = ({ repo, compiler, project }) => {
469
- const configs = [];
470
- const visited = /* @__PURE__ */ new Set();
471
- const projects = [];
472
- let build = false;
473
- const visit = (inputPath) => {
474
- const path = realpathSync(statSync(inputPath).isDirectory() ? join(inputPath, "tsconfig.json") : inputPath);
475
- readFileSync(path, "utf8");
476
- if (visited.has(path)) return;
477
- visited.add(path);
478
- const result = spawnSync(process.execPath, [
479
- compiler,
480
- "--showConfig",
481
- "--project",
482
- path
483
- ], {
484
- cwd: repo,
485
- encoding: "utf8",
486
- maxBuffer: 64 * 1024 * 1024
487
- });
488
- if (result.error) throw result.error;
489
- if (result.status !== 0) throw new Error(result.stdout + result.stderr);
490
- const config = JSON.parse(result.stdout);
491
- if (typeof config !== "object" || config === null) throw new Error(`Invalid resolved config: ${path}`);
492
- const references = "references" in config && Array.isArray(config.references) ? config.references : [];
493
- build ||= project === void 0 && references.length > 0;
494
- const compilerOptions = "compilerOptions" in config ? config.compilerOptions : {};
495
- if (typeof compilerOptions !== "object" || compilerOptions === null || Array.isArray(compilerOptions)) throw new Error(`Invalid compiler options: ${path}`);
496
- const rawFiles = "files" in config ? config.files : [];
497
- if (!Array.isArray(rawFiles)) throw new Error(`Invalid project files: ${path}`);
498
- const files = rawFiles.map((file) => {
499
- if (typeof file !== "string") throw new Error(`Invalid project file: ${path}`);
500
- return resolve(dirname(path), file);
501
- });
502
- if (files.length === 0 && (project !== void 0 || references.length === 0)) throw new Error(`Project resolves to zero input files: ${path}`);
503
- const referencePaths = [];
504
- const resolvedReferences = [];
505
- projects.push({
506
- path,
507
- compilerOptions,
508
- files,
509
- references: referencePaths,
510
- resolvedReferences
511
- });
512
- if (files.length > 0 || references.length === 0) configs.push({
513
- path,
514
- compilerOptions,
515
- packageContext: fixturePackageContext(path)
516
- });
517
- for (const reference of references) {
518
- if (typeof reference !== "object" || reference === null || !("path" in reference) || typeof reference.path !== "string") throw new Error(`Invalid project reference: ${path}`);
519
- const referencedProject = resolve(dirname(path), reference.path);
520
- const referencePath = realpathSync(statSync(referencedProject).isDirectory() ? join(referencedProject, "tsconfig.json") : referencedProject);
521
- referencePaths.push(referencePath);
522
- resolvedReferences.push({
523
- ...reference,
524
- path: referencePath
525
- });
526
- if (project === void 0) visit(referencePath);
527
- }
528
- };
529
- const selected = resolve(repo, project ?? "tsconfig.json");
530
- const root = realpathSync(statSync(selected).isDirectory() ? join(selected, "tsconfig.json") : selected);
531
- visit(root);
532
- const groups = groupCompilerConfigs(configs);
533
- if (groups.length === 0) throw new Error("No consumer compiler configurations to compare");
534
- return {
535
- build,
536
- groups,
537
- projects,
538
- root
539
- };
540
- };
541
- const discoverProjectGraphs = ({ repo, compiler, projects }) => {
542
- if (projects === void 0) return [discoverConfigGroups({
543
- repo,
544
- compiler
545
- })];
546
- if (projects.length === 0) throw new Error("Select at least one project");
547
- const graphs = /* @__PURE__ */ new Map();
548
- for (const project of projects) {
549
- const graph = discoverConfigGroups({
550
- repo,
551
- compiler,
552
- project
553
- });
554
- if (!graphs.has(graph.root)) graphs.set(graph.root, graph);
555
- }
556
- return [...graphs.values()];
557
- };
558
- const timedCommand = ({ command, args, repo }) => {
559
- const started = performance.now();
560
- const result = spawnSync("/usr/bin/time", [
561
- process.platform === "darwin" ? "-l" : "-v",
562
- command,
563
- ...args
564
- ], {
565
- cwd: repo,
566
- encoding: "utf8",
567
- maxBuffer: 64 * 1024 * 1024
568
- });
569
- if (result.error) throw result.error;
570
- const rss = process.platform === "darwin" ? /([0-9]+)\s+maximum resident set size/.exec(result.stderr) : /Maximum resident set size \(kbytes\):\s*([0-9]+)/.exec(result.stderr);
571
- if (!rss) throw new Error("Cannot measure maximum RSS with /usr/bin/time");
572
- return {
573
- status: result.status,
574
- output: result.stdout + result.stderr,
575
- wall: (performance.now() - started) / 1e3,
576
- maxRssKiB: Number(rss[1]) / (process.platform === "darwin" ? 1024 : 1)
577
- };
578
- };
579
- const NO_WORK_MAX_RSS_KIB = 16 * 1024;
580
- const NO_WORK_MAX_WALL_SECONDS = .25;
581
- const sourceDiagnosticSet = ({ output, repo, scratch, configPaths }) => {
582
- const configs = new Set(configPaths.map((path) => resolve(path)));
583
- const invalid = new Set(configurationDiagnostics(output, repo));
584
- return diagnosticSet(output, repo).filter((diagnostic) => {
585
- if (invalid.has(diagnostic)) return false;
586
- if (diagnostic.startsWith("<config>:")) return true;
587
- const file = /^(.*):[0-9]+:[0-9]+$/.exec(diagnostic)?.at(1);
588
- if (file === void 0) return false;
589
- const path = resolve(repo, file);
590
- return !configs.has(path) && path !== scratch && !path.startsWith(scratch + "/");
591
- });
592
- };
593
- const diagnosticExitStatus = ({ status, output, repo }) => status === 2 && configurationDiagnostics(output, repo).length === 0 && diagnosticSet(output, repo).some((diagnostic) => !diagnostic.startsWith("<config>:")) ? 1 : status;
594
- const repositoryDiagnosticComparison = ({ baseline, candidate, repo, scratch, configPaths }) => {
595
- const configs = new Set(configPaths.map((path) => resolve(path)));
596
- const configurationErrors = (output) => [.../* @__PURE__ */ new Set([...configurationDiagnostics(output, repo), ...diagnosticSet(output, repo).filter((diagnostic) => {
597
- const file = /^(.*):[0-9]+:[0-9]+$/.exec(diagnostic)?.at(1);
598
- return file !== void 0 && configs.has(resolve(repo, file));
599
- })])];
600
- const configurationErrorsFound = [...configurationErrors(baseline.output).map((diagnostic) => `TypeScript: ${diagnostic}`), ...configurationErrors(candidate.output).map((diagnostic) => `Bun: ${diagnostic}`)];
601
- const diagnostics = (output) => sourceDiagnosticSet({
602
- output,
603
- repo,
604
- scratch,
605
- configPaths
606
- });
607
- const comparison = compareDiagnosticSets({
608
- status: baseline.status,
609
- diagnostics: diagnostics(baseline.output)
610
- }, {
611
- status: candidate.status,
612
- diagnostics: diagnostics(candidate.output)
613
- });
614
- return {
615
- ...comparison,
616
- passed: configurationErrorsFound.length === 0 && comparison.passed,
617
- configurationDiagnostics: configurationErrorsFound
618
- };
619
- };
620
- const temporaryProjectTree = async ({ scratch, projects }) => {
621
- const contexts = /* @__PURE__ */ new Map();
622
- const linkedFolders = /* @__PURE__ */ new Set();
623
- for (const project of projects) {
624
- const path = join(scratch, "projects", relative(resolve("/"), project));
625
- const folder = dirname(path);
626
- await mkdir(folder, { recursive: true });
627
- for (let original = dirname(project);; original = dirname(original)) {
628
- if (!linkedFolders.has(original)) {
629
- linkedFolders.add(original);
630
- const modules = join(original, "node_modules");
631
- try {
632
- if (statSync(modules).isDirectory()) {
633
- const destination = join(scratch, "projects", relative(resolve("/"), original));
634
- await mkdir(destination, { recursive: true });
635
- await symlink(modules, join(destination, "node_modules"), "dir");
636
- }
637
- } catch (error) {
638
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
639
- }
640
- }
641
- if (dirname(original) === original) break;
642
- }
643
- contexts.set(project, {
644
- path,
645
- folder,
646
- outputFolder: join(folder, `${basename(path)}.parity-output`)
647
- });
648
- }
649
- return contexts;
650
- };
651
- const compareRepository = async ({ repo, compiler, bun, graph }) => {
652
- const scratch = await mkdtemp(join(tmpdir(), "parity-repository-"));
653
- try {
654
- const contexts = await temporaryProjectTree({
655
- scratch,
656
- projects: graph.projects.map(({ path }) => path)
657
- });
658
- const configPaths = new Map([...contexts].map(([original, context]) => [original, context.path]));
659
- const requiredOutputs = new Set(graph.projects.flatMap(({ references }) => references));
660
- for (const project of graph.projects) {
661
- const context = contexts.get(project.path);
662
- if (context === void 0) throw new Error(`Missing temporary project: ${project.path}`);
663
- const { path: configPath, outputFolder } = context;
664
- const options = resolvedCompilerOptions({
665
- configPath: project.path,
666
- compilerOptions: project.compilerOptions
667
- });
668
- const declarationsRequired = graph.build && requiredOutputs.has(project.path) && options["composite"] === true;
669
- options["noEmit"] = !graph.build || options["noEmit"] === true && !declarationsRequired;
670
- const relocatesOutput = options["noEmit"] !== true || "outDir" in options || "declarationDir" in options;
671
- if (!("rootDir" in options) && relocatesOutput) options["rootDir"] = dirname(project.path);
672
- if (relocatesOutput) options["outDir"] = join(outputFolder, "output");
673
- const emitsDeclarations = options["declaration"] === true || options["composite"] === true && options["declaration"] !== false;
674
- if (graph.build && emitsDeclarations || "declarationDir" in options) options["declarationDir"] = join(outputFolder, "declarations");
675
- if (graph.build || options["incremental"] === true || options["composite"] === true) options["tsBuildInfoFile"] = join(outputFolder, "project.tsbuildinfo");
676
- if (graph.build) {
677
- options["declarationMap"] = false;
678
- if (emitsDeclarations) options["emitDeclarationOnly"] = true;
679
- options["noEmitOnError"] = false;
680
- }
681
- if ("outFile" in options) options["outFile"] = join(outputFolder, "bundle.js");
682
- await writeFile(configPath, JSON.stringify({
683
- compilerOptions: options,
684
- files: project.files,
685
- include: [],
686
- references: graph.build ? project.references.map((path) => {
687
- const temporary = configPaths.get(path);
688
- if (temporary === void 0) throw new Error(`Missing referenced temporary project: ${path}`);
689
- return { path: temporary };
690
- }) : project.resolvedReferences
691
- }));
692
- }
693
- const root = configPaths.get(graph.root);
694
- if (root === void 0) throw new Error("Missing temporary root config");
695
- const baselineRaw = timedCommand({
696
- command: process.execPath,
697
- args: [
698
- compiler,
699
- ...graph.build ? [
700
- "--build",
701
- "--force",
702
- root
703
- ] : [
704
- "--noEmit",
705
- "--project",
706
- root
707
- ],
708
- "--pretty",
709
- "false"
710
- ],
711
- repo
712
- });
713
- const candidate = timedCommand({
714
- command: bun,
715
- args: bunCheckArgs(root, graph.build),
716
- repo
717
- });
718
- const sourceDiagnostics = (output) => sourceDiagnosticSet({
719
- output,
720
- repo,
721
- scratch,
722
- configPaths: graph.projects.map(({ path }) => path)
723
- });
724
- const baselineDiagnostics = sourceDiagnostics(baselineRaw.output);
725
- const baseline = {
726
- ...baselineRaw,
727
- rawStatus: baselineRaw.status,
728
- status: diagnosticExitStatus({
729
- status: baselineRaw.status,
730
- output: baselineRaw.output,
731
- repo
732
- }),
733
- diagnostics: baselineDiagnostics
734
- };
735
- const repository = repositoryDiagnosticComparison({
736
- baseline,
737
- candidate,
738
- repo,
739
- scratch,
740
- configPaths: [...graph.projects.map(({ path }) => path), ...configPaths.values()]
741
- });
742
- return {
743
- baseline,
744
- candidate: {
745
- ...candidate,
746
- rawStatus: candidate.status,
747
- diagnostics: sourceDiagnostics(candidate.output)
748
- },
749
- repository
750
- };
751
- } finally {
752
- await rm(scratch, {
753
- recursive: true,
754
- force: true
755
- });
756
- }
757
- };
758
- const runTypecheckParity = async ({ repo, policy, bun = process.versions.bun ? process.execPath : "bun", projects }) => {
759
- await assertUnshadowedCheck(repo);
760
- assertBunVersion(bun, policy);
761
- const compiler = await resolveCompiler(repo, policy);
762
- const graphs = discoverProjectGraphs({
763
- repo,
764
- compiler,
765
- projects
766
- });
767
- const results = [];
768
- for (const graph of graphs) results.push(await runConfigParity({
769
- repo,
770
- compiler,
771
- bun,
772
- graph
773
- }));
774
- return results.every((passed) => passed);
775
- };
776
- const runConfigParity = async ({ repo, compiler, bun, graph }) => {
777
- const { groups } = graph;
778
- const { baseline, candidate, repository } = await compareRepository({
779
- repo,
780
- compiler,
781
- bun,
782
- graph
783
- });
784
- console.log("Class | TypeScript diagnostics | Bun diagnostics | Result");
785
- console.log(`repository | ${baseline.diagnostics.join(",")} | ${candidate.diagnostics.join(",")} | ${repository.passed ? "PASS" : "FAIL"}`);
786
- console.log(`repository tsc: wall=${baseline.wall.toFixed(3)}s maxRSS=${baseline.maxRssKiB}KiB exit=${baseline.rawStatus}`);
787
- console.log(`repository bun: wall=${candidate.wall.toFixed(3)}s maxRSS=${candidate.maxRssKiB}KiB exit=${candidate.rawStatus}`);
788
- for (const diagnostic of repository.configurationDiagnostics) console.error(`FAIL: invalid repository configuration: ${diagnostic}`);
789
- const scratch = await mkdtemp(join(tmpdir(), "typecheck-parity-"));
790
- const groupResults = [];
791
- try {
792
- for (const [index, group] of groups.entries()) {
793
- console.log(`Config group ${index + 1}: ${relative(repo, group.path)} (${group.projects.length} projects)`);
794
- const results = [];
795
- let tscWall = 0;
796
- let bunWall = 0;
797
- let tscRss = 0;
798
- let bunRss = 0;
799
- const context = (await temporaryProjectTree({
800
- scratch: join(scratch, `config-${index + 1}`),
801
- projects: [group.path]
802
- })).get(group.path);
803
- if (context === void 0) throw new Error(`Missing temporary fixture context: ${group.path}`);
804
- const groupFolder = context.folder;
805
- const compilerOptions = fixtureCompilerOptions({
806
- compilerOptions: group.compilerOptions,
807
- configPath: group.path
808
- });
809
- await writeFile(join(groupFolder, "package.json"), JSON.stringify(group.packageContext ?? fixturePackageContext(group.path)));
810
- for (const fixture of fixtures) {
811
- const inputs = fixtureInputs({
812
- files: Object.keys(fixture.files),
813
- compilerOptions
814
- });
815
- if (inputs.status === "inapplicable") {
816
- console.log(`${fixture.name} (inactive under this config: ${inputs.reason}) | | | INACTIVE`);
817
- continue;
818
- }
819
- const folder = join(groupFolder, fixture.name);
820
- await mkdir(folder);
821
- await writeFile(join(folder, "tsconfig.json"), JSON.stringify({
822
- compilerOptions,
823
- files: inputs.files,
824
- include: [],
825
- exclude: []
826
- }));
827
- for (const [name, content] of Object.entries(fixture.files)) await writeFile(join(folder, name), content);
828
- const tsc = timedCommand({
829
- command: process.execPath,
830
- args: [
831
- compiler,
832
- "--noEmit",
833
- "--pretty",
834
- "false",
835
- "-p",
836
- folder
837
- ],
838
- repo: folder
839
- });
840
- const checked = timedCommand({
841
- command: bun,
842
- args: [...bunCheckArgs(folder), "--threads=1"],
843
- repo: folder
844
- });
845
- const result = fixtureParity({
846
- seedFiles: inputs.files,
847
- expected: fixture.codes,
848
- match: fixture.anyCode ? "any" : "all",
849
- repo: folder,
850
- baseline: {
851
- ...tsc,
852
- status: diagnosticExitStatus({
853
- status: tsc.status,
854
- output: tsc.output,
855
- repo: folder
856
- })
857
- },
858
- candidate: checked
859
- });
860
- results.push(result);
861
- tscWall += tsc.wall;
862
- bunWall += checked.wall;
863
- tscRss = Math.max(tscRss, tsc.maxRssKiB);
864
- bunRss = Math.max(bunRss, checked.maxRssKiB);
865
- if (result.configurationDiagnostics.length > 0) {
866
- console.error(`FAIL: invalid fixture configuration for ${fixture.name}: ${result.configurationDiagnostics.join("; ")}`);
867
- console.log(`${fixture.name} | configuration error | configuration error | FAIL`);
868
- continue;
869
- }
870
- let outcome = "INACTIVE";
871
- if (result.active) outcome = result.passed ? "PASS" : "FAIL";
872
- console.log(`${fixture.name}${result.active ? "" : " (inactive under this config)"} | ${result.tscCodes.join(",")} | ${result.bunCodes.join(",")} | ${outcome}`);
873
- if (!result.active && !result.passed) console.error(`FAIL: diagnostic comparison differs for inactive class ${fixture.name}: TypeScript exit=${tsc.status}, Bun exit=${checked.status}; missing=${result.identityMissing.join(",")}; extra=${result.identityExtra.join(",")}`);
874
- if (result.active && result.bunCodes.length === 0) {
875
- console.error(`FAIL: Bun returned zero diagnostics for active class ${fixture.name} (exit ${checked.status})`);
876
- if (checked.maxRssKiB <= NO_WORK_MAX_RSS_KIB && checked.wall <= NO_WORK_MAX_WALL_SECONDS) console.error(`Bun measured little checker work: wall=${checked.wall.toFixed(3)}s maxRSS=${checked.maxRssKiB}KiB; verify the checker invocation`);
877
- }
878
- }
879
- console.log(`fixtures tsc: wall=${tscWall.toFixed(3)}s maxRSS=${tscRss}KiB`);
880
- console.log(`fixtures bun: wall=${bunWall.toFixed(3)}s maxRSS=${bunRss}KiB`);
881
- if (!results.some(({ active }) => active)) console.error(`FAIL: zero seeded fixture classes active under config group ${index + 1}`);
882
- groupResults.push(fixtureRunPassed(results));
883
- }
884
- } finally {
885
- await rm(scratch, {
886
- recursive: true,
887
- force: true
888
- });
889
- }
890
- return repository.passed && groupResults.every((passed) => passed);
891
- };
892
- //#endregion
2
+ import { n as runTypecheckParity } from "./typecheck-parity.mjs";
3
+ import { t as detectToolchainChanges } from "./toolchain-changed.mjs";
4
+ import { readFile } from "node:fs/promises";
893
5
  //#region src/typecheck-parity-args.ts
894
- const parityUsage = "Usage: stll-typecheck-parity [--project <tsconfig>]... (run from repository root)\n stll-typecheck-parity --help";
6
+ const parityUsage = "Usage: stll-typecheck-parity [--changed-since <git-ref>] [--project <tsconfig>]... (run from repository root)\n stll-typecheck-parity --help";
895
7
  const parseParityArguments = (args) => {
896
8
  if (args.length === 1 && args.at(0) === "--help") return { mode: "help" };
897
9
  const projects = [];
10
+ let changedSince;
898
11
  for (let index = 0; index < args.length; index += 1) {
899
12
  const project = args.at(index + 1);
900
- if (args.at(index) !== "--project" || project === void 0 || project.trim() === "" || project.startsWith("--")) throw new Error(parityUsage);
901
- projects.push(project);
13
+ const option = args.at(index);
14
+ if (option !== "--project" && option !== "--changed-since" || project === void 0 || project.trim() === "" || project.startsWith("--")) throw new Error(parityUsage);
15
+ if (option === "--project") projects.push(project);
16
+ else {
17
+ if (changedSince !== void 0) throw new Error(parityUsage);
18
+ changedSince = project;
19
+ }
902
20
  index += 1;
903
21
  }
904
- return projects.length === 0 ? { mode: "default" } : {
22
+ return projects.length === 0 ? {
23
+ mode: "default",
24
+ ...changedSince === void 0 ? {} : { changedSince }
25
+ } : {
905
26
  mode: "selected",
906
- projects
27
+ projects,
28
+ ...changedSince === void 0 ? {} : { changedSince }
907
29
  };
908
30
  };
909
31
  //#endregion
32
+ //#region src/typecheck-parity-selection.ts
33
+ /** CI forcing considers every tool; compiler parity includes Bun, TS, and unclassified shared declarations. */
34
+ const runSelectedTypecheckParity = async ({ repo, since, run, detect = detectToolchainChanges, output = (text) => process.stdout.write(text) }) => {
35
+ if (since === void 0) return run();
36
+ const result = await detect({
37
+ repo,
38
+ since
39
+ });
40
+ if (result.status === "unreadable") return run();
41
+ if (result.tools.some((tool) => tool === "bun" || tool === "typescript" || tool === "shared")) return run();
42
+ output(`parity skipped: toolchain unchanged since ${since} (bun ${result.current.bun.join(", ") || "not declared"}, typescript ${result.current.typescript.join(", ") || "not declared"})\n`);
43
+ return true;
44
+ };
45
+ //#endregion
910
46
  //#region src/typecheck-parity-cli.ts
911
47
  const main = async () => {
912
48
  const args = parseParityArguments(process.argv.slice(2));
@@ -915,10 +51,14 @@ const main = async () => {
915
51
  return;
916
52
  }
917
53
  const policy = JSON.parse(await readFile(new URL("../toolchain.json", import.meta.url), "utf8"));
918
- if (!await runTypecheckParity({
54
+ if (!await runSelectedTypecheckParity({
919
55
  repo: process.cwd(),
920
- policy,
921
- ...args.mode === "selected" ? { projects: args.projects } : {}
56
+ since: args.changedSince,
57
+ run: () => runTypecheckParity({
58
+ repo: process.cwd(),
59
+ policy,
60
+ ...args.mode === "selected" ? { projects: args.projects } : {}
61
+ })
922
62
  })) process.exitCode = 1;
923
63
  };
924
64
  main().catch((error) => {