@antelopejs/tooling-configs 0.5.2 → 0.5.4

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-BiXgdsRN.mjs";
3
+ import { t as PRESET_CONFIGS } from "../templates-DaatyItc.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";
@@ -1,7 +1,10 @@
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
+ //#region package.json
6
+ var packageManager$1 = "pnpm@10.2.0";
7
+ //#endregion
5
8
  //#region src/guardrails/package.ts
6
9
  /** The capture tool's optional peers, which a repository with `docs/captures.ts` declares as devDependencies at the ranges the pack tests against. */
7
10
  const CAPTURE_PEERS = [
@@ -25,6 +28,14 @@ function packageManager(manifest) {
25
28
  default: throw new Error(`Unsupported package manager ${manager}. Expected pnpm, npm, yarn, or bun.`);
26
29
  }
27
30
  }
31
+ /** Whether the repository at `root` is a Nuxt app: it depends on `nuxt` or has a `nuxt.config.*`. */
32
+ function usesNuxt(root, manifest) {
33
+ return Boolean(manifest.dependencies?.nuxt || manifest.devDependencies?.nuxt || readdirSync(root).some((name) => name.startsWith("nuxt.config.")));
34
+ }
35
+ /** Whether the repository at `root` has `docs/captures.ts`, so it declares the capture tool's peers. */
36
+ function usesCaptures(root) {
37
+ return existsSync(join(root, "docs/captures.ts"));
38
+ }
28
39
  function execCommand(manager) {
29
40
  if (manager === "npm") return "npm exec --";
30
41
  if (manager === "bun") return "bun x --no-install";
@@ -37,24 +48,23 @@ function toolingVersions() {
37
48
  if (existsSync(path)) {
38
49
  const manifest = parseManifest(readFileSync(path, "utf8"));
39
50
  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
- const oxlint = manifest.devDependencies?.oxlint;
44
- const oxfmt = manifest.devDependencies?.oxfmt;
45
- if (!lefthook || !knip || !tsgolint || !oxlint || !oxfmt || !manifest.version) throw new Error("tooling-configs must declare its version and lefthook, knip, oxlint, oxfmt and oxlint-tsgolint devDependencies.");
46
- const tested = manifest.devDependencies ?? {};
51
+ const declared = (field, name) => {
52
+ const range = manifest[field]?.[name];
53
+ if (!range) throw new Error(`tooling-configs must declare ${name} in ${field}.`);
54
+ return range;
55
+ };
56
+ const dev = (name) => declared("devDependencies", name);
57
+ if (!manifest.version) throw new Error("tooling-configs must declare its version.");
47
58
  return {
48
- lefthook,
49
- knip,
50
- tsgolint,
51
- oxlint,
52
- oxfmt,
53
- capture: CAPTURE_PEERS.map((name) => {
54
- const range = tested[name];
55
- if (!range) throw new Error(`tooling-configs must declare ${name} as a devDependency.`);
56
- return [name, range];
57
- }),
59
+ lefthook: dev("lefthook"),
60
+ knip: dev("knip"),
61
+ tsgolint: dev("oxlint-tsgolint"),
62
+ oxlint: dev("oxlint"),
63
+ oxfmt: dev("oxfmt"),
64
+ typescript: declared("dependencies", "typescript"),
65
+ nodeTypes: dev("@types/node"),
66
+ capture: CAPTURE_PEERS.map((name) => [name, dev(name)]),
67
+ packageManager: packageManager$1,
58
68
  pack: manifest.version
59
69
  };
60
70
  }
@@ -159,26 +169,46 @@ function addedDevDependencies(manifest, versions, options) {
159
169
  if (options.typeAware) tools.push(["oxlint-tsgolint", versions.tsgolint]);
160
170
  return [...tools.filter(([name]) => !declared[name]), ...options.captures ? versions.capture.filter(([name, tested]) => !withinTested(declared[name], tested)) : []];
161
171
  }
162
- /** The pack, oxlint, oxlint-tsgolint and oxfmt with the ranges `--init` declares for a repository that has none of them. Sync needs the first three installed to load its preset and run the type-aware baseline before it writes any devDependency. */
163
- function bootstrapDependencies(manifest, versions) {
172
+ /**
173
+ * The pack, oxlint, oxlint-tsgolint, oxfmt and typescript with the ranges `--init` declares for a repository that has
174
+ * none of them, and `@types/node` when `nodeProject` says init writes the tsconfig that loads it. Sync needs the first
175
+ * three installed to load its preset and run the type-aware baseline before it writes any devDependency; the synced
176
+ * `typecheck` script runs typescript's `tsc`.
177
+ */
178
+ function bootstrapDependencies(manifest, versions, nodeProject) {
164
179
  const declared = {
165
180
  ...manifest.dependencies,
166
181
  ...manifest.devDependencies
167
182
  };
168
- return [
183
+ const wanted = [
169
184
  ["@antelopejs/tooling-configs", `^${versions.pack}`],
170
185
  ["oxlint", versions.oxlint],
171
186
  ["oxlint-tsgolint", versions.tsgolint],
172
- ["oxfmt", versions.oxfmt]
173
- ].filter(([name]) => !declared[name]);
187
+ ["oxfmt", versions.oxfmt],
188
+ ["typescript", versions.typescript]
189
+ ];
190
+ if (nodeProject) wanted.push(["@types/node", versions.nodeTypes]);
191
+ return wanted.filter(([name]) => !declared[name]);
174
192
  }
175
- /** `current` with `added` in its sorted devDependencies, formatted as the rest of the sync writers do. */
176
- function withDevDependencies(current, added) {
193
+ /** The `test` script `npm init` writes, which fails every run. */
194
+ const NPM_INIT_TEST = "echo \"Error: no test specified\" && exit 1";
195
+ /**
196
+ * `current` with `added` in its sorted devDependencies, `packageManager` set to `pin` unless it names pnpm, the only
197
+ * manager the pack's CI installs with, and a `test` script running Node's test runner when it has none or only npm's
198
+ * failing default, which passes with no test file and runs the ones the repository adds. An explicit `"type": "commonjs"`, which `npm init` writes, is dropped: under
199
+ * it Node refuses to load the pack's ESM `*.config.ts` files, while without it `.js` files stay CommonJS unless they
200
+ * use ESM syntax, which `commonjs` rejected anyway. Formatted as the rest of the sync writers do.
201
+ */
202
+ function bootstrappedManifest(current, added, pin) {
177
203
  const manifest = parseManifest(current);
178
204
  manifest.devDependencies = sortedEntries({
179
205
  ...manifest.devDependencies,
180
206
  ...Object.fromEntries(added)
181
207
  });
208
+ if (manifest.packageManager === void 0 || packageManager(manifest) !== "pnpm") manifest.packageManager = pin;
209
+ if (manifest.type === "commonjs") delete manifest.type;
210
+ const scripts = manifest.scripts ??= {};
211
+ if (scripts.test === void 0 || scripts.test === NPM_INIT_TEST) scripts.test = "node --test";
182
212
  return serializeManifest(manifest, current);
183
213
  }
184
214
  function managedPackage(current, versions, options = {}) {
@@ -244,10 +274,11 @@ function templatePackage(current, versions, options) {
244
274
  });
245
275
  return serializeManifest(manifest, current);
246
276
  }
277
+ /** `manifest` as JSON in the indentation and line endings of `current`, the text it was read from. */
247
278
  function serializeManifest(manifest, current) {
248
279
  const indent = /^([\t ]+)"/m.exec(current)?.[1] ?? " ";
249
280
  const newline = current.includes("\r\n") ? "\r\n" : "\n";
250
281
  return `${JSON.stringify(manifest, null, indent).replaceAll("\n", newline)}${newline}`;
251
282
  }
252
283
  //#endregion
253
- export { packageManager as a, templatePackage as c, managedPackage as i, toolingVersions as l, bootstrapDependencies as n, parseManifest as o, execCommand as r, repositoryTools as s, addedDevDependencies as t, withDevDependencies as u };
284
+ export { managedPackage as a, repositoryTools as c, toolingVersions as d, usesCaptures as f, execCommand as i, serializeManifest as l, bootstrapDependencies as n, packageManager as o, usesNuxt as p, bootstrappedManifest as r, parseManifest as s, addedDevDependencies as t, templatePackage as u };
@@ -1,6 +1,6 @@
1
- import { o as parseManifest } from "./package-DxxcxOzp.mjs";
1
+ import { s as parseManifest } from "./package-CORwvwTw.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 { l as toolingVersions } from "./package-DxxcxOzp.mjs";
3
+ import { d as toolingVersions } from "./package-CORwvwTw.mjs";
4
4
  import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-DJ0TeaTU.mjs";
5
5
  import { t as lintDiagnostics } from "./oxlint-BbpTFFmf.mjs";
6
- import "./suppression-budget-Dvb_IqBo.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 { r as execCommand } from "./package-DxxcxOzp.mjs";
1
+ import { i as execCommand } from "./package-CORwvwTw.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 { o as parseManifest } from "./package-DxxcxOzp.mjs";
1
+ import { s as parseManifest } from "./package-CORwvwTw.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";
@@ -434,7 +434,7 @@ function canonicalSyncJob() {
434
434
  }
435
435
  function ensureSyncJob(document, jobs, syncCallers) {
436
436
  if (!syncCallers.length) {
437
- jobs.set(RENOVATE_SYNC_JOB_ID, canonicalSyncJob());
437
+ jobs.add(document.createPair(RENOVATE_SYNC_JOB_ID, canonicalSyncJob()));
438
438
  return true;
439
439
  }
440
440
  let changed = false;
@@ -473,7 +473,10 @@ function dropRedundantAggregator(jobs, syncCallers) {
473
473
  * that still exist, so sync never drops coverage.
474
474
  */
475
475
  function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests = false) {
476
- 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);
477
480
  if (!callers.length) return current;
478
481
  const document = parseDocument(current);
479
482
  if (document.errors.length) throw new Error(`${CI_PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/tooling-configs",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
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",