rolldown-pnpm-config 2.4.3 → 2.4.5

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 CHANGED
@@ -81,7 +81,7 @@ npx rolldown-pnpm-config upgrade
81
81
  # Applied <n> changes.
82
82
  ```
83
83
 
84
- The command shows an interactive table by default — every catalog package at once, one row per package, `●`/`○` bubbles, modeled on `pnpm up -i`. `--yes` takes the latest in-range version for every package without prompting and fails hard on any warning or unresolvable package name; `--dry-run` runs the identical table and skips only the write; `--catalog <name>` restricts the table to one catalog. Pass `--preview` for a non-interactive projection of what an upgrade would do, with `--full` to show up-to-date entries too. The output is colorized in a supporting terminal. For packages that declare a `strategy`, the command also resyncs their materialized peer range, preserving any prerelease identifier rather than rebuilding it from parsed version parts. See [upgrading catalogs](https://github.com/spencerbeggs/rolldown-pnpm-config/blob/main/docs/05-upgrading-catalogs.md) for the full surface.
84
+ The command shows an interactive table by default — every catalog package at once, one row per package, `●`/`○` bubbles, modeled on `pnpm up -i`. `--yes` takes the latest in-range version for every package without prompting and fails hard on any warning or unresolvable package name; `--dry-run` runs the identical table and skips only the write; `--catalog <name>` scopes every mode — the table, `--preview`, `--check`, `--yes` and `--dry-run` — to one catalog, and fails on a name the config does not declare. Pass `--preview` for a non-interactive projection of what an upgrade would do, with `--full` to show up-to-date entries too. The output is colorized in a supporting terminal. For packages that declare a `strategy`, the command also resyncs their materialized peer range, preserving any prerelease identifier rather than rebuilding it from parsed version parts. See [upgrading catalogs](https://github.com/spencerbeggs/rolldown-pnpm-config/blob/main/docs/05-upgrading-catalogs.md) for the full surface.
85
85
 
86
86
  ## Exporting to pnpm-workspace.yaml
87
87
 
@@ -75,21 +75,46 @@ var CheckFailedError = class extends Data.TaggedError("CheckFailedError") {
75
75
  function writeSource(file, next) {
76
76
  return AtomicFile.write(file, next).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot write ${file}` })));
77
77
  }
78
- /** Read a config file and statically discover its catalog entries. @internal */
79
- function readCatalogSource(file) {
78
+ /**
79
+ * Read a config file and statically discover its catalog entries. With
80
+ * `catalog`, the entries and skipped names are scoped to that one catalog,
81
+ * and a name the config does not declare fails (`kind: "catalog"`) rather
82
+ * than silently matching nothing. Every `upgrade` mode reads through here, so
83
+ * `--catalog` scopes them all alike.
84
+ *
85
+ * @internal
86
+ */
87
+ function readCatalogSource(file, catalog) {
80
88
  return Effect.gen(function* () {
81
89
  const source = yield* (yield* FileSystem.FileSystem).readFileString(file).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot read ${file}` })));
82
- const { entries, skipped } = yield* Effect.try({
90
+ const { entries, skipped, skippedRefs, catalogs } = yield* Effect.try({
83
91
  try: () => discoverCatalogEntries(source, file),
84
92
  catch: (e) => new UpgradeError({ message: Fmt.describe(e) })
85
93
  });
86
- return {
94
+ if (catalog === void 0) return {
87
95
  source,
88
96
  entries,
89
97
  skipped
90
98
  };
99
+ if (!catalogs.includes(catalog)) return yield* Effect.fail(new UpgradeError({
100
+ message: unknownCatalogMessage(catalog, catalogs),
101
+ kind: "catalog"
102
+ }));
103
+ return {
104
+ source,
105
+ entries: filterEntriesByCatalog(entries, catalog),
106
+ skipped: skippedRefs.filter((r) => r.catalog === catalog).map((r) => `${r.catalog}.${r.pkg}`)
107
+ };
91
108
  });
92
109
  }
110
+ /**
111
+ * The message for a `--catalog` that names no catalog the config declares.
112
+ *
113
+ * @internal
114
+ */
115
+ function unknownCatalogMessage(catalog, declared) {
116
+ return `No catalog named "${catalog}" in the config (${declared.length === 0 ? "it declares no catalogs" : `declared: ${declared.join(", ")}`})`;
117
+ }
93
118
  /** Combine the config-declared and pnpm-resolved release-age gates (strictest of both). @internal */
94
119
  function computeGate(source, file, resolver) {
95
120
  return Effect.gen(function* () {
@@ -194,8 +219,9 @@ function resolveProgress(report) {
194
219
  * materialize its managed peer offline from the current range.
195
220
  *
196
221
  * This path runs UNATTENDED (`--yes`, i.e. CI), so it fails hard rather than
197
- * degrading: any peer-strategy warning, or any planned edit no published
198
- * version satisfies, aborts the run and writes NOTHING. A warning that scrolls
222
+ * degrading: any peer-strategy warning, any planned edit no published
223
+ * version satisfies, or a malformed pending changeset read while resolving a
224
+ * workspace-sourced entry, aborts the run and writes NOTHING. A warning that scrolls
199
225
  * past unread in a CI log is a bad range in a published artifact. The
200
226
  * interactive path is deliberately more forgiving (see `upgradeCommand`).
201
227
  *
@@ -203,10 +229,15 @@ function resolveProgress(report) {
203
229
  */
204
230
  function runUpgrade(opts) {
205
231
  return Effect.gen(function* () {
206
- const { source, entries, skipped } = yield* readCatalogSource(opts.file);
232
+ const { source, entries, skipped } = yield* readCatalogSource(opts.file, opts.catalog);
207
233
  const gate = yield* computeGate(source, opts.file, opts.resolver);
208
234
  const versionsByPkg = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, opts.onProgress, opts.workspaceResolver);
209
235
  if (versionsByPkg.unresolved.length > 0) return yield* Effect.fail(new UpgradeError({ message: unresolvedMessage(versionsByPkg.unresolved) }));
236
+ const skippedChangesets = opts.workspaceResolver?.skippedChangesets() ?? [];
237
+ if (skippedChangesets.length > 0) return yield* Effect.fail(new UpgradeError({
238
+ message: skippedChangesetsMessage(skippedChangesets),
239
+ kind: "changeset"
240
+ }));
210
241
  const edits = [];
211
242
  const interopEdits = [];
212
243
  const warnings = [];
@@ -376,7 +407,7 @@ function projectDecisions(items, full) {
376
407
  */
377
408
  function runUpgradePreview(opts) {
378
409
  return Effect.gen(function* () {
379
- const { source, entries } = yield* readCatalogSource(opts.file);
410
+ const { source, entries } = yield* readCatalogSource(opts.file, opts.catalog);
380
411
  const gate = yield* computeGate(source, opts.file, opts.resolver);
381
412
  const versions = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, void 0, opts.workspaceResolver);
382
413
  const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
@@ -470,7 +501,8 @@ function checkJsonOutcome(result) {
470
501
  * real apply; `changed` uses the same row object as check's `drift`. A failure
471
502
  * emits an error document on stdout and is returned as `failure`, which the
472
503
  * command fails with (non-zero exit, human message on stderr); `error.kind` is
473
- * `"peer-strategy"` for a peer-strategy refusal and `"resolution"` otherwise.
504
+ * `"peer-strategy"` for a peer-strategy refusal, `"changeset"` for a run that
505
+ * resolved past a malformed pending changeset, and `"resolution"` otherwise.
474
506
  *
475
507
  * @internal
476
508
  */
@@ -534,6 +566,48 @@ function resolveTargetFile(fileOpt) {
534
566
  return picked.file;
535
567
  });
536
568
  }
569
+ /**
570
+ * The report for pending changesets the workspace resolver skipped: one line
571
+ * per file with why it would not parse. A skipped file's bumps are dropped,
572
+ * so the workspace packages it names resolve to their current version.
573
+ *
574
+ * @internal
575
+ */
576
+ function skippedChangesetsMessage(skipped) {
577
+ 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");
578
+ }
579
+ /**
580
+ * Collects the workspace resolvers one upgrade run builds, so the run reports
581
+ * every pending changeset they skipped exactly once, whichever path it took.
582
+ * `report` is the run's finalizer: a warning on stderr, unless `silence` was
583
+ * called because the run already failed with that list (`runUpgrade`).
584
+ */
585
+ function skippedChangesetsTracker() {
586
+ const resolvers = [];
587
+ let silenced = false;
588
+ const collect = () => {
589
+ const byFile = /* @__PURE__ */ new Map();
590
+ for (const r of resolvers) for (const s of r.skippedChangesets()) byFile.set(s.file, s);
591
+ return [...byFile.values()];
592
+ };
593
+ return {
594
+ track: (resolver) => {
595
+ resolvers.push(resolver);
596
+ return resolver;
597
+ },
598
+ silence: () => {
599
+ silenced = true;
600
+ },
601
+ report: Effect.suspend(() => {
602
+ const skipped = silenced ? [] : collect();
603
+ return skipped.length > 0 ? Doc.print(warningDoc(skippedChangesetsMessage(skipped)), { stream: "stderr" }) : Effect.void;
604
+ })
605
+ };
606
+ }
607
+ /** Whether a run failed on a malformed pending changeset, which its failure report already lists. */
608
+ function isChangesetFailure(error) {
609
+ return (error instanceof UpgradeError || error instanceof CheckFailedError) && error.kind === "changeset";
610
+ }
537
611
  /** Print the unresolved-packages warning to stderr, when there is one. */
538
612
  function warnUnresolved(unresolved) {
539
613
  return unresolved.length > 0 ? Doc.print(warningDoc(unresolvedMessage(unresolved)), { stream: "stderr" }) : Effect.void;
@@ -618,144 +692,151 @@ const upgradeCommand = Command.make("upgrade", {
618
692
  full: fullFlag,
619
693
  check: checkFlag,
620
694
  format: formatFlag
621
- }, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format }) => Effect.gen(function* () {
622
- const jsonRejection = validateFormatMode({
623
- format,
624
- check,
625
- yes,
626
- dryRun,
627
- preview
628
- });
629
- if (jsonRejection !== null) return yield* Effect.fail(jsonRejection);
630
- const resolver = yield* RegistryResolver;
631
- const workspaceOf = (file) => makeWorkspaceResolver(findWorkspaceRoot(dirname(file)));
632
- const nonInteractive = (forceDryRun) => resolveTargetFile(fileOpt).pipe(Effect.flatMap((file) => runUpgrade({
633
- file,
634
- resolver,
635
- workspaceResolver: workspaceOf(file),
636
- dryRun: forceDryRun || dryRun
637
- })), Effect.result);
638
- if (check) {
639
- const result = yield* nonInteractive(true);
640
- const json = checkJsonOutcome(result);
641
- const failure = json.failure;
642
- if (failure !== void 0) {
643
- if (format === "json") yield* CliFormat.print("json", {
644
- doc: () => failure[CliDoc](),
645
- json: () => json.data
646
- }, ONE_LINE);
647
- return yield* Effect.fail(failure);
648
- }
649
- const outcome = checkOutcome(Result.isSuccess(result) ? result.success.changed : []);
650
- yield* CliFormat.print(format, {
651
- doc: () => outcome.doc,
652
- json: () => json.data
653
- }, ONE_LINE);
654
- return yield* CliExit.set(outcome.exitCode);
655
- }
656
- if (format === "json") {
657
- const o = upgradeJsonOutcome(yield* nonInteractive(false), dryRun);
658
- yield* CliFormat.print("json", {
659
- doc: () => [],
660
- json: () => o.data
661
- }, ONE_LINE);
662
- if (o.failure !== void 0) return yield* Effect.fail(o.failure);
663
- return;
664
- }
665
- const file = yield* resolveTargetFile(fileOpt);
666
- const workspaceResolver = workspaceOf(file);
667
- if (preview) {
668
- const { doc, unresolved } = yield* runUpgradePreview({
669
- file,
670
- resolver,
671
- full,
672
- workspaceResolver
695
+ }, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format }) => {
696
+ const skippedChangesets = skippedChangesetsTracker();
697
+ const catalogName = Option.getOrUndefined(catalog);
698
+ const scope = catalogName === void 0 ? {} : { catalog: catalogName };
699
+ return Effect.gen(function* () {
700
+ const jsonRejection = validateFormatMode({
701
+ format,
702
+ check,
703
+ yes,
704
+ dryRun,
705
+ preview
673
706
  });
674
- yield* Doc.print(doc);
675
- return yield* warnUnresolved(unresolved);
676
- }
677
- if (yes) {
678
- const result = yield* withProgress((report) => runUpgrade({
707
+ if (jsonRejection !== null) return yield* Effect.fail(jsonRejection);
708
+ const resolver = yield* RegistryResolver;
709
+ const workspaceOf = (file) => skippedChangesets.track(makeWorkspaceResolver(findWorkspaceRoot(dirname(file))));
710
+ const nonInteractive = (forceDryRun) => resolveTargetFile(fileOpt).pipe(Effect.flatMap((file) => runUpgrade({
679
711
  file,
680
712
  resolver,
681
- dryRun,
682
- workspaceResolver,
683
- onProgress: resolveProgress(report)
684
- }));
685
- 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}.`);
686
- if (result.conflicts.length > 0) {
687
- const lines = result.conflicts.map((c) => ` ${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`);
688
- yield* Doc.print(warningDoc(["Interop conflicts (left at your pick):", ...lines].join("\n")), { stream: "stderr" });
713
+ workspaceResolver: workspaceOf(file),
714
+ dryRun: forceDryRun || dryRun,
715
+ ...scope
716
+ })), Effect.result);
717
+ if (check) {
718
+ const result = yield* nonInteractive(true);
719
+ const json = checkJsonOutcome(result);
720
+ const failure = json.failure;
721
+ if (failure !== void 0) {
722
+ if (format === "json") yield* CliFormat.print("json", {
723
+ doc: () => failure[CliDoc](),
724
+ json: () => json.data
725
+ }, ONE_LINE);
726
+ return yield* Effect.fail(failure);
727
+ }
728
+ const outcome = checkOutcome(Result.isSuccess(result) ? result.success.changed : []);
729
+ yield* CliFormat.print(format, {
730
+ doc: () => outcome.doc,
731
+ json: () => json.data
732
+ }, ONE_LINE);
733
+ return yield* CliExit.set(outcome.exitCode);
689
734
  }
690
- return;
691
- }
692
- const { source, entries: discovered } = yield* readCatalogSource(file);
693
- const entries = filterEntriesByCatalog(discovered, Option.getOrUndefined(catalog));
694
- const gate = yield* computeGate(source, file, resolver);
695
- if (!(yield* CliInteractive)) {
696
- const versions = yield* resolveGatedVersions(entries, resolver, gate, yield* Clock.currentTimeMillis, void 0, workspaceResolver);
697
- const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
698
- const note = dryRun ? "(dry run — nothing written)" : "(not interactive — run with --yes to apply, or in a terminal to choose)";
699
- yield* Doc.print([
700
- ...summaryDoc(projectDecisions(items, full)),
701
- Doc.line(""),
702
- Doc.line(Doc.text(note, "muted"))
703
- ]);
704
- return yield* warnUnresolved(versions.unresolved);
705
- }
706
- const { versions, items, interopByCatalog, interopModels } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, workspaceResolver, report));
707
- if (items.length === 0) {
708
- yield* warnUnresolved(versions.unresolved);
709
- return yield* CliMessage.info(nothingToUpgradeMessage(0));
710
- }
711
- const picked = yield* CliUi.run(walkScreen({
712
- items,
713
- dryRun,
714
- unresolved: versions.unresolved,
715
- interopModels
716
- })).pipe(Effect.map(Option.some), Effect.catchTag("Cancelled", (cancel) => cancel.reason === "escape" ? Effect.succeed(Option.none()) : Effect.fail(cancel)));
717
- if (Option.isNone(picked)) return yield* CliMessage.info("cancelled; nothing written");
718
- const decisions = picked.value;
719
- const nonInteropDecisions = decisions.filter((d) => d.item.entry.strategy !== "interop");
720
- const interopEdits = [];
721
- const allConflicts = [];
722
- let interopChanged = 0;
723
- for (const [catalog, group] of interopByCatalog) {
724
- const model = interopModels.get(catalog);
725
- if (model === void 0) continue;
726
- const selected = /* @__PURE__ */ new Map();
727
- for (const e of group) {
728
- const d = decisions.find((dd) => dd.item.entry.catalog === catalog && dd.item.entry.pkg === e.pkg);
729
- selected.set(e.pkg, d ? d.chosen.version : bareVersion(e.currentRange));
735
+ if (format === "json") {
736
+ const o = upgradeJsonOutcome(yield* nonInteractive(false), dryRun);
737
+ yield* CliFormat.print("json", {
738
+ doc: () => [],
739
+ json: () => o.data
740
+ }, ONE_LINE);
741
+ if (o.failure !== void 0) return yield* Effect.fail(o.failure);
742
+ return;
730
743
  }
731
- const { peer, conflict } = computeGroupPeers(model, selected);
732
- interopEdits.push(...buildInteropEdits(group, {
733
- resolved: selected,
734
- peers: peer,
735
- conflicts: []
736
- }));
737
- for (const [pkg, blockedBy] of conflict) allConflicts.push({
738
- pkg,
739
- ceiling: selected.get(pkg) ?? "",
740
- blockedBy
741
- });
742
- for (const e of group) {
743
- const version = selected.get(e.pkg);
744
- if (version === void 0) continue;
745
- const rangeChanged = `${e.operator}${version}` !== e.currentRange;
746
- const newPeer = peer.get(e.pkg);
747
- const peerChanged = newPeer !== void 0 && (e.peer ? newPeer !== e.peer.value : true);
748
- if (rangeChanged || peerChanged) interopChanged++;
744
+ const file = yield* resolveTargetFile(fileOpt);
745
+ const workspaceResolver = workspaceOf(file);
746
+ if (preview) {
747
+ const { doc, unresolved } = yield* runUpgradePreview({
748
+ file,
749
+ resolver,
750
+ full,
751
+ workspaceResolver,
752
+ ...scope
753
+ });
754
+ yield* Doc.print(doc);
755
+ return yield* warnUnresolved(unresolved);
749
756
  }
750
- }
751
- const planned = buildEdits(nonInteropDecisions);
752
- const { accepted, rejected } = yield* validateEdits(planned, versions.raw);
753
- const acceptedPkgs = new Set(accepted.map((e) => e.pkg));
754
- yield* Doc.print(summaryDoc(decisions, { conflicts: allConflicts }, rejected));
755
- if (!dryRun) yield* applyInteropAndDecisions(file, source, accepted, interopEdits);
756
- const changed = countChangedDecisions(nonInteropDecisions.filter((d) => acceptedPkgs.has(d.item.entry.pkg))) + interopChanged;
757
- yield* dryRun ? CliMessage.info(`Dry run — no changes written. ${Fmt.plural(changed, "change")} would be applied.`) : CliMessage.success(`Applied ${Fmt.plural(changed, "change")}.`);
758
- yield* warnUnresolved(versions.unresolved);
759
- })).pipe(Command.withDescription("Upgrade catalog versions in a config file"));
757
+ if (yes) {
758
+ const result = yield* withProgress((report) => runUpgrade({
759
+ file,
760
+ resolver,
761
+ dryRun,
762
+ workspaceResolver,
763
+ onProgress: resolveProgress(report),
764
+ ...scope
765
+ }));
766
+ 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}.`);
767
+ if (result.conflicts.length > 0) {
768
+ const lines = result.conflicts.map((c) => ` ${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`);
769
+ yield* Doc.print(warningDoc(["Interop conflicts (left at your pick):", ...lines].join("\n")), { stream: "stderr" });
770
+ }
771
+ return;
772
+ }
773
+ const { source, entries } = yield* readCatalogSource(file, catalogName);
774
+ const gate = yield* computeGate(source, file, resolver);
775
+ if (!(yield* CliInteractive)) {
776
+ const versions = yield* resolveGatedVersions(entries, resolver, gate, yield* Clock.currentTimeMillis, void 0, workspaceResolver);
777
+ const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
778
+ const note = dryRun ? "(dry run — nothing written)" : "(not interactive — run with --yes to apply, or in a terminal to choose)";
779
+ yield* Doc.print([
780
+ ...summaryDoc(projectDecisions(items, full)),
781
+ Doc.line(""),
782
+ Doc.line(Doc.text(note, "muted"))
783
+ ]);
784
+ return yield* warnUnresolved(versions.unresolved);
785
+ }
786
+ const { versions, items, interopByCatalog, interopModels } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, workspaceResolver, report));
787
+ if (items.length === 0) {
788
+ yield* warnUnresolved(versions.unresolved);
789
+ return yield* CliMessage.info(nothingToUpgradeMessage(0));
790
+ }
791
+ const picked = yield* CliUi.run(walkScreen({
792
+ items,
793
+ dryRun,
794
+ unresolved: versions.unresolved,
795
+ interopModels
796
+ })).pipe(Effect.map(Option.some), Effect.catchTag("Cancelled", (cancel) => cancel.reason === "escape" ? Effect.succeed(Option.none()) : Effect.fail(cancel)));
797
+ if (Option.isNone(picked)) return yield* CliMessage.info("cancelled; nothing written");
798
+ const decisions = picked.value;
799
+ const nonInteropDecisions = decisions.filter((d) => d.item.entry.strategy !== "interop");
800
+ const interopEdits = [];
801
+ const allConflicts = [];
802
+ let interopChanged = 0;
803
+ for (const [catalog, group] of interopByCatalog) {
804
+ const model = interopModels.get(catalog);
805
+ if (model === void 0) continue;
806
+ const selected = /* @__PURE__ */ new Map();
807
+ for (const e of group) {
808
+ const d = decisions.find((dd) => dd.item.entry.catalog === catalog && dd.item.entry.pkg === e.pkg);
809
+ selected.set(e.pkg, d ? d.chosen.version : bareVersion(e.currentRange));
810
+ }
811
+ const { peer, conflict } = computeGroupPeers(model, selected);
812
+ interopEdits.push(...buildInteropEdits(group, {
813
+ resolved: selected,
814
+ peers: peer,
815
+ conflicts: []
816
+ }));
817
+ for (const [pkg, blockedBy] of conflict) allConflicts.push({
818
+ pkg,
819
+ ceiling: selected.get(pkg) ?? "",
820
+ blockedBy
821
+ });
822
+ for (const e of group) {
823
+ const version = selected.get(e.pkg);
824
+ if (version === void 0) continue;
825
+ const rangeChanged = `${e.operator}${version}` !== e.currentRange;
826
+ const newPeer = peer.get(e.pkg);
827
+ const peerChanged = newPeer !== void 0 && (e.peer ? newPeer !== e.peer.value : true);
828
+ if (rangeChanged || peerChanged) interopChanged++;
829
+ }
830
+ }
831
+ const planned = buildEdits(nonInteropDecisions);
832
+ const { accepted, rejected } = yield* validateEdits(planned, versions.raw);
833
+ const acceptedPkgs = new Set(accepted.map((e) => e.pkg));
834
+ yield* Doc.print(summaryDoc(decisions, { conflicts: allConflicts }, rejected));
835
+ if (!dryRun) yield* applyInteropAndDecisions(file, source, accepted, interopEdits);
836
+ const changed = countChangedDecisions(nonInteropDecisions.filter((d) => acceptedPkgs.has(d.item.entry.pkg))) + interopChanged;
837
+ yield* dryRun ? CliMessage.info(`Dry run — no changes written. ${Fmt.plural(changed, "change")} would be applied.`) : CliMessage.success(`Applied ${Fmt.plural(changed, "change")}.`);
838
+ yield* warnUnresolved(versions.unresolved);
839
+ }).pipe(Effect.tapError((error) => isChangesetFailure(error) ? Effect.sync(skippedChangesets.silence) : Effect.void), Effect.ensuring(skippedChangesets.report));
840
+ }).pipe(Command.withDescription("Upgrade catalog versions in a config file"));
760
841
 
761
- export { CHECK_FAILED_LABEL, CheckFailedError, UpgradeError, UpgradeUsageError, applyInteropAndDecisions, checkJsonOutcome, checkOutcome, computeGate, countChangedDecisions, nothingToUpgradeMessage, projectDecisions, readCatalogSource, resolveGatedVersions, resolveProgress, resolveTargetFile, runUpgrade, runUpgradePreview, unresolvedMessage, upgradeCommand, upgradeJsonOutcome, validateFormatMode };
842
+ 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 };
package/cli/discover.js CHANGED
@@ -22,6 +22,11 @@ function operatorOf(range) {
22
22
  * Each package whose range is a simple-operator string literal yields a
23
23
  * CatalogEntry with byte-offset spans; anything else (computed value, complex
24
24
  * range) is reported in `skipped` as `<catalog>.<pkg>` and never throws.
25
+ * `catalogs` names every declared catalog in source order, including one
26
+ * that yields no entries, so `--catalog` can tell an empty catalog from a
27
+ * typo. `skippedRefs` carries the same skips as `{ catalog, pkg }` pairs, so
28
+ * a caller can scope them by catalog identity: the flattened string cannot
29
+ * tell catalog `a` from a catalog named `a.b`.
25
30
  *
26
31
  * @internal
27
32
  */
@@ -30,21 +35,23 @@ function discoverCatalogEntries(source, filename) {
30
35
  if (result.errors.length > 0) throw new DiscoverError({ message: result.errors.map((e) => e.message).join("; ") });
31
36
  const program = result.program;
32
37
  const entries = [];
33
- const skipped = [];
34
- const arg = findPluginArg(program);
35
- if (!arg) return {
38
+ const skippedRefs = [];
39
+ const declared = [];
40
+ const finish = () => ({
36
41
  entries,
37
- skipped
38
- };
42
+ skipped: skippedRefs.map((r) => `${r.catalog}.${r.pkg}`),
43
+ skippedRefs,
44
+ catalogs: declared
45
+ });
46
+ const arg = findPluginArg(program);
47
+ if (!arg) return finish();
39
48
  const catalogs = prop(arg, "catalogs");
40
- if (catalogs?.type !== "ObjectExpression") return {
41
- entries,
42
- skipped
43
- };
49
+ if (catalogs?.type !== "ObjectExpression") return finish();
44
50
  for (const catProp of catalogs.properties ?? []) {
45
51
  if (catProp.type !== "Property") continue;
46
52
  const catalog = keyName(catProp.key);
47
53
  if (catalog === void 0) continue;
54
+ declared.push(catalog);
48
55
  const decl = catProp.value;
49
56
  if (decl.type !== "ObjectExpression") continue;
50
57
  const packages = prop(decl, "packages");
@@ -70,7 +77,10 @@ function discoverCatalogEntries(source, filename) {
70
77
  if (src?.type === "Literal" && (src.value === "registry" || src.value === "workspace")) source = src.value;
71
78
  }
72
79
  if (!rangeNode || !SIMPLE_RANGE_RE.test(rangeNode.value)) {
73
- skipped.push(`${catalog}.${pkg}`);
80
+ skippedRefs.push({
81
+ catalog,
82
+ pkg
83
+ });
74
84
  continue;
75
85
  }
76
86
  const currentRange = rangeNode.value;
@@ -89,10 +99,7 @@ function discoverCatalogEntries(source, filename) {
89
99
  });
90
100
  }
91
101
  }
92
- return {
93
- entries,
94
- skipped
95
- };
102
+ return finish();
96
103
  }
97
104
 
98
105
  export { DiscoverError, discoverCatalogEntries };
package/cli/version.js CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "2.4.3";
9
+ const CLI_VERSION = "2.4.5";
10
10
 
11
11
  export { CLI_VERSION };
@@ -2,6 +2,7 @@ import { parseVersion } from "../semver-util.js";
2
2
  import { ResolveError } from "./resolve.js";
3
3
  import { Effect, Result } from "effect";
4
4
  import { resolve } from "node:path";
5
+ import { Fmt } from "@effected/cli-kit";
5
6
  import { findWorkspaceRootSync, getWorkspacePackagesSync } from "@effected/workspaces";
6
7
  import { nodeSyncOps } from "@effected/workspaces/node-sync";
7
8
  import { PendingChangesets } from "@effected/changesets";
@@ -53,27 +54,38 @@ function readManifests(rootDir) {
53
54
  }
54
55
  /**
55
56
  * Read the pending changeset bumps under `<rootDir>/.changeset/` through
56
- * `@effected/changesets`' `PendingChangesets.readSync` (which skips readmes,
57
- * agent context files, dotfiles and non-`.md` files, and also reads the
58
- * `pre/` changesets a pre-release keeps): package name → strongest bump.
57
+ * `@effected/changesets`' `PendingChangesets.readSettledSync` (which skips
58
+ * readmes, agent context files, dotfiles and non-`.md` files, and also reads
59
+ * the `pre/` changesets a pre-release keeps): package name → strongest bump.
59
60
  * A `none` release is no bump. Total: an absent `.changeset/` lists nothing,
60
- * and an unreadable directory or any malformed changeset degrades to an
61
- * empty map (current versions), never a failure.
61
+ * an unlistable directory degrades to no bumps (current versions), and a
62
+ * malformed changeset drops only its own bumps and is returned in `skipped`
63
+ * for the caller to report, never a failure.
62
64
  */
63
65
  function readPendingBumps(rootDir) {
64
- const out = /* @__PURE__ */ new Map();
65
- const pending = PendingChangesets.readSync(rootDir);
66
- if (Result.isFailure(pending)) return out;
67
- for (const changeset of pending.success) for (const [pkg, release] of changeset.releases) {
66
+ const bumps = /* @__PURE__ */ new Map();
67
+ const pending = PendingChangesets.readSettledSync(rootDir);
68
+ if (Result.isFailure(pending)) return {
69
+ bumps,
70
+ skipped: []
71
+ };
72
+ const skipped = pending.success.failures.map((f) => ({
73
+ file: `.changeset/${f.file}`,
74
+ message: Fmt.errorText(f.error)
75
+ }));
76
+ for (const changeset of pending.success.changesets) for (const [pkg, release] of changeset.releases) {
68
77
  if (release === "none") continue;
69
- const prev = out.get(pkg);
70
- if (prev === void 0 || BUMP_ORDER[release] > BUMP_ORDER[prev]) out.set(pkg, release);
78
+ const prev = bumps.get(pkg);
79
+ if (prev === void 0 || BUMP_ORDER[release] > BUMP_ORDER[prev]) bumps.set(pkg, release);
71
80
  }
72
- return out;
81
+ return {
82
+ bumps,
83
+ skipped
84
+ };
73
85
  }
74
86
  /** Apply the strongest pending bump for each package already present in `versions`. */
75
87
  function applyPendingBumps(rootDir, versions) {
76
- const bumps = readPendingBumps(rootDir);
88
+ const { bumps, skipped } = readPendingBumps(rootDir);
77
89
  for (const [pkg, bump] of bumps) {
78
90
  const current = versions.get(pkg);
79
91
  if (current === void 0) continue;
@@ -81,19 +93,20 @@ function applyPendingBumps(rootDir, versions) {
81
93
  if (parsed === null) continue;
82
94
  versions.set(pkg, parsed.bump[bump]().toString());
83
95
  }
96
+ return skipped;
84
97
  }
85
98
  /**
86
- * Read every workspace package's NEXT release version: the current
87
- * manifest version overlaid with the bump implied by any pending changeset.
88
- * Absent or unreadable `.changeset/` degrades to current versions.
99
+ * {@link readWorkspaceVersions}, plus the pending changesets it skipped.
89
100
  *
90
101
  * @internal
91
102
  */
92
- function readWorkspaceVersions(rootDir, manifests = readManifests(rootDir)) {
93
- const out = /* @__PURE__ */ new Map();
94
- for (const [name, manifest] of manifests) out.set(name, manifest.version);
95
- applyPendingBumps(rootDir, out);
96
- return out;
103
+ function readWorkspaceState(rootDir, manifests = readManifests(rootDir)) {
104
+ const versions = /* @__PURE__ */ new Map();
105
+ for (const [name, manifest] of manifests) versions.set(name, manifest.version);
106
+ return {
107
+ versions,
108
+ skipped: applyPendingBumps(rootDir, versions)
109
+ };
97
110
  }
98
111
  /**
99
112
  * The plain (layer-less) workspace resolver value, for callers that route
@@ -105,16 +118,17 @@ function readWorkspaceVersions(rootDir, manifests = readManifests(rootDir)) {
105
118
  */
106
119
  function makeWorkspaceResolver(rootDir) {
107
120
  let manifests;
108
- let versions;
121
+ let state;
109
122
  const load = () => {
110
123
  manifests ??= readManifests(rootDir);
111
- versions ??= readWorkspaceVersions(rootDir, manifests);
124
+ state ??= readWorkspaceState(rootDir, manifests);
112
125
  return {
113
126
  manifests,
114
- versions
127
+ versions: state.versions
115
128
  };
116
129
  };
117
130
  return {
131
+ skippedChangesets: () => state?.skipped ?? [],
118
132
  versions: (pkg) => {
119
133
  const v = load().versions.get(pkg);
120
134
  return v === void 0 ? Effect.fail(new ResolveError({
@@ -143,4 +157,4 @@ function findWorkspaceRoot(startDir) {
143
157
  }) ?? resolve(startDir);
144
158
  }
145
159
 
146
- export { findWorkspaceRoot, makeWorkspaceResolver, readManifests, readWorkspaceVersions };
160
+ export { findWorkspaceRoot, makeWorkspaceResolver, readManifests, readWorkspaceState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -36,23 +36,23 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@effect/platform-node": "~4.1.2",
39
- "@effected/changesets": "^0.1.0",
39
+ "@effected/changesets": "^0.2.0",
40
40
  "@effected/cli-kit": "^0.27.1",
41
41
  "@effected/env": "^0.11.0",
42
42
  "@effected/files": "^0.2.0",
43
43
  "@effected/glob": "^0.20.0",
44
- "@effected/npm": "^0.31.0",
44
+ "@effected/npm": "^0.32.0",
45
45
  "@effected/semver": "^0.22.0",
46
46
  "@effected/walker": "^0.26.0",
47
- "@effected/workspaces": "^0.44.0",
47
+ "@effected/workspaces": "^0.44.1",
48
48
  "@effected/yaml": "^0.29.0",
49
49
  "effect": "~4.1.2",
50
50
  "ink": "^8.0.0",
51
- "oxc-parser": "^0.157.0",
51
+ "oxc-parser": "^0.158.0",
52
52
  "react": "^19.3.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "rolldown": "^1.2.0"
55
+ "rolldown": "^1.2.16"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "rolldown": {