rolldown-pnpm-config 3.2.1 → 4.1.0

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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/catalogs.js +32 -15
  3. package/cli/commands/export.js +8 -3
  4. package/cli/commands/preview.js +10 -7
  5. package/cli/commands/sync.js +140 -70
  6. package/cli/commands/upgrade.js +348 -138
  7. package/cli/discover.js +134 -28
  8. package/cli/drift.js +2 -2
  9. package/cli/edits.js +8 -17
  10. package/cli/effective.js +132 -4
  11. package/cli/interop.js +35 -16
  12. package/cli/local-merge.js +4 -1
  13. package/cli/peer-range.js +21 -5
  14. package/cli/plan.js +9 -4
  15. package/cli/preview-views.js +3 -1
  16. package/cli/release-age.js +2 -1
  17. package/cli/respell.js +86 -0
  18. package/cli/select-file.js +5 -2
  19. package/cli/summary.js +44 -10
  20. package/cli/sync/commit-message.js +4 -3
  21. package/cli/sync/config.js +60 -24
  22. package/cli/sync/local-gate.js +19 -9
  23. package/cli/sync/membership.js +93 -31
  24. package/cli/sync/ripples.js +4 -4
  25. package/cli/sync/running-list.js +9 -5
  26. package/cli/ui/walk-screen.js +66 -20
  27. package/cli/validate.js +1 -1
  28. package/cli/version.js +1 -1
  29. package/cli/walk-plan.js +17 -10
  30. package/cli/walk-reducer.js +99 -19
  31. package/cli/workspace-overlay.js +5 -0
  32. package/cli/workspace-resolve.js +17 -1
  33. package/index.d.ts +176 -127
  34. package/package.json +6 -6
  35. package/plugin/allowed-versions.js +3 -3
  36. package/plugin/families.js +185 -0
  37. package/plugin/freeze.js +137 -32
  38. package/plugin/second-forms.js +155 -0
  39. package/plugin/synced-catalogs.js +32 -0
  40. package/registry.js +13 -1
  41. package/skills/rolldown-pnpm-config/SKILL.md +13 -3
  42. package/skills/rolldown-pnpm-config/references/catalogs.md +127 -14
  43. package/skills/rolldown-pnpm-config/references/options.md +131 -47
  44. package/skills/rolldown-pnpm-config/references/sync.md +32 -21
  45. package/skills/rolldown-pnpm-config/references/wiring.md +12 -8
  46. package/plugin/overrides-from-catalogs.js +0 -151
package/README.md CHANGED
@@ -80,7 +80,7 @@ npx rolldown-pnpm-config upgrade
80
80
  # Applied <n> changes.
81
81
  ```
82
82
 
83
- The command shows an interactive table by default — every catalog package at once, one row per package, `●`/`○` bubbles, modeled on `pnpm up -i`. `--yes` takes the latest in-range version for every package without prompting and fails hard on any warning or unresolvable package name; `--dry-run` runs the identical table and skips only the write; `--catalog <name>` scopes every mode — the table, `--preview`, `--check`, `--yes` and `--dry-run` — to one catalog, and fails on a name the config does not declare. Pass `--preview` for a non-interactive projection of what an upgrade would do, with `--full` to show up-to-date entries too. The output is colorized in a supporting terminal. For packages that declare a `strategy`, the command also resyncs their materialized peer range, preserving any prerelease identifier rather than rebuilding it from parsed version parts. See [upgrading catalogs](https://github.com/spencerbeggs/rolldown-pnpm-config/blob/main/docs/05-upgrading-catalogs.md) for the full surface.
83
+ The command shows an interactive table by default — every catalog package at once, one row per package, `●`/`○` bubbles, modeled on `pnpm up -i`. `--yes` takes the latest in-range version for every npm entry without prompting and fails hard on any warning or unresolvable package name; workspace entries (`source: "workspace"`) are `rolldown-pnpm-config sync`'s and show read-only, and the members of a locked catalog family move only under `--family <name>`; `--dry-run` runs the identical table and skips only the write; `--catalog <name>` scopes every mode — the table, `--preview`, `--check`, `--yes` and `--dry-run` — to one catalog, and fails on a name the config does not declare. Pass `--preview` for a non-interactive projection of what an upgrade would do, with `--full` to show up-to-date entries too. The output is colorized in a supporting terminal. For entries whose peer is `{ value, strategy }`, the command also re-derives the peer value, preserving any prerelease identifier rather than rebuilding it from parsed version parts. See [upgrading catalogs](https://github.com/spencerbeggs/rolldown-pnpm-config/blob/main/docs/05-upgrading-catalogs.md) for the full surface.
84
84
 
85
85
  ## Exporting to pnpm-workspace.yaml
86
86
 
package/catalogs.js CHANGED
@@ -3,11 +3,27 @@ import { Result } from "effect";
3
3
 
4
4
  // src/catalogs.ts
5
5
  /**
6
- * The install range of a catalog spec (bare string or `{ range }` object).
6
+ * The dependency specifier of a catalog spec (bare string or `{ dependency }` object).
7
7
  *
8
8
  * @internal
9
9
  */
10
- const rangeOf = (spec) => typeof spec === "string" ? spec : spec.range;
10
+ const dependencyOf = (spec) => typeof spec === "string" ? spec : spec.dependency;
11
+ /**
12
+ * The peer of a catalog spec as `{ value, strategy }`, `strategy` absent for
13
+ * a hand-set string peer, or `undefined` when the entry has no peer.
14
+ *
15
+ * @internal
16
+ */
17
+ function peerOf(spec) {
18
+ if (typeof spec === "string" || spec.peer === void 0) return void 0;
19
+ return typeof spec.peer === "string" ? { value: spec.peer } : spec.peer;
20
+ }
21
+ /**
22
+ * Where a catalog spec's next dependency comes from: its `source`, or `"npm"`.
23
+ *
24
+ * @internal
25
+ */
26
+ const sourceOf = (spec) => typeof spec === "string" ? "npm" : spec.source ?? "npm";
11
27
  /**
12
28
  * Matches a range the `upgrade` CLI discovers and rewrites: a simple operator
13
29
  * (`^`, `~` or none) on a version, partials like `^1.2` and `1.x` included.
@@ -33,30 +49,30 @@ function singleVersionOf(range) {
33
49
  }
34
50
  /** The `<name>:exact` value of one entry, `undefined` to leave it out; throws on an entry with no single version. */
35
51
  function exactEntry(catalog, pkg, spec) {
36
- const range = rangeOf(spec);
52
+ const range = dependencyOf(spec);
37
53
  const derived = singleVersionOf(range);
38
54
  const explicit = typeof spec === "object" ? spec.exact : void 0;
39
55
  if (explicit === false) return void 0;
40
56
  const rewritable = REWRITABLE_RANGE_RE.test(range);
41
57
  if (explicit !== void 0) {
42
58
  if (derived !== null) throw new Error(`catalogs: "${pkg}" in catalog "${catalog}" derives its exact version ${derived} from "${range}"; remove its exact value, which upgrade would leave stale`);
43
- if (rewritable) throw new Error(`catalogs: "${pkg}" in catalog "${catalog}" has range "${range}", which upgrade rewrites; an exact value would go stale, so write the range as a full version, or set exact: false`);
59
+ if (rewritable) throw new Error(`catalogs: "${pkg}" in catalog "${catalog}" has dependency "${range}", which upgrade rewrites; an exact value would go stale, so write the dependency as a full version, or set exact: false`);
44
60
  const parsed = Result.getOrNull(VersionSpecifier.parseResult(explicit));
45
61
  if (parsed === null || parsed.operator !== "") throw new Error(`catalogs: exact value "${explicit}" for "${pkg}" in catalog "${catalog}" is not a plain version`);
46
62
  return explicit;
47
63
  }
48
- if (derived === null && rewritable) throw new Error(`catalogs: catalog "${catalog}" sets exact: true, but "${pkg}" has range "${range}", which names no single version; write the range as a full version, or set exact: false to leave it out`);
49
- if (derived === null) throw new Error(`catalogs: catalog "${catalog}" sets exact: true, but "${pkg}" has range "${range}", which names no single version; set exact to a version, or exact: false to leave it out`);
64
+ if (derived === null && rewritable) throw new Error(`catalogs: catalog "${catalog}" sets exact: true, but "${pkg}" has dependency "${range}", which names no single version; write the dependency as a full version, or set exact: false to leave it out`);
65
+ if (derived === null) throw new Error(`catalogs: catalog "${catalog}" sets exact: true, but "${pkg}" has dependency "${range}", which names no single version; set exact to a version, or exact: false to leave it out`);
50
66
  return derived;
51
67
  }
52
68
  /**
53
- * Normalize declarative catalog input into the resolved `{ catalog → pkg → range }`
69
+ * Normalize declarative catalog input into the resolved `{ catalog → pkg → specifier }`
54
70
  * map consumed by the runtime. Pure: the base catalog uses each package's
55
- * `range` (or bare string); a peers catalog is emitted only for packages
56
- * carrying a materialized `peer`, using that value verbatim, under the
57
- * `<name>:peers` colon-delimited name. A declaration with `exact: true` also
58
- * emits `<name>:exact`, each range with its operator stripped. `strategy` is
59
- * CLI-only and ignored here. Throws when an exact-opted entry names no single
71
+ * `dependency` (or bare string); a peers catalog is emitted only for packages
72
+ * carrying a `peer`, using its value verbatim, under the `<name>:peers`
73
+ * colon-delimited name. A declaration with `exact: true` also emits
74
+ * `<name>:exact`, each dependency with its operator stripped. A peer's
75
+ * `strategy` and the entry's `source` are CLI-only and ignored here. Throws when an exact-opted entry names no single
60
76
  * version, or when an entry sets `exact` in a catalog that has not opted in.
61
77
  *
62
78
  * @internal
@@ -69,8 +85,9 @@ function normalizeCatalogs(input) {
69
85
  const peers = {};
70
86
  const exact = {};
71
87
  for (const [pkg, spec] of Object.entries(decl.packages)) {
72
- base[pkg] = typeof spec === "string" ? spec : spec.range;
73
- if (typeof spec === "object" && spec.peer !== void 0) peers[pkg] = spec.peer;
88
+ base[pkg] = dependencyOf(spec);
89
+ const peer = peerOf(spec);
90
+ if (peer !== void 0) peers[pkg] = peer.value;
74
91
  if (decl.exact === true) {
75
92
  const value = exactEntry(name, pkg, spec);
76
93
  if (value !== void 0) exact[pkg] = value;
@@ -83,4 +100,4 @@ function normalizeCatalogs(input) {
83
100
  return out;
84
101
  }
85
102
 
86
- export { REWRITABLE_RANGE_RE, normalizeCatalogs, rangeOf };
103
+ export { REWRITABLE_RANGE_RE, dependencyOf, normalizeCatalogs, peerOf, sourceOf };
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { dirname, relative } from "node:path";
3
- import { CliDoc, CliMessage } from "@effected/cli-kit";
3
+ import { CliDoc, CliMessage, Fmt } from "@effected/cli-kit";
4
4
  import { AtomicFile } from "@effected/files";
5
5
  import { PnpmWorkspaceFile } from "@effected/pnpm";
6
6
  import { Data, Effect, Option, Predicate } from "effect";
@@ -18,6 +18,7 @@ import { loadConfigAndWorkspace } from "../load-config.js";
18
18
  import { legend } from "../render/legend.js";
19
19
  import { printView } from "../render/print.js";
20
20
  import { failureDoc } from "../render/report.js";
21
+ import { respellForFile } from "../respell.js";
21
22
  import { findConfigFiles, pickConfigCandidate } from "../select-file.js";
22
23
  import { overlayWorkspace } from "../workspace-overlay.js";
23
24
 
@@ -51,7 +52,10 @@ function runExport(opts) {
51
52
  const managed = {};
52
53
  for (const [k, v] of Object.entries(base)) if (WORKSPACE_FIELDS.has(k)) managed[k] = v;
53
54
  const rootName = resolveRootName({ dir: dirname(path) });
54
- const effective = effectiveManaged(managed, localCfg, parsed, manifest, rootName);
55
+ const effective = yield* Effect.try({
56
+ try: () => effectiveManaged(managed, localCfg, parsed, manifest, rootName),
57
+ catch: (e) => new ExportError({ message: Fmt.errorText(e) })
58
+ });
55
59
  const explicitPatchMap = owned === void 0;
56
60
  const contributed = {};
57
61
  if (explicitPatchMap) {
@@ -69,7 +73,8 @@ function runExport(opts) {
69
73
  root: dirname(path),
70
74
  exists: existsSync
71
75
  });
72
- const merged = overlayWorkspace(effective, parsed);
76
+ const { effective: spelled, parsed: fileBase } = respellForFile(effective, parsed);
77
+ const merged = overlayWorkspace(spelled, fileBase);
73
78
  const rendered = yield* Effect.fromResult(file.writeResult(merged)).pipe(Effect.mapError((e) => new ExportError({ message: e.message })));
74
79
  const localKeys = new Set(Object.keys(localCfg ?? {}).filter((k) => WORKSPACE_FIELDS.has(k)));
75
80
  const tree = buildDiff(PnpmWorkspaceFile.canonicalize(parsed), PnpmWorkspaceFile.canonicalize(merged), {
@@ -1,5 +1,5 @@
1
1
  import { dirname } from "node:path";
2
- import { CliDoc, CliInteractive } from "@effected/cli-kit";
2
+ import { CliDoc, CliInteractive, Fmt } from "@effected/cli-kit";
3
3
  import { CliUi } from "@effected/cli-kit/ui";
4
4
  import { Data, Effect, Option } from "effect";
5
5
  import { Argument, Command } from "effect/cli";
@@ -35,12 +35,15 @@ function runPreviewViews(opts) {
35
35
  const { base, manifest } = yield* freeze(config).pipe(Effect.mapError((e) => new PreviewError({ message: e.message })));
36
36
  const managed = {};
37
37
  for (const [k, v] of Object.entries(base)) if (WORKSPACE_FIELDS.has(k)) managed[k] = v;
38
- return buildPreviewViews({
39
- managed,
40
- ...localCfg ? { local: localCfg } : {},
41
- parsed,
42
- manifest,
43
- rootName: resolveRootName({ dir: dirname(path) })
38
+ return yield* Effect.try({
39
+ try: () => buildPreviewViews({
40
+ managed,
41
+ ...localCfg ? { local: localCfg } : {},
42
+ parsed,
43
+ manifest,
44
+ rootName: resolveRootName({ dir: dirname(path) })
45
+ }),
46
+ catch: (e) => new PreviewError({ message: Fmt.errorText(e) })
44
47
  });
45
48
  });
46
49
  }
@@ -12,8 +12,8 @@ import { applyEdits } from "../rewrite.js";
12
12
  import { renderCommitMessage } from "../sync/commit-message.js";
13
13
  import { SyncConfigError, resolveEvaluatedSync } from "../sync/config.js";
14
14
  import { applyFloorEdits, describeFloorEdits, planFloorEdits } from "../sync/floors.js";
15
- import { exportDrift, exportedCatalogNames, readServedCatalogs } from "../sync/local-gate.js";
16
- import { MEMBERSHIP_REMEDY, checkMembership, membershipMessage, pluginManifest, pluginPackageName } from "../sync/membership.js";
15
+ import { LocalGateError, exportDrift, exportedCatalogNames, readServedCatalogs } from "../sync/local-gate.js";
16
+ import { checkSyncMembership, hasMembershipGap, membershipRemedies, notWorkspaceRow, pairsMembershipMessage, pluginManifest, pluginPackageName } from "../sync/membership.js";
17
17
  import { readReleasePlan } from "../sync/release-plan.js";
18
18
  import { rippleEdits, rippleMismatches } from "../sync/ripples.js";
19
19
  import { currentCatalogs, mergeMoves, parseChangeset, renderChangeset, staleMoves } from "../sync/running-list.js";
@@ -34,18 +34,44 @@ var SyncUsageError = class extends Data.TaggedError("SyncUsageError") {
34
34
  }
35
35
  };
36
36
  /**
37
- * Publishable workspace packages the sync catalog does not name. Raised before
37
+ * Publishable workspace packages the sync catalog does not name, or names
38
+ * without `source: "workspace"`, so sync would never move them. Raised before
38
39
  * any write: a sync that upgraded versions while a member was missing would
39
40
  * report "synced" for a catalog that is still incomplete. A finding, exit 1.
40
41
  *
41
42
  * @internal
42
43
  */
43
44
  var MembershipError = class extends Data.TaggedError("MembershipError") {
44
- /** The failure report: the `membershipMessage` text. */
45
+ /** The failure report: the `pairsMembershipMessage` text. */
45
46
  [CliDoc]() {
46
47
  return failureDoc(this.message);
47
48
  }
48
49
  };
50
+ /** Every synced catalog, in pair order: what the upgrade, ripple and running-list steps act on. */
51
+ function syncedCatalogs(sync) {
52
+ return sync.pairs.map((pair) => pair.catalog);
53
+ }
54
+ /**
55
+ * The entries `sync` owns: workspace-sourced ones. An npm entry in a synced
56
+ * catalog is `upgrade`'s, so a ripple never moves it, even when it names a
57
+ * workspace package the release plan bumps.
58
+ */
59
+ function workspaceEntries(entries) {
60
+ return entries.filter((entry) => entry.source === "workspace");
61
+ }
62
+ /**
63
+ * Every pair's membership as one comparison, in pair order: the write-mode
64
+ * result and its JSON document. The failure message and `--check` keep the
65
+ * pairs apart.
66
+ */
67
+ function mergeMembership(pairs) {
68
+ return {
69
+ missing: pairs.flatMap((p) => p.result.missing),
70
+ notWorkspace: pairs.flatMap((p) => p.result.notWorkspace),
71
+ publishable: pairs.flatMap((p) => p.result.publishable),
72
+ catalogued: pairs.flatMap((p) => p.result.catalogued)
73
+ };
74
+ }
49
75
  /** Read and decode the `sync` block of the config at `configFile`. */
50
76
  function readSyncConfig(configFile) {
51
77
  return Effect.gen(function* () {
@@ -77,19 +103,19 @@ function writeListAndMessage(rootDir, sync, pluginName, moves) {
77
103
  return Effect.gen(function* () {
78
104
  const path = yield* Path.Path;
79
105
  const file = path.join(rootDir, sync.changesetPath);
80
- yield* writeFile(file, yield* Effect.fromResult(renderChangeset(pluginName, sync.bump, moves, sync.catalog)).pipe(Effect.mapError((error) => new UpgradeError({ message: `Cannot render ${file}: ${error.message}` }))));
81
- yield* writeFile(path.join(rootDir, sync.messagePath), renderCommitMessage(sync.commitScope, moves));
106
+ yield* writeFile(file, yield* Effect.fromResult(renderChangeset(pluginName, sync.bump, moves, syncedCatalogs(sync))).pipe(Effect.mapError((error) => new UpgradeError({ message: `Cannot render ${file}: ${error.message}` }))));
107
+ yield* writeFile(path.join(rootDir, sync.messagePath), renderCommitMessage(sync.commitScope, moves, sync.pairs.length));
82
108
  });
83
109
  }
84
110
  /**
85
- * Bring the sync catalog in the config at `configFile` to the next release
86
- * versions, and record the moves in the running-list changeset.
111
+ * Bring every sync pair's catalog in the config at `configFile` to the next
112
+ * release versions, and record the moves in one running-list changeset.
87
113
  *
88
114
  * @remarks
89
115
  * The order is the scripts' and each step has its reason:
90
116
  *
91
- * 1. Membership, before any write: a sync that upgrades versions while a
92
- * member is missing would report success for an incomplete catalog.
117
+ * 1. Membership, per pair, before any write: a sync that upgrades versions
118
+ * while a member is missing would report success for an incomplete catalog.
93
119
  * 2. Floors, when `sync.floors` is on, before the plan is read: a raised
94
120
  * package releases at a new minor, and the catalog must name that version.
95
121
  * 3. The release plan, read before the config is rewritten, so a plan that
@@ -97,9 +123,11 @@ function writeListAndMessage(rootDir, sync, pluginName, moves) {
97
123
  * commit message unchanged (step 2 may already have written floors).
98
124
  * 4. A snapshot of the config, which decides whether the catalog moved: the
99
125
  * file cannot disagree with itself.
100
- * 5. The upgrade (`--yes`), scoped to the sync catalog.
126
+ * 5. The upgrade (`--yes`), one run over every pair's catalog, moving only
127
+ * workspace entries: npm entries in a synced catalog are `upgrade`'s.
101
128
  * 6. Ripples, read from the config the upgrade just wrote: a package bumped
102
129
  * only as a dependency ripple has no changeset, so the upgrade cannot see it.
130
+ * Only workspace entries ripple.
103
131
  * 7. If the config did not move, the running list is rewritten only when it is
104
132
  * stale (hand-edited, or carried over a merge), so a sync repairs it.
105
133
  * Otherwise this run's moves are merged into it: it lists every move since
@@ -113,11 +141,16 @@ const runSyncWrite = Effect.fn("Sync.runSyncWrite")(function* (opts) {
113
141
  const file = opts.configFile;
114
142
  const sync = yield* readSyncConfig(file);
115
143
  const rootDir = findWorkspaceRoot(dirname(path.resolve(file)));
116
- const membership = yield* checkMembership(file, rootDir, sync);
117
- if (membership.missing.length > 0) return yield* new MembershipError({
118
- message: membershipMessage(membership.missing, file),
119
- missing: membership.missing
120
- });
144
+ const pairs = yield* checkSyncMembership(file, rootDir, sync);
145
+ const membership = mergeMembership(pairs);
146
+ if (hasMembershipGap(membership)) {
147
+ const gaps = pairs.filter((pair) => hasMembershipGap(pair.result));
148
+ return yield* new MembershipError({
149
+ message: pairsMembershipMessage(gaps, file, sync.pairs.length > 1),
150
+ missing: membership.missing,
151
+ notWorkspace: membership.notWorkspace
152
+ });
153
+ }
121
154
  const pluginName = yield* pluginPackageName(file);
122
155
  let floors = 0;
123
156
  if (sync.floors) {
@@ -127,14 +160,16 @@ const runSyncWrite = Effect.fn("Sync.runSyncWrite")(function* (opts) {
127
160
  }
128
161
  const plan = yield* readReleasePlan(rootDir);
129
162
  const before = (yield* readCatalogSource(file)).source;
163
+ const catalogs = syncedCatalogs(sync);
130
164
  const upgraded = yield* runUpgrade({
131
165
  file,
132
166
  resolver: opts.resolver,
133
167
  workspaceResolver: opts.workspaceResolver,
134
- catalog: sync.catalog
168
+ catalog: catalogs,
169
+ owns: "workspace"
135
170
  });
136
- const { source: afterUpgrade, entries } = yield* readCatalogSource(file, sync.catalog);
137
- const ripples = yield* rippleMismatches(entries, plan);
171
+ const { source: afterUpgrade, entries } = yield* readCatalogSource(file, catalogs);
172
+ const ripples = yield* rippleMismatches(workspaceEntries(entries), plan);
138
173
  if (ripples.length > 0) yield* writeFile(file, applyEdits(afterUpgrade, rippleEdits(entries, ripples)));
139
174
  const after = yield* readCatalogSource(file);
140
175
  const current = currentCatalogs(after.entries);
@@ -187,29 +222,41 @@ const runSyncWrite = Effect.fn("Sync.runSyncWrite")(function* (opts) {
187
222
  const syncRemedy = (displayFile) => `Run \`rolldown-pnpm-config sync ${displayFile}\`.`;
188
223
  /** The remedy for export drift: the export writes the yaml, the rebuild serves what it wrote. */
189
224
  const EXPORT_REMEDY = "Run `pnpm pnpm:export`, then rebuild the plugin.";
190
- /** A section with nothing to report. */
191
- const ok = (section) => ({
225
+ /** A section with nothing to report; `catalog` names the pair a per-catalog section covers. */
226
+ const ok = (section, catalog) => ({
192
227
  section,
228
+ ...catalog === void 0 ? {} : { catalog },
193
229
  status: "ok"
194
230
  });
195
231
  /** `rows` as findings, or ok when there are none. */
196
- const findings = (section, rows, remedy) => rows.length === 0 ? ok(section) : {
232
+ const findings = (section, rows, remedy, catalog) => rows.length === 0 ? ok(section, catalog) : {
197
233
  section,
234
+ ...catalog === void 0 ? {} : { catalog },
198
235
  status: "findings",
199
236
  rows,
200
237
  remedy
201
238
  };
239
+ /** A typed failure as a section's `error` status. */
240
+ const errorSection = (section, error) => ({
241
+ section,
242
+ status: "error",
243
+ kind: error._tag,
244
+ message: error.message
245
+ });
202
246
  /**
203
247
  * Evaluate one section. A typed failure becomes its `error` status, so one
204
248
  * section that cannot be read never hides the verdict of the next.
205
249
  */
206
250
  function evaluate(section, effect) {
207
- return effect.pipe(Effect.catch((error) => Effect.succeed({
208
- section,
209
- status: "error",
210
- kind: error._tag,
211
- message: error.message
212
- })));
251
+ return effect.pipe(Effect.catch((error) => Effect.succeed(errorSection(section, error))));
252
+ }
253
+ /**
254
+ * Evaluate a section reported per catalog. A failure that no one pair owns
255
+ * (an unreadable workspace or release plan) is one `error` section with no
256
+ * catalog, since it says nothing about any pair in particular.
257
+ */
258
+ function evaluatePerCatalog(section, effect) {
259
+ return effect.pipe(Effect.catch((error) => Effect.succeed([errorSection(section, error)])));
213
260
  }
214
261
  /** One drift row: `catalog.pkg from -> to (source)`; a peer-only resync keeps its range. */
215
262
  function driftRow(row) {
@@ -217,22 +264,25 @@ function driftRow(row) {
217
264
  return ` ${row.catalog}.${row.pkg} ${move} (${row.source})`;
218
265
  }
219
266
  /**
220
- * Versions: the upgrade's own check, a dry run scoped to the sync catalog.
221
- * Also returns the rows the upgrade would move (none when it errored), which
222
- * the ripples section lays over the config.
267
+ * Versions: the upgrade's own check, a dry run per sync pair, so a resolver
268
+ * failure is reported against the catalog it belongs to. Also returns the rows
269
+ * the upgrades would move (none from a pair that errored), which the ripples
270
+ * section lays over the config.
223
271
  */
224
- function versionsSection(opts, sync, remedy) {
225
- return runUpgrade({
272
+ function versionsSections(opts, sync, remedy) {
273
+ return Effect.forEach(syncedCatalogs(sync), (catalog) => runUpgrade({
226
274
  file: opts.configFile,
227
275
  resolver: opts.resolver,
228
276
  workspaceResolver: opts.workspaceResolver,
229
- catalog: sync.catalog,
277
+ catalog,
278
+ owns: "workspace",
230
279
  dryRun: true
231
280
  }).pipe(Effect.result, Effect.map((result) => {
232
281
  const { failure } = checkJsonOutcome(result);
233
282
  if (failure !== void 0) return {
234
283
  section: {
235
284
  section: "versions",
285
+ catalog,
236
286
  status: "error",
237
287
  kind: failure.kind ?? "resolution",
238
288
  message: failure.message
@@ -241,14 +291,17 @@ function versionsSection(opts, sync, remedy) {
241
291
  };
242
292
  const changed = Result.isSuccess(result) ? result.success.changed : [];
243
293
  return {
244
- section: findings("versions", changed.map(driftRow), remedy),
294
+ section: findings("versions", changed.map(driftRow), remedy, catalog),
245
295
  changed
246
296
  };
247
- }));
297
+ }))).pipe(Effect.map((pairs) => ({
298
+ sections: pairs.map((p) => p.section),
299
+ changed: pairs.flatMap((p) => p.changed)
300
+ })));
248
301
  }
249
- /** Membership: publishable workspace members the sync catalog does not name. */
250
- function membershipSection(configFile, rootDir, sync) {
251
- return evaluate("membership", checkMembership(configFile, rootDir, sync).pipe(Effect.map((m) => findings("membership", m.missing.map((name) => ` - ${name}`), MEMBERSHIP_REMEDY))));
302
+ /** Membership, per pair: publishable workspace members the pair's catalog does not name, or names without `source: "workspace"`. */
303
+ function membershipSections(configFile, rootDir, sync) {
304
+ return evaluatePerCatalog("membership", checkSyncMembership(configFile, rootDir, sync).pipe(Effect.map((pairs) => pairs.map((pair) => findings("membership", [...pair.result.missing.map((name) => ` - ${name}`), ...pair.result.notWorkspace.map(notWorkspaceRow)], membershipRemedies([pair.result]).join(" "), pair.catalog)))));
252
305
  }
253
306
  /** Floors: the breaking-floor changesets on disk differ from the ones the plan derives. */
254
307
  function floorsSection(rootDir, remedy) {
@@ -265,31 +318,33 @@ function runningListSection(configFile, rootDir, sync, remedy) {
265
318
  }));
266
319
  }
267
320
  /**
268
- * Ripples: entries behind the version the release plan would release, which
269
- * the upgrade cannot see.
321
+ * Ripples, per pair: workspace entries behind the version the release plan
322
+ * would release, which the upgrade cannot see.
270
323
  *
271
324
  * @remarks
272
325
  * Write mode looks for ripples after the upgrade has run, so `upgraded` (the
273
- * versions section's drift rows) is laid over the config first: a package the
274
- * upgrade moves is a versions row, never a ripple too. When versions errored,
275
- * `upgraded` is empty and the list is unfiltered. With `floors: true`, the
276
- * targets come from the plan before any floor is raised (write mode raises
277
- * floors first), so a row can differ from what a sync would write.
326
+ * versions sections' drift rows) is laid over the config first: a package the
327
+ * upgrade moves is a versions row, never a ripple too. A pair whose versions
328
+ * errored contributes no rows, so its ripples are unfiltered. With
329
+ * `floors: true`, the targets come from the plan before any floor is raised
330
+ * (write mode raises floors first), so a row can differ from what a sync would
331
+ * write.
278
332
  */
279
- function ripplesSection(configFile, rootDir, sync, upgraded, remedy) {
280
- return evaluate("ripples", Effect.gen(function* () {
333
+ function ripplesSections(configFile, rootDir, sync, upgraded, remedy) {
334
+ return evaluatePerCatalog("ripples", Effect.gen(function* () {
281
335
  const plan = yield* readReleasePlan(rootDir);
282
- const { entries } = yield* readCatalogSource(configFile, sync.catalog);
336
+ const catalogs = syncedCatalogs(sync);
337
+ const { entries } = yield* readCatalogSource(configFile, catalogs);
283
338
  const moved = new Map(upgraded.map((row) => [`${row.catalog}\0${row.pkg}`, row.to]));
284
- const afterUpgrade = entries.map((entry) => {
339
+ const afterUpgrade = workspaceEntries(entries).map((entry) => {
285
340
  const to = moved.get(`${entry.catalog}\0${entry.pkg}`);
286
341
  return to === void 0 ? entry : {
287
342
  ...entry,
288
343
  currentRange: to
289
344
  };
290
345
  });
291
- const rows = (yield* rippleMismatches(afterUpgrade, plan)).map((r) => ` ${r.catalog}.${r.pkg} ${r.from} -> ${r.to}`);
292
- return findings("ripples", rows, remedy);
346
+ const ripples = yield* rippleMismatches(afterUpgrade, plan);
347
+ return catalogs.map((catalog) => findings("ripples", ripples.filter((r) => r.catalog === catalog).map((r) => ` ${r.catalog}.${r.pkg} ${r.from} -> ${r.to}`), remedy, catalog));
293
348
  }));
294
349
  }
295
350
  /**
@@ -310,7 +365,11 @@ function exportSection(configFile, rootDir, sync) {
310
365
  const source = yield* fs.readFileString(path.join(rootDir, "pnpm-workspace.yaml"));
311
366
  const workspace = yield* PnpmWorkspaceFile.parse(source);
312
367
  const names = exportedCatalogNames(served.success, sync);
313
- return findings("export", exportDrift(served.success, names, { ...workspace.value }), EXPORT_REMEDY);
368
+ const rows = yield* Effect.try({
369
+ try: () => exportDrift(served.success, names, { ...workspace.value }),
370
+ catch: (cause) => new LocalGateError({ message: Fmt.errorText(cause) })
371
+ });
372
+ return findings("export", rows, EXPORT_REMEDY);
314
373
  }));
315
374
  }
316
375
  /** What both gates start from: the decoded `sync` block and the workspace root. */
@@ -337,9 +396,10 @@ function checkDoc(mode, sections) {
337
396
  *
338
397
  * @remarks
339
398
  * Every section is evaluated, in the order versions, membership, floors (when
340
- * `sync.floors` is on), running-list, ripples, and none short-circuits: the
341
- * scripts this ports stop at the first failure, but a red check that lists
342
- * everything saves a round trip. Only an unreadable or invalid config fails
399
+ * `sync.floors` is on), running-list, ripples, and none short-circuits.
400
+ * Versions, membership and ripples come once per sync pair, in pair order,
401
+ * each naming its `catalog`. The scripts this ports stop at the first
402
+ * failure, but a red check that lists everything saves a round trip. Only an unreadable or invalid config fails
343
403
  * the run; a section that cannot be evaluated is an `error` section.
344
404
  *
345
405
  * @internal
@@ -348,14 +408,16 @@ const runSyncCheck = Effect.fn("Sync.runSyncCheck")(function* (opts) {
348
408
  const file = opts.configFile;
349
409
  const remedy = syncRemedy(opts.displayFile ?? file);
350
410
  const { sync, rootDir } = yield* gateContext(file);
351
- const versions = yield* versionsSection(opts, sync, remedy);
352
- const rest = yield* Effect.all([
353
- membershipSection(file, rootDir, sync),
354
- ...sync.floors ? [floorsSection(rootDir, remedy)] : [],
355
- runningListSection(file, rootDir, sync, remedy),
356
- ripplesSection(file, rootDir, sync, versions.changed, remedy)
411
+ const versions = yield* versionsSections(opts, sync, remedy);
412
+ const membership = yield* membershipSections(file, rootDir, sync);
413
+ const shared = yield* Effect.all([...sync.floors ? [floorsSection(rootDir, remedy)] : [], runningListSection(file, rootDir, sync, remedy)]);
414
+ const ripples = yield* ripplesSections(file, rootDir, sync, versions.changed, remedy);
415
+ return checkDoc("check", [
416
+ ...versions.sections,
417
+ ...membership,
418
+ ...shared,
419
+ ...ripples
357
420
  ]);
358
- return checkDoc("check", [versions.section, ...rest]);
359
421
  });
360
422
  /**
361
423
  * The offline push-time gate: membership, and that the exported catalogs in
@@ -363,8 +425,8 @@ const runSyncCheck = Effect.fn("Sync.runSyncCheck")(function* (opts) {
363
425
  * release plan, no version drift; writes nothing.
364
426
  *
365
427
  * @remarks
366
- * The sync catalog and its `:peers` sibling are not exported by default, so a
367
- * lagging sync catalog in the yaml is not reported: that is `--check`'s
428
+ * The synced catalogs and their `:peers` and `:exact` twins are not exported by
429
+ * default, so a lagging synced catalog in the yaml is not reported: that is `--check`'s
368
430
  * versions question, and it needs the network.
369
431
  *
370
432
  * @internal
@@ -372,7 +434,9 @@ const runSyncCheck = Effect.fn("Sync.runSyncCheck")(function* (opts) {
372
434
  const runSyncLocal = Effect.fn("Sync.runSyncLocal")(function* (opts) {
373
435
  const file = opts.configFile;
374
436
  const { sync, rootDir } = yield* gateContext(file);
375
- return checkDoc("local", yield* Effect.all([membershipSection(file, rootDir, sync), exportSection(file, rootDir, sync)]));
437
+ const membership = yield* membershipSections(file, rootDir, sync);
438
+ const exported = yield* exportSection(file, rootDir, sync);
439
+ return checkDoc("local", [...membership, exported]);
376
440
  });
377
441
  /**
378
442
  * Fail unless the `sync` block manages breaking floors: `--floors-only` on a
@@ -435,15 +499,21 @@ function findingsHeading(section, count) {
435
499
  function syncCheckView(doc) {
436
500
  const failing = doc.sections.filter((s) => s.status !== "ok");
437
501
  if (failing.length === 0) return [Doc.line(doc.mode === "check" ? "Catalogs are in sync." : "Catalog membership and the exported catalogs are in sync.")];
438
- return failing.map((s) => {
502
+ const catalogs = new Set(doc.sections.flatMap((s) => s.catalog === void 0 ? [] : [s.catalog]));
503
+ const named = (heading, catalog) => catalogs.size > 1 && catalog !== void 0 ? heading.replace(/:$/, ` (catalog ${catalog}):`) : heading;
504
+ const remedyAtEnd = catalogs.size > 1;
505
+ const blocks = failing.map((s) => {
439
506
  if (s.status === "findings") return Doc.section(void 0, [
440
- Doc.line(findingsHeading(s.section, s.rows.length)),
507
+ Doc.line(named(findingsHeading(s.section, s.rows.length), s.catalog)),
441
508
  Doc.lines(s.rows, { wrap: false }),
442
- Doc.line(s.remedy)
509
+ ...remedyAtEnd ? [] : [Doc.line(s.remedy)]
443
510
  ]);
444
511
  const heading = s.section === "versions" ? CHECK_FAILED_LABEL : `The ${s.section} section could not be evaluated (${s.kind}, not a finding):`;
445
- return Doc.section(void 0, [Doc.line(heading), Doc.lines(s.message.split("\n").map((line) => ` ${line}`), { wrap: false })]);
512
+ return Doc.section(void 0, [Doc.line(named(heading, s.catalog)), Doc.lines(s.message.split("\n").map((line) => ` ${line}`), { wrap: false })]);
446
513
  });
514
+ if (!remedyAtEnd) return blocks;
515
+ const remedies = [...new Set(failing.flatMap((s) => s.status === "findings" ? [s.remedy] : []))];
516
+ return [Doc.section(void 0, [...blocks, ...remedies.map((r) => Doc.line(r))])];
447
517
  }
448
518
  /** One move as a report line: `catalog.pkg from -> to`. */
449
519
  function moveLine(move, note = "") {