@antelopejs/tooling-configs 0.5.1 → 0.5.3

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/dist/oxc/lint.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
2
2
  import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
3
- import { t as PRESET_CONFIGS } from "../templates-lJBZFskp.mjs";
3
+ import { t as PRESET_CONFIGS } from "../templates-C6cfOd2H.mjs";
4
4
  import { t as TYPE_AWARE_RULES } from "../type-aware-rules-DMuN6sHb.mjs";
5
5
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
6
6
  import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-igPpEDpS.mjs";
@@ -20,8 +20,13 @@ function ruleId(code) {
20
20
  const [, plugin, rule] = match;
21
21
  return `${plugin === "typescript-eslint" ? "typescript" : plugin}/${rule}`;
22
22
  }
23
+ const NO_FILES = "No files found to lint.";
24
+ /** Whether oxlint matched no file, in which case it prints a notice before its report and exits 1. */
25
+ function foundNoFiles(stdout) {
26
+ return stdout.startsWith(NO_FILES) && stdout.includes("{");
27
+ }
23
28
  function parseReport(text) {
24
- const report = JSON.parse(text);
29
+ const report = JSON.parse(foundNoFiles(text) ? text.slice(text.indexOf("{")) : text);
25
30
  if (!Array.isArray(report?.diagnostics)) throw new Error("oxlint did not return a JSON diagnostics array.");
26
31
  return report.diagnostics;
27
32
  }
@@ -65,7 +70,7 @@ function runOxlint(root, config, files, flags) {
65
70
  if (result.error) throw result.error;
66
71
  if (result.status !== 0 && result.status !== 1) throw new Error(`oxlint failed (${result.status ?? result.signal}): ${result.stderr || result.stdout}`);
67
72
  const diagnostics = parseReport(result.stdout);
68
- if (result.status !== 0 && diagnostics.length === 0) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
73
+ if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
69
74
  return diagnostics;
70
75
  } finally {
71
76
  if (temporary) rmSync(temporary, {
@@ -1,5 +1,5 @@
1
1
  import { t as admits } from "./semver-BDxeEcP_.mjs";
2
- import { existsSync, readFileSync } from "node:fs";
2
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  //#region src/guardrails/package.ts
@@ -25,6 +25,10 @@ function packageManager(manifest) {
25
25
  default: throw new Error(`Unsupported package manager ${manager}. Expected pnpm, npm, yarn, or bun.`);
26
26
  }
27
27
  }
28
+ /** Whether the repository at `root` is a Nuxt app: it depends on `nuxt` or has a `nuxt.config.*`. */
29
+ function usesNuxt(root, manifest) {
30
+ return Boolean(manifest.dependencies?.nuxt || manifest.devDependencies?.nuxt || readdirSync(root).some((name) => name.startsWith("nuxt.config.")));
31
+ }
28
32
  function execCommand(manager) {
29
33
  if (manager === "npm") return "npm exec --";
30
34
  if (manager === "bun") return "bun x --no-install";
@@ -37,20 +41,23 @@ function toolingVersions() {
37
41
  if (existsSync(path)) {
38
42
  const manifest = parseManifest(readFileSync(path, "utf8"));
39
43
  if (manifest.name === "@antelopejs/tooling-configs") {
40
- const lefthook = manifest.devDependencies?.lefthook;
41
- const knip = manifest.devDependencies?.knip;
42
- const tsgolint = manifest.devDependencies?.["oxlint-tsgolint"];
43
- if (!lefthook || !knip || !tsgolint || !manifest.version) throw new Error("tooling-configs must declare its version and lefthook, knip and oxlint-tsgolint devDependencies.");
44
- const tested = manifest.devDependencies ?? {};
44
+ const declared = (field, name) => {
45
+ const range = manifest[field]?.[name];
46
+ if (!range) throw new Error(`tooling-configs must declare ${name} in ${field}.`);
47
+ return range;
48
+ };
49
+ const dev = (name) => declared("devDependencies", name);
50
+ if (!manifest.version || !manifest.packageManager) throw new Error("tooling-configs must declare its version and packageManager.");
45
51
  return {
46
- lefthook,
47
- knip,
48
- tsgolint,
49
- capture: CAPTURE_PEERS.map((name) => {
50
- const range = tested[name];
51
- if (!range) throw new Error(`tooling-configs must declare ${name} as a devDependency.`);
52
- return [name, range];
53
- }),
52
+ lefthook: dev("lefthook"),
53
+ knip: dev("knip"),
54
+ tsgolint: dev("oxlint-tsgolint"),
55
+ oxlint: dev("oxlint"),
56
+ oxfmt: dev("oxfmt"),
57
+ typescript: declared("dependencies", "typescript"),
58
+ nodeTypes: dev("@types/node"),
59
+ capture: CAPTURE_PEERS.map((name) => [name, dev(name)]),
60
+ packageManager: manifest.packageManager,
54
61
  pack: manifest.version
55
62
  };
56
63
  }
@@ -155,6 +162,48 @@ function addedDevDependencies(manifest, versions, options) {
155
162
  if (options.typeAware) tools.push(["oxlint-tsgolint", versions.tsgolint]);
156
163
  return [...tools.filter(([name]) => !declared[name]), ...options.captures ? versions.capture.filter(([name, tested]) => !withinTested(declared[name], tested)) : []];
157
164
  }
165
+ /**
166
+ * The pack, oxlint, oxlint-tsgolint, oxfmt and typescript with the ranges `--init` declares for a repository that has
167
+ * none of them, and `@types/node` when `nodeProject` says init writes the tsconfig that loads it. Sync needs the first
168
+ * three installed to load its preset and run the type-aware baseline before it writes any devDependency; the synced
169
+ * `typecheck` script runs typescript's `tsc`.
170
+ */
171
+ function bootstrapDependencies(manifest, versions, nodeProject) {
172
+ const declared = {
173
+ ...manifest.dependencies,
174
+ ...manifest.devDependencies
175
+ };
176
+ const wanted = [
177
+ ["@antelopejs/tooling-configs", `^${versions.pack}`],
178
+ ["oxlint", versions.oxlint],
179
+ ["oxlint-tsgolint", versions.tsgolint],
180
+ ["oxfmt", versions.oxfmt],
181
+ ["typescript", versions.typescript]
182
+ ];
183
+ if (nodeProject) wanted.push(["@types/node", versions.nodeTypes]);
184
+ return wanted.filter(([name]) => !declared[name]);
185
+ }
186
+ /** The `test` script `npm init` writes, which fails every run. */
187
+ const NPM_INIT_TEST = "echo \"Error: no test specified\" && exit 1";
188
+ /**
189
+ * `current` with `added` in its sorted devDependencies, `packageManager` set to `pin` when it has none, and a `test`
190
+ * script running Node's test runner when it has none or only npm's failing default, which passes with no test file
191
+ * and runs the ones the repository adds. An explicit `"type": "commonjs"`, which `npm init` writes, is dropped: under
192
+ * it Node refuses to load the pack's ESM `*.config.ts` files, while without it `.js` files stay CommonJS unless they
193
+ * use ESM syntax, which `commonjs` rejected anyway. Formatted as the rest of the sync writers do.
194
+ */
195
+ function bootstrappedManifest(current, added, pin) {
196
+ const manifest = parseManifest(current);
197
+ manifest.devDependencies = sortedEntries({
198
+ ...manifest.devDependencies,
199
+ ...Object.fromEntries(added)
200
+ });
201
+ manifest.packageManager ??= pin;
202
+ if (manifest.type === "commonjs") delete manifest.type;
203
+ const scripts = manifest.scripts ??= {};
204
+ if (scripts.test === void 0 || scripts.test === NPM_INIT_TEST) scripts.test = "node --test";
205
+ return serializeManifest(manifest, current);
206
+ }
158
207
  function managedPackage(current, versions, options = {}) {
159
208
  if (current === void 0) throw new Error("package.json is missing.");
160
209
  const manifest = parseManifest(current);
@@ -218,10 +267,11 @@ function templatePackage(current, versions, options) {
218
267
  });
219
268
  return serializeManifest(manifest, current);
220
269
  }
270
+ /** `manifest` as JSON in the indentation and line endings of `current`, the text it was read from. */
221
271
  function serializeManifest(manifest, current) {
222
272
  const indent = /^([\t ]+)"/m.exec(current)?.[1] ?? " ";
223
273
  const newline = current.includes("\r\n") ? "\r\n" : "\n";
224
274
  return `${JSON.stringify(manifest, null, indent).replaceAll("\n", newline)}${newline}`;
225
275
  }
226
276
  //#endregion
227
- export { parseManifest as a, toolingVersions as c, packageManager as i, execCommand as n, repositoryTools as o, managedPackage as r, templatePackage as s, addedDevDependencies as t };
277
+ export { managedPackage as a, repositoryTools as c, toolingVersions as d, usesNuxt as f, execCommand as i, serializeManifest as l, bootstrapDependencies as n, packageManager as o, bootstrappedManifest as r, parseManifest as s, addedDevDependencies as t, templatePackage as u };
@@ -1,6 +1,6 @@
1
- import { a as parseManifest } from "./package-Dn7VTFUW.mjs";
1
+ import { s as parseManifest } from "./package-DiaBP7bI.mjs";
2
2
  import { l as resolveRevision, u as trackedManifests } from "./files-DJ0TeaTU.mjs";
3
- import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-BroaaGJ_.mjs";
3
+ import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-CQTcKCi1.mjs";
4
4
  import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync } from "node:fs";
5
5
  import { dirname, isAbsolute, join, matchesGlob, relative, sep } from "node:path";
6
6
  import { execFileSync, spawnSync } from "node:child_process";
@@ -1,9 +1,9 @@
1
1
  import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPackRelease, s as isRetired, t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
2
2
  import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
3
- import { c as toolingVersions } from "./package-Dn7VTFUW.mjs";
3
+ import { d as toolingVersions } from "./package-DiaBP7bI.mjs";
4
4
  import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-DJ0TeaTU.mjs";
5
- import { t as lintDiagnostics } from "./oxlint-DIV-lLSS.mjs";
6
- import "./suppression-budget-Dvb_IqBo.mjs";
5
+ import { t as lintDiagnostics } from "./oxlint-BbpTFFmf.mjs";
6
+ import "./suppression-budget-DgYdu6JK.mjs";
7
7
  import { n as sizeFailure } from "./size-DBatLT-F.mjs";
8
8
  import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
9
9
  import { dirname, join } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { l as resolveRevision, o as isAgentFile } from "./files-DJ0TeaTU.mjs";
2
- import { a as parseBudget, n as SUPPRESSIONS_FILE, o as safetyCeiling, p as coveredLimits } from "./suppression-budget-Dvb_IqBo.mjs";
3
- import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-BroaaGJ_.mjs";
2
+ import { a as parseBudget, n as SUPPRESSIONS_FILE, o as safetyCeiling, p as coveredLimits } from "./suppression-budget-DgYdu6JK.mjs";
3
+ import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-CQTcKCi1.mjs";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { spawnSync } from "node:child_process";
@@ -1,6 +1,6 @@
1
1
  import { n as renamedPaths } from "./renames-L2owF5GD.mjs";
2
2
  import { o as isAgentFile, r as changedFiles } from "./files-DJ0TeaTU.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-BroaaGJ_.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-CQTcKCi1.mjs";
4
4
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { join, matchesGlob } from "node:path";
6
6
  import { execFileSync, spawnSync } from "node:child_process";
@@ -429,4 +429,4 @@ function countSuppressions(suppressions) {
429
429
  };
430
430
  }
431
431
  //#endregion
432
- export { openDisablesIn as a, suppressionsIn as c, inWorktree as i, worktreeSuppressions as l, configKey as n, revisionSuppressions as o, countSuppressions as r, sortedKeys as s, atRevision as t };
432
+ export { openDisablesIn as a, suppressionsIn as c, inWorktree as i, worktreeSuppressions as l, configKey as n, revisionSuppressions as o, countSuppressions as r, sortedKeys as s, atRevision as t, typescript as u };
@@ -1,4 +1,4 @@
1
- import { n as execCommand } from "./package-Dn7VTFUW.mjs";
1
+ import { i as execCommand } from "./package-DiaBP7bI.mjs";
2
2
  import { isMap, parseDocument } from "yaml";
3
3
  //#region src/guardrails/templates.ts
4
4
  const PRESET_CONFIGS = [
@@ -1,4 +1,4 @@
1
- import { a as parseManifest } from "./package-Dn7VTFUW.mjs";
1
+ import { s as parseManifest } from "./package-DiaBP7bI.mjs";
2
2
  import { u as trackedManifests } from "./files-DJ0TeaTU.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -1,112 +1,6 @@
1
1
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { Scalar, isMap, isNode, isPair, isScalar, isSeq, parseDocument, visit } from "yaml";
4
- //#region src/guardrails/renovate.ts
5
- /** The Renovate config file sync writes when a repository has none. */
6
- const RENOVATE_PATH = "renovate.json";
7
- /** The config files Renovate's `detectConfigFile` reads, in its lookup order (`getConfigFileNames()` in its `lib/config/app-strings.ts`, called without a platform), before the `renovate` key of `package.json`. */
8
- const RENOVATE_CONFIGS = [
9
- RENOVATE_PATH,
10
- "renovate.jsonc",
11
- "renovate.json5",
12
- ".github/renovate.json",
13
- ".github/renovate.jsonc",
14
- ".github/renovate.json5",
15
- ".gitlab/renovate.json",
16
- ".gitlab/renovate.jsonc",
17
- ".gitlab/renovate.json5",
18
- ".renovaterc",
19
- ".renovaterc.json",
20
- ".renovaterc.jsonc",
21
- ".renovaterc.json5"
22
- ];
23
- const PRESET = "github>AntelopeJS/.github:renovate.json5";
24
- /** Matches a config that extends the AntelopeJS shared Renovate preset. */
25
- const RENOVATE_PRESET = /github>AntelopeJS\/\.github(?::|\/)/;
26
- const RENOVATE_JSON = `{
27
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
28
- "extends": ["${PRESET}"]
29
- }
30
- `;
31
- /**
32
- * Writes `renovate.json` when the repository has no Renovate config, keeps an existing one byte for byte,
33
- * and fails one that does not extend the AntelopeJS preset, since rewriting it would drop the repository's settings.
34
- * `managed` is false for a project scaffolded from a template, whose Renovate setup is its own.
35
- */
36
- function renovateArtifacts(root, manifest, managed) {
37
- if (!managed) return [];
38
- const file = RENOVATE_CONFIGS.find((path) => existsSync(join(root, path)));
39
- const path = file ?? "package.json";
40
- const text = file === void 0 ? manifest.renovate ? JSON.stringify(manifest.renovate) : void 0 : readFileSync(join(root, file), "utf8");
41
- if (text === void 0) return [{
42
- kind: "write",
43
- path: RENOVATE_PATH,
44
- content: RENOVATE_JSON,
45
- mode: void 0
46
- }];
47
- if (RENOVATE_PRESET.test(text)) return [{
48
- kind: "unchanged",
49
- path
50
- }];
51
- return [{
52
- kind: "error",
53
- path,
54
- message: `${file ?? "package.json \"renovate\""}: extend "${PRESET}" in its extends, then rerun antelopejs-sync.`
55
- }];
56
- }
57
- //#endregion
58
- //#region src/guardrails/workflow.ts
59
- const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
60
- const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
61
- 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>.";
62
- function hasChecksWorkflow(root) {
63
- const directory = join(root, ".github/workflows");
64
- if (!existsSync(directory)) return false;
65
- for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
66
- const document = parseDocument(readFileSync(join(directory, file), "utf8"));
67
- if (document.errors.length) continue;
68
- const jobs = document.get("jobs", true);
69
- if (!isMap(jobs)) continue;
70
- for (const { value: job } of jobs.items) {
71
- if (!isMap(job)) continue;
72
- const uses = job.get("uses", true);
73
- if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
74
- const steps = job.get("steps", true);
75
- if (!isSeq(steps)) continue;
76
- for (const step of steps.items) {
77
- if (!isMap(step)) continue;
78
- const run = step.get("run", true);
79
- if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
80
- }
81
- }
82
- }
83
- return false;
84
- }
85
- function callers(text, pattern) {
86
- const document = parseDocument(text);
87
- const jobs = document.errors.length ? void 0 : document.get("jobs", true);
88
- if (!isMap(jobs)) return [];
89
- const found = [];
90
- for (const { key, value: job } of jobs.items) {
91
- if (!isMap(job)) continue;
92
- const uses = job.get("uses", true);
93
- if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
94
- id: String(isScalar(key) ? key.value : key),
95
- uses: String(uses.value),
96
- named: job.has("name")
97
- });
98
- }
99
- return found;
100
- }
101
- /** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
102
- function ciNodeCallers(text) {
103
- return callers(text, CI_NODE_PATTERN);
104
- }
105
- /** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
106
- function ciRenovateSyncCallers(text) {
107
- return callers(text, CI_RENOVATE_SYNC_PATTERN);
108
- }
109
- //#endregion
110
4
  //#region src/guardrails/ci-aggregator.ts
111
5
  /** The caller-level gate job older callers carry next to the shared workflow, which already reports `ci / checks`. */
112
6
  const LEGACY_AGGREGATOR_ID = "checks";
@@ -540,7 +434,7 @@ function canonicalSyncJob() {
540
434
  }
541
435
  function ensureSyncJob(document, jobs, syncCallers) {
542
436
  if (!syncCallers.length) {
543
- jobs.set(RENOVATE_SYNC_JOB_ID, canonicalSyncJob());
437
+ jobs.add(document.createPair(RENOVATE_SYNC_JOB_ID, canonicalSyncJob()));
544
438
  return true;
545
439
  }
546
440
  let changed = false;
@@ -579,7 +473,10 @@ function dropRedundantAggregator(jobs, syncCallers) {
579
473
  * that still exist, so sync never drops coverage.
580
474
  */
581
475
  function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests = false) {
582
- if (current === void 0) return newCaller(placeholderTests);
476
+ if (current === void 0) return ciWorkflow(newCaller(placeholderTests), [{
477
+ id: "ci",
478
+ named: false
479
+ }], [{ id: RENOVATE_SYNC_JOB_ID }], docsFiles, placeholderTests);
583
480
  if (!callers.length) return current;
584
481
  const document = parseDocument(current);
585
482
  if (document.errors.length) throw new Error(`${CI_PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
@@ -621,4 +518,110 @@ function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests =
621
518
  });
622
519
  }
623
520
  //#endregion
624
- export { ciWorkflow as a, ciNodeCallers as c, RENOVATE_CONFIGS as d, RENOVATE_PRESET as f, CI_RENOVATE_SYNC_REF as i, ciRenovateSyncCallers as l, CI_NODE_REF as n, placeholderTestScript as o, renovateArtifacts as p, CI_PATH as r, MISSING_CHECKS_WORKFLOW as s, CI_CONTEXT as t, hasChecksWorkflow as u };
521
+ //#region src/guardrails/renovate.ts
522
+ /** The Renovate config file sync writes when a repository has none. */
523
+ const RENOVATE_PATH = "renovate.json";
524
+ /** The config files Renovate's `detectConfigFile` reads, in its lookup order (`getConfigFileNames()` in its `lib/config/app-strings.ts`, called without a platform), before the `renovate` key of `package.json`. */
525
+ const RENOVATE_CONFIGS = [
526
+ RENOVATE_PATH,
527
+ "renovate.jsonc",
528
+ "renovate.json5",
529
+ ".github/renovate.json",
530
+ ".github/renovate.jsonc",
531
+ ".github/renovate.json5",
532
+ ".gitlab/renovate.json",
533
+ ".gitlab/renovate.jsonc",
534
+ ".gitlab/renovate.json5",
535
+ ".renovaterc",
536
+ ".renovaterc.json",
537
+ ".renovaterc.jsonc",
538
+ ".renovaterc.json5"
539
+ ];
540
+ const PRESET = "github>AntelopeJS/.github:renovate.json5";
541
+ /** Matches a config that extends the AntelopeJS shared Renovate preset. */
542
+ const RENOVATE_PRESET = /github>AntelopeJS\/\.github(?::|\/)/;
543
+ const RENOVATE_JSON = `{
544
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
545
+ "extends": ["${PRESET}"]
546
+ }
547
+ `;
548
+ /**
549
+ * Writes `renovate.json` when the repository has no Renovate config, keeps an existing one byte for byte,
550
+ * and fails one that does not extend the AntelopeJS preset, since rewriting it would drop the repository's settings.
551
+ * `managed` is false for a project scaffolded from a template, whose Renovate setup is its own.
552
+ */
553
+ function renovateArtifacts(root, manifest, managed) {
554
+ if (!managed) return [];
555
+ const file = RENOVATE_CONFIGS.find((path) => existsSync(join(root, path)));
556
+ const path = file ?? "package.json";
557
+ const text = file === void 0 ? manifest.renovate ? JSON.stringify(manifest.renovate) : void 0 : readFileSync(join(root, file), "utf8");
558
+ if (text === void 0) return [{
559
+ kind: "write",
560
+ path: RENOVATE_PATH,
561
+ content: RENOVATE_JSON,
562
+ mode: void 0
563
+ }];
564
+ if (RENOVATE_PRESET.test(text)) return [{
565
+ kind: "unchanged",
566
+ path
567
+ }];
568
+ return [{
569
+ kind: "error",
570
+ path,
571
+ message: `${file ?? "package.json \"renovate\""}: extend "${PRESET}" in its extends, then rerun antelopejs-sync.`
572
+ }];
573
+ }
574
+ //#endregion
575
+ //#region src/guardrails/workflow.ts
576
+ const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
577
+ const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
578
+ 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>.";
579
+ function hasChecksWorkflow(root) {
580
+ const directory = join(root, ".github/workflows");
581
+ if (!existsSync(directory)) return false;
582
+ for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
583
+ const document = parseDocument(readFileSync(join(directory, file), "utf8"));
584
+ if (document.errors.length) continue;
585
+ const jobs = document.get("jobs", true);
586
+ if (!isMap(jobs)) continue;
587
+ for (const { value: job } of jobs.items) {
588
+ if (!isMap(job)) continue;
589
+ const uses = job.get("uses", true);
590
+ if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
591
+ const steps = job.get("steps", true);
592
+ if (!isSeq(steps)) continue;
593
+ for (const step of steps.items) {
594
+ if (!isMap(step)) continue;
595
+ const run = step.get("run", true);
596
+ if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
597
+ }
598
+ }
599
+ }
600
+ return false;
601
+ }
602
+ function callers(text, pattern) {
603
+ const document = parseDocument(text);
604
+ const jobs = document.errors.length ? void 0 : document.get("jobs", true);
605
+ if (!isMap(jobs)) return [];
606
+ const found = [];
607
+ for (const { key, value: job } of jobs.items) {
608
+ if (!isMap(job)) continue;
609
+ const uses = job.get("uses", true);
610
+ if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
611
+ id: String(isScalar(key) ? key.value : key),
612
+ uses: String(uses.value),
613
+ named: job.has("name")
614
+ });
615
+ }
616
+ return found;
617
+ }
618
+ /** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
619
+ function ciNodeCallers(text) {
620
+ return callers(text, CI_NODE_PATTERN);
621
+ }
622
+ /** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
623
+ function ciRenovateSyncCallers(text) {
624
+ return callers(text, CI_RENOVATE_SYNC_PATTERN);
625
+ }
626
+ //#endregion
627
+ export { RENOVATE_CONFIGS as a, CI_CONTEXT as c, CI_RENOVATE_SYNC_REF as d, ciWorkflow as f, hasChecksWorkflow as i, CI_NODE_REF as l, ciNodeCallers as n, RENOVATE_PRESET as o, placeholderTestScript as p, ciRenovateSyncCallers as r, renovateArtifacts as s, MISSING_CHECKS_WORKFLOW as t, CI_PATH as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/tooling-configs",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -75,7 +75,8 @@
75
75
  "suppressions:update": "node src/bin/suppressions.ts --update",
76
76
  "docs:generate": "node src/docs/generate.ts",
77
77
  "ci:shard": "node src/ci/shard.ts",
78
- "ci:weights": "node src/ci/refresh-weights.ts"
78
+ "ci:weights": "node src/ci/refresh-weights.ts",
79
+ "ci:weights:check": "node src/ci/check-weights.ts"
79
80
  },
80
81
  "dependencies": {
81
82
  "@oxlint/plugins": "1.81.0",