@antelopejs/tooling-configs 0.3.5 → 0.3.6

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/README.md CHANGED
@@ -83,7 +83,7 @@ The tools are optional peer dependencies, so add only the ones a repository uses
83
83
  | Tool | Packages to add |
84
84
  | ----------------------- | -------------------------------------------------------------------------------- |
85
85
  | oxlint | `oxlint@1.81.0`, plus `oxlint-tsgolint` for the type-aware rules (on by default) |
86
- | oxfmt | `oxfmt@^0.66.0` |
86
+ | oxfmt | `oxfmt@^0.77.0` |
87
87
  | ESLint | `@nuxt/eslint-config` |
88
88
  | Knip | `knip@>=6` |
89
89
  | Import sorting (opt-in) | `eslint-plugin-perfectionist` |
@@ -210,7 +210,12 @@ pnpm install
210
210
 
211
211
  `--profile template` writes only the three preset configs, a user-facing `AGENTS.md` block and the `suppressions` package scripts (plus `ratchet` once `guardrails.ratchet.json` exists) that `antelopejs-checks` requires, for template repositories. The agent layer, `verify-template` and the writing skills under `.agents/skills/` with their `.claude/skills` links, is synced and checked only in the template source, marked by its `.agents/skills/verify-template/` folder; a project scaffolded from the template ships without it, so the template's `AGENTS.md` block links no skill under `.agents/` or `.claude/skills/`. `antelopejs-sync --check` writes nothing and exits 1 on any drift; `pnpm run checks` runs it.
212
212
 
213
- `pnpm run checks` runs `typecheck`, `lint`, `format:check`, `knip`, `test`, `size`, `suppressions` and `sync:check`, plus `ratchet` when `guardrails.ratchet.json` exists. It prints only the output of the steps that failed. Sync adds the ratchet scripts and pre-commit hook only while that file exists.
213
+ `pnpm run checks` runs `typecheck`, `lint`, `format:check`, `knip`, `test`, `size`, `suppressions` and `sync:check`, plus `ratchet` when `guardrails.ratchet.json` exists. It prints only the output of the steps that failed. Sync adds the ratchet scripts and pre-commit hook only while `guardrails.ratchet.json` exists. When the repository has a verify layer, an `.agents/skills/verify-*` folder holding a `verify.config.ts` or a `tsconfig.json`, it also runs `verify:types` and `verify:lockfiles`, which need no package script. Neither writes a file in the repository, spawns a package manager or fetches anything, so both pass offline after a root install, as CI runs them.
214
+
215
+ - `verify:types` type-checks each layer's own code with the repository's own TypeScript, run as `node <typescript>/bin/tsc` without a shell. The files are those the layer's `tsconfig.json` includes, minus its `playground` folder and any `node_modules` or `dist` folder: verify compiles a playground itself, with the playground's own config, after installing it. The step writes a config to the system temp folder that extends the layer's, lists those files, keeps the layer's type roots, sets `noEmit` and unsets with `null` the `declaration`, `composite`, `incremental`, `tsBuildInfoFile`, `declarationDir`, `declarationMap`, `emitDeclarationOnly` and `isolatedDeclarations` the layer may inherit, then deletes it. No `.tsbuildinfo` is written, no declaration check runs on code that is never emitted, and `skipLibCheck` keeps the layer's value. `antelopejs-sync` writes the `tsconfig.json` of the shared `verify-interface`, `verify-module` and `verify-template` layers; a repository's own layer, such as a `verify-dms-*` one, keeps the one it wrote. A layer with a `verify.config.ts` and no `tsconfig.json` fails, and so does one whose `tsconfig.json` does not include its `verify.config.ts`.
216
+ - `verify:lockfiles` compares, in code, the direct dependencies each lockfile records with the `package.json` files it locks, and fails on a difference in either direction, naming the dependency and the command that regenerates the lockfile. It reads each lockfile in a folder under a layer, `node_modules` and `dist` aside, and in the root `playground`. A `pnpm-lock.yaml` is compared importer by importer, for each importer it lists that has a `package.json` on disk; a `package-lock.json` by its root entry. Only `dependencies`, `devDependencies` and `optionalDependencies` are compared, by name and specifier: a name counts as present whichever of the three fields records it, and a `catalog:` or `workspace:` specifier compares as written, as pnpm stores it. A name the lockfile records that `package.json` declares only in `peerDependencies` passes, whether or not peers are auto-installed. A name an override selector in the `pnpm-lock.yaml` mentions is not compared, nor is a `link:` dependency the lockfile leaves out under `excludeLinksFromLockfile`. A lockfile it cannot parse, or of a version before pnpm's 6 or npm's 2, fails as unreadable. A missing lockfile fails only in a layer's `playground` or the root `playground` whose `package.json` has dependencies, unless a folder above it holds a `pnpm-workspace.yaml` or a `package.json` with `workspaces`; the fix it names is npm's when a `package-lock.json` sits in a folder above, pnpm's otherwise. It does not check workspace membership, `overrides`, lockfile `settings`, catalogs, `.npmrc` or user configuration, resolved versions, integrity hashes, transitive entries, npm workspace members, or `yarn.lock` and `bun.lock`: verify's own frozen install still rejects a lockfile stale there.
217
+
218
+ `ANTELOPEJS_CHECKS_SKIP` accepts both names.
214
219
 
215
220
  When the repository has `.github/compose.yml`, the file the shared CI starts through its `services-compose-file` input, and the `test` step runs, `pnpm run checks` runs `docker compose -f .github/compose.yml up -d --wait` before the steps and `docker compose -f .github/compose.yml down -v` after them, also when a step fails or the run is interrupted (SIGINT, SIGTERM or SIGHUP stops the running step or `up`, removes the services and exits 130, 143 or 129; a repeated signal does not cut the teardown short). The compose project is `COMPOSE_PROJECT_NAME` when set, else the file's own `name:`, else one named after the repository root, so checkouts never share the `github` project compose would derive from the file's directory. Services are left alone when every port the file publishes already accepts connections, so a stack you started yourself is reused and kept. A run's project that already had containers before the run is started but not removed. When Docker Compose cannot run, the run fails before any step, naming the compose file, because the tests that need those services would wait for them forever. On GitHub Actions (`GITHUB_ACTIONS=true`) the workflow owns the services, and `--no-services` skips all of this anywhere.
216
221
 
@@ -237,6 +242,19 @@ When every rule count is zero and `oversizeFiles` is empty, the ratchet is retir
237
242
 
238
243
  `antelopejs-sync --check` rejects an existing retired file and tells you to run `ratchet:update`. Plain sync reports the same note but leaves deletion to the update command.
239
244
 
245
+ ### Lib check coverage
246
+
247
+ No repository sets `skipLibCheck` globally. `typecheck` runs a full `tsc --noEmit` over the program that covers the sources, and `build` may pass `--skipLibCheck` only over a program `typecheck` checks in full, so nothing `typecheck` skipped goes unchecked. `antelopejs-sync` and `antelopejs-sync --check` print a `Note:` line naming the file, the script and the fix, and do not fail, when:
248
+
249
+ - `build` passes `--skipLibCheck` (in any letter case) to a `tsc` program (`-p`/`--project`, `tsconfig.json` when absent) that no `tsc` run of `typecheck` covers without `--skipLibCheck`. `./tsconfig.build.json` and `tsconfig.build.json`, `-p .` and no `-p` are the same program. `pre<script>` scripts count with their script, and `&&` chains, parentheses, `cross-env` and environment prefixes, `run-s` and `npm-run-all`, and scripts run through `pnpm`, `npm`, `yarn` or `bun` (`--filter <x>`, `-C <dir>` and other options with a value included) are followed to five levels. `tsc` is recognised as `tsc`, `npx tsc`, `npx -p typescript tsc`, `pnpm exec tsc` and `node ./node_modules/typescript/bin/tsc`.
250
+ - A tsconfig the scripts use through `tsc`, or the root `tsconfig.json`, ends up with `compilerOptions.skipLibCheck: true`, set directly or through a local `extends` chain (`.json` or `.jsonc`, a later duplicate key winning as in tsc). `tsc -b` reads the config it names and the projects they reference. Presets extended from a package are not read. When the file that sets it is one git ignores, such as Nuxt's generated `.nuxt/tsconfig.json`, the note names the first tracked tsconfig of the chain and asks for `skipLibCheck: false` there; when none is tracked, nothing is reported.
251
+ - A `release` script exists and does not run `typecheck`, directly or through a script it runs, its `prerelease`, or a release-it hook that runs before publishing (`before:init`, `before:bump`, `before:release` and their plugin-scoped forms), read from `.release-it.json` and from `release-it.hooks` in `package.json`.
252
+ - A file the check needs cannot be read (a directory where a tsconfig is expected, a permission error): the note says "could not read …" and sync carries on.
253
+
254
+ These findings are report-only for now: a later release makes `--check` fail on them once the repositories that still miss them are fixed. `antelopejs-checks` hides the output of a step that passes, so the notes show only when `antelopejs-sync` runs directly, which agents do when they bump the pack.
255
+
256
+ Known blind spots, none of them read: `|| true` or a background `&` after a `typecheck`, a `typecheck` placed after `release-it` in `release`, a `typecheck` that checks nothing, `vue-tsc`, release-it configs other than JSON (`.release-it.js`, `.yaml`, `.toml`), presets extended from a package, and workspace packages.
257
+
240
258
  ### Suppression budget
241
259
 
242
260
  `guardrails.suppressions.json` caps the suppressions in authored code files. It is separate from the ratchet and permanent: it stays when its counts reach zero and when the ratchet is retired.
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import "../ceilings-B7KayYIG.mjs";
2
+ import { t as CEILINGS_FILE } from "../ceilings-B7KayYIG.mjs";
3
3
  import { i as parseManifest, r as packageManager } from "../package-CqqBgE8Y.mjs";
4
4
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
5
5
  import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
6
6
  import { t as accepting } from "../ports-DGP6bPJy.mjs";
7
- import { existsSync, readFileSync } from "node:fs";
8
- import { basename, join } from "node:path";
7
+ import { createRequire } from "node:module";
8
+ import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
9
+ import { basename, join, posix, relative, resolve, sep } from "node:path";
9
10
  import { spawn } from "node:child_process";
10
11
  import { isMap, isScalar, isSeq, parseDocument } from "yaml";
11
12
  import { createHash } from "node:crypto";
13
+ import { tmpdir } from "node:os";
12
14
  import { parseArgs } from "node:util";
13
15
  //#region src/guardrails/run-command.ts
14
16
  const KILL_GRACE_MS = 5e3;
@@ -23,15 +25,17 @@ function stopGroup(child, signal) {
23
25
  }
24
26
  /**
25
27
  * Runs `command` in its own process group and collects stdout and stderr together. When `signal` aborts, the group
26
- * gets SIGTERM, then SIGKILL after a grace period, so a step's own children stop with it.
28
+ * gets SIGTERM, then SIGKILL after a grace period, so a step's own children stop with it. On Windows the command runs
29
+ * through a shell, so `npm` and `pnpm` resolve to their `.cmd` shims, unless `shell` is `false`: pass that for an
30
+ * executable path and arguments that a shell must not split, such as paths with spaces.
27
31
  */
28
32
  function runCommand(command, args, options) {
29
- const { cwd, env = process.env, signal } = options;
33
+ const { cwd, env = process.env, signal, shell = process.platform === "win32" } = options;
30
34
  return new Promise((resolve) => {
31
35
  const child = spawn(command, args, {
32
36
  cwd,
33
37
  env,
34
- shell: process.platform === "win32",
38
+ shell,
35
39
  detached: process.platform !== "win32",
36
40
  stdio: [
37
41
  "ignore",
@@ -184,6 +188,327 @@ async function stopServices(root) {
184
188
  return (await compose(root, ["down", "-v"])).failure;
185
189
  }
186
190
  //#endregion
191
+ //#region src/guardrails/verify-layers.ts
192
+ const SKILLS_FOLDER = ".agents/skills";
193
+ const LAYER_PREFIX = "verify-";
194
+ const TSCONFIG = "tsconfig.json";
195
+ /** Folders of a layer that are not the layer's own code: verify builds its playground with the playground's own tsconfig. */
196
+ const NOT_LAYER_CODE = /* @__PURE__ */ new Set(["node_modules", "dist"]);
197
+ const LAYER_PLAYGROUND = "playground";
198
+ const VERIFY_CONFIG = "verify.config.ts";
199
+ /**
200
+ * Options the generated config sets over the layer's: nothing is emitted, and each declaration or build-cache option the
201
+ * layer may inherit is unset with `null`, so no `.tsbuildinfo` is written, no option is left needing `declaration` or
202
+ * `composite`, and the declaration checks of files that are never emitted are not run.
203
+ */
204
+ const NO_OUTPUT = {
205
+ noEmit: true,
206
+ declaration: null,
207
+ composite: null,
208
+ incremental: null,
209
+ tsBuildInfoFile: null,
210
+ declarationDir: null,
211
+ declarationMap: null,
212
+ emitDeclarationOnly: null,
213
+ isolatedDeclarations: null
214
+ };
215
+ /** The verify layers of a repository, relative to its root: each `.agents/skills/verify-*` folder that holds a `tsconfig.json` or a `verify.config.ts`. */
216
+ function verifyLayers(root) {
217
+ const skills = join(root, SKILLS_FOLDER);
218
+ if (!existsSync(skills)) return [];
219
+ return readdirSync(skills, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith(LAYER_PREFIX) && [TSCONFIG, VERIFY_CONFIG].some((file) => existsSync(join(skills, entry.name, file)))).map((entry) => `${SKILLS_FOLDER}/${entry.name}`).sort();
220
+ }
221
+ /** Whether a file the layer's tsconfig includes is the layer's own code, not its playground, a dependency or a build output. */
222
+ function isLayerCode(layer, file) {
223
+ const segments = relative(layer, file).split(sep);
224
+ return segments[0] !== LAYER_PLAYGROUND && !segments.some((segment) => NOT_LAYER_CODE.has(segment));
225
+ }
226
+ /** The repository's own `tsc` entry, run with Node so no shell parses its path. */
227
+ function compilerOf(root) {
228
+ try {
229
+ return createRequire(join(root, "package.json")).resolve("typescript/bin/tsc");
230
+ } catch {
231
+ return;
232
+ }
233
+ }
234
+ async function typecheckLayer(root, compiler, layer, signal) {
235
+ const configPath = join(root, layer, TSCONFIG);
236
+ if (!existsSync(configPath)) return `${layer}: has a verify.config.ts and no tsconfig.json. Add a tsconfig.json that includes its TypeScript files; antelopejs-sync writes one for the shared kinds.\n`;
237
+ const ts = (await import("typescript")).default;
238
+ const parsed = ts.getParsedCommandLineOfConfigFile(configPath, void 0, {
239
+ ...ts.sys,
240
+ onUnRecoverableConfigFileDiagnostic: () => void 0
241
+ });
242
+ if (parsed === void 0) return `${layer}/${TSCONFIG}: could not read it.\n`;
243
+ const verifyConfig = join(root, layer, VERIFY_CONFIG);
244
+ if (existsSync(verifyConfig) && !parsed.fileNames.some((file) => resolve(file) === verifyConfig)) return `${layer}/${TSCONFIG}: does not include ${VERIFY_CONFIG}, so it is never type-checked. Add it to the tsconfig's "include" or "files".\n`;
245
+ const files = parsed.fileNames.filter((file) => isLayerCode(join(root, layer), resolve(file)));
246
+ if (files.length === 0) return "";
247
+ const folder = mkdtempSync(join(tmpdir(), "antelopejs-verify-types-"));
248
+ try {
249
+ const generated = join(folder, TSCONFIG);
250
+ writeFileSync(generated, JSON.stringify({
251
+ extends: configPath,
252
+ compilerOptions: {
253
+ ...NO_OUTPUT,
254
+ typeRoots: ts.getEffectiveTypeRoots(parsed.options, ts.sys)
255
+ },
256
+ files,
257
+ include: []
258
+ }));
259
+ const result = await runCommand(process.execPath, [
260
+ compiler,
261
+ "-p",
262
+ generated,
263
+ "--pretty",
264
+ "false"
265
+ ], {
266
+ cwd: root,
267
+ env: {
268
+ ...process.env,
269
+ CI: "1"
270
+ },
271
+ signal,
272
+ shell: false
273
+ });
274
+ return result.status === 0 ? "" : result.output;
275
+ } finally {
276
+ rmSync(folder, {
277
+ recursive: true,
278
+ force: true
279
+ });
280
+ }
281
+ }
282
+ /**
283
+ * Type-checks the own code of each verify layer with the repository's own TypeScript. The files are those the layer's
284
+ * `tsconfig.json` includes, minus its `playground` folder, which verify compiles with the playground's own config after
285
+ * installing it, and any `node_modules` or `dist` folder. A config generated in the system temp folder extends the layer's,
286
+ * lists those files, turns off emit and unsets the emit and build-cache options in `NO_OUTPUT`, so nothing is written in the
287
+ * repository and no package is fetched. A layer whose `tsconfig.json` does not include its `verify.config.ts` fails. Returns the compiler output of the layers that fail, empty when all pass.
288
+ */
289
+ async function typecheckLayers(root, signal) {
290
+ const layers = verifyLayers(root);
291
+ if (layers.length === 0) return "";
292
+ const compiler = compilerOf(root);
293
+ if (compiler === void 0) return "TypeScript is not installed in the repository root: run the package manager's install first.\n";
294
+ return (await Promise.all(layers.map((layer) => typecheckLayer(root, compiler, layer, signal)))).join("");
295
+ }
296
+ //#endregion
297
+ //#region src/guardrails/verify-lockfiles.ts
298
+ /** The folder a repository's playground lives in; verify installs a fixture project from it. */
299
+ const PLAYGROUND = "playground";
300
+ const PNPM_LOCK = "pnpm-lock.yaml";
301
+ const NPM_LOCK = "package-lock.json";
302
+ const MANIFEST = "package.json";
303
+ const PNPM_WORKSPACE = "pnpm-workspace.yaml";
304
+ /** Lockfiles this check does not compare, which still mean a folder is locked. */
305
+ const OTHER_LOCKS = [
306
+ "npm-shrinkwrap.json",
307
+ "yarn.lock",
308
+ "bun.lock",
309
+ "bun.lockb"
310
+ ];
311
+ /** The manifest fields both package managers record as a project's direct dependencies. */
312
+ const DIRECT_FIELDS = [
313
+ "dependencies",
314
+ "devDependencies",
315
+ "optionalDependencies"
316
+ ];
317
+ var Unreadable = class extends Error {};
318
+ /** Parses a JSON or YAML file whose top level is a mapping; throws `Unreadable` otherwise. */
319
+ function readMapping(path) {
320
+ const document = parseDocument(readFileSync(path, "utf8"), {
321
+ schema: "failsafe",
322
+ uniqueKeys: false
323
+ });
324
+ const { contents } = document;
325
+ if (document.errors.length > 0 || !isMap(contents)) throw new Unreadable(path);
326
+ return contents;
327
+ }
328
+ function mapping(map, key) {
329
+ const value = map?.get(key, true);
330
+ return isMap(value) ? value : void 0;
331
+ }
332
+ function scalar(map, key) {
333
+ const value = map?.get(key, true);
334
+ return isScalar(value) ? String(value.value) : void 0;
335
+ }
336
+ function keys(map) {
337
+ return (map?.items ?? []).flatMap((pair) => isScalar(pair.key) ? [String(pair.key.value)] : []);
338
+ }
339
+ /** Reads a project's direct dependencies, with `specifierOf` reading the specifier of one name from its field. */
340
+ function directOf(node, specifierOf) {
341
+ const direct = /* @__PURE__ */ new Map();
342
+ for (const field of DIRECT_FIELDS) {
343
+ const entries = mapping(node, field);
344
+ for (const name of keys(entries)) {
345
+ const specifier = specifierOf(entries, name);
346
+ if (specifier === void 0) throw new Unreadable(name);
347
+ direct.set(name, /* @__PURE__ */ new Set([...direct.get(name) ?? [], specifier]));
348
+ }
349
+ }
350
+ return direct;
351
+ }
352
+ /** A `package.json` or a `package-lock.json` root entry, where each name maps to its specifier. */
353
+ function declared(node) {
354
+ return directOf(node, scalar);
355
+ }
356
+ /** A `pnpm-lock.yaml` importer, where each name maps to its `specifier` and resolved `version`. */
357
+ function pnpmLocked(node) {
358
+ return directOf(node, (field, name) => scalar(mapping(field, name), "specifier"));
359
+ }
360
+ function listed(specifiers) {
361
+ return specifiers === void 0 ? "none" : [...specifiers].map((specifier) => `"${specifier}"`).join(" or ");
362
+ }
363
+ /**
364
+ * The names whose specifiers differ between a manifest and what its lockfile records, in either direction. A name counts as
365
+ * present whichever of the three fields records it, and matches when the two sides share a specifier. A name the lockfile
366
+ * records and the manifest declares only as a peer passes, since the package manager may or may not install peers. `skip`
367
+ * names the manifest entries the lockfile may leave out or record with another specifier.
368
+ */
369
+ function differences(manifest, locked, skip) {
370
+ const wanted = declared(manifest);
371
+ const peers = new Set(keys(mapping(manifest, "peerDependencies")));
372
+ const line = (name) => `"${name}": package.json asks for ${listed(wanted.get(name))}, the lockfile has ${listed(locked.get(name))}.`;
373
+ const stale = [...wanted].filter(([name, specifiers]) => ![...locked.get(name) ?? []].some((specifier) => specifiers.has(specifier)) && !skip(name, specifiers)).map(([name]) => line(name));
374
+ const extra = [...locked.keys()].filter((name) => !wanted.has(name) && !peers.has(name)).map(line);
375
+ return [...stale, ...extra].sort();
376
+ }
377
+ /** Every package name an override selector such as `foo`, `@scope/foo@^1` or `bar@1>foo@2` mentions, its target among them. */
378
+ function overrideNames(selector) {
379
+ return selector.split(">").flatMap((segment) => /^(?:@[^/@]+\/)?[^@]+/u.exec(segment) ?? []);
380
+ }
381
+ function pnpmDifferences(path) {
382
+ const lockfile = readMapping(join(path, PNPM_LOCK));
383
+ if (Number(scalar(lockfile, "lockfileVersion") ?? "0") < 6) throw new Unreadable(path);
384
+ const overridden = new Set(keys(mapping(lockfile, "overrides")).flatMap(overrideNames));
385
+ const linksLeftOut = scalar(mapping(lockfile, "settings"), "excludeLinksFromLockfile") === "true";
386
+ const skip = (name, specifiers) => overridden.has(name) || linksLeftOut && [...specifiers].every((specifier) => specifier.startsWith("link:"));
387
+ const importers = mapping(lockfile, "importers");
388
+ return (importers ? keys(importers) : ["."]).flatMap((importer) => {
389
+ const manifest = join(path, importer, MANIFEST);
390
+ if (!existsSync(manifest)) return [];
391
+ const node = importers ? mapping(importers, importer) : lockfile;
392
+ return differences(readMapping(manifest), pnpmLocked(node), skip).map((line) => `importer "${importer}" ${line}`);
393
+ });
394
+ }
395
+ function npmDifferences(path) {
396
+ const lockfile = readMapping(join(path, NPM_LOCK));
397
+ const rootEntry = mapping(mapping(lockfile, "packages"), "");
398
+ if (Number(scalar(lockfile, "lockfileVersion") ?? "0") < 2 || rootEntry === void 0) throw new Unreadable(path);
399
+ const manifest = join(path, MANIFEST);
400
+ if (!existsSync(manifest)) return [];
401
+ return differences(readMapping(manifest), declared(rootEntry), () => false);
402
+ }
403
+ function lockfileIn(path) {
404
+ if (existsSync(join(path, PNPM_LOCK))) return PNPM_LOCK;
405
+ if (existsSync(join(path, NPM_LOCK))) return NPM_LOCK;
406
+ return OTHER_LOCKS.some((name) => existsSync(join(path, name))) ? "other" : void 0;
407
+ }
408
+ /** Each folder at or under `folder`, `node_modules` and `dist` aside, that holds a lockfile. */
409
+ function lockedFolders(root, folder) {
410
+ const path = join(root, folder);
411
+ if (!existsSync(path)) return [];
412
+ const lockfile = lockfileIn(path);
413
+ return [...lockfile === void 0 ? [] : [{
414
+ folder,
415
+ lockfile
416
+ }], ...readdirSync(path, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist").flatMap((entry) => lockedFolders(root, `${folder}/${entry.name}`))];
417
+ }
418
+ /** Whether a `package.json` declares a direct dependency; `false` when it is missing or cannot be read, so this check cannot tell. */
419
+ function hasDependencies(path) {
420
+ try {
421
+ if (!existsSync(path)) return false;
422
+ const manifest = readMapping(path);
423
+ return DIRECT_FIELDS.some((field) => keys(mapping(manifest, field)).length > 0);
424
+ } catch (error) {
425
+ if (error instanceof Unreadable) return false;
426
+ throw error;
427
+ }
428
+ }
429
+ /**
430
+ * The folders this check reads, when a layer exists: each folder under a layer, `node_modules` and `dist` aside, and the
431
+ * root `playground`, that holds a lockfile; and each layer's `playground` and the root `playground`, the folders verify
432
+ * installs from, when its `package.json` has dependencies and it holds no lockfile.
433
+ */
434
+ function verifyInstallFolders(root) {
435
+ const layers = verifyLayers(root);
436
+ if (layers.length === 0) return [];
437
+ const playgrounds = [...layers.map((layer) => `${layer}/${PLAYGROUND}`), PLAYGROUND];
438
+ const rootPlayground = lockfileIn(join(root, PLAYGROUND));
439
+ return [
440
+ ...layers.flatMap((layer) => lockedFolders(root, layer)),
441
+ ...rootPlayground === void 0 ? [] : [{
442
+ folder: PLAYGROUND,
443
+ lockfile: rootPlayground
444
+ }],
445
+ ...playgrounds.filter((folder) => lockfileIn(join(root, folder)) === void 0 && hasDependencies(join(root, folder, MANIFEST))).map((folder) => ({
446
+ folder,
447
+ lockfile: void 0
448
+ }))
449
+ ];
450
+ }
451
+ /** The folders above `folder`, nearest first, up to the repository root. */
452
+ function ancestors(folder) {
453
+ const parent = posix.dirname(folder);
454
+ return parent === folder ? [] : [parent, ...ancestors(parent)];
455
+ }
456
+ /** Whether a manifest declares workspaces, or cannot be read and so might. */
457
+ function declaresWorkspaces(path) {
458
+ try {
459
+ return existsSync(path) && readMapping(path).has("workspaces");
460
+ } catch (error) {
461
+ if (error instanceof Unreadable) return true;
462
+ throw error;
463
+ }
464
+ }
465
+ /**
466
+ * Whether a folder above `folder` holds a workspace that may list it, a `pnpm-workspace.yaml` or a `package.json` with
467
+ * `workspaces`: its membership then follows patterns this check does not evaluate, and that workspace's lockfile may hold it.
468
+ */
469
+ function inWorkspace(root, folder) {
470
+ return ancestors(folder).some((above) => existsSync(join(root, above, PNPM_WORKSPACE)) || declaresWorkspaces(join(root, above, MANIFEST)));
471
+ }
472
+ function fixCommand(root, folder, lockfile) {
473
+ if (lockfile === NPM_LOCK) return `npm install --package-lock-only --prefix ${folder}`;
474
+ return existsSync(join(root, folder, PNPM_WORKSPACE)) ? `pnpm install --dir ${folder} --lockfile-only` : `pnpm install --dir ${folder} --ignore-workspace --lockfile-only`;
475
+ }
476
+ function unlocked(root, folder) {
477
+ if (inWorkspace(root, folder)) return "";
478
+ const manager = ancestors(folder).some((above) => existsSync(join(root, above, NPM_LOCK))) ? NPM_LOCK : PNPM_LOCK;
479
+ return `${folder}/${MANIFEST} has dependencies and no lockfile: run \`${fixCommand(root, folder, manager)}\`.\n`;
480
+ }
481
+ function checkFolder(root, { folder, lockfile }) {
482
+ if (lockfile === "other") return "";
483
+ try {
484
+ if (lockfile === void 0) return unlocked(root, folder);
485
+ const path = join(root, folder);
486
+ const found = lockfile === PNPM_LOCK ? pnpmDifferences(path) : npmDifferences(path);
487
+ return found.length === 0 ? "" : `${folder}/${lockfile} does not match ${folder}/${MANIFEST}: run \`${fixCommand(root, folder, lockfile)}\`.\n${found.map((line) => ` ${line}\n`).join("")}`;
488
+ } catch (error) {
489
+ if (error instanceof Unreadable) return `${folder}/${lockfile ?? MANIFEST}: could not read it, or a ${MANIFEST} it locks, as a version this check knows.\n`;
490
+ throw error;
491
+ }
492
+ }
493
+ /**
494
+ * Compares, in code, the direct dependencies each lockfile records with the `package.json` files it locks, and fails on a
495
+ * difference in either direction. A `pnpm-lock.yaml` is compared importer by importer, for each importer it lists that has a
496
+ * `package.json` on disk; a `package-lock.json` by its root entry. Only `dependencies`, `devDependencies` and
497
+ * `optionalDependencies` are compared, by name and specifier: a name counts as present whichever of the three fields records
498
+ * it, and specifiers such as `catalog:` or `workspace:^` compare as written. A name the lockfile records that `package.json`
499
+ * declares only in `peerDependencies` passes. A `package.json` name that an override selector in the `pnpm-lock.yaml`
500
+ * mentions, or a `link:` one the lockfile leaves out under `excludeLinksFromLockfile`, is not compared. A missing lockfile fails only in a layer's
501
+ * `playground` or the root `playground` whose `package.json` has dependencies, unless a folder above it holds a workspace.
502
+ *
503
+ * It spawns no package manager, writes no file and fetches nothing. It does not check workspace membership, overrides,
504
+ * settings, catalogs, `.npmrc` or user configuration, resolved versions, integrity hashes, transitive entries, npm workspace
505
+ * members, or `yarn.lock` and `bun.lock`: verify's own frozen install still rejects a lockfile stale there. Returns what
506
+ * failed, empty when every lockfile matches.
507
+ */
508
+ function checkLockfiles(root) {
509
+ return verifyInstallFolders(root).map((install) => checkFolder(root, install)).join("");
510
+ }
511
+ //#endregion
187
512
  //#region src/guardrails/checks.ts
188
513
  const CHECK_STEPS = [
189
514
  "typecheck",
@@ -194,8 +519,18 @@ const CHECK_STEPS = [
194
519
  "size",
195
520
  "ratchet",
196
521
  "suppressions",
197
- "sync:check"
522
+ "sync:check",
523
+ "verify:types",
524
+ "verify:lockfiles"
198
525
  ];
526
+ /** Steps `antelopejs-checks` runs itself, no package.json script behind them: each returns what failed, empty when it passed. */
527
+ const OWN_STEPS = /* @__PURE__ */ new Map([["verify:types", typecheckLayers], ["verify:lockfiles", (root) => Promise.resolve(checkLockfiles(root))]]);
528
+ function hasWork(root, step) {
529
+ if (step === "ratchet") return existsSync(join(root, CEILINGS_FILE));
530
+ if (step === "verify:types") return verifyLayers(root).length > 0;
531
+ if (step === "verify:lockfiles") return verifyInstallFolders(root).length > 0;
532
+ return true;
533
+ }
199
534
  /** The step that runs after the others, never beside them: tests often hold time limits that CPU contention would break. */
200
535
  const RUNS_ALONE = "test";
201
536
  /** The environment variable naming, comma-separated, the steps `runChecks` leaves to another CI job. */
@@ -207,6 +542,11 @@ async function runSteps(root, manifest, steps, signal) {
207
542
  const manager = packageManager(manifest);
208
543
  const runStep = async (step) => {
209
544
  if (signal?.aborted) return [];
545
+ const own = OWN_STEPS.get(step);
546
+ if (own) {
547
+ const failure = await own(root, signal);
548
+ return failure ? [`[${step}]\n${failure}`] : [];
549
+ }
210
550
  if (!manifest.scripts?.[step]) return [`[${step}] Missing package.json script "${step}". Run antelopejs-sync.\n`];
211
551
  const result = await runCommand(manager, ["run", step], {
212
552
  cwd: root,
@@ -243,7 +583,7 @@ async function runChecks(root, options = {}) {
243
583
  interrupted: false,
244
584
  output: `[${CHECKS_SKIP_ENV}]\nUnknown step ${unknown.map((name) => `"${name}"`).join(", ")}. Valid steps: ${CHECK_STEPS.join(", ")}.\nChecks: 0 passed, 1 failed.\n`
245
585
  };
246
- const present = CHECK_STEPS.filter((step) => step !== "ratchet" || existsSync(join(root, "guardrails.ratchet.json")));
586
+ const present = CHECK_STEPS.filter((step) => hasWork(root, step));
247
587
  const steps = present.filter((step) => !requested.includes(step));
248
588
  const skipped = present.length - steps.length;
249
589
  const manifest = parseManifest(readFileSync(join(root, "package.json"), "utf8"));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  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";
3
3
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
4
- import { c as ciRenovateSyncCallers, d as RENOVATE_PRESET, i as CI_RENOVATE_SYNC_REF, n as CI_NODE_REF, r as CI_PATH, s as ciNodeCallers, t as CI_CONTEXT, u as RENOVATE_CONFIGS } from "../ci-workflow-C4mQ8QSp.mjs";
4
+ import { c as ciNodeCallers, d as RENOVATE_CONFIGS, f as RENOVATE_PRESET, i as CI_RENOVATE_SYNC_REF, l as ciRenovateSyncCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT } from "../ci-workflow-37qJa9LX.mjs";
5
5
  import { i as ghToken, n as createApi, t as ApiError } from "../api-CCOiLN3w.mjs";
6
6
  import { parseArgs } from "node:util";
7
7
  import { inflateRawSync } from "node:zlib";