rolldown-pnpm-config 4.0.0 → 4.1.1
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/cli/commands/upgrade.js +23 -11
- package/cli/drift.js +1 -1
- package/cli/effective.js +16 -3
- package/cli/interop.js +28 -1
- package/cli/peer-range.js +21 -5
- package/cli/plan.js +1 -1
- package/cli/summary.js +16 -18
- package/cli/sync/ripples.js +1 -1
- package/cli/version.js +1 -1
- package/cli/walk-plan.js +1 -1
- package/cli/workspace-overlay.js +5 -0
- package/cli/workspace-resolve.js +17 -1
- package/package.json +5 -5
- package/plugin/freeze.js +15 -0
- package/skills/rolldown-pnpm-config/references/catalogs.md +21 -5
- package/skills/rolldown-pnpm-config/references/options.md +7 -2
- package/skills/rolldown-pnpm-config/references/wiring.md +2 -0
package/cli/commands/upgrade.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
1
2
|
import { CliDoc, CliExit, CliFormat, CliInteractive, CliMessage, Doc, Fmt } from "@effected/cli-kit";
|
|
2
3
|
import { CliUi } from "@effected/cli-kit/ui";
|
|
3
4
|
import { AtomicFile } from "@effected/files";
|
|
@@ -9,7 +10,7 @@ import { WorkingDirectory } from "../cwd.js";
|
|
|
9
10
|
import { discoverCatalogEntries } from "../discover.js";
|
|
10
11
|
import { buildEdits, entryEdits } from "../edits.js";
|
|
11
12
|
import { evaluatePluginConfig } from "../evaluate.js";
|
|
12
|
-
import { buildInteropEdits, interopEntryChanged, makePeerFetcher, runInterop } from "../interop.js";
|
|
13
|
+
import { buildInteropEdits, interopEntryChanged, makePeerFetcher, runInterop, withWorkspacePeers, workspaceMembers } from "../interop.js";
|
|
13
14
|
import { buildGroupModel, computeGroupPeers } from "../interop-live.js";
|
|
14
15
|
import { derivePeerRange } from "../peer-range.js";
|
|
15
16
|
import { defaultPick, planEntry } from "../plan.js";
|
|
@@ -23,6 +24,7 @@ import { walkScreen, withProgress } from "../ui/screens.js";
|
|
|
23
24
|
import { validateEdits } from "../validate.js";
|
|
24
25
|
import { versionKeyOf } from "../version-key.js";
|
|
25
26
|
import { buildWalkItems } from "../walk-plan.js";
|
|
27
|
+
import { findWorkspaceRoot, manifestPeerReader } from "../workspace-resolve.js";
|
|
26
28
|
|
|
27
29
|
// src/cli/commands/upgrade.ts
|
|
28
30
|
/**
|
|
@@ -344,7 +346,7 @@ function runUpgrade(opts) {
|
|
|
344
346
|
if (entry.strategy === "interop") continue;
|
|
345
347
|
const versions = versionsByPkg.gated.get(versionKeyOf(entry)) ?? [];
|
|
346
348
|
const { range, setPeer } = entryEdits(entry);
|
|
347
|
-
const derived = entry.strategy ? yield* derivePeerRange(entry.currentRange, entry.strategy).pipe(Effect.orElseSucceed(() => null)) : null;
|
|
349
|
+
const derived = entry.strategy ? yield* derivePeerRange(entry.currentRange, entry.strategy, entry.peer?.value).pipe(Effect.orElseSucceed(() => null)) : null;
|
|
348
350
|
if (derived?.warning) warnings.push(`${entry.pkg}: ${derived.warning.message}`);
|
|
349
351
|
const peerOnly = derived === null || setPeer === void 0 || derived.range === entry.peer?.value ? null : derived.range;
|
|
350
352
|
const candidates = versions.length === 0 ? [] : yield* planEntry(entry, versions).pipe(Effect.orElseSucceed(() => []));
|
|
@@ -366,6 +368,7 @@ function runUpgrade(opts) {
|
|
|
366
368
|
...foreign
|
|
367
369
|
].filter((e) => e.strategy === "interop");
|
|
368
370
|
const conflicts = [];
|
|
371
|
+
const interopResolver = withWorkspacePeers(opts.resolver, workspaceMembers(interopEntries), opts.manifestPeers ?? manifestPeerReader(findWorkspaceRoot(dirname(opts.file))));
|
|
369
372
|
const byCatalog = /* @__PURE__ */ new Map();
|
|
370
373
|
for (const e of interopEntries) {
|
|
371
374
|
const list = byCatalog.get(e.catalog) ?? [];
|
|
@@ -392,7 +395,7 @@ function runUpgrade(opts) {
|
|
|
392
395
|
candidates: versions
|
|
393
396
|
});
|
|
394
397
|
}
|
|
395
|
-
const result = yield* runInterop(members,
|
|
398
|
+
const result = yield* runInterop(members, interopResolver);
|
|
396
399
|
const moving = group.filter((e) => !pinned.has(e));
|
|
397
400
|
interopEdits.push(...buildInteropEdits(moving, result));
|
|
398
401
|
for (const e of moving) {
|
|
@@ -513,23 +516,25 @@ function projectDecisions(items, full) {
|
|
|
513
516
|
* `--dry-run`: the rows the projection shows, and a scope counting what the
|
|
514
517
|
* display filter left out, so the summary tallies the whole catalog. Under
|
|
515
518
|
* `full` the workspace rows and the locked family rows join the table as the
|
|
516
|
-
* dialog shows them
|
|
519
|
+
* dialog shows them: catalogs in config order, a family's row where its first
|
|
520
|
+
* member sits.
|
|
517
521
|
*
|
|
518
522
|
* @internal
|
|
519
523
|
*/
|
|
520
524
|
function projectPreview(items, families, full) {
|
|
521
525
|
const decisions = [];
|
|
522
526
|
const locked = /* @__PURE__ */ new Map();
|
|
527
|
+
const slots = [];
|
|
523
528
|
let hiddenUpToDate = 0;
|
|
524
529
|
let hiddenWorkspace = 0;
|
|
525
530
|
for (const item of items) {
|
|
526
531
|
const { entry } = item;
|
|
527
532
|
if (item.readOnly === true) {
|
|
528
533
|
const keep = item.candidates.find((c) => c.kind === "keep");
|
|
529
|
-
if (full && keep) decisions.push({
|
|
534
|
+
if (full && keep) slots.push(decisions.push({
|
|
530
535
|
item,
|
|
531
536
|
chosen: keep
|
|
532
|
-
});
|
|
537
|
+
}) - 1);
|
|
533
538
|
else hiddenWorkspace++;
|
|
534
539
|
continue;
|
|
535
540
|
}
|
|
@@ -537,6 +542,7 @@ function projectPreview(items, families, full) {
|
|
|
537
542
|
const key = `${entry.catalog}\0${entry.family}`;
|
|
538
543
|
const seen = locked.get(key);
|
|
539
544
|
const newer = item.upToDate ? 0 : 1;
|
|
545
|
+
if (seen === void 0) slots.push(key);
|
|
540
546
|
locked.set(key, seen === void 0 ? {
|
|
541
547
|
catalog: entry.catalog,
|
|
542
548
|
family: entry.family,
|
|
@@ -551,9 +557,14 @@ function projectPreview(items, families, full) {
|
|
|
551
557
|
}
|
|
552
558
|
const projected = projectDecisions([item], full);
|
|
553
559
|
if (projected.length === 0) hiddenUpToDate++;
|
|
554
|
-
|
|
560
|
+
for (const decision of projected) slots.push(decisions.push(decision) - 1);
|
|
555
561
|
}
|
|
556
562
|
const rows = [...locked.values()];
|
|
563
|
+
const order = slots.flatMap((slot) => {
|
|
564
|
+
if (typeof slot === "number") return [slot];
|
|
565
|
+
const family = locked.get(slot);
|
|
566
|
+
return full && family !== void 0 ? [family] : [];
|
|
567
|
+
});
|
|
557
568
|
return {
|
|
558
569
|
decisions,
|
|
559
570
|
scope: {
|
|
@@ -563,7 +574,8 @@ function projectPreview(items, families, full) {
|
|
|
563
574
|
families: full ? 0 : rows.length,
|
|
564
575
|
members: full ? 0 : rows.reduce((n, r) => n + r.members, 0)
|
|
565
576
|
},
|
|
566
|
-
locked: full ? rows : []
|
|
577
|
+
locked: full ? rows : [],
|
|
578
|
+
order
|
|
567
579
|
}
|
|
568
580
|
};
|
|
569
581
|
}
|
|
@@ -810,7 +822,7 @@ function warnUnresolved(unresolved, causes) {
|
|
|
810
822
|
*
|
|
811
823
|
* @internal
|
|
812
824
|
*/
|
|
813
|
-
function resolveForWalk(entries, resolver, gate, report) {
|
|
825
|
+
function resolveForWalk(entries, resolver, gate, report, manifestPeers) {
|
|
814
826
|
return Effect.gen(function* () {
|
|
815
827
|
const { moving, locked } = partitionEntries(entries, "npm");
|
|
816
828
|
const owned = [...moving, ...locked];
|
|
@@ -826,7 +838,7 @@ function resolveForWalk(entries, resolver, gate, report) {
|
|
|
826
838
|
}
|
|
827
839
|
const interopModels = /* @__PURE__ */ new Map();
|
|
828
840
|
if (interopByCatalog.size > 0) {
|
|
829
|
-
const fetchPeer = makePeerFetcher(resolver);
|
|
841
|
+
const fetchPeer = makePeerFetcher(manifestPeers === void 0 ? resolver : withWorkspacePeers(resolver, workspaceMembers([...pinned]), manifestPeers));
|
|
830
842
|
yield* report({
|
|
831
843
|
_tag: "Phase",
|
|
832
844
|
label: "Resolving peer dependencies",
|
|
@@ -1042,7 +1054,7 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
1042
1054
|
]);
|
|
1043
1055
|
return yield* warnUnresolved(versions.unresolved, versions.causes);
|
|
1044
1056
|
}
|
|
1045
|
-
const { versions, items, interopByCatalog, interopModels, pinned } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, report));
|
|
1057
|
+
const { versions, items, interopByCatalog, interopModels, pinned } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, report, manifestPeerReader(findWorkspaceRoot(dirname(file)))));
|
|
1046
1058
|
if (items.length === 0) {
|
|
1047
1059
|
yield* warnUnresolved(versions.unresolved, versions.causes);
|
|
1048
1060
|
return yield* CliMessage.info(nothingToUpgradeMessage(0));
|
package/cli/drift.js
CHANGED
|
@@ -19,7 +19,7 @@ import { derivePeerRange } from "./peer-range.js";
|
|
|
19
19
|
function detectPeerDrift(entry) {
|
|
20
20
|
return Effect.gen(function* () {
|
|
21
21
|
if (!entry.peer || !entry.strategy || entry.strategy === "interop") return null;
|
|
22
|
-
const { range: expected } = yield* derivePeerRange(entry.currentRange, entry.strategy);
|
|
22
|
+
const { range: expected } = yield* derivePeerRange(entry.currentRange, entry.strategy, entry.peer.value);
|
|
23
23
|
return expected === entry.peer.value ? null : expected;
|
|
24
24
|
});
|
|
25
25
|
}
|
package/cli/effective.js
CHANGED
|
@@ -102,9 +102,11 @@ function defaultCatalogOf(managed, directive, file) {
|
|
|
102
102
|
* pnpm 12's nested `overrides` and `catalog` forms in `local` and in the file
|
|
103
103
|
* are desugared first, so every merge sees flat maps and the default catalog
|
|
104
104
|
* as `catalogs.default`; `respellForFile` writes them back in the file's form.
|
|
105
|
-
*
|
|
106
|
-
* a shared key
|
|
107
|
-
*
|
|
105
|
+
* Every managed catalog is laid over the file's own per package (managed wins
|
|
106
|
+
* on a shared key, a file-only package is kept), as install merges them: the
|
|
107
|
+
* default catalog after `local.catalog` acts on it, a named one after
|
|
108
|
+
* `local.catalogs` does. `local.catalogs: { strategy: "rewrite" }` opts the
|
|
109
|
+
* named catalogs back into replace-by-name.
|
|
108
110
|
*
|
|
109
111
|
* @throws `Error` when `local` sets a nested sub-key beside its twin setting,
|
|
110
112
|
* when `local` or the file sets `catalog` beside `catalogs.default`, or when
|
|
@@ -149,6 +151,17 @@ function effectiveManaged(managed, local, parsed, manifest, rootName) {
|
|
|
149
151
|
else delete out.catalogs;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
154
|
+
if (!(isLocalDirective(flatLocal?.catalogs) && (flatLocal?.catalogs)?.strategy === "rewrite") && isMap(out.catalogs)) {
|
|
155
|
+
const next = {};
|
|
156
|
+
for (const [name, catalog] of Object.entries(out.catalogs)) {
|
|
157
|
+
const fileCatalog = fileCatalogs[name];
|
|
158
|
+
next[name] = name !== "default" && isMap(catalog) && isMap(fileCatalog) ? {
|
|
159
|
+
...fileCatalog,
|
|
160
|
+
...catalog
|
|
161
|
+
} : catalog;
|
|
162
|
+
}
|
|
163
|
+
out.catalogs = next;
|
|
164
|
+
}
|
|
152
165
|
return out;
|
|
153
166
|
}
|
|
154
167
|
/**
|
package/cli/interop.js
CHANGED
|
@@ -148,6 +148,33 @@ function resolveGroup(members, fetchPeer) {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
+
* `resolver`, with each `workspace` member's peers read from its own manifest
|
|
152
|
+
* instead of the registry.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* A workspace member's next release is usually unpublished, so the registry
|
|
156
|
+
* answers `{}` for it and its peers on the group's npm entries were never
|
|
157
|
+
* seen. The manifest is the next release, whatever version the group holds the
|
|
158
|
+
* member at. Only a peer written as a semver range is a constraint: a
|
|
159
|
+
* `catalog:` or `workspace:` peer follows the catalog or the workspace, so it
|
|
160
|
+
* is dropped rather than read as a range nothing satisfies. A name that is not
|
|
161
|
+
* a workspace package falls back to the registry.
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
function withWorkspacePeers(resolver, workspace, manifestPeers) {
|
|
166
|
+
if (workspace.size === 0) return resolver;
|
|
167
|
+
return { peerDependencies: (pkg, version) => {
|
|
168
|
+
const own = workspace.has(pkg) ? manifestPeers(pkg) : void 0;
|
|
169
|
+
if (own === void 0) return resolver.peerDependencies(pkg, version);
|
|
170
|
+
return Effect.succeed(Object.fromEntries(Object.entries(own).filter(([, range]) => parseRange(range) !== null)));
|
|
171
|
+
} };
|
|
172
|
+
}
|
|
173
|
+
/** The names of the workspace-sourced entries among `entries`. @internal */
|
|
174
|
+
function workspaceMembers(entries) {
|
|
175
|
+
return new Set(entries.filter((e) => e.source === "workspace").map((e) => e.pkg));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
151
178
|
* Fetch the peerDependencies needed to reconcile one catalog interop group,
|
|
152
179
|
* then run the pure resolve + floor derivation. Failures degrade to empty
|
|
153
180
|
* peerDeps (the member resolves at its ceiling).
|
|
@@ -221,4 +248,4 @@ function buildInteropEdits(entries, result) {
|
|
|
221
248
|
return edits;
|
|
222
249
|
}
|
|
223
250
|
|
|
224
|
-
export { buildInteropEdits, deriveFloors, interopEntryChanged, lowestVersion, makePeerFetcher, resolveGroup, runInterop };
|
|
251
|
+
export { buildInteropEdits, deriveFloors, interopEntryChanged, lowestVersion, makePeerFetcher, resolveGroup, runInterop, withWorkspacePeers, workspaceMembers };
|
package/cli/peer-range.js
CHANGED
|
@@ -14,10 +14,25 @@ const DERIVABLE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
14
14
|
"~",
|
|
15
15
|
""
|
|
16
16
|
]);
|
|
17
|
+
/** The range operator a peer literal already carries: `^`, `~`, or none. */
|
|
18
|
+
function operatorOf(peer) {
|
|
19
|
+
if (peer === void 0) return "";
|
|
20
|
+
const spec = Result.getOrNull(VersionSpecifier.parseResult(peer));
|
|
21
|
+
return spec !== null && (spec.operator === "^" || spec.operator === "~") ? spec.operator : "";
|
|
22
|
+
}
|
|
17
23
|
/**
|
|
18
24
|
* Recompute a materialized peer range from a package range and a strategy.
|
|
19
25
|
* "lock" pins to the exact version; "lock-minor" floors the patch to .0.
|
|
20
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* The operator comes from the dependency range when it has one (`^`/`~`).
|
|
28
|
+
* An exact dependency has none to give, and every locked-family member is
|
|
29
|
+
* exact, so the peer then keeps the operator `currentPeer` already carries:
|
|
30
|
+
* `4.1.7` beside `~4.1.0` derives `~4.1.0`, never the bare `4.1.0`. When
|
|
31
|
+
* neither carries one, "lock" stays exact (a pin on a pin), and "lock-minor"
|
|
32
|
+
* takes `~`, which holds the minor line on every major (a caret would admit
|
|
33
|
+
* only `0.0.0` on a 0.0.x line). A
|
|
34
|
+
* bare floor version is never a "lock-minor" result: it names one release,
|
|
35
|
+
* usually not the catalogued one, and often one that was never published.
|
|
21
36
|
*
|
|
22
37
|
* "lock" reuses the version text verbatim rather than rebuilding it from
|
|
23
38
|
* major.minor.patch, so prerelease and build identifiers survive intact
|
|
@@ -36,12 +51,13 @@ const DERIVABLE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
36
51
|
*
|
|
37
52
|
* @internal
|
|
38
53
|
*/
|
|
39
|
-
function derivePeerRange(range, strategy) {
|
|
54
|
+
function derivePeerRange(range, strategy, currentPeer) {
|
|
40
55
|
return Effect.gen(function* () {
|
|
41
56
|
const spec = Result.getOrNull(VersionSpecifier.parseResult(range));
|
|
42
57
|
if (spec === null || !DERIVABLE_OPERATORS.has(spec.operator)) return yield* Effect.fail(new PeerRangeError({ message: `Cannot derive peer range from "${range}"` }));
|
|
43
|
-
const { operator
|
|
44
|
-
const version = range.slice(
|
|
58
|
+
const { operator, version: parsed } = spec;
|
|
59
|
+
const version = range.slice(operator.length);
|
|
60
|
+
const prefix = operator === "" ? operatorOf(currentPeer) : operator;
|
|
45
61
|
if (strategy === "lock") return {
|
|
46
62
|
range: `${prefix}${version}`,
|
|
47
63
|
warning: null
|
|
@@ -54,7 +70,7 @@ function derivePeerRange(range, strategy) {
|
|
|
54
70
|
}
|
|
55
71
|
};
|
|
56
72
|
return {
|
|
57
|
-
range: `${prefix}${parsed.major}.${parsed.minor}.0`,
|
|
73
|
+
range: `${prefix !== "" ? prefix : "~"}${parsed.major}.${parsed.minor}.0`,
|
|
58
74
|
warning: null
|
|
59
75
|
};
|
|
60
76
|
});
|
package/cli/plan.js
CHANGED
|
@@ -24,7 +24,7 @@ function planEntry(entry, versions) {
|
|
|
24
24
|
const inRangeMax = range ? Option.getOrNull(Range.maxSatisfying(parsed, range)) : null;
|
|
25
25
|
const sameMajorMax = Option.getOrNull(SemVer.max(parsed.filter((v) => v.major === currentMajor)));
|
|
26
26
|
const overallMax = Option.getOrNull(SemVer.max(parsed));
|
|
27
|
-
const withPeer = (version) => entry.strategy && entry.strategy !== "interop" ? derivePeerRange(`${entry.operator}${version}`, entry.strategy).pipe(Effect.map((d) => d.range)) : Effect.succeed(void 0);
|
|
27
|
+
const withPeer = (version) => entry.strategy && entry.strategy !== "interop" ? derivePeerRange(`${entry.operator}${version}`, entry.strategy, entry.peer?.value).pipe(Effect.map((d) => d.range)) : Effect.succeed(void 0);
|
|
28
28
|
const candidate = (kind, sv) => Effect.map(withPeer(sv.toString()), (peerRange) => ({
|
|
29
29
|
kind,
|
|
30
30
|
range: `${entry.operator}${sv}`,
|
package/cli/summary.js
CHANGED
|
@@ -26,21 +26,25 @@ function summaryDoc(decisions, interop, rejected, scope) {
|
|
|
26
26
|
members: 0
|
|
27
27
|
};
|
|
28
28
|
const lockedRows = [...scope?.locked ?? []];
|
|
29
|
-
const
|
|
30
|
-
const lockedFor = (catalog) => {
|
|
31
|
-
if (shown.has(catalog)) return;
|
|
32
|
-
shown.add(catalog);
|
|
33
|
-
for (const f of lockedRows.filter((r) => r.catalog === catalog)) lines.push(row(" ", 0, [tone(`▸ family: ${f.family}`, "plain"), tone(` (${familyDetail(f.members, f.newer)})`, "unchanged")]));
|
|
34
|
-
};
|
|
29
|
+
const slots = scope?.order ?? [...decisions.keys(), ...lockedRows];
|
|
35
30
|
const { pkgWidth, maxCells, blankCell, cellText } = tableLayout(decisions.map((d) => d.item));
|
|
36
31
|
let lastCatalog = null;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
const header = (catalog) => {
|
|
33
|
+
if (catalog === lastCatalog) return;
|
|
34
|
+
lastCatalog = catalog;
|
|
35
|
+
lines.push(row(" ", 0, [tone(`── catalog: ${catalog} ──`, "unchanged")]));
|
|
36
|
+
};
|
|
37
|
+
for (const slot of slots) {
|
|
38
|
+
if (typeof slot !== "number") {
|
|
39
|
+
header(slot.catalog);
|
|
40
|
+
lines.push(row(" ", 0, [tone(`▸ family: ${slot.family}`, "plain"), tone(` (${familyDetail(slot.members, slot.newer)})`, "unchanged")]));
|
|
41
|
+
continue;
|
|
43
42
|
}
|
|
43
|
+
const decision = decisions[slot];
|
|
44
|
+
if (decision === void 0) continue;
|
|
45
|
+
const { item, chosen } = decision;
|
|
46
|
+
const { entry } = item;
|
|
47
|
+
header(entry.catalog);
|
|
44
48
|
if (item.readOnly === true) {
|
|
45
49
|
workspace++;
|
|
46
50
|
lines.push(row(" ", 0, [tone(`${Fmt.pad(entry.pkg, pkgWidth + 2)}${entry.currentRange} ${WORKSPACE_ROW_NOTE}`, "unchanged")]));
|
|
@@ -62,12 +66,6 @@ function summaryDoc(decisions, interop, rejected, scope) {
|
|
|
62
66
|
} else if (entry.peer && item.driftPeer) resync++;
|
|
63
67
|
else upToDate++;
|
|
64
68
|
}
|
|
65
|
-
if (lastCatalog !== null) lockedFor(lastCatalog);
|
|
66
|
-
for (const catalog of new Set(lockedRows.map((r) => r.catalog))) {
|
|
67
|
-
if (shown.has(catalog)) continue;
|
|
68
|
-
lines.push(row(" ", 0, [tone(`── catalog: ${catalog} ──`, "unchanged")]));
|
|
69
|
-
lockedFor(catalog);
|
|
70
|
-
}
|
|
71
69
|
const tally = [
|
|
72
70
|
`${toUpdate} to update`,
|
|
73
71
|
`${major} major`,
|
package/cli/sync/ripples.js
CHANGED
|
@@ -20,7 +20,7 @@ const rippleMismatches = Effect.fn("Sync.rippleMismatches")(function* (entries,
|
|
|
20
20
|
if (planned === void 0) continue;
|
|
21
21
|
const to = `${entry.operator}${planned}`;
|
|
22
22
|
if (entry.currentRange === to) continue;
|
|
23
|
-
const derived = entry.peer === void 0 || entry.strategy === void 0 ? void 0 : yield* Effect.orDie(derivePeerRange(to, entry.strategy));
|
|
23
|
+
const derived = entry.peer === void 0 || entry.strategy === void 0 ? void 0 : yield* Effect.orDie(derivePeerRange(to, entry.strategy, entry.peer.value));
|
|
24
24
|
const warning = derived?.warning?.message;
|
|
25
25
|
ripples.push({
|
|
26
26
|
catalog: entry.catalog,
|
package/cli/version.js
CHANGED
package/cli/walk-plan.js
CHANGED
|
@@ -34,7 +34,7 @@ function buildWalkItems(entries, versionsByPkg) {
|
|
|
34
34
|
const candidates = yield* planEntry(entry, [...versions]);
|
|
35
35
|
const driftPeer = yield* detectPeerDrift(entry);
|
|
36
36
|
let peerWarning = null;
|
|
37
|
-
if (entry.strategy && entry.strategy !== "interop") peerWarning = (yield* derivePeerRange(entry.currentRange, entry.strategy)).warning;
|
|
37
|
+
if (entry.strategy && entry.strategy !== "interop") peerWarning = (yield* derivePeerRange(entry.currentRange, entry.strategy, entry.peer?.value)).warning;
|
|
38
38
|
const upToDate = candidates.length === 1 && driftPeer === null;
|
|
39
39
|
items.push({
|
|
40
40
|
entry,
|
package/cli/workspace-overlay.js
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* (plugin names replace, local names are preserved); every other key in the
|
|
6
6
|
* parsed file is kept verbatim. Nothing is deleted. Pure.
|
|
7
7
|
*
|
|
8
|
+
* The per-package merge of a catalog both sides hold is not done here:
|
|
9
|
+
* `effectiveManaged` has already laid each managed catalog over the file's
|
|
10
|
+
* own, so the value replacing a name already carries the file-only packages
|
|
11
|
+
* (unless `local.catalogs` asked for a rewrite).
|
|
12
|
+
*
|
|
8
13
|
* @internal
|
|
9
14
|
*/
|
|
10
15
|
function overlayWorkspace(managed, parsed) {
|
package/cli/workspace-resolve.js
CHANGED
|
@@ -62,6 +62,22 @@ function readManifests(rootDir) {
|
|
|
62
62
|
return out;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
+
* A reader of workspace packages' own `peerDependencies` under `rootDir`, for
|
|
66
|
+
* interop reconciliation. The manifests are read on the first call, so a run
|
|
67
|
+
* with no workspace interop entry reads nothing, and no pending changeset is
|
|
68
|
+
* read at all: `upgrade` stays clear of them.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
function manifestPeerReader(rootDir) {
|
|
73
|
+
let manifests;
|
|
74
|
+
return (pkg) => {
|
|
75
|
+
manifests ??= readManifests(rootDir);
|
|
76
|
+
const manifest = manifests.get(pkg);
|
|
77
|
+
return manifest === void 0 ? void 0 : manifest.peerDependencies ?? {};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
65
81
|
* Read the pending changeset bumps under `<rootDir>/.changeset/` through
|
|
66
82
|
* `@effected/changesets`' `PendingChangesets.readSettledSync` (which skips
|
|
67
83
|
* readmes, agent context files, dotfiles and non-`.md` files, and also reads
|
|
@@ -166,4 +182,4 @@ function findWorkspaceRoot(startDir) {
|
|
|
166
182
|
}) ?? resolve(startDir);
|
|
167
183
|
}
|
|
168
184
|
|
|
169
|
-
export { findWorkspaceRoot, makeWorkspaceResolver, readManifests, readWorkspaceState };
|
|
185
|
+
export { findWorkspaceRoot, makeWorkspaceResolver, manifestPeerReader, readManifests, readWorkspaceState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-pnpm-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A dogfooding example of our plugin",
|
|
6
6
|
"repository": {
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@effect/platform-node": "4.1.7",
|
|
39
|
-
"@effected/changesets": "0.
|
|
40
|
-
"@effected/cli-kit": "0.34.
|
|
39
|
+
"@effected/changesets": "0.13.0",
|
|
40
|
+
"@effected/cli-kit": "0.34.1",
|
|
41
41
|
"@effected/env": "0.12.0",
|
|
42
|
-
"@effected/files": "0.
|
|
42
|
+
"@effected/files": "0.8.0",
|
|
43
43
|
"@effected/glob": "0.23.1",
|
|
44
44
|
"@effected/npm": "0.35.1",
|
|
45
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.7",
|
|
49
49
|
"@effected/yaml": "0.31.0",
|
|
50
50
|
"effect": "4.1.7",
|
|
51
51
|
"ink": "^8.0.0",
|
package/plugin/freeze.js
CHANGED
|
@@ -165,6 +165,19 @@ function orphanedWorkspaceEntry(catalogs, sync) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The first catalog entry naming the plugin itself, as a message naming the
|
|
170
|
+
* catalog and the entry, or `undefined` when no catalog holds it. Checking the
|
|
171
|
+
* declarations covers every served catalog: a `:peers` or `:exact` twin holds
|
|
172
|
+
* only names its declaration holds. The entry's `source` does not matter.
|
|
173
|
+
*/
|
|
174
|
+
function selfCataloguedEntry(catalogs, name) {
|
|
175
|
+
for (const [catalog, decl] of Object.entries(catalogs)) {
|
|
176
|
+
if (!Predicate.isObject(decl) || !Predicate.isObject(decl.packages)) continue;
|
|
177
|
+
if (!Object.hasOwn(decl.packages, name)) continue;
|
|
178
|
+
return `catalogs: "${name}" in catalog "${catalog}" is the plugin itself; a plugin must never serve its own name (every catalog rewrite would bump it, a release loop with no end). Remove the entry.`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
168
181
|
function normalizeField(input) {
|
|
169
182
|
if (isWrappedField(input)) {
|
|
170
183
|
const o = input;
|
|
@@ -219,6 +232,8 @@ function freeze(authored) {
|
|
|
219
232
|
...exactCatalogs.length > 0 ? { options: { exactCatalogs } } : {}
|
|
220
233
|
};
|
|
221
234
|
if (typeof config.name !== "string" || config.name.trim() === "") return yield* Effect.fail(new ConfigError({ message: "Config `name` is required and must be a non-empty string" }));
|
|
235
|
+
const self = selfCataloguedEntry(config.catalogs, config.name);
|
|
236
|
+
if (self !== void 0) return yield* Effect.fail(new ConfigError({ message: self }));
|
|
222
237
|
const declared = config;
|
|
223
238
|
for (const [field, why] of Object.entries(REMOVED_SETTINGS)) if (Object.hasOwn(declared, field) && declared[field] !== void 0) return yield* Effect.fail(new ConfigError({ message: `\`${field}\` is not a pnpm 12 setting: ${why}` }));
|
|
224
239
|
for (const [field, value] of Object.entries(declared)) {
|
|
@@ -61,6 +61,15 @@ catalogs: {
|
|
|
61
61
|
its operator.
|
|
62
62
|
- `peer` is served under `catalog:<name>:peers`. `{ value, strategy }` is
|
|
63
63
|
re-derived on every move; a bare string is hand-set and never touched.
|
|
64
|
+
The derived peer takes `dependency`'s operator; beside an exact
|
|
65
|
+
`dependency` (every locked family member) it keeps the operator `value`
|
|
66
|
+
already carries, so write the floor as a range (`~4.1.0`, `^0.74.0`). A
|
|
67
|
+
bare floor version (`4.1.0`) under `lock-minor` is drift, and the next run
|
|
68
|
+
that moves the entry rewrites it to `~4.1.0`.
|
|
69
|
+
- An `interop` member with `source: "workspace"` constrains its group
|
|
70
|
+
through the `peerDependencies` in its own `package.json`, not the
|
|
71
|
+
registry's. Only peers written as semver ranges count; `catalog:` and
|
|
72
|
+
`workspace:` peers are ignored.
|
|
64
73
|
- `source: "workspace"` marks a package of this monorepo. `sync` moves it,
|
|
65
74
|
reading the next release version from manifests plus pending changesets.
|
|
66
75
|
`"npm"` (the default) is `upgrade`'s.
|
|
@@ -116,7 +125,8 @@ catalogs: {
|
|
|
116
125
|
consumer's own `catalog:<name>` dependency. Nothing is pinned graph-wide.
|
|
117
126
|
An authored `overrides` selector wins over a generated one.
|
|
118
127
|
- `upgrade --yes` and `--check` skip members; `--check` lists a newer member
|
|
119
|
-
as informational and still exits 0.
|
|
128
|
+
as informational and still exits 0. A member's peer is skipped with it: a
|
|
129
|
+
family's peers re-derive only on a `--family` run. `upgrade --yes --family <name>`
|
|
120
130
|
(repeatable) moves each member to its newest version in its breaking line
|
|
121
131
|
(the major, or the minor on 0.x). That moves versions, so it is the user's
|
|
122
132
|
to run. A 0.0.x member never moves under `--family` (`^0.0.3` admits only
|
|
@@ -130,8 +140,10 @@ catalogs: {
|
|
|
130
140
|
The plugin package must never appear in any catalog it serves. Every
|
|
131
141
|
catalog rewrite bumps the plugin; a catalogued plugin would then move its
|
|
132
142
|
own catalog, write another changeset and bump again, a release loop that
|
|
133
|
-
never ends.
|
|
134
|
-
|
|
143
|
+
never ends. The build enforces it: an entry under the plugin's own `name`
|
|
144
|
+
in any catalog's `packages`, whatever its `source`, fails with
|
|
145
|
+
`catalogs: "<name>" in catalog "<catalog>" is the plugin itself`. Remove the
|
|
146
|
+
entry, and leave a comment at the catalog saying the omission is deliberate.
|
|
135
147
|
|
|
136
148
|
## Bundle every import; declare none
|
|
137
149
|
|
|
@@ -160,8 +172,12 @@ Read-only forms are fine: `pnpm:preview`, `upgrade --check`,
|
|
|
160
172
|
sub-keys, or `catalogs.default`; neither: `catalogs.default`), never both.
|
|
161
173
|
Nested `overrides` in the file stays nested. The default catalog merges per
|
|
162
174
|
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
|
|
164
|
-
|
|
175
|
+
and entries only the file holds stay. Named catalogs merge the same way, as
|
|
176
|
+
an install does; `local: { catalogs: { strategy: "rewrite" } }` makes each
|
|
177
|
+
managed named catalog replace the file's by name instead. `export` never
|
|
178
|
+
deletes a catalog only the file holds, and a package the plugin stops
|
|
179
|
+
serving inside a catalog it still serves stays in the file until it is
|
|
180
|
+
removed by hand or by a `rewrite`.
|
|
165
181
|
|
|
166
182
|
For fields whose runtime strategy is a union (`publicHoistPattern`,
|
|
167
183
|
`hoistPattern`, `minimumReleaseAgeExclude`, `trustPolicyExclude`,
|
|
@@ -27,7 +27,7 @@ dependency string (sourced from npm, no peer), or an object:
|
|
|
27
27
|
| Spec field | Meaning |
|
|
28
28
|
| --- | --- |
|
|
29
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 |
|
|
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"`). The derived value takes `dependency`'s operator, or keeps its own beside an exact `dependency`; a `lock-minor` value is always a range (`~4.1.0`, `^0.74.0`), never a bare floor version. CLI-only strategy |
|
|
31
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
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
33
|
|
|
@@ -102,10 +102,15 @@ catalog: { entries: { effect: "^4.0.0" }, mode: "strict", unused: "prune" },
|
|
|
102
102
|
`families` need `catalogs.default`. A bare `local.catalog` replaces the managed default
|
|
103
103
|
catalog, like `local.catalogs.<name>`; a directive's `union`/`merge` lays its
|
|
104
104
|
packages over the managed ones, `difference` removes the listed packages and
|
|
105
|
-
`rewrite` drops the file's own entries.
|
|
105
|
+
`rewrite` drops the file's own entries. A named catalog keeps the file's own
|
|
106
|
+
packages under the managed ones on export unless `local.catalogs` is
|
|
107
|
+
`{ strategy: "rewrite" }`. `local.catalog` beside a
|
|
106
108
|
`local.catalogs` that also names `default` fails. An empty catalog (`entries: {}`) ships no
|
|
107
109
|
`catalogs.default`.
|
|
108
110
|
|
|
111
|
+
A catalog entry under the plugin's own `name` fails the build, in any
|
|
112
|
+
catalog and whatever its `source`: a plugin never serves itself.
|
|
113
|
+
|
|
109
114
|
These fail the build with a `ConfigError` naming both keys: a sub-key together
|
|
110
115
|
with its twin setting (`overrides.unused` and `warnUnusedOverrides`);
|
|
111
116
|
`catalog` together with `catalogs.default`; a `value`, `enforcement` or
|
|
@@ -55,6 +55,8 @@ const plugin: ReturnType<typeof PnpmConfigPlugin> = PnpmConfigPlugin({
|
|
|
55
55
|
export default plugin;
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
The plugin's own `name` never goes in `packages`: the build fails on it.
|
|
59
|
+
|
|
58
60
|
`src/pnpmfile.ts` re-exports the generated hook, nothing more:
|
|
59
61
|
|
|
60
62
|
```ts
|