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/cli/commands/upgrade.js
CHANGED
|
@@ -10,7 +10,7 @@ import { WorkingDirectory } from "../cwd.js";
|
|
|
10
10
|
import { discoverCatalogEntries } from "../discover.js";
|
|
11
11
|
import { buildEdits, entryEdits } from "../edits.js";
|
|
12
12
|
import { evaluatePluginConfig } from "../evaluate.js";
|
|
13
|
-
import { buildInteropEdits, interopEntryChanged, makePeerFetcher, runInterop } from "../interop.js";
|
|
13
|
+
import { buildInteropEdits, interopEntryChanged, makePeerFetcher, runInterop, withWorkspacePeers, workspaceMembers } from "../interop.js";
|
|
14
14
|
import { buildGroupModel, computeGroupPeers } from "../interop-live.js";
|
|
15
15
|
import { derivePeerRange } from "../peer-range.js";
|
|
16
16
|
import { defaultPick, planEntry } from "../plan.js";
|
|
@@ -24,7 +24,7 @@ import { walkScreen, withProgress } from "../ui/screens.js";
|
|
|
24
24
|
import { validateEdits } from "../validate.js";
|
|
25
25
|
import { versionKeyOf } from "../version-key.js";
|
|
26
26
|
import { buildWalkItems } from "../walk-plan.js";
|
|
27
|
-
import { findWorkspaceRoot,
|
|
27
|
+
import { findWorkspaceRoot, manifestPeerReader } from "../workspace-resolve.js";
|
|
28
28
|
|
|
29
29
|
// src/cli/commands/upgrade.ts
|
|
30
30
|
/**
|
|
@@ -85,33 +85,40 @@ function writeSource(file, next) {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Read a config file and statically discover its catalog entries. With
|
|
88
|
-
* `catalog`, the entries and skipped names are scoped to that
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* `catalog`, the entries and skipped names are scoped to that catalog (or to
|
|
89
|
+
* each of a list of them, as `sync` passes its pairs' catalogs), and a name
|
|
90
|
+
* the config does not declare fails (`kind: "catalog"`) rather than silently
|
|
91
|
+
* matching nothing. Every `upgrade` mode reads through here, so `--catalog`
|
|
92
|
+
* scopes them all alike.
|
|
92
93
|
*
|
|
93
94
|
* @internal
|
|
94
95
|
*/
|
|
95
96
|
function readCatalogSource(file, catalog) {
|
|
96
97
|
return Effect.gen(function* () {
|
|
97
98
|
const { text: source } = yield* AtomicFile.readText(file).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot read ${file}` })));
|
|
98
|
-
const { entries, skipped, skippedRefs, catalogs } = yield* Effect.try({
|
|
99
|
+
const { entries, skipped, skippedRefs, catalogs, families, unreadFamilies } = yield* Effect.try({
|
|
99
100
|
try: () => discoverCatalogEntries(source, file),
|
|
100
101
|
catch: (e) => new UpgradeError({ message: Fmt.describe(e) })
|
|
101
102
|
});
|
|
102
103
|
if (catalog === void 0) return {
|
|
103
104
|
source,
|
|
104
105
|
entries,
|
|
105
|
-
skipped
|
|
106
|
+
skipped,
|
|
107
|
+
families,
|
|
108
|
+
unreadFamilies
|
|
106
109
|
};
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
const scope = typeof catalog === "string" ? [catalog] : catalog;
|
|
111
|
+
const unknown = scope.find((name) => !catalogs.includes(name));
|
|
112
|
+
if (unknown !== void 0) return yield* Effect.fail(new UpgradeError({
|
|
113
|
+
message: unknownCatalogMessage(unknown, catalogs),
|
|
109
114
|
kind: "catalog"
|
|
110
115
|
}));
|
|
111
116
|
return {
|
|
112
117
|
source,
|
|
113
|
-
entries: filterEntriesByCatalog(entries,
|
|
114
|
-
skipped: skippedRefs.filter((r) => r.catalog
|
|
118
|
+
entries: filterEntriesByCatalog(entries, scope),
|
|
119
|
+
skipped: skippedRefs.filter((r) => scope.includes(r.catalog)).map((r) => `${r.catalog}.${r.pkg}`),
|
|
120
|
+
families,
|
|
121
|
+
unreadFamilies
|
|
115
122
|
};
|
|
116
123
|
});
|
|
117
124
|
}
|
|
@@ -123,6 +130,46 @@ function readCatalogSource(file, catalog) {
|
|
|
123
130
|
function unknownCatalogMessage(catalog, declared) {
|
|
124
131
|
return `No catalog named "${catalog}" in the config (${declared.length === 0 ? "it declares no catalogs" : `declared: ${declared.join(", ")}`})`;
|
|
125
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* The message for a `--family` that names no family the config declares.
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
function unknownFamilyMessage(unknown, declared) {
|
|
139
|
+
return `No family named ${unknown.map((n) => `"${n}"`).join(", ")} in the config (${declared.length === 0 ? "it declares no families" : `declared: ${declared.join(", ")}`})`;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The message for `--family` over a config whose `families` could not be
|
|
143
|
+
* read statically in some catalog: which members a name covers, or whether
|
|
144
|
+
* it exists at all, is unknown there, so no `--family` is applied.
|
|
145
|
+
*
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
function unreadFamiliesMessage(unread) {
|
|
149
|
+
return `Cannot apply --family: could not read families statically in catalog ${unread.map((c) => `"${c}"`).join(", ")}; write each family, its members and its exclude as literal lists`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Split discovered entries into what a non-interactive run moves and the
|
|
153
|
+
* locked family members it only reports. A run owns one source: `upgrade`
|
|
154
|
+
* owns npm entries and `sync` owns workspace ones, so an entry of the other
|
|
155
|
+
* source is neither moved nor reported. A family member moves only when
|
|
156
|
+
* `families` names its family.
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
function partitionEntries(entries, owns, families = []) {
|
|
161
|
+
const moving = [];
|
|
162
|
+
const locked = [];
|
|
163
|
+
for (const e of entries) {
|
|
164
|
+
if ((e.source ?? "npm") !== owns) continue;
|
|
165
|
+
if (e.family !== void 0 && !families.includes(e.family)) locked.push(e);
|
|
166
|
+
else moving.push(e);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
moving,
|
|
170
|
+
locked
|
|
171
|
+
};
|
|
172
|
+
}
|
|
126
173
|
/** Combine the config-declared and pnpm-resolved release-age gates (strictest of both). @internal */
|
|
127
174
|
function computeGate(source, file, resolver) {
|
|
128
175
|
return Effect.gen(function* () {
|
|
@@ -238,8 +285,8 @@ function resolveProgress(report) {
|
|
|
238
285
|
* recomputed peer literal), and write the file. Never selects a major bump.
|
|
239
286
|
*
|
|
240
287
|
* A package whose version list gates to empty (fetch failure / fully age-gated)
|
|
241
|
-
* is treated as a skip, except that a strategy entry can still resync
|
|
242
|
-
*
|
|
288
|
+
* is treated as a skip, except that a strategy entry can still resync its
|
|
289
|
+
* managed peer offline from the current range.
|
|
243
290
|
*
|
|
244
291
|
* This path runs UNATTENDED (`--yes`, i.e. CI), so it fails hard rather than
|
|
245
292
|
* degrading: any peer-strategy warning, any planned edit no published
|
|
@@ -248,13 +295,21 @@ function resolveProgress(report) {
|
|
|
248
295
|
* past unread in a CI log is a bad range in a published artifact. The
|
|
249
296
|
* interactive path is deliberately more forgiving (see `upgradeCommand`).
|
|
250
297
|
*
|
|
298
|
+
* The run moves only the entries it owns (`owns`, npm by default; `sync`
|
|
299
|
+
* passes `"workspace"`), and never a locked family member unless `families`
|
|
300
|
+
* names its family. A locked member with a newer version is returned in
|
|
301
|
+
* `locked`, which is informational: it never fails `--check`.
|
|
302
|
+
*
|
|
251
303
|
* @internal
|
|
252
304
|
*/
|
|
253
305
|
function runUpgrade(opts) {
|
|
254
306
|
return Effect.gen(function* () {
|
|
255
|
-
const
|
|
307
|
+
const read = yield* readCatalogSource(opts.file, opts.catalog);
|
|
308
|
+
const { source, skipped } = read;
|
|
309
|
+
const owns = opts.owns ?? "npm";
|
|
310
|
+
const { moving: entries, locked: lockedEntries } = partitionEntries(read.entries, owns, opts.families);
|
|
256
311
|
const gate = yield* computeGate(source, opts.file, opts.resolver);
|
|
257
|
-
const versionsByPkg = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, opts.onProgress, opts.workspaceResolver);
|
|
312
|
+
const versionsByPkg = yield* resolveGatedVersions([...entries, ...lockedEntries], opts.resolver, gate, yield* Clock.currentTimeMillis, opts.onProgress, opts.workspaceResolver);
|
|
258
313
|
if (versionsByPkg.unresolved.length > 0) return yield* Effect.fail(new UpgradeError({ message: unresolvedMessage(versionsByPkg.unresolved, versionsByPkg.causes) }));
|
|
259
314
|
const skippedChangesets = opts.workspaceResolver?.skippedChangesets() ?? [];
|
|
260
315
|
if (skippedChangesets.length > 0) return yield* Effect.fail(new UpgradeError({
|
|
@@ -266,38 +321,54 @@ function runUpgrade(opts) {
|
|
|
266
321
|
const warnings = [];
|
|
267
322
|
const changedSpans = /* @__PURE__ */ new Set();
|
|
268
323
|
const changedPkgs = /* @__PURE__ */ new Map();
|
|
324
|
+
const rowOf = (entry, to) => ({
|
|
325
|
+
name: `${entry.catalog}.${entry.pkg}`,
|
|
326
|
+
catalog: entry.catalog,
|
|
327
|
+
pkg: entry.pkg,
|
|
328
|
+
from: entry.currentRange,
|
|
329
|
+
...to !== void 0 ? { to } : {},
|
|
330
|
+
source: entry.source ?? "npm",
|
|
331
|
+
...entry.family !== void 0 ? { family: entry.family } : {}
|
|
332
|
+
});
|
|
269
333
|
const markChanged = (entry, to) => {
|
|
270
334
|
changedSpans.add(entry.rangeSpan[0]);
|
|
271
|
-
const
|
|
272
|
-
changedPkgs.set(name,
|
|
273
|
-
name,
|
|
274
|
-
catalog: entry.catalog,
|
|
275
|
-
pkg: entry.pkg,
|
|
276
|
-
from: entry.currentRange,
|
|
277
|
-
...to !== void 0 ? { to } : {},
|
|
278
|
-
source: entry.source ?? "registry"
|
|
279
|
-
});
|
|
335
|
+
const row = rowOf(entry, to);
|
|
336
|
+
changedPkgs.set(row.name, row);
|
|
280
337
|
};
|
|
338
|
+
const locked = [];
|
|
339
|
+
for (const entry of lockedEntries) {
|
|
340
|
+
const versions = versionsByPkg.gated.get(versionKeyOf(entry)) ?? [];
|
|
341
|
+
const candidates = yield* planEntry(entry, versions).pipe(Effect.orElseSucceed(() => []));
|
|
342
|
+
const pick = defaultPick(entry, candidates);
|
|
343
|
+
if (pick) locked.push(rowOf(entry, pick.range));
|
|
344
|
+
}
|
|
281
345
|
for (const entry of entries) {
|
|
282
346
|
if (entry.strategy === "interop") continue;
|
|
283
347
|
const versions = versionsByPkg.gated.get(versionKeyOf(entry)) ?? [];
|
|
284
348
|
const { range, setPeer } = entryEdits(entry);
|
|
285
|
-
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;
|
|
286
350
|
if (derived?.warning) warnings.push(`${entry.pkg}: ${derived.warning.message}`);
|
|
287
|
-
const peerOnly = derived === null
|
|
351
|
+
const peerOnly = derived === null || setPeer === void 0 || derived.range === entry.peer?.value ? null : derived.range;
|
|
288
352
|
const candidates = versions.length === 0 ? [] : yield* planEntry(entry, versions).pipe(Effect.orElseSucceed(() => []));
|
|
289
353
|
const pick = defaultPick(entry, candidates);
|
|
290
354
|
if (pick) {
|
|
291
355
|
edits.push(range(pick.range));
|
|
292
356
|
markChanged(entry, pick.range);
|
|
293
|
-
if (pick.peerRange) edits.push(setPeer(pick.peerRange));
|
|
294
|
-
} else if (peerOnly !== null) {
|
|
357
|
+
if (pick.peerRange && setPeer) edits.push(setPeer(pick.peerRange));
|
|
358
|
+
} else if (peerOnly !== null && setPeer) {
|
|
295
359
|
edits.push(setPeer(peerOnly));
|
|
296
360
|
markChanged(entry);
|
|
297
361
|
} else if (versions.length === 0) skipped.push(`${entry.catalog}.${entry.pkg}`);
|
|
298
362
|
}
|
|
299
|
-
const
|
|
363
|
+
const foreign = read.entries.filter((e) => e.strategy === "interop" && (e.source ?? "npm") !== owns);
|
|
364
|
+
const pinned = /* @__PURE__ */ new Set([...lockedEntries, ...foreign]);
|
|
365
|
+
const interopEntries = [
|
|
366
|
+
...entries,
|
|
367
|
+
...lockedEntries,
|
|
368
|
+
...foreign
|
|
369
|
+
].filter((e) => e.strategy === "interop");
|
|
300
370
|
const conflicts = [];
|
|
371
|
+
const interopResolver = withWorkspacePeers(opts.resolver, workspaceMembers(interopEntries), opts.manifestPeers ?? manifestPeerReader(findWorkspaceRoot(dirname(opts.file))));
|
|
301
372
|
const byCatalog = /* @__PURE__ */ new Map();
|
|
302
373
|
for (const e of interopEntries) {
|
|
303
374
|
const list = byCatalog.get(e.catalog) ?? [];
|
|
@@ -307,18 +378,27 @@ function runUpgrade(opts) {
|
|
|
307
378
|
for (const [, group] of byCatalog) {
|
|
308
379
|
const members = [];
|
|
309
380
|
for (const e of group) {
|
|
381
|
+
const current = bareVersion(e.currentRange);
|
|
382
|
+
if (pinned.has(e)) {
|
|
383
|
+
members.push({
|
|
384
|
+
pkg: e.pkg,
|
|
385
|
+
ceiling: current,
|
|
386
|
+
candidates: [current]
|
|
387
|
+
});
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
310
390
|
const versions = versionsByPkg.gated.get(versionKeyOf(e)) ?? [];
|
|
311
|
-
const
|
|
312
|
-
const ceiling = inRange ? inRange.version : bareVersion(e.currentRange);
|
|
391
|
+
const cands = yield* planEntry(e, versions).pipe(Effect.orElseSucceed(() => []));
|
|
313
392
|
members.push({
|
|
314
393
|
pkg: e.pkg,
|
|
315
|
-
ceiling,
|
|
394
|
+
ceiling: defaultPick(e, cands)?.version ?? current,
|
|
316
395
|
candidates: versions
|
|
317
396
|
});
|
|
318
397
|
}
|
|
319
|
-
const result = yield* runInterop(members,
|
|
320
|
-
|
|
321
|
-
|
|
398
|
+
const result = yield* runInterop(members, interopResolver);
|
|
399
|
+
const moving = group.filter((e) => !pinned.has(e));
|
|
400
|
+
interopEdits.push(...buildInteropEdits(moving, result));
|
|
401
|
+
for (const e of moving) {
|
|
322
402
|
if (!interopEntryChanged(e, result)) continue;
|
|
323
403
|
const next = result.resolved.get(e.pkg);
|
|
324
404
|
const nextRange = next === void 0 ? void 0 : `${e.operator}${next}`;
|
|
@@ -342,13 +422,14 @@ function runUpgrade(opts) {
|
|
|
342
422
|
skipped,
|
|
343
423
|
conflicts,
|
|
344
424
|
rejected,
|
|
345
|
-
changed: [...changedPkgs.values()]
|
|
425
|
+
changed: [...changedPkgs.values()],
|
|
426
|
+
locked
|
|
346
427
|
};
|
|
347
428
|
});
|
|
348
429
|
}
|
|
349
|
-
/** Count the decisions that actually change the file (a bump
|
|
430
|
+
/** Count the decisions that actually change the file (a bump or a peer resync). @internal */
|
|
350
431
|
function countChangedDecisions(decisions) {
|
|
351
|
-
return decisions.filter((d) => d.chosen.kind !== "keep" || d.item.entry.peer !== void 0 && d.item.driftPeer !== null
|
|
432
|
+
return decisions.filter((d) => d.chosen.kind !== "keep" || d.item.entry.peer !== void 0 && d.item.driftPeer !== null).length;
|
|
352
433
|
}
|
|
353
434
|
/**
|
|
354
435
|
* Apply the interactive result: the (already validated) non-interop edits plus
|
|
@@ -410,7 +491,7 @@ function projectDecisions(items, full) {
|
|
|
410
491
|
});
|
|
411
492
|
continue;
|
|
412
493
|
}
|
|
413
|
-
if (i.driftPeer !== null
|
|
494
|
+
if (i.driftPeer !== null) {
|
|
414
495
|
const keep = i.candidates.find((c) => c.kind === "keep");
|
|
415
496
|
if (keep) {
|
|
416
497
|
out.push({
|
|
@@ -431,6 +512,92 @@ function projectDecisions(items, full) {
|
|
|
431
512
|
return out;
|
|
432
513
|
}
|
|
433
514
|
/**
|
|
515
|
+
* Project every evaluated entry for `--preview` and the non-interactive
|
|
516
|
+
* `--dry-run`: the rows the projection shows, and a scope counting what the
|
|
517
|
+
* display filter left out, so the summary tallies the whole catalog. Under
|
|
518
|
+
* `full` the workspace rows and the locked family rows join the table as the
|
|
519
|
+
* dialog shows them: catalogs in config order, a family's row where its first
|
|
520
|
+
* member sits.
|
|
521
|
+
*
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
function projectPreview(items, families, full) {
|
|
525
|
+
const decisions = [];
|
|
526
|
+
const locked = /* @__PURE__ */ new Map();
|
|
527
|
+
const slots = [];
|
|
528
|
+
let hiddenUpToDate = 0;
|
|
529
|
+
let hiddenWorkspace = 0;
|
|
530
|
+
for (const item of items) {
|
|
531
|
+
const { entry } = item;
|
|
532
|
+
if (item.readOnly === true) {
|
|
533
|
+
const keep = item.candidates.find((c) => c.kind === "keep");
|
|
534
|
+
if (full && keep) slots.push(decisions.push({
|
|
535
|
+
item,
|
|
536
|
+
chosen: keep
|
|
537
|
+
}) - 1);
|
|
538
|
+
else hiddenWorkspace++;
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (entry.family !== void 0 && !families.includes(entry.family)) {
|
|
542
|
+
const key = `${entry.catalog}\0${entry.family}`;
|
|
543
|
+
const seen = locked.get(key);
|
|
544
|
+
const newer = item.upToDate ? 0 : 1;
|
|
545
|
+
if (seen === void 0) slots.push(key);
|
|
546
|
+
locked.set(key, seen === void 0 ? {
|
|
547
|
+
catalog: entry.catalog,
|
|
548
|
+
family: entry.family,
|
|
549
|
+
members: 1,
|
|
550
|
+
newer
|
|
551
|
+
} : {
|
|
552
|
+
...seen,
|
|
553
|
+
members: seen.members + 1,
|
|
554
|
+
newer: seen.newer + newer
|
|
555
|
+
});
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
const projected = projectDecisions([item], full);
|
|
559
|
+
if (projected.length === 0) hiddenUpToDate++;
|
|
560
|
+
for (const decision of projected) slots.push(decisions.push(decision) - 1);
|
|
561
|
+
}
|
|
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
|
+
});
|
|
568
|
+
return {
|
|
569
|
+
decisions,
|
|
570
|
+
scope: {
|
|
571
|
+
hidden: {
|
|
572
|
+
upToDate: hiddenUpToDate,
|
|
573
|
+
workspace: hiddenWorkspace,
|
|
574
|
+
families: full ? 0 : rows.length,
|
|
575
|
+
members: full ? 0 : rows.reduce((n, r) => n + r.members, 0)
|
|
576
|
+
},
|
|
577
|
+
locked: full ? rows : [],
|
|
578
|
+
order
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* The preview document of a catalog source: every entry is evaluated (the
|
|
584
|
+
* registry-owned ones, locked family members included, resolved), then
|
|
585
|
+
* {@link projectPreview} decides what shows.
|
|
586
|
+
*
|
|
587
|
+
* @internal
|
|
588
|
+
*/
|
|
589
|
+
function previewOf(entries, families, resolver, gate, full) {
|
|
590
|
+
return Effect.gen(function* () {
|
|
591
|
+
const { moving, locked } = partitionEntries(entries, "npm", families);
|
|
592
|
+
const versions = yield* resolveGatedVersions([...moving, ...locked], resolver, gate, yield* Clock.currentTimeMillis);
|
|
593
|
+
const { decisions, scope } = projectPreview(yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message }))), families, full);
|
|
594
|
+
return {
|
|
595
|
+
doc: summaryDoc(decisions, void 0, void 0, scope),
|
|
596
|
+
versions
|
|
597
|
+
};
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
434
601
|
* Build the `--preview` projection without writing: the summary document, and
|
|
435
602
|
* the packages the registry could not resolve (which render as up to date and
|
|
436
603
|
* would otherwise be invisible in the projection).
|
|
@@ -439,12 +606,11 @@ function projectDecisions(items, full) {
|
|
|
439
606
|
*/
|
|
440
607
|
function runUpgradePreview(opts) {
|
|
441
608
|
return Effect.gen(function* () {
|
|
442
|
-
const
|
|
443
|
-
const gate = yield* computeGate(source, opts.file, opts.resolver);
|
|
444
|
-
const versions = yield*
|
|
445
|
-
const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
|
|
609
|
+
const read = yield* readCatalogSource(opts.file, opts.catalog);
|
|
610
|
+
const gate = yield* computeGate(read.source, opts.file, opts.resolver);
|
|
611
|
+
const { doc, versions } = yield* previewOf(read.entries, opts.families ?? [], opts.resolver, gate, opts.full);
|
|
446
612
|
return {
|
|
447
|
-
doc
|
|
613
|
+
doc,
|
|
448
614
|
unresolved: versions.unresolved,
|
|
449
615
|
causes: versions.causes
|
|
450
616
|
};
|
|
@@ -460,10 +626,11 @@ function runUpgradePreview(opts) {
|
|
|
460
626
|
*
|
|
461
627
|
* @internal
|
|
462
628
|
*/
|
|
463
|
-
function checkOutcome(changed) {
|
|
629
|
+
function checkOutcome(changed, locked = []) {
|
|
630
|
+
const info = lockedDoc(locked);
|
|
464
631
|
if (changed.length === 0) return {
|
|
465
632
|
exitCode: 0,
|
|
466
|
-
doc: [Doc.line("Catalogs are in sync.")]
|
|
633
|
+
doc: [Doc.line("Catalogs are in sync."), ...info]
|
|
467
634
|
};
|
|
468
635
|
return {
|
|
469
636
|
exitCode: 1,
|
|
@@ -474,10 +641,31 @@ function checkOutcome(changed) {
|
|
|
474
641
|
"Run ",
|
|
475
642
|
Doc.code("rolldown-pnpm-config upgrade --yes"),
|
|
476
643
|
" to apply."
|
|
477
|
-
])
|
|
644
|
+
]),
|
|
645
|
+
...info
|
|
478
646
|
]
|
|
479
647
|
};
|
|
480
648
|
}
|
|
649
|
+
/**
|
|
650
|
+
* The informational block for locked family members with a newer version:
|
|
651
|
+
* never drift, so it never moves the exit code. Names the `--family` flag
|
|
652
|
+
* that would move each family.
|
|
653
|
+
*
|
|
654
|
+
* @internal
|
|
655
|
+
*/
|
|
656
|
+
function lockedDoc(locked) {
|
|
657
|
+
if (locked.length === 0) return [];
|
|
658
|
+
const families = [...new Set(locked.flatMap((r) => r.family === void 0 ? [] : [r.family]))];
|
|
659
|
+
return [
|
|
660
|
+
Doc.line(`Locked family members with a newer version (not drift): ${locked.length}`),
|
|
661
|
+
Doc.lines(locked.map((r) => ` ${r.name} ${r.from} -> ${r.to ?? r.from} (family ${r.family})`), { wrap: false }),
|
|
662
|
+
Doc.line([
|
|
663
|
+
"Run ",
|
|
664
|
+
Doc.code(`rolldown-pnpm-config upgrade --yes ${families.map((f) => `--family ${f}`).join(" ")}`),
|
|
665
|
+
" to move them."
|
|
666
|
+
])
|
|
667
|
+
];
|
|
668
|
+
}
|
|
481
669
|
/** Project a drift row to its stable `--json` object: catalog/pkg/from/to?/source, camelCase, `to` omitted (never null) when unknown. */
|
|
482
670
|
function driftRowJson(row) {
|
|
483
671
|
return {
|
|
@@ -485,9 +673,14 @@ function driftRowJson(row) {
|
|
|
485
673
|
pkg: row.pkg,
|
|
486
674
|
from: row.from,
|
|
487
675
|
...row.to !== void 0 ? { to: row.to } : {},
|
|
488
|
-
source: row.source
|
|
676
|
+
source: row.source,
|
|
677
|
+
...row.family !== void 0 ? { family: row.family } : {}
|
|
489
678
|
};
|
|
490
679
|
}
|
|
680
|
+
/** The `locked` key of a JSON document: present only when a locked member has a newer version. */
|
|
681
|
+
function lockedJson(locked) {
|
|
682
|
+
return locked.length === 0 ? {} : { locked: locked.map(driftRowJson) };
|
|
683
|
+
}
|
|
491
684
|
/**
|
|
492
685
|
* The `--check --format json` outcome. stdout carries exactly one JSON
|
|
493
686
|
* document (`data`, printed by `CliFormat.print` on one line) in EVERY case —
|
|
@@ -523,7 +716,8 @@ function checkJsonOutcome(result) {
|
|
|
523
716
|
data: {
|
|
524
717
|
command: "check",
|
|
525
718
|
inSync: changed.length === 0,
|
|
526
|
-
drift: changed.map(driftRowJson)
|
|
719
|
+
drift: changed.map(driftRowJson),
|
|
720
|
+
...lockedJson(result.success.locked)
|
|
527
721
|
}
|
|
528
722
|
};
|
|
529
723
|
}
|
|
@@ -565,7 +759,8 @@ function upgradeJsonOutcome(result, dryRun) {
|
|
|
565
759
|
pkg: c.pkg,
|
|
566
760
|
ceiling: c.ceiling,
|
|
567
761
|
blockedBy: c.blockedBy
|
|
568
|
-
}))
|
|
762
|
+
})),
|
|
763
|
+
...lockedJson(r.locked)
|
|
569
764
|
} };
|
|
570
765
|
}
|
|
571
766
|
/**
|
|
@@ -609,38 +804,6 @@ function resolveTargetFile(fileOpt) {
|
|
|
609
804
|
function skippedChangesetsMessage(skipped) {
|
|
610
805
|
return [skipped.length === 1 ? "Skipped 1 malformed changeset; the workspace packages it names resolve to their current version, not their next:" : `Skipped ${skipped.length} malformed changesets; the workspace packages they name resolve to their current version, not their next:`, ...skipped.map((s) => ` ${s.file}: ${s.message}`)].join("\n");
|
|
611
806
|
}
|
|
612
|
-
/**
|
|
613
|
-
* Collects the workspace resolvers one upgrade run builds, so the run reports
|
|
614
|
-
* every pending changeset they skipped exactly once, whichever path it took.
|
|
615
|
-
* `report` is the run's finalizer: a warning on stderr, unless `silence` was
|
|
616
|
-
* called because the run already failed with that list (`runUpgrade`).
|
|
617
|
-
*/
|
|
618
|
-
function skippedChangesetsTracker() {
|
|
619
|
-
const resolvers = [];
|
|
620
|
-
let silenced = false;
|
|
621
|
-
const collect = () => {
|
|
622
|
-
const byFile = /* @__PURE__ */ new Map();
|
|
623
|
-
for (const r of resolvers) for (const s of r.skippedChangesets()) byFile.set(s.file, s);
|
|
624
|
-
return [...byFile.values()];
|
|
625
|
-
};
|
|
626
|
-
return {
|
|
627
|
-
track: (resolver) => {
|
|
628
|
-
resolvers.push(resolver);
|
|
629
|
-
return resolver;
|
|
630
|
-
},
|
|
631
|
-
silence: () => {
|
|
632
|
-
silenced = true;
|
|
633
|
-
},
|
|
634
|
-
report: Effect.suspend(() => {
|
|
635
|
-
const skipped = silenced ? [] : collect();
|
|
636
|
-
return skipped.length > 0 ? Doc.print(warningDoc(skippedChangesetsMessage(skipped)), { stream: "stderr" }) : Effect.void;
|
|
637
|
-
})
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
/** Whether a run failed on a malformed pending changeset, which its failure report already lists. */
|
|
641
|
-
function isChangesetFailure(error) {
|
|
642
|
-
return (error instanceof UpgradeError || error instanceof CheckFailedError) && error.kind === "changeset";
|
|
643
|
-
}
|
|
644
807
|
/** Print the unresolved-packages warning to stderr, when there is one. */
|
|
645
808
|
function warnUnresolved(unresolved, causes) {
|
|
646
809
|
return unresolved.length > 0 ? Doc.print(warningDoc(unresolvedMessage(unresolved, causes)), { stream: "stderr" }) : Effect.void;
|
|
@@ -652,13 +815,22 @@ function warnUnresolved(unresolved, causes) {
|
|
|
652
815
|
* moved ahead of the walk). Interactively the live table IS the reconcile;
|
|
653
816
|
* `--yes`/CI keeps the auto-reconcile (`runUpgrade`). Each phase reports
|
|
654
817
|
* progress, which an interactive run draws as a live view.
|
|
818
|
+
*
|
|
819
|
+
* A workspace interop entry is a read-only row, but it stays in its catalog's
|
|
820
|
+
* group, pinned at its current version (`pinned`), so an npm pick whose peer
|
|
821
|
+
* it does not satisfy shows as a conflict, as `runUpgrade` reports it.
|
|
822
|
+
*
|
|
823
|
+
* @internal
|
|
655
824
|
*/
|
|
656
|
-
function resolveForWalk(entries, resolver, gate,
|
|
825
|
+
function resolveForWalk(entries, resolver, gate, report, manifestPeers) {
|
|
657
826
|
return Effect.gen(function* () {
|
|
658
|
-
const
|
|
827
|
+
const { moving, locked } = partitionEntries(entries, "npm");
|
|
828
|
+
const owned = [...moving, ...locked];
|
|
829
|
+
const versions = yield* resolveGatedVersions(owned, resolver, gate, yield* Clock.currentTimeMillis, resolveProgress(report));
|
|
659
830
|
const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
|
|
831
|
+
const pinned = new Set(entries.filter((e) => e.strategy === "interop" && e.source === "workspace"));
|
|
660
832
|
const interopByCatalog = /* @__PURE__ */ new Map();
|
|
661
|
-
for (const e of
|
|
833
|
+
for (const e of [...owned, ...pinned]) {
|
|
662
834
|
if (e.strategy !== "interop") continue;
|
|
663
835
|
const list = interopByCatalog.get(e.catalog) ?? [];
|
|
664
836
|
list.push(e);
|
|
@@ -666,7 +838,7 @@ function resolveForWalk(entries, resolver, gate, workspaceResolver, report) {
|
|
|
666
838
|
}
|
|
667
839
|
const interopModels = /* @__PURE__ */ new Map();
|
|
668
840
|
if (interopByCatalog.size > 0) {
|
|
669
|
-
const fetchPeer = makePeerFetcher(resolver);
|
|
841
|
+
const fetchPeer = makePeerFetcher(manifestPeers === void 0 ? resolver : withWorkspacePeers(resolver, workspaceMembers([...pinned]), manifestPeers));
|
|
670
842
|
yield* report({
|
|
671
843
|
_tag: "Phase",
|
|
672
844
|
label: "Resolving peer dependencies",
|
|
@@ -675,7 +847,7 @@ function resolveForWalk(entries, resolver, gate, workspaceResolver, report) {
|
|
|
675
847
|
for (const [catalog, group] of interopByCatalog) {
|
|
676
848
|
const candByPkg = /* @__PURE__ */ new Map();
|
|
677
849
|
for (const e of group) {
|
|
678
|
-
const it = items.find((i) => i.entry.catalog === catalog && i.entry.pkg === e.pkg);
|
|
850
|
+
const it = pinned.has(e) ? void 0 : items.find((i) => i.entry.catalog === catalog && i.entry.pkg === e.pkg);
|
|
679
851
|
candByPkg.set(e.pkg, it ? it.candidates.map((c) => c.version) : [bareVersion(e.currentRange)]);
|
|
680
852
|
}
|
|
681
853
|
interopModels.set(catalog, yield* buildGroupModel(candByPkg, fetchPeer));
|
|
@@ -693,10 +865,76 @@ function resolveForWalk(entries, resolver, gate, workspaceResolver, report) {
|
|
|
693
865
|
versions,
|
|
694
866
|
items,
|
|
695
867
|
interopByCatalog,
|
|
696
|
-
interopModels
|
|
868
|
+
interopModels,
|
|
869
|
+
pinned
|
|
697
870
|
};
|
|
698
871
|
});
|
|
699
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* The interactive interop write: the user's final picks and the live-derived
|
|
875
|
+
* peer floors, written as picked (no auto-downgrade; the live table already
|
|
876
|
+
* surfaced any conflict). A `pinned` member is read in at its current version
|
|
877
|
+
* so its dependents' peers and conflicts count it, but gets no edit and is
|
|
878
|
+
* never counted as a change.
|
|
879
|
+
*
|
|
880
|
+
* @internal
|
|
881
|
+
*/
|
|
882
|
+
function walkInteropEdits(interopByCatalog, interopModels, decisions, pinned) {
|
|
883
|
+
const edits = [];
|
|
884
|
+
const conflicts = [];
|
|
885
|
+
let changed = 0;
|
|
886
|
+
for (const [catalog, group] of interopByCatalog) {
|
|
887
|
+
const model = interopModels.get(catalog);
|
|
888
|
+
if (model === void 0) continue;
|
|
889
|
+
const selected = /* @__PURE__ */ new Map();
|
|
890
|
+
for (const e of group) {
|
|
891
|
+
const d = decisions.find((dd) => dd.item.entry.catalog === catalog && dd.item.entry.pkg === e.pkg);
|
|
892
|
+
selected.set(e.pkg, d ? d.chosen.version : bareVersion(e.currentRange));
|
|
893
|
+
}
|
|
894
|
+
const { peer, conflict } = computeGroupPeers(model, selected);
|
|
895
|
+
const moving = group.filter((e) => !pinned.has(e));
|
|
896
|
+
edits.push(...buildInteropEdits(moving, {
|
|
897
|
+
resolved: selected,
|
|
898
|
+
peers: peer,
|
|
899
|
+
conflicts: []
|
|
900
|
+
}));
|
|
901
|
+
for (const [pkg, blockedBy] of conflict) conflicts.push({
|
|
902
|
+
pkg,
|
|
903
|
+
ceiling: selected.get(pkg) ?? "",
|
|
904
|
+
blockedBy
|
|
905
|
+
});
|
|
906
|
+
for (const e of moving) {
|
|
907
|
+
const version = selected.get(e.pkg);
|
|
908
|
+
if (version === void 0) continue;
|
|
909
|
+
const rangeChanged = `${e.operator}${version}` !== e.currentRange;
|
|
910
|
+
const newPeer = peer.get(e.pkg);
|
|
911
|
+
const peerChanged = newPeer !== void 0 && (e.peer ? newPeer !== e.peer.value : true);
|
|
912
|
+
if (rangeChanged || peerChanged) changed++;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return {
|
|
916
|
+
edits,
|
|
917
|
+
conflicts,
|
|
918
|
+
changed
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Fail with a usage error (exit 64) when `--family` names a family the config
|
|
923
|
+
* does not declare, listing the declared names, or when any catalog's
|
|
924
|
+
* `families` could not be read statically. A config that cannot be found
|
|
925
|
+
* or read is left to the run itself, whose report (a JSON document under
|
|
926
|
+
* `--format json`) covers it.
|
|
927
|
+
*/
|
|
928
|
+
function validateFamilies(fileOpt, names) {
|
|
929
|
+
if (names.length === 0) return Effect.void;
|
|
930
|
+
return resolveTargetFile(fileOpt).pipe(Effect.flatMap((file) => readCatalogSource(file)), Effect.option, Effect.flatMap((read) => {
|
|
931
|
+
if (Option.isNone(read)) return Effect.void;
|
|
932
|
+
const { families: declared, unreadFamilies } = read.value;
|
|
933
|
+
if (unreadFamilies.length > 0) return Effect.fail(new UpgradeUsageError({ message: unreadFamiliesMessage(unreadFamilies) }));
|
|
934
|
+
const unknown = names.filter((n) => !declared.includes(n));
|
|
935
|
+
return unknown.length === 0 ? Effect.void : Effect.fail(new UpgradeUsageError({ message: unknownFamilyMessage(unknown, declared) }));
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
700
938
|
const fileArg = Argument.File("file").pipe(Argument.withDescription("The config file to upgrade (autodetected in the current directory when omitted)"), Argument.optional);
|
|
701
939
|
const yesFlag = Flag.Boolean("yes").pipe(Flag.withAlias("y"), Flag.withDescription("Apply the latest in-range version of every entry without asking (never a major)"), Flag.withDefault(false));
|
|
702
940
|
const dryRunFlag = Flag.Boolean("dry-run").pipe(Flag.withDescription("Run the whole flow and report what would change, but write nothing"), Flag.withDefault(false));
|
|
@@ -704,6 +942,7 @@ const catalogOption = Flag.String("catalog").pipe(Flag.withDescription("Only upg
|
|
|
704
942
|
const previewFlag = Flag.Boolean("preview").pipe(Flag.withDescription("Print the default picks as a summary and exit"), Flag.withDefault(false));
|
|
705
943
|
const fullFlag = Flag.Boolean("full").pipe(Flag.withDescription("Include up-to-date packages in a printed summary"), Flag.withDefault(false));
|
|
706
944
|
const checkFlag = Flag.Boolean("check").pipe(Flag.withDescription("Exit 1 when --yes would change anything (a drift gate; never writes)"), Flag.withDefault(false));
|
|
945
|
+
const familyOption = Flag.String("family").pipe(Flag.withDescription("Also move the members of this locked family (repeatable), each to its newest version within its breaking line (the major from 1.0, the minor for 0.x)"), Flag.atLeast(0));
|
|
707
946
|
const formatFlag = CliFormat.flag(["auto", "json"], { description: "Output format: auto (for whoever is reading) or json (one JSON document on stdout, with --check, --yes or --dry-run)" });
|
|
708
947
|
/** JSON mode writes one single-line document, so a bash gate can pipe it straight into jq. */
|
|
709
948
|
const ONE_LINE = { indent: 0 };
|
|
@@ -723,11 +962,15 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
723
962
|
preview: previewFlag,
|
|
724
963
|
full: fullFlag,
|
|
725
964
|
check: checkFlag,
|
|
726
|
-
format: formatFlag
|
|
727
|
-
|
|
728
|
-
|
|
965
|
+
format: formatFlag,
|
|
966
|
+
family: familyOption
|
|
967
|
+
}, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format, family }) => {
|
|
729
968
|
const catalogName = Option.getOrUndefined(catalog);
|
|
730
|
-
const
|
|
969
|
+
const families = [...family];
|
|
970
|
+
const scope = {
|
|
971
|
+
...catalogName === void 0 ? {} : { catalog: catalogName },
|
|
972
|
+
...families.length === 0 ? {} : { families }
|
|
973
|
+
};
|
|
731
974
|
return Effect.gen(function* () {
|
|
732
975
|
const jsonRejection = validateFormatMode({
|
|
733
976
|
format,
|
|
@@ -737,12 +980,11 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
737
980
|
preview
|
|
738
981
|
});
|
|
739
982
|
if (jsonRejection !== null) return yield* Effect.fail(jsonRejection);
|
|
983
|
+
yield* validateFamilies(fileOpt, families);
|
|
740
984
|
const resolver = yield* RegistryResolver;
|
|
741
|
-
const workspaceOf = (file) => skippedChangesets.track(makeWorkspaceResolver(findWorkspaceRoot(dirname(file))));
|
|
742
985
|
const nonInteractive = (forceDryRun) => resolveTargetFile(fileOpt).pipe(Effect.flatMap((file) => runUpgrade({
|
|
743
986
|
file,
|
|
744
987
|
resolver,
|
|
745
|
-
workspaceResolver: workspaceOf(file),
|
|
746
988
|
dryRun: forceDryRun || dryRun,
|
|
747
989
|
...scope
|
|
748
990
|
})), Effect.result);
|
|
@@ -757,7 +999,7 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
757
999
|
}, ONE_LINE);
|
|
758
1000
|
return yield* Effect.fail(failure);
|
|
759
1001
|
}
|
|
760
|
-
const outcome =
|
|
1002
|
+
const outcome = Result.isSuccess(result) ? checkOutcome(result.success.changed, result.success.locked) : checkOutcome([]);
|
|
761
1003
|
yield* CliFormat.print(format, {
|
|
762
1004
|
doc: () => outcome.doc,
|
|
763
1005
|
json: () => json.data
|
|
@@ -774,13 +1016,11 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
774
1016
|
return;
|
|
775
1017
|
}
|
|
776
1018
|
const file = yield* resolveTargetFile(fileOpt);
|
|
777
|
-
const workspaceResolver = workspaceOf(file);
|
|
778
1019
|
if (preview) {
|
|
779
1020
|
const { doc, unresolved, causes } = yield* runUpgradePreview({
|
|
780
1021
|
file,
|
|
781
1022
|
resolver,
|
|
782
1023
|
full,
|
|
783
|
-
workspaceResolver,
|
|
784
1024
|
...scope
|
|
785
1025
|
});
|
|
786
1026
|
yield* Doc.print(doc);
|
|
@@ -791,11 +1031,11 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
791
1031
|
file,
|
|
792
1032
|
resolver,
|
|
793
1033
|
dryRun,
|
|
794
|
-
workspaceResolver,
|
|
795
1034
|
onProgress: resolveProgress(report),
|
|
796
1035
|
...scope
|
|
797
1036
|
}));
|
|
798
1037
|
yield* dryRun ? CliMessage.info(`Dry run — no changes written. ${Fmt.plural(result.updated, "package")} would be updated; skipped ${result.skipped.length}.`) : CliMessage.success(`Updated ${Fmt.plural(result.updated, "package")}; skipped ${result.skipped.length}.`);
|
|
1038
|
+
if (result.locked.length > 0) yield* Doc.print(lockedDoc(result.locked));
|
|
799
1039
|
if (result.conflicts.length > 0) {
|
|
800
1040
|
const lines = result.conflicts.map((c) => ` ${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`);
|
|
801
1041
|
yield* Doc.print(warningDoc(["Interop conflicts (left at your pick):", ...lines].join("\n")), { stream: "stderr" });
|
|
@@ -805,17 +1045,16 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
805
1045
|
const { source, entries } = yield* readCatalogSource(file, catalogName);
|
|
806
1046
|
const gate = yield* computeGate(source, file, resolver);
|
|
807
1047
|
if (!(yield* CliInteractive)) {
|
|
808
|
-
const versions = yield*
|
|
809
|
-
const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
|
|
1048
|
+
const { doc: projection, versions } = yield* previewOf(entries, families, resolver, gate, full);
|
|
810
1049
|
const note = dryRun ? "(dry run — nothing written)" : "(not interactive — run with --yes to apply, or in a terminal to choose)";
|
|
811
1050
|
yield* Doc.print([
|
|
812
|
-
...
|
|
1051
|
+
...projection,
|
|
813
1052
|
Doc.line(""),
|
|
814
1053
|
Doc.line(Doc.text(note, "muted"))
|
|
815
1054
|
]);
|
|
816
1055
|
return yield* warnUnresolved(versions.unresolved, versions.causes);
|
|
817
1056
|
}
|
|
818
|
-
const { versions, items, interopByCatalog, interopModels } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate,
|
|
1057
|
+
const { versions, items, interopByCatalog, interopModels, pinned } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, report, manifestPeerReader(findWorkspaceRoot(dirname(file)))));
|
|
819
1058
|
if (items.length === 0) {
|
|
820
1059
|
yield* warnUnresolved(versions.unresolved, versions.causes);
|
|
821
1060
|
return yield* CliMessage.info(nothingToUpgradeMessage(0));
|
|
@@ -824,42 +1063,13 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
824
1063
|
items,
|
|
825
1064
|
dryRun,
|
|
826
1065
|
unresolved: versions.unresolved,
|
|
827
|
-
interopModels
|
|
1066
|
+
interopModels,
|
|
1067
|
+
open: families
|
|
828
1068
|
})).pipe(Effect.map(Option.some), Effect.catchTag("Cancelled", (cancel) => cancel.reason === "escape" ? Effect.succeed(Option.none()) : Effect.fail(cancel)));
|
|
829
1069
|
if (Option.isNone(picked)) return yield* CliMessage.info("cancelled; nothing written");
|
|
830
|
-
const decisions = picked.value;
|
|
1070
|
+
const decisions = picked.value.filter((d) => d.item.readOnly !== true);
|
|
831
1071
|
const nonInteropDecisions = decisions.filter((d) => d.item.entry.strategy !== "interop");
|
|
832
|
-
const interopEdits =
|
|
833
|
-
const allConflicts = [];
|
|
834
|
-
let interopChanged = 0;
|
|
835
|
-
for (const [catalog, group] of interopByCatalog) {
|
|
836
|
-
const model = interopModels.get(catalog);
|
|
837
|
-
if (model === void 0) continue;
|
|
838
|
-
const selected = /* @__PURE__ */ new Map();
|
|
839
|
-
for (const e of group) {
|
|
840
|
-
const d = decisions.find((dd) => dd.item.entry.catalog === catalog && dd.item.entry.pkg === e.pkg);
|
|
841
|
-
selected.set(e.pkg, d ? d.chosen.version : bareVersion(e.currentRange));
|
|
842
|
-
}
|
|
843
|
-
const { peer, conflict } = computeGroupPeers(model, selected);
|
|
844
|
-
interopEdits.push(...buildInteropEdits(group, {
|
|
845
|
-
resolved: selected,
|
|
846
|
-
peers: peer,
|
|
847
|
-
conflicts: []
|
|
848
|
-
}));
|
|
849
|
-
for (const [pkg, blockedBy] of conflict) allConflicts.push({
|
|
850
|
-
pkg,
|
|
851
|
-
ceiling: selected.get(pkg) ?? "",
|
|
852
|
-
blockedBy
|
|
853
|
-
});
|
|
854
|
-
for (const e of group) {
|
|
855
|
-
const version = selected.get(e.pkg);
|
|
856
|
-
if (version === void 0) continue;
|
|
857
|
-
const rangeChanged = `${e.operator}${version}` !== e.currentRange;
|
|
858
|
-
const newPeer = peer.get(e.pkg);
|
|
859
|
-
const peerChanged = newPeer !== void 0 && (e.peer ? newPeer !== e.peer.value : true);
|
|
860
|
-
if (rangeChanged || peerChanged) interopChanged++;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
1072
|
+
const { edits: interopEdits, conflicts: allConflicts, changed: interopChanged } = walkInteropEdits(interopByCatalog, interopModels, decisions, pinned);
|
|
863
1073
|
const planned = buildEdits(nonInteropDecisions);
|
|
864
1074
|
const { accepted, rejected } = yield* validateEdits(planned, versions.raw);
|
|
865
1075
|
const acceptedPkgs = new Set(accepted.map((e) => e.pkg));
|
|
@@ -868,7 +1078,7 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
868
1078
|
const changed = countChangedDecisions(nonInteropDecisions.filter((d) => acceptedPkgs.has(d.item.entry.pkg))) + interopChanged;
|
|
869
1079
|
yield* dryRun ? CliMessage.info(`Dry run — no changes written. ${Fmt.plural(changed, "change")} would be applied.`) : CliMessage.success(`Applied ${Fmt.plural(changed, "change")}.`);
|
|
870
1080
|
yield* warnUnresolved(versions.unresolved, versions.causes);
|
|
871
|
-
})
|
|
1081
|
+
});
|
|
872
1082
|
}).pipe(Command.withDescription("Upgrade catalog versions in a config file"));
|
|
873
1083
|
|
|
874
|
-
export { CHECK_FAILED_LABEL, CheckFailedError, UpgradeError, UpgradeUsageError, applyInteropAndDecisions, checkJsonOutcome, checkOutcome, computeGate, countChangedDecisions, nothingToUpgradeMessage, projectDecisions, readCatalogSource, resolveGatedVersions, resolveProgress, resolveTargetFile, runUpgrade, runUpgradePreview, skippedChangesetsMessage, unknownCatalogMessage, unresolvedMessage, upgradeCommand, upgradeJsonOutcome, validateFormatMode };
|
|
1084
|
+
export { CHECK_FAILED_LABEL, CheckFailedError, UpgradeError, UpgradeUsageError, applyInteropAndDecisions, checkJsonOutcome, checkOutcome, computeGate, countChangedDecisions, lockedDoc, nothingToUpgradeMessage, partitionEntries, projectDecisions, projectPreview, readCatalogSource, resolveForWalk, resolveGatedVersions, resolveProgress, resolveTargetFile, runUpgrade, runUpgradePreview, skippedChangesetsMessage, unknownCatalogMessage, unknownFamilyMessage, unreadFamiliesMessage, unresolvedMessage, upgradeCommand, upgradeJsonOutcome, validateFormatMode, walkInteropEdits };
|