@antelopejs/tooling-configs 0.7.4 → 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 (44) hide show
  1. package/README.md +32 -77
  2. package/dist/bin/api-diff.mjs +16 -36
  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 +284 -189
  11. package/dist/bin/tsc.mjs +1 -1
  12. package/dist/bin/verify.mjs +33 -613
  13. package/dist/{checks-BTFf0Evy.mjs → checks-C60vMFin.mjs} +130 -283
  14. package/dist/{docs-compat-BmczGA1d.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-CNmSFSxO.mjs → guardrails-Dron1AbR.mjs} +5 -611
  19. package/dist/{map-BYkmnvNw.mjs → map-CbNbypUa.mjs} +2 -2
  20. package/dist/oxc/anti-slop/index.mjs +22 -964
  21. package/dist/oxc/guardrails/index.d.mts +1 -1
  22. package/dist/oxc/guardrails/index.mjs +1 -1
  23. package/dist/oxc/lint.d.mts +2 -14
  24. package/dist/oxc/lint.mjs +3 -20
  25. package/dist/{package-1pH5I0TF.mjs → package-7oylgBeT.mjs} +3 -12
  26. package/dist/{workflow-C-oBwL2H.mjs → renovate-D0su_v9p.mjs} +191 -91
  27. package/dist/{suppression-budget-BeJIgSTO.mjs → suppression-budget-De9nUzlD.mjs} +33 -13
  28. package/dist/{suppressions-BvWGA463.mjs → suppressions-CfJwL0fN.mjs} +1 -1
  29. package/dist/{templates-Df6SlGLA.mjs → templates-DLW0Ubfk.mjs} +26 -29
  30. package/dist/typescript-C7eU-cig.mjs +581 -0
  31. package/dist/verify/index.d.mts +5 -24
  32. package/package.json +1 -3
  33. package/dist/bin/body-check.d.mts +0 -1
  34. package/dist/bin/body-check.mjs +0 -350
  35. package/dist/bin/ratchet.d.mts +0 -1
  36. package/dist/bin/ratchet.mjs +0 -375
  37. package/dist/ceilings-B7KayYIG.mjs +0 -76
  38. package/dist/oxlint-CIeonWMB.mjs +0 -133
  39. package/dist/proof-stamp-Bg4ULLvr.mjs +0 -342
  40. package/dist/ratchet-CPpvIU6Y.mjs +0 -453
  41. package/dist/renames-L2owF5GD.mjs +0 -59
  42. package/dist/size-CCGLY4Ke.mjs +0 -18
  43. package/dist/suppression-base-CDiFJse2.mjs +0 -120
  44. package/dist/typescript-B0df00nl.mjs +0 -292
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as admits } from "../semver-BDxeEcP_.mjs";
3
- 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
+ import { 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";
4
4
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
5
- import { a as RENOVATE_CONFIGS, c as GITATTRIBUTES, d as enforcesLf, f as CI_CONTEXT, h as CI_RENOVATE_SYNC_REF, m as CI_PATH, n as ciNodeCallers, o as RENOVATE_PRESET, p as CI_NODE_REF, r as ciRenovateSyncCallers, u as LF_ATTRIBUTES } from "../workflow-C-oBwL2H.mjs";
5
+ import { _ as ciRenovateSyncCallers, c as CI_CONTEXT, d as CI_RENOVATE_SYNC_REF, g as ciNodeCallers, i as GITATTRIBUTES, l as CI_NODE_REF, n as RENOVATE_PRESET, o as LF_ATTRIBUTES, s as enforcesLf, t as RENOVATE_CONFIGS, u as CI_PATH } from "../renovate-D0su_v9p.mjs";
6
6
  import { n as tagVersion, r as tooling, t as TOOLING_PACKAGE } from "../npm-CIIqL5SG.mjs";
7
7
  import { i as ghToken, n as createApi, t as ApiError } from "../api-BQLrI_S1.mjs";
8
- import { parseDocument } from "yaml";
9
8
  import { parseArgs } from "node:util";
10
9
  import { inflateRawSync } from "node:zlib";
11
10
  //#region src/garden/decode.ts
@@ -30,6 +29,7 @@ function workflowRun(value) {
30
29
  updatedAt: time(source, "updated_at"),
31
30
  url: str(source, "html_url"),
32
31
  headSha: optStr(source, "head_sha") ?? "",
32
+ event: optStr(source, "event") ?? "",
33
33
  referencedWorkflows: (source.referenced_workflows === null ? [] : children(source, "referenced_workflows")).map((workflow) => ({
34
34
  path: str(workflow, "path"),
35
35
  sha: optStr(workflow, "sha") ?? ""
@@ -119,6 +119,7 @@ const PACKS = [
119
119
  "template",
120
120
  "none"
121
121
  ];
122
+ const INTEGRATION_BRANCHES = ["next", "develop"];
122
123
  const TIERS = [
123
124
  "N1",
124
125
  "N2",
@@ -187,7 +188,6 @@ var GardenContext = class {
187
188
  pulls = new Memo();
188
189
  alertLists = new Memo();
189
190
  packuments = new Memo();
190
- removals = new Memo();
191
191
  searches = new Memo();
192
192
  branchLists = new Memo();
193
193
  closed = new Memo();
@@ -222,17 +222,29 @@ var GardenContext = class {
222
222
  async scope() {
223
223
  return (await this.repos()).filter(isInScope);
224
224
  }
225
+ /** The branch whose CI judges the repository: `next`, else `develop`, the cloud's integration branch, else the default branch. */
225
226
  async targetBranch(repo) {
226
227
  return this.branches.get(repo.name, async () => {
227
- try {
228
- await this.api.json(`/repos/${ORG}/${repo.name}/branches/next`);
229
- return "next";
230
- } catch (error) {
231
- if (error instanceof Error && isMissing(error)) return repo.defaultBranch;
232
- throw error;
233
- }
228
+ for (const branch of INTEGRATION_BRANCHES) if (await this.hasBranch(repo, branch)) return branch;
229
+ return repo.defaultBranch;
234
230
  });
235
231
  }
232
+ async hasBranch(repo, branch) {
233
+ try {
234
+ await this.api.json(`/repos/${ORG}/${repo.name}/branches/${branch}`);
235
+ return true;
236
+ } catch (error) {
237
+ if (error instanceof Error && isMissing(error)) return false;
238
+ throw error;
239
+ }
240
+ }
241
+ /**
242
+ * Completed runs of a workflow that judge a branch, newest first: its pushes, and the nightly schedule, which runs on
243
+ * the default branch since a push there no longer runs CI. Undefined when the workflow does not exist.
244
+ */
245
+ async branchRuns(repo, workflow, branch) {
246
+ return (await this.workflowRuns(repo, workflow, branch, ""))?.filter(({ event }) => event === "push" || event === "schedule");
247
+ }
236
248
  tree(repo) {
237
249
  return this.trees.get(repo.name, async () => {
238
250
  const body = object(await this.api.json(`/repos/${ORG}/${repo.name}/git/trees/${repo.defaultBranch}?recursive=1`), "tree");
@@ -330,17 +342,6 @@ var GardenContext = class {
330
342
  throw error;
331
343
  }
332
344
  }
333
- /** Whether a commit of the default branch history removed the file; looks at the 30 newest commits that touched it. */
334
- removedInHistory(repo, path) {
335
- return this.removals.get(`${repo.name}:${path}`, async () => {
336
- const commits = list(await this.api.json(`/repos/${ORG}/${repo.name}/commits?path=${path}&sha=${repo.defaultBranch}&per_page=30`), "commits");
337
- for (const commit of commits) {
338
- const detail = object(await this.api.json(`/repos/${ORG}/${repo.name}/commits/${str(object(commit, "commit"), "sha")}`), "commit");
339
- if (children(detail, "files").some((file) => str(file, "filename") === path && optStr(file, "status") === "removed")) return true;
340
- }
341
- return false;
342
- });
343
- }
344
345
  packument(name) {
345
346
  return this.packuments.get(name, () => this.api.npm(name));
346
347
  }
@@ -482,7 +483,7 @@ function firstZipEntry(archive) {
482
483
  }
483
484
  //#endregion
484
485
  //#region src/garden/checks/artifacts.ts
485
- const WORKFLOWS_REPO$1 = ".github";
486
+ const WORKFLOWS_REPO = ".github";
486
487
  async function latestReport(context, repo, name) {
487
488
  const [latest] = await context.artifactsNamed(repo, name);
488
489
  if (latest === void 0) return void 0;
@@ -492,8 +493,8 @@ async function latestReport(context, repo, name) {
492
493
  const linkRot = {
493
494
  id: "link-rot",
494
495
  async run(context) {
495
- if (!await context.exists(WORKFLOWS_REPO$1, ".github/workflows/link-rot.yml")) return skip("AntelopeJS/.github has no link-rot.yml yet");
496
- const report = await latestReport(context, WORKFLOWS_REPO$1, "link-rot");
496
+ if (!await context.exists(WORKFLOWS_REPO, ".github/workflows/link-rot.yml")) return skip("AntelopeJS/.github has no link-rot.yml yet");
497
+ const report = await latestReport(context, WORKFLOWS_REPO, "link-rot");
497
498
  if (report === void 0) return skip("no link-rot artifact exists yet");
498
499
  const repos = object(report.repos ?? {}, "repos");
499
500
  const findings = [];
@@ -546,8 +547,8 @@ async function perRepo(repos, scan) {
546
547
  //#endregion
547
548
  //#region src/garden/checks/ci-health.ts
548
549
  const DAY$4 = 864e5;
549
- const WORKFLOW$1 = "ci.yml";
550
- const CALLER = `.github/workflows/${WORKFLOW$1}`;
550
+ const WORKFLOW = "ci.yml";
551
+ const CALLER = `.github/workflows/${WORKFLOW}`;
551
552
  const RECENT_RUNS = 10;
552
553
  const MIN_BASELINE = 5;
553
554
  const RELATIVE_LIMIT = 1.2;
@@ -577,14 +578,14 @@ function redSince(runs) {
577
578
  }
578
579
  async function red(context, repo) {
579
580
  const branch = await context.targetBranch(repo);
580
- const runs = await context.workflowRuns(repo, WORKFLOW$1, branch);
581
+ const runs = await context.branchRuns(repo, WORKFLOW, branch);
581
582
  const since = runs === void 0 ? void 0 : redSince(runs);
582
583
  if (since === void 0 || context.api.now().getTime() - since.createdAt <= DAY$4) return [];
583
584
  return [finding({
584
585
  repo: repo.name,
585
586
  check: "red-branch",
586
587
  subject: branch
587
- }, `${WORKFLOW$1} has been red on ${branch} since ${new Date(since.createdAt).toISOString()}: ${since.url}`, `${WORKFLOW$1} is green on ${branch}.`)];
588
+ }, `${WORKFLOW} has been red on ${branch} since ${new Date(since.createdAt).toISOString()}: ${since.url}`, `${WORKFLOW} is green on ${branch}.`)];
588
589
  }
589
590
  /** A reusable workflow path without its `@ref`, e.g. `AntelopeJS/.github/.github/workflows/ci-node.yml`. */
590
591
  function workflowPath(path) {
@@ -624,7 +625,7 @@ async function callerChange(context, repo, branch, newest) {
624
625
  }
625
626
  async function slow(context, repo) {
626
627
  const branch = await context.targetBranch(repo);
627
- const runs = await context.workflowRuns(repo, WORKFLOW$1, branch);
628
+ const runs = await context.branchRuns(repo, WORKFLOW, branch);
628
629
  if (runs === void 0) return [];
629
630
  const passed = runs.filter((run) => run.conclusion === "success");
630
631
  const cutoff = Math.max(context.api.now().getTime() - 30 * DAY$4, await callerChange(context, repo, branch, passed[0]));
@@ -640,7 +641,7 @@ async function slow(context, repo) {
640
641
  repo: repo.name,
641
642
  check: "ci-duration",
642
643
  subject: branch
643
- }, `The median of the last ${RECENT_RUNS} ${WORKFLOW$1} runs on ${branch} is ${Math.round(recent)} s against ${Math.round(usual)} s over the earlier runs since ${since}, the latest of 30 days ago, the last change to ${CALLER} or a workflow file of this repository it calls, and the last change to the shared workflows it calls.`, `The median is within 20% and 60 s of the baseline since the last change to what ${WORKFLOW$1} runs.`)];
644
+ }, `The median of the last ${RECENT_RUNS} ${WORKFLOW} runs on ${branch} is ${Math.round(recent)} s against ${Math.round(usual)} s over the earlier runs since ${since}, the latest of 30 days ago, the last change to ${CALLER} or a workflow file of this repository it calls, and the last change to the shared workflows it calls.`, `The median is within 20% and 60 s of the baseline since the last change to what ${WORKFLOW} runs.`)];
644
645
  }
645
646
  const redBranch = {
646
647
  id: "red-branch",
@@ -662,7 +663,7 @@ const ciDuration = {
662
663
  };
663
664
  //#endregion
664
665
  //#region src/garden/checks/branches.ts
665
- const CHECK$2 = "stale-branches";
666
+ const CHECK$1 = "stale-branches";
666
667
  const SUBJECT = "branches";
667
668
  const DAY$3 = 864e5;
668
669
  const INACTIVE_DAYS = 30;
@@ -715,13 +716,13 @@ function report(repo, prunes) {
715
716
  if (!prunes.length) return [];
716
717
  return [finding({
717
718
  repo: repo.name,
718
- check: CHECK$2,
719
+ check: CHECK$1,
719
720
  subject: SUBJECT
720
721
  }, prunes.map(({ branch, reason }) => `${branch} (${reason})`).join(", "), `No branch other than the default, next and protected ones is the head of a merged or closed PR, or has no open PR and no commit for ${INACTIVE_DAYS} days.`)];
721
722
  }
722
723
  /** Lists, per repository, the branches `--apply-prunes` would delete. */
723
724
  const staleBranches = {
724
- id: CHECK$2,
725
+ id: CHECK$1,
725
726
  async run(context) {
726
727
  return perRepo(await context.scope(), async (repo) => report(repo, await prunable(context, repo)));
727
728
  }
@@ -729,7 +730,7 @@ const staleBranches = {
729
730
  /** The deletions behind each stale-branches finding, re-read from the API given so a branch that gained an open PR or a commit since the scan is kept; a repository whose read failed is never pruned. */
730
731
  async function plannedPrunes(api, findings) {
731
732
  const fresh = new GardenContext(api);
732
- const flagged = new Set(findings.filter((entry) => entry.check === CHECK$2).map((entry) => entry.repo));
733
+ const flagged = new Set(findings.filter((entry) => entry.check === CHECK$1).map((entry) => entry.repo));
733
734
  const prunes = [];
734
735
  const failed = [];
735
736
  const scope = await fresh.scope().catch((error) => {
@@ -755,7 +756,7 @@ async function applyPrunes(api, prunes) {
755
756
  }
756
757
  //#endregion
757
758
  //#region src/garden/checks/conformance.ts
758
- const CHECK$1 = "conformance";
759
+ const CHECK = "conformance";
759
760
  const DAY$2 = 864e5;
760
761
  const MEND_EXEMPT = /* @__PURE__ */ new Set(["k8s-gitops-infra"]);
761
762
  /** Repositories whose ci.yml runs its own jobs: tooling-configs shards its tests and checks its docs action at HEAD, which ci-node.yml cannot do. */
@@ -763,7 +764,7 @@ const CI_CALLER_EXEMPT = /* @__PURE__ */ new Set(["tooling-configs"]);
763
764
  function problem(repo, subject, evidence, doneMeans) {
764
765
  return finding({
765
766
  repo: repo.name,
766
- check: CHECK$1,
767
+ check: CHECK,
767
768
  subject
768
769
  }, evidence, doneMeans);
769
770
  }
@@ -778,7 +779,7 @@ async function ciCaller(context, repo) {
778
779
  if (unpinned.length === callers.length) findings.push(problem(repo, "ci-caller", `${CI_PATH} calls ${unpinned[0].uses}.`, `The caller uses ${CI_NODE_REF}.`));
779
780
  if (!callers.some(({ id, named }) => id === "ci" && !named)) findings.push(problem(repo, "ci-job-id", `The caller job is ${callers[0].id}${callers[0].named ? " with a name" : ""}, so the check is not reported as ${CI_CONTEXT}.`, `antelopejs-sync has renamed the caller job to ci and removed its name.`));
780
781
  const syncCallers = ciRenovateSyncCallers(text);
781
- if (!syncCallers.some(({ uses }) => uses === "AntelopeJS/.github/.github/workflows/ci-renovate-sync.yml@v1")) findings.push(problem(repo, "ci-renovate-sync", syncCallers.length ? `${CI_PATH} calls ${syncCallers[0].uses}.` : `${CI_PATH} has no job calling ci-renovate-sync.yml.`, `${CI_PATH} has a job calling ${CI_RENOVATE_SYNC_REF}.`));
782
+ if (!syncCallers.some(({ uses }) => uses === CI_RENOVATE_SYNC_REF)) findings.push(problem(repo, "ci-renovate-sync", syncCallers.length ? `${CI_PATH} calls ${syncCallers[0].uses}.` : `${CI_PATH} has no job calling ci-renovate-sync.yml.`, `${CI_PATH} has a job calling ${CI_RENOVATE_SYNC_REF}.`));
782
783
  return findings;
783
784
  }
784
785
  async function renovateConfig(context, repo) {
@@ -806,17 +807,12 @@ async function toolingVersion(context, repo) {
806
807
  }
807
808
  async function checksStatus(context, repo) {
808
809
  const branch = await context.targetBranch(repo);
809
- const [latest] = await context.workflowRuns(repo, "ci.yml", branch) ?? [];
810
+ const [latest] = await context.branchRuns(repo, "ci.yml", branch) ?? [];
810
811
  const runs = (await context.checkRuns(repo, latest?.headSha || branch)).filter(({ name }) => name === CI_CONTEXT || name === "checks");
811
812
  const reported = runs.find(({ name }) => name === CI_CONTEXT);
812
813
  if (reported === void 0) return [problem(repo, "checks-context", `${branch} reports ${runs.length ? runs.map(({ name }) => name).join(", ") : "no checks"} instead of ${CI_CONTEXT}.`, `The latest run on ${branch} reports ${CI_CONTEXT}.`)];
813
814
  return reported.conclusion === "success" ? [] : [problem(repo, "checks-red", `${CI_CONTEXT} on ${branch} is ${reported.conclusion ?? "pending"}: ${reported.url}`, `${CI_CONTEXT} is green on ${branch}.`)];
814
815
  }
815
- const GUARDRAILS_RATCHET = "guardrails.ratchet.json";
816
- async function cleanRatchet(context, repo) {
817
- if (!(await context.tree(repo)).includes(GUARDRAILS_RATCHET) || !await context.removedInHistory(repo, GUARDRAILS_RATCHET)) return [];
818
- return [problem(repo, "ratchet", `${GUARDRAILS_RATCHET} is back after the history deleted it.`, `${GUARDRAILS_RATCHET} is deleted again.`)];
819
- }
820
816
  const BRANCH_CLEANUP = "delete-branch-on-merge";
821
817
  async function branchCleanup(context, repo) {
822
818
  return await context.deletesBranchOnMerge(repo) ? [] : [problem(repo, BRANCH_CLEANUP, "delete_branch_on_merge is off, so merged head branches stay behind.", "delete_branch_on_merge is on; antelopejs-garden --apply turns it on.")];
@@ -831,7 +827,7 @@ const deleteBranchOnMerge = {
831
827
  /** Turns `delete_branch_on_merge` on for each repository a finding reports it off on, and writes nothing else; returns the writes that failed. */
832
828
  async function applySettings(api, findings) {
833
829
  const failed = [];
834
- for (const entry of findings) if (entry.check === CHECK$1 && entry.subject === BRANCH_CLEANUP) await api.send("PATCH", `/repos/${ORG}/${entry.repo}`, { delete_branch_on_merge: true }).catch((error) => {
830
+ for (const entry of findings) if (entry.check === CHECK && entry.subject === BRANCH_CLEANUP) await api.send("PATCH", `/repos/${ORG}/${entry.repo}`, { delete_branch_on_merge: true }).catch((error) => {
835
831
  failed.push(`${entry.repo}: ${error instanceof Error ? error.message : String(error)}`);
836
832
  });
837
833
  return failed;
@@ -841,8 +837,7 @@ async function scan(context, repo) {
841
837
  ...await ciCaller(context, repo),
842
838
  ...await renovateConfig(context, repo),
843
839
  ...await toolingVersion(context, repo),
844
- ...await checksStatus(context, repo),
845
- ...await cleanRatchet(context, repo)
840
+ ...await checksStatus(context, repo)
846
841
  ];
847
842
  }
848
843
  async function newRepos(context) {
@@ -853,7 +848,7 @@ async function mendSelection(context) {
853
848
  return (await context.repos()).filter((repo) => repo.tier !== "N4" && !MEND_EXEMPT.has(repo.name) && !active.has(repo.name)).map((repo) => problem(repo, "renovate-app", "No issue or pull request from the Renovate app: the repository is not in the app's selection.", "Antony adds the repository to the Mend Renovate app's selected repositories."));
854
849
  }
855
850
  const conformance = {
856
- id: CHECK$1,
851
+ id: CHECK,
857
852
  async run(context) {
858
853
  const scanned = await perRepo(await context.scope(), (repo) => scan(context, repo));
859
854
  const extra = [...await newRepos(context), ...await mendSelection(context)];
@@ -1211,99 +1206,6 @@ const packageSize = {
1211
1206
  }
1212
1207
  };
1213
1208
  //#endregion
1214
- //#region src/garden/workflow-windows.ts
1215
- const CI_NODE$1 = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@(\S+)$/;
1216
- const CI_EVENTS = /* @__PURE__ */ new Set([
1217
- "pull_request",
1218
- "pull_request_target",
1219
- "push",
1220
- "merge_group"
1221
- ]);
1222
- const WINDOWS = /windows/i;
1223
- const EXPRESSION = /\$\{\{/;
1224
- const MATRIX_KEY = /\bmatrix\.([\w-]+)/g;
1225
- const ALWAYS = /^\s*\$\{\{\s*true\s*\}\}\s*$/;
1226
- const NEVER = /^\s*\$\{\{\s*false\s*\}\}\s*$/;
1227
- /** The workflow as JSON, its anchors, aliases and merge keys resolved; undefined when the YAML does not parse. */
1228
- function workflow(text) {
1229
- const document = parseDocument(text, { merge: true });
1230
- if (document.errors.length) return void 0;
1231
- const value = parseJson(JSON.stringify(document.toJS({ maxAliasCount: 1e3 }) ?? null));
1232
- return isObject(value) ? value : void 0;
1233
- }
1234
- /** Every string in `value`, nested lists and object values included. */
1235
- function texts(value) {
1236
- if (value === null) return [];
1237
- if (isString(value)) return [value];
1238
- if (Array.isArray(value)) return value.flatMap(texts);
1239
- if (isObject(value)) return Object.values(value).flatMap(texts);
1240
- return [];
1241
- }
1242
- function own(source, key) {
1243
- return Object.hasOwn(source, key) ? source[key] : null;
1244
- }
1245
- function at(value, keys) {
1246
- return keys.reduce((node, key) => node !== null && isObject(node) ? own(node, key) : null, value);
1247
- }
1248
- function triggers(on) {
1249
- if (on !== null && isObject(on)) return Object.keys(on);
1250
- return texts(on);
1251
- }
1252
- function entries(value) {
1253
- return Array.isArray(value) ? value.filter(isObject) : [];
1254
- }
1255
- /** The values the matrix gives `key`: its own list and `include` entries, less the values a single-key `exclude` entry drops. */
1256
- function legs(matrix, key) {
1257
- const dropped = new Set(entries(own(matrix, "exclude")).filter((entry) => Object.keys(entry).length === 1).flatMap((entry) => texts(own(entry, key))));
1258
- return [...texts(own(matrix, key)), ...entries(own(matrix, "include")).flatMap((entry) => texts(own(entry, key)))].filter((value) => !dropped.has(value));
1259
- }
1260
- function runnerIsWindows(job) {
1261
- const labels = texts(own(job, "runs-on"));
1262
- if (labels.some((label) => WINDOWS.test(label))) return true;
1263
- const strategy = own(job, "strategy");
1264
- const matrix = strategy !== null && isObject(strategy) ? own(strategy, "matrix") : null;
1265
- if (matrix === null) return false;
1266
- if (!isObject(matrix)) return texts(matrix).some((value) => WINDOWS.test(value));
1267
- return labels.filter((label) => EXPRESSION.test(label)).flatMap((label) => [...label.matchAll(MATRIX_KEY)].map((match) => match[1])).some((key) => legs(matrix, key).some((value) => WINDOWS.test(value)));
1268
- }
1269
- async function jobRunsOnWindows(job, windowsDefault) {
1270
- const condition = own(job, "if");
1271
- if (condition === false || isString(condition) && NEVER.test(condition)) return false;
1272
- const uses = own(job, "uses");
1273
- const ref = isString(uses) ? CI_NODE$1.exec(uses)?.[1] : void 0;
1274
- if (ref === void 0) return runnerIsWindows(job);
1275
- const windows = at(job, ["with", "windows"]);
1276
- if (windows === null) return windowsDefault(ref);
1277
- return windows === true || isString(windows) && ALWAYS.test(windows);
1278
- }
1279
- /** Whether a ci-node.yml, given as its text, defaults its `windows` input to true. False when the YAML does not parse. */
1280
- function windowsByDefault(ciNode) {
1281
- const parsed = workflow(ciNode);
1282
- return parsed !== void 0 && at(parsed, [
1283
- "on",
1284
- "workflow_call",
1285
- "inputs",
1286
- "windows",
1287
- "default"
1288
- ]) === true;
1289
- }
1290
- /**
1291
- * Whether a workflow file runs a job on Windows for pull requests or pushes: a ci-node.yml caller with
1292
- * `windows: true`, or with no `windows` input when `windowsDefault` says the ci-node.yml at the caller's ref
1293
- * defaults it to true, or a job whose `runs-on`, or the matrix value it reads, names a Windows runner. A
1294
- * workflow on other events only, a job whose `if` is false, and matrix values `exclude` drops do not count.
1295
- * False when the YAML does not parse.
1296
- */
1297
- async function runsOnWindows(text, windowsDefault) {
1298
- const parsed = workflow(text);
1299
- if (parsed === void 0) return false;
1300
- if (!triggers(own(parsed, "on")).some((event) => CI_EVENTS.has(event))) return false;
1301
- const jobs = own(parsed, "jobs");
1302
- if (jobs === null || !isObject(jobs)) return false;
1303
- for (const job of Object.values(jobs)) if (job !== null && isObject(job) && await jobRunsOnWindows(job, windowsDefault)) return true;
1304
- return false;
1305
- }
1306
- //#endregion
1307
1209
  //#region src/garden/stack.ts
1308
1210
  const FRAMEWORK = /* @__PURE__ */ new Set([
1309
1211
  "antelopejs",
@@ -1336,40 +1238,14 @@ const FAMILIES = [
1336
1238
  "dms-"
1337
1239
  ];
1338
1240
  const RETIRED = /* @__PURE__ */ new Set(["dms-builder"]);
1339
- /** Whether a repository belongs to the framework and DMS stack, whose CI must run on Windows: the framework, its interfaces, modules and templates, and the DMS repositories. */
1241
+ /** Whether a repository belongs to the framework and DMS stack, whose clones must keep LF line endings: the framework, its interfaces, modules and templates, and the DMS repositories. */
1340
1242
  function isStackRepo(name) {
1341
1243
  if (RETIRED.has(name)) return false;
1342
1244
  return FRAMEWORK.has(name) || MODULES.has(name) || FAMILIES.some((prefix) => name.startsWith(prefix));
1343
1245
  }
1344
1246
  //#endregion
1345
- //#region src/garden/checks/windows.ts
1346
- const CHECK = "windows-ci";
1247
+ //#region src/garden/checks/line-endings.ts
1347
1248
  const LINE_ENDINGS = "line-endings";
1348
- const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
1349
- const WORKFLOWS_REPO = ".github";
1350
- const CI_NODE = ".github/workflows/ci-node.yml";
1351
- /** Reports every framework and DMS stack repository whose workflows run no job on Windows. */
1352
- const windowsCi = {
1353
- id: CHECK,
1354
- async run(context) {
1355
- const repos = await context.repos();
1356
- const workflowsRepo = repos.find(({ name }) => name === WORKFLOWS_REPO);
1357
- const windowsDefault = async (ref) => {
1358
- if (workflowsRepo === void 0) return false;
1359
- const ciNode = await context.file(workflowsRepo, CI_NODE, ref);
1360
- return ciNode !== void 0 && windowsByDefault(ciNode);
1361
- };
1362
- return perRepo(repos.filter(({ name }) => isStackRepo(name)), async (repo) => {
1363
- const workflows = (await context.tree(repo)).filter((path) => WORKFLOW.test(path));
1364
- for (const path of workflows) if (await runsOnWindows(await context.file(repo, path) ?? "", windowsDefault)) return [];
1365
- return [finding({
1366
- repo: repo.name,
1367
- check: CHECK,
1368
- subject: "windows"
1369
- }, workflows.length ? `No job in ${workflows.join(", ")} runs on Windows.` : "The repository has no workflow.", "The ci-node.yml caller passes windows: true or leaves it at a true default, or a workflow job runs on windows-latest.")];
1370
- });
1371
- }
1372
- };
1373
1249
  /** Reports every framework and DMS stack repository whose `.gitattributes` does not check text files out with LF, so a Windows clone keeps its shell scripts runnable. */
1374
1250
  const lineEndings = {
1375
1251
  id: LINE_ENDINGS,
@@ -1534,7 +1410,6 @@ const CHECKS = [
1534
1410
  webBuild,
1535
1411
  linkRot,
1536
1412
  captureScenes,
1537
- windowsCi,
1538
1413
  lineEndings,
1539
1414
  staleBranches
1540
1415
  ];
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { d as toolingRoot } from "../package-1pH5I0TF.mjs";
2
+ import { d as toolingRoot } from "../package-7oylgBeT.mjs";
3
3
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
- import { c as repositoryRoot } from "../files-C-JJhExM.mjs";
4
+ import { s as repositoryRoot } from "../files-BbzJEk-L.mjs";
5
5
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { parseArgs } from "node:util";
@@ -1,14 +1,104 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
- import { c as repositoryRoot, r as changedFiles } from "../files-C-JJhExM.mjs";
4
- import { t as directiveReport } from "../oxlint-CIeonWMB.mjs";
5
- import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-BeJIgSTO.mjs";
6
- import { c as suppressionsIn, i as inWorktree } from "../suppressions-BvWGA463.mjs";
7
- import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-CDiFJse2.mjs";
8
- import { readdirSync } from "node:fs";
9
- import { join, posix } from "node:path";
3
+ import { a as isAgentFile, c as resolveRevision, n as changedFiles, o as repositoryPath, s as repositoryRoot } from "../files-BbzJEk-L.mjs";
4
+ import { a as parseBudget, c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, n as SUPPRESSIONS_FILE, o as safetyCeiling, s as stagedNames, u as coveredLimits } from "../suppression-budget-De9nUzlD.mjs";
5
+ import { c as suppressionsIn, i as inWorktree, o as revisionSuppressions, r as countSuppressions } from "../suppressions-CfJwL0fN.mjs";
6
+ import { createRequire } from "node:module";
7
+ import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
8
+ import { basename, dirname, join, posix } from "node:path";
10
9
  import { execFileSync, spawnSync } from "node:child_process";
11
10
  import { parseArgs } from "node:util";
11
+ //#region src/guardrails/oxlint.ts
12
+ function resolveOxlint(root) {
13
+ try {
14
+ const require = createRequire(join(root, "package.json"));
15
+ return join(dirname(require.resolve("oxlint/package.json")), "bin/oxlint");
16
+ } catch {
17
+ throw new Error("oxlint is not installed in this repository. Install dependencies first.");
18
+ }
19
+ }
20
+ const NO_FILES = "No files found to lint.";
21
+ const PLUGIN_ERROR = "Error running JS plugin.";
22
+ /** Whether oxlint matched no file, in which case it prints a notice before its report and exits 1. */
23
+ function foundNoFiles(stdout) {
24
+ return stdout.startsWith(NO_FILES) && stdout.includes("{");
25
+ }
26
+ /** The `-f json` report in oxlint's stdout, or undefined when oxlint printed an error in its place. */
27
+ function parseReport(text) {
28
+ const json = foundNoFiles(text) ? text.slice(text.indexOf("{")) : text;
29
+ if (!json.startsWith("{")) return void 0;
30
+ const report = JSON.parse(json);
31
+ if (!Array.isArray(report?.diagnostics)) throw new Error("oxlint did not return a JSON diagnostics array.");
32
+ return report.diagnostics;
33
+ }
34
+ function runOxlint(root, config, files, flags) {
35
+ const binary = resolveOxlint(root);
36
+ const temporary = config === void 0 ? void 0 : mkdtempSync(join(root, ".antelopejs-measure.generated."));
37
+ try {
38
+ const args = [
39
+ binary,
40
+ "-f",
41
+ "json",
42
+ ...flags
43
+ ];
44
+ if (temporary) {
45
+ const path = join(temporary, "oxlint.config.ts");
46
+ writeFileSync(path, config ?? "");
47
+ args.push("--config", path, "--ignore-pattern", `${basename(temporary)}/**`);
48
+ }
49
+ if (files) args.push("--no-error-on-unmatched-pattern", "--", ...files);
50
+ const result = spawnSync(process.execPath, args, {
51
+ cwd: root,
52
+ encoding: "utf8",
53
+ maxBuffer: 67108864
54
+ });
55
+ if (result.error) throw result.error;
56
+ if (result.status !== 0 && result.status !== 1) throw new Error(`oxlint failed (${result.status ?? result.signal}): ${result.stderr || result.stdout}`);
57
+ const diagnostics = parseReport(result.stdout);
58
+ if (diagnostics === void 0) throw new Error(`oxlint failed (exit ${result.status}): ${result.stdout}${result.stderr}`.trimEnd());
59
+ if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
60
+ const crash = diagnostics.find(({ code, message }) => code === void 0 && message.startsWith(PLUGIN_ERROR));
61
+ if (crash) throw new Error(crash.message);
62
+ return diagnostics;
63
+ } finally {
64
+ if (temporary) rmSync(temporary, {
65
+ recursive: true,
66
+ force: true
67
+ });
68
+ }
69
+ }
70
+ const UNUSED_RULES = /\(no problems were reported from (.+)\)/u;
71
+ function isUnusedDirective(message) {
72
+ return message.startsWith("Unused ") && message.includes("-disable directive");
73
+ }
74
+ /**
75
+ * The disable directives in `files` that suppress nothing and the files
76
+ * oxlint could not read.
77
+ * `files` must not be empty, which would lint the whole repository.
78
+ */
79
+ function directiveReport(root, files) {
80
+ const report = {
81
+ unused: [],
82
+ unreadable: []
83
+ };
84
+ for (const item of runOxlint(root, void 0, files, ["--report-unused-disable-directives"])) {
85
+ if (item.code !== void 0) continue;
86
+ const file = item.filename === void 0 ? void 0 : repositoryPath(root, item.filename);
87
+ const span = item.labels?.[0]?.span;
88
+ if (file !== void 0 && isUnusedDirective(item.message)) report.unused.push({
89
+ file,
90
+ line: span?.line ?? 0,
91
+ message: item.message,
92
+ rules: UNUSED_RULES.exec(item.message)?.[1].split(/,\s*/u)
93
+ });
94
+ else report.unreadable.push({
95
+ location: file !== void 0 && span ? `${file}:${span.line}:${span.column}` : file,
96
+ message: item.message
97
+ });
98
+ }
99
+ return report;
100
+ }
101
+ //#endregion
12
102
  //#region src/guardrails/dead-directives.ts
13
103
  const BLOCK_DISABLE = /-disable$/u;
14
104
  const ESLINT_CONFIG = /^(?:eslint\.config\.[cm]?[jt]s|\.eslintrc(?:\..+)?)$/u;
@@ -62,8 +152,8 @@ function reasonlessFailure(directive) {
62
152
  }
63
153
  /**
64
154
  * Fails, in each of `files`, every lint directive that suppresses nothing
65
- * under the repository's own lint configuration with its ratchet rules
66
- * enabled, and every directive naming rules that gives no reason. Directives
155
+ * under the repository's own lint configuration, and every directive naming
156
+ * rules that gives no reason. Directives
67
157
  * in other files are left alone, so adopting the check changes no existing
68
158
  * file until a change touches it. `eslint-` directives under an ESLint config
69
159
  * are left to ESLint, and `.vue` files are not linted by oxlint.
@@ -125,6 +215,119 @@ function touchedFiles(root, revision) {
125
215
  return [.../* @__PURE__ */ new Set([...tracked.split("\0"), ...changedFiles(root)])].filter(Boolean);
126
216
  }
127
217
  //#endregion
218
+ //#region src/guardrails/suppression-base.ts
219
+ function verified(root, ref) {
220
+ const result = spawnSync("git", [
221
+ "rev-parse",
222
+ "--verify",
223
+ "--quiet",
224
+ "--end-of-options",
225
+ `${ref}^{commit}`
226
+ ], {
227
+ cwd: root,
228
+ encoding: "utf8"
229
+ });
230
+ return result.status === 0 ? result.stdout.trim() : void 0;
231
+ }
232
+ function fetchBase(root, branch, remote) {
233
+ const result = spawnSync("git", [
234
+ "fetch",
235
+ "--quiet",
236
+ "--no-tags",
237
+ "--depth=1",
238
+ "origin",
239
+ `+refs/heads/${branch}:${remote}`
240
+ ], {
241
+ cwd: root,
242
+ encoding: "utf8",
243
+ env: {
244
+ ...process.env,
245
+ GIT_TERMINAL_PROMPT: "0"
246
+ },
247
+ stdio: [
248
+ "ignore",
249
+ "ignore",
250
+ "pipe"
251
+ ]
252
+ });
253
+ if (result.status === 0) return;
254
+ const detail = result.error?.message ?? result.stderr.trim();
255
+ throw new Error(`Cannot compare with the pull request base: ${remote} is missing and fetching ${branch} from origin failed${detail ? ` (${detail})` : ""}. In CI, fetch the base branch before this check with credentials, or pass --base.`);
256
+ }
257
+ /**
258
+ * The commit a pull request merges into: `base` when given; in CI the
259
+ * `GITHUB_BASE_REF` branch, taken from the local `origin/<branch>` ref when
260
+ * present and otherwise fetched from `origin`, an error naming the missing ref
261
+ * when the fetch fails; otherwise `origin/HEAD`, the remote's default branch.
262
+ * A requested base that cannot be resolved is an error; without one, a
263
+ * repository with no `origin/HEAD` has no base.
264
+ */
265
+ function suppressionBase(root, base) {
266
+ if (base !== void 0) return resolveRevision(root, base);
267
+ const branch = process.env.GITHUB_BASE_REF;
268
+ if (branch) {
269
+ const remote = `refs/remotes/origin/${branch}`;
270
+ if (verified(root, remote) === void 0) fetchBase(root, branch, remote);
271
+ return resolveRevision(root, remote);
272
+ }
273
+ return verified(root, "refs/remotes/origin/HEAD");
274
+ }
275
+ function agentFilesDropped(base, current) {
276
+ return base.agentFiles && !current.agentFiles ? [`${SUPPRESSIONS_FILE}: drops agentFiles, which the base has. Keep it; the repository's own files under the agent directories stay counted.`] : [];
277
+ }
278
+ /** What the agent directories hold, when `current` begins recording them and `base` does not; nothing otherwise. */
279
+ function adoptableAgentCounts(root, revision, base, current) {
280
+ const none = {
281
+ rules: {},
282
+ config: {},
283
+ tsExpectError: 0,
284
+ tsIgnore: 0,
285
+ safety: 0
286
+ };
287
+ if (base.agentFiles || !current.agentFiles) return none;
288
+ const counts = countSuppressions(revisionSuppressions(root, revision).filter(({ file }) => isAgentFile(file)));
289
+ return {
290
+ ...counts,
291
+ config: counts.config ?? {}
292
+ };
293
+ }
294
+ /**
295
+ * Fails each ceiling of the working-tree budget that is higher than on
296
+ * `revision`, and each rule that `revision` lists but the working tree
297
+ * dropped, config rule-offs included once the base has their ceilings; a
298
+ * config ceiling may rise by what a containing scope of its rule falls. The
299
+ * safety ceiling may rise by what the SAFETY rule's own ceiling falls. A
300
+ * base that does not record the agent directories' files lets the working
301
+ * tree record them, each ceiling rising by no more than its count there; a
302
+ * base that does must keep recording them. A base without a budget, a first
303
+ * adoption, passes.
304
+ */
305
+ function raisedCeilings(root, revision) {
306
+ const committed = spawnSync("git", ["show", `${revision}:${SUPPRESSIONS_FILE}`], {
307
+ cwd: root,
308
+ encoding: "utf8"
309
+ });
310
+ if (committed.status !== 0) return [];
311
+ const label = `${revision.slice(0, 12)}:${SUPPRESSIONS_FILE}`;
312
+ const base = parseBudget(committed.stdout, label);
313
+ const current = parseBudget(readFileSync(join(root, SUPPRESSIONS_FILE), "utf8"), SUPPRESSIONS_FILE);
314
+ const failures = agentFilesDropped(base, current);
315
+ const room = adoptableAgentCounts(root, revision, base, current);
316
+ const compare = (key, ceiling, after, adoptable = 0) => {
317
+ const before = ceiling + adoptable;
318
+ if (after === void 0) failures.push(`${SUPPRESSIONS_FILE}: removes ${key}, which has ceiling ${before} on the base. Keep the key; lower it with suppressions:update.`);
319
+ else if (after > before) failures.push(`${SUPPRESSIONS_FILE}: raises ${key} from ${ceiling} on the base to ${after}${adoptable ? `, above the ${before} that recording the agent files allows` : ""}.`);
320
+ };
321
+ for (const rule of /* @__PURE__ */ new Set([...Object.keys(base.rules), ...Object.keys(current.rules)])) compare(`lint rule \`${rule}\``, base.rules[rule] ?? 0, Object.hasOwn(base.rules, rule) ? current.rules[rule] : current.rules[rule] ?? 0, room.rules[rule]);
322
+ const baseConfig = base.config ?? {};
323
+ const covered = coveredLimits(baseConfig, current.config ?? {});
324
+ for (const rule of /* @__PURE__ */ new Set([...Object.keys(baseConfig), ...Object.keys(current.config ?? {})])) if (base.config !== void 0) compare(`lint config rule-off \`${rule}\``, covered[rule] ?? 0, current.config === void 0 || Object.hasOwn(baseConfig, rule) && !Object.hasOwn(current.config, rule) ? void 0 : current.config[rule] ?? 0, room.config[rule]);
325
+ compare("`@ts-expect-error`", base.tsExpectError, current.tsExpectError, room.tsExpectError);
326
+ compare("`@ts-ignore`", base.tsIgnore, current.tsIgnore, room.tsIgnore);
327
+ compare("`SAFETY:` comments", safetyCeiling(base, current.rules["anti-slop/require-safety-comment-for-type-assertion"] ?? 0), current.safety, room.safety);
328
+ return failures.length ? [...failures, "Ceilings only go down. Fix the code, or remove another suppression of the same kind; raising a ceiling needs the operator's approval through the ruleset bypass."] : [];
329
+ }
330
+ //#endregion
128
331
  //#region src/bin/suppressions.ts
129
332
  function fullCheck(root, update, base) {
130
333
  const failures = checkSuppressions(root, update);