@antelopejs/tooling-configs 0.5.3 → 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/README.md CHANGED
@@ -198,7 +198,7 @@ pnpm dlx --package=@antelopejs/tooling-configs antelopejs-sync --init
198
198
  npx --package=@antelopejs/tooling-configs antelopejs-sync --init
199
199
  ```
200
200
 
201
- `--init` adds `node_modules` to `.gitignore` and declares each of `@antelopejs/tooling-configs`, `oxlint`, `oxlint-tsgolint` and `oxfmt` the repository does not declare yet. In a pnpm or npm workspace, it sets each member's declared pack tools to the root's ranges, so the workspace installs one copy of the pack, and moves the `options` of a member's oxlint config, which oxlint accepts only in the root config, to the same flags on the member's `oxlint` scripts. It stops before installing when an option has no command-line flag. It installs with the repository's package manager, runs `antelopejs-sync`, installs again when sync added devDependencies, and formats `package.json` with the installed oxfmt. It takes the full profile only and rejects `--check` and `--profile template`. Install output shows only when the install fails.
201
+ `--init` adds `node_modules` to `.gitignore` and declares each of `@antelopejs/tooling-configs`, `oxlint`, `oxlint-tsgolint` and `oxfmt` the repository does not declare yet. In a pnpm or npm workspace, it sets each member's declared pack tools to the root's ranges, so the workspace installs one copy of the pack. A root `catalog:` spec is copied as written. A member `catalog:` spec is kept when its catalog entry, in `pnpm-workspace.yaml` or Bun's root `package.json`, matches the root's range, and otherwise `--init` names the member and the package and stops before installing. It also moves the `options` of a member's oxlint config, which oxlint accepts only in the root config, to the same flags on the member's `oxlint` scripts. It stops before installing when an option has no command-line flag. It installs with the repository's package manager, runs `antelopejs-sync`, installs again when sync added devDependencies, and formats `package.json` with the installed oxfmt. It takes the full profile only and rejects `--check` and `--profile template`. Install output shows only when the install fails.
202
202
 
203
203
  It then sets `delete_branch_on_merge` through `gh` when it can, even when an earlier step failed. When `gh` is missing, unauthenticated or refused, `--init` prints the `gh api -X PATCH repos/{owner}/{repo} -F delete_branch_on_merge=true` command to run and exits 1. After any failure, fix what it printed and rerun `antelopejs-sync --init`. Commit and push to the default branch afterwards, so the first run reports `ci / checks`.
204
204
 
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { o as packageManager, s as parseManifest } from "../package-DiaBP7bI.mjs";
2
+ import { o as packageManager, s as parseManifest } from "../package-CORwvwTw.mjs";
3
3
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
4
  import { c as repositoryRoot, l as resolveRevision } from "../files-DJ0TeaTU.mjs";
5
- import { a as DIRECTORY_LINK, c as revisionCounts, d as createAddedPolicy, f as describeAllowance, i as stampProof, l as workspaceManifests, m as recordVerdict, o as compareRevisions, p as fillStars, u as allowedByGlob } from "../proof-stamp-BPIdT5ik.mjs";
6
- import { c as packagesAt, i as isTestSource, l as unpublishedAt, o as loadTypeScript, r as isExportPath, s as outputRoot, t as emitPackage } from "../typescript-DJzdex32.mjs";
5
+ import { a as DIRECTORY_LINK, c as revisionCounts, d as createAddedPolicy, f as describeAllowance, i as stampProof, l as workspaceManifests, m as recordVerdict, o as compareRevisions, p as fillStars, u as allowedByGlob } from "../proof-stamp-C56iYgHa.mjs";
6
+ import { c as packagesAt, i as isTestSource, l as unpublishedAt, o as loadTypeScript, r as isExportPath, s as outputRoot, t as emitPackage } from "../typescript-Cw1JH8mk.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import { copyFileSync, cpSync, existsSync, globSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, parse, posix, relative, resolve, sep } from "node:path";
@@ -2,7 +2,7 @@
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
3
  import { c as repositoryRoot, l as resolveRevision } from "../files-DJ0TeaTU.mjs";
4
4
  import { t as lintDiagnostics } from "../oxlint-BbpTFFmf.mjs";
5
- import { n as proofDigest, r as proofLines, s as revisionCountRows, t as parseProofStamp } from "../proof-stamp-BPIdT5ik.mjs";
5
+ import { n as proofDigest, r as proofLines, s as revisionCountRows, t as parseProofStamp } from "../proof-stamp-C56iYgHa.mjs";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { spawnSync } from "node:child_process";
8
8
  import { parseArgs } from "node:util";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
3
3
  import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
- import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-BFGuy1KI.mjs";
4
+ import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-CyMCnYb4.mjs";
5
5
  import { parseArgs } from "node:util";
6
6
  //#region src/bin/checks.ts
7
7
  const SIGNAL_EXIT = /* @__PURE__ */ new Map([
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
3
  import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
- import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-BPIdT5ik.mjs";
5
- import { a as listsNoFiles, c as packagesAt, n as extendedConfigs, t as emitPackage } from "../typescript-DJzdex32.mjs";
4
+ import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-C56iYgHa.mjs";
5
+ import { a as listsNoFiles, c as packagesAt, n as extendedConfigs, t as emitPackage } from "../typescript-Cw1JH8mk.mjs";
6
6
  import { copyFileSync, existsSync, mkdirSync } from "node:fs";
7
7
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
8
8
  //#region src/guardrails/comment-proof.ts
@@ -3,7 +3,7 @@ import { c as parseCeilings, l as readCeilings, t as CEILINGS_FILE } from "../ce
3
3
  import { n as renamedPaths } from "../renames-L2owF5GD.mjs";
4
4
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
5
5
  import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-DJ0TeaTU.mjs";
6
- import { n as ratchet, r as withPreviousTree } from "../ratchet-BZvlFCWL.mjs";
6
+ import { n as ratchet, r as withPreviousTree } from "../ratchet-Al0XZtOz.mjs";
7
7
  import { t as lintDiagnostics } from "../oxlint-BbpTFFmf.mjs";
8
8
  import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-DgYdu6JK.mjs";
9
9
  import { n as suppressionBase } from "../suppression-base-DZgUDXiI.mjs";
package/dist/bin/sync.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as formatCeilings, l as readCeilings, s as isRetired, t as CEILINGS_FILE } from "../ceilings-B7KayYIG.mjs";
3
+ import { a as managedPackage, c as repositoryTools, d as toolingVersions, f as usesCaptures, l as serializeManifest, n as bootstrapDependencies, o as packageManager, p as usesNuxt, r as bootstrappedManifest, s as parseManifest, t as addedDevDependencies, u as templatePackage } from "../package-CORwvwTw.mjs";
3
4
  import { t as admits } from "../semver-BDxeEcP_.mjs";
4
- import { a as managedPackage, c as repositoryTools, d as toolingVersions, f as usesNuxt, l as serializeManifest, n as bootstrapDependencies, o as packageManager, r as bootstrappedManifest, s as parseManifest, t as addedDevDependencies, u as templatePackage } from "../package-DiaBP7bI.mjs";
5
- import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-C6cfOd2H.mjs";
5
+ import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-DaatyItc.mjs";
6
6
  import { a as VERIFY_KINDS, c as isVerifyKind, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-igPpEDpS.mjs";
7
7
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
8
8
  import { c as CI_CONTEXT, f as ciWorkflow, i as hasChecksWorkflow, n as ciNodeCallers, p as placeholderTestScript, r as ciRenovateSyncCallers, s as renovateArtifacts, t as MISSING_CHECKS_WORKFLOW, u as CI_PATH } from "../workflow-CPcNc8KL.mjs";
9
9
  import { a as gitFiles, c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
10
- import { i as recordedRelease, t as measureBaseline } from "../ratchet-BZvlFCWL.mjs";
11
- import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps, o as planDocs, s as workspaceDirectories } from "../checks-BFGuy1KI.mjs";
10
+ import { a as stepsOf, c as workspacePatterns, i as matchingScripts, n as droppedChecksSteps, o as planDocs, s as workspaceDirectories } from "../checks-CyMCnYb4.mjs";
11
+ import { i as recordedRelease, t as measureBaseline } from "../ratchet-Al0XZtOz.mjs";
12
12
  import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-DgYdu6JK.mjs";
13
13
  import { u as typescript } from "../suppressions-CQTcKCi1.mjs";
14
14
  import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
@@ -16,7 +16,7 @@ import { createRequire } from "node:module";
16
16
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
17
17
  import { basename, dirname, join, posix, resolve } from "node:path";
18
18
  import { execFileSync, spawnSync } from "node:child_process";
19
- import { isMap, isScalar, parseDocument } from "yaml";
19
+ import { isAlias, isMap, isNode, isScalar, isSeq, parseDocument, stringify } from "yaml";
20
20
  import ts from "typescript";
21
21
  import { parseArgs } from "node:util";
22
22
  //#region src/guardrails/docs-typescript.ts
@@ -264,37 +264,47 @@ function readsSettings(manifest) {
264
264
  return pinned === void 0 || admits(">=10.5.0", pinned);
265
265
  }
266
266
  /**
267
- * `current` with `allowBuilds.lefthook` set to `false` unless the repository already decides it.
268
- * pnpm 11 fails an install on a dependency build it was not told about, and the synced `prepare` script runs `lefthook install` itself.
267
+ * The dependency builds sync declares and pnpm 11 must be told to skip.
268
+ * The synced `prepare` script runs `lefthook install` itself, and `MongoMemoryServer.create()` downloads the mongod that the capture peer's postinstall would fetch.
269
269
  */
270
- function withLefthookDecided(current = "") {
270
+ function skippedBuilds(captures) {
271
+ return captures ? ["lefthook", "mongodb-memory-server"] : ["lefthook"];
272
+ }
273
+ /**
274
+ * `current` with `allowBuilds.<name>` set to `false` for each of `names` the repository does not already decide.
275
+ * pnpm 11 fails an install on a dependency build it was not told about.
276
+ */
277
+ function withBuildsDecided(names, current = "") {
271
278
  const document = parseDocument(current);
272
279
  if (document.errors.length) throw new Error(`${PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
273
280
  if (document.toJS() == null) {
274
281
  const kept = current.trimStart();
275
- return `${kept}${kept === "" || kept.endsWith("\n") ? "" : "\n"}allowBuilds:\n lefthook: false\n`;
282
+ const lines = names.map((name) => ` ${name}: false\n`).join("");
283
+ return `${kept}${kept === "" || kept.endsWith("\n") ? "" : "\n"}allowBuilds:\n${lines}`;
276
284
  }
277
285
  if (!isMap(document.contents)) throw new Error(`${PATH} must contain a YAML mapping.`);
278
286
  if (document.get("allowBuilds") == null) document.set("allowBuilds", document.createNode({}));
279
287
  const builds = document.get("allowBuilds");
280
288
  if (!isMap(builds)) throw new Error(`${PATH}: allowBuilds must be a mapping.`);
281
- if (builds.get("lefthook") != null) return current;
289
+ const undecided = names.filter((name) => builds.get(name) == null);
290
+ if (!undecided.length) return current;
282
291
  document.contents.flow = false;
283
292
  builds.flow = false;
284
- builds.set("lefthook", false);
293
+ for (const name of undecided) builds.set(name, false);
285
294
  return document.toString({
286
295
  lineWidth: 0,
287
296
  flowCollectionPadding: false
288
297
  });
289
298
  }
290
- /** The `pnpm-workspace.yaml` a full-profile pnpm repository needs so pnpm 11 and later install lefthook without `ERR_PNPM_IGNORED_BUILDS`. */
299
+ /** The `pnpm-workspace.yaml` a full-profile pnpm repository needs so pnpm 11 and later install the builds sync declares without `ERR_PNPM_IGNORED_BUILDS`. */
291
300
  function pnpmWorkspaceArtifacts(root, manifest, managed) {
292
301
  if (!managed || packageManager(manifest) !== "pnpm") return [];
293
302
  const file = join(root, PATH);
294
303
  const current = existsSync(file) ? readFileSync(file, "utf8") : void 0;
295
304
  if (current === void 0 && !readsSettings(manifest)) return [];
305
+ const names = skippedBuilds(usesCaptures(root));
296
306
  try {
297
- const content = withLefthookDecided(current);
307
+ const content = withBuildsDecided(names, current);
298
308
  return [content === current ? {
299
309
  kind: "unchanged",
300
310
  path: PATH
@@ -308,7 +318,7 @@ function pnpmWorkspaceArtifacts(root, manifest, managed) {
308
318
  return [{
309
319
  kind: "error",
310
320
  path: PATH,
311
- message: `${error instanceof Error ? error.message : String(error)} Add \`allowBuilds: { lefthook: false }\` to it, then rerun antelopejs-sync.`
321
+ message: `${error instanceof Error ? error.message : String(error)} Add \`allowBuilds: { ${names.map((name) => `${name}: false`).join(", ")} }\` to it, then rerun antelopejs-sync.`
312
322
  }];
313
323
  }
314
324
  }
@@ -1478,7 +1488,7 @@ function repositoryContext(root, current, profile, verificationSkill) {
1478
1488
  glossary: ["GLOSSARY.md", "docs/GLOSSARY.md"].find((file) => existsSync(join(root, file))),
1479
1489
  docs: profile === "full" && current.has("package.json") ? planDocs(root, manager) : void 0,
1480
1490
  placeholderTests: current.has("package.json") && placeholderTestScript(manifest.scripts?.test),
1481
- captures: existsSync(join(root, "docs/captures.ts"))
1491
+ captures: usesCaptures(root)
1482
1492
  };
1483
1493
  }
1484
1494
  function writeArtifacts(root, artifacts) {
@@ -1709,9 +1719,72 @@ const ALIGNED_TOOLS = [
1709
1719
  "knip",
1710
1720
  "lefthook"
1711
1721
  ];
1712
- /** The range each pack tool resolves to at the root: the one it declares, else the one `--init` and sync add. A protocol or path spec stays root-only, since a member would resolve it elsewhere. */
1713
- function rootRanges(root, versions) {
1714
- const ranges = /* @__PURE__ */ new Map([
1722
+ const CATALOG = "catalog:";
1723
+ /** The scalar keys of the mapping `node` holds, each with its value node, following YAML aliases and `<<` merge keys; a key the mapping sets itself comes after the merged one it overrides. */
1724
+ function mapPairs(document, node, seen = /* @__PURE__ */ new Set()) {
1725
+ const map = isAlias(node) ? node.resolve(document) : node;
1726
+ if (!isMap(map) || seen.has(map)) return [];
1727
+ const within = /* @__PURE__ */ new Set([...seen, map]);
1728
+ const merged = [];
1729
+ const own = [];
1730
+ for (const { key, value } of map.items) {
1731
+ if (!isScalar(key)) continue;
1732
+ if (key.value !== "<<") {
1733
+ own.push([String(key.value), isAlias(value) ? value.resolve(document) : value]);
1734
+ continue;
1735
+ }
1736
+ const merge = isAlias(value) ? value.resolve(document) : value;
1737
+ const sources = isSeq(merge) ? [...merge.items].reverse() : [merge];
1738
+ for (const source of sources) if (isNode(source)) merged.push(...mapPairs(document, source, within));
1739
+ }
1740
+ return [...merged, ...own];
1741
+ }
1742
+ /** The scalar keys of the mapping at `path`, each with its value node. */
1743
+ function mapEntries(document, path) {
1744
+ let pairs = mapPairs(document, document.contents);
1745
+ for (const key of path) {
1746
+ const value = new Map(pairs).get(key);
1747
+ pairs = isNode(value) ? mapPairs(document, value) : [];
1748
+ }
1749
+ return pairs;
1750
+ }
1751
+ /** The package names of the catalog at `path`, each with its range. */
1752
+ function catalogEntries(document, path) {
1753
+ return mapEntries(document, path).flatMap(([name, value]) => isScalar(value) ? [[name, String(value.value)]] : []);
1754
+ }
1755
+ function catalogSource(root) {
1756
+ const pnpm = join(root, "pnpm-workspace.yaml");
1757
+ if (existsSync(pnpm)) return {
1758
+ document: parseDocument(readFileSync(pnpm, "utf8")),
1759
+ prefixes: [[]]
1760
+ };
1761
+ return {
1762
+ document: parseDocument(readFileSync(join(root, "package.json"), "utf8")),
1763
+ prefixes: [["workspaces"], []]
1764
+ };
1765
+ }
1766
+ function workspaceCatalogs(root) {
1767
+ const { document, prefixes } = catalogSource(root);
1768
+ const catalogs = /* @__PURE__ */ new Map();
1769
+ const add = (name, path) => catalogs.set(name, new Map([...catalogs.get(name) ?? [], ...catalogEntries(document, path)]));
1770
+ for (const prefix of prefixes) {
1771
+ add("default", [...prefix, "catalog"]);
1772
+ for (const [name] of mapEntries(document, [...prefix, "catalogs"])) add(name, [
1773
+ ...prefix,
1774
+ "catalogs",
1775
+ name
1776
+ ]);
1777
+ }
1778
+ return catalogs;
1779
+ }
1780
+ /** The range `spec` installs `name` at: `spec` itself, its catalog entry for a `catalog:` spec, or undefined for another protocol or a path. */
1781
+ function resolvedRange(catalogs, name, spec) {
1782
+ if (spec.startsWith(CATALOG)) return catalogs.get(spec.slice(8) || "default")?.get(name);
1783
+ return /[:/]/.test(spec) ? void 0 : spec;
1784
+ }
1785
+ /** The spec of each pack tool at the root: the one it declares, else the one `--init` and sync add. A `catalog:` spec resolves the same in every member; another protocol or a path stays root-only, since a member would resolve it elsewhere. */
1786
+ function rootSpecs(root, versions, catalogs) {
1787
+ const declared = /* @__PURE__ */ new Map([
1715
1788
  ["@antelopejs/tooling-configs", `^${versions.pack}`],
1716
1789
  ["oxlint", versions.oxlint],
1717
1790
  ["oxlint-tsgolint", versions.tsgolint],
@@ -1719,27 +1792,40 @@ function rootRanges(root, versions) {
1719
1792
  ["knip", versions.knip],
1720
1793
  ["lefthook", versions.lefthook]
1721
1794
  ]);
1722
- for (const field of [root.dependencies, root.devDependencies]) for (const [name, range] of Object.entries(field ?? {})) if (ranges.has(name)) ranges.set(name, range);
1723
- for (const [name, range] of ranges) if (/[:/]/.test(range)) ranges.delete(name);
1724
- return ranges;
1795
+ for (const field of [root.dependencies, root.devDependencies]) for (const [name, spec] of Object.entries(field ?? {})) if (declared.has(name)) declared.set(name, spec);
1796
+ const specs = /* @__PURE__ */ new Map();
1797
+ for (const [name, spec] of declared) {
1798
+ const range = resolvedRange(catalogs, name, spec);
1799
+ if (range !== void 0) specs.set(name, {
1800
+ spec,
1801
+ range
1802
+ });
1803
+ }
1804
+ return specs;
1725
1805
  }
1726
- /** Sets each pack tool the member declares to the root's range, so the workspace installs one copy of the pack; returns whether it changed one. */
1727
- function alignRanges(member, ranges) {
1806
+ /** Sets each pack tool the member declares as a plain range to the root's spec, so the workspace installs one copy of the pack, and names each member `catalog:` spec that resolves to another range; returns whether it changed one. */
1807
+ function alignRanges(member, manifestPath, specs, catalogs, failures) {
1728
1808
  let changed = false;
1729
1809
  for (const field of [member.dependencies, member.devDependencies]) for (const name of ALIGNED_TOOLS) {
1730
1810
  const declared = field && Object.hasOwn(field, name) ? field[name] : void 0;
1731
- const wanted = ranges.get(name);
1732
- if (!field || declared === void 0 || wanted === void 0 || declared === wanted || declared.includes(":")) continue;
1733
- field[name] = wanted;
1811
+ const wanted = specs.get(name);
1812
+ if (!field || declared === void 0 || wanted === void 0 || declared === wanted.spec) continue;
1813
+ if (declared.startsWith(CATALOG)) {
1814
+ const range = resolvedRange(catalogs, name, declared);
1815
+ if (range !== void 0 && range !== wanted.range) failures.push(`${manifestPath} declares ${name} as ${declared}, which resolves to ${range}, while the root resolves it to ${wanted.range}, so the workspace would install two copies. Give both the same catalog entry or range, then rerun antelopejs-sync --init.`);
1816
+ continue;
1817
+ }
1818
+ if (declared.includes(":")) continue;
1819
+ field[name] = wanted.spec;
1734
1820
  changed = true;
1735
1821
  }
1736
1822
  return changed;
1737
1823
  }
1738
- function alignMember(root, directory, ranges, result) {
1824
+ function alignMember(root, directory, workspace, result) {
1739
1825
  const manifestPath = join(root, directory, "package.json");
1740
1826
  const current = readFileSync(manifestPath, "utf8");
1741
1827
  const member = parseManifest(current);
1742
- let changed = alignRanges(member, ranges);
1828
+ let changed = alignRanges(member, `${directory}/package.json`, workspace.specs, workspace.catalogs, result.failures);
1743
1829
  for (const name of LINT_CONFIGS) {
1744
1830
  const relative = `${directory}/${name}`;
1745
1831
  const path = join(root, relative);
@@ -1767,12 +1853,16 @@ function alignMember(root, directory, ranges, result) {
1767
1853
  * on the member's `oxlint` scripts.
1768
1854
  */
1769
1855
  function alignWorkspaceMembers(root, manifest, versions) {
1770
- const ranges = rootRanges(manifest, versions);
1856
+ const catalogs = workspaceCatalogs(root);
1857
+ const workspace = {
1858
+ specs: rootSpecs(manifest, versions, catalogs),
1859
+ catalogs
1860
+ };
1771
1861
  const result = {
1772
1862
  paths: [],
1773
1863
  failures: []
1774
1864
  };
1775
- for (const directory of workspaceDirectories(root)) alignMember(root, directory, ranges, result);
1865
+ for (const directory of workspaceDirectories(root)) alignMember(root, directory, workspace, result);
1776
1866
  return result;
1777
1867
  }
1778
1868
  //#endregion
@@ -1833,10 +1923,10 @@ function ensureBranchCleanup(root) {
1833
1923
  reason: failureText(write)
1834
1924
  } : { kind: "enabled" };
1835
1925
  }
1836
- /** Runs `manager` with `args` quietly; returns its output only when it failed. */
1837
- function run(root, manager, args) {
1838
- const command = [manager, ...args].join(" ");
1839
- const result = spawnSync(manager, args, {
1926
+ /** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
1927
+ function run(root, args) {
1928
+ const command = ["pnpm", ...args].join(" ");
1929
+ const result = spawnSync("pnpm", args, {
1840
1930
  cwd: root,
1841
1931
  encoding: "utf8"
1842
1932
  });
@@ -1844,8 +1934,8 @@ function run(root, manager, args) {
1844
1934
  if (result.status === 0) return void 0;
1845
1935
  return `${command} failed (exit ${result.status}).\n${result.stdout}${result.stderr}`.trimEnd();
1846
1936
  }
1847
- function install(root, manager) {
1848
- return run(root, manager, ["install"]);
1937
+ function install(root) {
1938
+ return run(root, ["install"]);
1849
1939
  }
1850
1940
  function resolveOxfmt(root) {
1851
1941
  const require = createRequire(join(root, "package.json"));
@@ -1899,19 +1989,77 @@ const NODE_TSCONFIG = `{
1899
1989
  }
1900
1990
  }
1901
1991
  `;
1902
- const NPM_LOCKFILE = "package-lock.json";
1992
+ /**
1993
+ * The other package managers' install state `--init` deletes once pnpm's lockfile replaces it, and whether
1994
+ * `pnpm import` reads the versions it resolved. Yarn's Plug'n'Play loaders go too: left in place, Node resolves every
1995
+ * package through them and misses what pnpm installed.
1996
+ */
1997
+ const FOREIGN_INSTALL_FILES = [
1998
+ {
1999
+ file: "package-lock.json",
2000
+ importable: true
2001
+ },
2002
+ {
2003
+ file: "npm-shrinkwrap.json",
2004
+ importable: true
2005
+ },
2006
+ {
2007
+ file: "yarn.lock",
2008
+ importable: true
2009
+ },
2010
+ {
2011
+ file: ".pnp.cjs",
2012
+ importable: false
2013
+ },
2014
+ {
2015
+ file: ".pnp.loader.mjs",
2016
+ importable: false
2017
+ },
2018
+ {
2019
+ file: "bun.lock",
2020
+ importable: false
2021
+ },
2022
+ {
2023
+ file: "bun.lockb",
2024
+ importable: false
2025
+ }
2026
+ ];
2027
+ const LINK_WORKSPACE_PACKAGES = "link-workspace-packages=true";
2028
+ /**
2029
+ * Lists package.json `workspaces` in a new `pnpm-workspace.yaml`, since pnpm ignores the field, and, when `converting`
2030
+ * another manager's install state, links members declared by version as npm, yarn and bun do, so `pnpm import` locks
2031
+ * every member. `.npmrc` carries the link setting because the pinned pnpm reads no settings from `pnpm-workspace.yaml`
2032
+ * when importing, and an explicit setting there is kept. Returns the files it wrote.
2033
+ */
2034
+ function ensurePnpmWorkspace(root, converting) {
2035
+ const packages = workspacePatterns(root);
2036
+ if (!packages.length) return [];
2037
+ const written = [];
2038
+ const workspace = join(root, "pnpm-workspace.yaml");
2039
+ if (!existsSync(workspace)) {
2040
+ writeFileSync(workspace, stringify({ packages }));
2041
+ written.push("pnpm-workspace.yaml");
2042
+ }
2043
+ const npmrc = join(root, ".npmrc");
2044
+ const current = existsSync(npmrc) ? readFileSync(npmrc, "utf8") : "";
2045
+ if (!converting || /^\s*link-workspace-packages\s*=/m.test(current)) return written;
2046
+ const separator = current === "" || current.endsWith("\n") ? "" : "\n";
2047
+ writeFileSync(npmrc, `${current}${separator}${LINK_WORKSPACE_PACKAGES}\n`);
2048
+ return [...written, ".npmrc"];
2049
+ }
1903
2050
  /**
1904
2051
  * The file steps before the first install: `node_modules` ignored, the pnpm version the pack's CI runs pinned when
1905
- * `packageManager` is unset, the bootstrap devDependencies, a tsconfig for a Node repository without one or its own
1906
- * `typecheck`, the pack's oxfmt config when there is none, each workspace member on the root's tool ranges with its
1907
- * oxlint `options` moved to flags, and npm's lockfile replaced by a pnpm lockfile holding the versions it resolved.
2052
+ * `packageManager` names no pnpm, the bootstrap devDependencies, a tsconfig for a Node repository without one or its
2053
+ * own `typecheck`, the pack's oxfmt config when there is none, each workspace member on the root's tool ranges with
2054
+ * its oxlint `options` moved to flags, package.json `workspaces` listed for pnpm, and the other managers' lockfiles
2055
+ * deleted once `pnpm import` carried the versions npm's or yarn's resolved into a pnpm lockfile.
1908
2056
  */
1909
2057
  function bootstrap(root) {
1910
2058
  const path = join(root, "package.json");
1911
2059
  if (!existsSync(path)) throw new Error("package.json is missing. antelopejs-sync --init needs a repository that already has one.");
1912
2060
  const current = readFileSync(path, "utf8");
1913
2061
  const manifest = parseManifest(current);
1914
- const manager = packageManager(manifest);
2062
+ packageManager(manifest);
1915
2063
  const versions = toolingVersions();
1916
2064
  const paths = [];
1917
2065
  if (ensureGitignore(root)) paths.push(".gitignore");
@@ -1933,25 +2081,23 @@ function bootstrap(root) {
1933
2081
  const members = alignWorkspaceMembers(root, manifest, versions);
1934
2082
  paths.push(...members.paths);
1935
2083
  if (members.failures.length) return {
1936
- manager,
1937
2084
  paths,
1938
2085
  removed: [],
1939
2086
  failure: members.failures.join("\n")
1940
2087
  };
1941
- const npmLock = manager === "pnpm" && existsSync(join(root, NPM_LOCKFILE));
1942
- const imported = npmLock && !existsSync(join(root, "pnpm-lock.yaml")) ? run(root, manager, ["import"]) : void 0;
2088
+ const foreign = FOREIGN_INSTALL_FILES.filter(({ file }) => existsSync(join(root, file)));
2089
+ paths.push(...ensurePnpmWorkspace(root, foreign.length > 0));
2090
+ const imported = foreign.some(({ importable }) => importable) && !existsSync(join(root, "pnpm-lock.yaml")) ? run(root, ["import"]) : void 0;
1943
2091
  if (imported !== void 0) return {
1944
- manager,
1945
2092
  paths,
1946
2093
  removed: [],
1947
2094
  failure: imported
1948
2095
  };
1949
- if (npmLock) unlinkSync(join(root, NPM_LOCKFILE));
2096
+ for (const { file } of foreign) unlinkSync(join(root, file));
1950
2097
  return {
1951
- manager,
1952
2098
  paths,
1953
- removed: npmLock ? [NPM_LOCKFILE] : [],
1954
- failure: install(root, manager)
2099
+ removed: foreign.map(({ file }) => file),
2100
+ failure: install(root)
1955
2101
  };
1956
2102
  }
1957
2103
  /**
@@ -1961,7 +2107,7 @@ function bootstrap(root) {
1961
2107
  * did. Every step is idempotent, so a second run changes nothing.
1962
2108
  */
1963
2109
  function initRepository(root, options = {}) {
1964
- const { manager, paths, removed, failure: installed } = bootstrap(root);
2110
+ const { paths, removed, failure: installed } = bootstrap(root);
1965
2111
  const format = () => {
1966
2112
  const formatted = formatRepository(root);
1967
2113
  for (const file of formatted.rewritten) if (!paths.includes(file)) paths.push(file);
@@ -1982,7 +2128,7 @@ function initRepository(root, options = {}) {
1982
2128
  });
1983
2129
  let failure;
1984
2130
  if (!sync.errors.length) {
1985
- failure = sync.dependenciesAdded ? install(root, manager) : void 0;
2131
+ failure = sync.dependenciesAdded ? install(root) : void 0;
1986
2132
  failure ??= format();
1987
2133
  }
1988
2134
  return {