rolldown-pnpm-config 3.2.1 → 4.0.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 +333 -135
- package/cli/discover.js +134 -28
- package/cli/drift.js +1 -1
- package/cli/edits.js +8 -17
- package/cli/effective.js +119 -4
- package/cli/interop.js +7 -15
- package/cli/local-merge.js +4 -1
- package/cli/plan.js +8 -3
- 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 +42 -6
- 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/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 +122 -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 +109 -12
- package/skills/rolldown-pnpm-config/references/options.md +126 -47
- package/skills/rolldown-pnpm-config/references/sync.md +32 -21
- package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
- package/plugin/overrides-from-catalogs.js +0 -151
package/cli/summary.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Doc, Fmt } from "@effected/cli-kit";
|
|
2
2
|
import { row, tone } from "./render/tone.js";
|
|
3
|
-
import { cellTone, displayCandidates, peerFor, tableLayout } from "./walk-reducer.js";
|
|
3
|
+
import { WORKSPACE_ROW_NOTE, cellTone, displayCandidates, familyDetail, peerFor, tableLayout } from "./walk-reducer.js";
|
|
4
4
|
|
|
5
5
|
// src/cli/summary.ts
|
|
6
|
+
const HIDDEN = " (hidden; --full shows them)";
|
|
6
7
|
/**
|
|
7
8
|
* Build the pending-decisions summary as a document: one table row per
|
|
8
9
|
* decision — mirroring the interactive selection table, catalog headers,
|
|
@@ -11,21 +12,40 @@ import { cellTone, displayCandidates, peerFor, tableLayout } from "./walk-reduce
|
|
|
11
12
|
*
|
|
12
13
|
* @internal
|
|
13
14
|
*/
|
|
14
|
-
function summaryDoc(decisions, interop, rejected) {
|
|
15
|
+
function summaryDoc(decisions, interop, rejected, scope) {
|
|
15
16
|
const lines = [];
|
|
16
17
|
let toUpdate = 0;
|
|
17
18
|
let major = 0;
|
|
18
19
|
let resync = 0;
|
|
19
|
-
let materialize = 0;
|
|
20
20
|
let upToDate = 0;
|
|
21
|
+
let workspace = 0;
|
|
22
|
+
const hidden = scope?.hidden ?? {
|
|
23
|
+
upToDate: 0,
|
|
24
|
+
workspace: 0,
|
|
25
|
+
families: 0,
|
|
26
|
+
members: 0
|
|
27
|
+
};
|
|
28
|
+
const lockedRows = [...scope?.locked ?? []];
|
|
29
|
+
const shown = /* @__PURE__ */ new Set();
|
|
30
|
+
const lockedFor = (catalog) => {
|
|
31
|
+
if (shown.has(catalog)) return;
|
|
32
|
+
shown.add(catalog);
|
|
33
|
+
for (const f of lockedRows.filter((r) => r.catalog === catalog)) lines.push(row(" ", 0, [tone(`▸ family: ${f.family}`, "plain"), tone(` (${familyDetail(f.members, f.newer)})`, "unchanged")]));
|
|
34
|
+
};
|
|
21
35
|
const { pkgWidth, maxCells, blankCell, cellText } = tableLayout(decisions.map((d) => d.item));
|
|
22
36
|
let lastCatalog = null;
|
|
23
37
|
for (const { item, chosen } of decisions) {
|
|
24
38
|
const { entry } = item;
|
|
25
39
|
if (entry.catalog !== lastCatalog) {
|
|
40
|
+
if (lastCatalog !== null) lockedFor(lastCatalog);
|
|
26
41
|
lastCatalog = entry.catalog;
|
|
27
42
|
lines.push(row(" ", 0, [tone(`── catalog: ${entry.catalog} ──`, "unchanged")]));
|
|
28
43
|
}
|
|
44
|
+
if (item.readOnly === true) {
|
|
45
|
+
workspace++;
|
|
46
|
+
lines.push(row(" ", 0, [tone(`${Fmt.pad(entry.pkg, pkgWidth + 2)}${entry.currentRange} ${WORKSPACE_ROW_NOTE}`, "unchanged")]));
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
29
49
|
const cells = displayCandidates(item);
|
|
30
50
|
const content = [tone(Fmt.pad(entry.pkg, pkgWidth + 2), "plain")];
|
|
31
51
|
for (const c of cells) {
|
|
@@ -39,12 +59,28 @@ function summaryDoc(decisions, interop, rejected) {
|
|
|
39
59
|
if (chosen.kind !== "keep") {
|
|
40
60
|
toUpdate++;
|
|
41
61
|
if (chosen.isMajor) major++;
|
|
42
|
-
if (!entry.peer && entry.strategy && chosen.peerRange) materialize++;
|
|
43
62
|
} else if (entry.peer && item.driftPeer) resync++;
|
|
44
|
-
else if (!entry.peer && item.materializePeer) materialize++;
|
|
45
63
|
else upToDate++;
|
|
46
64
|
}
|
|
47
|
-
|
|
65
|
+
if (lastCatalog !== null) lockedFor(lastCatalog);
|
|
66
|
+
for (const catalog of new Set(lockedRows.map((r) => r.catalog))) {
|
|
67
|
+
if (shown.has(catalog)) continue;
|
|
68
|
+
lines.push(row(" ", 0, [tone(`── catalog: ${catalog} ──`, "unchanged")]));
|
|
69
|
+
lockedFor(catalog);
|
|
70
|
+
}
|
|
71
|
+
const tally = [
|
|
72
|
+
`${toUpdate} to update`,
|
|
73
|
+
`${major} major`,
|
|
74
|
+
`${resync} resync`,
|
|
75
|
+
`${upToDate + hidden.upToDate} up to date${hidden.upToDate > 0 ? HIDDEN : ""}`
|
|
76
|
+
];
|
|
77
|
+
if (workspace + hidden.workspace > 0) tally.push(`${workspace + hidden.workspace} workspace${hidden.workspace > 0 ? HIDDEN : ""}`);
|
|
78
|
+
const families = lockedRows.length + hidden.families;
|
|
79
|
+
if (families > 0) {
|
|
80
|
+
const members = lockedRows.reduce((n, r) => n + r.members, 0) + hidden.members;
|
|
81
|
+
tally.push(`${families} locked ${families === 1 ? "family" : "families"} (${Fmt.plural(members, "member")})${hidden.families > 0 ? HIDDEN : ""}`);
|
|
82
|
+
}
|
|
83
|
+
lines.push(row(" ", 0, [tone(tally.join(" · "), "unchanged")]));
|
|
48
84
|
if (interop) for (const c of interop.conflicts) lines.push(row("⚠", 0, [tone(`${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`, "warn")]));
|
|
49
85
|
return Doc.concat(Doc.lines(lines, { wrap: false }), rejected !== void 0 && rejected.length > 0 && [Doc.line(""), Doc.lines([row("⚠", 0, [tone("Rejected (no published version satisfies these):", "warn")]), ...rejected.map((r) => row("⚠", 1, [tone(`${r.pkg} ${r.kind} ${r.value} — ${r.reason}`, "warn")]))], { wrap: false })]);
|
|
50
86
|
}
|
|
@@ -6,15 +6,16 @@ import { byCatalog } from "./running-list.js";
|
|
|
6
6
|
* blank line, then one bullet per package.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* With no moves the message is the headline alone
|
|
9
|
+
* With no moves the message is the headline alone, which names `catalogs` in
|
|
10
|
+
* the plural when the sync owns more than one. Package names are written
|
|
10
11
|
* bare, never as inline code: commitlint presets such as
|
|
11
12
|
* `@savvy-web/commitlint`'s `silk/body-no-markdown` reject a body with more
|
|
12
13
|
* than a couple of code spans, and a sync can move dozens of packages.
|
|
13
14
|
*
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
|
-
function renderCommitMessage(scope, moves) {
|
|
17
|
-
const headline = `chore(${scope}): sync catalog to the next release versions`;
|
|
17
|
+
function renderCommitMessage(scope, moves, catalogCount = 1) {
|
|
18
|
+
const headline = `chore(${scope}): sync ${catalogCount > 1 ? "catalogs" : "catalog"} to the next release versions`;
|
|
18
19
|
if (moves.length === 0) return `${headline}\n`;
|
|
19
20
|
return `${headline}\n\n${byCatalog(moves).flatMap(([, group]) => group.map((move) => `- ${move.pkg} ${move.from} -> ${move.to}`)).join("\n")}\n`;
|
|
20
21
|
}
|
package/cli/sync/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CliDoc } from "@effected/cli-kit";
|
|
2
|
-
import { Data, Effect, Schema } from "effect";
|
|
2
|
+
import { Data, Effect, Result, Schema } from "effect";
|
|
3
|
+
import { syncedCatalogNames } from "../../plugin/synced-catalogs.js";
|
|
3
4
|
import { failureDoc } from "../render/report.js";
|
|
4
5
|
|
|
5
6
|
// src/cli/sync/config.ts
|
|
@@ -16,13 +17,18 @@ var SyncConfigError = class extends Data.TaggedError("SyncConfigError") {
|
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
const Names = Schema.Array(Schema.String);
|
|
20
|
+
const Members = Schema.Struct({
|
|
21
|
+
scope: Schema.NonEmptyString,
|
|
22
|
+
packages: Schema.optionalKey(Names),
|
|
23
|
+
exclude: Schema.optionalKey(Names)
|
|
24
|
+
});
|
|
19
25
|
const SyncSchema = Schema.Struct({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
catalogs: Schema.optionalKey(Schema.NonEmptyArray(Schema.Struct({
|
|
27
|
+
catalog: Schema.String,
|
|
28
|
+
members: Members
|
|
29
|
+
}))),
|
|
30
|
+
catalog: Schema.optionalKey(Schema.String),
|
|
31
|
+
members: Schema.optionalKey(Members),
|
|
26
32
|
changeset: Schema.optionalKey(Schema.Struct({
|
|
27
33
|
path: Schema.optionalKey(Schema.String),
|
|
28
34
|
bump: Schema.optionalKey(Schema.Literals(["patch", "minor"]))
|
|
@@ -38,31 +44,61 @@ const SyncSchema = Schema.Struct({
|
|
|
38
44
|
}))
|
|
39
45
|
});
|
|
40
46
|
const decodeSync = Schema.decodeUnknownEffect(SyncSchema);
|
|
47
|
+
const NO_SYNC = "add `sync: { catalogs: [{ catalog, members: { scope } }] }` to the PnpmConfigPlugin config";
|
|
48
|
+
/** The pairs of either authored form, or the message naming why there are none. */
|
|
49
|
+
function pairsOf(sync) {
|
|
50
|
+
const shorthand = sync.catalog !== void 0 || sync.members !== void 0;
|
|
51
|
+
if (sync.catalogs !== void 0 && shorthand) return Result.fail("`sync` sets both sync.catalogs and the sync.catalog/sync.members shorthand: keep one of them, moving the shorthand pair into sync.catalogs");
|
|
52
|
+
const authored = sync.catalogs ?? (sync.catalog !== void 0 && sync.members !== void 0 ? [{
|
|
53
|
+
catalog: sync.catalog,
|
|
54
|
+
members: sync.members
|
|
55
|
+
}] : void 0);
|
|
56
|
+
if (authored === void 0) return Result.fail(sync.catalog === void 0 ? `\`sync\` names no catalog: ${NO_SYNC}` : "`sync.catalog` needs `members: { scope }` beside it");
|
|
57
|
+
return Result.succeed(authored.map((pair) => ({
|
|
58
|
+
catalog: pair.catalog,
|
|
59
|
+
scope: pair.members.scope,
|
|
60
|
+
packages: pair.members.packages,
|
|
61
|
+
exclude: pair.members.exclude ?? []
|
|
62
|
+
})));
|
|
63
|
+
}
|
|
41
64
|
/**
|
|
42
65
|
* Decode the statically evaluated `sync` block of a plugin config and apply
|
|
43
66
|
* its defaults. Unknown keys are rejected so a typo cannot pass for an absent
|
|
44
67
|
* setting.
|
|
45
68
|
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* `sync.catalogs` and the one-pair `sync.catalog` + `sync.members` shorthand
|
|
71
|
+
* both resolve to `pairs`; setting both fails. Two pairs naming one catalog
|
|
72
|
+
* fail, and with more than one pair `commit.scope` is required, since the
|
|
73
|
+
* single-pair default (the catalog name) no longer names one thing.
|
|
74
|
+
*
|
|
46
75
|
* @internal
|
|
47
76
|
*/
|
|
48
77
|
function resolveSyncConfig(config) {
|
|
49
|
-
if (config.sync === void 0) return Effect.fail(new SyncConfigError({ message:
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
commitScope
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
if (config.sync === void 0) return Effect.fail(new SyncConfigError({ message: `no \`sync\` block: ${NO_SYNC}` }));
|
|
79
|
+
return Effect.gen(function* () {
|
|
80
|
+
const sync = yield* decodeSync(config.sync, {
|
|
81
|
+
onExcessProperty: "error",
|
|
82
|
+
errors: "all"
|
|
83
|
+
}).pipe(Effect.mapError((error) => new SyncConfigError({ message: `invalid \`sync\` block: ${error.message}` })));
|
|
84
|
+
const pairs = yield* Effect.fromResult(pairsOf(sync)).pipe(Effect.mapError((message) => new SyncConfigError({ message })));
|
|
85
|
+
const names = syncedCatalogNames(config.sync) ?? [];
|
|
86
|
+
const twice = names.find((name, i) => names.indexOf(name) !== i);
|
|
87
|
+
if (twice !== void 0) return yield* new SyncConfigError({ message: `two sync pairs name the catalog "${twice}": merge their members into one pair` });
|
|
88
|
+
const [first] = pairs;
|
|
89
|
+
const commitScope = sync.commit?.scope ?? (pairs.length === 1 ? first?.catalog : void 0);
|
|
90
|
+
if (commitScope === void 0) return yield* new SyncConfigError({ message: `\`sync\` has ${pairs.length} pairs, so commit.scope is required: no one catalog names the commit` });
|
|
91
|
+
return {
|
|
92
|
+
pairs,
|
|
93
|
+
changesetPath: sync.changeset?.path ?? ".changeset/catalog-sync.md",
|
|
94
|
+
bump: sync.changeset?.bump ?? "patch",
|
|
95
|
+
commitScope,
|
|
96
|
+
messagePath: sync.commit?.messagePath ?? ".changeset/catalog-sync.commit.txt",
|
|
97
|
+
floors: sync.floors ?? false,
|
|
98
|
+
pnpmfile: sync.local?.pnpmfile ?? "dist/prod/npm/pkg/pnpmfile.mjs",
|
|
99
|
+
localCatalogs: sync.local?.catalogs
|
|
100
|
+
};
|
|
101
|
+
});
|
|
66
102
|
}
|
|
67
103
|
/**
|
|
68
104
|
* Decode the `sync` block from what `evaluatePluginConfig` read out of
|
package/cli/sync/local-gate.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { Fmt } from "@effected/cli-kit";
|
|
4
4
|
import { Data, Effect, Predicate } from "effect";
|
|
5
|
+
import { desugarSecondForms } from "../../plugin/second-forms.js";
|
|
5
6
|
|
|
6
7
|
// src/cli/sync/local-gate.ts
|
|
7
8
|
/**
|
|
@@ -28,30 +29,39 @@ function readServedCatalogs(pnpmfilePath) {
|
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* The catalogs the export writes into this repo's own workspace file: an
|
|
31
|
-
* explicit `local.catalogs` wins, otherwise every served catalog except
|
|
32
|
-
*
|
|
32
|
+
* explicit `local.catalogs` wins, otherwise every served catalog except each
|
|
33
|
+
* pair's catalog and its derived `:peers` and `:exact` siblings, which lag it
|
|
33
34
|
* between releases in exactly the same way.
|
|
34
35
|
*
|
|
35
36
|
* @internal
|
|
36
37
|
*/
|
|
37
38
|
function exportedCatalogNames(served, sync) {
|
|
38
39
|
if (sync.localCatalogs !== void 0) return sync.localCatalogs;
|
|
39
|
-
const managed =
|
|
40
|
-
|
|
41
|
-
`${
|
|
42
|
-
`${
|
|
43
|
-
]);
|
|
40
|
+
const managed = new Set(sync.pairs.flatMap(({ catalog }) => [
|
|
41
|
+
catalog,
|
|
42
|
+
`${catalog}:peers`,
|
|
43
|
+
`${catalog}:exact`
|
|
44
|
+
]));
|
|
44
45
|
return Object.keys(served).filter((name) => !managed.has(name));
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Per exported catalog, the packages whose served range differs from the
|
|
48
49
|
* parsed `pnpm-workspace.yaml` mapping (its `catalogs` key holds the named
|
|
49
|
-
* catalogs
|
|
50
|
+
* catalogs, and a `catalog` key, flat or nested, is the default catalog).
|
|
51
|
+
* Rows are human-readable; empty means in sync.
|
|
52
|
+
*
|
|
53
|
+
* @throws `Error` when the workspace file declares the default catalog twice
|
|
54
|
+
* or pnpm would refuse a section option. A nested sub-key beside its twin
|
|
55
|
+
* setting is accepted, the sub-key winning, as pnpm reads it.
|
|
50
56
|
*
|
|
51
57
|
* @internal
|
|
52
58
|
*/
|
|
53
59
|
function exportDrift(served, names, workspace) {
|
|
54
|
-
const
|
|
60
|
+
const flat = desugarSecondForms(workspace, "pnpm-workspace.yaml", {
|
|
61
|
+
catalogShape: "map",
|
|
62
|
+
twinConflict: "nestedWins"
|
|
63
|
+
});
|
|
64
|
+
const catalogs = Predicate.isObject(flat.catalogs) ? flat.catalogs : {};
|
|
55
65
|
const rows = [];
|
|
56
66
|
for (const name of names) {
|
|
57
67
|
const want = served[name] ?? {};
|
package/cli/sync/membership.js
CHANGED
|
@@ -52,67 +52,129 @@ function compile(source) {
|
|
|
52
52
|
return Result.mapError(GlobPattern.compileResult(source), (error) => new SyncWorkspaceError({ message: `invalid glob "${source}": ${error.message}` }));
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Publishable workspace packages in `
|
|
55
|
+
* Publishable workspace packages in a pair's `scope`, sorted: `publishConfig.access`
|
|
56
56
|
* is `"public"`, the name is not excluded and is not the plugin itself. A scope
|
|
57
57
|
* that matches no workspace package name at all, whatever its access, fails.
|
|
58
|
-
* `
|
|
58
|
+
* The pair's `packages`, when set, limits discovery to members whose workspace-relative
|
|
59
59
|
* path matches one of its globs. Unlike the upgrade resolver, an unreadable
|
|
60
60
|
* workspace fails rather than reading as empty: an empty list would pass the
|
|
61
61
|
* gate for the wrong reason.
|
|
62
62
|
*
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
function publishableMembers(rootDir,
|
|
65
|
+
function publishableMembers(rootDir, pair, pluginName) {
|
|
66
66
|
return Effect.gen(function* () {
|
|
67
67
|
if (!existsSync(join(rootDir, "pnpm-workspace.yaml"))) return yield* new SyncWorkspaceError({ message: `no pnpm-workspace.yaml found in ${rootDir}` });
|
|
68
|
-
const scope = yield* Effect.fromResult(compile(
|
|
69
|
-
const excludes = yield* Effect.fromResult(Result.all(
|
|
70
|
-
const paths = yield* Effect.fromResult(Result.all((
|
|
68
|
+
const scope = yield* Effect.fromResult(compile(pair.scope));
|
|
69
|
+
const excludes = yield* Effect.fromResult(Result.all(pair.exclude.map(compile)));
|
|
70
|
+
const paths = yield* Effect.fromResult(Result.all((pair.packages ?? []).map(compile)));
|
|
71
71
|
const packages = yield* Effect.try({
|
|
72
72
|
try: () => getWorkspacePackagesSync(rootDir, nodeSyncOps),
|
|
73
73
|
catch: (error) => new SyncWorkspaceError({ message: `cannot discover workspace packages in ${rootDir}: ${error instanceof Error ? error.message : String(error)}` })
|
|
74
74
|
});
|
|
75
|
-
if (!packages.some((pkg) => scope.matches(pkg.name))) return yield* new SyncWorkspaceError({ message: `members.scope "${
|
|
76
|
-
return packages.filter((pkg) => pkg.publishConfig?.access === "public" && pkg.name !== pluginName && scope.matches(pkg.name) && !excludes.some((glob) => glob.matches(pkg.name)) && (
|
|
75
|
+
if (!packages.some((pkg) => scope.matches(pkg.name))) return yield* new SyncWorkspaceError({ message: `members.scope "${pair.scope}" matches no workspace package in ${rootDir}: check it for a typo` });
|
|
76
|
+
return packages.filter((pkg) => pkg.publishConfig?.access === "public" && pkg.name !== pluginName && scope.matches(pkg.name) && !excludes.some((glob) => glob.matches(pkg.name)) && (pair.packages === void 0 || paths.some((glob) => glob.matches(pkg.relativePath)))).map((pkg) => pkg.name).sort();
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* Compare
|
|
80
|
+
* Compare a pair's publishable members, already discovered, with the packages
|
|
81
|
+
* its catalog names in the config at `configFile`. The span is the caller's.
|
|
82
|
+
*/
|
|
83
|
+
function compareMembership(configFile, pair, publishable) {
|
|
84
|
+
return Effect.gen(function* () {
|
|
85
|
+
const { entries } = yield* readCatalogSource(configFile, pair.catalog);
|
|
86
|
+
const catalogued = entries.map((entry) => entry.pkg);
|
|
87
|
+
const scope = yield* Effect.fromResult(compile(pair.scope));
|
|
88
|
+
const inScope = catalogued.filter((name) => scope.matches(name));
|
|
89
|
+
if (publishable.length === 0 && inScope.length > 0) return yield* new SyncWorkspaceError({ message: `no publishable package matches ${pair.scope}, yet the \`${pair.catalog}\` catalog names ${inScope.length}: a member that is \`private\` without \`publishConfig.access: "public"\` is not publishable` });
|
|
90
|
+
const named = new Set(catalogued);
|
|
91
|
+
const workspace = new Set(entries.filter((entry) => entry.source === "workspace").map((entry) => entry.pkg));
|
|
92
|
+
return {
|
|
93
|
+
missing: publishable.filter((name) => !named.has(name)),
|
|
94
|
+
notWorkspace: publishable.filter((name) => named.has(name) && !workspace.has(name)),
|
|
95
|
+
publishable,
|
|
96
|
+
catalogued
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compare one pair's publishable workspace members with the packages its
|
|
81
102
|
* catalog names in the config at `configFile`.
|
|
82
103
|
*
|
|
83
104
|
* @internal
|
|
84
105
|
*/
|
|
85
|
-
const checkMembership = Effect.fn("Sync.checkMembership")(function* (configFile, rootDir,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
const checkMembership = Effect.fn("Sync.checkMembership")(function* (configFile, rootDir, pair) {
|
|
107
|
+
return yield* compareMembership(configFile, pair, yield* publishableMembers(rootDir, pair, yield* pluginPackageName(configFile)));
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Run the membership gate for every sync pair, in pair order. A publishable
|
|
111
|
+
* package two pairs both own fails before any catalog is compared: `sync`
|
|
112
|
+
* would otherwise write it into two catalogs.
|
|
113
|
+
*
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
const checkSyncMembership = Effect.fn("Sync.checkSyncMembership")(function* (configFile, rootDir, sync) {
|
|
117
|
+
const pluginName = yield* pluginPackageName(configFile);
|
|
118
|
+
const owned = yield* Effect.forEach(sync.pairs, (pair) => publishableMembers(rootDir, pair, pluginName));
|
|
119
|
+
const ownerOf = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const [i, pair] of sync.pairs.entries()) for (const name of owned[i] ?? []) {
|
|
121
|
+
const other = ownerOf.get(name);
|
|
122
|
+
if (other !== void 0) return yield* new SyncWorkspaceError({ message: `${name} matches the members of two sync pairs, catalogs "${other}" and "${pair.catalog}": narrow one pair's scope or exclude it there` });
|
|
123
|
+
ownerOf.set(name, pair.catalog);
|
|
124
|
+
}
|
|
125
|
+
return yield* Effect.forEach(sync.pairs, (pair, i) => compareMembership(configFile, pair, owned[i] ?? []).pipe(Effect.map((result) => ({
|
|
126
|
+
catalog: pair.catalog,
|
|
127
|
+
result
|
|
128
|
+
}))));
|
|
98
129
|
});
|
|
99
130
|
/**
|
|
100
|
-
* What to do about a membership gap: the last line of {@link
|
|
131
|
+
* What to do about a membership gap: the last line of {@link pairsMembershipMessage}.
|
|
101
132
|
*
|
|
102
133
|
* @internal
|
|
103
134
|
*/
|
|
104
135
|
const MEMBERSHIP_REMEDY = "Add an entry for each at the PnpmConfigPlugin(...) call site with `source: \"workspace\"`.";
|
|
105
136
|
/**
|
|
106
|
-
*
|
|
137
|
+
* What to do about a member catalogued without `source: "workspace"`: the
|
|
138
|
+
* last line of {@link pairsMembershipMessage} when any pair has one.
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
const NOT_WORKSPACE_REMEDY = "Set `source: \"workspace\"` on each of these entries: only sync moves a member, and sync moves only workspace entries.";
|
|
143
|
+
/**
|
|
144
|
+
* The `--check` / `--local` row for a member catalogued without
|
|
145
|
+
* `source: "workspace"`, beside the bare ` - <name>` row of a missing one.
|
|
146
|
+
*
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
const notWorkspaceRow = (name) => ` - ${name} (set source: "workspace")`;
|
|
150
|
+
/**
|
|
151
|
+
* The failure text for the pairs with a membership gap: per pair, a block of
|
|
152
|
+
* the publishable packages its catalog does not name, and a block of those it
|
|
153
|
+
* names without `source: "workspace"`, each naming its catalog when `named`
|
|
154
|
+
* (the sync owns more than one) — the second always names it — then each
|
|
155
|
+
* remedy once.
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
function pairsMembershipMessage(gaps, configFile, named) {
|
|
160
|
+
return [...gaps.flatMap((gap) => [...gap.result.missing.length === 0 ? [] : [`Publishable packages missing from ${named ? `catalog "${gap.catalog}"` : "the catalog"} in ${configFile}:`, ...gap.result.missing.map((name) => ` - ${name}`)], ...gap.result.notWorkspace.length === 0 ? [] : [`Publishable packages catalog "${gap.catalog}" names without \`source: "workspace"\` in ${configFile}:`, ...gap.result.notWorkspace.map((name) => ` - ${name}`)]]), ...membershipRemedies(gaps.map((gap) => gap.result))].join("\n");
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The remedies for the gaps in `results`, each once: {@link MEMBERSHIP_REMEDY}
|
|
164
|
+
* for a missing member, {@link NOT_WORKSPACE_REMEDY} for one catalogued
|
|
165
|
+
* without `source: "workspace"`.
|
|
107
166
|
*
|
|
108
167
|
* @internal
|
|
109
168
|
*/
|
|
110
|
-
function
|
|
111
|
-
return [
|
|
112
|
-
`Publishable packages missing from the catalog in ${configFile}:`,
|
|
113
|
-
...missing.map((name) => ` - ${name}`),
|
|
114
|
-
MEMBERSHIP_REMEDY
|
|
115
|
-
].join("\n");
|
|
169
|
+
function membershipRemedies(results) {
|
|
170
|
+
return [...results.some((result) => result.missing.length > 0) ? [MEMBERSHIP_REMEDY] : [], ...results.some((result) => result.notWorkspace.length > 0) ? [NOT_WORKSPACE_REMEDY] : []];
|
|
116
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Whether a pair's membership has any gap: a member its catalog does not
|
|
174
|
+
* name, or one it names without `source: "workspace"`.
|
|
175
|
+
*
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
const hasMembershipGap = (result) => result.missing.length > 0 || result.notWorkspace.length > 0;
|
|
117
179
|
|
|
118
|
-
export { MEMBERSHIP_REMEDY, SyncWorkspaceError,
|
|
180
|
+
export { MEMBERSHIP_REMEDY, NOT_WORKSPACE_REMEDY, SyncWorkspaceError, checkSyncMembership, hasMembershipGap, membershipRemedies, notWorkspaceRow, pairsMembershipMessage, pluginManifest, pluginPackageName, publishableMembers };
|
package/cli/sync/ripples.js
CHANGED
|
@@ -7,9 +7,9 @@ import { derivePeerRange } from "../peer-range.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
9
|
* The peer follows the entry's strategy through `derivePeerRange`, so `lock`
|
|
10
|
-
* pins it and `lock-minor` floors it.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* pins it and `lock-minor` floors it. Only `peer: { value, strategy }` is
|
|
11
|
+
* derived: a bare-string peer is hand-set, so it keeps its value, and an
|
|
12
|
+
* entry with no peer keeps none.
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
@@ -20,7 +20,7 @@ const rippleMismatches = Effect.fn("Sync.rippleMismatches")(function* (entries,
|
|
|
20
20
|
if (planned === void 0) continue;
|
|
21
21
|
const to = `${entry.operator}${planned}`;
|
|
22
22
|
if (entry.currentRange === to) continue;
|
|
23
|
-
const derived = entry.peer === void 0 ? void 0 : yield* Effect.orDie(derivePeerRange(to, entry.strategy
|
|
23
|
+
const derived = entry.peer === void 0 || entry.strategy === void 0 ? void 0 : yield* Effect.orDie(derivePeerRange(to, entry.strategy));
|
|
24
24
|
const warning = derived?.warning?.message;
|
|
25
25
|
ripples.push({
|
|
26
26
|
catalog: entry.catalog,
|
package/cli/sync/running-list.js
CHANGED
|
@@ -41,14 +41,18 @@ function moveText(move) {
|
|
|
41
41
|
*
|
|
42
42
|
* @remarks
|
|
43
43
|
* Names every package and both of its ranges: consumers take their ranges from
|
|
44
|
-
* the catalog, so which packages moved and to what IS the release note.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* the catalog, so which packages moved and to what IS the release note. Moves
|
|
45
|
+
* are grouped under one heading per catalog, so a catalog with no moves has
|
|
46
|
+
* none. With no moves at all the body falls back to a one-line statement naming
|
|
47
|
+
* every synced catalog in `catalogs`. The text format is byte-compatible with
|
|
48
|
+
* the scripts this ports.
|
|
47
49
|
*
|
|
48
50
|
* @internal
|
|
49
51
|
*/
|
|
50
|
-
function renderChangeset(pluginName, bump, moves,
|
|
51
|
-
const
|
|
52
|
+
function renderChangeset(pluginName, bump, moves, catalogs) {
|
|
53
|
+
const names = catalogs.map((name) => `\`${name}\``);
|
|
54
|
+
const synced = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)} catalogs` : `${names[0] ?? ""} catalog`;
|
|
55
|
+
const body = moves.length === 0 ? `- Synced the ${synced} to the current release versions` : byCatalog(moves).map(([name, group]) => {
|
|
52
56
|
const lines = group.map((move) => `- \`${move.pkg}\` ${moveText(move)}`);
|
|
53
57
|
return `### Updates ${moveSummary(name, group.length)}\n\n${lines.join("\n")}`;
|
|
54
58
|
}).join("\n\n");
|
package/cli/ui/walk-screen.js
CHANGED
|
@@ -4,13 +4,17 @@ import { Box, Text } from "ink";
|
|
|
4
4
|
import { useRef, useState } from "react";
|
|
5
5
|
import { computeGroupPeers } from "../interop-live.js";
|
|
6
6
|
import { TONES } from "../render/tone.js";
|
|
7
|
-
import { cellTone, displayCandidates, initTable, peerFor, tableDecisions, tableLayout, tableStep } from "../walk-reducer.js";
|
|
7
|
+
import { WORKSPACE_ROW_NOTE, cellTone, displayCandidates, familyDetail, initTable, peerFor, tableDecisions, tableLayout, tableRows, tableStep } from "../walk-reducer.js";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
// src/cli/ui/walk-screen.tsx
|
|
11
11
|
/** @jsxRuntime automatic */
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The table's keys: arrows (or vim keys) to move and pick, Enter to finish,
|
|
14
|
+
* and space to open a family group, listed only when a group exists so the
|
|
15
|
+
* help line keeps its width. Esc and Ctrl-C are the host's.
|
|
16
|
+
*/
|
|
17
|
+
function walkKeys(dryRun, families) {
|
|
14
18
|
return KeyTable.make([
|
|
15
19
|
{
|
|
16
20
|
keys: ["up", { char: "k" }],
|
|
@@ -36,7 +40,12 @@ function walkKeys(dryRun) {
|
|
|
36
40
|
keys: ["enter"],
|
|
37
41
|
action: "submit",
|
|
38
42
|
help: dryRun ? "preview" : "update"
|
|
39
|
-
}
|
|
43
|
+
},
|
|
44
|
+
...families ? [{
|
|
45
|
+
keys: ["space"],
|
|
46
|
+
action: "toggle",
|
|
47
|
+
help: "family"
|
|
48
|
+
}] : []
|
|
40
49
|
]);
|
|
41
50
|
}
|
|
42
51
|
/**
|
|
@@ -50,17 +59,20 @@ function chromeHeight(props) {
|
|
|
50
59
|
/**
|
|
51
60
|
* The interactive upgrade table. Every package is one row; each row is a radio
|
|
52
61
|
* group over its candidates with keep (index 0) preselected, so the default
|
|
53
|
-
* state of the table applies nothing.
|
|
62
|
+
* state of the table applies nothing. A workspace entry is a read-only row
|
|
63
|
+
* showing its current version, which the cursor skips (`sync` moves it). A
|
|
64
|
+
* locked family is one group row; its members are listed, and selectable,
|
|
65
|
+
* only once the group is opened (space, or right; left closes it). Enter resolves the screen with one
|
|
54
66
|
* decision per row; Esc and Ctrl-C cancel it (the host's `Cancelled`).
|
|
55
67
|
*
|
|
56
68
|
* @internal
|
|
57
69
|
*/
|
|
58
70
|
function makeWalkScreen(props) {
|
|
59
|
-
const { items, dryRun, unresolved, interopModels } = props;
|
|
60
|
-
const keys = walkKeys(dryRun);
|
|
71
|
+
const { items, dryRun, unresolved, interopModels, open = [] } = props;
|
|
72
|
+
const keys = walkKeys(dryRun, items.some((i) => i.entry.family !== void 0));
|
|
61
73
|
return ({ resolve }) => {
|
|
62
74
|
const Walk = () => {
|
|
63
|
-
const table = useRef(initTable(items));
|
|
75
|
+
const table = useRef(initTable(items, open));
|
|
64
76
|
const [state, setState] = useState(table.current);
|
|
65
77
|
const { columns, rows: termRows } = useTerminalSize();
|
|
66
78
|
useKeys(keys, (key) => {
|
|
@@ -73,10 +85,11 @@ function makeWalkScreen(props) {
|
|
|
73
85
|
if (state.done) return /* @__PURE__ */ jsx(Text, { children: "Done." });
|
|
74
86
|
const { pkgWidth, cellWidth, maxCells, blankCell, cellText } = tableLayout(items);
|
|
75
87
|
const fixedPrefix = 2 + (pkgWidth + 2) + maxCells * (cellWidth + 4) + 2;
|
|
88
|
+
const tableRowsNow = tableRows(items, state.open);
|
|
76
89
|
const catalogs = new Set(items.map((i) => i.entry.catalog)).size;
|
|
77
|
-
const height = Math.max(3, Math.min(
|
|
78
|
-
const start = Math.max(0, Math.min(state.cursor - Math.floor(height / 2),
|
|
79
|
-
const visible =
|
|
90
|
+
const height = Math.max(3, Math.min(tableRowsNow.length, termRows - chromeHeight(props) - catalogs));
|
|
91
|
+
const start = Math.max(0, Math.min(state.cursor - Math.floor(height / 2), tableRowsNow.length - height));
|
|
92
|
+
const visible = tableRowsNow.slice(start, start + height);
|
|
80
93
|
const interopPeers = /* @__PURE__ */ new Map();
|
|
81
94
|
for (const [catalog, model] of interopModels) {
|
|
82
95
|
const selected = /* @__PURE__ */ new Map();
|
|
@@ -89,16 +102,52 @@ function makeWalkScreen(props) {
|
|
|
89
102
|
}
|
|
90
103
|
const rows = [];
|
|
91
104
|
let lastCatalog = null;
|
|
92
|
-
visible.forEach((
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
visible.forEach((row, offset) => {
|
|
106
|
+
const onCursor = start + offset === state.cursor;
|
|
107
|
+
const rowCatalog = row.kind === "group" ? row.catalog : items[row.index].entry.catalog;
|
|
108
|
+
if (rowCatalog !== lastCatalog) {
|
|
109
|
+
lastCatalog = rowCatalog;
|
|
96
110
|
rows.push(/* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(Styled, {
|
|
97
111
|
token: "muted",
|
|
98
112
|
children: ` ── catalog: ${Fmt.sanitize(lastCatalog)} ──`
|
|
99
113
|
}) }, `cat-${lastCatalog}`));
|
|
100
114
|
}
|
|
101
|
-
const
|
|
115
|
+
const cursorMark = onCursor ? /* @__PURE__ */ jsx(Styled, {
|
|
116
|
+
token: "accent",
|
|
117
|
+
children: "❯ "
|
|
118
|
+
}) : " ";
|
|
119
|
+
if (row.kind === "group") {
|
|
120
|
+
const isOpen = state.open.includes(row.family);
|
|
121
|
+
const newer = row.members.filter((m) => !items[m].upToDate).length;
|
|
122
|
+
const detail = familyDetail(row.members.length, newer);
|
|
123
|
+
rows.push(/* @__PURE__ */ jsxs(Text, {
|
|
124
|
+
wrap: "truncate-end",
|
|
125
|
+
children: [
|
|
126
|
+
cursorMark,
|
|
127
|
+
/* @__PURE__ */ jsx(Text, {
|
|
128
|
+
bold: onCursor,
|
|
129
|
+
children: `${isOpen ? "▾" : "▸"} family: ${Fmt.sanitize(row.family)}`
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ jsx(Styled, {
|
|
132
|
+
token: "muted",
|
|
133
|
+
children: ` (${detail}${isOpen ? "" : "; space opens"})`
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}, `fam-${row.family}`));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const i = row.index;
|
|
140
|
+
const item = items[i];
|
|
141
|
+
if (item.readOnly === true) {
|
|
142
|
+
rows.push(/* @__PURE__ */ jsxs(Text, {
|
|
143
|
+
wrap: "truncate-end",
|
|
144
|
+
children: [" ", /* @__PURE__ */ jsx(Styled, {
|
|
145
|
+
token: "muted",
|
|
146
|
+
children: `${Fmt.pad(Fmt.sanitize(item.entry.pkg), pkgWidth + 2)}${Fmt.sanitize(item.entry.currentRange)} ${WORKSPACE_ROW_NOTE}`
|
|
147
|
+
})]
|
|
148
|
+
}, `${item.entry.catalog}/${item.entry.pkg}`));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
102
151
|
const pick = state.picks[i] ?? 0;
|
|
103
152
|
const candidates = displayCandidates(item);
|
|
104
153
|
const chosen = candidates[pick];
|
|
@@ -109,10 +158,7 @@ function makeWalkScreen(props) {
|
|
|
109
158
|
rows.push(/* @__PURE__ */ jsxs(Text, {
|
|
110
159
|
wrap: "truncate-end",
|
|
111
160
|
children: [
|
|
112
|
-
|
|
113
|
-
token: "accent",
|
|
114
|
-
children: "❯ "
|
|
115
|
-
}) : " ",
|
|
161
|
+
cursorMark,
|
|
116
162
|
/* @__PURE__ */ jsx(Text, {
|
|
117
163
|
bold: onCursor,
|
|
118
164
|
children: Fmt.pad(Fmt.sanitize(item.entry.pkg), pkgWidth + 2)
|
package/cli/validate.js
CHANGED
|
@@ -14,7 +14,7 @@ import { parseRange, parseVersion } from "../semver-util.js";
|
|
|
14
14
|
* or an unparseable range yields `true`. Validation is a safety net against
|
|
15
15
|
* ranges we DERIVED wrongly, not a gate on the author's own hand-written
|
|
16
16
|
* ranges, and rejecting everything the moment the registry is unreachable would
|
|
17
|
-
* break offline peer
|
|
17
|
+
* break an offline peer resync.
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|