@antelopejs/tooling-configs 0.2.16 → 0.2.17
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.
- package/README.md +88 -48
- package/dist/bin/api-diff.mjs +409 -97
- package/dist/bin/body-check.d.mts +1 -0
- package/dist/bin/body-check.mjs +344 -0
- package/dist/bin/check-size.mjs +3 -3
- package/dist/bin/checks.mjs +3 -3
- package/dist/bin/comment-proof.mjs +4 -3
- package/dist/bin/garden.mjs +5 -5
- package/dist/bin/ratchet.mjs +267 -7
- package/dist/bin/suppressions.mjs +118 -80
- package/dist/bin/sync.mjs +490 -35
- package/dist/bin/verify.mjs +5 -5
- package/dist/{ceilings-BSw9p4YB.mjs → ceilings-B7KayYIG.mjs} +11 -3
- package/dist/{checks-BlWDFYio.mjs → checks-CxkSu2E6.mjs} +1 -1
- package/dist/{ci-workflow-DIsoEgMd.mjs → ci-workflow-ChW4He0r.mjs} +84 -3
- package/dist/{files-2FikHZ9F.mjs → files-Bc036sJW.mjs} +2 -2
- package/dist/{json-BqvuCkqr.mjs → json-CG2L7YFl.mjs} +12 -8
- package/dist/oxc/anti-slop/index.mjs +160 -13
- package/dist/oxc/fmt.mjs +1 -1
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +645 -1
- package/dist/oxc/lint.d.mts +11 -3
- package/dist/oxc/lint.mjs +21 -8
- package/dist/oxlint-Bltmk8-6.mjs +94 -0
- package/dist/{package-Dtjt_lSa.mjs → package-DTxLPNDu.mjs} +3 -2
- package/dist/proof-stamp-w-3j47A-.mjs +279 -0
- package/dist/ratchet-DwRj9h4L.mjs +275 -0
- package/dist/{renames-BGO4dWJ8.mjs → renames-L2owF5GD.mjs} +2 -2
- package/dist/shared-CoUt4GUm.mjs +73 -0
- package/dist/{size-BVgNbLO6.mjs → size-DNtWruCO.mjs} +3 -3
- package/dist/suppression-base-DAfCXwjL.mjs +95 -0
- package/dist/{suppression-budget-Yyf5_J5l.mjs → suppression-budget-Bd2GqMYb.mjs} +248 -33
- package/dist/{suppressions-BJAngUxo.mjs → suppressions-BD_f8f7L.mjs} +180 -18
- package/dist/typescript-BmS5BmrS.mjs +222 -0
- package/dist/verify/index.mjs +1 -1
- package/package.json +4 -2
- package/dist/kinds-Bzyyi9yk.mjs +0 -25
- package/dist/ratchet-DRdIYwmv.mjs +0 -80
- package/dist/shared-CsXIMK3I.mjs +0 -34
- package/dist/staged-ratchet-CjoRfZaM.mjs +0 -236
- package/dist/typescript-C54ONh9m.mjs +0 -433
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
+
import { o as repositoryRoot, s as resolveRevision } from "../files-Bc036sJW.mjs";
|
|
4
|
+
import { t as lintDiagnostics } from "../oxlint-Bltmk8-6.mjs";
|
|
5
|
+
import { n as proofDigest, r as proofLines, s as revisionCountRows, t as parseProofStamp } from "../proof-stamp-w-3j47A-.mjs";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
|
+
//#region src/guardrails/body-scan.ts
|
|
10
|
+
const FINDINGS_BEGIN = "<!-- antelopejs-findings begin -->";
|
|
11
|
+
const FINDINGS_END = "<!-- antelopejs-findings end -->";
|
|
12
|
+
const CODE_FILE_SOURCE = /(?<![\w@.[\]/-])(?:[\w@.[\]-]+\/)*[\w@[\]-][\w@.[\]-]*\.(?:[cm]?[jt]sx?|vue)(?!\w)/u.source;
|
|
13
|
+
/** A `path:line` reference to a code file, as a findings list writes it. */
|
|
14
|
+
const CODE_REFERENCE = new RegExp(`${CODE_FILE_SOURCE}:\\d+`, "u");
|
|
15
|
+
/** A mention of a code file, with or without a line. A bare `.d.ts` names no file. */
|
|
16
|
+
const CODE_MENTION = new RegExp(`${CODE_FILE_SOURCE}(?::\\d+)?`, "u");
|
|
17
|
+
function isFindingsHeading(title) {
|
|
18
|
+
return /\b(?:left|remaining|kept)\b/iu.test(title) && /\b(?:ratchet|findings?)\b/iu.test(title) || /^not fixed\b/iu.test(title);
|
|
19
|
+
}
|
|
20
|
+
/** The title a plain or bold line stands for: the whole line, without emphasis or a closing colon. Prose sentences have none. */
|
|
21
|
+
function plainTitle(trimmed) {
|
|
22
|
+
const title = trimmed.replace(/^(\*\*|__)(.+?)\1:?$/u, "$2").replace(/:$/u, "");
|
|
23
|
+
return /^[A-Za-z][\w ,'()-]{0,79}$/u.test(title) ? title : void 0;
|
|
24
|
+
}
|
|
25
|
+
var SectionTracker = class {
|
|
26
|
+
fenced = false;
|
|
27
|
+
level;
|
|
28
|
+
plain = false;
|
|
29
|
+
/** Follows headings outside code fences, and plain or bold title lines that name findings left, and reports whether `text` sits in a findings-left section. A heading section ends at the next heading of its level or above, a plain one at the next heading. */
|
|
30
|
+
visit(text) {
|
|
31
|
+
const trimmed = text.trim();
|
|
32
|
+
if (trimmed.startsWith("```")) this.fenced = !this.fenced;
|
|
33
|
+
if (this.fenced) return this.level !== void 0 || this.plain;
|
|
34
|
+
const heading = /^(#{1,6})\s+(.*)$/u.exec(trimmed);
|
|
35
|
+
if (heading) {
|
|
36
|
+
this.plain = false;
|
|
37
|
+
const level = heading[1].length;
|
|
38
|
+
if (this.level !== void 0 && level <= this.level) this.level = void 0;
|
|
39
|
+
if (this.level === void 0 && isFindingsHeading(heading[2])) this.level = level;
|
|
40
|
+
} else {
|
|
41
|
+
const title = plainTitle(trimmed);
|
|
42
|
+
if (title !== void 0 && isFindingsHeading(title)) this.plain = true;
|
|
43
|
+
}
|
|
44
|
+
return this.level !== void 0 || this.plain;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/** Moves the lines a stamp covers out of `outside`: its digested line count, counted back from the stamp, blank lines and fences included. */
|
|
48
|
+
function proofBlock(outside, stamp, at) {
|
|
49
|
+
const lines = [];
|
|
50
|
+
let counted = 0;
|
|
51
|
+
while (counted < stamp.lines && outside.length > 0) {
|
|
52
|
+
const line = outside.pop();
|
|
53
|
+
if (line === void 0) break;
|
|
54
|
+
lines.unshift(line);
|
|
55
|
+
counted += proofLines([line.text]).length;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
kind: "proof",
|
|
59
|
+
start: lines.at(0)?.number ?? at,
|
|
60
|
+
lines,
|
|
61
|
+
stamp,
|
|
62
|
+
closed: true
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Splits a pull request body into stamped proof blocks, findings blocks, and the lines outside both. */
|
|
66
|
+
function scanBody(body) {
|
|
67
|
+
const scanned = {
|
|
68
|
+
blocks: [],
|
|
69
|
+
outside: []
|
|
70
|
+
};
|
|
71
|
+
const sections = new SectionTracker();
|
|
72
|
+
let findings;
|
|
73
|
+
body.split(/\r?\n/u).forEach((text, index) => {
|
|
74
|
+
const line = {
|
|
75
|
+
number: index + 1,
|
|
76
|
+
text,
|
|
77
|
+
inFindingsSection: sections.visit(text)
|
|
78
|
+
};
|
|
79
|
+
const trimmed = text.trim();
|
|
80
|
+
const stamp = parseProofStamp(text);
|
|
81
|
+
if (findings !== void 0) {
|
|
82
|
+
if (trimmed === "<!-- antelopejs-findings end -->") {
|
|
83
|
+
findings.closed = true;
|
|
84
|
+
findings = void 0;
|
|
85
|
+
} else findings.lines.push(line);
|
|
86
|
+
} else if (trimmed === "<!-- antelopejs-findings begin -->") {
|
|
87
|
+
findings = {
|
|
88
|
+
kind: "findings",
|
|
89
|
+
start: line.number,
|
|
90
|
+
lines: [],
|
|
91
|
+
stamp: void 0,
|
|
92
|
+
closed: false
|
|
93
|
+
};
|
|
94
|
+
scanned.blocks.push(findings);
|
|
95
|
+
} else if (stamp !== void 0) scanned.blocks.push(proofBlock(scanned.outside, stamp, line.number));
|
|
96
|
+
else scanned.outside.push(line);
|
|
97
|
+
});
|
|
98
|
+
return scanned;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/guardrails/body-findings.ts
|
|
102
|
+
const PLACEHOLDER = "<why>";
|
|
103
|
+
const ITEM = /^[-*+]\s+`([^`\s]+?):(\d+)(?::\d+)?`\s+`([^`\s]+)`\s*:?\s*(.*)$/u;
|
|
104
|
+
const CLAIM_BEFORE = /(\d+)\s*(?:×\s*)?`([^`\s]+)`/gu;
|
|
105
|
+
const CLAIM_AFTER = /`([^`\s]+)`\s*\((\d+)\)/gu;
|
|
106
|
+
const RECOPY = "Copy the list again from `antelopejs-body-check --findings`.";
|
|
107
|
+
const key = (file, line, rule) => `${file}:${line} \`${rule}\``;
|
|
108
|
+
function tally(keys) {
|
|
109
|
+
const counts = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const entry of keys) counts.set(entry, (counts.get(entry) ?? 0) + 1);
|
|
111
|
+
return counts;
|
|
112
|
+
}
|
|
113
|
+
function readItem(line) {
|
|
114
|
+
const match = ITEM.exec(line.text.trim());
|
|
115
|
+
if (!match) return void 0;
|
|
116
|
+
const [, file, at, rule, why] = match;
|
|
117
|
+
return {
|
|
118
|
+
line: line.number,
|
|
119
|
+
file,
|
|
120
|
+
at: Number(at),
|
|
121
|
+
rule,
|
|
122
|
+
why: why.trim()
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function readClaims(line) {
|
|
126
|
+
const claims = [...line.text.matchAll(CLAIM_BEFORE)].map((match) => ({
|
|
127
|
+
line: line.number,
|
|
128
|
+
name: match[2],
|
|
129
|
+
count: Number(match[1])
|
|
130
|
+
}));
|
|
131
|
+
for (const match of line.text.matchAll(CLAIM_AFTER)) claims.push({
|
|
132
|
+
line: line.number,
|
|
133
|
+
name: match[1],
|
|
134
|
+
count: Number(match[2])
|
|
135
|
+
});
|
|
136
|
+
return claims;
|
|
137
|
+
}
|
|
138
|
+
const names = (rule, name) => rule === name || rule.endsWith(`/${name}`);
|
|
139
|
+
function claimProblems(items, claims, rules) {
|
|
140
|
+
const known = claims.flatMap((claim) => {
|
|
141
|
+
const rule = [...rules].find((candidate) => names(candidate, claim.name));
|
|
142
|
+
return rule === void 0 ? [] : [{
|
|
143
|
+
...claim,
|
|
144
|
+
rule
|
|
145
|
+
}];
|
|
146
|
+
});
|
|
147
|
+
return known.flatMap((claim) => {
|
|
148
|
+
const next = known.find((other) => other.line > claim.line && other.rule === claim.rule);
|
|
149
|
+
const listed = items.filter((item) => item.line > claim.line && (next === void 0 || item.line < next.line) && item.rule === claim.rule).length;
|
|
150
|
+
return listed === claim.count ? [] : [`line ${claim.line}: claims ${claim.count} \`${claim.name}\` but ${listed} listed under it. Drop the typed count or make the list match it.`];
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function liveProblems(items, diagnostics) {
|
|
154
|
+
const live = tally(diagnostics.flatMap(({ file, line, rule }) => line === void 0 ? [] : [key(file, line, rule)]));
|
|
155
|
+
const seen = /* @__PURE__ */ new Map();
|
|
156
|
+
const problems = [];
|
|
157
|
+
for (const item of items) {
|
|
158
|
+
const entry = key(item.file, item.at, item.rule);
|
|
159
|
+
seen.set(entry, (seen.get(entry) ?? 0) + 1);
|
|
160
|
+
if ((seen.get(entry) ?? 0) <= (live.get(entry) ?? 0)) continue;
|
|
161
|
+
const lines = diagnostics.filter(({ file, rule }) => file === item.file && rule === item.rule).map(({ line }) => line).sort((a, b) => (a ?? 0) - (b ?? 0));
|
|
162
|
+
const hint = lines.length ? ` (live at ${lines.join(", ")})` : "";
|
|
163
|
+
problems.push(`line ${item.line}: ${item.file}:${item.at} has no live \`${item.rule}\` diagnostic at HEAD${hint}. ${RECOPY}`);
|
|
164
|
+
}
|
|
165
|
+
const covered = new Set(items.map(({ rule }) => rule));
|
|
166
|
+
for (const [entry, count] of live) {
|
|
167
|
+
const rule = /`([^`]+)`$/u.exec(entry)?.[1] ?? "";
|
|
168
|
+
if (covered.has(rule) && count > (seen.get(entry) ?? 0)) problems.push(`${entry} is live at HEAD but not listed. List every finding of a rule the block lists. ${RECOPY}`);
|
|
169
|
+
}
|
|
170
|
+
return problems;
|
|
171
|
+
}
|
|
172
|
+
/** Checks one findings block: every item is a live diagnostic at HEAD with a reason, every finding of a listed rule is listed, and every typed count matches the items under it. */
|
|
173
|
+
function findingsProblems(block, diagnostics) {
|
|
174
|
+
const problems = [];
|
|
175
|
+
if (!block.closed) problems.push(`line ${block.start}: ${FINDINGS_BEGIN} has no ${FINDINGS_END}. ${RECOPY}`);
|
|
176
|
+
const items = [];
|
|
177
|
+
const claims = [];
|
|
178
|
+
for (const line of block.lines) {
|
|
179
|
+
const item = readItem(line);
|
|
180
|
+
if (item !== void 0) items.push(item);
|
|
181
|
+
else if (CODE_REFERENCE.test(line.text)) problems.push(`line ${line.number}: write each finding as \`- \\\`path:line\\\` \\\`rule\\\`: why\`. ${RECOPY}`);
|
|
182
|
+
else claims.push(...readClaims(line));
|
|
183
|
+
}
|
|
184
|
+
for (const item of items) if (item.why === "" || item.why === PLACEHOLDER) problems.push(`line ${item.line}: ${item.file}:${item.at} \`${item.rule}\` has no reason; give the reason it stays under the ratchet.`);
|
|
185
|
+
const rules = /* @__PURE__ */ new Set([...items.map(({ rule }) => rule), ...diagnostics.map(({ rule }) => rule)]);
|
|
186
|
+
return [
|
|
187
|
+
...problems,
|
|
188
|
+
...liveProblems(items, diagnostics),
|
|
189
|
+
...claimProblems(items, claims, rules)
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
/** Prints every lint finding at HEAD as a findings block grouped by rule, with a `<why>` for the author to replace. */
|
|
193
|
+
function formatFindings(diagnostics) {
|
|
194
|
+
const groups = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const diagnostic of diagnostics) if (diagnostic.line !== void 0) groups.set(diagnostic.rule, [...groups.get(diagnostic.rule) ?? [], diagnostic]);
|
|
196
|
+
const sections = [...groups].sort(([a], [b]) => a.localeCompare(b)).map(([rule, found]) => [
|
|
197
|
+
`\`${rule}\` (${found.length}):`,
|
|
198
|
+
"",
|
|
199
|
+
...found.sort((a, b) => a.file.localeCompare(b.file) || (a.line ?? 0) - (b.line ?? 0)).map(({ file, line }) => `- \`${file}:${line}\` \`${rule}\`: ${PLACEHOLDER}`)
|
|
200
|
+
].join("\n"));
|
|
201
|
+
return `${[
|
|
202
|
+
FINDINGS_BEGIN,
|
|
203
|
+
...sections,
|
|
204
|
+
FINDINGS_END
|
|
205
|
+
].join("\n\n")}\n`;
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/guardrails/body-check.ts
|
|
209
|
+
const PROOF_COMMANDS = "`antelopejs-api-diff <base-ref>` or `antelopejs-comment-proof <base-ref>`";
|
|
210
|
+
const SUPPRESSION_HEADER = /^\|\s*Suppressions\s*\|\s*base\s*\|\s*HEAD\s*\|/u;
|
|
211
|
+
const PROOF_SUMMARY = /\b(?:Runtime API|API|Comment proof): (?:\d+ packages, \d+ entries unchanged|differences|comparison incomplete)/u;
|
|
212
|
+
function git(root, args) {
|
|
213
|
+
const result = spawnSync("git", args, {
|
|
214
|
+
cwd: root,
|
|
215
|
+
encoding: "utf8"
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
ok: result.status === 0,
|
|
219
|
+
out: result.stdout.trim()
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function outsideProblems(lines) {
|
|
223
|
+
return lines.flatMap((line) => {
|
|
224
|
+
const text = line.text.trim();
|
|
225
|
+
if (SUPPRESSION_HEADER.test(text)) return [`line ${line.number}: suppression table outside a stamped proof block. Copy the whole output of ${PROOF_COMMANDS}, its closing antelopejs-proof stamp included.`];
|
|
226
|
+
if (PROOF_SUMMARY.test(text)) return [`line ${line.number}: proof output outside a stamped proof block. Copy the whole output of ${PROOF_COMMANDS}, its closing antelopejs-proof stamp included.`];
|
|
227
|
+
const reference = line.inFindingsSection ? CODE_MENTION.exec(text) : null;
|
|
228
|
+
return reference ? [`line ${line.number}: \`${reference[0]}\` sits in a findings-left section outside an antelopejs-findings block. Print the list with \`antelopejs-body-check --findings\`, copy its block, and give each finding its reason.`] : [];
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function tableRows(lines) {
|
|
232
|
+
const rows = /* @__PURE__ */ new Map();
|
|
233
|
+
for (const { text } of lines) {
|
|
234
|
+
const cells = text.trim().replace(/^\|/u, "").replace(/\|$/u, "").split("|").map((cell) => cell.trim());
|
|
235
|
+
if (cells.length === 3 && /^\d+$/u.test(cells[1])) rows.set(cells[0], `${cells[1]} | ${cells[2]}`);
|
|
236
|
+
}
|
|
237
|
+
return rows;
|
|
238
|
+
}
|
|
239
|
+
function suppressionProblems(root, block, rerun) {
|
|
240
|
+
if (!block.lines.some(({ text }) => SUPPRESSION_HEADER.test(text.trim()))) return [];
|
|
241
|
+
const base = block.stamp?.base ?? "HEAD";
|
|
242
|
+
const copied = tableRows(block.lines);
|
|
243
|
+
const current = tableRows(revisionCountRows(root, base).map((text) => ({
|
|
244
|
+
number: 0,
|
|
245
|
+
text,
|
|
246
|
+
inFindingsSection: false
|
|
247
|
+
})));
|
|
248
|
+
return [.../* @__PURE__ */ new Set([...copied.keys(), ...current.keys()])].flatMap((label) => copied.get(label) === current.get(label) ? [] : [`line ${block.start}: suppression row ${label} reads ${copied.get(label) ?? "nothing"}, which no longer matches HEAD (${current.get(label) ?? "no row"}). ${rerun}`]);
|
|
249
|
+
}
|
|
250
|
+
function sharesBase(root, stampBase, base) {
|
|
251
|
+
const mine = git(root, [
|
|
252
|
+
"merge-base",
|
|
253
|
+
stampBase,
|
|
254
|
+
"HEAD"
|
|
255
|
+
]);
|
|
256
|
+
const theirs = git(root, [
|
|
257
|
+
"merge-base",
|
|
258
|
+
base,
|
|
259
|
+
"HEAD"
|
|
260
|
+
]);
|
|
261
|
+
return mine.ok && theirs.ok && mine.out === theirs.out;
|
|
262
|
+
}
|
|
263
|
+
function revisionProblems(root, block, rerun, base) {
|
|
264
|
+
const stamp = block.stamp;
|
|
265
|
+
if (stamp === void 0) return [];
|
|
266
|
+
for (const sha of [stamp.base, stamp.head]) if (!git(root, [
|
|
267
|
+
"cat-file",
|
|
268
|
+
"-e",
|
|
269
|
+
`${sha}^{commit}`
|
|
270
|
+
]).ok) return [`line ${block.start}: proof block names ${sha.slice(0, 12)}, a commit this checkout does not have. Fetch the full history (fetch-depth: 0), or ${rerun}`];
|
|
271
|
+
if (!git(root, [
|
|
272
|
+
"merge-base",
|
|
273
|
+
"--is-ancestor",
|
|
274
|
+
stamp.head,
|
|
275
|
+
"HEAD"
|
|
276
|
+
]).ok) return [`line ${block.start}: proof block stamped at ${stamp.head.slice(0, 12)}, which is not in this branch's history. ${rerun}`];
|
|
277
|
+
const head = git(root, ["rev-parse", "HEAD"]).out;
|
|
278
|
+
const trees = [stamp.head, head].map((sha) => git(root, ["rev-parse", `${sha}^{tree}`]).out);
|
|
279
|
+
if (stamp.command.startsWith("antelopejs-api-diff") && trees[0] !== trees[1]) return [`line ${block.start}: proof block stamped at ${stamp.head.slice(0, 12)}, but HEAD is ${head.slice(0, 12)}. ${rerun}`];
|
|
280
|
+
if (base !== void 0 && stamp.command.startsWith("antelopejs-api-diff") && !sharesBase(root, stamp.base, base)) return [`line ${block.start}: proof block compared against ${stamp.base.slice(0, 12)}, whose base is not the pull request base ${base.slice(0, 12)}. Re-run \`antelopejs-api-diff <pull request base>\` at HEAD and copy its whole output, its closing antelopejs-proof stamp included.`];
|
|
281
|
+
return suppressionProblems(root, block, rerun);
|
|
282
|
+
}
|
|
283
|
+
function proofProblems(root, block, base) {
|
|
284
|
+
const stamp = block.stamp;
|
|
285
|
+
if (stamp === void 0) return [];
|
|
286
|
+
const rerun = `Re-run \`${stamp.command}\` at HEAD and copy its whole output, its closing antelopejs-proof stamp included.`;
|
|
287
|
+
const lines = block.lines.map(({ text }) => text);
|
|
288
|
+
if (proofDigest(stamp, lines) !== stamp.digest) return [`line ${block.start}: proof block edited after \`${stamp.command}\` printed it. ${rerun}`];
|
|
289
|
+
return revisionProblems(root, block, rerun, base);
|
|
290
|
+
}
|
|
291
|
+
/** Checks a pull request body against the repository at HEAD: stamped proof blocks are unedited and current, bin output appears only inside them, and findings blocks list live diagnostics. With `base`, an api-diff stamp must compare against that pull request base or an ancestor of it on the branch's merge-base. Returns one message per problem. */
|
|
292
|
+
function checkBody(root, body, { base } = {}) {
|
|
293
|
+
const { blocks, outside } = scanBody(body);
|
|
294
|
+
let diagnostics;
|
|
295
|
+
const problems = outsideProblems(outside);
|
|
296
|
+
for (const block of blocks) if (block.kind === "proof") problems.push(...proofProblems(root, block, base));
|
|
297
|
+
else {
|
|
298
|
+
diagnostics ??= lintDiagnostics(root);
|
|
299
|
+
problems.push(...findingsProblems(block, diagnostics));
|
|
300
|
+
}
|
|
301
|
+
return problems;
|
|
302
|
+
}
|
|
303
|
+
/** The findings block for every lint finding in the working tree, ready to paste into a pull request body. */
|
|
304
|
+
function findingsBlock(root) {
|
|
305
|
+
return formatFindings(lintDiagnostics(root));
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/bin/body-check.ts
|
|
309
|
+
const USAGE = "Usage: antelopejs-body-check <body.md | -> [--head <sha>] [--base <sha>] | antelopejs-body-check --findings";
|
|
310
|
+
function parse(args) {
|
|
311
|
+
try {
|
|
312
|
+
const { positionals, values } = parseArgs({
|
|
313
|
+
args,
|
|
314
|
+
allowPositionals: true,
|
|
315
|
+
options: {
|
|
316
|
+
findings: { type: "boolean" },
|
|
317
|
+
head: { type: "string" },
|
|
318
|
+
base: { type: "string" }
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
if (positionals.length !== (values.findings ? 0 : 1)) throw new Error(USAGE);
|
|
322
|
+
return {
|
|
323
|
+
body: positionals.at(0),
|
|
324
|
+
...values
|
|
325
|
+
};
|
|
326
|
+
} catch {
|
|
327
|
+
throw new Error(USAGE);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
runCli(() => {
|
|
331
|
+
const { base, body, findings, head } = parse(process.argv.slice(2));
|
|
332
|
+
const root = repositoryRoot();
|
|
333
|
+
if (findings) {
|
|
334
|
+
process.stdout.write(findingsBlock(root));
|
|
335
|
+
return 0;
|
|
336
|
+
}
|
|
337
|
+
const current = resolveRevision(root, "HEAD");
|
|
338
|
+
if (head !== void 0 && head !== current) throw new Error(`HEAD is ${current}, not the pull request head ${head}: check out the pull request head (actions/checkout with ref: \${{ github.event.pull_request.head.sha }}) before running antelopejs-body-check.`);
|
|
339
|
+
const problems = checkBody(root, readFileSync(body === "-" ? 0 : body ?? 0, "utf8"), { base });
|
|
340
|
+
for (const problem of problems) process.stderr.write(`${problem}\n`);
|
|
341
|
+
return problems.length ? 1 : 0;
|
|
342
|
+
});
|
|
343
|
+
//#endregion
|
|
344
|
+
export {};
|
package/dist/bin/check-size.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import { a as repositoryPath, o as repositoryRoot, t as authoredSizes } from "../files-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { a as repositoryPath, o as repositoryRoot, t as authoredSizes } from "../files-Bc036sJW.mjs";
|
|
4
|
+
import { l as worktreeSuppressions, o as revisionSuppressions } from "../suppressions-BD_f8f7L.mjs";
|
|
5
|
+
import { t as checkSize } from "../size-DNtWruCO.mjs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
8
|
//#region src/guardrails/directives.ts
|
package/dist/bin/checks.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../ceilings-
|
|
2
|
+
import "../ceilings-B7KayYIG.mjs";
|
|
3
3
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
4
|
-
import { o as repositoryRoot } from "../files-
|
|
5
|
-
import { i as parseManifest, r as packageManager } from "../package-
|
|
4
|
+
import { o as repositoryRoot } from "../files-Bc036sJW.mjs";
|
|
5
|
+
import { i as parseManifest, r as packageManager } from "../package-DTxLPNDu.mjs";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import { o as repositoryRoot } from "../files-
|
|
4
|
-
import { c as revisionCounts, i as
|
|
3
|
+
import { o as repositoryRoot } from "../files-Bc036sJW.mjs";
|
|
4
|
+
import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-w-3j47A-.mjs";
|
|
5
|
+
import { o as packagesAt, t as emitPackage } from "../typescript-BmS5BmrS.mjs";
|
|
5
6
|
import { copyFileSync, mkdirSync } from "node:fs";
|
|
6
7
|
import { dirname, join, relative } from "node:path";
|
|
7
8
|
//#region src/guardrails/comment-proof.ts
|
|
@@ -28,7 +29,7 @@ function commentProof(root, baseRef) {
|
|
|
28
29
|
});
|
|
29
30
|
return {
|
|
30
31
|
...result,
|
|
31
|
-
output: result.output + revisionCounts(root, baseRef)
|
|
32
|
+
output: stampProof(root, `antelopejs-comment-proof ${baseRef}`, baseRef, result.output + revisionCounts(root, baseRef))
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
//#endregion
|
package/dist/bin/garden.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-
|
|
2
|
+
import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
3
3
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
4
|
-
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-
|
|
4
|
+
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-ChW4He0r.mjs";
|
|
5
5
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
@@ -1132,7 +1132,7 @@ const packageSize = {
|
|
|
1132
1132
|
//#endregion
|
|
1133
1133
|
//#region src/garden/semver.ts
|
|
1134
1134
|
const VERSION = /^v?(\d+)\.(\d+)\.(\d+)/;
|
|
1135
|
-
function parse(text) {
|
|
1135
|
+
function parse$1(text) {
|
|
1136
1136
|
const match = VERSION.exec(text.trim());
|
|
1137
1137
|
return match ? [
|
|
1138
1138
|
Number(match[1]),
|
|
@@ -1161,7 +1161,7 @@ function caret(floor) {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
function comparator(term, version) {
|
|
1163
1163
|
const operator = /^(>=|<=|>|<|=|\^|~)?\s*(.*)$/.exec(term.trim());
|
|
1164
|
-
const bound = parse(operator?.[2] ?? "");
|
|
1164
|
+
const bound = parse$1(operator?.[2] ?? "");
|
|
1165
1165
|
if (!operator || !bound) return true;
|
|
1166
1166
|
switch (operator[1]) {
|
|
1167
1167
|
case ">=": return compare$1(version, bound) >= 0;
|
|
@@ -1179,7 +1179,7 @@ function comparator(term, version) {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
/** Whether a plain npm range (`^`, `~`, comparators, `||`, `*`) admits a release; wildcards and tags admit everything. */
|
|
1181
1181
|
function admits(range, release) {
|
|
1182
|
-
const version = parse(release);
|
|
1182
|
+
const version = parse$1(release);
|
|
1183
1183
|
if (!version) return true;
|
|
1184
1184
|
return range.split("||").some((alternative) => {
|
|
1185
1185
|
return alternative.replace(/(>=|<=|>|<|=|\^|~)\s+/g, "$1").trim().split(/\s+/).every((term) => comparator(term, version));
|