rolldown-pnpm-config 3.1.0 → 3.2.1

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.
@@ -4,6 +4,7 @@ import { AtomicFile } from "@effected/files";
4
4
  import { PnpmWorkspaceFile } from "@effected/pnpm";
5
5
  import { Data, Effect, FileSystem, Option, Path, Result } from "effect";
6
6
  import { Argument, Command, Flag } from "effect/cli";
7
+ import { WorkingDirectory } from "../cwd.js";
7
8
  import { evaluatePluginConfig } from "../evaluate.js";
8
9
  import { failureDoc, warningDoc } from "../render/report.js";
9
10
  import { RegistryResolver } from "../resolve.js";
@@ -75,7 +76,8 @@ function readRunningList(file) {
75
76
  function writeListAndMessage(rootDir, sync, pluginName, moves) {
76
77
  return Effect.gen(function* () {
77
78
  const path = yield* Path.Path;
78
- yield* writeFile(path.join(rootDir, sync.changesetPath), renderChangeset(pluginName, sync.bump, moves, sync.catalog));
79
+ const file = path.join(rootDir, sync.changesetPath);
80
+ yield* writeFile(file, yield* Effect.fromResult(renderChangeset(pluginName, sync.bump, moves, sync.catalog)).pipe(Effect.mapError((error) => new UpgradeError({ message: `Cannot render ${file}: ${error.message}` }))));
79
81
  yield* writeFile(path.join(rootDir, sync.messagePath), renderCommitMessage(sync.commitScope, moves));
80
82
  });
81
83
  }
@@ -176,8 +178,13 @@ const runSyncWrite = Effect.fn("Sync.runSyncWrite")(function* (opts) {
176
178
  listWritten: true
177
179
  };
178
180
  });
179
- /** The remedy for everything a plain `sync` repairs. */
180
- const syncRemedy = (configFile) => `Run \`rolldown-pnpm-config sync ${configFile}\`.`;
181
+ /**
182
+ * The remedy for everything a plain `sync` repairs. `displayFile` is the
183
+ * config path as the reader should type it (the command passes it relative to
184
+ * the working directory), never an absolute path that leaks the machine's
185
+ * layout into CI logs.
186
+ */
187
+ const syncRemedy = (displayFile) => `Run \`rolldown-pnpm-config sync ${displayFile}\`.`;
181
188
  /** The remedy for export drift: the export writes the yaml, the rebuild serves what it wrote. */
182
189
  const EXPORT_REMEDY = "Run `pnpm pnpm:export`, then rebuild the plugin.";
183
190
  /** A section with nothing to report. */
@@ -214,7 +221,7 @@ function driftRow(row) {
214
221
  * Also returns the rows the upgrade would move (none when it errored), which
215
222
  * the ripples section lays over the config.
216
223
  */
217
- function versionsSection(opts, sync) {
224
+ function versionsSection(opts, sync, remedy) {
218
225
  return runUpgrade({
219
226
  file: opts.configFile,
220
227
  resolver: opts.resolver,
@@ -234,7 +241,7 @@ function versionsSection(opts, sync) {
234
241
  };
235
242
  const changed = Result.isSuccess(result) ? result.success.changed : [];
236
243
  return {
237
- section: findings("versions", changed.map(driftRow), syncRemedy(opts.configFile)),
244
+ section: findings("versions", changed.map(driftRow), remedy),
238
245
  changed
239
246
  };
240
247
  }));
@@ -244,17 +251,17 @@ function membershipSection(configFile, rootDir, sync) {
244
251
  return evaluate("membership", checkMembership(configFile, rootDir, sync).pipe(Effect.map((m) => findings("membership", m.missing.map((name) => ` - ${name}`), MEMBERSHIP_REMEDY))));
245
252
  }
246
253
  /** Floors: the breaking-floor changesets on disk differ from the ones the plan derives. */
247
- function floorsSection(configFile, rootDir) {
248
- return evaluate("floors", planFloorEdits(rootDir).pipe(Effect.map(({ raised, edits }) => findings("floors", describeFloorEdits(raised, edits).split("\n").filter((line) => line !== ""), syncRemedy(configFile)))));
254
+ function floorsSection(rootDir, remedy) {
255
+ return evaluate("floors", planFloorEdits(rootDir).pipe(Effect.map(({ raised, edits }) => findings("floors", describeFloorEdits(raised, edits).split("\n").filter((line) => line !== ""), remedy))));
249
256
  }
250
257
  /** The running list: a pending list whose moves disagree with the config. Absent is in sync. */
251
- function runningListSection(configFile, rootDir, sync) {
258
+ function runningListSection(configFile, rootDir, sync, remedy) {
252
259
  return evaluate("running-list", Effect.gen(function* () {
253
260
  const existing = yield* readRunningList((yield* Path.Path).join(rootDir, sync.changesetPath));
254
261
  if (Option.isNone(existing)) return ok("running-list");
255
262
  const { entries } = yield* readCatalogSource(configFile);
256
263
  const stale = staleMoves(parseChangeset(existing.value), currentCatalogs(entries));
257
- return findings("running-list", stale, syncRemedy(configFile));
264
+ return findings("running-list", stale, remedy);
258
265
  }));
259
266
  }
260
267
  /**
@@ -269,7 +276,7 @@ function runningListSection(configFile, rootDir, sync) {
269
276
  * targets come from the plan before any floor is raised (write mode raises
270
277
  * floors first), so a row can differ from what a sync would write.
271
278
  */
272
- function ripplesSection(configFile, rootDir, sync, upgraded) {
279
+ function ripplesSection(configFile, rootDir, sync, upgraded, remedy) {
273
280
  return evaluate("ripples", Effect.gen(function* () {
274
281
  const plan = yield* readReleasePlan(rootDir);
275
282
  const { entries } = yield* readCatalogSource(configFile, sync.catalog);
@@ -282,7 +289,7 @@ function ripplesSection(configFile, rootDir, sync, upgraded) {
282
289
  };
283
290
  });
284
291
  const rows = (yield* rippleMismatches(afterUpgrade, plan)).map((r) => ` ${r.catalog}.${r.pkg} ${r.from} -> ${r.to}`);
285
- return findings("ripples", rows, syncRemedy(configFile));
292
+ return findings("ripples", rows, remedy);
286
293
  }));
287
294
  }
288
295
  /**
@@ -339,13 +346,14 @@ function checkDoc(mode, sections) {
339
346
  */
340
347
  const runSyncCheck = Effect.fn("Sync.runSyncCheck")(function* (opts) {
341
348
  const file = opts.configFile;
349
+ const remedy = syncRemedy(opts.displayFile ?? file);
342
350
  const { sync, rootDir } = yield* gateContext(file);
343
- const versions = yield* versionsSection(opts, sync);
351
+ const versions = yield* versionsSection(opts, sync, remedy);
344
352
  const rest = yield* Effect.all([
345
353
  membershipSection(file, rootDir, sync),
346
- ...sync.floors ? [floorsSection(file, rootDir)] : [],
347
- runningListSection(file, rootDir, sync),
348
- ripplesSection(file, rootDir, sync, versions.changed)
354
+ ...sync.floors ? [floorsSection(rootDir, remedy)] : [],
355
+ runningListSection(file, rootDir, sync, remedy),
356
+ ripplesSection(file, rootDir, sync, versions.changed, remedy)
349
357
  ]);
350
358
  return checkDoc("check", [versions.section, ...rest]);
351
359
  });
@@ -366,6 +374,48 @@ const runSyncLocal = Effect.fn("Sync.runSyncLocal")(function* (opts) {
366
374
  const { sync, rootDir } = yield* gateContext(file);
367
375
  return checkDoc("local", yield* Effect.all([membershipSection(file, rootDir, sync), exportSection(file, rootDir, sync)]));
368
376
  });
377
+ /**
378
+ * Fail unless the `sync` block manages breaking floors: `--floors-only` on a
379
+ * config with `floors: false` would otherwise write or pass on files this
380
+ * config never asked `sync` to own.
381
+ */
382
+ function requireFloors(sync, configFile) {
383
+ return sync.floors ? Effect.void : Effect.fail(new SyncConfigError({ message: `--floors-only needs \`sync.floors: true\` in ${configFile}; this config does not manage breaking floors` }));
384
+ }
385
+ /**
386
+ * `sync --floors-only`: raise the breaking-floor changesets and stop. No
387
+ * registry, no upgrade, no running list or commit message: the floors step
388
+ * of {@link runSyncWrite} alone, for a repository that keeps a separate
389
+ * floors script or hook.
390
+ *
391
+ * @internal
392
+ */
393
+ const runSyncFloors = Effect.fn("Sync.runSyncFloors")(function* (opts) {
394
+ const { sync, rootDir } = yield* gateContext(opts.configFile);
395
+ yield* requireFloors(sync, opts.configFile);
396
+ const { edits } = yield* planFloorEdits(rootDir);
397
+ yield* applyFloorEdits(rootDir, edits).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot write the breaking-floor changesets in ${rootDir}` })));
398
+ return { edits: edits.map((edit) => ({
399
+ path: edit.path,
400
+ deleted: edit.content === null
401
+ })) };
402
+ });
403
+ /**
404
+ * `sync --check --floors-only`: the floors section of the gate alone. Offline;
405
+ * writes nothing.
406
+ *
407
+ * @internal
408
+ */
409
+ const runSyncFloorsCheck = Effect.fn("Sync.runSyncFloorsCheck")(function* (opts) {
410
+ const { sync, rootDir } = yield* gateContext(opts.configFile);
411
+ yield* requireFloors(sync, opts.configFile);
412
+ return checkDoc("check", [yield* floorsSection(rootDir, `Run \`rolldown-pnpm-config sync --floors-only ${opts.displayFile ?? opts.configFile}\`.`)]);
413
+ });
414
+ /** The human view of a `--floors-only` write. @internal */
415
+ function syncFloorsDoc(result) {
416
+ if (result.edits.length === 0) return [Doc.line("Breaking floors are current; nothing written.")];
417
+ return [Doc.line(`Updated ${Fmt.plural(result.edits.length, "breaking-floor changeset")}:`), Doc.lines(result.edits.map((edit) => ` ${edit.path}${edit.deleted ? " (deleted)" : ""}`), { wrap: false })];
418
+ }
369
419
  /** The gate's exit code: 0 when every section is ok, 1 for any finding or error. @internal */
370
420
  function syncCheckExit(doc) {
371
421
  return doc.sections.every((s) => s.status === "ok") ? 0 : 1;
@@ -403,14 +453,7 @@ function moveLine(move, note = "") {
403
453
  function syncWriteDoc(result) {
404
454
  if (!result.wrote) return [Doc.line("The sync catalog is current; nothing written.")];
405
455
  const rippled = new Set(result.ripples.map((r) => `${r.catalog}\0${r.pkg}`));
406
- const blocks = [];
407
- if (result.moves.length > 0) {
408
- blocks.push(Doc.line(`Synced ${Fmt.plural(result.moves.length, "catalog entry", "catalog entries")}:`));
409
- blocks.push(Doc.lines(result.moves.map((m) => moveLine(m, rippled.has(`${m.catalog}\0${m.pkg}`) ? " (ripple)" : "")), { wrap: false }));
410
- } else if (result.listWritten) blocks.push(Doc.line("The catalog was current; rewrote the stale running list."));
411
- else blocks.push(Doc.line("The catalog was current; the running list was left as it was."));
412
- if (result.floors > 0) blocks.push(Doc.line(`Updated ${Fmt.plural(result.floors, "breaking-floor changeset")}.`));
413
- return blocks;
456
+ return Doc.concat(result.moves.length > 0 ? [Doc.line(`Synced ${Fmt.plural(result.moves.length, "catalog entry", "catalog entries")}:`), Doc.lines(result.moves.map((m) => moveLine(m, rippled.has(`${m.catalog}\0${m.pkg}`) ? " (ripple)" : "")), { wrap: false })] : Doc.line(result.listWritten ? "The catalog was current; rewrote the stale running list." : "The catalog was current; the running list was left as it was."), result.floors > 0 && Doc.line(`Updated ${Fmt.plural(result.floors, "breaking-floor changeset")}.`));
414
457
  }
415
458
  /**
416
459
  * The `--format json` document of a write-mode run.
@@ -451,11 +494,25 @@ function syncWriteJson(result) {
451
494
  const configArg = Argument.File("config").pipe(Argument.withDescription("The plugin config holding the `sync` block (autodetected in the current directory when omitted)"), Argument.optional);
452
495
  const checkFlag = Flag.Boolean("check").pipe(Flag.withDescription("Report whether a sync would change anything, and why (a gate; never writes)"), Flag.withDefault(false));
453
496
  const localFlag = Flag.Boolean("local").pipe(Flag.withDescription("Compare the built pnpmfile's catalogs with pnpm-workspace.yaml (offline; never writes)"), Flag.withDefault(false));
497
+ const floorsOnlyFlag = Flag.Boolean("floors-only").pipe(Flag.withDescription("Only the breaking-floor changesets: raise them, or with --check report them (offline; needs sync.floors)"), Flag.withDefault(false));
454
498
  const formatFlag = CliFormat.flag(["json"], {
455
499
  aliases: { text: "auto" },
456
500
  default: "text",
457
501
  description: "Output format: text (for whoever is reading) or json (one JSON document on stdout)"
458
502
  });
503
+ /**
504
+ * `file` as the reader should type it: relative to the working directory. A
505
+ * contributor copies the remedy from a CI log or a terminal, and an absolute
506
+ * path is neither portable nor private.
507
+ */
508
+ function displayPath(file) {
509
+ return Effect.gen(function* () {
510
+ const cwd = yield* WorkingDirectory;
511
+ const path = yield* Path.Path;
512
+ const relative = path.relative(cwd, path.resolve(cwd, file));
513
+ return relative === "" ? file : relative;
514
+ });
515
+ }
459
516
  /** JSON mode writes one single-line document, so a bash gate can pipe it straight into jq. */
460
517
  const ONE_LINE = { indent: 0 };
461
518
  /**
@@ -469,13 +526,46 @@ const syncCommand = Command.make("sync", {
469
526
  config: configArg,
470
527
  check: checkFlag,
471
528
  local: localFlag,
529
+ floorsOnly: floorsOnlyFlag,
472
530
  format: formatFlag
473
- }, ({ config, check, local, format }) => Effect.gen(function* () {
531
+ }, ({ config, check, local, floorsOnly, format }) => Effect.gen(function* () {
474
532
  if (check && local) return yield* new SyncUsageError({ message: "--check and --local cannot be combined; pass one" });
533
+ if (floorsOnly && local) return yield* new SyncUsageError({ message: "--floors-only cannot be combined with --local; pass it alone or with --check" });
534
+ if (floorsOnly && !check) {
535
+ const result = yield* resolveTargetFile(config).pipe(Effect.flatMap((file) => runSyncFloors({ configFile: file })), Effect.result);
536
+ if (format === "json") {
537
+ const json = Result.isFailure(result) ? {
538
+ command: "sync",
539
+ mode: "floors",
540
+ wrote: false,
541
+ error: {
542
+ kind: result.failure._tag,
543
+ message: result.failure.message
544
+ }
545
+ } : {
546
+ command: "sync",
547
+ mode: "floors",
548
+ wrote: result.success.edits.length > 0,
549
+ edits: result.success.edits
550
+ };
551
+ yield* CliFormat.print("json", {
552
+ doc: () => [],
553
+ json: () => json
554
+ }, ONE_LINE);
555
+ }
556
+ if (Result.isFailure(result)) return yield* Effect.fail(result.failure);
557
+ if (format === "json") return;
558
+ yield* Doc.print(syncFloorsDoc(result.success));
559
+ return;
560
+ }
475
561
  if (check || local) {
476
562
  const mode = check ? "check" : "local";
477
- const result = yield* resolveTargetFile(config).pipe(Effect.flatMap((file) => check ? Effect.flatMap(RegistryResolver, (resolver) => runSyncCheck({
563
+ const result = yield* resolveTargetFile(config).pipe(Effect.flatMap((file) => floorsOnly ? Effect.flatMap(displayPath(file), (displayFile) => runSyncFloorsCheck({
564
+ configFile: file,
565
+ displayFile
566
+ })) : check ? Effect.flatMap(Effect.all([RegistryResolver, displayPath(file)]), ([resolver, displayFile]) => runSyncCheck({
478
567
  configFile: file,
568
+ displayFile,
479
569
  resolver,
480
570
  workspaceResolver: makeWorkspaceResolver(findWorkspaceRoot(dirname(file)))
481
571
  })) : runSyncLocal({ configFile: file })), Effect.result);
@@ -500,7 +590,7 @@ const syncCommand = Command.make("sync", {
500
590
  return yield* Effect.fail(result.failure);
501
591
  }
502
592
  const doc = result.success;
503
- yield* CliFormat.print(format === "json" ? "json" : "auto", {
593
+ yield* CliFormat.print(format, {
504
594
  doc: () => syncCheckView(doc),
505
595
  json: () => doc
506
596
  }, ONE_LINE);
@@ -524,4 +614,4 @@ const syncCommand = Command.make("sync", {
524
614
  if (success.wrote) yield* CliMessage.success("Sync written.");
525
615
  })).pipe(Command.withDescription("Sync the plugin's own catalog to the next release versions"));
526
616
 
527
- export { MembershipError, SyncUsageError, runSyncCheck, runSyncLocal, runSyncWrite, syncCheckExit, syncCheckView, syncCommand, syncWriteDoc, syncWriteJson };
617
+ export { MembershipError, SyncUsageError, runSyncCheck, runSyncFloors, runSyncFloorsCheck, runSyncLocal, runSyncWrite, syncCheckExit, syncCheckView, syncCommand, syncFloorsDoc, syncWriteDoc, syncWriteJson };
@@ -3,7 +3,7 @@ import { CliDoc, CliExit, CliFormat, CliInteractive, CliMessage, Doc, Fmt } from
3
3
  import { CliUi } from "@effected/cli-kit/ui";
4
4
  import { AtomicFile } from "@effected/files";
5
5
  import { ReleaseAgeGate } from "@effected/pnpm";
6
- import { Clock, Data, Effect, FileSystem, Option, Result } from "effect";
6
+ import { Clock, Data, Effect, Option, Result } from "effect";
7
7
  import { Argument, Command, Flag } from "effect/cli";
8
8
  import { bareVersion } from "../../semver-util.js";
9
9
  import { WorkingDirectory } from "../cwd.js";
@@ -94,7 +94,7 @@ function writeSource(file, next) {
94
94
  */
95
95
  function readCatalogSource(file, catalog) {
96
96
  return Effect.gen(function* () {
97
- const source = yield* (yield* FileSystem.FileSystem).readFileString(file).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot read ${file}` })));
97
+ const { text: source } = yield* AtomicFile.readText(file).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot read ${file}` })));
98
98
  const { entries, skipped, skippedRefs, catalogs } = yield* Effect.try({
99
99
  try: () => discoverCatalogEntries(source, file),
100
100
  catch: (e) => new UpgradeError({ message: Fmt.describe(e) })
package/cli/main.js CHANGED
@@ -16,8 +16,9 @@ import { CLI_VERSION } from "./version.js";
16
16
  * kit reads it from when `env.stderrIsTerminal` is omitted.
17
17
  *
18
18
  * The registry resolver is provided here, at the edge, so a test drives the
19
- * same command tree against a stub resolver. It spawns `pnpm view` through the
20
- * platform's `ChildProcessSpawner`, reads pnpm's settings from
19
+ * same command tree against a stub resolver. It reads the registry through
20
+ * `@effected/npm`'s `NpmRegistry` (npmrc routing, auth, proxy and CA settings
21
+ * as pnpm applies them), reads pnpm's settings from
21
22
  * `process.cwd()` / `process.env` / `process.platform`, and takes `FileSystem`
22
23
  * and `Path` from `NodeServices.layer`, provided by `main`.
23
24
  *
@@ -25,11 +25,8 @@ const coloured = Effect.gen(function* () {
25
25
  */
26
26
  function printView(view, options = {}) {
27
27
  return Effect.gen(function* () {
28
- const doc = [];
29
- if (options.heading !== void 0) doc.push(Doc.line(options.heading), Doc.line(""));
30
- if (options.legend !== void 0 && (yield* coloured)) doc.push(options.legend, Doc.line(""));
31
- doc.push(Doc.lines(view.lines, { wrap: false }));
32
- yield* Doc.print(doc);
28
+ const legend = options.legend !== void 0 && (yield* coloured) ? options.legend : void 0;
29
+ yield* Doc.print(Doc.concat(options.heading !== void 0 && [Doc.line(options.heading), Doc.line("")], legend !== void 0 && [legend, Doc.line("")], Doc.lines(view.lines, { wrap: false })));
33
30
  });
34
31
  }
35
32
 
@@ -3,13 +3,11 @@ import { Doc, Status } from "@effected/cli-kit";
3
3
  // src/cli/render/report.ts
4
4
  function statusDoc(status, message) {
5
5
  const [first = "", ...rest] = message.split("\n");
6
- const blocks = [Doc.line([
6
+ return Doc.concat(Doc.line([
7
7
  Doc.status(Status.core, status),
8
8
  " ",
9
9
  first
10
- ])];
11
- if (rest.length > 0) blocks.push(Doc.verbatim(rest.join("\n")));
12
- return blocks;
10
+ ]), rest.length > 0 && Doc.verbatim(rest.join("\n")));
13
11
  }
14
12
  /**
15
13
  * The failure report for one of the CLI's own errors: a status line carrying
package/cli/summary.js CHANGED
@@ -46,9 +46,7 @@ function summaryDoc(decisions, interop, rejected) {
46
46
  }
47
47
  lines.push(row(" ", 0, [tone(`${toUpdate} to update · ${major} major · ${resync} resync · ${materialize} new peer · ${upToDate} up to date`, "unchanged")]));
48
48
  if (interop) for (const c of interop.conflicts) lines.push(row("⚠", 0, [tone(`${c.pkg} (kept ${c.ceiling}) blocked by ${c.blockedBy}`, "warn")]));
49
- const blocks = [Doc.lines(lines, { wrap: false })];
50
- if (rejected && rejected.length > 0) blocks.push(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 }));
51
- return blocks;
49
+ 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 })]);
52
50
  }
53
51
 
54
52
  export { summaryDoc };
@@ -6,14 +6,17 @@ 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. Package names are written
10
+ * bare, never as inline code: commitlint presets such as
11
+ * `@savvy-web/commitlint`'s `silk/body-no-markdown` reject a body with more
12
+ * than a couple of code spans, and a sync can move dozens of packages.
10
13
  *
11
14
  * @internal
12
15
  */
13
16
  function renderCommitMessage(scope, moves) {
14
17
  const headline = `chore(${scope}): sync catalog to the next release versions`;
15
18
  if (moves.length === 0) return `${headline}\n`;
16
- return `${headline}\n\n${byCatalog(moves).flatMap(([, group]) => group.map((move) => `- \`${move.pkg}\` ${move.from} -> ${move.to}`)).join("\n")}\n`;
19
+ return `${headline}\n\n${byCatalog(moves).flatMap(([, group]) => group.map((move) => `- ${move.pkg} ${move.from} -> ${move.to}`)).join("\n")}\n`;
17
20
  }
18
21
 
19
22
  export { renderCommitMessage };
@@ -1,4 +1,4 @@
1
- import { ChangesetConfig, PendingChangeset, PendingChangesets, PreState, ReleasePlan } from "@effected/changesets";
1
+ import { ChangesetConfig, ChangesetFile, PendingChangeset, PendingChangesets, PreState, ReleasePlan } from "@effected/changesets";
2
2
  import { WorkspaceDiscovery } from "@effected/workspaces";
3
3
  import { Effect, FileSystem, Option, Path } from "effect";
4
4
  import { ReleasePlanError, discoveryLayer } from "./release-plan.js";
@@ -16,7 +16,10 @@ const isFloorFile = (file) => file.startsWith("breaking-floor-") && file.endsWit
16
16
  const renderFloorChangeset = (raised) => {
17
17
  const lines = raised.causes.map((cause) => `- Requires \`${cause.dependency}\` ${cause.newVersion} (\`${cause.kind}\`: \`${cause.range}\`), a breaking release from ${cause.oldVersion}. A consumer still on ${cause.oldVersion} cannot install this version beside it, so this release leaves its own version line too.`);
18
18
  const upgrade = raised.causes.map((cause) => `\`${cause.dependency}\` to ${cause.newVersion}`).join(", ");
19
- return `---\n"${raised.name}": ${raised.required}\n---\n\n## Breaking Changes\n\n${lines.join("\n")}\n\nTo upgrade, move ${upgrade} in the same install as this release.\n`;
19
+ return ChangesetFile.render({
20
+ releases: { [raised.name]: raised.required },
21
+ summary: `## Breaking Changes\n\n${lines.join("\n")}\n\nTo upgrade, move ${upgrade} in the same install as this release.`
22
+ });
20
23
  };
21
24
  /**
22
25
  * Raise every release whose published floor crosses a dependency's breaking
@@ -92,7 +95,7 @@ const planFloorEdits = Effect.fn("Sync.planFloorEdits")(function* (rootDir) {
92
95
  for (const r of raised) {
93
96
  const file = floorFile(r.name);
94
97
  wanted.add(file);
95
- const content = renderFloorChangeset(r);
98
+ const content = yield* renderFloorChangeset(r).pipe(Effect.mapError((error) => new ReleasePlanError({ message: `Floor changeset for ${r.name} could not be rendered: ${error.message}` })));
96
99
  const target = path.join(dir, file);
97
100
  const current = yield* fs.readFileString(target).pipe(Effect.option);
98
101
  if (Option.isNone(current) || current.value !== content) edits.push({
@@ -29,13 +29,19 @@ function readServedCatalogs(pnpmfilePath) {
29
29
  /**
30
30
  * The catalogs the export writes into this repo's own workspace file: an
31
31
  * explicit `local.catalogs` wins, otherwise every served catalog except the
32
- * sync catalog and its `:peers` sibling.
32
+ * sync catalog and its derived `:peers` and `:exact` siblings, which lag it
33
+ * between releases in exactly the same way.
33
34
  *
34
35
  * @internal
35
36
  */
36
37
  function exportedCatalogNames(served, sync) {
37
38
  if (sync.localCatalogs !== void 0) return sync.localCatalogs;
38
- return Object.keys(served).filter((name) => name !== sync.catalog && name !== `${sync.catalog}:peers`);
39
+ const managed = /* @__PURE__ */ new Set([
40
+ sync.catalog,
41
+ `${sync.catalog}:peers`,
42
+ `${sync.catalog}:exact`
43
+ ]);
44
+ return Object.keys(served).filter((name) => !managed.has(name));
39
45
  }
40
46
  /**
41
47
  * Per exported catalog, the packages whose served range differs from the
@@ -1,3 +1,5 @@
1
+ import { ChangesetFile } from "@effected/changesets";
2
+
1
3
  // src/cli/sync/running-list.ts
2
4
  /**
3
5
  * The config's catalog entries by catalog name, then package: the
@@ -46,10 +48,14 @@ function moveText(move) {
46
48
  * @internal
47
49
  */
48
50
  function renderChangeset(pluginName, bump, moves, catalog) {
49
- return `---\n"${pluginName}": ${bump}\n---\n\n## Maintenance\n\n${moves.length === 0 ? `- Synced the \`${catalog}\` catalog to the current release versions` : byCatalog(moves).map(([name, group]) => {
51
+ const body = moves.length === 0 ? `- Synced the \`${catalog}\` catalog to the current release versions` : byCatalog(moves).map(([name, group]) => {
50
52
  const lines = group.map((move) => `- \`${move.pkg}\` ${moveText(move)}`);
51
53
  return `### Updates ${moveSummary(name, group.length)}\n\n${lines.join("\n")}`;
52
- }).join("\n\n")}\n`;
54
+ }).join("\n\n");
55
+ return ChangesetFile.renderResult({
56
+ releases: { [pluginName]: bump },
57
+ summary: `## Maintenance\n\n${body}`
58
+ });
53
59
  }
54
60
  /** One `### Updates … catalog:<catalog> …` heading, capturing the catalog. */
55
61
  const SECTION = /^### Updates \d+ catalog:(\S+) versions?$/;
package/cli/version.js CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "3.1.0";
9
+ const CLI_VERSION = "3.2.1";
10
10
 
11
11
  export { CLI_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -36,16 +36,16 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@effect/platform-node": "4.1.7",
39
- "@effected/changesets": "0.9.0",
40
- "@effected/cli-kit": "0.33.0",
39
+ "@effected/changesets": "0.11.0",
40
+ "@effected/cli-kit": "0.34.0",
41
41
  "@effected/env": "0.12.0",
42
- "@effected/files": "0.4.0",
42
+ "@effected/files": "0.6.0",
43
43
  "@effected/glob": "0.23.1",
44
44
  "@effected/npm": "0.35.1",
45
- "@effected/pnpm": "0.1.3",
45
+ "@effected/pnpm": "0.1.4",
46
46
  "@effected/semver": "0.24.0",
47
- "@effected/walker": "0.32.0",
48
- "@effected/workspaces": "0.49.3",
47
+ "@effected/walker": "0.33.0",
48
+ "@effected/workspaces": "0.49.5",
49
49
  "@effected/yaml": "0.31.0",
50
50
  "effect": "4.1.7",
51
51
  "ink": "^8.0.0",
@@ -67,7 +67,7 @@ excluded.
67
67
  | `floors` | `boolean` | `false` | Manage breaking-floor changesets (`.changeset/breaking-floor-*.md`). `sync --check` reports a `floors` section when they differ from the release plan; a write-mode `sync` raises them (writes or deletes the files) before reading the plan |
68
68
  | `local` | object | see below | The `sync --local` gate |
69
69
  | `local.pnpmfile` | `string` | `dist/prod/npm/pkg/pnpmfile.mjs` | The built pnpmfile `--local` imports, relative to the plugin package |
70
- | `local.catalogs` | `string[]` | every served catalog except `<catalog>` and `<catalog>:peers` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
70
+ | `local.catalogs` | `string[]` | every served catalog except `<catalog>`, `<catalog>:peers` and `<catalog>:exact` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
71
71
 
72
72
  ### `local`
73
73
 
@@ -6,7 +6,7 @@ changeset. It reads the `sync` block of the config; the wiring reference
6
6
  lists the fields.
7
7
 
8
8
  ```sh
9
- rolldown-pnpm-config sync [config] [--check | --local] [--format json]
9
+ rolldown-pnpm-config sync [config] [--check | --local] [--floors-only] [--format json]
10
10
  ```
11
11
 
12
12
  `config` defaults to the single top-level `.ts` file in the current directory
@@ -19,8 +19,11 @@ that calls `PnpmConfigPlugin(...)`.
19
19
  | `sync` | yes | registry | membership refusal, then the write | the Catalog Sync workflow; you only when the user asks |
20
20
  | `sync --check` | never | registry | `versions`, `membership`, `floors` (only with `sync.floors: true`), `running-list`, `ripples` | the Catalog Sync workflow, as its gate |
21
21
  | `sync --local` | never | none | `membership`, `export` | the pre-push hook; safe for you to run |
22
+ | `sync --floors-only` | yes | none | the floors step alone: write or delete `.changeset/breaking-floor-*.md` | a floors script or hook; needs `sync.floors: true` |
23
+ | `sync --check --floors-only` | never | none | `floors` | a floors gate; safe for you to run |
22
24
 
23
- `--check` and `--local` together are a usage error. Every gate section is
25
+ `--check` and `--local` together are a usage error, and so is
26
+ `--floors-only` with `--local`. Every gate section is
24
27
  evaluated; none stops the others.
25
28
 
26
29
  What plain `sync` does, in order: refuse if a publishable member is missing
@@ -36,7 +39,7 @@ nothing moved); write the commit message to `sync.commit.messagePath`.
36
39
  | --- | --- |
37
40
  | 0 | every section ok, or the write succeeded |
38
41
  | 1 | a finding, a section that could not be evaluated, or a failed write (membership, release plan, upgrade, workspace) |
39
- | 64 | usage: `--check --local`; a config that does not parse or has no `PnpmConfigPlugin(...)` call; or no or an invalid `sync` block |
42
+ | 64 | usage: `--check --local` or `--floors-only --local`; `--floors-only` with `sync.floors` off; a config that does not parse or has no `PnpmConfigPlugin(...)` call; or no or an invalid `sync` block |
40
43
 
41
44
  Exit 1 does not mean drift. Read the report or the JSON before acting.
42
45
 
@@ -113,7 +116,8 @@ plugin's `package.json` cannot be read or parsed.
113
116
  ## Why `--local` skips the sync catalog
114
117
 
115
118
  By default `--local` compares every catalog the built pnpmfile serves except
116
- `sync.catalog` and `<sync.catalog>:peers`. The workflow's sync commits only
119
+ `sync.catalog` and its derived `<sync.catalog>:peers` and
120
+ `<sync.catalog>:exact` twins. The workflow's sync commits only
117
121
  the config literal and the changesets; it never re-exports
118
122
  `pnpm-workspace.yaml`, because `pnpm:export` is run by the user only. The
119
123
  yaml's copy of the sync catalog therefore lags by design, and comparing it
@@ -143,7 +143,7 @@ Every field the CLI reads. Unknown keys are rejected, and a config with no
143
143
  | `commit.messagePath` | `.changeset/catalog-sync.commit.txt` | Where the commit message is written |
144
144
  | `floors` | `false` | Also raise and check breaking-floor changesets (`.changeset/breaking-floor-*.md`) |
145
145
  | `local.pnpmfile` | `dist/prod/npm/pkg/pnpmfile.mjs` | The built pnpmfile `--local` imports, relative to the plugin package |
146
- | `local.catalogs` | every served catalog except `<catalog>` and `<catalog>:peers` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
146
+ | `local.catalogs` | every served catalog except `<catalog>`, `<catalog>:peers` and `<catalog>:exact` | The catalogs `--local` compares with `pnpm-workspace.yaml` |
147
147
 
148
148
  - A member is publishable when its `publishConfig.access` is `"public"`;
149
149
  `private` is never read.