rolldown-pnpm-config 2.4.2 → 2.4.3

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.
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { main } from "../cli/main.js";
3
-
4
2
  // src/cli/bin.ts
3
+ if (import.meta.url.endsWith(".ts")) {
4
+ const { register } = await import([
5
+ "tsx",
6
+ "esm",
7
+ "api"
8
+ ].join("/"));
9
+ register();
10
+ }
11
+ const { main } = await import("../cli/main.js");
5
12
  main();
6
13
 
7
14
  export { };
@@ -7,7 +7,7 @@ import { buildInteropEdits, interopEntryChanged, makePeerFetcher, runInterop } f
7
7
  import { buildGroupModel, computeGroupPeers } from "../interop-live.js";
8
8
  import { derivePeerRange } from "../peer-range.js";
9
9
  import { defaultPick, planEntry } from "../plan.js";
10
- import { parsePnpmGate, readConfigReleaseAge } from "../release-age.js";
10
+ import { readConfigReleaseAge } from "../release-age.js";
11
11
  import { failureDoc, warningDoc } from "../render/report.js";
12
12
  import { RegistryResolver } from "../resolve.js";
13
13
  import { applyEdits } from "../rewrite.js";
@@ -94,9 +94,7 @@ function readCatalogSource(file) {
94
94
  function computeGate(source, file, resolver) {
95
95
  return Effect.gen(function* () {
96
96
  const { config } = yield* Effect.try(() => evaluatePluginConfig(source, file)).pipe(Effect.orElseSucceed(() => ({ config: null })));
97
- const cfg = readConfigReleaseAge(config);
98
- const [age, exc] = yield* Effect.all([resolver.pnpmConfig("minimumReleaseAge").pipe(Effect.orElseSucceed(() => null)), resolver.pnpmConfig("minimumReleaseAgeExclude").pipe(Effect.orElseSucceed(() => null))], { concurrency: "unbounded" });
99
- const contributions = [cfg, parsePnpmGate(age, exc)].filter((g) => g !== null);
97
+ const contributions = [readConfigReleaseAge(config), yield* resolver.pnpmReleaseAge().pipe(Effect.orElseSucceed(() => null))].filter((g) => g !== null);
100
98
  return ReleaseAgeGate.combine(...contributions);
101
99
  });
102
100
  }
package/cli/interop.js CHANGED
@@ -153,7 +153,7 @@ function resolveGroup(members, fetchPeer) {
153
153
  * peerDeps (the member resolves at its ceiling).
154
154
  *
155
155
  * Phase 1 now prefetches only the ceiling version of each member (one
156
- * `pnpm view` call per member) instead of every candidate version ≤ ceiling.
156
+ * registry read per member) instead of every candidate version ≤ ceiling.
157
157
  * `resolveGroup` / `violations` fetch lower versions on-demand via the shared
158
158
  * `fetchPeer` Effectful memoized lookup — they are only consulted when a
159
159
  * downgrade search probes them, which for real-world interop groups (where most
package/cli/main.js CHANGED
@@ -15,9 +15,11 @@ import { NodeRuntime, NodeServices } from "@effect/platform-node";
15
15
  * platform's `Stdio` (in `NodeServices.layer`) answers it, which is where the
16
16
  * kit reads it from when `env.stderrIsTerminal` is omitted.
17
17
  *
18
- * The registry resolver (`pnpm view`, spawned through the platform) is
19
- * provided here, at the edge, so a test drives the same command tree against
20
- * a stub resolver.
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
21
+ * `process.cwd()` / `process.env` / `process.platform`, and takes `FileSystem`
22
+ * and `Path` from `NodeServices.layer`, provided by `main`.
21
23
  *
22
24
  * `CliRuntime.main` builds the audience, terminal and theme from `env`,
23
25
  * decides whether the run may prompt, reports every failure on stderr for the
@@ -27,7 +29,13 @@ import { NodeRuntime, NodeServices } from "@effect/platform-node";
27
29
  * @internal
28
30
  */
29
31
  function main() {
30
- const program = CliAudience.run(rootCommand, { version: CLI_VERSION }).pipe(Effect.provideService(WorkingDirectory, process.cwd()), Effect.provide(RegistryResolverLive));
32
+ const cwd = process.cwd();
33
+ const resolverLayer = RegistryResolverLive({
34
+ cwd,
35
+ env: process.env,
36
+ platform: process.platform
37
+ });
38
+ const program = CliAudience.run(rootCommand, { version: CLI_VERSION }).pipe(Effect.provideService(WorkingDirectory, cwd), Effect.provide(resolverLayer));
31
39
  NodeRuntime.runMain(CliRuntime.main(program, {
32
40
  platform: NodeServices.layer,
33
41
  helpOnUsageError: "stderr",
@@ -2,11 +2,12 @@ import { isWrappedField } from "../plugin/freeze.js";
2
2
 
3
3
  // src/cli/release-age.ts
4
4
  /**
5
- * Read a release-age gate from config and pnpm and combine it with
5
+ * Read a release-age gate from config and combine it with
6
6
  * {@link @effected/npm#ReleaseAgeGate.combine}. The gate model itself
7
7
  * (`ReleaseAgeGate`, `PartialReleaseAgeGate`, the age filter, and the
8
8
  * `@pnpm/matcher` exclude semantics) lives in `@effected/npm`; this module
9
- * only turns this repo's two config sources into partial contributions.
9
+ * only turns a plugin config into a partial contribution (pnpm's own settings
10
+ * are read by `RegistryResolver.pnpmReleaseAge`, through `PnpmSettings`).
10
11
  */
11
12
  /** Unwrap a managed field that may be a bare value or a `{ value, enforcement }` FieldInput. */
12
13
  const fieldValue = (raw) => isWrappedField(raw) ? raw.value : raw;
@@ -20,26 +21,5 @@ function readConfigReleaseAge(config) {
20
21
  if (Array.isArray(exc)) out.exclude = exc.filter((x) => typeof x === "string");
21
22
  return out.ageMinutes === void 0 && out.exclude === void 0 ? null : out;
22
23
  }
23
- /** Parse `pnpm config get minimumReleaseAge[Exclude]` stdout into a PartialReleaseAgeGate. @internal */
24
- function parsePnpmGate(age, exclude) {
25
- const out = {};
26
- const trimmedAge = age?.trim();
27
- if (trimmedAge && trimmedAge !== "undefined") {
28
- const n = Number.parseInt(trimmedAge, 10);
29
- if (Number.isFinite(n)) out.ageMinutes = n;
30
- }
31
- const trimmedExc = exclude?.trim();
32
- if (trimmedExc && trimmedExc !== "undefined") {
33
- let list = [];
34
- try {
35
- const json = JSON.parse(trimmedExc);
36
- list = Array.isArray(json) ? json.map(String) : [String(json)];
37
- } catch {
38
- list = trimmedExc.split(/[\s,]+/).filter(Boolean);
39
- }
40
- if (list.length) out.exclude = list;
41
- }
42
- return out.ageMinutes === void 0 && out.exclude === void 0 ? null : out;
43
- }
44
24
 
45
- export { parsePnpmGate, readConfigReleaseAge };
25
+ export { readConfigReleaseAge };
package/cli/resolve.js CHANGED
@@ -1,5 +1,6 @@
1
- import { Context, Data, Effect, Layer, Predicate } from "effect";
1
+ import { Context, Data, Effect, FileSystem, Layer, Option, Path, Predicate } from "effect";
2
2
  import { Fmt } from "@effected/cli-kit";
3
+ import { PnpmSettings } from "@effected/workspaces";
3
4
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
5
 
5
6
  // src/cli/resolve.ts
@@ -11,14 +12,31 @@ const Spawner = ChildProcessSpawner.ChildProcessSpawner;
11
12
  */
12
13
  var ResolveError = class extends Data.TaggedError("ResolveError") {};
13
14
  /**
14
- * Resolves the published versions of a package from the registry. The Live
15
- * implementation shells out to `pnpm view`, reusing the user's .npmrc, scoped
16
- * registries, and auth tokens.
15
+ * Resolves the published versions of a package from the registry, and the
16
+ * release-age gate pnpm itself would apply. The Live implementation shells out
17
+ * to `pnpm view` for registry reads, reusing the user's .npmrc, scoped
18
+ * registries, auth tokens, proxy and TLS settings, and reads pnpm's own
19
+ * settings through `@effected/workspaces`' `PnpmSettings`.
17
20
  *
18
21
  * @internal
19
22
  */
20
23
  var RegistryResolver = class extends Context.Service()("RegistryResolver") {};
21
24
  /**
25
+ * Turn pnpm's effective settings into this resolver's partial gate contribution.
26
+ * `minimumReleaseAge` unset is absent (not an open gate); an empty exclude list
27
+ * contributes nothing.
28
+ *
29
+ * @internal
30
+ */
31
+ function pnpmGateOf(settings) {
32
+ const out = {};
33
+ const age = settings.minimumReleaseAge;
34
+ if (Option.isSome(age)) out.ageMinutes = age.value;
35
+ const exclude = settings.minimumReleaseAgeExclude;
36
+ if (exclude.length > 0) out.exclude = [...exclude];
37
+ return out.ageMinutes === void 0 && out.exclude === void 0 ? null : out;
38
+ }
39
+ /**
22
40
  * Drop pnpm's own notice lines from captured stdout. pnpm prints e.g.
23
41
  * `[WARN] This project is configured to use 12.5.0… Your current pnpm is v12.4.2`
24
42
  * (a `packageManager` mismatch) to STDOUT ahead of the `--json` payload, which
@@ -30,7 +48,7 @@ var RegistryResolver = class extends Context.Service()("RegistryResolver") {};
30
48
  function stripPnpmNotices(stdout) {
31
49
  return stdout.replace(/^[ \t]*(?:\[WARN\]|\[ERR\]|WARN\b|ERR_PNPM_\w+)[^\n]*\n?/gm, "");
32
50
  }
33
- /** Parse `pnpm view ... versions --json` stdout: a JSON array, or a single JSON string. */
51
+ /** Parse `pnpm view ... versions --json` stdout: a JSON array, or a single JSON string. @internal */
34
52
  function parseVersions(pkg, stdout) {
35
53
  return Effect.try({
36
54
  try: () => {
@@ -72,35 +90,51 @@ function parsePeerDeps(pkg, stdout) {
72
90
  return parseStringRecord(pkg, trimmed, "peerDependencies");
73
91
  }
74
92
  /**
75
- * Live RegistryResolver backed by `pnpm view <pkg> versions --json`.
93
+ * Live RegistryResolver: registry reads through `pnpm view`, the release-age
94
+ * gate through `PnpmSettings`.
95
+ *
96
+ * Registry reads stay on `pnpm view` rather than `@effected/npm`'s
97
+ * `NpmRegistry` until the kit honours npmrc `proxy`/`https-proxy`,
98
+ * `cafile`/`ca` and `strict-ssl` (spencerbeggs/effected#1307, tracked locally
99
+ * in #295): over plain `fetch`, a user behind a corporate proxy or an
100
+ * internal CA would fail every lookup that `pnpm view` answers.
101
+ *
102
+ * `PnpmSettings` loads lazily and once (`Effect.cached`), so a malformed
103
+ * `pnpm-workspace.yaml` fails only `pnpmReleaseAge`, typed, and never layer
104
+ * construction.
76
105
  *
77
106
  * @internal
78
107
  */
79
- const RegistryResolverLive = Layer.effect(RegistryResolver, Effect.gen(function* () {
80
- const spawner = yield* Spawner;
81
- /** `pnpm view <spec> <field> --json` stdout, with a spawn failure typed against `pkg`. */
82
- const pnpmView = (pkg, spec, field) => spawner.string(ChildProcess.make("pnpm", [
83
- "view",
84
- spec,
85
- field,
86
- "--json"
87
- ])).pipe(Effect.map(stripPnpmNotices), Effect.mapError((e) => new ResolveError({
88
- pkg,
89
- message: Fmt.errorText(e)
90
- })));
91
- return {
92
- versions: (pkg) => pnpmView(pkg, pkg, "versions").pipe(Effect.flatMap((out) => parseVersions(pkg, out))),
93
- times: (pkg) => pnpmView(pkg, pkg, "time").pipe(Effect.flatMap((out) => parseTimes(pkg, out))),
94
- peerDependencies: (pkg, version) => pnpmView(pkg, `${pkg}@${version}`, "peerDependencies").pipe(Effect.flatMap((out) => parsePeerDeps(pkg, out))),
95
- pnpmConfig: (key) => Effect.gen(function* () {
96
- const cmd = ChildProcess.make("pnpm", [
97
- "config",
98
- "get",
99
- key
100
- ]);
101
- return yield* spawner.string(cmd).pipe(Effect.map((s) => stripPnpmNotices(s).trim()), Effect.orElseSucceed(() => null));
102
- })
103
- };
104
- }));
108
+ function RegistryResolverLive(options) {
109
+ return Layer.effect(RegistryResolver, Effect.gen(function* () {
110
+ const spawner = yield* Spawner;
111
+ const fs = yield* FileSystem.FileSystem;
112
+ const path = yield* Path.Path;
113
+ const pnpmSettings = yield* Effect.cached(PnpmSettings.load({
114
+ cwd: options.cwd,
115
+ env: options.env,
116
+ platform: options.platform
117
+ }).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)));
118
+ /** `pnpm view <spec> <field> --json` stdout, with a spawn failure typed against `pkg`. */
119
+ const pnpmView = (pkg, spec, field) => spawner.string(ChildProcess.make("pnpm", [
120
+ "view",
121
+ spec,
122
+ field,
123
+ "--json"
124
+ ])).pipe(Effect.map(stripPnpmNotices), Effect.mapError((e) => new ResolveError({
125
+ pkg,
126
+ message: Fmt.errorText(e)
127
+ })));
128
+ return {
129
+ versions: (pkg) => pnpmView(pkg, pkg, "versions").pipe(Effect.flatMap((out) => parseVersions(pkg, out))),
130
+ times: (pkg) => pnpmView(pkg, pkg, "time").pipe(Effect.flatMap((out) => parseTimes(pkg, out))),
131
+ peerDependencies: (pkg, version) => pnpmView(pkg, `${pkg}@${version}`, "peerDependencies").pipe(Effect.flatMap((out) => parsePeerDeps(pkg, out))),
132
+ pnpmReleaseAge: () => pnpmSettings.pipe(Effect.map(pnpmGateOf), Effect.mapError((e) => new ResolveError({
133
+ pkg: "pnpm-workspace.yaml",
134
+ message: Fmt.errorText(e)
135
+ })))
136
+ };
137
+ }));
138
+ }
105
139
 
106
- export { RegistryResolver, RegistryResolverLive, ResolveError, parsePeerDeps, parseTimes, parseVersions, stripPnpmNotices };
140
+ export { RegistryResolver, RegistryResolverLive, ResolveError, parsePeerDeps, parseTimes, parseVersions, pnpmGateOf, stripPnpmNotices };
@@ -6,6 +6,7 @@ import { useEffect, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
 
8
8
  // src/cli/ui/preview-screen.tsx
9
+ /** @jsxRuntime automatic */
9
10
  const TABS = [
10
11
  {
11
12
  name: "changes",
@@ -4,6 +4,7 @@ import { Text } from "ink";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
 
6
6
  // src/cli/ui/progress-view.tsx
7
+ /** @jsxRuntime automatic */
7
8
  function Progress({ state, frame }) {
8
9
  const glyphs = useGlyphs();
9
10
  const theme = useTheme();
@@ -8,6 +8,7 @@ import { useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
 
10
10
  // src/cli/ui/walk-screen.tsx
11
+ /** @jsxRuntime automatic */
11
12
  /** The table's keys: arrows (or vim keys) to move and pick, Enter to finish. Esc and Ctrl-C are the host's. */
12
13
  function walkKeys(dryRun) {
13
14
  return KeyTable.make([
package/cli/version.js CHANGED
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- const CLI_VERSION = "2.4.2";
9
+ const CLI_VERSION = "2.4.3";
10
10
 
11
11
  export { CLI_VERSION };
@@ -1,24 +1,18 @@
1
1
  import { parseVersion } from "../semver-util.js";
2
2
  import { ResolveError } from "./resolve.js";
3
- import { Effect, Layer, Result } from "effect";
4
- import { join, resolve } from "node:path";
5
- import { GlobPattern, GlobPatternOptions } from "@effected/glob";
6
- import { descendSync } from "@effected/walker";
7
- import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
8
- import { readFileSync } from "node:fs";
3
+ import { Effect, Result } from "effect";
4
+ import { resolve } from "node:path";
9
5
  import { findWorkspaceRootSync, getWorkspacePackagesSync } from "@effected/workspaces";
10
6
  import { nodeSyncOps } from "@effected/workspaces/node-sync";
7
+ import { PendingChangesets } from "@effected/changesets";
11
8
 
12
9
  // src/cli/workspace-resolve.ts
10
+ /** Bump strength, weakest to strongest, for strongest-bump-per-package. */
13
11
  const BUMP_ORDER = {
14
12
  patch: 0,
15
13
  minor: 1,
16
14
  major: 2
17
15
  };
18
- /** The changeset files of `.changeset/`: top-level `.md` FILES, no dotfiles, sorted. */
19
- const CHANGESET_FILES = Result.getOrThrow(GlobPattern.compileResult("*.md", GlobPatternOptions.make({ dot: false })));
20
- /** Matches one changeset frontmatter line: `"@scope/name": minor` (quotes optional). */
21
- const FRONTMATTER_LINE_RE = /^\s*["']?([^"':\s]+)["']?\s*:\s*(major|minor|patch)\s*$/;
22
16
  /**
23
17
  * Read every workspace package manifest under `rootDir` with a usable name and
24
18
  * version, honoring the workspace's own `pnpm-workspace.yaml` `packages:`
@@ -58,37 +52,22 @@ function readManifests(rootDir) {
58
52
  return out;
59
53
  }
60
54
  /**
61
- * Read the pending changeset bumps from `<rootDir>/.changeset/*.md` (skipping
62
- * README.md): each file's YAML frontmatter (between the first two `---` lines)
63
- * maps package name → bump level; the strongest bump per package wins.
64
- * An absent or unreadable `.changeset/` yields an empty map.
55
+ * Read the pending changeset bumps under `<rootDir>/.changeset/` through
56
+ * `@effected/changesets`' `PendingChangesets.readSync` (which skips readmes,
57
+ * agent context files, dotfiles and non-`.md` files, and also reads the
58
+ * `pre/` changesets a pre-release keeps): package name → strongest bump.
59
+ * A `none` release is no bump. Total: an absent `.changeset/` lists nothing,
60
+ * and an unreadable directory or any malformed changeset degrades to an
61
+ * empty map (current versions), never a failure.
65
62
  */
66
63
  function readPendingBumps(rootDir) {
67
64
  const out = /* @__PURE__ */ new Map();
68
- const dir = join(rootDir, ".changeset");
69
- const names = Result.getOrElse(descendSync(CHANGESET_FILES, {
70
- cwd: dir,
71
- ...nodeWalkerSyncOps
72
- }), () => []).filter((n) => n !== "README.md");
73
- for (const name of names) {
74
- let text;
75
- try {
76
- text = readFileSync(join(dir, name), "utf8");
77
- } catch {
78
- continue;
79
- }
80
- const lines = text.split("\n");
81
- const fences = [];
82
- for (let i = 0; i < lines.length && fences.length < 2; i++) if (lines[i]?.trim() === "---") fences.push(i);
83
- const [open, close] = fences;
84
- if (open === void 0 || close === void 0) continue;
85
- for (const line of lines.slice(open + 1, close)) {
86
- const m = FRONTMATTER_LINE_RE.exec(line);
87
- if (!m) continue;
88
- const [, pkg, bump] = m;
89
- const prev = out.get(pkg);
90
- if (prev === void 0 || BUMP_ORDER[bump] > BUMP_ORDER[prev]) out.set(pkg, bump);
91
- }
65
+ const pending = PendingChangesets.readSync(rootDir);
66
+ if (Result.isFailure(pending)) return out;
67
+ for (const changeset of pending.success) for (const [pkg, release] of changeset.releases) {
68
+ if (release === "none") continue;
69
+ const prev = out.get(pkg);
70
+ if (prev === void 0 || BUMP_ORDER[release] > BUMP_ORDER[prev]) out.set(pkg, release);
92
71
  }
93
72
  return out;
94
73
  }
@@ -145,7 +124,7 @@ function makeWorkspaceResolver(rootDir) {
145
124
  },
146
125
  times: () => Effect.succeed({}),
147
126
  peerDependencies: (pkg) => Effect.succeed(load().manifests.get(pkg)?.peerDependencies ?? {}),
148
- pnpmConfig: () => Effect.succeed(null)
127
+ pnpmReleaseAge: () => Effect.succeed(null)
149
128
  };
150
129
  }
151
130
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -36,14 +36,15 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@effect/platform-node": "~4.1.2",
39
- "@effected/cli-kit": "^0.27.0",
39
+ "@effected/changesets": "^0.1.0",
40
+ "@effected/cli-kit": "^0.27.1",
40
41
  "@effected/env": "^0.11.0",
41
- "@effected/files": "^0.1.0",
42
- "@effected/glob": "^0.19.0",
43
- "@effected/npm": "^0.30.1",
42
+ "@effected/files": "^0.2.0",
43
+ "@effected/glob": "^0.20.0",
44
+ "@effected/npm": "^0.31.0",
44
45
  "@effected/semver": "^0.22.0",
45
- "@effected/walker": "^0.25.1",
46
- "@effected/workspaces": "^0.43.0",
46
+ "@effected/walker": "^0.26.0",
47
+ "@effected/workspaces": "^0.44.0",
47
48
  "@effected/yaml": "^0.29.0",
48
49
  "effect": "~4.1.2",
49
50
  "ink": "^8.0.0",