@effected/workspaces 0.47.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ConfigDependencyHooks.js +14 -26
- package/PackageManagerName.js +75 -19
- package/PackedInstall.js +7 -9
- package/PeerCheck.js +9 -10
- package/README.md +13 -43
- package/WorkspaceCatalogs.js +9 -7
- package/WorkspacePackage.js +7 -1
- package/WorkspaceStateSnapshot.js +3 -1
- package/Workspaces.js +5 -2
- package/WorkspacesSync.js +7 -5
- package/index.d.ts +91 -409
- package/index.js +3 -4
- package/internal/catalogs.js +55 -32
- package/internal/importerVersions.js +1 -1
- package/internal/limits.js +1 -1
- package/internal/membership.js +2 -1
- package/internal/packageManagerDecision.js +14 -3
- package/internal/packedInstallPlan.js +10 -33
- package/internal/workspaceYaml.js +4 -4
- package/package.json +10 -12
- package/testing.d.ts +30 -22
- package/PnpmSettings.js +0 -535
- package/internal/peerPatterns.js +0 -34
package/ConfigDependencyHooks.js
CHANGED
|
@@ -5,36 +5,23 @@ import { Context, Duration, Effect, Layer, Predicate, Schema } from "effect";
|
|
|
5
5
|
import { CatalogAssemblyError } from "@effected/npm";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { Run } from "@effected/commands";
|
|
8
|
+
import { PeerDependencyRules } from "@effected/pnpm";
|
|
8
9
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
9
10
|
|
|
10
11
|
// src/ConfigDependencyHooks.ts
|
|
11
|
-
/**
|
|
12
|
-
* The empty {@link PeerDependencyRules}: every axis present and empty.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* Exported so that "I assert this workspace's rules are empty" is **one token**
|
|
16
|
-
* rather than three hand-written empty axes. That matters where the distinction
|
|
17
|
-
* is load-bearing — supplying rules asserts they were looked up, while omitting
|
|
18
|
-
* them asserts nothing — and a caller spelling the object out by hand will
|
|
19
|
-
* eventually fill two of the three axes and mean the third.
|
|
20
|
-
*
|
|
21
|
-
* Frozen, since it is shared.
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
const NoPeerDependencyRules = Object.freeze({
|
|
26
|
-
allowedVersions: Object.freeze({}),
|
|
27
|
-
ignoreMissing: Object.freeze([]),
|
|
28
|
-
allowAny: Object.freeze([])
|
|
29
|
-
});
|
|
30
12
|
/** Internal alias, kept short at the many call sites in this module. */
|
|
31
|
-
const NO_PEER_RULES =
|
|
13
|
+
const NO_PEER_RULES = PeerDependencyRules.empty;
|
|
32
14
|
/** Turn the seed record into the pnpm hook config, with the default catalog split out under `catalog`. */
|
|
33
15
|
const seedToConfig = (seed, rules) => {
|
|
34
16
|
const catalogs = {};
|
|
35
17
|
let catalog = {};
|
|
36
18
|
for (const [name, entries] of Object.entries(seed)) if (name === "default") catalog = { ...entries };
|
|
37
|
-
else catalogs
|
|
19
|
+
else Object.defineProperty(catalogs, name, {
|
|
20
|
+
value: { ...entries },
|
|
21
|
+
writable: true,
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true
|
|
24
|
+
});
|
|
38
25
|
return {
|
|
39
26
|
catalog,
|
|
40
27
|
catalogs,
|
|
@@ -83,11 +70,11 @@ const peerRulesOr = (value, fallback) => {
|
|
|
83
70
|
const ignoreMissing = stringArrayOr(value.ignoreMissing, fallback?.ignoreMissing);
|
|
84
71
|
const allowAny = stringArrayOr(value.allowAny, fallback?.allowAny);
|
|
85
72
|
if (allowed === void 0 && ignoreMissing === void 0 && allowAny === void 0) return fallback;
|
|
86
|
-
return {
|
|
73
|
+
return PeerDependencyRules.make({
|
|
87
74
|
allowedVersions: allowed ?? {},
|
|
88
75
|
ignoreMissing: ignoreMissing ?? [],
|
|
89
76
|
allowAny: allowAny ?? []
|
|
90
|
-
};
|
|
77
|
+
});
|
|
91
78
|
};
|
|
92
79
|
/** Project the threaded config's rules into the slice, defaulting every axis to empty. */
|
|
93
80
|
const peerRulesOf = (config) => config.peerDependencyRules ?? NO_PEER_RULES;
|
|
@@ -258,7 +245,8 @@ const replay = async () => {
|
|
|
258
245
|
const catalogs = {};
|
|
259
246
|
for (const [name, entries] of Object.entries(JSON.parse(seedJson))) {
|
|
260
247
|
if (name === "default") catalog = { ...entries };
|
|
261
|
-
|
|
248
|
+
// An own data property: a catalog named __proto__ must not become the record's prototype.
|
|
249
|
+
else Object.defineProperty(catalogs, name, { value: { ...entries }, writable: true, enumerable: true, configurable: true });
|
|
262
250
|
}
|
|
263
251
|
let config = {
|
|
264
252
|
catalog,
|
|
@@ -516,7 +504,7 @@ var ConfigDependencyHooks = class ConfigDependencyHooks extends Context.Service(
|
|
|
516
504
|
* `layerLive` — which captures nothing — would succeed).
|
|
517
505
|
*
|
|
518
506
|
* Catalog folding and normalization stay in the **parent** (the same
|
|
519
|
-
*
|
|
507
|
+
* catalog engine path `layerLive` uses); the child returns only the
|
|
520
508
|
* raw threaded config slice, since the script cannot import kit code.
|
|
521
509
|
*
|
|
522
510
|
* Requires core's `ChildProcessSpawner`, resolved when the layer is built —
|
|
@@ -559,4 +547,4 @@ var ConfigDependencyHooks = class ConfigDependencyHooks extends Context.Service(
|
|
|
559
547
|
}));
|
|
560
548
|
};
|
|
561
549
|
|
|
562
|
-
export { ConfigDependencyHooks
|
|
550
|
+
export { ConfigDependencyHooks };
|
package/PackageManagerName.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { MARKER_FILES, decidePackageManager } from "./internal/packageManagerDecision.js";
|
|
2
2
|
import { WorkspaceManifestError } from "./WorkspacePackage.js";
|
|
3
|
-
import { Context, Effect, FileSystem, Layer, Option, Path, Predicate, Schema } from "effect";
|
|
3
|
+
import { Context, Effect, FileSystem, Layer, Option, Path, Predicate, Result, Schema } from "effect";
|
|
4
4
|
import { PackageJsonFormat } from "@effected/package-json";
|
|
5
5
|
|
|
6
6
|
// src/PackageManagerName.ts
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
8
|
+
* The package managers this package acts on: npm, pnpm and bun.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* A repository run by any other manager still discovers — its members come
|
|
12
|
+
* from `package.json#workspaces` — but detection reports it as an
|
|
13
|
+
* `UnsupportedPackageManagerError` rather than naming one of these.
|
|
9
14
|
*
|
|
10
15
|
* @public
|
|
11
16
|
*/
|
|
12
17
|
const PackageManagerName = Schema.Literals([
|
|
13
18
|
"npm",
|
|
14
19
|
"pnpm",
|
|
15
|
-
"yarn",
|
|
16
20
|
"bun"
|
|
17
21
|
]);
|
|
18
22
|
/**
|
|
@@ -37,7 +41,6 @@ const PackageManagerEvidence = Schema.Literals([
|
|
|
37
41
|
"pnpm-workspace.yaml",
|
|
38
42
|
"bun.lock",
|
|
39
43
|
"bun.lockb",
|
|
40
|
-
"yarn.lock",
|
|
41
44
|
"package.json#workspaces",
|
|
42
45
|
"pnpm-lock.yaml",
|
|
43
46
|
"package-lock.json",
|
|
@@ -49,16 +52,16 @@ const PackageManagerEvidence = Schema.Literals([
|
|
|
49
52
|
*
|
|
50
53
|
* @remarks
|
|
51
54
|
* `version` is `Option.none()` unless a manifest field naming the *same* manager
|
|
52
|
-
* that was detected also carries a version — a `packageManager: "
|
|
53
|
-
* pnpm workspace tells us nothing about pnpm's version, so it is not reported
|
|
54
|
-
* one. The two fields consulted are the corepack top-level `packageManager` and
|
|
55
|
+
* that was detected also carries a version — a `packageManager: "bun@1.2.0"` in
|
|
56
|
+
* a pnpm workspace tells us nothing about pnpm's version, so it is not reported
|
|
57
|
+
* as one. The two fields consulted are the corepack top-level `packageManager` and
|
|
55
58
|
* `devEngines.packageManager`; see {@link PackageManagerDetector} for the
|
|
56
59
|
* precedence between them.
|
|
57
60
|
*
|
|
58
61
|
* `evidence` is the rung of the priority order that decided the **name** — the
|
|
59
62
|
* verdict's provenance, in the same vocabulary the failure path reports as
|
|
60
|
-
* `PackageManagerDetectionError.checked`. For the bun
|
|
61
|
-
*
|
|
63
|
+
* `PackageManagerDetectionError.checked`. For the bun rung the lockfile is the
|
|
64
|
+
* recorded signal even though the rung is a conjunction (the
|
|
62
65
|
* lockfile *plus* a manifest field naming the manager): the manifest field alone
|
|
63
66
|
* would have resolved in the declaration tier, so the lockfile is what this rung
|
|
64
67
|
* added. The version's provenance is deliberately not carried — it follows the
|
|
@@ -94,22 +97,75 @@ var PackageManagerDetectionError = class extends Schema.TaggedError()("PackageMa
|
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
/**
|
|
100
|
+
* Raised when a root belongs to a package manager this package does not act
|
|
101
|
+
* on, so detection names it instead of guessing a supported one.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* yarn is that manager. A yarn repository declares its members in
|
|
105
|
+
* `package.json#workspaces` exactly as npm does, so discovery, the root ascent
|
|
106
|
+
* and the dependency graph work on it unchanged; what fails is everything that
|
|
107
|
+
* runs or provisions a manager, parses its lockfile or launches its tools.
|
|
108
|
+
* Reporting npm there would run the wrong manager against a yarn tree.
|
|
109
|
+
*
|
|
110
|
+
* `evidence` is the signal that identified the manager: its lockfile, or the
|
|
111
|
+
* manifest field that names it.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
var UnsupportedPackageManagerError = class extends Schema.TaggedError()("UnsupportedPackageManagerError", {
|
|
116
|
+
/** The workspace root that was probed. */
|
|
117
|
+
root: Schema.String,
|
|
118
|
+
/** The unsupported manager the root belongs to. */
|
|
119
|
+
manager: Schema.Literal("yarn"),
|
|
120
|
+
/** The signal that identified it. */
|
|
121
|
+
evidence: Schema.Literals([
|
|
122
|
+
"yarn.lock",
|
|
123
|
+
"package.json#devEngines.packageManager",
|
|
124
|
+
"package.json#packageManager"
|
|
125
|
+
])
|
|
126
|
+
}) {
|
|
127
|
+
/** Renders the root, manager and evidence into a one-line message. */
|
|
128
|
+
get message() {
|
|
129
|
+
return `${this.root} is a ${this.manager} repository (${this.evidence}), and ${this.manager} is not a supported package manager: use npm, pnpm or bun`;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
97
133
|
* The markers probed, in priority order. Derived from the evidence vocabulary so
|
|
98
134
|
* the failure path's `checked` and the success path's `evidence` cannot drift.
|
|
99
135
|
*/
|
|
100
136
|
const CHECKED = PackageManagerEvidence.literals;
|
|
101
137
|
/**
|
|
138
|
+
* The detection result for a decided verdict: the detected manager, or the
|
|
139
|
+
* unsupported-manager failure. Shared by the Effect and sync surfaces.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
const verdictResult = (root, verdict) => verdict._tag === "Unsupported" ? Result.fail(new UnsupportedPackageManagerError({
|
|
144
|
+
root,
|
|
145
|
+
manager: verdict.manager,
|
|
146
|
+
evidence: verdict.evidence
|
|
147
|
+
})) : Result.succeed(DetectedPackageManager.make({
|
|
148
|
+
name: verdict.name,
|
|
149
|
+
version: verdict.version,
|
|
150
|
+
runtime: verdict.runtime,
|
|
151
|
+
evidence: verdict.evidence
|
|
152
|
+
}));
|
|
153
|
+
/**
|
|
102
154
|
* Detects which package manager owns a workspace root.
|
|
103
155
|
*
|
|
104
156
|
* @remarks
|
|
105
157
|
* **Lockfile evidence is the primary signal** — it is what says which manager
|
|
106
158
|
* actually ran. Priority, first match wins: a `pnpm-workspace.yaml` means pnpm;
|
|
107
|
-
* a bun lockfile *plus* a manifest field naming bun means bun; a
|
|
108
|
-
*
|
|
109
|
-
*
|
|
159
|
+
* a bun lockfile *plus* a manifest field naming bun means bun; a root
|
|
160
|
+
* `package.json` with a `workspaces` field falls back to npm.
|
|
161
|
+
*
|
|
162
|
+
* The manifest conjunction is deliberate: a stray bun lockfile in an npm repo
|
|
163
|
+
* is common, and only a declared manager name disambiguates it.
|
|
110
164
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
165
|
+
* A yarn repository fails with {@link UnsupportedPackageManagerError} instead
|
|
166
|
+
* of falling back to npm: a manifest field naming yarn decides it, and so does
|
|
167
|
+
* a `yarn.lock` that is the root's only lockfile when the manifest names no
|
|
168
|
+
* manager.
|
|
113
169
|
*
|
|
114
170
|
* **Two manifest fields declare a manager, and they are not interchangeable.**
|
|
115
171
|
* Corepack reads both, and this is the rule that falls out of how it treats
|
|
@@ -126,8 +182,8 @@ const CHECKED = PackageManagerEvidence.literals;
|
|
|
126
182
|
* supplies the version instead.
|
|
127
183
|
*
|
|
128
184
|
* A version is reported **only when the field it came from names the manager
|
|
129
|
-
* that was actually detected**. A `packageManager: "
|
|
130
|
-
* says nothing about pnpm's version, so no version is reported — and the same
|
|
185
|
+
* that was actually detected**. A `packageManager: "bun@1.2.0"` in a pnpm
|
|
186
|
+
* workspace says nothing about pnpm's version, so no version is reported — and the same
|
|
131
187
|
* discipline applies to `devEngines`.
|
|
132
188
|
*
|
|
133
189
|
* Malformed manifest *hints* are ignored rather than fatal, matching corepack: a
|
|
@@ -148,7 +204,7 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
|
|
|
148
204
|
/**
|
|
149
205
|
* The root manifest, read and parsed **once** per detection.
|
|
150
206
|
*
|
|
151
|
-
* An absent manifest is `Option.none()` — a bun
|
|
207
|
+
* An absent manifest is `Option.none()` — a bun repo with no root
|
|
152
208
|
* `package.json` is unusual but not an error. A manifest that is present but
|
|
153
209
|
* unreadable, unparseable, or not a JSON object fails typed: those are
|
|
154
210
|
* corrupt-manifest conditions, and swallowing them would report "no manager
|
|
@@ -177,7 +233,7 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
|
|
|
177
233
|
root,
|
|
178
234
|
checked: CHECKED
|
|
179
235
|
}));
|
|
180
|
-
return
|
|
236
|
+
return yield* Effect.fromResult(verdictResult(root, decision));
|
|
181
237
|
});
|
|
182
238
|
return { detect: (root) => detect(root).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)) };
|
|
183
239
|
});
|
|
@@ -241,4 +297,4 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
|
|
|
241
297
|
static layerTest = (overrides = {}) => Layer.succeed(PackageManagerDetector, PackageManagerDetector.makeTest(overrides));
|
|
242
298
|
};
|
|
243
299
|
|
|
244
|
-
export { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerEvidence, PackageManagerName };
|
|
300
|
+
export { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerEvidence, PackageManagerName, UnsupportedPackageManagerError, verdictResult };
|
package/PackedInstall.js
CHANGED
|
@@ -89,8 +89,7 @@ var InstalledConsumer = class extends Schema.Class("InstalledConsumer")({
|
|
|
89
89
|
* Which installed package the `node_modules/.bin` entry `name` resolves into.
|
|
90
90
|
*
|
|
91
91
|
* @remarks
|
|
92
|
-
* Under a flat layout (npm, bun,
|
|
93
|
-
* this run configures), a hoisted bin of the same name from another package
|
|
92
|
+
* Under a flat layout (npm, bun), a hoisted bin of the same name from another package
|
|
94
93
|
* can shadow the carrier's, and running it cannot tell you which one ran.
|
|
95
94
|
* Those managers write each `.bin` entry as a symlink, so this reads the
|
|
96
95
|
* link, realpaths its target, and walks up to the nearest `package.json`
|
|
@@ -213,8 +212,7 @@ var InstalledConsumer = class extends Schema.Class("InstalledConsumer")({
|
|
|
213
212
|
* won the `node_modules/.bin` slot.
|
|
214
213
|
*
|
|
215
214
|
* @remarks
|
|
216
|
-
* With `allowSharedBins`, a flat layout (npm, bun
|
|
217
|
-
* linker) can link a front end's same-named bin into `.bin`, so
|
|
215
|
+
* With `allowSharedBins`, a flat layout (npm, bun) can link a front end's same-named bin into `.bin`, so
|
|
218
216
|
* {@link InstalledConsumer.runBin} proves only that SOME package's bin runs.
|
|
219
217
|
* This reads the carrier's installed `node_modules/<carrier>/package.json`,
|
|
220
218
|
* takes `name` from its `bin` map (a `bin` string answers to the unscoped
|
|
@@ -351,7 +349,7 @@ const tail = (text) => text.length <= TAIL ? text : text.slice(-2e3);
|
|
|
351
349
|
const MESSAGE_TAIL_CHARS = 600;
|
|
352
350
|
/**
|
|
353
351
|
* `message` followed by the end of `output`. The manager's own install and
|
|
354
|
-
* pack logs are what `output` holds: npm, pnpm
|
|
352
|
+
* pack logs are what `output` holds: npm, pnpm and bun print registry
|
|
355
353
|
* URLs and resolution failures, never the auth values they read from the
|
|
356
354
|
* user's rc files or from `NODE_AUTH_TOKEN` (npm redacts tokens in its own
|
|
357
355
|
* log lines), and the install env is already scrubbed of the parent
|
|
@@ -533,14 +531,14 @@ var PackedInstall = class PackedInstall {
|
|
|
533
531
|
* import { Duration } from "effect";
|
|
534
532
|
*
|
|
535
533
|
* const budget = PackedInstall.timeoutBudget({
|
|
536
|
-
* managers: ["npm", "pnpm", "
|
|
534
|
+
* managers: ["npm", "pnpm", "bun"],
|
|
537
535
|
* installTimeout: "3 minutes",
|
|
538
536
|
* packTimeout: "30 seconds",
|
|
539
537
|
* packages: ["my-tool", "my-tool-cli", "my-tool-core"],
|
|
540
538
|
* perConsumer: "2 minutes",
|
|
541
539
|
* });
|
|
542
540
|
* console.log(Duration.format(budget));
|
|
543
|
-
* // =>
|
|
541
|
+
* // => 21m
|
|
544
542
|
* ```
|
|
545
543
|
*/
|
|
546
544
|
static timeoutBudget = (budget) => {
|
|
@@ -848,7 +846,7 @@ var PackedInstall = class PackedInstall {
|
|
|
848
846
|
name,
|
|
849
847
|
bins: manifest.bins
|
|
850
848
|
})));
|
|
851
|
-
if (conflict !== void 0) return yield* failure("BinConflict", `${conflict.package} declares the bin ${conflict.bin}, which the carrier ${carrier.name} declares; under a flat layout (npm, bun
|
|
849
|
+
if (conflict !== void 0) return yield* failure("BinConflict", `${conflict.package} declares the bin ${conflict.bin}, which the carrier ${carrier.name} declares; under a flat layout (npm, bun) either can take node_modules/.bin/${conflict.bin} and the carrier's provenance is lost there; drop the bin from ${conflict.package}, or pass allowSharedBins: true to share it deliberately`, { package: conflict.package });
|
|
852
850
|
const overrides = Object.fromEntries(rest.map(({ name, tarball }) => [name, tarball]));
|
|
853
851
|
const consumers = yield* Effect.forEach(available, ({ manager, version }) => Effect.gen(function* () {
|
|
854
852
|
const directory = path.join(scratch, `consumer-${manager}`);
|
|
@@ -861,7 +859,7 @@ var PackedInstall = class PackedInstall {
|
|
|
861
859
|
dependencies: options.consumerDependencies ?? {}
|
|
862
860
|
})) yield* fs.writeFileString(path.join(directory, file), content).pipe(Effect.mapError(io(`could not write ${file}`)));
|
|
863
861
|
const installTimeout = options.installTimeout ?? DEFAULT_INSTALL_TIMEOUT;
|
|
864
|
-
const output = yield* Run.collect(command(manager, installArgs(manager
|
|
862
|
+
const output = yield* Run.collect(command(manager, installArgs(manager), directory), { timeout: installTimeout }).pipe(Effect.mapError((cause) => failure("InstallFailed", cause._tag === "CommandFailedError" && cause.kind === "timeout" ? `${manager} install timed out after ${describeDuration(installTimeout)}` : `${manager} install could not run`, {
|
|
865
863
|
manager,
|
|
866
864
|
cause
|
|
867
865
|
})));
|
package/PeerCheck.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { peerNameMatcher } from "./internal/peerPatterns.js";
|
|
2
1
|
import { indexInstances, rootInstances } from "./internal/roots.js";
|
|
3
2
|
import { Option, Result, Schema } from "effect";
|
|
3
|
+
import { PnpmMatcher } from "@effected/pnpm";
|
|
4
4
|
import { Range, SemVer } from "@effected/semver";
|
|
5
5
|
|
|
6
6
|
// src/PeerCheck.ts
|
|
@@ -63,7 +63,7 @@ var UnsatisfiedPeer = class extends Schema.Class("UnsatisfiedPeer")({
|
|
|
63
63
|
/**
|
|
64
64
|
* The formats whose lockfiles record peer resolution.
|
|
65
65
|
*
|
|
66
|
-
* An allowlist rather than a
|
|
66
|
+
* An allowlist rather than a denylist, so a format added to
|
|
67
67
|
* `Lockfile["format"]` is unsupported until someone says otherwise. A denylist
|
|
68
68
|
* would report the new format `supported: true` with an empty `unsatisfied`
|
|
69
69
|
* before any parser records peer resolution for it — a clean bill of health
|
|
@@ -421,11 +421,10 @@ var PeerCheck = class PeerCheck extends Schema.Class("PeerCheck")({
|
|
|
421
421
|
/**
|
|
422
422
|
* Whether the lockfile's format records peer resolution at all.
|
|
423
423
|
*
|
|
424
|
-
* `false` for
|
|
425
|
-
* peer
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
* is empty and this flag says why.
|
|
424
|
+
* `false` for a format whose lockfile does not record which instance
|
|
425
|
+
* satisfied which peer. The answer is not recoverable there, so it is not
|
|
426
|
+
* fabricated — `unsatisfied` is empty and this flag says why. Every format
|
|
427
|
+
* `Lockfile.parse` reads today records it.
|
|
429
428
|
*/
|
|
430
429
|
supported: Schema.Boolean,
|
|
431
430
|
/** Every unsatisfied peer found, optional ones included. */
|
|
@@ -501,7 +500,7 @@ var PeerCheck = class PeerCheck extends Schema.Class("PeerCheck")({
|
|
|
501
500
|
* - **A workspace-linked provider counts.** Resolution is followed through
|
|
502
501
|
* whatever the edge names, including a workspace row.
|
|
503
502
|
*
|
|
504
|
-
* Known limits it does not paper over:
|
|
503
|
+
* Known limits it does not paper over: the npm and
|
|
505
504
|
* bun root importer (see `unresolvedImporters`), and pnpm recording no peer
|
|
506
505
|
* declarations for workspace projects themselves — under pnpm a workspace
|
|
507
506
|
* package's *own* unsatisfied peers are not in the lockfile at all, and
|
|
@@ -554,8 +553,8 @@ var PeerCheck = class PeerCheck extends Schema.Class("PeerCheck")({
|
|
|
554
553
|
const rules = options?.peerDependencyRules;
|
|
555
554
|
const policy = {
|
|
556
555
|
allowed: rules?.allowedVersions ?? {},
|
|
557
|
-
ignoreMissing:
|
|
558
|
-
allowAny:
|
|
556
|
+
ignoreMissing: PnpmMatcher.compile(rules?.ignoreMissing ?? []),
|
|
557
|
+
allowAny: PnpmMatcher.compile(rules?.allowAny ?? [])
|
|
559
558
|
};
|
|
560
559
|
const unverified = keySupplied ? [] : ["peerRulesNotApplied"];
|
|
561
560
|
if (!supportsPeerResolution(lockfile.format)) return PeerCheck.make({
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
|
|
8
|
-
Monorepo workspace tooling for [Effect](https://effect.website) v4: find the workspace root, enumerate its packages, walk the dependency graph, detect the package manager, resolve pnpm catalogs, read the lockfile, check it for unsatisfied peer dependencies and work out which packages a git range touches. Every capability is a service you provide at the edge and swap in tests. Works with npm, pnpm,
|
|
8
|
+
Monorepo workspace tooling for [Effect](https://effect.website) v4: find the workspace root, enumerate its packages, walk the dependency graph, detect the package manager, resolve pnpm catalogs, read the lockfile, check it for unsatisfied peer dependencies and work out which packages a git range touches. Every capability is a service you provide at the edge and swap in tests. Works with npm, pnpm and bun. A repository on any other manager still discovers, since its members come from `package.json#workspaces`, but detection reports it as `UnsupportedPackageManagerError` rather than guessing a supported one.
|
|
9
9
|
|
|
10
10
|
> **Pre-`1.0.0`.** This package is part of the `@effected/*` kit, built on stable
|
|
11
11
|
> Effect v4 (`effect` `~4.1.0`) and still in `0.x` development. Stable Effect
|
|
@@ -41,7 +41,7 @@ Requires Node.js >=24.11.0. `effect` v4 is a peer dependency. You provide a `Fil
|
|
|
41
41
|
|
|
42
42
|
All `@effected/*` packages are ESM-only: the exports maps publish only `import` conditions, so `require()` — including tools that resolve in CJS mode — fails with Node's `ERR_PACKAGE_PATH_NOT_EXPORTED` rather than loading a CJS build that does not exist. Import from an ES module.
|
|
43
43
|
|
|
44
|
-
pnpm's catalog semantics
|
|
44
|
+
pnpm's catalog semantics are restated from pnpm 12's own catalog crates in a single internal module; no `@pnpm/*` package is installed.
|
|
45
45
|
|
|
46
46
|
## Quick start
|
|
47
47
|
|
|
@@ -161,36 +161,7 @@ A specifier the workspace cannot answer fails typed as `UnresolvedDependencyErro
|
|
|
161
161
|
|
|
162
162
|
## pnpm settings
|
|
163
163
|
|
|
164
|
-
`PnpmSettings
|
|
165
|
-
|
|
166
|
-
1. a `pnpm_config_<name>` or `PNPM_CONFIG_<NAME>` environment variable (highest);
|
|
167
|
-
2. the workspace root's `pnpm-workspace.yaml`: the one in the directory `PNPM_CONFIG_WORKSPACE_DIR` / `NPM_CONFIG_WORKSPACE_DIR` names, or else the nearest one at or above the real path of `cwd`, when `cwd` belongs to that workspace;
|
|
168
|
-
3. pnpm's global `config.yaml`, in `$XDG_CONFIG_HOME/pnpm`, else `~/Library/Preferences/pnpm` on macOS, `%LOCALAPPDATA%\pnpm\config` on Windows and `~/.config/pnpm` elsewhere (lowest).
|
|
169
|
-
|
|
170
|
-
A higher source replaces a lower one's value whole, so a workspace `minimumReleaseAgeExclude` list replaces the global one rather than adding to it.
|
|
171
|
-
|
|
172
|
-
`cwd` belongs to the workspace, as pnpm decides it, when it is the root, when it holds no project manifest (`package.json`, `package.json5` or `package.yaml`), or when it matches the manifest's `packages:` patterns. A manifest with no `packages:` key has the root as its only member, so an example app or fixture with its own `package.json` inside a single-package repo reads no workspace settings, exactly as pnpm skips them. A misnamed manifest (`pnpm-workspace.yml`, `.pnpm-workspace.yaml`) is not a workspace file, and the ascent passes it, as pnpm 12 does.
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
176
|
-
import { PnpmSettings } from "@effected/workspaces";
|
|
177
|
-
import { Effect, Option } from "effect";
|
|
178
|
-
|
|
179
|
-
const program = Effect.gen(function* () {
|
|
180
|
-
const settings = yield* PnpmSettings.load({ cwd: process.cwd(), env: process.env, platform: process.platform });
|
|
181
|
-
return {
|
|
182
|
-
cutoffMinutes: Option.getOrUndefined(settings.minimumReleaseAge), // number | undefined
|
|
183
|
-
exclude: settings.minimumReleaseAgeExclude, // ReadonlyArray<string>, [] when unset
|
|
184
|
-
strict: settings.getBoolean("minimumReleaseAgeStrict"), // Option<boolean>
|
|
185
|
-
};
|
|
186
|
-
}).pipe(Effect.provide(NodeServices.layer));
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
`get(key)` returns a setting's raw value and `origin(key)` says which source it came from; `getString`, `getNumber`, `getBoolean` and `getStringArray` read it as a type. A key is the camelCase name pnpm writes in YAML or the kebab-case one an npmrc uses, and both name the same setting. An environment value is text, read as the type the accessor asks for: canonical digits for `minimumReleaseAge` (`05`, `+5`, `0x10` and `1e2` do not count), a canonical decimal for `getNumber`, exactly `true` or `false` for a boolean, or a JSON array of strings for a list. One that does not read as that type is skipped, so the next source answers, as pnpm 12 skips it. A comma-separated list is not a list. In a file, a boolean setting also reads the words pnpm 12 coerces (`yes`, `y`, `on`, `no`, `n`, `off`, quoted or not, in any case), and an integer setting a quoted digit string. A file value that still has the wrong type answers `None`, because pnpm 12 refuses to load such a file. A `null` in a file is unset.
|
|
190
|
-
|
|
191
|
-
pnpm 11 and 12 read no pnpm setting from `.npmrc` (only registry and auth keys), from `npm_config_*` variables or from the old global `rc` file, so neither does `PnpmSettings`. For registries and credentials, use `@effected/npm`'s `NpmConfig`. pnpm's built-in defaults are not applied: an unset `minimumReleaseAge` is `None`, which is also what `pnpm config get` reports. Command-line `--config.*` flags are not modelled either. `WorkspaceCatalogs.releaseAgeGate()` is a different question: the gate the workspace file and replayed config-dependency hooks declare, with no environment or global layer.
|
|
192
|
-
|
|
193
|
-
`PnpmSettings.fromSourcesResult({ workspace, global, env })` does the same merge over text you already hold, with no IO. A file that exists but cannot be read, is not YAML, or whose document is not a mapping fails `PnpmSettingsError` (`reason` `"read"`, `"parse"` or `"shape"`). A missing file is skipped.
|
|
164
|
+
`PnpmSettings`, pnpm's effective settings as `pnpm config get` reports them, is in `@effected/pnpm`. `WorkspaceCatalogs.releaseAgeGate()` here answers a different question: the gate the workspace file and replayed config-dependency hooks declare, with no environment or global layer.
|
|
194
165
|
|
|
195
166
|
## Peer dependency checking
|
|
196
167
|
|
|
@@ -227,7 +198,7 @@ const program = Effect.gen(function* () {
|
|
|
227
198
|
|
|
228
199
|
**An empty `unsatisfied` is not the same as clean**, and reading it that way is the mistake this report's shape exists to prevent. Three other fields carry the difference between "nothing is wrong" and "nothing was checked", and a gate must read all four:
|
|
229
200
|
|
|
230
|
-
- `supported` is `false` for
|
|
201
|
+
- `supported` is `false` for a lockfile format that does not record which instance satisfied which peer. The answer is unrecoverable there, so it is not fabricated. Every format `Lockfile.parse` reads records it.
|
|
231
202
|
- `unresolvedImporters` names importers that could not be joined to package instances — in practice the root importer under npm and bun, neither of which records a resolved version per importer dependency.
|
|
232
203
|
- `unverified` says why the report is not a complete answer, and every reason means fail closed:
|
|
233
204
|
- `"peerRulesNotApplied"` — the `peerDependencyRules` key was omitted, so pnpm's suppression policy was not applied.
|
|
@@ -236,7 +207,7 @@ const program = Effect.gen(function* () {
|
|
|
236
207
|
- `"peerVersionUnresolved"` — a peer resolved to a non-workspace provider whose version is a protocol specifier rather than a version: a `file:` directory or tarball, directly or through a `file:` override, which the lockfile records as `file:vendor/x` with no version for a directory, and a git or remote-tarball provider, which pnpm keys by its URL (`https://codeload.github.com/…`). The comparison never runs, so the peer is neither reported nor passed as satisfied; for a `file:` directory `pnpm peers check` reports it as a `bad` row even when the directory's manifest satisfies the range. It applies to peers declared by lockfile rows and by joined manifests alike.
|
|
237
208
|
- `required` is the getter for the rows a gate should act on — the non-optional ones. An unsatisfied *optional* peer is normal, so `optional` travels with the row rather than being filtered out at the source.
|
|
238
209
|
|
|
239
|
-
`WorkspaceCatalogs.peerDependencyRules()` returns the workspace's effective merged pnpm suppression rules, which the lockfile records nowhere; without them a checker reports findings pnpm itself calls clean. **Presence of the `peerDependencyRules` option key is the assertion, not its contents.** Passing `
|
|
210
|
+
`WorkspaceCatalogs.peerDependencyRules()` returns the workspace's effective merged pnpm suppression rules, which the lockfile records nowhere; without them a checker reports findings pnpm itself calls clean. **Presence of the `peerDependencyRules` option key is the assertion, not its contents.** Passing `PeerDependencyRules.empty` (from `@effected/pnpm`) asserts the workspace has none, so the report carries no `"peerRulesNotApplied"` — though it can still be unverified for another reason, or unsupported; omitting the key says nobody looked, and always yields `"peerRulesNotApplied"`. **All three axes of the supplied rules are applied**, with pnpm's measured semantics. `allowedVersions` hides a row whose resolved version a matching key's range permits, in all three key spellings pnpm accepts: `parent@version>peer` (what `pnpm:export` writes; the parent version is ignored, as pnpm ignores it), `parent>peer` (what a config-dependency plugin injects) and a bare `peer`, which pnpm applies to every parent that declares it. `ignoreMissing` hides a required peer nothing resolved for, and `allowAny` hides a peer that resolved outside its range; both are `@pnpm/matcher` patterns over the PEER name (`*` wildcard, leading `!` negates), never `parent>peer` keys, and the two never cross.
|
|
240
211
|
|
|
241
212
|
The `workspacePackages` option takes the packages `WorkspaceDiscovery` already returned, and supplying it is what turns a `link:`-resolved parent from a refusal into an answer: the matched manifest's declared peers join the walk, named from the manifest (`probe-a@1.0.0`, not the row's `packages/a@0.0.0`) and judged against the **importer's own** dependency set, which is where pnpm resolves them from. Measured one variable at a time on the probe workspace, against pnpm 12.5.1 and 12.6.0: a consumer's own `react@18.3.1` satisfies the linked parent's `^18.0.0` peer, the same version installed only by a sibling importer does not, and a consumer's own `react@17.0.2` is a `bad` row carrying `foundVersion`. A target the set does not cover — every target, when the key is omitted — keeps `"unresolvedEdge"`, so the option answers only for what it covers and says so about the rest. A covered target the walk cannot reach — one the lockfile records no workspace row for — keeps the marker too; the root importer's linked targets are walked and judged against the root's own dependencies, as pnpm does.
|
|
242
213
|
|
|
@@ -496,7 +467,7 @@ Both checks are static analysis of literal specifiers — there is no dynamic-im
|
|
|
496
467
|
|
|
497
468
|
### Packed install
|
|
498
469
|
|
|
499
|
-
`PackedInstall.run` packs a carrier and every workspace package it needs, then installs the carrier into a fresh project outside the workspace under each package manager that answers `--version`, and checks every expected bin is linked and executable. It carries the traps each manager sets: the parent run's `npm_*` and `pnpm_config_*` context is scrubbed, pnpm's overrides go in `pnpm-workspace.yaml`,
|
|
470
|
+
`PackedInstall.run` packs a carrier and every workspace package it needs, then installs the carrier into a fresh project outside the workspace under each package manager that answers `--version`, and checks every expected bin is linked and executable. It carries the traps each manager sets: the parent run's `npm_*` and `pnpm_config_*` context is scrubbed, pnpm's overrides go in `pnpm-workspace.yaml`, `packageManager` is pinned to the probed version, and lifecycle scripts are skipped. By default it packs each package's built `dist/prod/npm/pkg`, the artifact a release publishes; build first.
|
|
500
471
|
|
|
501
472
|
It does not run the bins; the test does, inside the same scope, because the scratch directory (`result.scratch`) is removed when the scope closes. `consumer.runBin(name, args, options?)` runs one to completion and returns `{ stdout, stderr, exitCode }`, with no direct `@effected/commands` dependency. `consumer.command(name, args?, options?)` returns the `ChildProcess` command `runBin` builds, same environment and working directory, with stdin left open, so a probe that writes to the bin can spawn it. `consumer.binProvenance(name)` names the package a `.bin` symlink resolves into. `PackedInstall.closure(carrier, options?)` names every package the run will pack before it runs, and `PackedInstall.timeoutBudget` sizes the outer timeout from those names and the run's own ceilings. For an MCP server bin, `McpProbe` from `@effected/mcp-kit/testing` is the proof:
|
|
502
473
|
|
|
@@ -514,7 +485,7 @@ import { Duration, Effect, Layer } from "effect";
|
|
|
514
485
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
515
486
|
const Live = Workspaces.layer({ cwd: ROOT }).pipe(Layer.provideMerge(NodeServices.layer));
|
|
516
487
|
|
|
517
|
-
const MANAGERS = ["npm", "pnpm", "
|
|
488
|
+
const MANAGERS = ["npm", "pnpm", "bun"] as const;
|
|
518
489
|
const INSTALL_TIMEOUT = "2 minutes";
|
|
519
490
|
const PACK_TIMEOUT = "1 minute";
|
|
520
491
|
const BIN_TIMEOUT = "30 seconds";
|
|
@@ -572,7 +543,7 @@ describe("packed install", () => {
|
|
|
572
543
|
|
|
573
544
|
Pass `process.env` in: nothing in the subpath reads `process` itself. `runBin` and `command` run under the environment the install ran under, with `options.env` layered over it after the parent manager's context is stripped, so an explicit entry such as `CI: "true"` wins and a key set to `undefined` removes a variable; a non-zero exit is a result, and a bin that cannot spawn or outlives its ceiling (one minute by default) fails `BinFailed`. `PackedInstall.scrubEnv(...)` returns the same scrubbed environment for any other spawn. A requested manager that is not installed lands in `result.unavailable`; pass `require: "all"` to make that a failure instead. Declare in `consumerDependencies` every package the consumer's own code imports besides the carrier: pnpm links only declared dependencies at a project's top level. An entry that names a packed package is written as its `file:` tarball whatever spec you pass, so any range will do; npm fails `EOVERRIDE` when a direct spec differs from its override.
|
|
574
545
|
|
|
575
|
-
By default only the carrier may declare its bins. If any other packed package declares one of the carrier's bin names, the run fails `BinConflict` before installing: under npm
|
|
546
|
+
By default only the carrier may declare its bins. If any other packed package declares one of the carrier's bin names, the run fails `BinConflict` before installing: under npm's and bun's flat layouts either package can take the `.bin` slot (npm and bun were observed to link the package whose name sorts first), so the bin that runs may carry no carrier identity, and the bin check and every bin run could pass on the wrong package. The check reads the `bin` field of the packed packages only (the carrier, the closure and `overrides`): it does not read `directories.bin`, and a registry dependency declaring the same name goes undetected.
|
|
576
547
|
|
|
577
548
|
Sharing bin names is a supported choice for a carrier whose front ends are also installed on their own: pass `allowSharedBins: true`. The expected bins are still verified present, but `runBin` may then run a front end's bin. `consumer.runCarrierBin(name, args?, options?)` runs the carrier's own bin whichever package took the slot: it resolves `name` through the carrier's installed `package.json` `bin` map and runs that file with `node`, under the same environment as `runBin`. Running through `node` assumes a Node script, drops any shebang flags, and bypasses the executable bit, so it proves the carrier's shim runs, not that it is executable. `consumer.carrierCommand(name, args?, options?)` returns that command, stdin open, for `McpProbe`.
|
|
578
549
|
|
|
@@ -580,7 +551,7 @@ When a closure member needs a dependency the registry does not have yet, for exa
|
|
|
580
551
|
|
|
581
552
|
The installs run one after another. `timeoutBudget` adds each manager's `--version` probe (30 seconds), install (`installTimeout`, four minutes by default) and `perConsumer` (one minute by default, one `runBin` at its default ceiling; add a minute per further bin run, or pass `"0 seconds"` for a test that only installs), each package's pack (`packTimeout`, two minutes by default) and manifest read (30 seconds), 30 seconds for the untimed steps, and one minute for cleanup (removing the scratch root when the scope closes, and killing a child after its ceiling interrupts it); a tighter outer guard fires first, as a `TimeoutError` that names no manager. `packages` is a count or the names `PackedInstall.closure` returns for the run's options: pass the run's own options object as the second argument when it sets `closure`, `overrides` or `workspaceOverrides`, and the names equal `Object.keys(result.tarballs)` in order. `PackedInstall.timeoutBudgetFor(runOptions, { perConsumer? })` does both in one Effect, reading `managers`, `installTimeout` and `packTimeout` from the same object. A vitest test's timeout is fixed when it is declared, so await either at module evaluation, as the example above does.
|
|
582
553
|
|
|
583
|
-
`binProvenance` reads the `.bin` entry as a symlink, which npm
|
|
554
|
+
`binProvenance` reads the `.bin` entry as a symlink, which npm and bun write, realpaths it, and walks up to the nearest `package.json` with a string `name`, inside the (realpath'd) consumer directory. `undefined` means only that the entry exists and is not a symlink, which is a pnpm shim. An entry that does not exist, or a link to nothing, fails `MissingBin`; a link into no named package inside the consumer fails `UnownedBin`; any other read failure fails `Io`. `PackedInstall` is POSIX-only and fails `UnsupportedPlatform` elsewhere.
|
|
584
555
|
|
|
585
556
|
## Error handling
|
|
586
557
|
|
|
@@ -601,7 +572,7 @@ const program = Effect.gen(function* () {
|
|
|
601
572
|
);
|
|
602
573
|
```
|
|
603
574
|
|
|
604
|
-
`WorkspaceRootNotFoundError`, `WorkspaceDiscoveryError`, `WorkspacePatternError`, `PackageNotFoundError`, `WorkspaceManifestError`, `PackageManagerDetectionError`, `CatalogAssemblyError`, `LockfileReadError`, `CyclicDependencyError
|
|
575
|
+
`WorkspaceRootNotFoundError`, `WorkspaceDiscoveryError`, `WorkspacePatternError`, `PackageNotFoundError`, `WorkspaceManifestError`, `PackageManagerDetectionError`, `CatalogAssemblyError`, `LockfileReadError`, `CyclicDependencyError` and `ChangeDetectionError` each name one thing that can actually go wrong, and each method's error channel is narrowed to the ones it can produce. `CatalogAssemblyError` is defined in `@effected/npm`, beside the resolver contract that names it in its channel — import it from there. Change detection additionally surfaces `@effected/git`'s typed git errors, such as `NotARepositoryError`.
|
|
605
576
|
|
|
606
577
|
## Testing
|
|
607
578
|
|
|
@@ -639,12 +610,11 @@ A name miss in the derived `getPackage` fails with the service's own typed `Pack
|
|
|
639
610
|
- `WorkspaceDiscovery` — package enumeration with a bounded descent for segment-crossing `packages/**` patterns, per-package lookup and the `makeTest` / `layerTest` in-memory test doubles.
|
|
640
611
|
- `WorkspacePackage` — a deliberately tolerant manifest model, so one member with an odd version cannot fail discovery for the whole repo. `version` is optional and carried exactly as the manifest has it — absent for the ordinary version-less private root or member, never a `"0.0.0"` placeholder; a `version` that is present but not a string is `invalidShape`. `manifestRecord` keeps the as-read `package.json` for tolerant access to fields outside the typed slice without a second read; `WorkspacePackage.manifest(pkg)` re-reads and is the opt-in bridge to `@effected/package-json`'s strict `Package`.
|
|
641
612
|
- `DependencyGraph` — a value class over discovered packages: `levels()` for parallel build tiers, the flattened topological order, `toMermaid()` for a deterministic Mermaid `flowchart TD` of the whole graph, and `CyclicDependencyError` — naming the cycle's actual members — when there is no order.
|
|
642
|
-
- `PackageManagerDetector` — npm, pnpm
|
|
643
|
-
- `WorkspaceCatalogs` —
|
|
644
|
-
- `PnpmSettings` — pnpm's effective settings as `pnpm config get` resolves them (`PNPM_CONFIG_*` variables, then `pnpm-workspace.yaml`, then the global `config.yaml`), with typed accessors and the `minimumReleaseAge` / `minimumReleaseAgeExclude` pair.
|
|
613
|
+
- `PackageManagerDetector` — npm, pnpm or bun from lockfiles and the `packageManager` field; a yarn repository fails `UnsupportedPackageManagerError`.
|
|
614
|
+
- `WorkspaceCatalogs` — catalog assembly (pnpm's `pnpm-workspace.yaml`, bun's `package.json`, and both managers' lockfiles) and `catalog:` resolution as pnpm 12 resolves it; `releaseAgeGate()` assembles the effective `@effected/pnpm` `ReleaseAgeGate` from inline `pnpm-workspace.yaml` release-age keys and replayed hook contributions, strictest-wins, in the same pass as the catalogs.
|
|
645
615
|
- `LockfileReader` — locate and parse the workspace's lockfile through `@effected/lockfiles`.
|
|
646
616
|
- `PeerCheck` — unsatisfied peer-dependency detection as a pure, total value over a parsed lockfile, with `UnsatisfiedPeer` and `PeerParent` as the report's rows. Read `supported`, `unresolvedImporters` and `unverified` alongside `unsatisfied`: an empty finding list is a clean bill of health only when those three say so.
|
|
647
|
-
- `
|
|
617
|
+
- `PeerDependencyRules` (from `@effected/pnpm`) — the effective pnpm suppression policy `WorkspaceCatalogs.peerDependencyRules()` assembles; `PeerDependencyRules.empty` is the "I assert none apply" value for callers that have checked.
|
|
648
618
|
- `ChangeDetector` — git-range change detection over `@effected/git`'s `Git` service; swap the layer to mock it with no repository.
|
|
649
619
|
- `PublishabilityDetector` — whether a package publishes and to where, as a `PublishTarget` (registry, directory, access, provenance). No composite provides one: pick `PublishabilityDetector.layerNpm` (standard npm semantics) or `.layerNone` (nothing publishes) and provide it explicitly.
|
|
650
620
|
- `ReleaseTag` / `TrackingTag` — release-tag formatting (`ReleaseTag.single` / `.scoped`, strict SemVer by default with no `v` prefix) and the floating major/minor alias derivation GitHub Actions-style consumers expect (`v1`, `v1.2`), plus `classifyTag` to tell a release tag from a tracking alias.
|
package/WorkspaceCatalogs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigDependencyHooks
|
|
1
|
+
import { ConfigDependencyHooks } from "./ConfigDependencyHooks.js";
|
|
2
2
|
import { inlineCatalogs, merge, normalize, rangeOf } from "./internal/catalogs.js";
|
|
3
3
|
import { isStringRecord } from "./internal/guards.js";
|
|
4
4
|
import { importerVersionsOf } from "./internal/importerVersions.js";
|
|
@@ -7,10 +7,11 @@ import { configDependenciesOf, inlinePeerDependencyRules } from "./internal/work
|
|
|
7
7
|
import { LockfileReader } from "./LockfileReader.js";
|
|
8
8
|
import { WorkspaceRoot } from "./WorkspaceRoot.js";
|
|
9
9
|
import { Context, Duration, Effect, Exit, FileSystem, Layer, Option, Path, PlatformError, Predicate, Schema } from "effect";
|
|
10
|
-
import { CatalogAssemblyError, CatalogResolver, DependencyResolutionError
|
|
10
|
+
import { CatalogAssemblyError, CatalogResolver, DependencyResolutionError } from "@effected/npm";
|
|
11
11
|
import { PackageJsonFormat } from "@effected/package-json";
|
|
12
12
|
import { Yaml } from "@effected/yaml";
|
|
13
13
|
import { filenameFor } from "@effected/lockfiles";
|
|
14
|
+
import { PartialReleaseAgeGate, PeerDependencyRules, ReleaseAgeGate } from "@effected/pnpm";
|
|
14
15
|
|
|
15
16
|
// src/WorkspaceCatalogs.ts
|
|
16
17
|
/**
|
|
@@ -106,7 +107,7 @@ entries: Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String
|
|
|
106
107
|
* the default catalog declared twice — once as `workspaces.catalog` and again
|
|
107
108
|
* as `workspaces.catalogs.default` — fails with `CatalogAssemblyError`
|
|
108
109
|
* naming what was wrong. An absent `workspaces` field, one explicitly `null`,
|
|
109
|
-
* or the plain array form (npm
|
|
110
|
+
* or the plain array form (npm patterns, which carry no catalogs) yields
|
|
110
111
|
* the empty set. Presence is checked structurally, so an explicitly-declared
|
|
111
112
|
* empty `catalog: {}` still counts as a declaration.
|
|
112
113
|
*
|
|
@@ -154,7 +155,8 @@ entries: Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String
|
|
|
154
155
|
*/
|
|
155
156
|
rangeOf(dependency, catalog) {
|
|
156
157
|
const name = Option.getOrElse(catalog, () => "default");
|
|
157
|
-
|
|
158
|
+
const entries = Object.hasOwn(this.entries, name) ? this.entries[name] : void 0;
|
|
159
|
+
return entries !== void 0 && Object.hasOwn(entries, dependency) ? Option.fromUndefinedOr(entries[dependency]) : Option.none();
|
|
158
160
|
}
|
|
159
161
|
};
|
|
160
162
|
/** The `catalog` / `catalogs` blocks of a parsed pnpm-workspace document. */
|
|
@@ -170,7 +172,7 @@ const catalogBlocksOf = (document) => {
|
|
|
170
172
|
* The inline release-age gate contribution of a parsed `pnpm-workspace.yaml`
|
|
171
173
|
* document — pnpm's top-level `minimumReleaseAge` (minutes) and
|
|
172
174
|
* `minimumReleaseAgeExclude` (name patterns) keys, mapped onto
|
|
173
|
-
* `@effected/
|
|
175
|
+
* `@effected/pnpm`'s `PartialReleaseAgeGate` field names
|
|
174
176
|
* (`ageMinutes` / `exclude`).
|
|
175
177
|
*
|
|
176
178
|
* @remarks
|
|
@@ -349,7 +351,7 @@ var WorkspaceCatalogs = class WorkspaceCatalogs extends Context.Service()("@effe
|
|
|
349
351
|
let injected;
|
|
350
352
|
let inlineGate = {};
|
|
351
353
|
let hookGate = {};
|
|
352
|
-
let peerDependencyRules =
|
|
354
|
+
let peerDependencyRules = PeerDependencyRules.empty;
|
|
353
355
|
let hookReplays = {};
|
|
354
356
|
if (hasPnpmWorkspace) {
|
|
355
357
|
const text = yield* fs.readFileString(workspaceYaml).pipe(Effect.mapError((cause) => new CatalogAssemblyError({
|
|
@@ -377,7 +379,7 @@ var WorkspaceCatalogs = class WorkspaceCatalogs extends Context.Service()("@effe
|
|
|
377
379
|
catalogs: fromLockfile,
|
|
378
380
|
releaseAgeGate: ReleaseAgeGate.combine(),
|
|
379
381
|
importerVersions,
|
|
380
|
-
peerDependencyRules:
|
|
382
|
+
peerDependencyRules: PeerDependencyRules.empty,
|
|
381
383
|
hookReplays: {}
|
|
382
384
|
};
|
|
383
385
|
const text = yield* fs.readFileString(manifestPath).pipe(Effect.mapError((cause) => new CatalogAssemblyError({
|
package/WorkspacePackage.js
CHANGED
|
@@ -33,7 +33,13 @@ var PublishConfig = class extends Schema.Class("PublishConfig")({
|
|
|
33
33
|
*/
|
|
34
34
|
linkDirectory: Schema.optionalKey(Schema.Boolean),
|
|
35
35
|
/** The dist-tag to publish under. */
|
|
36
|
-
tag: Schema.optionalKey(Schema.String)
|
|
36
|
+
tag: Schema.optionalKey(Schema.String),
|
|
37
|
+
/**
|
|
38
|
+
* The name the package publishes under when it differs from its manifest
|
|
39
|
+
* `name`. An empty string is no rename, as pnpm's `published_name` reads it,
|
|
40
|
+
* so a reader of the registry name takes `name` only when it is non-empty.
|
|
41
|
+
*/
|
|
42
|
+
name: Schema.optionalKey(Schema.String)
|
|
37
43
|
}) {};
|
|
38
44
|
const DependencyMap = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed(EMPTY)), Schema.withConstructorDefault(Effect.succeed(EMPTY)));
|
|
39
45
|
/**
|
|
@@ -4,6 +4,8 @@ import { Effect, Exit, Layer, Option, Schema, SchemaTransformation } from "effec
|
|
|
4
4
|
import { CatalogResolver, DependencyResolutionError, DependencySpecifier, WorkspaceResolver } from "@effected/npm";
|
|
5
5
|
|
|
6
6
|
// src/WorkspaceStateSnapshot.ts
|
|
7
|
+
/** `record[key]` when `key` is the record's own property; never an inherited member. */
|
|
8
|
+
const ownValue = (record, key) => record !== void 0 && Object.hasOwn(record, key) ? record[key] : void 0;
|
|
7
9
|
const EMPTY = Object.freeze(Object.create(null));
|
|
8
10
|
const DependencyMap = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed(EMPTY)), Schema.withConstructorDefault(Effect.succeed(EMPTY)));
|
|
9
11
|
/**
|
|
@@ -263,7 +265,7 @@ var WorkspaceStateSnapshot = class WorkspaceStateSnapshot extends Schema.Class("
|
|
|
263
265
|
* @param specifier - The raw specifier string.
|
|
264
266
|
*/
|
|
265
267
|
resolveIn(importerPath, dependency, specifier) {
|
|
266
|
-
return this.#resolveWith(dependency, specifier, () => Option.fromUndefinedOr(this.importerVersions
|
|
268
|
+
return this.#resolveWith(dependency, specifier, () => Option.fromUndefinedOr(ownValue(ownValue(this.importerVersions, importerPath), dependency)));
|
|
267
269
|
}
|
|
268
270
|
/**
|
|
269
271
|
* The shared resolution path: classify, answer from the captured state, and
|