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.
- 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 +143 -79
- package/cli/commands/upgrade.js +333 -135
- package/cli/discover.js +134 -28
- package/cli/drift.js +1 -1
- package/cli/edits.js +8 -17
- package/cli/effective.js +119 -4
- package/cli/interop.js +7 -15
- package/cli/local-merge.js +4 -1
- package/cli/plan.js +8 -3
- package/cli/preview-views.js +3 -1
- package/cli/release-age.js +2 -1
- package/cli/render/print.js +2 -5
- package/cli/render/report.js +2 -4
- package/cli/respell.js +86 -0
- package/cli/select-file.js +5 -2
- package/cli/summary.js +43 -9
- package/cli/sync/commit-message.js +4 -3
- package/cli/sync/config.js +60 -24
- package/cli/sync/floors.js +6 -3
- 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 +16 -6
- 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/index.d.ts +176 -127
- package/package.json +8 -8
- package/plugin/allowed-versions.js +3 -3
- package/plugin/families.js +185 -0
- package/plugin/freeze.js +122 -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 +109 -12
- package/skills/rolldown-pnpm-config/references/options.md +126 -47
- package/skills/rolldown-pnpm-config/references/sync.md +32 -21
- package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
- package/plugin/overrides-from-catalogs.js +0 -151
package/cli/discover.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import { REWRITABLE_RANGE_RE } from "../catalogs.js";
|
|
4
|
+
import { familyMembership } from "../plugin/families.js";
|
|
4
5
|
import { findPluginArg, keyName, prop } from "./ast.js";
|
|
5
6
|
|
|
6
7
|
// src/cli/discover.ts
|
|
@@ -10,6 +11,64 @@ import { findPluginArg, keyName, prop } from "./ast.js";
|
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
13
|
var DiscoverError = class extends Data.TaggedError("DiscoverError") {};
|
|
14
|
+
/**
|
|
15
|
+
* The string literals of an array literal. `complete` is false when the list
|
|
16
|
+
* is not an array literal or holds anything else (a spread, an identifier, a
|
|
17
|
+
* call), since the names behind it cannot be known statically.
|
|
18
|
+
*/
|
|
19
|
+
function stringList(node) {
|
|
20
|
+
if (node === void 0) return {
|
|
21
|
+
values: [],
|
|
22
|
+
complete: true
|
|
23
|
+
};
|
|
24
|
+
if (node.type !== "ArrayExpression") return {
|
|
25
|
+
values: [],
|
|
26
|
+
complete: false
|
|
27
|
+
};
|
|
28
|
+
const elements = node.elements ?? [];
|
|
29
|
+
const values = elements.flatMap((el) => el?.type === "Literal" && typeof el.value === "string" ? [el.value] : []);
|
|
30
|
+
return {
|
|
31
|
+
values,
|
|
32
|
+
complete: values.length === elements.length
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read one catalog's `families` literal: each family whose `name` is a string
|
|
37
|
+
* literal, with the string literals of its `members` and `exclude`. A family
|
|
38
|
+
* written any other way is not read (the build still checks it), and
|
|
39
|
+
* `complete` is false so a caller can say the list could not be read
|
|
40
|
+
* statically rather than that it declares nothing.
|
|
41
|
+
*/
|
|
42
|
+
function readFamilies(decl) {
|
|
43
|
+
const list = prop(decl, "families");
|
|
44
|
+
if (list === void 0) return {
|
|
45
|
+
families: [],
|
|
46
|
+
complete: true
|
|
47
|
+
};
|
|
48
|
+
if (list.type !== "ArrayExpression") return {
|
|
49
|
+
families: [],
|
|
50
|
+
complete: false
|
|
51
|
+
};
|
|
52
|
+
let complete = true;
|
|
53
|
+
return {
|
|
54
|
+
families: (list.elements ?? []).flatMap((el) => {
|
|
55
|
+
const name = el?.type === "ObjectExpression" ? prop(el, "name") : void 0;
|
|
56
|
+
if (el?.type !== "ObjectExpression" || name?.type !== "Literal" || typeof name.value !== "string") {
|
|
57
|
+
complete = false;
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const members = stringList(prop(el, "members"));
|
|
61
|
+
const exclude = stringList(prop(el, "exclude"));
|
|
62
|
+
if (!members.complete || !exclude.complete) complete = false;
|
|
63
|
+
return [{
|
|
64
|
+
name: name.value,
|
|
65
|
+
members: members.values,
|
|
66
|
+
exclude: exclude.values
|
|
67
|
+
}];
|
|
68
|
+
}),
|
|
69
|
+
complete
|
|
70
|
+
};
|
|
71
|
+
}
|
|
13
72
|
function operatorOf(range) {
|
|
14
73
|
if (range.startsWith("^")) return "^";
|
|
15
74
|
if (range.startsWith("~")) return "~";
|
|
@@ -17,10 +76,22 @@ function operatorOf(range) {
|
|
|
17
76
|
}
|
|
18
77
|
/**
|
|
19
78
|
* Statically discover the catalog version literals in a config source. Locates
|
|
20
|
-
* the single `PnpmConfigPlugin(...)` call and walks `.catalogs.<name>.packages
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
79
|
+
* the single `PnpmConfigPlugin(...)` call and walks `.catalogs.<name>.packages`
|
|
80
|
+
* plus the `catalog` property (flat, or under `entries`), reported as `default`.
|
|
81
|
+
* Each package whose `dependency` (or bare string) is a simple-operator string
|
|
82
|
+
* literal yields a CatalogEntry with byte-offset spans, reading `peer` as a
|
|
83
|
+
* hand-set string or as `{ value, strategy }` (the span then covers `value`
|
|
84
|
+
* alone) and the entry's `source`; anything else (computed value, complex
|
|
85
|
+
* range, a peer with no string literal, an entry still written with `range`)
|
|
86
|
+
* is reported in `skipped` as
|
|
87
|
+
* `<catalog>.<pkg>` and never throws.
|
|
88
|
+
* Each entry also carries the `family` that locks it, read statically from
|
|
89
|
+
* its catalog's `families` (string literals only) and expanded over the
|
|
90
|
+
* catalog's package names by `familyMembership`; `families` names every
|
|
91
|
+
* family so read, in source order, so `--family` can tell a typo, and
|
|
92
|
+
* `unreadFamilies` names each catalog whose `families` could not be read
|
|
93
|
+
* statically: a non-literal `families`, family or name, or a `members` or
|
|
94
|
+
* `exclude` list with any non-literal element.
|
|
24
95
|
* `catalogs` names every declared catalog in source order, including one
|
|
25
96
|
* that yields no entries, so `--catalog` can tell an empty catalog from a
|
|
26
97
|
* typo. `skippedRefs` carries the same skips as `{ catalog, pkg }` pairs, so
|
|
@@ -36,25 +107,9 @@ function discoverCatalogEntries(source, filename) {
|
|
|
36
107
|
const entries = [];
|
|
37
108
|
const skippedRefs = [];
|
|
38
109
|
const declared = [];
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
skippedRefs,
|
|
43
|
-
catalogs: declared
|
|
44
|
-
});
|
|
45
|
-
const arg = findPluginArg(program);
|
|
46
|
-
if (!arg) return finish();
|
|
47
|
-
const catalogs = prop(arg, "catalogs");
|
|
48
|
-
if (catalogs?.type !== "ObjectExpression") return finish();
|
|
49
|
-
for (const catProp of catalogs.properties ?? []) {
|
|
50
|
-
if (catProp.type !== "Property") continue;
|
|
51
|
-
const catalog = keyName(catProp.key);
|
|
52
|
-
if (catalog === void 0) continue;
|
|
53
|
-
declared.push(catalog);
|
|
54
|
-
const decl = catProp.value;
|
|
55
|
-
if (decl.type !== "ObjectExpression") continue;
|
|
56
|
-
const packages = prop(decl, "packages");
|
|
57
|
-
if (packages?.type !== "ObjectExpression") continue;
|
|
110
|
+
const declaredFamilies = [];
|
|
111
|
+
const unreadFamilies = [];
|
|
112
|
+
const walkPackages = (catalog, packages, membership = /* @__PURE__ */ new Map()) => {
|
|
58
113
|
for (const pkgProp of packages.properties ?? []) {
|
|
59
114
|
if (pkgProp.type !== "Property") continue;
|
|
60
115
|
const pkg = keyName(pkgProp.key);
|
|
@@ -66,14 +121,25 @@ function discoverCatalogEntries(source, filename) {
|
|
|
66
121
|
let source;
|
|
67
122
|
if (value.type === "Literal" && typeof value.value === "string") rangeNode = value;
|
|
68
123
|
else if (value.type === "ObjectExpression") {
|
|
69
|
-
const r = prop(value, "
|
|
124
|
+
const r = prop(value, "dependency");
|
|
70
125
|
if (r?.type === "Literal" && typeof r.value === "string") rangeNode = r;
|
|
71
126
|
const p = prop(value, "peer");
|
|
72
127
|
if (p?.type === "Literal" && typeof p.value === "string") peerNode = p;
|
|
73
|
-
|
|
74
|
-
|
|
128
|
+
else if (p?.type === "ObjectExpression") {
|
|
129
|
+
const v = prop(p, "value");
|
|
130
|
+
if (v?.type === "Literal" && typeof v.value === "string") peerNode = v;
|
|
131
|
+
const s = prop(p, "strategy");
|
|
132
|
+
if (s?.type === "Literal" && (s.value === "lock" || s.value === "lock-minor" || s.value === "interop")) strategy = s.value;
|
|
133
|
+
}
|
|
134
|
+
if (p !== void 0 && peerNode === void 0) {
|
|
135
|
+
skippedRefs.push({
|
|
136
|
+
catalog,
|
|
137
|
+
pkg
|
|
138
|
+
});
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
75
141
|
const src = prop(value, "source");
|
|
76
|
-
if (src?.type === "Literal" && (src.value === "
|
|
142
|
+
if (src?.type === "Literal" && (src.value === "npm" || src.value === "workspace")) source = src.value;
|
|
77
143
|
}
|
|
78
144
|
if (!rangeNode || !REWRITABLE_RANGE_RE.test(rangeNode.value)) {
|
|
79
145
|
skippedRefs.push({
|
|
@@ -83,6 +149,7 @@ function discoverCatalogEntries(source, filename) {
|
|
|
83
149
|
continue;
|
|
84
150
|
}
|
|
85
151
|
const currentRange = rangeNode.value;
|
|
152
|
+
const family = membership.get(pkg);
|
|
86
153
|
entries.push({
|
|
87
154
|
catalog,
|
|
88
155
|
pkg,
|
|
@@ -94,9 +161,48 @@ function discoverCatalogEntries(source, filename) {
|
|
|
94
161
|
span: [peerNode.start, peerNode.end]
|
|
95
162
|
} } : {},
|
|
96
163
|
...strategy ? { strategy } : {},
|
|
97
|
-
...source ? { source } : {}
|
|
164
|
+
...source ? { source } : {},
|
|
165
|
+
...family !== void 0 ? { family } : {}
|
|
98
166
|
});
|
|
99
167
|
}
|
|
168
|
+
};
|
|
169
|
+
const finish = () => ({
|
|
170
|
+
entries,
|
|
171
|
+
skipped: skippedRefs.map((r) => `${r.catalog}.${r.pkg}`),
|
|
172
|
+
skippedRefs,
|
|
173
|
+
catalogs: declared,
|
|
174
|
+
families: declaredFamilies,
|
|
175
|
+
unreadFamilies
|
|
176
|
+
});
|
|
177
|
+
const arg = findPluginArg(program);
|
|
178
|
+
if (!arg) return finish();
|
|
179
|
+
const catalogs = prop(arg, "catalogs");
|
|
180
|
+
if (catalogs?.type === "ObjectExpression") for (const catProp of catalogs.properties ?? []) {
|
|
181
|
+
if (catProp.type !== "Property") continue;
|
|
182
|
+
const catalog = keyName(catProp.key);
|
|
183
|
+
if (catalog === void 0) continue;
|
|
184
|
+
declared.push(catalog);
|
|
185
|
+
const decl = catProp.value;
|
|
186
|
+
if (decl.type !== "ObjectExpression") continue;
|
|
187
|
+
const packages = prop(decl, "packages");
|
|
188
|
+
if (packages?.type !== "ObjectExpression") continue;
|
|
189
|
+
const { families, complete } = readFamilies(decl);
|
|
190
|
+
declaredFamilies.push(...families.map((f) => f.name));
|
|
191
|
+
if (!complete) unreadFamilies.push(catalog);
|
|
192
|
+
const names = (packages.properties ?? []).flatMap((p) => {
|
|
193
|
+
const name = p.type === "Property" ? keyName(p.key) : void 0;
|
|
194
|
+
return name === void 0 ? [] : [name];
|
|
195
|
+
});
|
|
196
|
+
walkPackages(catalog, packages, familyMembership(families, names));
|
|
197
|
+
}
|
|
198
|
+
const defaultCatalog = prop(arg, "catalog");
|
|
199
|
+
if (defaultCatalog?.type === "ObjectExpression") {
|
|
200
|
+
const section = prop(defaultCatalog, "entries");
|
|
201
|
+
const packages = section === void 0 || section.type === "Literal" ? defaultCatalog : section.type === "ObjectExpression" ? section : void 0;
|
|
202
|
+
if (packages !== void 0) {
|
|
203
|
+
if (!declared.includes("default")) declared.push("default");
|
|
204
|
+
walkPackages("default", packages);
|
|
205
|
+
}
|
|
100
206
|
}
|
|
101
207
|
return finish();
|
|
102
208
|
}
|
package/cli/drift.js
CHANGED
|
@@ -12,7 +12,7 @@ import { derivePeerRange } from "./peer-range.js";
|
|
|
12
12
|
* GROUP-WISE by `interop.ts` from the resolved peerDependencies of the whole
|
|
13
13
|
* catalog group. Deriving one per package here would fall through to the
|
|
14
14
|
* lock-minor branch and report a bogus resync target, so interop entries are
|
|
15
|
-
* excluded — parity with
|
|
15
|
+
* excluded — parity with the peer-warning derivation in walk-plan.ts.
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
package/cli/edits.js
CHANGED
|
@@ -4,8 +4,7 @@ import { versionKeyOf } from "./version-key.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* The edit constructors for one entry, each tagged with the entry's package
|
|
6
6
|
* and route-aware version key so `validateEdits` can check it against the
|
|
7
|
-
* registry before it is written. The single place that knows the
|
|
8
|
-
* syntax and the key routing — both the interactive and the `--yes` paths
|
|
7
|
+
* registry before it is written. The single place that knows the key routing — both the interactive and the `--yes` paths
|
|
9
8
|
* build their edits through it.
|
|
10
9
|
*
|
|
11
10
|
* @internal
|
|
@@ -13,7 +12,7 @@ import { versionKeyOf } from "./version-key.js";
|
|
|
13
12
|
function entryEdits(entry) {
|
|
14
13
|
const pkg = entry.pkg;
|
|
15
14
|
const versionKey = versionKeyOf(entry);
|
|
16
|
-
const
|
|
15
|
+
const peer = entry.peer;
|
|
17
16
|
return {
|
|
18
17
|
range: (value) => ({
|
|
19
18
|
span: entry.rangeSpan,
|
|
@@ -23,26 +22,19 @@ function entryEdits(entry) {
|
|
|
23
22
|
kind: "range",
|
|
24
23
|
value
|
|
25
24
|
}),
|
|
26
|
-
setPeer: (value) =>
|
|
27
|
-
span:
|
|
25
|
+
setPeer: peer === void 0 ? void 0 : (value) => ({
|
|
26
|
+
span: peer.span,
|
|
28
27
|
text: JSON.stringify(value),
|
|
29
28
|
pkg,
|
|
30
29
|
versionKey,
|
|
31
30
|
kind: "peer",
|
|
32
31
|
value
|
|
33
|
-
}
|
|
34
|
-
span: [insertAt, insertAt],
|
|
35
|
-
text: `, peer: ${JSON.stringify(value)}`,
|
|
36
|
-
pkg,
|
|
37
|
-
versionKey,
|
|
38
|
-
kind: "peer",
|
|
39
|
-
value
|
|
40
|
-
}
|
|
32
|
+
})
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
35
|
/**
|
|
44
36
|
* Convert resolved decisions into span edits. A chosen upgrade rewrites the
|
|
45
|
-
*
|
|
37
|
+
* dependency literal (and the existing peer literal when the candidate carries a
|
|
46
38
|
* recomputed peerRange). A keep with peer drift rewrites only the peer literal
|
|
47
39
|
* to the resync target.
|
|
48
40
|
*
|
|
@@ -58,9 +50,8 @@ function buildEdits(decisions) {
|
|
|
58
50
|
const { range, setPeer } = entryEdits(entry);
|
|
59
51
|
if (chosen.kind !== "keep") {
|
|
60
52
|
edits.push(range(chosen.range));
|
|
61
|
-
if (chosen.peerRange &&
|
|
62
|
-
} else if (
|
|
63
|
-
else if (!entry.peer && item.materializePeer) edits.push(setPeer(item.materializePeer));
|
|
53
|
+
if (chosen.peerRange && setPeer) edits.push(setPeer(chosen.peerRange));
|
|
54
|
+
} else if (setPeer && item.driftPeer) edits.push(setPeer(item.driftPeer));
|
|
64
55
|
}
|
|
65
56
|
return edits;
|
|
66
57
|
}
|
package/cli/effective.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Predicate } from "effect";
|
|
2
|
+
import { desugarSecondForms } from "../plugin/second-forms.js";
|
|
1
3
|
import { WORKSPACE_FIELDS } from "../registry.js";
|
|
2
4
|
import { excludeByRepo } from "../runtime/ctx.js";
|
|
3
|
-
import { MAP_EXPORT_FIELDS, UNION_EXPORT_FIELDS, applyLocalDirective } from "./local-merge.js";
|
|
5
|
+
import { MAP_EXPORT_FIELDS, UNION_EXPORT_FIELDS, applyLocalDirective, isLocalDirective } from "./local-merge.js";
|
|
4
6
|
|
|
5
7
|
// src/cli/effective.ts
|
|
6
8
|
/** Apply the manifest's excludeByRepo refine to publicHoistPattern, if present. */
|
|
@@ -9,6 +11,87 @@ function applyExcludeByRepo(out, manifest, rootName) {
|
|
|
9
11
|
const phl = out.publicHoistPattern;
|
|
10
12
|
if (byRepo && typeof byRepo === "object" && Array.isArray(phl)) out.publicHoistPattern = excludeByRepo(phl, { rootName }, byRepo);
|
|
11
13
|
}
|
|
14
|
+
/** `Predicate.isObject` already refuses arrays; this only narrows to a string-keyed record. */
|
|
15
|
+
const isMap = (v) => Predicate.isObject(v);
|
|
16
|
+
/** True when a `local.catalogs` value (a map of catalogs or an array of names) names `default`. */
|
|
17
|
+
function namesDefault(value) {
|
|
18
|
+
return Array.isArray(value) ? value.map(String).includes("default") : isMap(value) && value.default !== void 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Desugar `local`'s second forms in the plain-map shape `local.catalogs`
|
|
22
|
+
* already has. A `{ value, strategy, preserve }` directive on `overrides` or
|
|
23
|
+
* `catalogs` is desugared inside its `value`. `local.catalog` (bare or a
|
|
24
|
+
* directive) is desugared on its own and held apart: it acts on the default
|
|
25
|
+
* catalog only, after `local.catalogs` has been applied, so the two compose.
|
|
26
|
+
* Both naming the default catalog is refused.
|
|
27
|
+
*/
|
|
28
|
+
function desugarLocal(local) {
|
|
29
|
+
const directives = {};
|
|
30
|
+
const { catalog: rawCatalog, ...rest } = local;
|
|
31
|
+
const unwrapped = { ...rest };
|
|
32
|
+
for (const field of ["overrides", "catalogs"]) if (isLocalDirective(local[field])) {
|
|
33
|
+
const directive = local[field];
|
|
34
|
+
directives[field] = directive;
|
|
35
|
+
if ("value" in directive) unwrapped[field] = directive.value;
|
|
36
|
+
else delete unwrapped[field];
|
|
37
|
+
}
|
|
38
|
+
let defaultCatalog;
|
|
39
|
+
if (rawCatalog !== void 0 && rawCatalog !== null) {
|
|
40
|
+
const directive = isLocalDirective(rawCatalog) ? { ...rawCatalog } : { value: rawCatalog };
|
|
41
|
+
if (namesDefault(unwrapped.catalogs)) throw new Error("local: catalog and catalogs.default both declare the default catalog; keep one of them.");
|
|
42
|
+
if (directive.value !== void 0 && !Array.isArray(directive.value)) unwrapped.catalog = directive.value;
|
|
43
|
+
defaultCatalog = directive;
|
|
44
|
+
}
|
|
45
|
+
const catalogs = unwrapped.catalogs;
|
|
46
|
+
delete unwrapped.catalogs;
|
|
47
|
+
const fields = desugarSecondForms(unwrapped, "local", { catalogShape: "map" });
|
|
48
|
+
if (defaultCatalog !== void 0 && "catalog" in unwrapped) defaultCatalog.value = isMap(fields.catalogs) ? fields.catalogs.default : {};
|
|
49
|
+
delete fields.catalogs;
|
|
50
|
+
if (catalogs !== void 0) fields.catalogs = catalogs;
|
|
51
|
+
for (const [field, directive] of Object.entries(directives)) fields[field] = fields[field] === void 0 ? directive : {
|
|
52
|
+
...directive,
|
|
53
|
+
value: fields[field]
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
fields,
|
|
57
|
+
defaultCatalog
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The default catalog's packages after `local.catalog`, with the file's own
|
|
62
|
+
* entries kept under the result. Each strategy gives what it gave when
|
|
63
|
+
* `catalog` was a map field merged with the file:
|
|
64
|
+
* - `union` / `merge`: the local packages laid over the managed ones;
|
|
65
|
+
* - `difference`: the listed packages (an array of names, or a map's keys)
|
|
66
|
+
* removed from the managed and file entries together;
|
|
67
|
+
* - `rewrite`: the managed catalog alone, the file's own entries dropped;
|
|
68
|
+
* - a bare value: the managed catalog replaced by it.
|
|
69
|
+
* With no directive, or one with no value, the managed catalog passes through.
|
|
70
|
+
* `undefined` means nothing to write.
|
|
71
|
+
*/
|
|
72
|
+
function defaultCatalogOf(managed, directive, file) {
|
|
73
|
+
const keepFile = (value) => isMap(file) && (value === void 0 || isMap(value)) ? {
|
|
74
|
+
...file,
|
|
75
|
+
...value ?? {}
|
|
76
|
+
} : value;
|
|
77
|
+
const strategy = directive?.strategy === "merge" ? "union" : directive?.strategy;
|
|
78
|
+
const value = directive?.value;
|
|
79
|
+
if (strategy === "rewrite") return managed;
|
|
80
|
+
if (value === void 0) return keepFile(managed);
|
|
81
|
+
if (strategy === "union") return keepFile({
|
|
82
|
+
...isMap(managed) ? managed : {},
|
|
83
|
+
...isMap(value) ? value : {}
|
|
84
|
+
});
|
|
85
|
+
if (strategy === "difference") {
|
|
86
|
+
const base = keepFile(managed);
|
|
87
|
+
if (!isMap(base)) return void 0;
|
|
88
|
+
const out = { ...base };
|
|
89
|
+
const names = Array.isArray(value) ? value.map(String) : isMap(value) ? Object.keys(value) : [];
|
|
90
|
+
for (const name of names) delete out[name];
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
return keepFile(value);
|
|
94
|
+
}
|
|
12
95
|
/**
|
|
13
96
|
* Compute the effective workspace fields for THIS repo: managed base, then
|
|
14
97
|
* excludeByRepo on publicHoistPattern, then per-field local directives.
|
|
@@ -16,24 +99,56 @@ function applyExcludeByRepo(out, manifest, rootName) {
|
|
|
16
99
|
* Union- and map-strategy fields also keep the existing file's entries unless `rewrite`.
|
|
17
100
|
* Only `local` keys that are managed workspace settings apply: a plugin-only
|
|
18
101
|
* key (`localPatchesDir`) or any other non-setting never reaches the yaml.
|
|
102
|
+
* pnpm 12's nested `overrides` and `catalog` forms in `local` and in the file
|
|
103
|
+
* are desugared first, so every merge sees flat maps and the default catalog
|
|
104
|
+
* as `catalogs.default`; `respellForFile` writes them back in the file's form.
|
|
105
|
+
* The default catalog is laid over the file's own per package (managed wins on
|
|
106
|
+
* a shared key), after `local.catalog` acts on it; named catalogs still
|
|
107
|
+
* replace by name in the overlay.
|
|
108
|
+
*
|
|
109
|
+
* @throws `Error` when `local` sets a nested sub-key beside its twin setting,
|
|
110
|
+
* when `local` or the file sets `catalog` beside `catalogs.default`, or when
|
|
111
|
+
* pnpm would refuse a section option.
|
|
19
112
|
*
|
|
20
113
|
* @internal
|
|
21
114
|
*/
|
|
22
115
|
function effectiveManaged(managed, local, parsed, manifest, rootName) {
|
|
23
116
|
const out = { ...managed };
|
|
24
117
|
applyExcludeByRepo(out, manifest, rootName);
|
|
25
|
-
const
|
|
26
|
-
|
|
118
|
+
const { fields: flatLocal, defaultCatalog } = local === void 0 ? {
|
|
119
|
+
fields: void 0,
|
|
120
|
+
defaultCatalog: void 0
|
|
121
|
+
} : desugarLocal(local);
|
|
122
|
+
const flatParsed = desugarSecondForms(parsed, "pnpm-workspace.yaml", {
|
|
123
|
+
catalogShape: "map",
|
|
124
|
+
twinConflict: "nestedWins"
|
|
125
|
+
});
|
|
126
|
+
const keepFileFields = [...UNION_EXPORT_FIELDS, ...MAP_EXPORT_FIELDS].filter((f) => f in out || f in flatParsed);
|
|
127
|
+
const localFields = Object.keys(flatLocal ?? {}).filter((f) => WORKSPACE_FIELDS.has(f));
|
|
27
128
|
const fields = /* @__PURE__ */ new Set([
|
|
28
129
|
"overrides",
|
|
29
130
|
...keepFileFields,
|
|
30
131
|
...localFields
|
|
31
132
|
]);
|
|
32
133
|
for (const field of fields) {
|
|
33
|
-
const next = applyLocalDirective(out[field],
|
|
134
|
+
const next = applyLocalDirective(out[field], flatLocal?.[field], flatParsed[field], field);
|
|
34
135
|
if (next === void 0) delete out[field];
|
|
35
136
|
else out[field] = next;
|
|
36
137
|
}
|
|
138
|
+
const catalogs = isMap(out.catalogs) ? out.catalogs : {};
|
|
139
|
+
const fileCatalogs = isMap(flatParsed.catalogs) ? flatParsed.catalogs : {};
|
|
140
|
+
if (catalogs.default !== void 0 || defaultCatalog !== void 0) {
|
|
141
|
+
const next = defaultCatalogOf(catalogs.default, defaultCatalog, fileCatalogs.default);
|
|
142
|
+
if (next !== void 0) out.catalogs = {
|
|
143
|
+
...catalogs,
|
|
144
|
+
default: next
|
|
145
|
+
};
|
|
146
|
+
else {
|
|
147
|
+
const { default: _, ...named } = catalogs;
|
|
148
|
+
if (Object.keys(named).length > 0) out.catalogs = named;
|
|
149
|
+
else delete out.catalogs;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
37
152
|
return out;
|
|
38
153
|
}
|
|
39
154
|
/**
|
package/cli/interop.js
CHANGED
|
@@ -193,13 +193,12 @@ function interopEntryChanged(e, result) {
|
|
|
193
193
|
if (`${e.operator}${version}` !== e.currentRange) return true;
|
|
194
194
|
const peer = result.peers.get(e.pkg);
|
|
195
195
|
if (peer === void 0) return false;
|
|
196
|
-
|
|
197
|
-
return true;
|
|
196
|
+
return e.peer !== void 0 && peer !== e.peer.value;
|
|
198
197
|
}
|
|
199
198
|
/**
|
|
200
199
|
* Build the span edits for one interop catalog group from its resolution: a
|
|
201
|
-
* range edit when the resolved version differs, and a peer edit that rewrites
|
|
202
|
-
* existing
|
|
200
|
+
* range edit when the resolved version differs, and a peer edit that rewrites
|
|
201
|
+
* the existing peer literal. An entry with no peer gets no peer edit.
|
|
203
202
|
*
|
|
204
203
|
* @internal
|
|
205
204
|
*/
|
|
@@ -214,17 +213,10 @@ function buildInteropEdits(entries, result) {
|
|
|
214
213
|
span: e.rangeSpan,
|
|
215
214
|
text: JSON.stringify(newRange)
|
|
216
215
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
text: JSON.stringify(peer)
|
|
222
|
-
});
|
|
223
|
-
else if (!e.peer) edits.push({
|
|
224
|
-
span: [at, at],
|
|
225
|
-
text: `, peer: ${JSON.stringify(peer)}`
|
|
226
|
-
});
|
|
227
|
-
}
|
|
216
|
+
if (peer !== void 0 && e.peer && peer !== e.peer.value) edits.push({
|
|
217
|
+
span: e.peer.span,
|
|
218
|
+
text: JSON.stringify(peer)
|
|
219
|
+
});
|
|
228
220
|
}
|
|
229
221
|
return edits;
|
|
230
222
|
}
|
package/cli/local-merge.js
CHANGED
|
@@ -31,10 +31,13 @@ const MAP_STRATEGIES = {
|
|
|
31
31
|
* round: the file is the base and the managed value is laid on top, so a
|
|
32
32
|
* managed change to a key the file holds is exported (install, where the
|
|
33
33
|
* consumer's value wins, freezes such a key after the first export).
|
|
34
|
+
* `catalog` is left out: it is desugared into `catalogs.default` before the
|
|
35
|
+
* merge, and `effectiveManaged` applies `local.catalog` to that catalog and
|
|
36
|
+
* keeps the file's own entries under it.
|
|
34
37
|
*/
|
|
35
38
|
const MAP_EXPORT_STRATEGIES = new Map(Object.entries(FIELD_REGISTRY).flatMap(([name, p]) => {
|
|
36
39
|
const strategy = MAP_STRATEGIES[p.strategy];
|
|
37
|
-
return strategy === void 0 ? [] : [[name, strategy]];
|
|
40
|
+
return strategy === void 0 || name === "catalog" ? [] : [[name, strategy]];
|
|
38
41
|
}));
|
|
39
42
|
/**
|
|
40
43
|
* Map fields (`mapChildWins` and `sectionMerge` in `FIELD_REGISTRY`) whose
|
package/cli/plan.js
CHANGED
|
@@ -15,7 +15,7 @@ import { derivePeerRange } from "./peer-range.js";
|
|
|
15
15
|
*/
|
|
16
16
|
function planEntry(entry, versions) {
|
|
17
17
|
return Effect.gen(function* () {
|
|
18
|
-
const range = parseRange(entry.currentRange);
|
|
18
|
+
const range = parseRange(entry.family !== void 0 && entry.operator === "" ? `^${bareVersion(entry.currentRange)}` : entry.currentRange);
|
|
19
19
|
const current = parseVersion(bareVersion(entry.currentRange));
|
|
20
20
|
const currentMajor = current?.major ?? 0;
|
|
21
21
|
const track = current && current.prerelease.length > 0 ? String(current.prerelease[0]) : null;
|
|
@@ -57,7 +57,11 @@ function planEntry(entry, versions) {
|
|
|
57
57
|
* which for a 0.x caret routinely falls OUTSIDE the current range (`^0.2.0`
|
|
58
58
|
* does not contain 0.3.0); the never-cross-a-range rule protects against
|
|
59
59
|
* surprise REGISTRY majors, and the workspace version is this repo's own
|
|
60
|
-
* declared next release.
|
|
60
|
+
* declared next release. An unlocked family member (`upgrade --family`) takes
|
|
61
|
+
* its in-range candidate too, which `planEntry` computes over its breaking
|
|
62
|
+
* line (the major from 1.0, the minor for 0.x), so the tier rules still hold — a stable member never
|
|
63
|
+
* sees a prerelease, and nothing unattended crosses a major. Undefined when
|
|
64
|
+
* nothing but keep is on offer.
|
|
61
65
|
*
|
|
62
66
|
* Shared by `--yes`/`--check` (runUpgrade) and the `--preview` / non-TTY
|
|
63
67
|
* projection (projectDecisions) so the three can never disagree.
|
|
@@ -65,7 +69,8 @@ function planEntry(entry, versions) {
|
|
|
65
69
|
* @internal
|
|
66
70
|
*/
|
|
67
71
|
function defaultPick(entry, candidates) {
|
|
68
|
-
|
|
72
|
+
if (entry.source === "workspace") return candidates.find((c) => c.kind !== "keep");
|
|
73
|
+
return candidates.find((c) => c.kind === "in-range");
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
export { defaultPick, planEntry };
|
package/cli/preview-views.js
CHANGED
|
@@ -3,6 +3,7 @@ import { WORKSPACE_FIELDS } from "../registry.js";
|
|
|
3
3
|
import { buildDiff } from "./diff/build.js";
|
|
4
4
|
import { renderExportDiff } from "./diff/render.js";
|
|
5
5
|
import { effectiveManaged, vanillaManaged } from "./effective.js";
|
|
6
|
+
import { respellForFile } from "./respell.js";
|
|
6
7
|
import { renderSimulated } from "./simulated-view.js";
|
|
7
8
|
import { overlayWorkspace } from "./workspace-overlay.js";
|
|
8
9
|
|
|
@@ -21,7 +22,8 @@ function buildPreviewViews(input) {
|
|
|
21
22
|
managedKeys: WORKSPACE_FIELDS
|
|
22
23
|
};
|
|
23
24
|
const effective = effectiveManaged(input.managed, input.local, input.parsed, input.manifest, input.rootName);
|
|
24
|
-
const
|
|
25
|
+
const { effective: spelled, parsed: fileBase } = respellForFile(effective, input.parsed);
|
|
26
|
+
const merged = overlayWorkspace(spelled, fileBase);
|
|
25
27
|
const vanilla = vanillaManaged(input.managed, input.manifest, input.rootName);
|
|
26
28
|
const before = PnpmWorkspaceFile.canonicalize(input.parsed);
|
|
27
29
|
const changesTree = buildDiff(before, PnpmWorkspaceFile.canonicalize(merged), meta);
|
package/cli/release-age.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Option, Schema } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import "../plugin/freeze.js";
|
|
3
|
+
import { isWrappedField } from "../plugin/second-forms.js";
|
|
3
4
|
import { FIELD_SCHEMAS } from "../registry.js";
|
|
4
5
|
|
|
5
6
|
// src/cli/release-age.ts
|
package/cli/render/print.js
CHANGED
|
@@ -25,11 +25,8 @@ const coloured = Effect.gen(function* () {
|
|
|
25
25
|
*/
|
|
26
26
|
function printView(view, options = {}) {
|
|
27
27
|
return Effect.gen(function* () {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (options.legend !== void 0 && (yield* coloured)) doc.push(options.legend, Doc.line(""));
|
|
31
|
-
doc.push(Doc.lines(view.lines, { wrap: false }));
|
|
32
|
-
yield* Doc.print(doc);
|
|
28
|
+
const legend = options.legend !== void 0 && (yield* coloured) ? options.legend : void 0;
|
|
29
|
+
yield* Doc.print(Doc.concat(options.heading !== void 0 && [Doc.line(options.heading), Doc.line("")], legend !== void 0 && [legend, Doc.line("")], Doc.lines(view.lines, { wrap: false })));
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
|
package/cli/render/report.js
CHANGED
|
@@ -3,13 +3,11 @@ import { Doc, Status } from "@effected/cli-kit";
|
|
|
3
3
|
// src/cli/render/report.ts
|
|
4
4
|
function statusDoc(status, message) {
|
|
5
5
|
const [first = "", ...rest] = message.split("\n");
|
|
6
|
-
|
|
6
|
+
return Doc.concat(Doc.line([
|
|
7
7
|
Doc.status(Status.core, status),
|
|
8
8
|
" ",
|
|
9
9
|
first
|
|
10
|
-
])
|
|
11
|
-
if (rest.length > 0) blocks.push(Doc.verbatim(rest.join("\n")));
|
|
12
|
-
return blocks;
|
|
10
|
+
]), rest.length > 0 && Doc.verbatim(rest.join("\n")));
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
13
|
* The failure report for one of the CLI's own errors: a status line carrying
|