@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,6 +1,6 @@
1
1
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../../shared-BG0Nkzh0.mjs";
2
2
  //#region src/oxc/guardrails/index.d.ts
3
- /** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, `any` assigned, passed or returned in a Vue script, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
3
+ /** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
4
4
  declare const guardrailsPlugin: import("@oxlint/plugins").Plugin;
5
5
  //#endregion
6
6
  export { ASSERTION_FUNCTION_NAMES, TEST_FILE_GLOBS, guardrailsPlugin as default };
@@ -1,3 +1,3 @@
1
1
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../../shared-WC0z3y9F.mjs";
2
- import { t as guardrailsPlugin } from "../../guardrails-CNmSFSxO.mjs";
2
+ import { t as guardrailsPlugin } from "../../guardrails-Dron1AbR.mjs";
3
3
  export { ASSERTION_FUNCTION_NAMES, TEST_FILE_GLOBS, guardrailsPlugin as default };
@@ -38,9 +38,7 @@ interface AntelopePresetOptions {
38
38
  * Type-aware rules. Defaults to true. Consumers must also set options.typeAware
39
39
  * in their root config because oxlint never reads that field from extends.
40
40
  * oxlint-tsgolint reads only TypeScript files, so in `.vue` script blocks
41
- * `antelopejs/no-unsafe-any-in-vue` runs the `typescript/no-unsafe-*`
42
- * checks, and `antelopeNuxtConfig({ typeAware })` runs every type-aware rule
43
- * in ESLint.
41
+ * `antelopeNuxtConfig({ typeAware })` runs every type-aware rule in ESLint.
44
42
  */
45
43
  typeAware?: boolean;
46
44
  }
@@ -105,7 +103,7 @@ declare function guardrailsRules(): {
105
103
  };
106
104
  })[];
107
105
  };
108
- /** The shared AntelopeJS preset. Every enabled rule fails CI; recorded debt is enforced by the ratchet. */
106
+ /** The shared AntelopeJS preset. Every enabled rule fails CI. */
109
107
  declare function antelopePreset(options?: AntelopePresetOptions): {
110
108
  extends: ({
111
109
  categories: {
@@ -202,7 +200,6 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
202
200
  }[];
203
201
  rules: {
204
202
  "antelopejs/no-unrun-query": "off" | "error";
205
- "antelopejs/no-unsafe-any-in-vue": "off" | "error";
206
203
  "antelopejs/no-unsafe-object-assign": "off" | "error";
207
204
  "antelopejs/require-tsconfig-include": "off" | "error";
208
205
  "antelopejs/require-tsconfig-types": "off" | "error";
@@ -251,15 +248,6 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
251
248
  rules: {
252
249
  "typescript/no-floating-promises": "off" | "error";
253
250
  };
254
- overrides: ({
255
- files: string[];
256
- rules: {
257
- "eslint/max-lines": "off";
258
- };
259
- } | {
260
- files: string[];
261
- rules: Record<string, "off">;
262
- })[];
263
251
  };
264
252
  //#endregion
265
253
  export { ANTELOPE_IGNORE_PATTERNS, ANTI_SLOP_RULES, ASSERTION_FUNCTION_NAMES, AntelopePresetOptions, ComplexityThresholds, DEFAULT_COMPLEXITY_THRESHOLDS, FRAMEWORK_SPECIFIC_JEST_RULES, TEST_FILE_GLOBS, antelopePreset, antiSlopRules, guardrailsRules };
package/dist/oxc/lint.mjs CHANGED
@@ -1,6 +1,4 @@
1
- import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
2
- import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
3
- import { t as PRESET_CONFIGS } from "../templates-Df6SlGLA.mjs";
1
+ import { t as PRESET_CONFIGS } from "../templates-DLW0Ubfk.mjs";
4
2
  import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "../type-aware-rules-BxhHbizU.mjs";
5
3
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
6
4
  import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-BCFFyp3l.mjs";
@@ -155,7 +153,6 @@ function guardrailsPreset(typeAware) {
155
153
  }],
156
154
  rules: {
157
155
  "antelopejs/no-unrun-query": typeAware ? "error" : "off",
158
- "antelopejs/no-unsafe-any-in-vue": typeAware ? "error" : "off",
159
156
  "antelopejs/no-unsafe-object-assign": typeAware ? "error" : "off",
160
157
  "antelopejs/require-tsconfig-include": typeAware ? "error" : "off",
161
158
  "antelopejs/require-tsconfig-types": typeAware ? "error" : "off"
@@ -211,20 +208,7 @@ function importSortingPreset() {
211
208
  }] }
212
209
  });
213
210
  }
214
- /** Overrides run after rules, including test-specific rules; measurement bypasses all ceilings. */
215
- function ratchetOverrides() {
216
- if (process.env["ANTELOPEJS_RATCHET_MEASURE"] !== void 0) return [];
217
- const ceilings = readCarriedCeilings(findGitRoot());
218
- const rules = Object.fromEntries(Object.keys(ceilings.rules).map((rule) => [rule, "off"]));
219
- return [...Object.keys(ceilings.oversizeFiles).map((path) => ({
220
- files: [path.replaceAll(/([*?[\]{}])/gu, "\\$1")],
221
- rules: { "eslint/max-lines": "off" }
222
- })), {
223
- files: ["**/*"],
224
- rules
225
- }];
226
- }
227
- /** The shared AntelopeJS preset. Every enabled rule fails CI; recorded debt is enforced by the ratchet. */
211
+ /** The shared AntelopeJS preset. Every enabled rule fails CI. */
228
212
  function antelopePreset(options = {}) {
229
213
  let thresholds = DEFAULT_COMPLEXITY_THRESHOLDS;
230
214
  if (options.complexity !== true && options.complexity !== false && options.complexity !== void 0) thresholds = {
@@ -240,8 +224,7 @@ function antelopePreset(options = {}) {
240
224
  options.complexity === false ? null : complexityPreset(thresholds),
241
225
  options.importSorting === true ? importSortingPreset() : null
242
226
  ].filter((config) => config !== null),
243
- rules: { "typescript/no-floating-promises": options.typeAware === false ? "off" : "error" },
244
- overrides: ratchetOverrides()
227
+ rules: { "typescript/no-floating-promises": options.typeAware === false ? "off" : "error" }
245
228
  });
246
229
  }
247
230
  //#endregion
@@ -81,7 +81,6 @@ function repositoryTools(manifest) {
81
81
  commands: {
82
82
  checks: "antelopejs-checks",
83
83
  size: "antelopejs-check-size",
84
- ratchet: "antelopejs-ratchet",
85
84
  suppressions: "antelopejs-suppressions",
86
85
  sync: "antelopejs-sync"
87
86
  },
@@ -96,7 +95,6 @@ function repositoryTools(manifest) {
96
95
  commands: {
97
96
  checks: "node src/bin/checks.ts",
98
97
  size: "node src/bin/check-size.ts",
99
- ratchet: "node src/bin/ratchet.ts",
100
98
  suppressions: "node src/bin/suppressions.ts",
101
99
  sync: "node src/bin/sync.ts"
102
100
  },
@@ -219,14 +217,11 @@ function managedPackage(current, versions, options = {}) {
219
217
  scripts.prepare = prepareScript(scripts.prepare);
220
218
  const tools = repositoryTools(manifest);
221
219
  Object.assign(scripts, tools.commands, {
222
- "ratchet:update": `${tools.commands.ratchet} --update`,
223
220
  "suppressions:update": `${tools.commands.suppressions} --update`,
224
221
  "sync:check": `${tools.commands.sync} --check`
225
222
  });
226
- if (options.ratchet === false) {
227
- delete scripts.ratchet;
228
- delete scripts["ratchet:update"];
229
- }
223
+ delete scripts.ratchet;
224
+ delete scripts["ratchet:update"];
230
225
  for (const [name, command] of Object.entries(defaultScripts(options.nuxt))) scripts[name] ??= command;
231
226
  manifest.devDependencies = sortedEntries({
232
227
  ...manifest.devDependencies,
@@ -252,11 +247,7 @@ function templatePackage(current, versions, options) {
252
247
  checks: commands.checks,
253
248
  size: commands.size,
254
249
  suppressions: commands.suppressions,
255
- "suppressions:update": `${commands.suppressions} --update`,
256
- ...options.ratchet && {
257
- ratchet: commands.ratchet,
258
- "ratchet:update": `${commands.ratchet} --update`
259
- }
250
+ "suppressions:update": `${commands.suppressions} --update`
260
251
  }).filter(([name, command]) => scripts[name] !== command);
261
252
  const defaults = Object.entries({
262
253
  ...defaultScripts(options.nuxt),
@@ -1,6 +1,6 @@
1
+ import { Scalar, isMap, isNode, isPair, isScalar, isSeq, parseDocument, visit } from "yaml";
1
2
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
3
  import { join } from "node:path";
3
- import { Scalar, isMap, isNode, isPair, isScalar, isSeq, parseDocument, visit } from "yaml";
4
4
  //#region src/guardrails/ci-aggregator.ts
5
5
  /** The caller-level gate job older callers carry next to the shared workflow, which already reports `ci / checks`. */
6
6
  const LEGACY_AGGREGATOR_ID = "checks";
@@ -69,6 +69,88 @@ function hasRedundantAggregator(jobs, callerId, keep) {
69
69
  return isMap(aggregator) && !holdsAnchor(aggregator) && onlyKeys(aggregator, JOB_KEYS) && needsOnly(aggregator, callerId) && gatesOnNeedsResults(aggregator) && jobs.items.every(({ key }) => isScalar(key) && (key.value === "checks" || keep.has(String(key.value))));
70
70
  }
71
71
  //#endregion
72
+ //#region src/guardrails/workflow.ts
73
+ /** The tag of AntelopeJS/.github every workflow sync writes calls; a repository that has not synced keeps its own ref. */
74
+ const SHARED_WORKFLOWS_TAG = "v2";
75
+ /** The `uses:` ref of the shared workflow `file` at the tag sync writes. */
76
+ function sharedWorkflow(file) {
77
+ return `AntelopeJS/.github/.github/workflows/${file}@${SHARED_WORKFLOWS_TAG}`;
78
+ }
79
+ /** A `uses:` line calling a shared workflow the tag ships; one it does not ship, such as the retired modules-update.yml, keeps its ref. */
80
+ const SHARED_USES = /^(\s*(?:-\s+)?uses:\s*["']?AntelopeJS\/\.github\/\.github\/workflows\/(?:ci-node|ci-renovate-sync|next-sync|release-npm-public|release-npm-private|stale)\.yml@)([^\s"'#]+)/gm;
81
+ /** `text` with every call to a shared workflow the tag ships moved to the tag, its lines otherwise byte for byte. */
82
+ function pinSharedWorkflows(text) {
83
+ return text.replace(SHARED_USES, (_line, prefix) => `${prefix}${SHARED_WORKFLOWS_TAG}`);
84
+ }
85
+ const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
86
+ const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
87
+ /** Moves the shared-workflow calls of each workflow file no other artifact of `planned` writes or removes to the tag. */
88
+ function sharedRefArtifacts(root, planned) {
89
+ const directory = join(root, ".github/workflows");
90
+ if (!existsSync(directory)) return [];
91
+ return readdirSync(directory).filter((name) => /\.ya?ml$/.test(name)).sort().map((name) => `.github/workflows/${name}`).filter((path) => !planned.has(path)).map((path) => {
92
+ const current = readFileSync(join(root, path), "utf8");
93
+ const content = pinSharedWorkflows(current);
94
+ return content === current ? {
95
+ kind: "unchanged",
96
+ path
97
+ } : {
98
+ kind: "write",
99
+ path,
100
+ content,
101
+ mode: void 0
102
+ };
103
+ });
104
+ }
105
+ const MISSING_CHECKS_WORKFLOW = "No workflow in .github/workflows runs pnpm run checks. Add a step running `pnpm run checks` (or `pnpm checks`), or a job using AntelopeJS/.github/.github/workflows/ci-node.yml@<ref>.";
106
+ function hasChecksWorkflow(root) {
107
+ const directory = join(root, ".github/workflows");
108
+ if (!existsSync(directory)) return false;
109
+ for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
110
+ const document = parseDocument(readFileSync(join(directory, file), "utf8"));
111
+ if (document.errors.length) continue;
112
+ const jobs = document.get("jobs", true);
113
+ if (!isMap(jobs)) continue;
114
+ for (const { value: job } of jobs.items) {
115
+ if (!isMap(job)) continue;
116
+ const uses = job.get("uses", true);
117
+ if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
118
+ const steps = job.get("steps", true);
119
+ if (!isSeq(steps)) continue;
120
+ for (const step of steps.items) {
121
+ if (!isMap(step)) continue;
122
+ const run = step.get("run", true);
123
+ if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
124
+ }
125
+ }
126
+ }
127
+ return false;
128
+ }
129
+ function callers(text, pattern) {
130
+ const document = parseDocument(text);
131
+ const jobs = document.errors.length ? void 0 : document.get("jobs", true);
132
+ if (!isMap(jobs)) return [];
133
+ const found = [];
134
+ for (const { key, value: job } of jobs.items) {
135
+ if (!isMap(job)) continue;
136
+ const uses = job.get("uses", true);
137
+ if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
138
+ id: String(isScalar(key) ? key.value : key),
139
+ uses: String(uses.value),
140
+ named: job.has("name")
141
+ });
142
+ }
143
+ return found;
144
+ }
145
+ /** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
146
+ function ciNodeCallers(text) {
147
+ return callers(text, CI_NODE_PATTERN);
148
+ }
149
+ /** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
150
+ function ciRenovateSyncCallers(text) {
151
+ return callers(text, CI_RENOVATE_SYNC_PATTERN);
152
+ }
153
+ //#endregion
72
154
  //#region src/guardrails/workflow-needs.ts
73
155
  const NEEDS_REFERENCE = /(?<![\w.'"-])needs(?:\.([A-Za-z_][\w-]*)|\[\s*(['"])([^'"]+)\2\s*\])/g;
74
156
  function neededIds(job) {
@@ -239,18 +321,43 @@ const CI_PATH = ".github/workflows/ci.yml";
239
321
  /** The status context GitHub derives from the caller job id and the shared workflow's `checks` job. */
240
322
  const CI_CONTEXT = `ci / checks`;
241
323
  const RENOVATE_SYNC_JOB_ID = "renovate-sync";
242
- const CI_NODE_REF = "AntelopeJS/.github/.github/workflows/ci-node.yml@v1";
243
- const CI_RENOVATE_SYNC_REF = "AntelopeJS/.github/.github/workflows/ci-renovate-sync.yml@v1";
244
- const CI_CALLER = `name: ci
245
-
246
- on:
247
- push:
248
- branches:
249
- - main
250
- - next
324
+ const CI_NODE_REF = sharedWorkflow("ci-node.yml");
325
+ const CI_RENOVATE_SYNC_REF = sharedWorkflow("ci-renovate-sync.yml");
326
+ const DEFAULT_PROFILE = {
327
+ integrationBranch: "next",
328
+ windowsOnPullRequests: false
329
+ };
330
+ const PROFILES = /* @__PURE__ */ new Map([
331
+ ["@antelopejs/core", { windowsOnPullRequests: true }],
332
+ ["cloud-sdk-workspace", { windowsOnPullRequests: true }],
333
+ ["@antelopejs-private/cloud", { integrationBranch: "develop" }]
334
+ ]);
335
+ /** The CI profile of the repository whose package.json is named `name`; the default for any other name. */
336
+ function ciProfile(name) {
337
+ return {
338
+ ...DEFAULT_PROFILE,
339
+ ...PROFILES.get(name ?? "")
340
+ };
341
+ }
342
+ /**
343
+ * The triggers of the three-tier CI: ci-node.yml picks the tier from the event, the target branch and the draft flag,
344
+ * so a caller only declares pull requests (draft to ready included), pushes to the integration branch, a nightly run
345
+ * and manual dispatch. A push to `main` runs nothing.
346
+ */
347
+ function ciTriggers(integrationBranch) {
348
+ return `on:
251
349
  pull_request:
350
+ types: [opened, synchronize, reopened, ready_for_review]
351
+ push:
352
+ branches: [${integrationBranch}]
353
+ schedule:
354
+ - cron: "17 2 * * *"
252
355
  workflow_dispatch:
356
+ `;
357
+ }
358
+ const CI_CALLER = `name: ci
253
359
 
360
+ ${ciTriggers(DEFAULT_PROFILE.integrationBranch)}
254
361
  permissions:
255
362
  contents: read
256
363
 
@@ -332,17 +439,33 @@ function renameNeedsExpressions(document, from, to) {
332
439
  node.value = isPair(parent) && isScalar(parent.key) && parent.key.value === "if" ? renameNeedsReferences(node.value, from, to) : node.value.replace(/\$\{\{[\s\S]*?\}\}/g, (expression) => renameNeedsReferences(expression, from, to));
333
440
  } });
334
441
  }
335
- function hasDispatch(document) {
336
- const trigger = document.get("on", true);
337
- if (isMap(trigger)) return trigger.has("workflow_dispatch");
338
- if (isSeq(trigger)) return trigger.items.some((entry) => isScalar(entry) && entry.value === "workflow_dispatch");
339
- return isScalar(trigger) && trigger.value === "workflow_dispatch";
442
+ function triggersOf(document) {
443
+ const node = document.get("on", true);
444
+ return JSON.stringify(isNode(node) ? node.toJS(document) : node);
340
445
  }
341
- function addDispatch(document) {
342
- const trigger = document.get("on", true);
343
- if (isMap(trigger)) trigger.set("workflow_dispatch", null);
344
- else if (isSeq(trigger)) trigger.add("workflow_dispatch");
345
- else document.set("on", document.createNode(isScalar(trigger) && trigger.value ? [String(trigger.value), "workflow_dispatch"] : ["workflow_dispatch"]));
446
+ function setTriggers(document, profile) {
447
+ const desired = parseDocument(ciTriggers(profile.integrationBranch));
448
+ if (triggersOf(document) === triggersOf(desired)) return false;
449
+ document.set("on", desired.get("on", true));
450
+ return true;
451
+ }
452
+ /** Whether the caller asks for Windows beyond the default: any `windows` value but an opt-out `false`, or Windows on pull requests. */
453
+ function asksForWindows(inputs, key) {
454
+ return key === "windows-pull-requests" || key === "windows" && inputs.get("windows") !== false;
455
+ }
456
+ function dropWindows(jobs, callers, profile) {
457
+ if (profile.windowsOnPullRequests) return false;
458
+ let changed = false;
459
+ for (const { id } of callers) {
460
+ const inputs = jobs.getIn([id, "with"], true);
461
+ if (!isMap(inputs)) continue;
462
+ const before = inputs.items.length;
463
+ inputs.items = inputs.items.filter(({ key }) => !(isScalar(key) && asksForWindows(inputs, String(key.value))));
464
+ if (inputs.items.length === before) continue;
465
+ if (!inputs.items.length) jobs.deleteIn([id, "with"]);
466
+ changed = true;
467
+ }
468
+ return changed;
346
469
  }
347
470
  function grants(job, expected) {
348
471
  const granted = job.get("permissions", true);
@@ -354,6 +477,22 @@ function grant(document, job, expected) {
354
477
  job.set("permissions", document.createNode(expected));
355
478
  return true;
356
479
  }
480
+ function pinRefs(jobs, callers, ref) {
481
+ let changed = false;
482
+ for (const { id } of callers) {
483
+ const uses = jobs.getIn([id, "uses"], true);
484
+ if (!isScalar(uses) || uses.value === ref) continue;
485
+ uses.value = ref;
486
+ changed = true;
487
+ }
488
+ return changed;
489
+ }
490
+ /** Points every caller at the shared tag and drops the Windows inputs `profile` does not allow. */
491
+ function pinCallerRefs(jobs, callers, syncCallers, profile) {
492
+ const windows = dropWindows(jobs, callers, profile);
493
+ const node = pinRefs(jobs, callers, CI_NODE_REF);
494
+ return pinRefs(jobs, syncCallers, CI_RENOVATE_SYNC_REF) || node || windows;
495
+ }
357
496
  function skipsRenovateSync(job) {
358
497
  const inputs = job.get("with", true);
359
498
  return isMap(inputs) && inputs.get("renovate-sync") === false;
@@ -457,6 +596,21 @@ function dropRedundantAggregator(jobs, syncCallers) {
457
596
  jobs.delete(LEGACY_AGGREGATOR_ID);
458
597
  return [LEGACY_AGGREGATOR_ID];
459
598
  }
599
+ function renameCaller(document, { key, value }, caller) {
600
+ if (caller.named) value.delete("name");
601
+ if (caller.id === "ci") return caller.named;
602
+ if (isScalar(key)) key.value = "ci";
603
+ renameNeeds(document, caller.id, "ci");
604
+ renameNeedsExpressions(document, caller.id, "ci");
605
+ return true;
606
+ }
607
+ /** What package.json tells the caller: whether its `test` script only stands in for tests, and the profile its name selects. */
608
+ function callerPlan(manifest) {
609
+ return {
610
+ placeholderTests: placeholderTestScript(manifest.scripts?.test),
611
+ profile: ciProfile(manifest.name)
612
+ };
613
+ }
460
614
  /**
461
615
  * Keeps the shared CI caller on the job id `ci` with no `name`, so the shared workflow reports `ci / checks`,
462
616
  * dispatchable and read-only, with the Renovate sync it would otherwise run turned off. The write permissions the sync
@@ -468,49 +622,47 @@ function dropRedundantAggregator(jobs, syncCallers) {
468
622
  * when the workflow has no other job besides the caller and the Renovate sync, since the shared workflow already
469
623
  * reports `ci / checks` and each `needs` hop adds to the critical path. A gate that also covers repository-specific
470
624
  * jobs is kept.
471
- * No `uses:` ref is ever rewritten. A workflow with no caller job is repository-specific CI and is left as it is.
625
+ * The workflow declares exactly the triggers of the three-tier CI, with pushes to `profile.integrationBranch`. Unless
626
+ * `profile.windowsOnPullRequests` lets the repository ask for Windows on pull requests, no caller passes
627
+ * `windows-pull-requests` or a `windows` other than the opt-out `false`. Sync writes neither input.
628
+ * Every job calling ci-node.yml or ci-renovate-sync.yml calls it at `CI_NODE_REF` or `CI_RENOVATE_SYNC_REF`, whatever
629
+ * ref it had. A workflow with no caller job is repository-specific CI and is left as it is.
472
630
  * When `docsFiles` computes paths, every caller's `docs-files` input lists them first, then keeps its hand-listed paths
473
631
  * that still exist, so sync never drops coverage.
474
632
  */
475
- function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests = false) {
633
+ function ciWorkflow(current, callers, syncCallers, plan = {}) {
634
+ const { docsFiles, profile = DEFAULT_PROFILE } = plan;
635
+ const placeholderTests = plan.placeholderTests === true;
476
636
  if (current === void 0) return ciWorkflow(newCaller(placeholderTests), [{
477
637
  id: "ci",
478
638
  named: false
479
- }], [{ id: RENOVATE_SYNC_JOB_ID }], docsFiles, placeholderTests);
639
+ }], [{ id: RENOVATE_SYNC_JOB_ID }], plan);
480
640
  if (!callers.length) return current;
481
641
  const document = parseDocument(current);
482
642
  if (document.errors.length) throw new Error(`${CI_PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
483
643
  const jobs = document.get("jobs", true);
484
644
  if (!isMap(jobs)) return current;
645
+ restoreEmptyValueComments(document, current);
485
646
  const caller = callers.find(({ id }) => id === "ci") ?? callers[0];
486
647
  assertNoClash(jobs, caller.id, syncCallers.length > 0);
487
648
  const pair = jobs.items.find(({ key }) => isScalar(key) && key.value === caller.id);
488
649
  if (!pair || !isMap(pair.value)) return current;
489
650
  let changed = setCallersDocsFiles(document, jobs, callers, docsFiles);
490
- if (caller.named) {
491
- pair.value.delete("name");
492
- changed = true;
493
- }
494
- if (caller.id !== "ci") {
495
- if (isScalar(pair.key)) pair.key.value = "ci";
496
- renameNeeds(document, caller.id, "ci");
497
- renameNeedsExpressions(document, caller.id, "ci");
498
- changed = true;
499
- }
651
+ changed = pinCallerRefs(jobs, callers, syncCallers, profile) || changed;
652
+ changed = renameCaller(document, {
653
+ key: pair.key,
654
+ value: pair.value
655
+ }, caller) || changed;
500
656
  changed = grant(document, pair.value, { contents: "read" }) || changed;
501
657
  changed = skipRenovateSync(document, pair.value) || changed;
502
658
  changed = setTestJob(document, pair.value, placeholderTests) || changed;
503
659
  changed = ensureSyncJob(document, jobs, syncCallers) || changed;
504
660
  const removed = dropRedundantAggregator(jobs, syncCallers);
505
661
  changed = removed.length > 0 || changed;
506
- if (!hasDispatch(document)) {
507
- addDispatch(document);
508
- changed = true;
509
- }
662
+ changed = setTriggers(document, profile) || changed;
510
663
  const stale = staleNeeds(document, CI_PATH, removed);
511
664
  if (stale.length) throw new Error(stale.join("\n"));
512
665
  if (!changed) return current;
513
- restoreEmptyValueComments(document, current);
514
666
  blockOverflowingFlow(document);
515
667
  return document.toString({
516
668
  lineWidth: 0,
@@ -596,56 +748,4 @@ function renovateArtifacts(root, manifest, managed) {
596
748
  }];
597
749
  }
598
750
  //#endregion
599
- //#region src/guardrails/workflow.ts
600
- const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
601
- const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
602
- const MISSING_CHECKS_WORKFLOW = "No workflow in .github/workflows runs pnpm run checks. Add a step running `pnpm run checks` (or `pnpm checks`), or a job using AntelopeJS/.github/.github/workflows/ci-node.yml@<ref>.";
603
- function hasChecksWorkflow(root) {
604
- const directory = join(root, ".github/workflows");
605
- if (!existsSync(directory)) return false;
606
- for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
607
- const document = parseDocument(readFileSync(join(directory, file), "utf8"));
608
- if (document.errors.length) continue;
609
- const jobs = document.get("jobs", true);
610
- if (!isMap(jobs)) continue;
611
- for (const { value: job } of jobs.items) {
612
- if (!isMap(job)) continue;
613
- const uses = job.get("uses", true);
614
- if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
615
- const steps = job.get("steps", true);
616
- if (!isSeq(steps)) continue;
617
- for (const step of steps.items) {
618
- if (!isMap(step)) continue;
619
- const run = step.get("run", true);
620
- if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
621
- }
622
- }
623
- }
624
- return false;
625
- }
626
- function callers(text, pattern) {
627
- const document = parseDocument(text);
628
- const jobs = document.errors.length ? void 0 : document.get("jobs", true);
629
- if (!isMap(jobs)) return [];
630
- const found = [];
631
- for (const { key, value: job } of jobs.items) {
632
- if (!isMap(job)) continue;
633
- const uses = job.get("uses", true);
634
- if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
635
- id: String(isScalar(key) ? key.value : key),
636
- uses: String(uses.value),
637
- named: job.has("name")
638
- });
639
- }
640
- return found;
641
- }
642
- /** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
643
- function ciNodeCallers(text) {
644
- return callers(text, CI_NODE_PATTERN);
645
- }
646
- /** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
647
- function ciRenovateSyncCallers(text) {
648
- return callers(text, CI_RENOVATE_SYNC_PATTERN);
649
- }
650
- //#endregion
651
- export { placeholderTestScript as _, RENOVATE_CONFIGS as a, GITATTRIBUTES as c, enforcesLf as d, CI_CONTEXT as f, ciWorkflow as g, CI_RENOVATE_SYNC_REF as h, hasChecksWorkflow as i, GITATTRIBUTES_ARTIFACT as l, CI_PATH as m, ciNodeCallers as n, RENOVATE_PRESET as o, CI_NODE_REF as p, ciRenovateSyncCallers as r, renovateArtifacts as s, MISSING_CHECKS_WORKFLOW as t, LF_ATTRIBUTES as u };
751
+ export { ciRenovateSyncCallers as _, GITATTRIBUTES_ARTIFACT as a, sharedWorkflow as b, CI_CONTEXT as c, CI_RENOVATE_SYNC_REF as d, callerPlan as f, ciNodeCallers as g, MISSING_CHECKS_WORKFLOW as h, GITATTRIBUTES as i, CI_NODE_REF as l, ciWorkflow as m, RENOVATE_PRESET as n, LF_ATTRIBUTES as o, ciProfile as p, renovateArtifacts as r, enforcesLf as s, RENOVATE_CONFIGS as t, CI_PATH as u, hasChecksWorkflow as v, sharedRefArtifacts as y };
@@ -1,6 +1,5 @@
1
- import { n as renamedPaths } from "./renames-L2owF5GD.mjs";
2
- import { o as isAgentFile, r as changedFiles } from "./files-C-JJhExM.mjs";
3
- import { a as openDisablesIn, i as inWorktree, l as worktreeSuppressions, n as configKey, o as revisionSuppressions, r as countSuppressions, s as sortedKeys, t as atRevision } from "./suppressions-BvWGA463.mjs";
1
+ import { a as isAgentFile, n as changedFiles } from "./files-BbzJEk-L.mjs";
2
+ import { a as openDisablesIn, i as inWorktree, l as worktreeSuppressions, n as configKey, o as revisionSuppressions, r as countSuppressions, s as sortedKeys, t as atRevision } from "./suppressions-CfJwL0fN.mjs";
4
3
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
4
  import { join, matchesGlob } from "node:path";
6
5
  import { execFileSync, spawnSync } from "node:child_process";
@@ -79,6 +78,36 @@ function coveredLimits(limits, counts) {
79
78
  return covered;
80
79
  }
81
80
  //#endregion
81
+ //#region src/guardrails/renames.ts
82
+ /**
83
+ * Renames git detects, as new path to old path. Without `revisions` it
84
+ * compares the index with HEAD when `staged`, otherwise the working tree with
85
+ * HEAD; with revisions it compares those. Copies are never reported, and a
86
+ * repository without HEAD has no renames.
87
+ */
88
+ function renamedPaths(root, staged = false, revisions = staged ? [] : ["HEAD"]) {
89
+ const result = spawnSync("git", [
90
+ "diff",
91
+ "--find-renames",
92
+ "--diff-filter=R",
93
+ "--name-status",
94
+ "-z",
95
+ "--no-ext-diff",
96
+ ...staged ? ["--cached"] : [],
97
+ ...revisions,
98
+ "--"
99
+ ], {
100
+ cwd: root,
101
+ encoding: "utf8",
102
+ maxBuffer: 67108864
103
+ });
104
+ const renames = /* @__PURE__ */ new Map();
105
+ if (result.error || result.status !== 0) return renames;
106
+ const fields = result.stdout.split("\0");
107
+ for (let index = 0; index + 2 < fields.length; index += 3) renames.set(fields[index + 2], fields[index + 1]);
108
+ return renames;
109
+ }
110
+ //#endregion
82
111
  //#region src/guardrails/staged-additions.ts
83
112
  /**
84
113
  * Each staged file's path and hunks against `revision`, HEAD when omitted,
@@ -125,15 +154,6 @@ function stagedAdditions(root, targets, revision) {
125
154
  end: start + count - 1
126
155
  }))]));
127
156
  }
128
- /** The line of the compared revision a staged line is unchanged from, or `undefined` when the staged change adds it. */
129
- function previousLine(hunks, line) {
130
- let shift = 0;
131
- for (const { removed, start, count } of hunks) {
132
- if (count > 0 && line >= start && line < start + count) return void 0;
133
- if (count > 0 ? start + count <= line : start < line) shift += removed - count;
134
- }
135
- return line + shift;
136
- }
137
157
  //#endregion
138
158
  //#region src/guardrails/suppression-policy.ts
139
159
  /** Rules a directive may never name, each with what to do instead. */
@@ -532,4 +552,4 @@ function stagedBudget(root, staged, previous) {
532
552
  return [...failures, ...fixesFor(failed)];
533
553
  }
534
554
  //#endregion
535
- export { parseBudget as a, stagedSuppressions as c, stagedAdditions as d, stagedChanges as f, checkSuppressions as i, checkPolicy as l, SUPPRESSIONS_FILE as n, safetyCeiling as o, coveredLimits as p, adoptedBudget as r, stagedNames as s, SAFETY_RULE as t, previousLine as u };
555
+ export { parseBudget as a, stagedSuppressions as c, checkSuppressions as i, checkPolicy as l, SUPPRESSIONS_FILE as n, safetyCeiling as o, adoptedBudget as r, stagedNames as s, SAFETY_RULE as t, coveredLimits as u };
@@ -1,6 +1,6 @@
1
1
  import { n as markerPattern, t as DEFAULT_SAFETY_MARKERS } from "./require-safety-comment-for-type-assertion-mnb0CIxa.mjs";
2
2
  import { t as requireTypeScript6 } from "./typescript-version-CptQKjGz.mjs";
3
- import { a as gitFiles, i as generatedOutput } from "./files-C-JJhExM.mjs";
3
+ import { i as gitFiles, r as generatedOutput } from "./files-BbzJEk-L.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync, lstatSync, readFileSync } from "node:fs";
6
6
  import { join } from "node:path";