rolldown-pnpm-config 3.2.0 → 4.0.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 +143 -79
  6. package/cli/commands/upgrade.js +333 -135
  7. package/cli/discover.js +134 -28
  8. package/cli/drift.js +1 -1
  9. package/cli/edits.js +8 -17
  10. package/cli/effective.js +119 -4
  11. package/cli/interop.js +7 -15
  12. package/cli/local-merge.js +4 -1
  13. package/cli/plan.js +8 -3
  14. package/cli/preview-views.js +3 -1
  15. package/cli/release-age.js +2 -1
  16. package/cli/render/print.js +2 -5
  17. package/cli/render/report.js +2 -4
  18. package/cli/respell.js +86 -0
  19. package/cli/select-file.js +5 -2
  20. package/cli/summary.js +43 -9
  21. package/cli/sync/commit-message.js +4 -3
  22. package/cli/sync/config.js +60 -24
  23. package/cli/sync/floors.js +6 -3
  24. package/cli/sync/local-gate.js +19 -9
  25. package/cli/sync/membership.js +93 -31
  26. package/cli/sync/ripples.js +4 -4
  27. package/cli/sync/running-list.js +16 -6
  28. package/cli/ui/walk-screen.js +66 -20
  29. package/cli/validate.js +1 -1
  30. package/cli/version.js +1 -1
  31. package/cli/walk-plan.js +17 -10
  32. package/cli/walk-reducer.js +99 -19
  33. package/index.d.ts +176 -127
  34. package/package.json +8 -8
  35. package/plugin/allowed-versions.js +3 -3
  36. package/plugin/families.js +185 -0
  37. package/plugin/freeze.js +122 -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 +109 -12
  43. package/skills/rolldown-pnpm-config/references/options.md +126 -47
  44. package/skills/rolldown-pnpm-config/references/sync.md +32 -21
  45. package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
  46. package/plugin/overrides-from-catalogs.js +0 -151
@@ -9,71 +9,164 @@ this file follows the code.
9
9
  ## Top-level keys
10
10
 
11
11
  Besides the managed pnpm settings (see "Managed settings" below), the config
12
- takes five keys. Any other key that is a pnpm 12 setting the plugin does not
12
+ takes four keys. Any other key that is a pnpm 12 setting the plugin does not
13
13
  manage fails the build.
14
14
 
15
15
  | Key | Type | Meaning |
16
16
  | --- | --- | --- |
17
17
  | `name` | `string`, required | Identifier for the config dependency; tags runtime warnings as `[name]`. Conventionally the package's npm name. Never written to `pnpm-workspace.yaml` |
18
18
  | `catalogs` | `Record<string, CatalogDeclaration>`, required | The catalogs served to consumers, keyed by catalog name. Keep the literal inline |
19
- | `sync` | `SyncConfig` | Settings for `rolldown-pnpm-config sync`, which moves one catalog's entries for the workspace's own packages to their next release versions. CLI-only: never reaches `base` or the pnpmfile |
19
+ | `sync` | `SyncConfig` | Settings for `rolldown-pnpm-config sync`, which moves the `source: "workspace"` entries of one or more catalogs to their packages' next release versions. Never reaches `base` or the pnpmfile; the build reads it only to refuse a workspace entry no pair owns |
20
20
  | `local` | object | Export-only overrides for `pnpm:export`. Ignored by the build and the pnpmfile |
21
- | `overridesFromCatalogs` | directive or array | Derive `overrides` from a catalog. Build-time only; `local` does not accept it |
22
21
 
23
22
  ### `catalogs`
24
23
 
25
- Each catalog is `{ exact?, packages: { <pkg>: spec } }`. A `spec` is a bare
26
- range string, or an object:
24
+ Each catalog is `{ exact?, families?, packages: { <pkg>: spec } }`. A `spec` is a bare
25
+ dependency string (sourced from npm, no peer), or an object:
27
26
 
28
27
  | Spec field | Meaning |
29
28
  | --- | --- |
30
- | `range` | The install range (required in the object form) |
31
- | `peer` | A materialized peer range. Emitted verbatim into the `<name>:peers` twin (colon-delimited), which exists only when at least one entry sets it |
32
- | `strategy` | `"lock"`, `"lock-minor"` or `"interop"`: how `upgrade` recomputes `peer` when `range` moves. CLI-only |
33
- | `source` | `"registry"` (default) or `"workspace"`: where `upgrade` and `sync` read the next version. `"workspace"` uses current manifest versions overlaid with pending changesets. CLI-only |
34
- | `exact` | The entry's value in `<name>:exact`, or `false` to leave it out. Valid only when the catalog sets `exact: true`; a plain version is rejected where one derives from `range` |
35
-
36
- Catalog field `exact: true` also emits `<name>:exact`: each range with its
29
+ | `dependency` | The value served under `catalog:<name>`: any specifier pnpm accepts (required in the object form) |
30
+ | `peer` | The value served under the `<name>:peers` twin (colon-delimited), which exists only when at least one entry sets it. A string is hand-set; `{ value, strategy }` lets `upgrade` re-derive `value` from `dependency` by `strategy` (`"lock"`, `"lock-minor"` or `"interop"`). CLI-only strategy |
31
+ | `source` | `"npm"` (default) or `"workspace"`: where the next version comes from, and so who moves the entry. `upgrade` moves npm entries; `sync` moves workspace entries, reading current manifest versions overlaid with pending changesets. A workspace entry in a catalog no `sync` pair owns fails the build |
32
+ | `exact` | The entry's value in `<name>:exact`, or `false` to leave it out. Valid only when the catalog sets `exact: true`; a plain version is rejected where one derives from `dependency` |
33
+
34
+ The keys `range`, an entry-level `strategy` and `source: "registry"` fail the
35
+ build, naming `dependency`, `peer.strategy` and `"npm"` instead. The removed
36
+ top-level `overridesFromCatalogs` also fails the build, naming `families`
37
+ with `owners`, or `overrides`. Any other key outside a level's set fails the
38
+ build too, naming the nearest valid key: a catalog takes `packages`, `exact`
39
+ and `families`, an entry `dependency`, `peer`, `source` and `exact`, an
40
+ object `peer` `value` and `strategy`, and a family `name`, `members`,
41
+ `exclude` and `owners`.
42
+
43
+ Catalog field `exact: true` also emits `<name>:exact`: each dependency with its
37
44
  operator stripped (`^0.34.0` becomes `0.34.0`). Only one comparator (`^`, `~`,
38
- `>=`, `=` or none) on one version derives; any other range fails the build
45
+ `>=`, `=` or none) on one version derives; any other dependency fails the build
39
46
  unless the entry sets `exact`. A consumer writes `catalog:<name>:exact`. The
40
- `:peers` and `:exact` twins are never declarations: neither directive nor
41
- `upgrade` accepts them as a catalog name.
47
+ `:peers` and `:exact` twins are never declarations: neither
48
+ `allowedVersionsFromCatalogs` nor `upgrade` accepts them as a catalog name.
49
+
50
+ #### `families`
51
+
52
+ Catalog field `families` is a list of locked release families over that
53
+ catalog's entries:
54
+
55
+ | Family field | Meaning |
56
+ | --- | --- |
57
+ | `name` | Required. Unique across the whole config, not per catalog; `upgrade --family <name>` selects by it |
58
+ | `members` | Required list of exact entry names or globs (`effect`, `@effect/*`). A name that is no entry, or a glob matching none, fails the build |
59
+ | `exclude` | List of names or globs removed from `members`; wins over `members` |
60
+ | `owners` | List of package-name globs (`@acme/*`). Each adds `"<owner>><member>": "<version>"` to `overrides` for every member |
61
+
62
+ Every member's `dependency` must be one exact version, and its `source` must
63
+ not be `"workspace"`. A package belongs to at most one family. `members`,
64
+ `exclude` and `owners` must be lists, never strings. An owner override pins
65
+ regular dependency edges only: pnpm never applies it to a peer edge, and no
66
+ family override is graph-wide. An authored `overrides` selector wins over a
67
+ generated one, but a global authored selector (no parent) on a member must
68
+ equal the member's exact version, or the build fails; a parent-scoped one
69
+ (`<parent>><member>`) always builds. `upgrade --yes` and `--check` skip members unless
70
+ `--family <name>` names their family; `--check` reports a newer member as
71
+ informational. A family of one locks a standalone tool. Keep the lists
72
+ literal: `upgrade --family` refuses a list it cannot read statically.
73
+
74
+ ### `overrides` and `catalog`: two forms each
75
+
76
+ pnpm 12 accepts a flat form and a nested form of both settings, and so does
77
+ the plugin. The flat form is a map of package to value. The nested form is an
78
+ object whose `rules` (overrides) or `entries` (catalog) key holds a mapping,
79
+ beside the sub-keys. Anything else is a flat map, so a package named `unused`,
80
+ or a `rules` or `entries` key holding a version, is a package.
81
+
82
+ ```ts
83
+ overrides: { rules: { "left-pad": "1.3.0" }, unused: "ignore" },
84
+ catalog: { entries: { effect: "^4.0.0" }, mode: "strict", unused: "prune" },
85
+ ```
86
+
87
+ `freeze` desugars the nested form at build time into pnpm's hook-time shape, so
88
+ `base` always holds flat `overrides` and never a `catalog` key:
89
+
90
+ | Sub-key | Setting it becomes |
91
+ | --- | --- |
92
+ | `overrides.rules` | `overrides` |
93
+ | `overrides.unused` `warn` / `ignore` | `warnUnusedOverrides` `true` / `false` |
94
+ | `catalog.entries` | `catalogs.default` |
95
+ | `catalog.mode` | `catalogMode` |
96
+ | `catalog.defaultSaveTarget` | `saveCatalogName` |
97
+ | `catalog.unused` `prune` / `ignore` | `catalogPrune` `true` / `false` |
98
+
99
+ `catalog` is the default catalog, not a shorthand: it ships as
100
+ `catalogs.default`, with divergence warnings, `upgrade` discovery and a
101
+ `sync` pair naming `default`. The `:exact` and `:peers` variants and
102
+ `families` need `catalogs.default`. A bare `local.catalog` replaces the managed default
103
+ catalog, like `local.catalogs.<name>`; a directive's `union`/`merge` lays its
104
+ packages over the managed ones, `difference` removes the listed packages and
105
+ `rewrite` drops the file's own entries. `local.catalog` beside a
106
+ `local.catalogs` that also names `default` fails. An empty catalog (`entries: {}`) ships no
107
+ `catalogs.default`.
108
+
109
+ These fail the build with a `ConfigError` naming both keys: a sub-key together
110
+ with its twin setting (`overrides.unused` and `warnUnusedOverrides`);
111
+ `catalog` together with `catalogs.default`; a `value`, `enforcement` or
112
+ `excludeByRepo` wrapper on `catalog`; a key beside a mapping `rules` or
113
+ `entries` that is not one of its options; an option outside its values, such
114
+ as an `unused` other than its two. `local` goes through the same checks. A
115
+ `pnpm-workspace.yaml` that sets a sub-key beside its twin is accepted on
116
+ export, preview and `sync --check`, the sub-key winning as pnpm reads it.
42
117
 
43
118
  ### `sync`
44
119
 
45
120
  Unknown keys are rejected, and `sync` with no block is a usage error (exit 64)
46
- when the CLI needs it. `sync.catalog` names the catalog that lists the
47
- members; `sync` moves its entries to the members' next release versions.
48
- `members.scope` and `members.exclude` match package names; an empty
49
- `members.scope` is a usage error (exit 64), and one that matches no workspace
50
- package fails membership as a `SyncWorkspaceError`. `members.packages` matches workspace-relative paths. A member counts when
121
+ when the CLI needs it. `sync` takes its pairs in one of two forms, never
122
+ both: `catalogs`, a non-empty list of `{ catalog, members }` pairs, or
123
+ `catalog` with `members`, shorthand for a one-pair list. `sync` moves each
124
+ pair's `source: "workspace"` entries to the members' next release versions
125
+ and leaves npm entries to `upgrade`. Two pairs naming one catalog fail, and
126
+ with more than one pair `commit.scope` is required. Every workspace entry's
127
+ catalog needs a pair, or the build fails. `members.scope` and
128
+ `members.exclude` match package names; an empty `members.scope` is a usage
129
+ error (exit 64), and one that matches no workspace package, or a package two
130
+ pairs' scopes both match, fails membership as a `SyncWorkspaceError`. A
131
+ member its pair's catalog names without `source: "workspace"` is a
132
+ membership finding.
133
+ `members.packages` matches workspace-relative paths. A member counts when
51
134
  its `publishConfig.access` is `"public"`; the plugin package is always
52
135
  excluded.
53
136
 
137
+ ```ts
138
+ sync: {
139
+ catalogs: [
140
+ { catalog: "rspress", members: { scope: "rspress-plugin-*" } },
141
+ { catalog: "vitepress", members: { scope: "vitepress-plugin-*" } },
142
+ ],
143
+ commit: { scope: "pnpm-plugin-acme" },
144
+ },
145
+ ```
146
+
54
147
  | Key | Type | Default | Meaning |
55
148
  | --- | --- | --- | --- |
56
- | `catalog` | `string`, required | none | The catalog `sync` owns and rewrites |
57
- | `members` | object, required | none | Which workspace packages are synced |
149
+ | `catalogs` | `{ catalog, members }[]`, non-empty | none | The sync pairs, one per catalog; `catalog` names a declared catalog (`"default"` for the default one) |
150
+ | `catalog` | `string` | none | Shorthand: the one pair's catalog, beside `members` |
151
+ | `members` | object | none | Which workspace packages a pair syncs (in each pair, or beside the shorthand `catalog`) |
58
152
  | `members.scope` | `string`, required | none | Package-name glob selecting members, e.g. `"@acme/*"` |
59
153
  | `members.packages` | `string[]` | every workspace package | Globs over workspace-relative paths (`"packages/*"`) narrowing discovery |
60
154
  | `members.exclude` | `string[]` | `[]` | Package names or globs over names left out of the scope |
61
- | `changeset` | object | see below | The running-list changeset |
62
- | `changeset.path` | `string` | `.changeset/catalog-sync.md` | Where the running list is written |
155
+ | `changeset` | object | see below | The running-list changeset, shared by every pair |
156
+ | `changeset.path` | `string` | `.changeset/catalog-sync.md` | Where the running list is written; moves are grouped under one heading per catalog |
63
157
  | `changeset.bump` | `"patch" \| "minor"` | `"patch"` | The plugin's bump in the running list |
64
158
  | `commit` | object | see below | The commit message `sync` writes |
65
- | `commit.scope` | `string` | the `catalog` name | Scope of `chore(<scope>): sync catalog to the next release versions` |
159
+ | `commit.scope` | `string` | the catalog name with one pair; required with more | Scope of `chore(<scope>): sync catalog to the next release versions` (`catalogs` with more than one pair) |
66
160
  | `commit.messagePath` | `string` | `.changeset/catalog-sync.commit.txt` | Where the message file is written |
67
161
  | `floors` | `boolean` | `false` | Manage breaking-floor changesets (`.changeset/breaking-floor-*.md`). `sync --check` reports a `floors` section when they differ from the release plan; a write-mode `sync` raises them (writes or deletes the files) before reading the plan |
68
162
  | `local` | object | see below | The `sync --local` gate |
69
163
  | `local.pnpmfile` | `string` | `dist/prod/npm/pkg/pnpmfile.mjs` | The built pnpmfile `--local` imports, relative to the plugin package |
70
- | `local.catalogs` | `string[]` | every served catalog except `<catalog>`, `<catalog>:peers` and `<catalog>:exact` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
164
+ | `local.catalogs` | `string[]` | every served catalog except each synced catalog and its `:peers` and `:exact` twins | The catalogs `--local` compares with `pnpm-workspace.yaml` |
71
165
 
72
166
  ### `local`
73
167
 
74
168
  Export-only (`export` and `preview`). Typed as `localPatchesDir` plus any
75
- managed setting, `catalogs` included (not `name`, `local`,
76
- `overridesFromCatalogs` or `sync`). A value is a bare value, which replaces
169
+ managed setting, `catalogs` included (not `name`, `local` or `sync`). A value is a bare value, which replaces
77
170
  the generated one, or a `LocalDirective` (see below). Only managed settings
78
171
  reach `pnpm-workspace.yaml`: `localPatchesDir` steers patch discovery and is
79
172
  never written, and any other key that is not a setting is ignored.
@@ -84,24 +177,6 @@ never written, and any other key that is not a setting is ignored.
84
177
  | `local.catalogs` | Replaces the managed `catalogs` map before it is overlaid on the file; the overlay then replaces each catalog it names and keeps the file's other catalogs |
85
178
  | `local.<setting>` | A managed setting's override; see "Value forms" |
86
179
 
87
- ### `overridesFromCatalogs`
88
-
89
- One directive or an array. Pins every selected member of a catalog to its exact
90
- catalog version across the whole consumer graph, merged under `overrides` at
91
- build time. An authored `overrides` entry wins on a selector clash. A pinned
92
- member's catalog value is frozen to the pinned version in the shipped output;
93
- the authored range stays what `upgrade` rewrites.
94
-
95
- | Field | Default | Meaning |
96
- | --- | --- | --- |
97
- | `catalog` | required | The catalog whose members are pinned |
98
- | `include` | every member | Names or globs (`@effect/*`) to pin; the rest are skipped. Empty list is rejected |
99
- | `exclude` | none | Names or globs left out; wins over `include` |
100
- | `scope` | `"line"` | `"line"` selects `name@^X.0.0` (the member's release line); `"any"` emits the bare name, pinning every request |
101
-
102
- Every `include` or `exclude` entry must match a member, or the build throws.
103
- Prerelease and compound-range members are skipped rather than widened.
104
-
105
180
  ## Value forms
106
181
 
107
182
  Every managed setting takes a bare value, or `{ value, enforcement }`. The
@@ -155,7 +230,8 @@ A directive is recognized only when its keys are a non-empty subset of
155
230
  | Setting | Extra shape |
156
231
  | --- | --- |
157
232
  | `publicHoistPattern` | Wrapped form adds `excludeByRepo: { [consumingRepoName]: patterns[] }`. The key is the consuming repo's root `package.json` name; its patterns are dropped from the merged list in that repo only |
158
- | `overrides` | A plain `Record<string, string>`. Fed by `overridesFromCatalogs`; setting only the directive still creates `overrides` |
233
+ | `overrides` | A flat `Record<string, string>` or `{ rules, unused }` (see "`overrides` and `catalog`: two forms each"). Fed by the catalogs' `families` owners; a family with owners still creates `overrides` when none is authored |
234
+ | `catalog` | A flat map or `{ entries, mode, defaultSaveTarget, unused }`, folded into `catalogs.default` at build time; never in the shipped payload |
159
235
  | `peerDependencyRules` | Adds `allowedVersionsFromCatalogs` beside `allowedVersions`, `ignoreMissing`, `allowAny` (see below) |
160
236
  | `patchedDependencies` | Also accepts `{ strategy: "rewrite" }`, the default when `public/patches/` has files: discovers patches and rewrites their paths to `node_modules/.pnpm-config/<name>/` |
161
237
  | `audit`, `update` | Sections. List keys union with the consumer's; other keys are the consumer's when set |
@@ -278,6 +354,9 @@ means (from the pnpm settings catalog). Each takes a bare value or
278
354
  | `nodeVersion` | `scalar` | `absent` | Node.js version used when checking a package's `engines` field. |
279
355
  | `nodeDownloadMirrors` | `mapChildWins` | `absent` | Custom Node.js download mirrors, keyed by release channel (`release`, `rc`, `nightly`, ...), each value the complete base URL for its channel. |
280
356
  | `catalogMode` | `scalar` | `absent` | Whether and how `pnpm add` adds dependencies to the default catalog. |
357
+ | `catalogPrune` | `scalar` | `absent` | Whether pnpm prunes catalog entries no project uses; also written as `catalog.unused`. |
358
+ | `saveCatalogName` | `scalar` | `absent` | The catalog a newly saved dependency goes into; also written as `catalog.defaultSaveTarget`. |
359
+ | `warnUnusedOverrides` | `scalar` | `absent` | Whether pnpm warns about overrides no dependency matches; also written as `overrides.unused`. |
281
360
  | `cleanupUnusedCatalogs` | `scalar` | `absent` | Former name of `catalogPrune`, which removes catalog entries no project uses; `catalogPrune` wins when both are set. |
282
361
  | `linkWorkspacePackages` | `scalar` | `absent` | Whether a bare version range resolves to a matching workspace package: `true`, `false`, or `deep` to link in dependencies of dependencies too. |
283
362
  | `preferWorkspacePackages` | `scalar` | `absent` | When `true`, prefer a workspace package over a registry pick even when the registry version is newer than the workspace one. |
@@ -1,8 +1,10 @@
1
1
  # Operating `rolldown-pnpm-config sync`
2
2
 
3
- `sync` keeps the plugin's own catalog (`sync.catalog`) at the versions the
4
- next release will publish, and records every move in a running-list
5
- changeset. It reads the `sync` block of the config; the wiring reference
3
+ `sync` keeps the plugin's own catalogs (each pair of `sync.catalogs`, or the
4
+ one-pair `sync.catalog` shorthand) at the versions the next release will
5
+ publish, and records every move in a running-list changeset. It moves only
6
+ `source: "workspace"` entries: npm entries in a synced catalog are
7
+ `upgrade`'s. It reads the `sync` block of the config; the wiring reference
6
8
  lists the fields.
7
9
 
8
10
  ```sh
@@ -17,7 +19,7 @@ that calls `PnpmConfigPlugin(...)`.
17
19
  | Mode | Writes | Network | Sections, in report order | Run by |
18
20
  | --- | --- | --- | --- | --- |
19
21
  | `sync` | yes | registry | membership refusal, then the write | the Catalog Sync workflow; you only when the user asks |
20
- | `sync --check` | never | registry | `versions`, `membership`, `floors` (only with `sync.floors: true`), `running-list`, `ripples` | the Catalog Sync workflow, as its gate |
22
+ | `sync --check` | never | registry | `versions`, `membership`, `floors` (only with `sync.floors: true`), `running-list`, `ripples`; `versions`, `membership` and `ripples` once per pair | the Catalog Sync workflow, as its gate |
21
23
  | `sync --local` | never | none | `membership`, `export` | the pre-push hook; safe for you to run |
22
24
  | `sync --floors-only` | yes | none | the floors step alone: write or delete `.changeset/breaking-floor-*.md` | a floors script or hook; needs `sync.floors: true` |
23
25
  | `sync --check --floors-only` | never | none | `floors` | a floors gate; safe for you to run |
@@ -27,11 +29,14 @@ that calls `PnpmConfigPlugin(...)`.
27
29
  evaluated; none stops the others.
28
30
 
29
31
  What plain `sync` does, in order: refuse if a publishable member is missing
30
- (before any write); raise breaking floors when `sync.floors` is on; read the
31
- release plan; run `upgrade --yes` scoped to `sync.catalog`; repair ripples
32
- (entries behind a version the plan releases only as a dependency ripple);
33
- merge this run's moves into the running list (or rewrite a stale list when
34
- nothing moved); write the commit message to `sync.commit.messagePath`.
32
+ from its pair's catalog (before any write); raise breaking floors when
33
+ `sync.floors` is on; read the release plan; run one `upgrade --yes` over
34
+ every pair's catalog, moving workspace entries only; repair ripples
35
+ (workspace entries behind a version the plan releases only as a dependency
36
+ ripple; a hand-set string `peer` is never derived); merge this run's moves
37
+ into the running list, one heading per catalog (or rewrite a stale list
38
+ when nothing moved); write the commit message to `sync.commit.messagePath`.
39
+ With more than one pair the headline says `sync catalogs`.
35
40
 
36
41
  ## Exit codes
37
42
 
@@ -39,7 +44,7 @@ nothing moved); write the commit message to `sync.commit.messagePath`.
39
44
  | --- | --- |
40
45
  | 0 | every section ok, or the write succeeded |
41
46
  | 1 | a finding, a section that could not be evaluated, or a failed write (membership, release plan, upgrade, workspace) |
42
- | 64 | usage: `--check --local` or `--floors-only --local`; `--floors-only` with `sync.floors` off; a config that does not parse or has no `PnpmConfigPlugin(...)` call; or no or an invalid `sync` block |
47
+ | 64 | usage: `--check --local` or `--floors-only --local`; `--floors-only` with `sync.floors` off; a config that does not parse or has no `PnpmConfigPlugin(...)` call; or no or an invalid `sync` block (both `sync.catalogs` and the shorthand, two pairs naming one catalog, several pairs without `commit.scope`) |
43
48
 
44
49
  Exit 1 does not mean drift. Read the report or the JSON before acting.
45
50
 
@@ -51,12 +56,18 @@ stdout. The document, wrapped here:
51
56
 
52
57
  ```json
53
58
  {"command":"sync","mode":"check","evaluated":true,"sections":[
54
- {"section":"versions","status":"ok"},
55
- {"section":"membership","status":"findings","rows":[" - @acme/new"],"remedy":"..."},
59
+ {"section":"versions","catalog":"acme","status":"ok"},
60
+ {"section":"membership","catalog":"acme","status":"findings","rows":[" - @acme/new"],"remedy":"..."},
56
61
  {"section":"ripples","status":"error","kind":"ReleasePlanError","message":"..."}
57
62
  ]}
58
63
  ```
59
64
 
65
+ - `versions`, `membership` and `ripples` come once per pair, each carrying
66
+ `catalog`, also with one pair. A failure no one pair owns (an unreadable
67
+ workspace or release plan) is one `error` section with no `catalog`. In
68
+ the text view, with more than one pair, a heading ends
69
+ `(catalog <name>)`.
70
+
60
71
  - `status: "findings"` is an answer: the tree is out of sync, and `remedy`
61
72
  says what clears it.
62
73
  - `status: "error"` is not an answer: the section could not be evaluated
@@ -90,8 +101,8 @@ could be evaluated (resolution error, not drift)".
90
101
 
91
102
  | Section | Finding means | Do |
92
103
  | --- | --- | --- |
93
- | `versions` | A `sync.catalog` entry is behind its next release version | Expected on any branch with a changeset. The workflow runs `sync` on the release PR. Run `pnpm catalog:sync` only if the user asks |
94
- | `membership` | A publishable member in `members.scope` is not in the catalog | Add an entry at the `PnpmConfigPlugin(...)` call site with `source: "workspace"`, or add it to `members.exclude` if it must not be catalogued |
104
+ | `versions` | A workspace entry of the section's `catalog` is behind its next release version | Expected on any branch with a changeset. The workflow runs `sync` on the release PR. Run `pnpm catalog:sync` only if the user asks |
105
+ | `membership` | A publishable member in a pair's `members.scope` is not in that pair's catalog, or is there without `source: "workspace"` (a row ending `(set source: "workspace")`) | Set `source: "workspace"` on that entry, or add an entry to that catalog at the `PnpmConfigPlugin(...)` call site with `source: "workspace"`, or add it to the pair's `members.exclude` if it must not be catalogued |
95
106
  | `floors` | The `.changeset/breaking-floor-*.md` files differ from what the plan derives | Run `sync` (the workflow does) |
96
107
  | `running-list` | `.changeset/catalog-sync.md` disagrees with the catalog (hand-edited, or carried over a merge) | Run `sync`; it rewrites the list. Do not hand-edit the list |
97
108
  | `ripples` | An entry is behind a version the plan releases only as a dependency bump | Run `sync` (the workflow does) |
@@ -102,25 +113,25 @@ The `rows` of each section name the packages; copy them into your report to
102
113
  the user.
103
114
 
104
115
  Error kinds you will meet: `resolution` (a registry lookup failed: network,
105
- auth, or a package that does not exist), `catalog` (`sync.catalog` names a
116
+ auth, or a package that does not exist), `catalog` (a sync pair names a
106
117
  catalog the config does not declare), `changeset` (a pending changeset will
107
118
  not parse), `peer-strategy`, `ReleasePlanError`, `SyncWorkspaceError` (no
108
119
  `pnpm-workspace.yaml`, a bad glob, a `members.scope` that matches no workspace
109
- package (a typo), or no publishable member while the catalog names some:
110
- check `publishConfig.access`), `LocalGateError` (the built
120
+ package (a typo), a package two pairs' scopes both match, or no publishable
121
+ member while the catalog names some: check `publishConfig.access`), `LocalGateError` (the built
111
122
  pnpmfile cannot be evaluated), `UpgradeError` (the running list or the config
112
123
  cannot be read, in `running-list` or `ripples`). Any other kind in `export`
113
124
  (a `PlatformError`, a YAML parse failure) means `pnpm-workspace.yaml` or the
114
125
  plugin's `package.json` cannot be read or parsed.
115
126
 
116
- ## Why `--local` skips the sync catalog
127
+ ## Why `--local` skips the synced catalogs
117
128
 
118
129
  By default `--local` compares every catalog the built pnpmfile serves except
119
- `sync.catalog` and its derived `<sync.catalog>:peers` and
120
- `<sync.catalog>:exact` twins. The workflow's sync commits only
130
+ each synced catalog and its derived `<catalog>:peers` and `<catalog>:exact`
131
+ twins. The workflow's sync commits only
121
132
  the config literal and the changesets; it never re-exports
122
133
  `pnpm-workspace.yaml`, because `pnpm:export` is run by the user only. The
123
- yaml's copy of the sync catalog therefore lags by design, and comparing it
134
+ yaml's copy of a synced catalog therefore lags by design, and comparing it
124
135
  would block every push. Version drift is `--check`'s question, and needs the
125
136
  network. Override the list with `sync.local.catalogs` only when the user asks.
126
137
 
@@ -45,11 +45,11 @@ const plugin: ReturnType<typeof PnpmConfigPlugin> = PnpmConfigPlugin({
45
45
  catalogs: {
46
46
  acme: {
47
47
  packages: {
48
- "@acme/core": { range: "^1.2.0", peer: "^1.2.0", strategy: "lock-minor", source: "workspace" },
48
+ "@acme/core": { dependency: "^1.2.0", peer: { value: "^1.2.0", strategy: "lock-minor" }, source: "workspace" },
49
49
  },
50
50
  },
51
51
  },
52
- sync: { catalog: "acme", members: { scope: "@acme/*" } },
52
+ sync: { catalogs: [{ catalog: "acme", members: { scope: "@acme/*" } }] },
53
53
  });
54
54
 
55
55
  export default plugin;
@@ -133,24 +133,26 @@ Every field the CLI reads. Unknown keys are rejected, and a config with no
133
133
 
134
134
  | Field | Default | Meaning |
135
135
  | --- | --- | --- |
136
- | `catalog` | required | The catalog `sync` owns and rewrites |
137
- | `members.scope` | required | Package-name glob, e.g. `"@acme/*"`; membership counts these names |
136
+ | `catalogs` | one of `catalogs` or `catalog` | A non-empty list of `{ catalog, members }` pairs, one per catalog `sync` owns |
137
+ | `catalog` | one of `catalogs` or `catalog` | Shorthand for one pair, beside `members`; never with `catalogs` |
138
+ | `members.scope` | required in each pair | Package-name glob, e.g. `"@acme/*"`; membership counts these names |
138
139
  | `members.packages` | every workspace package | Globs over workspace-relative paths (`"packages/*"`), narrowing discovery |
139
140
  | `members.exclude` | `[]` | Package names or name globs left out, e.g. `"@acme/sidecar-*"` |
140
141
  | `changeset.path` | `.changeset/catalog-sync.md` | The running-list changeset |
141
142
  | `changeset.bump` | `"patch"` | The running list's bump for the plugin, `"patch"` or `"minor"` |
142
- | `commit.scope` | the `catalog` name | Scope of the headline `chore(<scope>): sync catalog to the next release versions` |
143
+ | `commit.scope` | the catalog name with one pair; required with more | Scope of the headline `chore(<scope>): sync catalog to the next release versions` |
143
144
  | `commit.messagePath` | `.changeset/catalog-sync.commit.txt` | Where the commit message is written |
144
145
  | `floors` | `false` | Also raise and check breaking-floor changesets (`.changeset/breaking-floor-*.md`) |
145
146
  | `local.pnpmfile` | `dist/prod/npm/pkg/pnpmfile.mjs` | The built pnpmfile `--local` imports, relative to the plugin package |
146
- | `local.catalogs` | every served catalog except `<catalog>`, `<catalog>:peers` and `<catalog>:exact` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
147
+ | `local.catalogs` | every served catalog except each synced `<catalog>`, `<catalog>:peers` and `<catalog>:exact` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
147
148
 
148
149
  - A member is publishable when its `publishConfig.access` is `"public"`;
149
150
  `private` is never read.
150
151
  - The plugin package (the nearest `package.json` above the config) is always
151
152
  excluded from membership, whatever the block says.
152
- - `sync` is CLI-only. It never reaches the pnpmfile, and `local.sync` is not
153
- allowed.
153
+ - `sync` moves only `source: "workspace"` entries; `upgrade` moves the rest.
154
+ Every workspace entry's catalog needs a pair, or the build fails.
155
+ - `sync` never reaches the pnpmfile, and `local.sync` is not allowed.
154
156
 
155
157
  ## Workflow and hook templates
156
158
 
@@ -1,151 +0,0 @@
1
- import { OverrideKey } from "@effected/pnpm";
2
- import { VersionSpecifier } from "@effected/semver";
3
- import { Glob, Option, Predicate, Result } from "effect";
4
- import { rangeOf } from "../catalogs.js";
5
-
6
- // src/plugin/overrides-from-catalogs.ts
7
- /** The simple operators that can pin: an optional `^`, `~`, `>=` or `=` on one version. */
8
- const PINNABLE_OPERATORS = /* @__PURE__ */ new Set([
9
- "^",
10
- "~",
11
- ">=",
12
- "=",
13
- ""
14
- ]);
15
- /**
16
- * The release line a plain version belongs to: `^X.0.0`, or `^0.Y.0` when the
17
- * major is 0. A `0.0.Z` version has no caret line (`^0.0.0` admits only
18
- * `0.0.0` itself), so it takes the tilde line `~0.0.0`, which covers every
19
- * `0.0.Z` request.
20
- */
21
- function releaseLine(major, minor) {
22
- if (major !== 0) return `^${major}.0.0`;
23
- return minor === 0 ? "~0.0.0" : `^0.${minor}.0`;
24
- }
25
- /**
26
- * Compile a filter list into a member predicate, throwing when an entry
27
- * matches no member (an exact name or a pattern alike).
28
- */
29
- function compileFilter(entries, members, label, catalog) {
30
- const globs = entries.map((entry) => {
31
- const glob = Glob.make(entry);
32
- if (!members.some((name) => Glob.match(glob, name))) throw new Error(`overridesFromCatalogs: ${label} member "${entry}" is not in catalog "${catalog}"`);
33
- return glob;
34
- });
35
- return (name) => globs.some((glob) => Glob.match(glob, name));
36
- }
37
- /** The override selector for `name`, qualified by `range` when given, in pnpm's grammar. */
38
- function selectorOf(name, range) {
39
- return OverrideKey.make({ path: [{
40
- name,
41
- range: range === void 0 ? Option.none() : Option.some(range)
42
- }] }).format();
43
- }
44
- /**
45
- * The canonical spelling of an `overrides` key, so `" effect@^4.0.0"` and
46
- * `"effect@^4.0.0"` are recognised as one selector; a key pnpm cannot parse is
47
- * kept as written (the settings schema refuses it later).
48
- */
49
- function canonicalSelector(key) {
50
- const parsed = OverrideKey.parseResult(key);
51
- return Result.isSuccess(parsed) ? parsed.success.format() : key;
52
- }
53
- /** Derive the pins for one directive. Pure; throws when the catalog is absent or a filter entry matches nothing. */
54
- function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" }) {
55
- const decl = catalogs[catalog];
56
- if (decl === void 0) throw new Error(`overridesFromCatalogs: catalog "${catalog}" is not declared`);
57
- if (include?.length === 0) throw new Error(`overridesFromCatalogs: include for catalog "${catalog}" is empty, which would pin nothing`);
58
- const members = Object.keys(decl.packages);
59
- const isIncluded = include === void 0 ? () => true : compileFilter(include, members, "included", catalog);
60
- const isExcluded = compileFilter(exclude, members, "excluded", catalog);
61
- const pins = [];
62
- for (const [name, spec] of Object.entries(decl.packages)) {
63
- if (!isIncluded(name) || isExcluded(name)) continue;
64
- const parsed = Result.getOrNull(VersionSpecifier.parseResult(rangeOf(spec)));
65
- if (parsed === null || !PINNABLE_OPERATORS.has(parsed.operator)) continue;
66
- const { version } = parsed;
67
- if (version.prerelease.length > 0 || version.build.length > 0) continue;
68
- const selector = scope === "any" ? selectorOf(name) : selectorOf(name, releaseLine(version.major, version.minor));
69
- pins.push({
70
- catalog,
71
- name,
72
- selector,
73
- version: version.toString()
74
- });
75
- }
76
- return pins;
77
- }
78
- /** Every directive's pins, in directive order. */
79
- function derivePins(catalogs, directives) {
80
- return (Array.isArray(directives) ? directives : [directives]).flatMap((d) => deriveOne(catalogs, d));
81
- }
82
- /**
83
- * Merge the derived overrides for one or more directives (later directives win
84
- * on a selector clash).
85
- *
86
- * @internal
87
- */
88
- function deriveOverrides(catalogs, directives) {
89
- const out = {};
90
- for (const pin of derivePins(catalogs, directives)) out[pin.selector] = pin.version;
91
- return out;
92
- }
93
- /** The exact version an override value names, or `null` for a range, alias or removal. */
94
- function exactVersion(value) {
95
- if (typeof value !== "string") return null;
96
- const parsed = Result.getOrNull(VersionSpecifier.parseResult(value));
97
- if (parsed === null || parsed.operator !== "" && parsed.operator !== "=") return null;
98
- return parsed.version.toString();
99
- }
100
- /**
101
- * Freeze each pinned member's catalog value to the exact version its final
102
- * override names, so a `catalog:` specifier (which pnpm never matches against
103
- * an override) resolves the same version the override pins. Returns a new
104
- * catalogs map, and the `:exact` variant names the same version (a winner that
105
- * is not an exact version throws for a member that variant holds); `:peers`
106
- * catalogs and unpinned members pass through verbatim,
107
- * and a member whose winning override is not an exact version keeps its range.
108
- *
109
- * @internal
110
- */
111
- function pinCatalogs(resolved, overrides, directives, catalogs) {
112
- if (directives === void 0 || !Predicate.isObject(overrides)) return resolved;
113
- const table = new Map(Object.entries(overrides).map(([key, value]) => [canonicalSelector(key), value]));
114
- const out = { ...resolved };
115
- for (const { catalog, name, selector } of derivePins(catalogs, directives)) {
116
- const pinned = exactVersion(table.get(selector));
117
- const current = out[catalog];
118
- const exact = out[`${catalog}:exact`];
119
- if (pinned === null && exact !== void 0 && name in exact) throw new Error(`overridesFromCatalogs: override "${selector}" wins with ${JSON.stringify(table.get(selector))}, which is not an exact version, so catalog "${catalog}:exact" cannot name the version it pins; override with an exact version, or set exact: false on "${name}"`);
120
- if (pinned === null || current === void 0 || !(name in current)) continue;
121
- out[catalog] = {
122
- ...current,
123
- [name]: pinned
124
- };
125
- if (exact !== void 0 && name in exact) out[`${catalog}:exact`] = {
126
- ...exact,
127
- [name]: pinned
128
- };
129
- }
130
- return out;
131
- }
132
- /**
133
- * Resolve the `overrides` value a plugin ships: the derived table from the
134
- * directive, with the authored entries merged over it so a hand-written
135
- * selector wins. Without a directive the authored value passes through
136
- * untouched (by reference, so an absent field stays absent).
137
- *
138
- * @internal
139
- */
140
- function resolveOverrides(authored, directives, catalogs) {
141
- if (directives === void 0) return authored;
142
- const derived = deriveOverrides(catalogs, directives);
143
- const manual = Predicate.isObject(authored) ? authored : {};
144
- const authoredSelectors = new Set(Object.keys(manual).map(canonicalSelector));
145
- return {
146
- ...Object.fromEntries(Object.entries(derived).filter(([key]) => !authoredSelectors.has(key))),
147
- ...manual
148
- };
149
- }
150
-
151
- export { deriveOverrides, pinCatalogs, resolveOverrides };