@antelopejs/tooling-configs 0.5.2 → 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-BiXgdsRN.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";
@@ -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,24 +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
- 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 ?? {};
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.");
47
51
  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
- }),
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,
58
61
  pack: manifest.version
59
62
  };
60
63
  }
@@ -159,26 +162,46 @@ function addedDevDependencies(manifest, versions, options) {
159
162
  if (options.typeAware) tools.push(["oxlint-tsgolint", versions.tsgolint]);
160
163
  return [...tools.filter(([name]) => !declared[name]), ...options.captures ? versions.capture.filter(([name, tested]) => !withinTested(declared[name], tested)) : []];
161
164
  }
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) {
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) {
164
172
  const declared = {
165
173
  ...manifest.dependencies,
166
174
  ...manifest.devDependencies
167
175
  };
168
- return [
176
+ const wanted = [
169
177
  ["@antelopejs/tooling-configs", `^${versions.pack}`],
170
178
  ["oxlint", versions.oxlint],
171
179
  ["oxlint-tsgolint", versions.tsgolint],
172
- ["oxfmt", versions.oxfmt]
173
- ].filter(([name]) => !declared[name]);
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]);
174
185
  }
175
- /** `current` with `added` in its sorted devDependencies, formatted as the rest of the sync writers do. */
176
- function withDevDependencies(current, added) {
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) {
177
196
  const manifest = parseManifest(current);
178
197
  manifest.devDependencies = sortedEntries({
179
198
  ...manifest.devDependencies,
180
199
  ...Object.fromEntries(added)
181
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";
182
205
  return serializeManifest(manifest, current);
183
206
  }
184
207
  function managedPackage(current, versions, options = {}) {
@@ -244,10 +267,11 @@ function templatePackage(current, versions, options) {
244
267
  });
245
268
  return serializeManifest(manifest, current);
246
269
  }
270
+ /** `manifest` as JSON in the indentation and line endings of `current`, the text it was read from. */
247
271
  function serializeManifest(manifest, current) {
248
272
  const indent = /^([\t ]+)"/m.exec(current)?.[1] ?? " ";
249
273
  const newline = current.includes("\r\n") ? "\r\n" : "\n";
250
274
  return `${JSON.stringify(manifest, null, indent).replaceAll("\n", newline)}${newline}`;
251
275
  }
252
276
  //#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 };
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 { o as parseManifest } from "./package-DxxcxOzp.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 { l as toolingVersions } from "./package-DxxcxOzp.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
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-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 { o as parseManifest } from "./package-DxxcxOzp.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";
@@ -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.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",