@antelopejs/tooling-configs 0.8.1-next.374.g2cfc8a1 → 0.8.1-next.375.gde7597d

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
3
3
  import { s as repositoryRoot } from "../files-C0avD1Eo.mjs";
4
- import { i as runChecks, n as CI_TIER_ENV, t as CHECKS_SKIP_ENV } from "../checks-DLYDbTCN.mjs";
4
+ import { i as runChecks, n as CI_TIER_ENV, t as CHECKS_SKIP_ENV } from "../checks-Crg3yU_o.mjs";
5
5
  import { parseArgs } from "node:util";
6
6
  //#region src/bin/checks.ts
7
7
  const SIGNAL_EXIT = /* @__PURE__ */ new Map([
package/dist/bin/sync.mjs CHANGED
@@ -9,7 +9,7 @@ import { _ as ciRenovateSyncCallers, a as GITATTRIBUTES_ARTIFACT, b as sharedWor
9
9
  import { i as gitFiles, s as repositoryRoot } from "../files-C0avD1Eo.mjs";
10
10
  import { n as workspaceDirectories, r as workspacePatterns, t as planDocs } from "../docs-compat-CdgBviGf.mjs";
11
11
  import { n as shimInvocation } from "../run-command-BlFRPORx.mjs";
12
- import { a as verifyLayers, c as pnpmLockfiles, d as moveDependencyRanges, f as runPnpm, l as inWorkspace, o as matchingScripts, r as droppedChecksSteps, s as stepsOf, u as installsWithPnpm } from "../checks-DLYDbTCN.mjs";
12
+ import { a as verifyLayers, c as pnpmLockfiles, d as moveDependencyRanges, f as runPnpm, l as inWorkspace, o as matchingScripts, r as droppedChecksSteps, s as stepsOf, u as installsWithPnpm } from "../checks-Crg3yU_o.mjs";
13
13
  import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-B30kar1T.mjs";
14
14
  import { c as typescript } from "../suppressions-BWTxQbDL.mjs";
15
15
  import { t as DEFAULT_SHARED } from "../map-C3j9QGqf.mjs";
@@ -1222,12 +1222,6 @@ const OTHER_LOCKS = [
1222
1222
  "bun.lock",
1223
1223
  "bun.lockb"
1224
1224
  ];
1225
- /** The manifest fields both package managers record as a project's direct dependencies. */
1226
- const DIRECT_FIELDS = [
1227
- "dependencies",
1228
- "devDependencies",
1229
- "optionalDependencies"
1230
- ];
1231
1225
  /** A lockfile or manifest that cannot be read as a version this module knows. */
1232
1226
  var Unreadable = class extends Error {};
1233
1227
  /** Parses a JSON or YAML file whose top level is a mapping; throws `Unreadable` otherwise. */
@@ -1303,8 +1297,10 @@ function installsWithPnpm(root, folder) {
1303
1297
  const PNPM_LOCK = "pnpm-lock.yaml";
1304
1298
  /** Packages one process must load once: every AntelopeJS interface package shares one runtime with its peers. */
1305
1299
  const SINGLETON = /^@antelopejs\/interface-/u;
1306
- /** The fields of a lockfile package entry that point at the copy each dependency resolves to. */
1307
- const PACKAGE_FIELDS = ["dependencies", "optionalDependencies"];
1300
+ /** The fields of an importer or a lockfile package entry whose copies a production install reaches; pnpm records a resolved peer under `dependencies`. */
1301
+ const RUNTIME_FIELDS = ["dependencies", "optionalDependencies"];
1302
+ /** The fields of an importer whose copies only development installs reach. */
1303
+ const DEV_FIELDS = ["devDependencies"];
1308
1304
  /** How to move every importer onto one copy while pnpm keeps every other locked version, which `pnpm dedupe` does not. */
1309
1305
  const REPAIR = " Set the direct specifier that locks the older copy to the newer version, run `pnpm install --lockfile-only`, then restore the specifier.\n";
1310
1306
  /** How a puller that is a manifest of the repository, not a locked package, is named. */
@@ -1332,11 +1328,32 @@ function pull(copies, name, version, by) {
1332
1328
  };
1333
1329
  copies.get(target.name)?.get(target.version)?.add(by);
1334
1330
  }
1335
- function addPullers(copies, node, fields, by) {
1336
- for (const field of fields) {
1331
+ /** The dependencies `fields` of an importer or a lockfile package entry list. */
1332
+ function edges(node, fields) {
1333
+ return fields.flatMap((field) => {
1337
1334
  const entries = mapping(node, field);
1338
- for (const name of keys(entries)) pull(copies, name, scalar(entries, name) ?? scalar(mapping(entries, name), "version"), by);
1335
+ return keys(entries).flatMap((name) => {
1336
+ const version = scalar(entries, name) ?? scalar(mapping(entries, name), "version");
1337
+ return version === void 0 ? [] : [[name, version]];
1338
+ });
1339
+ });
1340
+ }
1341
+ /** A lockfile entry key without the leading `/` of version 6. */
1342
+ const entryKey = (key) => key.replace(/^\//u, "");
1343
+ /** The `name@version`, without peers, of each entry of `resolved` that a walk from `from` through runtime dependencies reaches. */
1344
+ function reached(resolved, from) {
1345
+ const entries = new Map(keys(resolved).map((key) => [entryKey(key), key]));
1346
+ const seen = /* @__PURE__ */ new Set();
1347
+ const queue = [...from];
1348
+ for (const [name, version] of queue) {
1349
+ const direct = `${name}@${version}`;
1350
+ const key = entries.has(direct) ? direct : entryKey(version);
1351
+ const original = entries.get(key);
1352
+ if (original === void 0 || seen.has(key)) continue;
1353
+ seen.add(key);
1354
+ queue.push(...edges(mapping(resolved, original), RUNTIME_FIELDS));
1339
1355
  }
1356
+ return new Set([...seen].map(withoutPeers));
1340
1357
  }
1341
1358
  /** Each document of a lockfile: pnpm 11 writes its config dependencies, installed apart from the project, as a document before the project's. */
1342
1359
  function lockfileDocuments(path) {
@@ -1349,14 +1366,52 @@ function lockfileDocuments(path) {
1349
1366
  return contents;
1350
1367
  });
1351
1368
  }
1352
- function documentCopies(lockfile) {
1353
- const copies = /* @__PURE__ */ new Map();
1369
+ /**
1370
+ * Whether the manifest in `folder` lists `name` under `peerDependencies`: the host loads that dependency at runtime, though
1371
+ * pnpm locks a peer the manifest also lists under `devDependencies` as a dev dependency only. Every name when the manifest
1372
+ * cannot be read, so no copy it might reach is dropped.
1373
+ */
1374
+ function peerOf(folder) {
1375
+ const path = join(folder, "package.json");
1376
+ if (!existsSync(path)) return () => false;
1377
+ try {
1378
+ const peers = new Set(keys(mapping(readMapping(path), "peerDependencies")));
1379
+ return (name) => peers.has(name);
1380
+ } catch (error) {
1381
+ if (error instanceof Unreadable) return () => true;
1382
+ throw error;
1383
+ }
1384
+ }
1385
+ /**
1386
+ * The singleton copies of the lockfile document in `folder`, with their pullers. A copy that devDependencies reach and
1387
+ * runtime dependencies do not never ships, so it and the packages that pull it do not count; a copy no importer reaches
1388
+ * still does.
1389
+ */
1390
+ function documentCopies(lockfile, folder) {
1354
1391
  const packages = mapping(lockfile, "packages");
1355
- for (const parsed of keys(packages).map(packageKey)) if (parsed && SINGLETON.test(parsed.name)) copies.set(parsed.name, (copies.get(parsed.name) ?? /* @__PURE__ */ new Map()).set(parsed.version, /* @__PURE__ */ new Set()));
1356
- const importers = mapping(lockfile, "importers");
1357
- for (const importer of importers ? keys(importers) : ["."]) addPullers(copies, importers ? mapping(importers, importer) : lockfile, DIRECT_FIELDS, `${IMPORTER}"${importer}"`);
1358
1392
  const resolved = mapping(lockfile, "snapshots") ?? packages;
1359
- for (const key of keys(resolved)) addPullers(copies, mapping(resolved, key), PACKAGE_FIELDS, withoutPeers(key.replace(/^\//u, "")));
1393
+ const importers = mapping(lockfile, "importers");
1394
+ const roots = (importers ? keys(importers) : ["."]).map((importer) => {
1395
+ const node = importers ? mapping(importers, importer) : lockfile;
1396
+ const peer = peerOf(join(folder, importer));
1397
+ const dev = edges(node, DEV_FIELDS);
1398
+ return {
1399
+ by: `${IMPORTER}"${importer}"`,
1400
+ node,
1401
+ runtime: [...edges(node, RUNTIME_FIELDS), ...dev.filter(([name]) => peer(name))],
1402
+ dev: dev.filter(([name]) => !peer(name))
1403
+ };
1404
+ });
1405
+ const runtime = reached(resolved, roots.flatMap((root) => root.runtime));
1406
+ const dev = reached(resolved, roots.flatMap((root) => root.dev));
1407
+ const devOnly = (entry) => !runtime.has(entry) && dev.has(entry);
1408
+ const copies = /* @__PURE__ */ new Map();
1409
+ for (const parsed of keys(packages).map(packageKey)) if (parsed && SINGLETON.test(parsed.name) && !devOnly(`${parsed.name}@${parsed.version}`)) copies.set(parsed.name, (copies.get(parsed.name) ?? /* @__PURE__ */ new Map()).set(parsed.version, /* @__PURE__ */ new Set()));
1410
+ for (const { by, node } of roots) for (const [name, version] of edges(node, [...RUNTIME_FIELDS, ...DEV_FIELDS])) pull(copies, name, version, by);
1411
+ for (const key of keys(resolved)) {
1412
+ const by = withoutPeers(entryKey(key));
1413
+ if (!devOnly(by)) for (const [name, version] of edges(mapping(resolved, key), RUNTIME_FIELDS)) pull(copies, name, version, by);
1414
+ }
1360
1415
  return copies;
1361
1416
  }
1362
1417
  /** Whether `other` is a release, not a prerelease, on the minor of `version`. */
@@ -1385,15 +1440,18 @@ function pnpmLockfiles(root) {
1385
1440
  /**
1386
1441
  * Fails when a `pnpm-lock.yaml` of the repository resolves an AntelopeJS interface package, any `@antelopejs/interface-*`,
1387
1442
  * at more than one version: each copy carries its own runtime, so two copies in one process break the contract between
1388
- * modules, or throw on a runtime protocol mismatch. A preview a manifest of the repository pins beside only releases on
1389
- * its minor does not count. Names, for each version, the importers and packages that pull it.
1390
- * Reads the lockfiles only: it spawns no package manager, writes no file and fetches nothing. Returns what failed, empty
1443
+ * modules, or throw on a runtime protocol mismatch. A copy only devDependencies reach does not count, though a
1444
+ * devDependency the manifest also lists under `peerDependencies` reaches its copies at runtime; nor does a preview a
1445
+ * manifest of the repository pins beside only releases on its minor. Names, for each version, the importers that pull it
1446
+ * and the packages that pull it through runtime dependencies.
1447
+ * Reads the lockfiles and the manifests beside them only: it spawns no package manager, writes no file and fetches
1448
+ * nothing. Returns what failed, empty
1391
1449
  * when every interface package resolves once.
1392
1450
  */
1393
1451
  function checkSingletonPackages(root) {
1394
1452
  return pnpmLockfiles(root).map((file) => {
1395
1453
  try {
1396
- return lockfileDocuments(join(root, file)).map((document) => report(file, documentCopies(document))).join("");
1454
+ return lockfileDocuments(join(root, file)).map((document) => report(file, documentCopies(document, join(root, dirname(file))))).join("");
1397
1455
  } catch (error) {
1398
1456
  if (error instanceof Unreadable) return `${file}: could not read it as a lockfile version this check knows.\n`;
1399
1457
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/tooling-configs",
3
- "version": "0.8.1-next.374.g2cfc8a1",
3
+ "version": "0.8.1-next.375.gde7597d",
4
4
  "description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and a dependency range check",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -152,7 +152,7 @@
152
152
  "engines": {
153
153
  "node": ">=22.18.0"
154
154
  },
155
- "gitHead": "2cfc8a1195ab90bd0aaf48488beabdc429776632",
155
+ "gitHead": "de7597d7ba60be1f4a359e707392ce4182df9384",
156
156
  "scripts": {
157
157
  "build": "tsdown",
158
158
  "lint": "oxlint",