rolldown-pnpm-config 3.2.1 → 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 (43) 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 +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/respell.js +86 -0
  17. package/cli/select-file.js +5 -2
  18. package/cli/summary.js +42 -6
  19. package/cli/sync/commit-message.js +4 -3
  20. package/cli/sync/config.js +60 -24
  21. package/cli/sync/local-gate.js +19 -9
  22. package/cli/sync/membership.js +93 -31
  23. package/cli/sync/ripples.js +4 -4
  24. package/cli/sync/running-list.js +9 -5
  25. package/cli/ui/walk-screen.js +66 -20
  26. package/cli/validate.js +1 -1
  27. package/cli/version.js +1 -1
  28. package/cli/walk-plan.js +17 -10
  29. package/cli/walk-reducer.js +99 -19
  30. package/index.d.ts +176 -127
  31. package/package.json +6 -6
  32. package/plugin/allowed-versions.js +3 -3
  33. package/plugin/families.js +185 -0
  34. package/plugin/freeze.js +122 -32
  35. package/plugin/second-forms.js +155 -0
  36. package/plugin/synced-catalogs.js +32 -0
  37. package/registry.js +13 -1
  38. package/skills/rolldown-pnpm-config/SKILL.md +13 -3
  39. package/skills/rolldown-pnpm-config/references/catalogs.md +109 -12
  40. package/skills/rolldown-pnpm-config/references/options.md +126 -47
  41. package/skills/rolldown-pnpm-config/references/sync.md +32 -21
  42. package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
  43. package/plugin/overrides-from-catalogs.js +0 -151
@@ -16,14 +16,24 @@ plugin's config in place (`upgrade`, `sync`), writes the repository's own
16
16
 
17
17
  - Keep the `catalogs` literal inline in the `PnpmConfigPlugin({...})` call.
18
18
  The CLI reads and rewrites it statically; never hoist, spread or compute it.
19
+ - The default catalog is `catalogs.default` or the nested/flat `catalog`
20
+ setting, never both; `overrides` also has a nested `{ rules, unused }` form.
21
+ See [references/options.md](references/options.md).
19
22
  - Dependencies use `catalog:<name>`; peers use `catalog:<name>:peers`.
20
23
  - Never run `pnpm:up` or `pnpm:export` (or `upgrade` / `export` without
21
24
  `--dry-run`). They are the user's; tell the user which to run.
22
25
  - Never put the plugin package in any catalog it serves.
23
26
  - A config dependency installs without its dependencies. Bundle every
24
27
  import of the pnpmfile and never declare one as a dependency.
25
- - Never edit a `sync.catalog` range or `.changeset/catalog-sync.md` by hand.
26
- `sync` owns both.
28
+ - Write each catalog entry as `{ dependency, peer?, source? }`, never the
29
+ old `range`, entry-level `strategy` or `source: "registry"`, which fail the
30
+ build.
31
+ - `sync` moves `source: "workspace"` entries and `upgrade` moves npm
32
+ entries. Every workspace entry's catalog needs a pair in `sync.catalogs`,
33
+ or the build fails. Never edit a workspace entry's `dependency` or
34
+ `.changeset/catalog-sync.md` by hand.
35
+ - A family member (`catalogs.<name>.families`) is locked: an exact version,
36
+ moved only by `upgrade --family <name>`, which is the user's to run.
27
37
  - Keep `private: true` in source; publishability is
28
38
  `publishConfig.access: "public"`.
29
39
  - A gate's exit 1 is not proof of drift. Read `evaluated` and each
@@ -36,7 +46,7 @@ Load the reference that matches the task. Each stands alone.
36
46
  | Reference | Load when |
37
47
  | --- | --- |
38
48
  | [references/wiring.md](references/wiring.md) | Adding the plugin to a repository: package layout, `effected.toml`, scripts and root aliases, every `sync` block field and default, the workflow and pre-push shapes |
39
- | [references/catalogs.md](references/catalogs.md) | Adding or editing catalog entries, choosing a specifier, adding imports to the plugin, or entries `export` keeps in `pnpm-workspace.yaml` (union and map fields) |
49
+ | [references/catalogs.md](references/catalogs.md) | Adding or editing catalog entries or families, choosing a specifier, adding imports to the plugin, or entries `export` keeps in `pnpm-workspace.yaml` (union and map fields) |
40
50
  | [references/options.md](references/options.md) | Writing or editing a plugin config, or looking up what a top-level key, `sync` field, value form, strategy or managed pnpm setting does |
41
51
  | [references/sync.md](references/sync.md) | Running `sync`, `sync --check` or `sync --local`, reading their text or JSON report, applying a remedy, or a red Catalog Sync check |
42
52
 
@@ -9,32 +9,121 @@ Write the `catalogs` object literally inside the `PnpmConfigPlugin({...})`
9
9
  call. `upgrade` and `sync` read and rewrite it statically through the AST.
10
10
 
11
11
  - Never hoist it into a variable, a spread, a helper or another module.
12
- - Never compute a range. Write a string literal.
12
+ - Never compute a version. Write a string literal, and keep `families`,
13
+ `members` and `exclude` literal lists: `upgrade --family` refuses a
14
+ spread, an identifier or a call there.
13
15
  - Quoted keys (`"@acme/core"`) are fine.
14
16
 
17
+ ## The default catalog
18
+
19
+ The default catalog is declared as `catalogs.default` or as the top-level
20
+ `catalog` setting, in a flat or nested form (see "`overrides` and `catalog`:
21
+ two forms each" in [options.md](options.md)); never both, which fails the
22
+ build. Either spelling ships as `catalogs.default`, and divergence warnings,
23
+ `upgrade` discovery and a `sync` pair naming `default` apply to it. The
24
+ `:exact` and `:peers` variants and `families` need `catalogs.default`: the
25
+ `catalog` setting takes plain dependency strings, with no `exact`, `peer`
26
+ or `families`. A consumer writes `catalog:` or `catalog:default`.
27
+
15
28
  ## Specifiers
16
29
 
17
30
  | Field | Write | Why |
18
31
  | --- | --- | --- |
19
- | `dependencies`, `devDependencies` | `catalog:<name>` | The catalog's `range` |
32
+ | `dependencies`, `devDependencies` | `catalog:<name>` | The entry's `dependency` |
20
33
  | `peerDependencies` | `catalog:<name>:peers` | The entry's `peer` floor |
21
34
  | An exact pin | `catalog:<name>:exact` | Only when the declaration sets `exact: true` |
22
35
 
23
36
  `pnpm pack` writes a `catalog:` specifier as the catalog's value, so a peer
24
37
  spelled `catalog:<name>` publishes the dependency range instead of the peer
25
- floor. The `:peers` twin holds only entries that declare a `peer`. Give such
26
- an entry a `strategy` (`"lock"`, `"lock-minor"` or `"interop"`) so `upgrade`
27
- and `sync` re-derive `peer` whenever they move `range`.
38
+ floor. The `:peers` twin holds only entries that declare a `peer`. Write such
39
+ a peer as `{ value, strategy }` (`"lock"`, `"lock-minor"` or `"interop"`) so
40
+ `upgrade` and `sync` re-derive it whenever they move `dependency`.
28
41
 
29
42
  ## Entries
30
43
 
31
- - An entry for a workspace package sets `source: "workspace"`, so `upgrade`
32
- and `sync` read the next release version from the workspace (manifests plus
33
- pending changesets) instead of the registry.
34
- - Never edit the `range` of a `sync.catalog` entry by hand. `sync` owns it.
35
- - Add every publishable workspace member in `sync.members.scope` to the sync
36
- catalog, or leave it out explicitly with `sync.members.exclude`. The
37
- membership gate fails otherwise.
44
+ An entry is a bare dependency string (an npm entry with no peer), or an
45
+ object naming what it writes:
46
+
47
+ ```ts
48
+ catalogs: {
49
+ acme: {
50
+ packages: {
51
+ typescript: "^5.9.0",
52
+ effect: { dependency: "^4.1.7", peer: { value: "^4.1.0", strategy: "lock-minor" } },
53
+ "@acme/core": { dependency: "^1.2.0", peer: { value: "^1.2.0", strategy: "lock-minor" }, source: "workspace" },
54
+ "left-pad": { dependency: "^1.3.0", peer: "*" },
55
+ },
56
+ },
57
+ },
58
+ ```
59
+
60
+ - `dependency` is any specifier, served under `catalog:<name>`. A move keeps
61
+ its operator.
62
+ - `peer` is served under `catalog:<name>:peers`. `{ value, strategy }` is
63
+ re-derived on every move; a bare string is hand-set and never touched.
64
+ - `source: "workspace"` marks a package of this monorepo. `sync` moves it,
65
+ reading the next release version from manifests plus pending changesets.
66
+ `"npm"` (the default) is `upgrade`'s.
67
+ - Never write `range`, an entry-level `strategy` or `source: "registry"`:
68
+ the build fails naming `dependency`, `peer.strategy` and `"npm"`.
69
+
70
+ ## Who moves an entry
71
+
72
+ - `upgrade` moves npm entries. It shows a workspace entry read-only and
73
+ never moves it.
74
+ - `sync` moves workspace entries, in every catalog of `sync.catalogs`, and
75
+ leaves npm entries alone, ripples included.
76
+ - Every workspace entry's catalog needs a `sync` pair. A workspace entry in a
77
+ catalog no pair owns, or any workspace entry with no `sync` block, fails the
78
+ build and every install. Add `{ catalog, members: { scope } }` to
79
+ `sync.catalogs`, or set `source: "npm"`.
80
+ - Never edit a workspace entry's `dependency` by hand. `sync` owns it.
81
+ - Add every publishable workspace member in a pair's `members.scope` to that
82
+ pair's catalog with `source: "workspace"`, or leave it out explicitly with
83
+ `members.exclude`. The membership gate fails otherwise, an npm entry for a
84
+ member included, and so does a package two pairs' scopes both match.
85
+
86
+ ## Families lock a release line
87
+
88
+ A family locks entries of one catalog that move together, only when asked:
89
+
90
+ ```ts
91
+ catalogs: {
92
+ effect: {
93
+ packages: {
94
+ effect: "4.1.7",
95
+ "@effect/platform-node": "4.1.7",
96
+ "@effect/tsgo": "0.6.0",
97
+ },
98
+ families: [
99
+ { name: "effect", members: ["effect", "@effect/*"], exclude: ["@effect/tsgo"], owners: ["@acme/*"] },
100
+ { name: "tsgo", members: ["@effect/tsgo"] },
101
+ ],
102
+ },
103
+ },
104
+ ```
105
+
106
+ - `members` and `exclude` are exact names or globs over that catalog's
107
+ entries; `exclude` wins. A name that is no entry, or a glob that matches
108
+ none, fails the build. A new entry matching a glob joins the family.
109
+ - Every member's `dependency` is one exact version (`4.1.7`, not `^4.1.7`),
110
+ and never `source: "workspace"`. Members need not share a version.
111
+ - A package belongs to one family. A family `name` is unique across the
112
+ whole config, not only within its catalog.
113
+ - Each owner glob adds `"<owner>><member>": "<version>"` to `overrides`.
114
+ It pins the owner's regular dependency edges only: pnpm never overrides a
115
+ peer edge, so a member the owner reaches as a peer is fixed by the
116
+ consumer's own `catalog:<name>` dependency. Nothing is pinned graph-wide.
117
+ An authored `overrides` selector wins over a generated one.
118
+ - `upgrade --yes` and `--check` skip members; `--check` lists a newer member
119
+ as informational and still exits 0. `upgrade --yes --family <name>`
120
+ (repeatable) moves each member to its newest version in its breaking line
121
+ (the major, or the minor on 0.x). That moves versions, so it is the user's
122
+ to run. A 0.0.x member never moves under `--family` (`^0.0.3` admits only
123
+ `0.0.3`); it moves only when the user picks a version in the interactive
124
+ table.
125
+ - `overridesFromCatalogs` no longer exists and fails the build. Declare a
126
+ family with `owners`, or write `overrides`.
38
127
 
39
128
  ## Never put the plugin in its own catalog
40
129
 
@@ -66,6 +155,14 @@ Read-only forms are fine: `pnpm:preview`, `upgrade --check`,
66
155
 
67
156
  ## Union and map fields keep unmanaged entries on export
68
157
 
158
+ `export` writes the default catalog under the key the consumer's
159
+ `pnpm-workspace.yaml` already uses (flat `catalog`, nested `catalog` with
160
+ sub-keys, or `catalogs.default`; neither: `catalogs.default`), never both.
161
+ Nested `overrides` in the file stays nested. The default catalog merges per
162
+ package with the file's own entries: the managed value wins on a shared key,
163
+ and entries only the file holds stay. Named catalogs still replace by name on
164
+ export, while an install keeps the consumer's entries; that gap is open.
165
+
69
166
  For fields whose runtime strategy is a union (`publicHoistPattern`,
70
167
  `hoistPattern`, `minimumReleaseAgeExclude`, `trustPolicyExclude`,
71
168
  `supportedArchitectures`, `auditConfig`, `ignoredOptionalDependencies`,
@@ -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