rolldown-pnpm-config 2.4.4 → 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 +1 -1
- package/cli/commands/upgrade.js +41 -12
- package/cli/discover.js +21 -14
- package/cli/version.js +1 -1
- package/package.json +1 -1
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>`
|
|
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
|
|
package/cli/commands/upgrade.js
CHANGED
|
@@ -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
|
-
/**
|
|
79
|
-
|
|
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* () {
|
|
@@ -204,7 +229,7 @@ function resolveProgress(report) {
|
|
|
204
229
|
*/
|
|
205
230
|
function runUpgrade(opts) {
|
|
206
231
|
return Effect.gen(function* () {
|
|
207
|
-
const { source, entries, skipped } = yield* readCatalogSource(opts.file);
|
|
232
|
+
const { source, entries, skipped } = yield* readCatalogSource(opts.file, opts.catalog);
|
|
208
233
|
const gate = yield* computeGate(source, opts.file, opts.resolver);
|
|
209
234
|
const versionsByPkg = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, opts.onProgress, opts.workspaceResolver);
|
|
210
235
|
if (versionsByPkg.unresolved.length > 0) return yield* Effect.fail(new UpgradeError({ message: unresolvedMessage(versionsByPkg.unresolved) }));
|
|
@@ -382,7 +407,7 @@ function projectDecisions(items, full) {
|
|
|
382
407
|
*/
|
|
383
408
|
function runUpgradePreview(opts) {
|
|
384
409
|
return Effect.gen(function* () {
|
|
385
|
-
const { source, entries } = yield* readCatalogSource(opts.file);
|
|
410
|
+
const { source, entries } = yield* readCatalogSource(opts.file, opts.catalog);
|
|
386
411
|
const gate = yield* computeGate(source, opts.file, opts.resolver);
|
|
387
412
|
const versions = yield* resolveGatedVersions(entries, opts.resolver, gate, yield* Clock.currentTimeMillis, void 0, opts.workspaceResolver);
|
|
388
413
|
const items = yield* buildWalkItems(entries, versions.gated).pipe(Effect.mapError((e) => new UpgradeError({ message: e.message })));
|
|
@@ -669,6 +694,8 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
669
694
|
format: formatFlag
|
|
670
695
|
}, ({ file: fileOpt, yes, dryRun, catalog, preview, full, check, format }) => {
|
|
671
696
|
const skippedChangesets = skippedChangesetsTracker();
|
|
697
|
+
const catalogName = Option.getOrUndefined(catalog);
|
|
698
|
+
const scope = catalogName === void 0 ? {} : { catalog: catalogName };
|
|
672
699
|
return Effect.gen(function* () {
|
|
673
700
|
const jsonRejection = validateFormatMode({
|
|
674
701
|
format,
|
|
@@ -684,7 +711,8 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
684
711
|
file,
|
|
685
712
|
resolver,
|
|
686
713
|
workspaceResolver: workspaceOf(file),
|
|
687
|
-
dryRun: forceDryRun || dryRun
|
|
714
|
+
dryRun: forceDryRun || dryRun,
|
|
715
|
+
...scope
|
|
688
716
|
})), Effect.result);
|
|
689
717
|
if (check) {
|
|
690
718
|
const result = yield* nonInteractive(true);
|
|
@@ -720,7 +748,8 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
720
748
|
file,
|
|
721
749
|
resolver,
|
|
722
750
|
full,
|
|
723
|
-
workspaceResolver
|
|
751
|
+
workspaceResolver,
|
|
752
|
+
...scope
|
|
724
753
|
});
|
|
725
754
|
yield* Doc.print(doc);
|
|
726
755
|
return yield* warnUnresolved(unresolved);
|
|
@@ -731,7 +760,8 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
731
760
|
resolver,
|
|
732
761
|
dryRun,
|
|
733
762
|
workspaceResolver,
|
|
734
|
-
onProgress: resolveProgress(report)
|
|
763
|
+
onProgress: resolveProgress(report),
|
|
764
|
+
...scope
|
|
735
765
|
}));
|
|
736
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}.`);
|
|
737
767
|
if (result.conflicts.length > 0) {
|
|
@@ -740,8 +770,7 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
740
770
|
}
|
|
741
771
|
return;
|
|
742
772
|
}
|
|
743
|
-
const { source, entries
|
|
744
|
-
const entries = filterEntriesByCatalog(discovered, Option.getOrUndefined(catalog));
|
|
773
|
+
const { source, entries } = yield* readCatalogSource(file, catalogName);
|
|
745
774
|
const gate = yield* computeGate(source, file, resolver);
|
|
746
775
|
if (!(yield* CliInteractive)) {
|
|
747
776
|
const versions = yield* resolveGatedVersions(entries, resolver, gate, yield* Clock.currentTimeMillis, void 0, workspaceResolver);
|
|
@@ -810,4 +839,4 @@ const upgradeCommand = Command.make("upgrade", {
|
|
|
810
839
|
}).pipe(Effect.tapError((error) => isChangesetFailure(error) ? Effect.sync(skippedChangesets.silence) : Effect.void), Effect.ensuring(skippedChangesets.report));
|
|
811
840
|
}).pipe(Command.withDescription("Upgrade catalog versions in a config file"));
|
|
812
841
|
|
|
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 };
|
|
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
|
|
34
|
-
const
|
|
35
|
-
|
|
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
|
-
|
|
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