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.
- package/README.md +1 -1
- package/catalogs.js +32 -15
- package/cli/commands/export.js +8 -3
- package/cli/commands/preview.js +10 -7
- package/cli/commands/sync.js +140 -70
- package/cli/commands/upgrade.js +348 -138
- package/cli/discover.js +134 -28
- package/cli/drift.js +2 -2
- package/cli/edits.js +8 -17
- package/cli/effective.js +132 -4
- package/cli/interop.js +35 -16
- package/cli/local-merge.js +4 -1
- package/cli/peer-range.js +21 -5
- package/cli/plan.js +9 -4
- package/cli/preview-views.js +3 -1
- package/cli/release-age.js +2 -1
- package/cli/respell.js +86 -0
- package/cli/select-file.js +5 -2
- package/cli/summary.js +44 -10
- package/cli/sync/commit-message.js +4 -3
- package/cli/sync/config.js +60 -24
- package/cli/sync/local-gate.js +19 -9
- package/cli/sync/membership.js +93 -31
- package/cli/sync/ripples.js +4 -4
- package/cli/sync/running-list.js +9 -5
- package/cli/ui/walk-screen.js +66 -20
- package/cli/validate.js +1 -1
- package/cli/version.js +1 -1
- package/cli/walk-plan.js +17 -10
- package/cli/walk-reducer.js +99 -19
- package/cli/workspace-overlay.js +5 -0
- package/cli/workspace-resolve.js +17 -1
- package/index.d.ts +176 -127
- package/package.json +6 -6
- package/plugin/allowed-versions.js +3 -3
- package/plugin/families.js +185 -0
- package/plugin/freeze.js +137 -32
- package/plugin/second-forms.js +155 -0
- package/plugin/synced-catalogs.js +32 -0
- package/registry.js +13 -1
- package/skills/rolldown-pnpm-config/SKILL.md +13 -3
- package/skills/rolldown-pnpm-config/references/catalogs.md +127 -14
- package/skills/rolldown-pnpm-config/references/options.md +131 -47
- package/skills/rolldown-pnpm-config/references/sync.md +32 -21
- package/skills/rolldown-pnpm-config/references/wiring.md +12 -8
- package/plugin/overrides-from-catalogs.js +0 -151
package/index.d.ts
CHANGED
|
@@ -1,44 +1,61 @@
|
|
|
1
1
|
import { PnpmSettingType } from "@effected/pnpm/settings";
|
|
2
2
|
import "effect";
|
|
3
3
|
import { Plugin } from "rolldown";
|
|
4
|
+
import "@effected/pnpm";
|
|
4
5
|
/**
|
|
5
|
-
* How the `upgrade` CLI recomputes a
|
|
6
|
-
*
|
|
6
|
+
* How the `upgrade` CLI recomputes a derived peer from an entry's
|
|
7
|
+
* `dependency` when the dependency moves. CLI-only metadata; the runtime
|
|
8
|
+
* ignores it.
|
|
7
9
|
*
|
|
8
10
|
* @public
|
|
9
11
|
*/
|
|
10
12
|
type PeerStrategy = "lock" | "lock-minor" | "interop";
|
|
11
13
|
/**
|
|
12
|
-
* Where a catalog entry's `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Where a catalog entry's next `dependency` comes from. `"npm"` (the default
|
|
15
|
+
* when omitted) queries the registry's published versions; `"workspace"`
|
|
16
|
+
* reads the local workspace's next release versions (current manifest
|
|
17
|
+
* versions overlaid with pending changeset bumps), for a package that lives
|
|
18
|
+
* in this monorepo. It sits on the entry, not on `dependency` or `peer`,
|
|
19
|
+
* because both name the same package. CLI-only metadata; the runtime ignores
|
|
20
|
+
* it.
|
|
19
21
|
*
|
|
20
22
|
* @public
|
|
21
23
|
*/
|
|
22
|
-
type VersionSource = "
|
|
24
|
+
type VersionSource = "workspace" | "npm";
|
|
23
25
|
/**
|
|
24
|
-
* A
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* A catalog entry, named by what it writes. A bare string is the entry's
|
|
27
|
+
* `dependency`, sourced from npm, with no peer.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* The object form names its two outputs: `dependency`, served under
|
|
31
|
+
* `catalog:<name>`, and `peer`, served under `catalog:<name>:peers`. The keys
|
|
32
|
+
* an earlier release read (`range`, a top-level `strategy`, and
|
|
33
|
+
* `source: "registry"`) fail the build with the key to write instead: a key
|
|
34
|
+
* the build ignored would ship an entry the author did not write.
|
|
28
35
|
*
|
|
29
36
|
* @public
|
|
30
37
|
*/
|
|
31
38
|
type CatalogPackageSpec = string | {
|
|
32
|
-
|
|
33
|
-
readonly
|
|
34
|
-
|
|
39
|
+
/** Any specifier pnpm accepts as a catalog value: an exact version, a `^` or `~` range, or a wider range. */
|
|
40
|
+
readonly dependency: string;
|
|
41
|
+
/**
|
|
42
|
+
* The entry's value in `<name>:peers`, absent to leave the entry out of
|
|
43
|
+
* that catalog. A bare string is a hand-set value nothing derives;
|
|
44
|
+
* `{ value, strategy }` is a value `upgrade` derives from `dependency` by
|
|
45
|
+
* `strategy` on every move.
|
|
46
|
+
*/
|
|
47
|
+
readonly peer?: string | {
|
|
48
|
+
readonly value: string;
|
|
49
|
+
readonly strategy?: PeerStrategy;
|
|
50
|
+
};
|
|
51
|
+
/** Where `upgrade` and `sync` read the next `dependency` from; defaults to `"npm"`. */
|
|
35
52
|
readonly source?: VersionSource;
|
|
36
53
|
/**
|
|
37
|
-
* The entry's value in the `<name>:exact` catalog, for a
|
|
38
|
-
* no single version (`">=1.2.0 <2.0.0"`), or `false` to leave the
|
|
39
|
-
* out of that catalog. Only valid when the declaration sets
|
|
40
|
-
* `exact: true`, and a plain version is rejected on a
|
|
41
|
-
* value already derives from, since `upgrade` rewrites `
|
|
54
|
+
* The entry's value in the `<name>:exact` catalog, for a dependency that
|
|
55
|
+
* names no single version (`">=1.2.0 <2.0.0"`), or `false` to leave the
|
|
56
|
+
* entry out of that catalog. Only valid when the declaration sets
|
|
57
|
+
* `exact: true`, and a plain version is rejected on a dependency the exact
|
|
58
|
+
* value already derives from, since `upgrade` rewrites `dependency` and
|
|
42
59
|
* would leave a hand-written value stale.
|
|
43
60
|
*/
|
|
44
61
|
readonly exact?: string | false;
|
|
@@ -49,18 +66,56 @@ type CatalogPackageSpec = string | {
|
|
|
49
66
|
* @public
|
|
50
67
|
*/
|
|
51
68
|
interface CatalogDeclaration {
|
|
52
|
-
/** Map of package name to
|
|
69
|
+
/** Map of package name to a dependency string or an entry object. */
|
|
53
70
|
readonly packages: Record<string, CatalogPackageSpec>;
|
|
54
71
|
/**
|
|
55
|
-
* Also emit `<name>:exact`, holding each entry's
|
|
56
|
-
* stripped (`^0.34.0` becomes `0.34.0`), so a dependent writing
|
|
72
|
+
* Also emit `<name>:exact`, holding each entry's dependency with its
|
|
73
|
+
* operator stripped (`^0.34.0` becomes `0.34.0`), so a dependent writing
|
|
57
74
|
* `catalog:<name>:exact` publishes an exact version that still follows the
|
|
58
75
|
* catalog. Only a single comparator (`^`, `~`, `>=`, `=` or none) on one
|
|
59
|
-
* version derives; any other
|
|
60
|
-
* `exact` (a value only where `upgrade` never rewrites the
|
|
61
|
-
*
|
|
76
|
+
* version derives; any other dependency fails the build unless its entry
|
|
77
|
+
* sets `exact` (a value only where `upgrade` never rewrites the
|
|
78
|
+
* dependency).
|
|
62
79
|
*/
|
|
63
80
|
readonly exact?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Locked release families over this catalog's entries. A member must be an
|
|
83
|
+
* exact version, `upgrade` moves it only when asked, and each owner glob
|
|
84
|
+
* pins the member on its regular dependency edges through `overrides`.
|
|
85
|
+
*/
|
|
86
|
+
readonly families?: readonly CatalogFamily[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A locked release family: catalog entries that move together, only when
|
|
90
|
+
* asked, each pinned to its exact version on the dependency edges of the
|
|
91
|
+
* family's owners.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* `members` and `exclude` take exact names or globs over the same catalog's
|
|
95
|
+
* entries, and `exclude` wins. An exact name that is no entry, or a glob that
|
|
96
|
+
* matches none, fails the build, so a typo cannot silently shrink the family.
|
|
97
|
+
* After expansion a package belongs to at most one family in a config. Every
|
|
98
|
+
* member's `dependency` must be one exact version and its `source` must not
|
|
99
|
+
* be `"workspace"`: a locked entry is one `sync` never moves.
|
|
100
|
+
*
|
|
101
|
+
* Each owner glob emits one `overrides` entry per member,
|
|
102
|
+
* `"<owner>><member>": "<version>"`. pnpm applies such an override to a
|
|
103
|
+
* regular dependency edge only; it never changes what a peer edge resolves,
|
|
104
|
+
* so a member an owner reaches through a peer is fixed by the consumer's own
|
|
105
|
+
* `catalog:` dependency, which the exact rule already pins. No override ever
|
|
106
|
+
* pins a member graph-wide.
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
interface CatalogFamily {
|
|
111
|
+
/** The family's name, unique across every catalog in the config; `upgrade --family` selects by it. */
|
|
112
|
+
readonly name: string;
|
|
113
|
+
/** Exact entry names or globs over this catalog's entries (`effect`, `@effect/*`). */
|
|
114
|
+
readonly members: readonly string[];
|
|
115
|
+
/** Exact entry names or globs removed from `members`; wins over `members`. */
|
|
116
|
+
readonly exclude?: readonly string[];
|
|
117
|
+
/** Package-name globs (`@effected/*`) whose regular dependency edges into the members are pinned. */
|
|
118
|
+
readonly owners?: readonly string[];
|
|
64
119
|
}
|
|
65
120
|
/**
|
|
66
121
|
* A directive that derives `peerDependencyRules.allowedVersions` rules from a
|
|
@@ -87,66 +142,6 @@ interface AllowedVersionsFromCatalogs {
|
|
|
87
142
|
*/
|
|
88
143
|
readonly prefix?: string | null;
|
|
89
144
|
}
|
|
90
|
-
/**
|
|
91
|
-
* A directive that derives pnpm `overrides` from a catalog, so every member of
|
|
92
|
-
* a release family resolves to the catalog's exact version everywhere in a
|
|
93
|
-
* consumer's graph: direct requests, transitive requests from other packages,
|
|
94
|
-
* and peer edges alike. A catalog range alone cannot do that, since a caret
|
|
95
|
-
* admits a newer member and a catalog never reaches a dependency's own
|
|
96
|
-
* dependencies. For each member whose range is a simple operator on a plain
|
|
97
|
-
* `X.Y.Z` version, an entry `"<name>@<selector>": "<X.Y.Z>"` is emitted.
|
|
98
|
-
*
|
|
99
|
-
* @remarks
|
|
100
|
-
* Under the default `scope: "line"` the selector is the member's release line,
|
|
101
|
-
* `^X.0.0` (`^0.Y.0` on a 0.x line, `~0.0.0` on 0.0.x), so a request for a *different* major
|
|
102
|
-
* (or a prerelease, which no caret line admits) is left alone. Prerelease and
|
|
103
|
-
* compound-range members are skipped rather than widened. An override entry
|
|
104
|
-
* authored by hand wins over a derived one on the same selector, and the
|
|
105
|
-
* consumer's own `overrides` still win over the plugin's at install time.
|
|
106
|
-
*
|
|
107
|
-
* Every pinned member's catalog value is frozen to the version its override
|
|
108
|
-
* names, so the catalog and the override always agree. pnpm never matches an
|
|
109
|
-
* override against a `catalog:` specifier, so a catalog left at `~X.Y.Z`
|
|
110
|
-
* would let a dependent writing `catalog:` resolve a newer patch than the
|
|
111
|
-
* override pins everywhere else, and the graph would carry two copies. Only
|
|
112
|
-
* the frozen output changes (the pnpmfile's `base`, `export`, `preview`): the
|
|
113
|
-
* authored range stays what `upgrade` reads and rewrites, the `:peers`
|
|
114
|
-
* catalog keeps its peer range, and an opted-in `:exact` catalog names the
|
|
115
|
-
* pinned version. When a hand-authored override wins on the
|
|
116
|
-
* selector, the catalog takes its value if that is an exact version and keeps
|
|
117
|
-
* the authored range otherwise.
|
|
118
|
-
*
|
|
119
|
-
* `include` and `exclude` select which members are pinned, so one catalog can
|
|
120
|
-
* hold both a release family that is pinned graph-wide and packages that are
|
|
121
|
-
* not. Each entry is an exact package name or a glob pattern (`@effect/*`),
|
|
122
|
-
* matched with `effect/Glob` against the whole name; `*` stays within the
|
|
123
|
-
* scope or the bare name. A member matched by both lists is excluded. Every
|
|
124
|
-
* entry must match at least one member, and an empty `include` is rejected,
|
|
125
|
-
* so a typo throws instead of silently widening or narrowing the pin set.
|
|
126
|
-
*
|
|
127
|
-
* @public
|
|
128
|
-
*/
|
|
129
|
-
interface OverridesFromCatalogs {
|
|
130
|
-
/** The catalog whose members are pinned. */
|
|
131
|
-
readonly catalog: string;
|
|
132
|
-
/**
|
|
133
|
-
* Members to pin, as exact names or glob patterns (`effect`, `@effect/*`);
|
|
134
|
-
* the rest are skipped. Omitted, every member is a candidate.
|
|
135
|
-
*/
|
|
136
|
-
readonly include?: readonly string[];
|
|
137
|
-
/**
|
|
138
|
-
* Members left out, as exact names or glob patterns, e.g. a tool that rides
|
|
139
|
-
* the catalog but is not part of the release family. Wins over `include`.
|
|
140
|
-
*/
|
|
141
|
-
readonly exclude?: readonly string[];
|
|
142
|
-
/**
|
|
143
|
-
* How each selector is scoped. `"line"` (the default) qualifies the package
|
|
144
|
-
* name with its caret line, so only requests on that line are pinned;
|
|
145
|
-
* `"any"` emits the bare package name, which pins every request regardless
|
|
146
|
-
* of the line it asked for.
|
|
147
|
-
*/
|
|
148
|
-
readonly scope?: "line" | "any";
|
|
149
|
-
}
|
|
150
145
|
/**
|
|
151
146
|
* How a field's divergences are enforced: silent, console warning, or a thrown
|
|
152
147
|
* error that fails the install. Part of the public authoring API via
|
|
@@ -181,40 +176,54 @@ interface LocalDirective<T> {
|
|
|
181
176
|
readonly strategy?: "union" | "difference" | "merge" | "rewrite";
|
|
182
177
|
}
|
|
183
178
|
/**
|
|
184
|
-
*
|
|
185
|
-
* own catalogs in step with the workspace packages it ships beside (the
|
|
186
|
-
* members), moving each member's catalog entry to the version that member's
|
|
187
|
-
* next release will publish. Read statically by the CLI; the build and the
|
|
188
|
-
* shipped pnpmfile ignore it.
|
|
179
|
+
* Which workspace packages one sync pair owns.
|
|
189
180
|
*
|
|
190
181
|
* @public
|
|
191
182
|
*/
|
|
192
|
-
interface
|
|
193
|
-
/**
|
|
183
|
+
interface SyncMembers {
|
|
184
|
+
/**
|
|
185
|
+
* Glob over package names selecting the members, e.g. `"@effected/*"`.
|
|
186
|
+
* Must be non-empty and match at least one workspace package, or the
|
|
187
|
+
* membership check fails rather than passing on an empty set.
|
|
188
|
+
*/
|
|
189
|
+
readonly scope: string;
|
|
190
|
+
/**
|
|
191
|
+
* Globs over workspace-relative package paths (e.g. `"packages/*"`), not
|
|
192
|
+
* package names, narrowing which workspace packages are discovered. Omitted,
|
|
193
|
+
* every workspace package in the scope is considered.
|
|
194
|
+
*/
|
|
195
|
+
readonly packages?: readonly string[];
|
|
196
|
+
/** Package names or globs over package names left out of the scope. */
|
|
197
|
+
readonly exclude?: readonly string[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* One sync pair: a catalog and the workspace packages whose entries in it
|
|
201
|
+
* `sync` moves to their next release versions.
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
interface SyncPairConfig {
|
|
206
|
+
/** The catalog that names the members; `"default"` names the default catalog. */
|
|
194
207
|
readonly catalog: string;
|
|
195
|
-
/** Which workspace packages are synced
|
|
196
|
-
readonly members:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* package names, narrowing which workspace packages are discovered. Omitted,
|
|
206
|
-
* every workspace package in the scope is considered.
|
|
207
|
-
*/
|
|
208
|
-
readonly packages?: readonly string[];
|
|
209
|
-
/** Package names or globs over package names left out of the scope. */
|
|
210
|
-
readonly exclude?: readonly string[];
|
|
211
|
-
};
|
|
208
|
+
/** Which workspace packages are synced into `catalog`. */
|
|
209
|
+
readonly members: SyncMembers;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The settings every sync pair shares: one running list, one commit message,
|
|
213
|
+
* one floors switch and one `--local` check.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
interface SyncShared {
|
|
212
218
|
/** The running-list changeset (default `.changeset/catalog-sync.md`, bump `patch`). */
|
|
213
219
|
readonly changeset?: {
|
|
214
220
|
readonly path?: string;
|
|
215
221
|
readonly bump?: "patch" | "minor";
|
|
216
222
|
};
|
|
217
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* The commit message (file `.changeset/catalog-sync.commit.txt`). The scope
|
|
225
|
+
* defaults to the catalog name with one pair, and is required with more.
|
|
226
|
+
*/
|
|
218
227
|
readonly commit?: {
|
|
219
228
|
readonly scope?: string;
|
|
220
229
|
readonly messagePath?: string;
|
|
@@ -229,13 +238,40 @@ interface SyncConfig {
|
|
|
229
238
|
/**
|
|
230
239
|
* The `--local` check: the built pnpmfile (default `dist/prod/npm/pkg/pnpmfile.mjs`)
|
|
231
240
|
* and the catalogs to compare with `pnpm-workspace.yaml` (default: every
|
|
232
|
-
* served catalog except
|
|
241
|
+
* served catalog except each synced catalog and its `:peers` and `:exact`
|
|
242
|
+
* twins).
|
|
233
243
|
*/
|
|
234
244
|
readonly local?: {
|
|
235
245
|
readonly pnpmfile?: string;
|
|
236
246
|
readonly catalogs?: readonly string[];
|
|
237
247
|
};
|
|
238
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* The `sync` block: how `rolldown-pnpm-config sync` keeps the plugin's own
|
|
251
|
+
* catalogs in step with the workspace packages it ships beside (the members),
|
|
252
|
+
* moving each member's `source: "workspace"` entry to the version that
|
|
253
|
+
* member's next release will publish. Read statically by the CLI, and by the
|
|
254
|
+
* build only to refuse a workspace entry no pair owns; never shipped.
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* `catalogs` lists the pairs. `catalog` with `members` is shorthand for a
|
|
258
|
+
* one-pair list, and setting both forms fails. A package matching two pairs'
|
|
259
|
+
* scopes fails the membership check.
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
type SyncConfig = SyncShared & ({
|
|
264
|
+
/** The sync pairs, one per catalog. */
|
|
265
|
+
readonly catalogs: readonly [SyncPairConfig, ...SyncPairConfig[]];
|
|
266
|
+
readonly catalog?: never;
|
|
267
|
+
readonly members?: never;
|
|
268
|
+
} | {
|
|
269
|
+
/** Shorthand for a one-pair `catalogs`: the catalog that names the members. */
|
|
270
|
+
readonly catalog: string;
|
|
271
|
+
/** Shorthand for a one-pair `catalogs`: which workspace packages are synced. */
|
|
272
|
+
readonly members: SyncMembers;
|
|
273
|
+
readonly catalogs?: never;
|
|
274
|
+
});
|
|
239
275
|
/**
|
|
240
276
|
* The declarative plugin configuration.
|
|
241
277
|
*
|
|
@@ -250,7 +286,11 @@ interface PluginConfig {
|
|
|
250
286
|
* @public
|
|
251
287
|
*/
|
|
252
288
|
readonly name: string;
|
|
253
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* The catalogs to inject into pnpm config, keyed by catalog name. Each entry
|
|
291
|
+
* is a dependency string or `{ dependency, peer, source, exact }`; `range`,
|
|
292
|
+
* an entry-level `strategy` and `source: "registry"` fail the build.
|
|
293
|
+
*/
|
|
254
294
|
readonly catalogs: Record<string, CatalogDeclaration>;
|
|
255
295
|
/**
|
|
256
296
|
* Configuration for `rolldown-pnpm-config sync`. Read statically by the CLI;
|
|
@@ -272,7 +312,7 @@ interface PluginConfig {
|
|
|
272
312
|
* folder detection is independent and unaffected.
|
|
273
313
|
*/
|
|
274
314
|
readonly localPatchesDir?: string;
|
|
275
|
-
} & { readonly [K in Exclude<keyof PluginConfig, "name" | "local" | "
|
|
315
|
+
} & { readonly [K in Exclude<keyof PluginConfig, "name" | "local" | "sync">]?: PluginConfig[K] | LocalDirective<PluginConfig[K]>; };
|
|
276
316
|
/** Per-package manifest overrides merged into the dependency graph. */
|
|
277
317
|
readonly packageExtensions?: FieldInput<PnpmSettingType<"packageExtensions">>;
|
|
278
318
|
/** Deprecated versions explicitly allowed, keyed by package. */
|
|
@@ -311,16 +351,15 @@ interface PluginConfig {
|
|
|
311
351
|
* are the consumer's when set.
|
|
312
352
|
*/
|
|
313
353
|
readonly audit?: FieldInput<PnpmSettingType<"audit">>;
|
|
314
|
-
/** Security version overrides, keyed by package selector. */
|
|
315
|
-
readonly overrides?: FieldInput<Record<string, string>>;
|
|
316
354
|
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* `overrides` entry wins on a selector clash. Not a pnpm field itself.
|
|
355
|
+
* Security version overrides, keyed by package selector. Also accepts pnpm
|
|
356
|
+
* 12's nested form, `{ rules, unused? }`: `rules` ships as `overrides` and
|
|
357
|
+
* `unused` as `warnUnusedOverrides`. A catalog family's owner-scoped pins
|
|
358
|
+
* merge in beneath these, and an authored selector wins on a clash.
|
|
322
359
|
*/
|
|
323
|
-
readonly
|
|
360
|
+
readonly overrides?: FieldInput<PnpmSettingType<"overrides">>;
|
|
361
|
+
/** Whether pnpm warns about overrides no dependency matches; also written as `overrides.unused`. */
|
|
362
|
+
readonly warnUnusedOverrides?: FieldInput<PnpmSettingType<"warnUnusedOverrides">>;
|
|
324
363
|
/** Peer dependency rules: allowed versions plus ignore/allow-any lists. */
|
|
325
364
|
readonly peerDependencyRules?: FieldInput<{
|
|
326
365
|
readonly allowedVersions?: Record<string, string>;
|
|
@@ -352,8 +391,14 @@ interface PluginConfig {
|
|
|
352
391
|
* the managed one; the other keys are the consumer's when set.
|
|
353
392
|
*/
|
|
354
393
|
readonly update?: FieldInput<PnpmSettingType<"update">>;
|
|
355
|
-
/**
|
|
356
|
-
|
|
394
|
+
/**
|
|
395
|
+
* The default version catalog. Ships as `catalogs.default`, checked for
|
|
396
|
+
* divergence and discovered by `upgrade`: pnpm 12's nested form with
|
|
397
|
+
* `entries`, `mode`, `defaultSaveTarget` and `unused` keys is also
|
|
398
|
+
* accepted. It takes no `{ value, enforcement }` wrapper, and `:exact`,
|
|
399
|
+
* `:peers` and `families` need `catalogs.default`.
|
|
400
|
+
*/
|
|
401
|
+
readonly catalog?: PnpmSettingType<"catalog">;
|
|
357
402
|
/** Whether any resolution fails when a package violates minimum-release-age. */
|
|
358
403
|
readonly minimumReleaseAgeStrict?: FieldInput<PnpmSettingType<"minimumReleaseAgeStrict">>;
|
|
359
404
|
/** Whether to skip the release-age check when publish-time metadata is absent. */
|
|
@@ -477,6 +522,10 @@ interface PluginConfig {
|
|
|
477
522
|
readonly nodeDownloadMirrors?: FieldInput<PnpmSettingType<"nodeDownloadMirrors">>;
|
|
478
523
|
/** Controls how dependencies are resolved against entries defined in the catalogs field. */
|
|
479
524
|
readonly catalogMode?: FieldInput<PnpmSettingType<"catalogMode">>;
|
|
525
|
+
/** Whether pnpm prunes catalog entries no project uses; also written as `catalog.unused`. */
|
|
526
|
+
readonly catalogPrune?: FieldInput<PnpmSettingType<"catalogPrune">>;
|
|
527
|
+
/** The catalog a newly saved dependency goes into; also written as `catalog.defaultSaveTarget`. */
|
|
528
|
+
readonly saveCatalogName?: FieldInput<PnpmSettingType<"saveCatalogName">>;
|
|
480
529
|
/** Whether pnpm removes catalog entries that are not used by any project in the workspace. */
|
|
481
530
|
readonly cleanupUnusedCatalogs?: FieldInput<PnpmSettingType<"cleanupUnusedCatalogs">>;
|
|
482
531
|
/** Whether workspace packages are linked from the workspace, not downloaded from the registry. */
|
|
@@ -553,5 +602,5 @@ interface PluginConfig {
|
|
|
553
602
|
* @public
|
|
554
603
|
*/
|
|
555
604
|
export declare function PnpmConfigPlugin(config: PluginConfig): Plugin;
|
|
556
|
-
export type { AllowedVersionsFromCatalogs, CatalogDeclaration, CatalogPackageSpec, Enforcement, FieldInput, LocalDirective,
|
|
605
|
+
export type { AllowedVersionsFromCatalogs, CatalogDeclaration, CatalogFamily, CatalogPackageSpec, Enforcement, FieldInput, LocalDirective, PeerStrategy, PluginConfig, SyncConfig, SyncMembers, SyncPairConfig, SyncShared, VersionSource };
|
|
557
606
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-pnpm-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A dogfooding example of our plugin",
|
|
6
6
|
"repository": {
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@effect/platform-node": "4.1.7",
|
|
39
|
-
"@effected/changesets": "0.
|
|
39
|
+
"@effected/changesets": "0.12.0",
|
|
40
40
|
"@effected/cli-kit": "0.34.0",
|
|
41
41
|
"@effected/env": "0.12.0",
|
|
42
|
-
"@effected/files": "0.
|
|
42
|
+
"@effected/files": "0.7.0",
|
|
43
43
|
"@effected/glob": "0.23.1",
|
|
44
44
|
"@effected/npm": "0.35.1",
|
|
45
|
-
"@effected/pnpm": "0.
|
|
45
|
+
"@effected/pnpm": "0.2.0",
|
|
46
46
|
"@effected/semver": "0.24.0",
|
|
47
47
|
"@effected/walker": "0.33.0",
|
|
48
|
-
"@effected/workspaces": "0.49.
|
|
48
|
+
"@effected/workspaces": "0.49.6",
|
|
49
49
|
"@effected/yaml": "0.31.0",
|
|
50
50
|
"effect": "4.1.7",
|
|
51
51
|
"ink": "^8.0.0",
|
|
52
|
-
"oxc-parser": "^0.
|
|
52
|
+
"oxc-parser": "^0.161.0",
|
|
53
53
|
"react": "^19.3.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VersionSpecifier } from "@effected/semver";
|
|
2
2
|
import { Predicate, Result } from "effect";
|
|
3
|
-
import {
|
|
3
|
+
import { dependencyOf } from "../catalogs.js";
|
|
4
4
|
import { bareVersion } from "../semver-util.js";
|
|
5
5
|
|
|
6
6
|
// src/plugin/allowed-versions.ts
|
|
@@ -21,11 +21,11 @@ function deriveOne(catalogs, { catalog, peer, prefix }) {
|
|
|
21
21
|
if (decl === void 0) throw new Error(`allowedVersionsFromCatalogs: catalog "${catalog}" is not declared`);
|
|
22
22
|
const peerSpec = decl.packages[peer];
|
|
23
23
|
if (peerSpec === void 0) throw new Error(`allowedVersionsFromCatalogs: peer "${peer}" is not in catalog "${catalog}"`);
|
|
24
|
-
const value = applyPrefix(
|
|
24
|
+
const value = applyPrefix(dependencyOf(peerSpec), prefix);
|
|
25
25
|
const table = {};
|
|
26
26
|
for (const [name, spec] of Object.entries(decl.packages)) {
|
|
27
27
|
if (name === peer) continue;
|
|
28
|
-
const range =
|
|
28
|
+
const range = dependencyOf(spec);
|
|
29
29
|
if (!isExactVersion(range)) continue;
|
|
30
30
|
table[`${name}@${range}>${peer}`] = value;
|
|
31
31
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { GlobPattern } from "@effected/glob";
|
|
2
|
+
import { OverrideKey } from "@effected/pnpm";
|
|
3
|
+
import { Range, SemVer, VersionSpecifier } from "@effected/semver";
|
|
4
|
+
import { Option, Result } from "effect";
|
|
5
|
+
import { dependencyOf, sourceOf } from "../catalogs.js";
|
|
6
|
+
|
|
7
|
+
// src/plugin/families.ts
|
|
8
|
+
/**
|
|
9
|
+
* The entries one `members` or `exclude` list selects. Each problem (an
|
|
10
|
+
* invalid glob, an exact name that is no entry, a glob that matches none) is
|
|
11
|
+
* handed to `problem`: the build throws on it, so a typo fails instead of
|
|
12
|
+
* silently shrinking the family, while the CLI's static reading skips it.
|
|
13
|
+
*/
|
|
14
|
+
function select(patterns, entries, catalog, problem, list) {
|
|
15
|
+
const selected = /* @__PURE__ */ new Set();
|
|
16
|
+
for (const pattern of patterns) {
|
|
17
|
+
const compiled = GlobPattern.compileResult(pattern);
|
|
18
|
+
if (Result.isFailure(compiled)) {
|
|
19
|
+
problem(`${list} "${pattern}" is not a valid glob: ${compiled.failure.message}`);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const glob = compiled.success;
|
|
23
|
+
if (!glob.hasMagic) {
|
|
24
|
+
if (entries.includes(pattern)) selected.add(pattern);
|
|
25
|
+
else problem(`${list} "${pattern}" is not an entry of catalog "${catalog}"`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const matched = entries.filter((name) => glob.matches(name));
|
|
29
|
+
if (matched.length === 0) problem(`${list} glob "${pattern}" matches no entry of catalog "${catalog}"`);
|
|
30
|
+
for (const name of matched) selected.add(name);
|
|
31
|
+
}
|
|
32
|
+
return selected;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The package names of one catalog that each family claims, keyed by package:
|
|
36
|
+
* `members` expanded over `entries`, less `exclude`. Tolerant by design: an
|
|
37
|
+
* invalid glob or a name that is no entry selects nothing, because the CLI
|
|
38
|
+
* reads `families` statically and the build, not the CLI, reports the
|
|
39
|
+
* mistake. A package claimed twice keeps the first family; the build refuses
|
|
40
|
+
* that config anyway.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
function familyMembership(families, entries) {
|
|
45
|
+
const out = /* @__PURE__ */ new Map();
|
|
46
|
+
const ignore = () => {};
|
|
47
|
+
for (const family of families) {
|
|
48
|
+
const excluded = select(family.exclude ?? [], entries, "", ignore, "exclude");
|
|
49
|
+
for (const name of select(family.members, entries, "", ignore, "member")) if (!excluded.has(name) && !out.has(name)) out.set(name, family.name);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/** The plain version an exact dependency names, or `null` for any range, tag or operator. */
|
|
54
|
+
function exactVersionOf(dependency) {
|
|
55
|
+
const parsed = Result.getOrNull(VersionSpecifier.parseResult(dependency));
|
|
56
|
+
return parsed === null || parsed.operator !== "" ? null : parsed.version.toString();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve every catalog's `families`: expand `members` and `exclude` over the
|
|
60
|
+
* catalog's entries, check each member is locked (exact, not a workspace
|
|
61
|
+
* entry, in one family only), and generate one owner-scoped override per
|
|
62
|
+
* owner glob and member. Pure; throws an `Error` naming the catalog and
|
|
63
|
+
* family on any violation, which freeze reports as a `ConfigError`.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* Owners are emitted as pnpm parent selectors written as authored, globs
|
|
67
|
+
* included: pnpm 12.24 matches `own-*>is-number` against a parent named
|
|
68
|
+
* `own-a` (measured), so no expansion is needed. The override pins regular
|
|
69
|
+
* dependency edges only; pnpm never applies one to a peer edge.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function resolveFamilies(catalogs) {
|
|
74
|
+
const members = /* @__PURE__ */ new Map();
|
|
75
|
+
const overrides = {};
|
|
76
|
+
const names = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const [catalog, decl] of Object.entries(catalogs)) {
|
|
78
|
+
if (typeof decl !== "object" || decl === null || typeof decl.packages !== "object" || decl.packages === null) continue;
|
|
79
|
+
if (decl.families === void 0) continue;
|
|
80
|
+
if (!Array.isArray(decl.families)) throw new Error(`catalogs: families of catalog "${catalog}" is not a list`);
|
|
81
|
+
const entries = Object.keys(decl.packages);
|
|
82
|
+
for (const family of decl.families) {
|
|
83
|
+
const at = `catalogs: family "${family?.name}" in catalog "${catalog}"`;
|
|
84
|
+
if (typeof family?.name !== "string" || family.name === "") throw new Error(`catalogs: a family in catalog "${catalog}" has no name`);
|
|
85
|
+
const declaredIn = names.get(family.name);
|
|
86
|
+
if (declaredIn === catalog) throw new Error(`${at}: family "${family.name}" is declared twice`);
|
|
87
|
+
if (declaredIn !== void 0) throw new Error(`catalogs: family "${family.name}" is declared in catalog "${declaredIn}" and catalog "${catalog}"; a family name is unique across the config`);
|
|
88
|
+
names.set(family.name, catalog);
|
|
89
|
+
for (const key of [
|
|
90
|
+
"members",
|
|
91
|
+
"exclude",
|
|
92
|
+
"owners"
|
|
93
|
+
]) {
|
|
94
|
+
if (key !== "members" && family[key] === void 0) continue;
|
|
95
|
+
if (!Array.isArray(family[key])) throw new Error(`${at}: ${key} is not a list`);
|
|
96
|
+
}
|
|
97
|
+
const fail = (message) => {
|
|
98
|
+
throw new Error(`${at}: ${message}`);
|
|
99
|
+
};
|
|
100
|
+
const excluded = select(family.exclude ?? [], entries, catalog, fail, "exclude");
|
|
101
|
+
const chosen = [...select(family.members, entries, catalog, fail, "member")].filter((name) => !excluded.has(name));
|
|
102
|
+
if (chosen.length === 0) throw new Error(`${at}: the family has no members once exclude applies`);
|
|
103
|
+
const locked = [];
|
|
104
|
+
for (const name of chosen) {
|
|
105
|
+
const spec = decl.packages[name];
|
|
106
|
+
const prior = members.get(name);
|
|
107
|
+
if (prior !== void 0) throw new Error(`catalogs: "${name}" is in family "${prior.family}" (catalog "${prior.catalog}") and family "${family.name}" (catalog "${catalog}"); a package belongs to one family`);
|
|
108
|
+
if (sourceOf(spec) === "workspace") throw new Error(`${at}: member "${name}" in catalog "${catalog}" has source "workspace", which sync moves; a locked family member cannot be a workspace entry`);
|
|
109
|
+
const dependency = dependencyOf(spec);
|
|
110
|
+
const version = exactVersionOf(dependency);
|
|
111
|
+
if (version === null) throw new Error(`${at}: member "${name}" has dependency "${dependency}", which is not an exact version; a family member must be exact`);
|
|
112
|
+
members.set(name, {
|
|
113
|
+
catalog,
|
|
114
|
+
family: family.name,
|
|
115
|
+
version
|
|
116
|
+
});
|
|
117
|
+
locked.push([name, version]);
|
|
118
|
+
}
|
|
119
|
+
for (const owner of family.owners ?? []) for (const [name, version] of locked) overrides[`${owner}>${name}`] = version;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
members,
|
|
124
|
+
overrides
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The canonical spelling of an `overrides` key, so `" own>effect"` and
|
|
129
|
+
* `"own>effect"` are recognised as one selector; a key pnpm cannot parse is
|
|
130
|
+
* kept as written (the settings schema refuses it later).
|
|
131
|
+
*/
|
|
132
|
+
function canonicalSelector(key) {
|
|
133
|
+
const parsed = OverrideKey.parseResult(key);
|
|
134
|
+
return Result.isSuccess(parsed) ? parsed.success.format() : key;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Merge the family-generated overrides under the authored ones. An authored
|
|
138
|
+
* selector wins even when it spells a generated one differently: the
|
|
139
|
+
* generated entry is dropped, so pnpm never sees one selector twice.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
function mergeOverrides(authored, generated) {
|
|
144
|
+
const authoredSelectors = new Set(Object.keys(authored).map(canonicalSelector));
|
|
145
|
+
const kept = Object.entries(generated).filter(([key]) => !authoredSelectors.has(canonicalSelector(key)));
|
|
146
|
+
return {
|
|
147
|
+
...Object.fromEntries(kept),
|
|
148
|
+
...authored
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Whether a selector's range admits the version; a range or version that does not parse is assumed to. */
|
|
152
|
+
function reaches(range, version) {
|
|
153
|
+
const parsedRange = Range.parseResult(range);
|
|
154
|
+
const parsedVersion = SemVer.parseResult(version);
|
|
155
|
+
if (Result.isFailure(parsedRange) || Result.isFailure(parsedVersion)) return true;
|
|
156
|
+
return Range.satisfies(parsedVersion.success, parsedRange.success);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The first authored `overrides` entry that contradicts a family: a global
|
|
160
|
+
* selector (no parent) whose target is a family member and whose value is not
|
|
161
|
+
* that member's exact version, as a message naming the selector, the family
|
|
162
|
+
* and the version, or `undefined` when there is none. A global override
|
|
163
|
+
* applies to every edge, the consumer's own `catalog:` dependency included, so
|
|
164
|
+
* it would serve a version the family does not lock. A parent-scoped selector
|
|
165
|
+
* (`@effect/platform-node@4.0.0-rc.118>@effect/platform-node-shared`) is the
|
|
166
|
+
* author's deliberate exception for one parent and is never refused; a key
|
|
167
|
+
* pnpm cannot parse is left to the settings schema. A target whose version
|
|
168
|
+
* range excludes the member's locked version (`effect@3` over 4.1.7) can never
|
|
169
|
+
* reach the locked copy and is not refused.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
function contradictingOverride(authored, members) {
|
|
174
|
+
for (const [key, value] of Object.entries(authored)) {
|
|
175
|
+
const parsed = OverrideKey.parseResult(key);
|
|
176
|
+
if (Result.isFailure(parsed) || Option.isSome(parsed.success.parent)) continue;
|
|
177
|
+
const member = members.get(parsed.success.target.name);
|
|
178
|
+
if (member === void 0 || value === member.version) continue;
|
|
179
|
+
const range = Option.getOrUndefined(parsed.success.target.range);
|
|
180
|
+
if (range !== void 0 && !reaches(range, member.version)) continue;
|
|
181
|
+
return `overrides: "${key}": "${value}" pins family member "${parsed.success.target.name}" on every edge, but family "${member.family}" (catalog "${member.catalog}") locks it at ${member.version}: write "${member.version}", or scope the override to a parent (\`<parent>>${parsed.success.target.name}\`)`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { contradictingOverride, familyMembership, mergeOverrides, resolveFamilies };
|