rolldown-pnpm-config 2.4.1 → 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.
- package/bin/rolldown-pnpm-config.js +9 -2
- package/cli/commands/export.js +3 -2
- package/cli/commands/upgrade.js +4 -5
- package/cli/interop.js +1 -1
- package/cli/main.js +12 -4
- package/cli/peer-range.js +12 -8
- package/cli/release-age.js +4 -24
- package/cli/resolve.js +67 -33
- package/cli/ui/preview-screen.js +1 -0
- package/cli/ui/progress-view.js +1 -0
- package/cli/ui/walk-screen.js +1 -0
- package/cli/version.js +1 -1
- package/cli/workspace-file.js +13 -23
- package/cli/workspace-resolve.js +18 -39
- package/package.json +12 -10
- package/plugin/allowed-versions.js +8 -4
- package/plugin/overrides-from-catalogs.js +18 -15
|
@@ -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 { };
|
package/cli/commands/export.js
CHANGED
|
@@ -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,
|
|
17
|
+
import { Data, Effect, Option, Predicate } from "effect";
|
|
18
18
|
import { dirname, relative } from "node:path";
|
|
19
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*
|
|
94
|
+
yield* AtomicFile.write(path, rendered).pipe(Effect.mapError(() => new ExportError({ message: `Cannot write ${path}` })));
|
|
94
95
|
return {
|
|
95
96
|
path,
|
|
96
97
|
rendered,
|
package/cli/commands/upgrade.js
CHANGED
|
@@ -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 {
|
|
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";
|
|
@@ -22,6 +22,7 @@ import { Clock, Data, Effect, FileSystem, Option, Result } from "effect";
|
|
|
22
22
|
import { dirname } from "node:path";
|
|
23
23
|
import { CliDoc, CliExit, CliFormat, CliInteractive, CliMessage, Doc, Fmt } from "@effected/cli-kit";
|
|
24
24
|
import { Argument, Command, Flag } from "effect/cli";
|
|
25
|
+
import { AtomicFile } from "@effected/files";
|
|
25
26
|
import { CliUi } from "@effected/cli-kit/ui";
|
|
26
27
|
import { ReleaseAgeGate } from "@effected/npm";
|
|
27
28
|
|
|
@@ -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
|
|
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) {
|
|
@@ -93,9 +94,7 @@ function readCatalogSource(file) {
|
|
|
93
94
|
function computeGate(source, file, resolver) {
|
|
94
95
|
return Effect.gen(function* () {
|
|
95
96
|
const { config } = yield* Effect.try(() => evaluatePluginConfig(source, file)).pipe(Effect.orElseSucceed(() => ({ config: null })));
|
|
96
|
-
const
|
|
97
|
-
const [age, exc] = yield* Effect.all([resolver.pnpmConfig("minimumReleaseAge").pipe(Effect.orElseSucceed(() => null)), resolver.pnpmConfig("minimumReleaseAgeExclude").pipe(Effect.orElseSucceed(() => null))], { concurrency: "unbounded" });
|
|
98
|
-
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);
|
|
99
98
|
return ReleaseAgeGate.combine(...contributions);
|
|
100
99
|
});
|
|
101
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
|
-
*
|
|
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
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
|
|
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",
|
package/cli/peer-range.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Data, Effect } from "effect";
|
|
2
|
-
import {
|
|
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
|
-
/**
|
|
12
|
-
const
|
|
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
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
40
|
-
const
|
|
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
|
package/cli/release-age.js
CHANGED
|
@@ -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
|
|
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
|
|
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 {
|
|
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
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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 };
|
package/cli/ui/preview-screen.js
CHANGED
package/cli/ui/progress-view.js
CHANGED
package/cli/ui/walk-screen.js
CHANGED
|
@@ -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
package/cli/workspace-file.js
CHANGED
|
@@ -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,
|
|
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
|
-
*
|
|
293
|
-
* quotes and trailing comment
|
|
294
|
-
*
|
|
295
|
-
*
|
|
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
|
|
301
|
-
|
|
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
|
|
304
|
-
const target = doc.success.contents.find(path);
|
|
305
|
-
|
|
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
|
|
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/cli/workspace-resolve.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { parseVersion } from "../semver-util.js";
|
|
2
2
|
import { ResolveError } from "./resolve.js";
|
|
3
|
-
import { Effect,
|
|
4
|
-
import {
|
|
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
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A dogfooding example of our plugin",
|
|
6
6
|
"repository": {
|
|
@@ -36,17 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@effect/platform-node": "~4.1.2",
|
|
39
|
-
"@effected/
|
|
40
|
-
"@effected/
|
|
41
|
-
"@effected/
|
|
42
|
-
"@effected/
|
|
43
|
-
"@effected/
|
|
44
|
-
"@effected/
|
|
45
|
-
"@effected/
|
|
46
|
-
"@effected/
|
|
39
|
+
"@effected/changesets": "^0.1.0",
|
|
40
|
+
"@effected/cli-kit": "^0.27.1",
|
|
41
|
+
"@effected/env": "^0.11.0",
|
|
42
|
+
"@effected/files": "^0.2.0",
|
|
43
|
+
"@effected/glob": "^0.20.0",
|
|
44
|
+
"@effected/npm": "^0.31.0",
|
|
45
|
+
"@effected/semver": "^0.22.0",
|
|
46
|
+
"@effected/walker": "^0.26.0",
|
|
47
|
+
"@effected/workspaces": "^0.44.0",
|
|
48
|
+
"@effected/yaml": "^0.29.0",
|
|
47
49
|
"effect": "~4.1.2",
|
|
48
50
|
"ink": "^8.0.0",
|
|
49
|
-
"oxc-parser": "^0.
|
|
51
|
+
"oxc-parser": "^0.157.0",
|
|
50
52
|
"react": "^19.3.1"
|
|
51
53
|
},
|
|
52
54
|
"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
|
-
|
|
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 (!
|
|
29
|
+
if (!isExactVersion(range)) continue;
|
|
26
30
|
table[`${name}@${range}>${peer}`] = value;
|
|
27
31
|
}
|
|
28
32
|
return table;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { rangeOf } from "../catalogs.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Glob, Predicate, Result } from "effect";
|
|
3
|
+
import { VersionSpecifier } from "@effected/semver";
|
|
4
4
|
|
|
5
5
|
// src/plugin/overrides-from-catalogs.ts
|
|
6
|
-
/**
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
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 !==
|
|
18
|
-
return minor ===
|
|
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
|
|
44
|
-
if (
|
|
45
|
-
const version =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
}
|