rolldown-pnpm-config 3.2.0 → 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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/catalogs.js +32 -15
  3. package/cli/commands/export.js +8 -3
  4. package/cli/commands/preview.js +10 -7
  5. package/cli/commands/sync.js +143 -79
  6. package/cli/commands/upgrade.js +333 -135
  7. package/cli/discover.js +134 -28
  8. package/cli/drift.js +1 -1
  9. package/cli/edits.js +8 -17
  10. package/cli/effective.js +119 -4
  11. package/cli/interop.js +7 -15
  12. package/cli/local-merge.js +4 -1
  13. package/cli/plan.js +8 -3
  14. package/cli/preview-views.js +3 -1
  15. package/cli/release-age.js +2 -1
  16. package/cli/render/print.js +2 -5
  17. package/cli/render/report.js +2 -4
  18. package/cli/respell.js +86 -0
  19. package/cli/select-file.js +5 -2
  20. package/cli/summary.js +43 -9
  21. package/cli/sync/commit-message.js +4 -3
  22. package/cli/sync/config.js +60 -24
  23. package/cli/sync/floors.js +6 -3
  24. package/cli/sync/local-gate.js +19 -9
  25. package/cli/sync/membership.js +93 -31
  26. package/cli/sync/ripples.js +4 -4
  27. package/cli/sync/running-list.js +16 -6
  28. package/cli/ui/walk-screen.js +66 -20
  29. package/cli/validate.js +1 -1
  30. package/cli/version.js +1 -1
  31. package/cli/walk-plan.js +17 -10
  32. package/cli/walk-reducer.js +99 -19
  33. package/index.d.ts +176 -127
  34. package/package.json +8 -8
  35. package/plugin/allowed-versions.js +3 -3
  36. package/plugin/families.js +185 -0
  37. package/plugin/freeze.js +122 -32
  38. package/plugin/second-forms.js +155 -0
  39. package/plugin/synced-catalogs.js +32 -0
  40. package/registry.js +13 -1
  41. package/skills/rolldown-pnpm-config/SKILL.md +13 -3
  42. package/skills/rolldown-pnpm-config/references/catalogs.md +109 -12
  43. package/skills/rolldown-pnpm-config/references/options.md +126 -47
  44. package/skills/rolldown-pnpm-config/references/sync.md +32 -21
  45. package/skills/rolldown-pnpm-config/references/wiring.md +10 -8
  46. package/plugin/overrides-from-catalogs.js +0 -151
@@ -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
- /** The table's keys: arrows (or vim keys) to move and pick, Enter to finish. Esc and Ctrl-C are the host's. */
13
- function walkKeys(dryRun) {
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. Enter resolves the screen with one
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(items.length, termRows - chromeHeight(props) - catalogs));
78
- const start = Math.max(0, Math.min(state.cursor - Math.floor(height / 2), items.length - height));
79
- const visible = items.slice(start, start + height);
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((item, offset) => {
93
- const i = start + offset;
94
- if (item.entry.catalog !== lastCatalog) {
95
- lastCatalog = item.entry.catalog;
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 onCursor = i === state.cursor;
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
- onCursor ? /* @__PURE__ */ jsx(Styled, {
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 materialization.
17
+ * break an offline peer resync.
18
18
  *
19
19
  * @internal
20
20
  */
package/cli/version.js CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "3.2.0";
9
+ const CLI_VERSION = "4.0.0";
10
10
 
11
11
  export { CLI_VERSION };
package/cli/walk-plan.js CHANGED
@@ -8,8 +8,9 @@ import { versionKeyOf } from "./version-key.js";
8
8
  /**
9
9
  * Build the interactive walk items: for each entry, its candidate list (from
10
10
  * planEntry against the resolved versions), an up-to-date flag (only the keep
11
- * candidate remains), any peer drift resync target, any peer to materialize,
12
- * and any strategy/prerelease incompatibility warning.
11
+ * candidate remains), any peer drift resync target, and any strategy/prerelease incompatibility warning.
12
+ * A workspace entry is a read-only row: `sync` moves it, so it gets only its
13
+ * keep candidate and no peer resync, whatever its versions say.
13
14
  *
14
15
  * @internal
15
16
  */
@@ -17,23 +18,29 @@ function buildWalkItems(entries, versionsByPkg) {
17
18
  return Effect.gen(function* () {
18
19
  const items = [];
19
20
  for (const entry of entries) {
21
+ if (entry.source === "workspace") {
22
+ const [keep] = yield* planEntry(entry, []);
23
+ items.push({
24
+ entry,
25
+ candidates: [keep],
26
+ upToDate: true,
27
+ driftPeer: null,
28
+ peerWarning: null,
29
+ readOnly: true
30
+ });
31
+ continue;
32
+ }
20
33
  const versions = versionsByPkg.get(versionKeyOf(entry)) ?? [];
21
34
  const candidates = yield* planEntry(entry, [...versions]);
22
35
  const driftPeer = yield* detectPeerDrift(entry);
23
36
  let peerWarning = null;
24
- let materializePeer = null;
25
- if (entry.strategy && entry.strategy !== "interop") {
26
- const derived = yield* derivePeerRange(entry.currentRange, entry.strategy);
27
- peerWarning = derived.warning;
28
- if (!entry.peer) materializePeer = derived.range;
29
- }
30
- const upToDate = candidates.length === 1 && driftPeer === null && materializePeer === null;
37
+ if (entry.strategy && entry.strategy !== "interop") peerWarning = (yield* derivePeerRange(entry.currentRange, entry.strategy)).warning;
38
+ const upToDate = candidates.length === 1 && driftPeer === null;
31
39
  items.push({
32
40
  entry,
33
41
  candidates,
34
42
  upToDate,
35
43
  driftPeer,
36
- materializePeer,
37
44
  peerWarning
38
45
  });
39
46
  }
@@ -1,6 +1,17 @@
1
1
  import { Fmt } from "@effected/cli-kit";
2
2
 
3
3
  // src/cli/walk-reducer.ts
4
+ /** The note on a workspace row, which `upgrade` shows as context and `sync` moves. @internal */
5
+ const WORKSPACE_ROW_NOTE = "(workspace; sync moves it)";
6
+ /**
7
+ * The detail of a locked family's row: how many members it holds and how many
8
+ * have a newer version on offer. The dialog and `--preview --full` both print it.
9
+ *
10
+ * @internal
11
+ */
12
+ function familyDetail(memberCount, newer) {
13
+ return `${Fmt.plural(memberCount, "member")}, locked${newer > 0 ? `, ${newer} newer` : ""}`;
14
+ }
4
15
  const ORDER = {
5
16
  keep: 0,
6
17
  "in-range": 1,
@@ -48,27 +59,82 @@ function displayCandidates(item) {
48
59
  return [...item.candidates].sort((a, b) => ORDER[a.kind] - ORDER[b.kind]);
49
60
  }
50
61
  /**
62
+ * The table's rows in display order. Items keep their order, except that a
63
+ * family's members gather under one group header placed where its first
64
+ * member was; the members are listed only while the group is open.
65
+ *
66
+ * @internal
67
+ */
68
+ function tableRows(items, open) {
69
+ const rows = [];
70
+ const grouped = /* @__PURE__ */ new Set();
71
+ items.forEach((item, index) => {
72
+ const family = item.entry.family;
73
+ if (family === void 0) {
74
+ rows.push({
75
+ kind: "item",
76
+ index
77
+ });
78
+ return;
79
+ }
80
+ if (grouped.has(family)) return;
81
+ grouped.add(family);
82
+ const members = items.flatMap((it, i) => it.entry.family === family ? [i] : []);
83
+ rows.push({
84
+ kind: "group",
85
+ family,
86
+ catalog: item.entry.catalog,
87
+ members
88
+ });
89
+ if (open.includes(family)) for (const i of members) rows.push({
90
+ kind: "item",
91
+ index: i
92
+ });
93
+ });
94
+ return rows;
95
+ }
96
+ /** Whether the cursor may rest on a row: a group header, or any item but a read-only one. */
97
+ function navigable(row, items) {
98
+ return row.kind === "group" || items[row.index]?.readOnly !== true;
99
+ }
100
+ /** Whether a row has something to apply: an item not up to date, or a group with such a member. */
101
+ function actionable(row, items) {
102
+ return (row.kind === "group" ? row.members : [row.index]).some((i) => items[i] !== void 0 && !items[i].upToDate && items[i].readOnly !== true);
103
+ }
104
+ /**
51
105
  * Initialize the table: keep selected on every row (so the default state applies
52
106
  * nothing), and the cursor on the first actionable row. Since every discovered
53
107
  * row is shown — up-to-date rows included, as context — the cursor skips past any
54
108
  * leading inert keep-only rows to land where the user can act; it falls back to
55
- * row 0 when nothing is actionable.
109
+ * the first row it may rest on (never a read-only one), then to row 0.
110
+ * `open` names the family groups to show opened (`upgrade --family`).
56
111
  *
57
112
  * @internal
58
113
  */
59
- function initTable(items) {
60
- const first = items.findIndex((i) => !i.upToDate);
114
+ function initTable(items, open = []) {
115
+ const rows = tableRows(items, open);
116
+ const first = rows.findIndex((r) => actionable(r, items));
117
+ const resting = rows.findIndex((r) => navigable(r, items));
61
118
  return {
62
- cursor: first === -1 ? 0 : first,
119
+ cursor: first !== -1 ? first : resting !== -1 ? resting : 0,
63
120
  picks: items.map(() => 0),
121
+ open: [...open],
64
122
  done: false
65
123
  };
66
124
  }
67
125
  const clamp = (n, max) => n < 0 ? 0 : Math.min(n, max);
126
+ /** The next row from `from` in direction `step` the cursor may rest on, or `from` when there is none. */
127
+ function moveCursor(rows, items, from, step) {
128
+ for (let i = from + step; i >= 0 && i < rows.length; i += step) if (navigable(rows[i], items)) return i;
129
+ return from;
130
+ }
68
131
  /**
69
- * Advance the table by a key. up/down move between rows; left/right move the
70
- * radio selection within the row under the cursor; submit applies. Both axes
71
- * clamp at their ends rather than wrapping.
132
+ * Advance the table by a key. up/down move between the rows the cursor may
133
+ * rest on, skipping read-only ones; left/right move the radio selection
134
+ * within the item under the cursor, and on a group header close and open
135
+ * it, as `toggle` does. Closing a group resets its members to keep, so a
136
+ * hidden row never applies a change. Both axes clamp at their ends rather
137
+ * than wrapping.
72
138
  *
73
139
  * @internal
74
140
  */
@@ -79,18 +145,33 @@ function tableStep(state, items, key) {
79
145
  done: true
80
146
  };
81
147
  if (items.length === 0) return state;
82
- if (key === "up") return {
83
- ...state,
84
- cursor: clamp(state.cursor - 1, items.length - 1)
85
- };
86
- if (key === "down") return {
148
+ const rows = tableRows(items, state.open);
149
+ if (key === "up" || key === "down") return {
87
150
  ...state,
88
- cursor: clamp(state.cursor + 1, items.length - 1)
151
+ cursor: moveCursor(rows, items, state.cursor, key === "down" ? 1 : -1)
89
152
  };
90
- const count = displayCandidates(items[state.cursor]).length;
153
+ const row = rows[state.cursor];
154
+ if (row === void 0) return state;
155
+ if (row.kind === "group") {
156
+ const isOpen = state.open.includes(row.family);
157
+ const wantOpen = key === "toggle" ? !isOpen : key === "right";
158
+ if (wantOpen === isOpen) return state;
159
+ if (wantOpen) return {
160
+ ...state,
161
+ open: [...state.open, row.family]
162
+ };
163
+ const picks = state.picks.map((p, i) => row.members.includes(i) ? 0 : p);
164
+ return {
165
+ ...state,
166
+ open: state.open.filter((f) => f !== row.family),
167
+ picks
168
+ };
169
+ }
170
+ if (key === "toggle" || items[row.index]?.readOnly === true) return state;
171
+ const count = displayCandidates(items[row.index]).length;
91
172
  const delta = key === "right" ? 1 : -1;
92
173
  const picks = [...state.picks];
93
- picks[state.cursor] = clamp(picks[state.cursor] + delta, count - 1);
174
+ picks[row.index] = clamp(picks[row.index] + delta, count - 1);
94
175
  return {
95
176
  ...state,
96
177
  picks
@@ -110,8 +191,8 @@ function tableDecisions(state, items) {
110
191
  /**
111
192
  * The peer range that would be written for a row's currently chosen candidate.
112
193
  * Non-keep candidates carry their own recomputed `peerRange`; keep reuses
113
- * whichever peer source the item already resolved (a drift resync, a
114
- * materialize target, or the entry's existing literal), falling back to an
194
+ * whichever peer source the item already resolved (a drift resync or the
195
+ * entry's existing literal), falling back to an
115
196
  * em dash placeholder when none applies.
116
197
  *
117
198
  * @internal
@@ -119,7 +200,6 @@ function tableDecisions(state, items) {
119
200
  function peerFor(item, chosen) {
120
201
  if (chosen.kind !== "keep") return chosen.peerRange ?? "—";
121
202
  if (item.driftPeer) return item.driftPeer;
122
- if (item.materializePeer) return item.materializePeer;
123
203
  return item.entry.peer?.value ?? "—";
124
204
  }
125
205
  /**
@@ -138,4 +218,4 @@ function cellTone(candidate, selected) {
138
218
  return candidate.isMajor ? "changed" : "added";
139
219
  }
140
220
 
141
- export { MAJOR_SUFFIX, cellTone, displayCandidates, initTable, peerFor, tableDecisions, tableLayout, tableStep };
221
+ export { MAJOR_SUFFIX, WORKSPACE_ROW_NOTE, cellTone, displayCandidates, familyDetail, initTable, peerFor, tableDecisions, tableLayout, tableRows, tableStep };