rolldown-pnpm-config 2.4.3 → 2.4.4
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 +189 -137
- package/cli/version.js +1 -1
- package/cli/workspace-resolve.js +39 -25
- package/package.json +6 -6
package/cli/commands/upgrade.js
CHANGED
|
@@ -194,8 +194,9 @@ function resolveProgress(report) {
|
|
|
194
194
|
* materialize its managed peer offline from the current range.
|
|
195
195
|
*
|
|
196
196
|
* This path runs UNATTENDED (`--yes`, i.e. CI), so it fails hard rather than
|
|
197
|
-
* degrading: any peer-strategy warning,
|
|
198
|
-
* version satisfies,
|
|
197
|
+
* degrading: any peer-strategy warning, any planned edit no published
|
|
198
|
+
* version satisfies, or a malformed pending changeset read while resolving a
|
|
199
|
+
* workspace-sourced entry, aborts the run and writes NOTHING. A warning that scrolls
|
|
199
200
|
* past unread in a CI log is a bad range in a published artifact. The
|
|
200
201
|
* interactive path is deliberately more forgiving (see `upgradeCommand`).
|
|
201
202
|
*
|
|
@@ -207,6 +208,11 @@ function runUpgrade(opts) {
|
|
|
207
208
|
const gate = yield* computeGate(source, opts.file, opts.resolver);
|
|
208
209
|
const versionsByPkg = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, opts.onProgress, opts.workspaceResolver);
|
|
209
210
|
if (versionsByPkg.unresolved.length > 0) return yield* Effect.fail(new UpgradeError({ message: unresolvedMessage(versionsByPkg.unresolved) }));
|
|
211
|
+
const skippedChangesets = opts.workspaceResolver?.skippedChangesets() ?? [];
|
|
212
|
+
if (skippedChangesets.length > 0) return yield* Effect.fail(new UpgradeError({
|
|
213
|
+
message: skippedChangesetsMessage(skippedChangesets),
|
|
214
|
+
kind: "changeset"
|
|
215
|
+
}));
|
|
210
216
|
const edits = [];
|
|
211
217
|
const interopEdits = [];
|
|
212
218
|
const warnings = [];
|
|
@@ -470,7 +476,8 @@ function checkJsonOutcome(result) {
|
|
|
470
476
|
* real apply; `changed` uses the same row object as check's `drift`. A failure
|
|
471
477
|
* emits an error document on stdout and is returned as `failure`, which the
|
|
472
478
|
* command fails with (non-zero exit, human message on stderr); `error.kind` is
|
|
473
|
-
* `"peer-strategy"` for a peer-strategy refusal
|
|
479
|
+
* `"peer-strategy"` for a peer-strategy refusal, `"changeset"` for a run that
|
|
480
|
+
* resolved past a malformed pending changeset, and `"resolution"` otherwise.
|
|
474
481
|
*
|
|
475
482
|
* @internal
|
|
476
483
|
*/
|
|
@@ -534,6 +541,48 @@ function resolveTargetFile(fileOpt) {
|
|
|
534
541
|
return picked.file;
|
|
535
542
|
});
|
|
536
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* The report for pending changesets the workspace resolver skipped: one line
|
|
546
|
+
* per file with why it would not parse. A skipped file's bumps are dropped,
|
|
547
|
+
* so the workspace packages it names resolve to their current version.
|
|
548
|
+
*
|
|
549
|
+
* @internal
|
|
550
|
+
*/
|
|
551
|
+
function skippedChangesetsMessage(skipped) {
|
|
552
|
+
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");
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Collects the workspace resolvers one upgrade run builds, so the run reports
|
|
556
|
+
* every pending changeset they skipped exactly once, whichever path it took.
|
|
557
|
+
* `report` is the run's finalizer: a warning on stderr, unless `silence` was
|
|
558
|
+
* called because the run already failed with that list (`runUpgrade`).
|
|
559
|
+
*/
|
|
560
|
+
function skippedChangesetsTracker() {
|
|
561
|
+
const resolvers = [];
|
|
562
|
+
let silenced = false;
|
|
563
|
+
const collect = () => {
|
|
564
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
565
|
+
for (const r of resolvers) for (const s of r.skippedChangesets()) byFile.set(s.file, s);
|
|
566
|
+
return [...byFile.values()];
|
|
567
|
+
};
|
|
568
|
+
return {
|
|
569
|
+
track: (resolver) => {
|
|
570
|
+
resolvers.push(resolver);
|
|
571
|
+
return resolver;
|
|
572
|
+
},
|
|
573
|
+
silence: () => {
|
|
574
|
+
silenced = true;
|
|
575
|
+
},
|
|
576
|
+
report: Effect.suspend(() => {
|
|
577
|
+
const skipped = silenced ? [] : collect();
|
|
578
|
+
return skipped.length > 0 ? Doc.print(warningDoc(skippedChangesetsMessage(skipped)), { stream: "stderr" }) : Effect.void;
|
|
579
|
+
})
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/** Whether a run failed on a malformed pending changeset, which its failure report already lists. */
|
|
583
|
+
function isChangesetFailure(error) {
|
|
584
|
+
return (error instanceof UpgradeError || error instanceof CheckFailedError) && error.kind === "changeset";
|
|
585
|
+
}
|
|
537
586
|
/** Print the unresolved-packages warning to stderr, when there is one. */
|
|
538
587
|
function warnUnresolved(unresolved) {
|
|
539
588
|
return unresolved.length > 0 ? Doc.print(warningDoc(unresolvedMessage(unresolved)), { stream: "stderr" }) : Effect.void;
|
|
@@ -618,144 +667,147 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
618
667
|
full: fullFlag,
|
|
619
668
|
check: checkFlag,
|
|
620
669
|
format: formatFlag
|
|
621
|
-
}, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format }) =>
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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
|
|
670
|
+
}, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format }) => {
|
|
671
|
+
const skippedChangesets = skippedChangesetsTracker();
|
|
672
|
+
return Effect.gen(function* () {
|
|
673
|
+
const jsonRejection = validateFormatMode({
|
|
674
|
+
format,
|
|
675
|
+
check,
|
|
676
|
+
yes,
|
|
677
|
+
dryRun,
|
|
678
|
+
preview
|
|
673
679
|
});
|
|
674
|
-
yield*
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
const result = yield* withProgress((report) => runUpgrade({
|
|
680
|
+
if (jsonRejection !== null) return yield* Effect.fail(jsonRejection);
|
|
681
|
+
const resolver = yield* RegistryResolver;
|
|
682
|
+
const workspaceOf = (file) => skippedChangesets.track(makeWorkspaceResolver(findWorkspaceRoot(dirname(file))));
|
|
683
|
+
const nonInteractive = (forceDryRun) => resolveTargetFile(fileOpt).pipe(Effect.flatMap((file) => runUpgrade({
|
|
679
684
|
file,
|
|
680
685
|
resolver,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
686
|
+
workspaceResolver: workspaceOf(file),
|
|
687
|
+
dryRun: forceDryRun || dryRun
|
|
688
|
+
})), Effect.result);
|
|
689
|
+
if (check) {
|
|
690
|
+
const result = yield* nonInteractive(true);
|
|
691
|
+
const json = checkJsonOutcome(result);
|
|
692
|
+
const failure = json.failure;
|
|
693
|
+
if (failure !== void 0) {
|
|
694
|
+
if (format === "json") yield* CliFormat.print("json", {
|
|
695
|
+
doc: () => failure[CliDoc](),
|
|
696
|
+
json: () => json.data
|
|
697
|
+
}, ONE_LINE);
|
|
698
|
+
return yield* Effect.fail(failure);
|
|
699
|
+
}
|
|
700
|
+
const outcome = checkOutcome(Result.isSuccess(result) ? result.success.changed : []);
|
|
701
|
+
yield* CliFormat.print(format, {
|
|
702
|
+
doc: () => outcome.doc,
|
|
703
|
+
json: () => json.data
|
|
704
|
+
}, ONE_LINE);
|
|
705
|
+
return yield* CliExit.set(outcome.exitCode);
|
|
689
706
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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));
|
|
707
|
+
if (format === "json") {
|
|
708
|
+
const o = upgradeJsonOutcome(yield* nonInteractive(false), dryRun);
|
|
709
|
+
yield* CliFormat.print("json", {
|
|
710
|
+
doc: () => [],
|
|
711
|
+
json: () => o.data
|
|
712
|
+
}, ONE_LINE);
|
|
713
|
+
if (o.failure !== void 0) return yield* Effect.fail(o.failure);
|
|
714
|
+
return;
|
|
730
715
|
}
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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++;
|
|
716
|
+
const file = yield* resolveTargetFile(fileOpt);
|
|
717
|
+
const workspaceResolver = workspaceOf(file);
|
|
718
|
+
if (preview) {
|
|
719
|
+
const { doc, unresolved } = yield* runUpgradePreview({
|
|
720
|
+
file,
|
|
721
|
+
resolver,
|
|
722
|
+
full,
|
|
723
|
+
workspaceResolver
|
|
724
|
+
});
|
|
725
|
+
yield* Doc.print(doc);
|
|
726
|
+
return yield* warnUnresolved(unresolved);
|
|
749
727
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
728
|
+
if (yes) {
|
|
729
|
+
const result = yield* withProgress((report) => runUpgrade({
|
|
730
|
+
file,
|
|
731
|
+
resolver,
|
|
732
|
+
dryRun,
|
|
733
|
+
workspaceResolver,
|
|
734
|
+
onProgress: resolveProgress(report)
|
|
735
|
+
}));
|
|
736
|
+
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}.`);
|
|
737
|
+
if (result.conflicts.length > 0) {
|
|
738
|
+
const lines = result.conflicts.map((c) => ` ${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`);
|
|
739
|
+
yield* Doc.print(warningDoc(["Interop conflicts (left at your pick):", ...lines].join("\n")), { stream: "stderr" });
|
|
740
|
+
}
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const { source, entries: discovered } = yield* readCatalogSource(file);
|
|
744
|
+
const entries = filterEntriesByCatalog(discovered, Option.getOrUndefined(catalog));
|
|
745
|
+
const gate = yield* computeGate(source, file, resolver);
|
|
746
|
+
if (!(yield* CliInteractive)) {
|
|
747
|
+
const versions = yield* resolveGatedVersions(entries, resolver, gate, yield* Clock.currentTimeMillis, void 0, workspaceResolver);
|
|
748
|
+
const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
|
|
749
|
+
const note = dryRun ? "(dry run — nothing written)" : "(not interactive — run with --yes to apply, or in a terminal to choose)";
|
|
750
|
+
yield* Doc.print([
|
|
751
|
+
...summaryDoc(projectDecisions(items, full)),
|
|
752
|
+
Doc.line(""),
|
|
753
|
+
Doc.line(Doc.text(note, "muted"))
|
|
754
|
+
]);
|
|
755
|
+
return yield* warnUnresolved(versions.unresolved);
|
|
756
|
+
}
|
|
757
|
+
const { versions, items, interopByCatalog, interopModels } = yield* withProgress((report) => resolveForWalk(entries, resolver, gate, workspaceResolver, report));
|
|
758
|
+
if (items.length === 0) {
|
|
759
|
+
yield* warnUnresolved(versions.unresolved);
|
|
760
|
+
return yield* CliMessage.info(nothingToUpgradeMessage(0));
|
|
761
|
+
}
|
|
762
|
+
const picked = yield* CliUi.run(walkScreen({
|
|
763
|
+
items,
|
|
764
|
+
dryRun,
|
|
765
|
+
unresolved: versions.unresolved,
|
|
766
|
+
interopModels
|
|
767
|
+
})).pipe(Effect.map(Option.some), Effect.catchTag("Cancelled", (cancel) => cancel.reason === "escape" ? Effect.succeed(Option.none()) : Effect.fail(cancel)));
|
|
768
|
+
if (Option.isNone(picked)) return yield* CliMessage.info("cancelled; nothing written");
|
|
769
|
+
const decisions = picked.value;
|
|
770
|
+
const nonInteropDecisions = decisions.filter((d) => d.item.entry.strategy !== "interop");
|
|
771
|
+
const interopEdits = [];
|
|
772
|
+
const allConflicts = [];
|
|
773
|
+
let interopChanged = 0;
|
|
774
|
+
for (const [catalog, group] of interopByCatalog) {
|
|
775
|
+
const model = interopModels.get(catalog);
|
|
776
|
+
if (model === void 0) continue;
|
|
777
|
+
const selected = /* @__PURE__ */ new Map();
|
|
778
|
+
for (const e of group) {
|
|
779
|
+
const d = decisions.find((dd) => dd.item.entry.catalog === catalog && dd.item.entry.pkg === e.pkg);
|
|
780
|
+
selected.set(e.pkg, d ? d.chosen.version : bareVersion(e.currentRange));
|
|
781
|
+
}
|
|
782
|
+
const { peer, conflict } = computeGroupPeers(model, selected);
|
|
783
|
+
interopEdits.push(...buildInteropEdits(group, {
|
|
784
|
+
resolved: selected,
|
|
785
|
+
peers: peer,
|
|
786
|
+
conflicts: []
|
|
787
|
+
}));
|
|
788
|
+
for (const [pkg, blockedBy] of conflict) allConflicts.push({
|
|
789
|
+
pkg,
|
|
790
|
+
ceiling: selected.get(pkg) ?? "",
|
|
791
|
+
blockedBy
|
|
792
|
+
});
|
|
793
|
+
for (const e of group) {
|
|
794
|
+
const version = selected.get(e.pkg);
|
|
795
|
+
if (version === void 0) continue;
|
|
796
|
+
const rangeChanged = `${e.operator}${version}` !== e.currentRange;
|
|
797
|
+
const newPeer = peer.get(e.pkg);
|
|
798
|
+
const peerChanged = newPeer !== void 0 && (e.peer ? newPeer !== e.peer.value : true);
|
|
799
|
+
if (rangeChanged || peerChanged) interopChanged++;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
const planned = buildEdits(nonInteropDecisions);
|
|
803
|
+
const { accepted, rejected } = yield* validateEdits(planned, versions.raw);
|
|
804
|
+
const acceptedPkgs = new Set(accepted.map((e) => e.pkg));
|
|
805
|
+
yield* Doc.print(summaryDoc(decisions, { conflicts: allConflicts }, rejected));
|
|
806
|
+
if (!dryRun) yield* applyInteropAndDecisions(file, source, accepted, interopEdits);
|
|
807
|
+
const changed = countChangedDecisions(nonInteropDecisions.filter((d) => acceptedPkgs.has(d.item.entry.pkg))) + interopChanged;
|
|
808
|
+
yield* dryRun ? CliMessage.info(`Dry run — no changes written. ${Fmt.plural(changed, "change")} would be applied.`) : CliMessage.success(`Applied ${Fmt.plural(changed, "change")}.`);
|
|
809
|
+
yield* warnUnresolved(versions.unresolved);
|
|
810
|
+
}).pipe(Effect.tapError((error) => isChangesetFailure(error) ? Effect.sync(skippedChangesets.silence) : Effect.void), Effect.ensuring(skippedChangesets.report));
|
|
811
|
+
}).pipe(Command.withDescription("Upgrade catalog versions in a config file"));
|
|
760
812
|
|
|
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 };
|
|
813
|
+
export { CHECK_FAILED_LABEL, CheckFailedError, UpgradeError, UpgradeUsageError, applyInteropAndDecisions, checkJsonOutcome, checkOutcome, computeGate, countChangedDecisions, nothingToUpgradeMessage, projectDecisions, readCatalogSource, resolveGatedVersions, resolveProgress, resolveTargetFile, runUpgrade, runUpgradePreview, skippedChangesetsMessage, unresolvedMessage, upgradeCommand, upgradeJsonOutcome, validateFormatMode };
|
package/cli/version.js
CHANGED
package/cli/workspace-resolve.js
CHANGED
|
@@ -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.
|
|
57
|
-
* agent context files, dotfiles and non-`.md` files, and also reads
|
|
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
|
-
*
|
|
61
|
-
*
|
|
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
|
|
65
|
-
const pending = PendingChangesets.
|
|
66
|
-
if (Result.isFailure(pending)) return
|
|
67
|
-
|
|
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 =
|
|
70
|
-
if (prev === void 0 || BUMP_ORDER[release] > BUMP_ORDER[prev])
|
|
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
|
|
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
|
-
*
|
|
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
|
|
93
|
-
const
|
|
94
|
-
for (const [name, manifest] of manifests)
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
121
|
+
let state;
|
|
109
122
|
const load = () => {
|
|
110
123
|
manifests ??= readManifests(rootDir);
|
|
111
|
-
|
|
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,
|
|
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
|
+
"version": "2.4.4",
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
51
|
+
"oxc-parser": "^0.158.0",
|
|
52
52
|
"react": "^19.3.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"rolldown": "^1.2.
|
|
55
|
+
"rolldown": "^1.2.16"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"rolldown": {
|