rolldown-pnpm-config 2.4.0 → 2.4.2

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.
@@ -14,11 +14,12 @@ import { failureDoc } from "../render/report.js";
14
14
  import { findConfigFiles, pickConfigCandidate } from "../select-file.js";
15
15
  import { canonicalize, writeWorkspace } from "../workspace-file.js";
16
16
  import { overlayWorkspace } from "../workspace-overlay.js";
17
- import { Data, Effect, FileSystem, Option, Predicate } from "effect";
17
+ import { Data, Effect, Option, Predicate } from "effect";
18
18
  import { dirname, relative } from "node:path";
19
- import { CliDoc, CliMessage } from "@effected/cli";
19
+ import { CliDoc, CliMessage } from "@effected/cli-kit";
20
20
  import { existsSync } from "node:fs";
21
21
  import { Argument, Command, Flag } from "effect/cli";
22
+ import { AtomicFile } from "@effected/files";
22
23
 
23
24
  // src/cli/commands/export.ts
24
25
  /**
@@ -90,7 +91,7 @@ function runExport(opts) {
90
91
  diff,
91
92
  report
92
93
  };
93
- yield* (yield* FileSystem.FileSystem).writeFileString(path, rendered).pipe(Effect.mapError(() => new ExportError({ message: `Cannot write ${path}` })));
94
+ yield* AtomicFile.write(path, rendered).pipe(Effect.mapError(() => new ExportError({ message: `Cannot write ${path}` })));
94
95
  return {
95
96
  path,
96
97
  rendered,
@@ -11,9 +11,9 @@ import { previewScreen } from "../ui/screens.js";
11
11
  import { WORKSPACE_FIELDS } from "./export.js";
12
12
  import { Data, Effect, Option } from "effect";
13
13
  import { dirname } from "node:path";
14
- import { CliDoc, CliInteractive } from "@effected/cli";
14
+ import { CliDoc, CliInteractive } from "@effected/cli-kit";
15
15
  import { Argument, Command } from "effect/cli";
16
- import { CliUi } from "@effected/cli/ui";
16
+ import { CliUi } from "@effected/cli-kit/ui";
17
17
 
18
18
  // src/cli/commands/preview.ts
19
19
  /** Typed failure for the preview run. @internal */
@@ -20,9 +20,10 @@ import { buildWalkItems } from "../walk-plan.js";
20
20
  import { findWorkspaceRoot, makeWorkspaceResolver } from "../workspace-resolve.js";
21
21
  import { Clock, Data, Effect, FileSystem, Option, Result } from "effect";
22
22
  import { dirname } from "node:path";
23
- import { CliDoc, CliExit, CliFormat, CliInteractive, CliMessage, Doc, Fmt } from "@effected/cli";
23
+ import { CliDoc, CliExit, CliFormat, CliInteractive, CliMessage, Doc, Fmt } from "@effected/cli-kit";
24
24
  import { Argument, Command, Flag } from "effect/cli";
25
- import { CliUi } from "@effected/cli/ui";
25
+ import { AtomicFile } from "@effected/files";
26
+ import { CliUi } from "@effected/cli-kit/ui";
26
27
  import { ReleaseAgeGate } from "@effected/npm";
27
28
 
28
29
  // src/cli/commands/upgrade.ts
@@ -72,7 +73,7 @@ var CheckFailedError = class extends Data.TaggedError("CheckFailedError") {
72
73
  };
73
74
  /** Write the rewritten config source back to `file`. */
74
75
  function writeSource(file, next) {
75
- return Effect.flatMap(FileSystem.FileSystem, (fs) => fs.writeFileString(file, next).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot write ${file}` }))));
76
+ return AtomicFile.write(file, next).pipe(Effect.mapError(() => new UpgradeError({ message: `Cannot write ${file}` })));
76
77
  }
77
78
  /** Read a config file and statically discover its catalog entries. @internal */
78
79
  function readCatalogSource(file) {
@@ -1,5 +1,5 @@
1
1
  import { row, tone } from "../render/tone.js";
2
- import { Doc } from "@effected/cli";
2
+ import { Doc } from "@effected/cli-kit";
3
3
 
4
4
  // src/cli/diff/render.ts
5
5
  const CONTEXT = 2;
@@ -1,7 +1,7 @@
1
1
  import { evaluatePluginConfig } from "./evaluate.js";
2
2
  import { parseWorkspace } from "./workspace-file.js";
3
3
  import { Effect, FileSystem, Predicate } from "effect";
4
- import { Fmt } from "@effected/cli";
4
+ import { Fmt } from "@effected/cli-kit";
5
5
 
6
6
  // src/cli/load-config.ts
7
7
  /**
package/cli/main.js CHANGED
@@ -4,7 +4,7 @@ import { RegistryResolverLive } from "./resolve.js";
4
4
  import { rootCommand } from "./root.js";
5
5
  import { CLI_VERSION } from "./version.js";
6
6
  import { Effect } from "effect";
7
- import { CliAudience, CliRuntime } from "@effected/cli";
7
+ import { CliAudience, CliRuntime } from "@effected/cli-kit";
8
8
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
9
9
 
10
10
  // src/cli/main.ts
package/cli/peer-range.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Data, Effect } from "effect";
2
- import { SemVer } from "@effected/semver";
1
+ import { Data, Effect, Result } from "effect";
2
+ import { VersionSpecifier } from "@effected/semver";
3
3
 
4
4
  // src/cli/peer-range.ts
5
5
  /**
@@ -8,8 +8,12 @@ import { SemVer } from "@effected/semver";
8
8
  * @internal
9
9
  */
10
10
  var PeerRangeError = class extends Data.TaggedError("PeerRangeError") {};
11
- /** Splits a simple range into its operator prefix and version (e.g. `^6.5.1`). */
12
- const PREFIX_RE = /^(\^|~|)(\d.*)$/;
11
+ /** The operators a peer range can be derived from; `VersionSpecifier` also admits comparators such as `>=`. */
12
+ const DERIVABLE_OPERATORS = /* @__PURE__ */ new Set([
13
+ "^",
14
+ "~",
15
+ ""
16
+ ]);
13
17
  /**
14
18
  * Recompute a materialized peer range from a package range and a strategy.
15
19
  * "lock" pins to the exact version; "lock-minor" floors the patch to .0.
@@ -34,10 +38,10 @@ const PREFIX_RE = /^(\^|~|)(\d.*)$/;
34
38
  */
35
39
  function derivePeerRange(range, strategy) {
36
40
  return Effect.gen(function* () {
37
- const match = PREFIX_RE.exec(range);
38
- if (!match) return yield* Effect.fail(new PeerRangeError({ message: `Cannot derive peer range from "${range}"` }));
39
- const [, prefix, version] = match;
40
- const parsed = yield* SemVer.parse(version).pipe(Effect.mapError(() => new PeerRangeError({ message: `Invalid version in range "${range}"` })));
41
+ const spec = Result.getOrNull(VersionSpecifier.parseResult(range));
42
+ if (spec === null || !DERIVABLE_OPERATORS.has(spec.operator)) return yield* Effect.fail(new PeerRangeError({ message: `Cannot derive peer range from "${range}"` }));
43
+ const { operator: prefix, version: parsed } = spec;
44
+ const version = range.slice(prefix.length);
41
45
  if (strategy === "lock") return {
42
46
  range: `${prefix}${version}`,
43
47
  warning: null
@@ -1,5 +1,5 @@
1
1
  import { tone } from "./tone.js";
2
- import { Doc } from "@effected/cli";
2
+ import { Doc } from "@effected/cli-kit";
3
3
 
4
4
  // src/cli/render/legend.ts
5
5
  function swatches(entries) {
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { CliTheme, Doc } from "@effected/cli";
2
+ import { CliTheme, Doc } from "@effected/cli-kit";
3
3
  import { Audience } from "@effected/env";
4
4
 
5
5
  // src/cli/render/print.ts
@@ -1,4 +1,4 @@
1
- import { Doc, Status } from "@effected/cli";
1
+ import { Doc, Status } from "@effected/cli-kit";
2
2
 
3
3
  // src/cli/render/report.ts
4
4
  function statusDoc(status, message) {
@@ -1,4 +1,4 @@
1
- import { Doc, Token } from "@effected/cli";
1
+ import { Doc, Token } from "@effected/cli-kit";
2
2
 
3
3
  // src/cli/render/tone.ts
4
4
  /**
package/cli/resolve.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Context, Data, Effect, Layer, Predicate } from "effect";
2
- import { Fmt } from "@effected/cli";
2
+ import { Fmt } from "@effected/cli-kit";
3
3
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
4
 
5
5
  // src/cli/resolve.ts
package/cli/root.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { exportCommand } from "./commands/export.js";
2
2
  import { previewCommand } from "./commands/preview.js";
3
3
  import { upgradeCommand } from "./commands/upgrade.js";
4
- import { CliAudience } from "@effected/cli";
4
+ import { CliAudience } from "@effected/cli-kit";
5
5
  import { Command } from "effect/cli";
6
6
 
7
7
  // src/cli/root.ts
@@ -2,7 +2,7 @@ import { scalarText } from "./diff/render.js";
2
2
  import { row, tone } from "./render/tone.js";
3
3
  import { canonicalize } from "./workspace-file.js";
4
4
  import { Predicate } from "effect";
5
- import { Doc } from "@effected/cli";
5
+ import { Doc } from "@effected/cli-kit";
6
6
 
7
7
  // src/cli/simulated-view.ts
8
8
  /**
package/cli/summary.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { row, tone } from "./render/tone.js";
2
2
  import { cellTone, displayCandidates, peerFor, tableLayout } from "./walk-reducer.js";
3
- import { Doc, Fmt } from "@effected/cli";
3
+ import { Doc, Fmt } from "@effected/cli-kit";
4
4
 
5
5
  // src/cli/summary.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { legend, simulatedLegend } from "../render/legend.js";
2
- import { Doc } from "@effected/cli";
3
- import { DocView, KeyHelp, KeyTable, Styled, Tabs, Viewport, useKeys, useTerminalSize, useTheme } from "@effected/cli/ui";
2
+ import { Doc } from "@effected/cli-kit";
3
+ import { DocView, KeyHelp, KeyTable, Styled, Tabs, Viewport, useKeys, useTerminalSize, useTheme } from "@effected/cli-kit/ui";
4
4
  import { Box, Text } from "ink";
5
5
  import { useEffect, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,5 +1,5 @@
1
- import { Status } from "@effected/cli";
2
- import { Styled, useGlyphs, useTheme } from "@effected/cli/ui";
1
+ import { Status } from "@effected/cli-kit";
2
+ import { Styled, useGlyphs, useTheme } from "@effected/cli-kit/ui";
3
3
  import { Text } from "ink";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
 
package/cli/ui/screens.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { initialProgress, reduceProgress } from "./progress.js";
2
2
  import { Effect, PubSub } from "effect";
3
- import { CliUi } from "@effected/cli/ui";
3
+ import { CliUi } from "@effected/cli-kit/ui";
4
4
 
5
5
  // src/cli/ui/screens.ts
6
6
  /** The interactive upgrade table, loaded on mount. @internal */
@@ -1,8 +1,8 @@
1
1
  import { computeGroupPeers } from "../interop-live.js";
2
2
  import { TONES } from "../render/tone.js";
3
3
  import { cellTone, displayCandidates, initTable, peerFor, tableDecisions, tableLayout, tableStep } from "../walk-reducer.js";
4
- import { Fmt } from "@effected/cli";
5
- import { KeyHelp, KeyTable, Styled, useKeys, useTerminalSize } from "@effected/cli/ui";
4
+ import { Fmt } from "@effected/cli-kit";
5
+ import { KeyHelp, KeyTable, Styled, useKeys, useTerminalSize } from "@effected/cli-kit/ui";
6
6
  import { Box, Text } from "ink";
7
7
  import { useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
package/cli/version.js CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "2.4.0";
9
+ const CLI_VERSION = "2.4.2";
10
10
 
11
11
  export { CLI_VERSION };
@@ -1,4 +1,4 @@
1
- import { Fmt } from "@effected/cli";
1
+ import { Fmt } from "@effected/cli-kit";
2
2
 
3
3
  // src/cli/walk-reducer.ts
4
4
  const ORDER = {
@@ -1,7 +1,7 @@
1
1
  import { Option, Order, Predicate, Result } from "effect";
2
2
  import { locateWorkspaceRootSync } from "@effected/workspaces";
3
3
  import { nodeSyncOps } from "@effected/workspaces/node-sync";
4
- import { Yaml, YamlDocument, YamlEdit, YamlFormat, YamlLint, YamlLintConfig, YamlStringifyOptions } from "@effected/yaml";
4
+ import { Yaml, YamlDocument, YamlFormat, YamlLint, YamlLintConfig, YamlStringifyOptions } from "@effected/yaml";
5
5
 
6
6
  // src/cli/workspace-file.ts
7
7
  const FILENAME = "pnpm-workspace.yaml";
@@ -289,24 +289,18 @@ function faithful(text, next) {
289
289
  return Result.isSuccess(value) && sameValue(isMapping(value.success) ? value.success : {}, next);
290
290
  }
291
291
  /**
292
- * Splice a primitive into an existing scalar's own source span, keeping its
293
- * quotes and trailing comment. `modify` only splices when given no
294
- * document-shaping options (any `indent`/`indentSequences` sends it down the
295
- * whole-document path, which re-styles the replaced node and drops its
296
- * comment), so the splice is attempted unstyled and accepted only when every
297
- * edit stays inside the target scalar. `None` means "not a splice" — the
298
- * caller takes the styled path. Workaround for spencerbeggs/effected#1219.
292
+ * Whether a change puts a primitive over an existing scalar. `modify` splices
293
+ * that in place, keeping the scalar's own quotes and trailing comment, so it
294
+ * must not be re-quoted to match its siblings: the author's spelling of that
295
+ * one value stands.
299
296
  */
300
- function spliceScalar(text, path, value) {
301
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return Option.none();
297
+ function replacesScalar(text, change) {
298
+ const { value } = change;
299
+ if (change.newKey || typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return false;
302
300
  const doc = YamlDocument.parseResult(text);
303
- if (Result.isFailure(doc) || doc.success.contents === null) return Option.none();
304
- const target = doc.success.contents.find(path);
305
- if (Option.isNone(target) || target.value._tag !== "YamlScalar") return Option.none();
306
- const { offset, length } = target.value;
307
- const edits = YamlFormat.modifyResult(text, path, value);
308
- if (Result.isFailure(edits)) return Option.none();
309
- return edits.success.every((e) => e.offset >= offset && e.offset + e.length <= offset + length) ? Option.some(YamlEdit.applyAll(text, edits.success)) : Option.none();
301
+ if (Result.isFailure(doc) || doc.success.contents === null) return false;
302
+ const target = doc.success.contents.find(change.path);
303
+ return Option.isSome(target) && target.value._tag === "YamlScalar";
310
304
  }
311
305
  /** Apply every change as an edit; `None` when the editor refuses one. */
312
306
  function applyChanges(source, changes, style) {
@@ -315,14 +309,10 @@ function applyChanges(source, changes, style) {
315
309
  const quoteChar = style.quoteStyle ?? "single";
316
310
  let text = source;
317
311
  for (const change of changes) {
318
- const spliced = change.newKey ? Option.none() : spliceScalar(text, change.path, change.value);
319
- if (Option.isSome(spliced)) {
320
- text = spliced.value;
321
- continue;
322
- }
312
+ const keepSpelling = replacesScalar(text, change);
323
313
  const result = YamlFormat.modifyToStringResult(text, change.path, change.value, style);
324
314
  if (Result.isFailure(result)) return Option.none();
325
- text = requoteWritten(result.success, change, roles, quoteChar);
315
+ text = keepSpelling ? result.success : requoteWritten(result.success, change, roles, quoteChar);
326
316
  }
327
317
  return Option.some(text);
328
318
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -35,18 +35,19 @@
35
35
  "rolldown-pnpm-config": "bin/rolldown-pnpm-config.js"
36
36
  },
37
37
  "dependencies": {
38
- "@effect/platform-node": "~4.1.1",
39
- "@effected/cli": "^0.25.0",
40
- "@effected/env": "^0.9.0",
41
- "@effected/glob": "^0.17.0",
42
- "@effected/npm": "^0.29.0",
43
- "@effected/semver": "^0.20.0",
44
- "@effected/walker": "^0.24.0",
45
- "@effected/workspaces": "^0.41.0",
46
- "@effected/yaml": "^0.27.0",
47
- "effect": "~4.1.1",
38
+ "@effect/platform-node": "~4.1.2",
39
+ "@effected/cli-kit": "^0.27.0",
40
+ "@effected/env": "^0.11.0",
41
+ "@effected/files": "^0.1.0",
42
+ "@effected/glob": "^0.19.0",
43
+ "@effected/npm": "^0.30.1",
44
+ "@effected/semver": "^0.22.0",
45
+ "@effected/walker": "^0.25.1",
46
+ "@effected/workspaces": "^0.43.0",
47
+ "@effected/yaml": "^0.29.0",
48
+ "effect": "~4.1.2",
48
49
  "ink": "^8.0.0",
49
- "oxc-parser": "^0.156.0",
50
+ "oxc-parser": "^0.157.0",
50
51
  "react": "^19.3.1"
51
52
  },
52
53
  "peerDependencies": {
@@ -1,10 +1,14 @@
1
1
  import { rangeOf } from "../catalogs.js";
2
2
  import { bareVersion } from "../semver-util.js";
3
- import { Predicate } from "effect";
3
+ import { Predicate, Result } from "effect";
4
+ import { VersionSpecifier } from "@effected/semver";
4
5
 
5
6
  // src/plugin/allowed-versions.ts
6
- /** An exact version: no range operator, no wildcard — `X.Y.Z` with an optional prerelease. */
7
- const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
7
+ /** An exact version: no range operator, no wildcard, no build metadata — `X.Y.Z` with an optional prerelease. */
8
+ function isExactVersion(range) {
9
+ const spec = Result.getOrNull(VersionSpecifier.parseResult(range));
10
+ return spec !== null && spec.operator === "" && spec.version.build.length === 0;
11
+ }
8
12
  /** Apply the `prefix` transform to a peer value: verbatim, re-prefixed, or stripped to exact. */
9
13
  function applyPrefix(peerValue, prefix) {
10
14
  if (prefix === void 0) return peerValue;
@@ -22,7 +26,7 @@ function deriveOne(catalogs, { catalog, peer, prefix }) {
22
26
  for (const [name, spec] of Object.entries(decl.packages)) {
23
27
  if (name === peer) continue;
24
28
  const range = rangeOf(spec);
25
- if (!EXACT_VERSION.test(range)) continue;
29
+ if (!isExactVersion(range)) continue;
26
30
  table[`${name}@${range}>${peer}`] = value;
27
31
  }
28
32
  return table;
package/plugin/freeze.js CHANGED
@@ -4,7 +4,7 @@ import { FIELD_REGISTRY } from "../registry.js";
4
4
  import { resolvePeerDependencyRules } from "./allowed-versions.js";
5
5
  import { resolveOverrides } from "./overrides-from-catalogs.js";
6
6
  import { Data, Effect, Predicate, Schema } from "effect";
7
- import { Fmt } from "@effected/cli";
7
+ import { Fmt } from "@effected/cli-kit";
8
8
 
9
9
  // src/plugin/freeze.ts
10
10
  /**
@@ -1,12 +1,16 @@
1
1
  import { rangeOf } from "../catalogs.js";
2
- import { bareVersion } from "../semver-util.js";
3
- import { Glob, Predicate } from "effect";
2
+ import { Glob, Predicate, Result } from "effect";
3
+ import { VersionSpecifier } from "@effected/semver";
4
4
 
5
5
  // src/plugin/overrides-from-catalogs.ts
6
- /** A plain release version: `X.Y.Z`, no prerelease, no build metadata. */
7
- const PLAIN_VERSION = /^(\d+)\.(\d+)\.(\d+)$/;
8
- /** A simple-operator range: an optional `^`, `~`, `>=` or `=` on one version. */
9
- const SIMPLE_RANGE = /^(?:\^|~|>=|=)?\s*\d/;
6
+ /** The simple operators that can pin: an optional `^`, `~`, `>=` or `=` on one version. */
7
+ const PINNABLE_OPERATORS = /* @__PURE__ */ new Set([
8
+ "^",
9
+ "~",
10
+ ">=",
11
+ "=",
12
+ ""
13
+ ]);
10
14
  /**
11
15
  * The release line a plain version belongs to: `^X.0.0`, or `^0.Y.0` when the
12
16
  * major is 0. A `0.0.Z` version has no caret line (`^0.0.0` admits only
@@ -14,8 +18,8 @@ const SIMPLE_RANGE = /^(?:\^|~|>=|=)?\s*\d/;
14
18
  * `0.0.Z` request.
15
19
  */
16
20
  function releaseLine(major, minor) {
17
- if (major !== "0") return `^${major}.0.0`;
18
- return minor === "0" ? "~0.0.0" : `^0.${minor}.0`;
21
+ if (major !== 0) return `^${major}.0.0`;
22
+ return minor === 0 ? "~0.0.0" : `^0.${minor}.0`;
19
23
  }
20
24
  /**
21
25
  * Compile a filter list into a member predicate, throwing when an entry
@@ -40,13 +44,12 @@ function deriveOne(catalogs, { catalog, include, exclude = [], scope = "line" })
40
44
  const table = {};
41
45
  for (const [name, spec] of Object.entries(decl.packages)) {
42
46
  if (!isIncluded(name) || isExcluded(name)) continue;
43
- const range = rangeOf(spec);
44
- if (!SIMPLE_RANGE.test(range) || /\s/.test(range.trim())) continue;
45
- const version = bareVersion(range);
46
- const match = PLAIN_VERSION.exec(version);
47
- if (match === null) continue;
48
- const selector = scope === "any" ? name : `${name}@${releaseLine(match[1], match[2])}`;
49
- table[selector] = version;
47
+ const parsed = Result.getOrNull(VersionSpecifier.parseResult(rangeOf(spec)));
48
+ if (parsed === null || !PINNABLE_OPERATORS.has(parsed.operator)) continue;
49
+ const { version } = parsed;
50
+ if (version.prerelease.length > 0 || version.build.length > 0) continue;
51
+ const selector = scope === "any" ? name : `${name}@${releaseLine(version.major, version.minor)}`;
52
+ table[selector] = version.toString();
50
53
  }
51
54
  return table;
52
55
  }