@antelopejs/tooling-configs 0.7.3 → 0.7.5-next.356.g0d472b3

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 (48) hide show
  1. package/README.md +63 -80
  2. package/dist/bin/api-diff.mjs +29 -49
  3. package/dist/bin/capture.mjs +4 -4
  4. package/dist/bin/check-size.mjs +12 -3
  5. package/dist/bin/checks.mjs +2 -2
  6. package/dist/bin/comment-proof.mjs +3 -4
  7. package/dist/bin/garden.mjs +45 -170
  8. package/dist/bin/readme-strip.mjs +2 -2
  9. package/dist/bin/suppressions.mjs +212 -9
  10. package/dist/bin/sync.mjs +318 -210
  11. package/dist/bin/tsc.mjs +24 -0
  12. package/dist/bin/verify.mjs +91 -671
  13. package/dist/{checks-CSlWvky1.mjs → checks-C60vMFin.mjs} +155 -310
  14. package/dist/{docs-compat-BAZiPLZt.mjs → docs-compat-CdgBviGf.mjs} +2 -2
  15. package/dist/eslint.mjs +1 -1
  16. package/dist/{files-C-JJhExM.mjs → files-BbzJEk-L.mjs} +5 -4
  17. package/dist/formal/index.mjs +1 -1
  18. package/dist/{guardrails-nj7NTglr.mjs → guardrails-Dron1AbR.mjs} +67 -673
  19. package/dist/{installed-typescript-6MtIWlE4.mjs → installed-typescript-CF_FR9DV.mjs} +17 -17
  20. package/dist/{map-BYkmnvNw.mjs → map-CbNbypUa.mjs} +2 -2
  21. package/dist/oxc/anti-slop/index.mjs +22 -964
  22. package/dist/oxc/guardrails/index.d.mts +1 -1
  23. package/dist/oxc/guardrails/index.mjs +1 -1
  24. package/dist/oxc/lint.d.mts +2 -14
  25. package/dist/oxc/lint.mjs +3 -20
  26. package/dist/{package-DDG3YH7W.mjs → package-7oylgBeT.mjs} +6 -19
  27. package/dist/{workflow-C-oBwL2H.mjs → renovate-D0su_v9p.mjs} +191 -91
  28. package/dist/{suppression-budget-CPDSFg4X.mjs → suppression-budget-De9nUzlD.mjs} +33 -13
  29. package/dist/{suppressions-CxPnh4sC.mjs → suppressions-CfJwL0fN.mjs} +6 -2
  30. package/dist/{templates-HG0fel2S.mjs → templates-DLW0Ubfk.mjs} +26 -29
  31. package/dist/typescript-C7eU-cig.mjs +581 -0
  32. package/dist/typescript-version-CptQKjGz.mjs +18 -0
  33. package/dist/typescript6-BWqCcXGY.mjs +2 -0
  34. package/dist/typescript6-HdyOMBv3.mjs +8 -0
  35. package/dist/verify/index.d.mts +5 -24
  36. package/package.json +27 -7
  37. package/dist/bin/body-check.mjs +0 -350
  38. package/dist/bin/ratchet.d.mts +0 -1
  39. package/dist/bin/ratchet.mjs +0 -375
  40. package/dist/ceilings-B7KayYIG.mjs +0 -76
  41. package/dist/oxlint-CIeonWMB.mjs +0 -133
  42. package/dist/proof-stamp-BFV7JTZT.mjs +0 -342
  43. package/dist/ratchet-DLCfeaPY.mjs +0 -453
  44. package/dist/renames-L2owF5GD.mjs +0 -59
  45. package/dist/size-CCGLY4Ke.mjs +0 -18
  46. package/dist/suppression-base-CYaLZAq7.mjs +0 -120
  47. package/dist/typescript-QfxkJYzd.mjs +0 -292
  48. /package/dist/bin/{body-check.d.mts → tsc.d.mts} +0 -0
@@ -1,342 +0,0 @@
1
- import { s as parseManifest } from "./package-DDG3YH7W.mjs";
2
- import { l as resolveRevision, u as trackedManifests } from "./files-C-JJhExM.mjs";
3
- import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-CxPnh4sC.mjs";
4
- import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync } from "node:fs";
5
- import { dirname, isAbsolute, join, matchesGlob, relative, sep } from "node:path";
6
- import { execFileSync, spawnSync } from "node:child_process";
7
- import { createHash } from "node:crypto";
8
- import { tmpdir } from "node:os";
9
- //#region src/guardrails/added-entries.ts
10
- function createAddedPolicy(globs) {
11
- return {
12
- globs,
13
- verdicts: /* @__PURE__ */ new Map(),
14
- allowed: /* @__PURE__ */ new Map(),
15
- problems: /* @__PURE__ */ new Set()
16
- };
17
- }
18
- function entryKey(directory, subpath) {
19
- return `${directory}\0${subpath}`;
20
- }
21
- function allowedByGlob(policy, subpath) {
22
- return policy.globs.some((glob) => matchesGlob(subpath, glob));
23
- }
24
- /** Substitutes each export star in order with its capture, as the published target pattern did. */
25
- function fillStars(pattern, captures, format = (capture) => capture) {
26
- let index = 0;
27
- return pattern.replaceAll("*", () => format(captures[index++] ?? captures[0] ?? ""));
28
- }
29
- const INTERNAL_TAG = /@internal\b/u;
30
- const MODULE_TAG = /@(?:packageDocumentation|module|fileoverview)\b/u;
31
- function exportedLocalNames(compiler, source) {
32
- const names = /* @__PURE__ */ new Set();
33
- for (const statement of source.statements) {
34
- if (compiler.isExportDeclaration(statement) && statement.moduleSpecifier === void 0 && statement.exportClause !== void 0 && compiler.isNamedExports(statement.exportClause)) for (const element of statement.exportClause.elements) names.add((element.propertyName ?? element.name).text);
35
- if (compiler.isExportAssignment(statement) && compiler.isIdentifier(statement.expression)) names.add(statement.expression.text);
36
- }
37
- return names;
38
- }
39
- function declaredNames(compiler, statement) {
40
- if (compiler.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => compiler.isIdentifier(declaration.name) ? [declaration.name.text] : []);
41
- if ((compiler.isFunctionDeclaration(statement) || compiler.isClassDeclaration(statement) || compiler.isInterfaceDeclaration(statement) || compiler.isTypeAliasDeclaration(statement) || compiler.isEnumDeclaration(statement) || compiler.isModuleDeclaration(statement)) && statement.name !== void 0 && compiler.isIdentifier(statement.name)) return [statement.name.text];
42
- return [];
43
- }
44
- function isExportedDeclaration(compiler, statement, locals) {
45
- if (compiler.isExportAssignment(statement)) return !compiler.isIdentifier(statement.expression);
46
- if ((compiler.canHaveModifiers(statement) ? compiler.getModifiers(statement) : void 0)?.some((modifier) => modifier.kind === compiler.SyntaxKind.ExportKeyword)) return true;
47
- return declaredNames(compiler, statement).some((name) => locals.has(name));
48
- }
49
- function hasInternalTag(compiler, statement) {
50
- return compiler.getJSDocTags(statement).some((tag) => tag.tagName.text === "internal");
51
- }
52
- /** Whether a module's text carries `@internal` on the module (with `@packageDocumentation`, `@module` or `@fileoverview`) or on every exported declaration. */
53
- function isInternalModule(compiler, text) {
54
- const source = compiler.createSourceFile("module.ts", text, compiler.ScriptTarget.Latest, true);
55
- if ((compiler.getLeadingCommentRanges(text, 0) ?? []).map((range) => text.slice(range.pos, range.end)).some((comment) => comment.startsWith("/**") && INTERNAL_TAG.test(comment) && MODULE_TAG.test(comment))) return true;
56
- const locals = exportedLocalNames(compiler, source);
57
- const exported = source.statements.filter((statement) => isExportedDeclaration(compiler, statement, locals));
58
- return exported.length > 0 && exported.every((statement) => hasInternalTag(compiler, statement));
59
- }
60
- /** Records why an allowed added entry is not internal, or `undefined` when its module is. */
61
- function recordVerdict(policy, compiler, entry) {
62
- const internal = isInternalModule(compiler, readFileSync(entry.module, "utf8"));
63
- policy.verdicts.set(entryKey(entry.directory, entry.subpath), internal ? void 0 : `${entry.label}: added entry ./${entry.subpath} is allowed by --allow-added but is not marked @internal. Add a leading "/** @internal @packageDocumentation */" comment to the file, or tag every exported declaration with "/** @internal */".`);
64
- }
65
- /** Lets matching, `@internal` additions through by removing them from the head output; returns how many files were removed. */
66
- function applyAllowance(policy, base, head, remove) {
67
- const existing = new Set(base.map(({ path }) => path));
68
- let removed = 0;
69
- for (const entry of head) {
70
- if (existing.has(entry.path) || !allowedByGlob(policy, entry.subpath)) continue;
71
- const key = entryKey(entry.directory, entry.subpath);
72
- const problem = policy.verdicts.has(key) ? policy.verdicts.get(key) : `${entry.directory}: added entry ./${entry.subpath} has no emitted declaration, so @internal cannot be verified.`;
73
- if (problem !== void 0) {
74
- policy.problems.add(problem);
75
- continue;
76
- }
77
- remove(entry.path);
78
- removed += 1;
79
- policy.allowed.set(key, {
80
- directory: entry.directory,
81
- subpath: entry.subpath
82
- });
83
- }
84
- return removed;
85
- }
86
- /** The "Added (allowed)" list with its count when anything was allowed, and the problems that kept additions from passing; empty when there is nothing to report. */
87
- function describeAllowance(policy) {
88
- const lines = [...policy.allowed.values()].map(({ directory, subpath }) => ` ${directory}: ./${subpath}\n`).sort();
89
- return `${lines.length ? `Added (allowed): ${lines.length}\n${lines.join("")}` : ""}${[...policy.problems].map((problem) => `Not internal: ${problem}\n`).join("")}`;
90
- }
91
- //#endregion
92
- //#region src/guardrails/revisions.ts
93
- const DIRECTORY_LINK = process.platform === "win32" ? "junction" : "dir";
94
- /** The parsed manifest of each tracked package of `checkout`, keyed by its directory; an unreadable manifest is left out. */
95
- function workspaceManifests(checkout) {
96
- const manifests = /* @__PURE__ */ new Map();
97
- for (const file of trackedManifests(checkout)) try {
98
- manifests.set(dirname(file), parseManifest(readFileSync(join(checkout, file), "utf8")));
99
- } catch {
100
- continue;
101
- }
102
- return manifests;
103
- }
104
- /** Maps each named package directory of the checkout to its package in `worktree`: the same directory when it holds a package of that name, otherwise the only package of that name. */
105
- function ownPackages(root, worktree) {
106
- const atRevision = workspaceManifests(worktree);
107
- const byName = /* @__PURE__ */ new Map();
108
- for (const [directory, { name }] of atRevision) if (name !== void 0) byName.set(name, [...byName.get(name) ?? [], directory]);
109
- const packages = /* @__PURE__ */ new Map();
110
- for (const [directory, { name }] of workspaceManifests(root)) {
111
- if (name === void 0) continue;
112
- const named = byName.get(name) ?? [];
113
- if (atRevision.get(directory)?.name === name) packages.set(directory, directory);
114
- else if (named.length === 1) packages.set(directory, named[0]);
115
- }
116
- return packages;
117
- }
118
- /** The worktree path standing in for `real`, a path relative to the checkout, when it is a workspace package of the checkout or lies inside one other than the root package, and the revision has a package of that name. */
119
- function ownCopy(real, packages) {
120
- const posix = real.split(sep).join("/") || ".";
121
- if (isAbsolute(real) || posix.split("/").some((part) => part === ".." || part === "node_modules")) return void 0;
122
- const owner = [...packages.keys()].filter((directory) => posix === directory || posix.startsWith(`${directory}/`)).sort((a, b) => b.length - a.length)[0];
123
- return owner === void 0 ? void 0 : join(packages.get(owner) ?? owner, posix.slice(owner.length));
124
- }
125
- /** Mirrors `path`, a `node_modules`, scope or `.bin` directory of the checkout, into the worktree entry by entry: an entry whose real location is a workspace package of the checkout links to the worktree's package of that name, and every other entry to the checkout's installed one. */
126
- function mirrorInstalled(installed, path) {
127
- const { root, realRoot, worktree, packages } = installed;
128
- mkdirSync(join(worktree, path));
129
- for (const entry of readdirSync(join(root, path))) {
130
- const source = join(root, path, entry);
131
- const target = join(worktree, path, entry);
132
- if (!existsSync(source) || lstatSync(target, { throwIfNoEntry: false }) !== void 0) continue;
133
- const directory = statSync(source).isDirectory();
134
- if (directory && (entry === ".bin" || entry.startsWith("@"))) {
135
- mirrorInstalled(installed, join(path, entry));
136
- continue;
137
- }
138
- const real = realpathSync.native(source);
139
- const own = ownCopy(relative(realRoot, real), packages);
140
- const type = directory ? DIRECTORY_LINK : "file";
141
- if (own !== void 0) symlinkSync(join(worktree, own), target, type);
142
- else if (directory) symlinkSync(source, target, DIRECTORY_LINK);
143
- else if (lstatSync(source).isSymbolicLink()) symlinkSync(real, target, type);
144
- else copyFileSync(source, target);
145
- }
146
- }
147
- /** Links the checkout's installed dependencies into `worktree`; with `ownWorkspace`, a dependency on a workspace package resolves to the worktree's own revision of it instead of the checkout's. */
148
- function linkDependencies(root, worktree, ownWorkspace) {
149
- const directories = /* @__PURE__ */ new Set([".", ...trackedManifests(root).map(dirname)]);
150
- const installed = {
151
- root,
152
- realRoot: realpathSync.native(root),
153
- worktree,
154
- packages: ownWorkspace ? ownPackages(root, worktree) : /* @__PURE__ */ new Map()
155
- };
156
- for (const directory of directories) {
157
- const path = join(directory, "node_modules");
158
- if (!existsSync(join(root, path)) || !existsSync(join(worktree, directory)) || lstatSync(join(worktree, path), { throwIfNoEntry: false }) !== void 0) continue;
159
- if (ownWorkspace) mirrorInstalled(installed, path);
160
- else symlinkSync(join(root, path), join(worktree, path), DIRECTORY_LINK);
161
- }
162
- }
163
- /** Compares isolated committed revisions and removes both worktrees even when compilation fails; a policy lets matching `@internal` additions through. */
164
- function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = false, collate, annotate } = {}) {
165
- const temporary = mkdtempSync(join(tmpdir(), "antelope-proof-"));
166
- const worktrees = [];
167
- const results = [];
168
- try {
169
- for (const [side, ref] of [["base", baseRef], ["head", "HEAD"]]) {
170
- const revision = execFileSync("git", [
171
- "rev-parse",
172
- "--verify",
173
- "--end-of-options",
174
- `${ref}^{commit}`
175
- ], {
176
- cwd: root,
177
- encoding: "utf8",
178
- stdio: [
179
- "ignore",
180
- "pipe",
181
- "pipe"
182
- ]
183
- }).trim();
184
- const worktree = join(temporary, "worktrees", side);
185
- execFileSync("git", [
186
- "worktree",
187
- "add",
188
- "--quiet",
189
- "--detach",
190
- worktree,
191
- revision
192
- ], {
193
- cwd: root,
194
- stdio: [
195
- "ignore",
196
- "pipe",
197
- "pipe"
198
- ]
199
- });
200
- worktrees.push(worktree);
201
- linkDependencies(root, worktree, ownWorkspace);
202
- const output = join(temporary, side);
203
- mkdirSync(output, { recursive: true });
204
- results.push(emit(worktree, output, join(temporary, "emit", side)));
205
- }
206
- const allowedAdditions = policy === void 0 ? 0 : applyAllowance(policy, results[0].published ?? [], results[1].published ?? [], (path) => rmSync(join(temporary, "head", path), { force: true }));
207
- if (collate !== void 0) for (const side of ["base", "head"]) collate(join(temporary, side));
208
- const diff = spawnSync("git", [
209
- "diff",
210
- "--no-index",
211
- "--no-color",
212
- "--no-renames",
213
- "--no-ext-diff",
214
- "--no-textconv",
215
- "--",
216
- "base",
217
- "head"
218
- ], {
219
- cwd: temporary,
220
- encoding: "utf8",
221
- maxBuffer: 67108864
222
- });
223
- if (diff.error) throw diff.error;
224
- if (diff.status !== 0 && diff.status !== 1) throw new Error(diff.stderr || "Could not compare revision outputs.");
225
- const packages = new Set(results.flatMap((result) => result.packages)).size;
226
- return {
227
- different: diff.status === 1,
228
- output: diff.status === 1 ? `${label}: differences against ${baseRef} (committed HEAD).\n${annotate === void 0 ? diff.stdout : annotate(diff.stdout, temporary)}` : `${label}: ${packages} packages, ${results[1].entries - allowedAdditions} entries unchanged against ${baseRef} (committed HEAD).\n`
229
- };
230
- } finally {
231
- for (const worktree of worktrees.reverse()) execFileSync("git", [
232
- "worktree",
233
- "remove",
234
- "--force",
235
- worktree
236
- ], {
237
- cwd: root,
238
- stdio: "pipe"
239
- });
240
- rmSync(temporary, {
241
- recursive: true,
242
- force: true
243
- });
244
- }
245
- }
246
- function countRows(base, head) {
247
- const total = (counts) => Object.values(counts.rules).reduce((sum, count) => sum + count, 0);
248
- const rules = [.../* @__PURE__ */ new Set([...Object.keys(base.rules), ...Object.keys(head.rules)])].sort((a, b) => a.localeCompare(b));
249
- const configTotal = (counts) => Object.values(counts.config ?? {}).reduce((sum, count) => sum + count, 0);
250
- const configRules = [.../* @__PURE__ */ new Set([...Object.keys(base.config ?? {}), ...Object.keys(head.config ?? {})])].sort((a, b) => a.localeCompare(b));
251
- return [
252
- [
253
- "Lint suppressions, all rules",
254
- total(base),
255
- total(head)
256
- ],
257
- ...rules.map((rule) => [
258
- `Lint suppressions, \`${rule}\``,
259
- base.rules[rule] ?? 0,
260
- head.rules[rule] ?? 0
261
- ]),
262
- [
263
- "`@ts-expect-error`",
264
- base.tsExpectError,
265
- head.tsExpectError
266
- ],
267
- [
268
- "`@ts-ignore`",
269
- base.tsIgnore,
270
- head.tsIgnore
271
- ],
272
- [
273
- "`SAFETY:` comments",
274
- base.safety,
275
- head.safety
276
- ],
277
- [
278
- "Lint config rule-offs, all rules",
279
- configTotal(base),
280
- configTotal(head)
281
- ],
282
- ...configRules.map((rule) => [
283
- `Lint config rule-offs, \`${rule}\``,
284
- base.config?.[rule] ?? 0,
285
- head.config?.[rule] ?? 0
286
- ])
287
- ];
288
- }
289
- /** The suppression table rows, `| label | base | head |`, counted in authored code files at both revisions with the shared suppression counter. */
290
- function revisionCountRows(root, baseRef, headRef = "HEAD") {
291
- const [base, head] = [baseRef, headRef].map((ref) => countSuppressions(revisionSuppressions(root, resolveRevision(root, ref))));
292
- return countRows(base, head).map(([label, before, after]) => `| ${label} | ${before} | ${after} |`);
293
- }
294
- /** Counts suppressions in authored code files at the base and at committed HEAD, so a PR body copies them instead of typing them. */
295
- function revisionCounts(root, baseRef) {
296
- return `\nSuppressions in authored code files (${baseRef} and committed HEAD). A lint directive counts once per rule it names; \`*\` is a directive naming none.\n| Suppressions | base | HEAD |\n| --- | ---: | ---: |\n${revisionCountRows(root, baseRef).join("\n")}\n`;
297
- }
298
- //#endregion
299
- //#region src/guardrails/proof-stamp.ts
300
- const PROOF_STAMP = /^<!-- antelopejs-proof base=([0-9a-f]{40}) head=([0-9a-f]{40}) lines=(\d+) digest=([0-9a-f]{16}) command: (.+) -->$/u;
301
- function tableRow(line) {
302
- return `| ${line.replace(/^\|/u, "").replace(/\|$/u, "").split("|").map((cell) => cell.trim()).map((cell) => /^:?-+:?$/u.test(cell) ? cell.replace(/-+/u, "---") : cell).join(" | ")} |`;
303
- }
304
- /** The lines a digest covers: trimmed, blank lines and code fences dropped, table cells re-padded, so indenting or reformatting a copy keeps it valid. */
305
- function proofLines(lines) {
306
- return lines.map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("```")).map((line) => line.startsWith("|") ? tableRow(line) : line);
307
- }
308
- /** Hashes the stamp's revisions and command with the normalised output lines. */
309
- function proofDigest(stamp, lines) {
310
- return createHash("sha256").update(JSON.stringify([
311
- stamp.command,
312
- stamp.base,
313
- stamp.head,
314
- ...proofLines(lines)
315
- ])).digest("hex").slice(0, 16);
316
- }
317
- /** Reads a stamp line, or `undefined` when the line is not one. */
318
- function parseProofStamp(line) {
319
- const match = PROOF_STAMP.exec(line.trim());
320
- if (!match) return void 0;
321
- const [, base, head, lines, digest, command] = match;
322
- return {
323
- base,
324
- head,
325
- lines: Number(lines),
326
- digest,
327
- command
328
- };
329
- }
330
- /** Appends a stamp line to a proof bin's output: the base and committed head it compared, the command, how many lines it printed, and a digest of them. */
331
- function stampProof(root, command, baseRef, output) {
332
- const stamp = {
333
- base: resolveRevision(root, baseRef),
334
- head: resolveRevision(root, "HEAD"),
335
- command
336
- };
337
- const text = output.endsWith("\n") ? output : `${output}\n`;
338
- const lines = text.split("\n");
339
- return `${text}<!-- antelopejs-proof base=${stamp.base} head=${stamp.head} lines=${proofLines(lines).length} digest=${proofDigest(stamp, lines)} command: ${command} -->\n`;
340
- }
341
- //#endregion
342
- export { DIRECTORY_LINK as a, revisionCounts as c, createAddedPolicy as d, describeAllowance as f, stampProof as i, workspaceManifests as l, recordVerdict as m, proofDigest as n, compareRevisions as o, fillStars as p, proofLines as r, revisionCountRows as s, parseProofStamp as t, allowedByGlob as u };