@effected/workspaces 0.12.0 → 0.13.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.
@@ -293,7 +293,10 @@ var ConfigDependencyHooks = class ConfigDependencyHooks extends Context.Service(
293
293
  const candidatePath = join(root, "node_modules", ".pnpm-config", name, filename);
294
294
  const candidateUrl = pathToFileURL(candidatePath).href;
295
295
  const result = yield* Effect.result(Effect.tryPromise({
296
- try: () => import(candidateUrl),
296
+ try: () => import(
297
+ /* webpackIgnore: true */
298
+ candidateUrl
299
+ ),
297
300
  catch: (cause) => cause
298
301
  }));
299
302
  if (Result.isSuccess(result)) {
@@ -15,6 +15,35 @@ const PackageManagerName = Schema.Literals([
15
15
  "bun"
16
16
  ]);
17
17
  /**
18
+ * The markers {@link PackageManagerDetector} probes, in the priority order it
19
+ * probes them.
20
+ *
21
+ * @remarks
22
+ * One vocabulary serves both halves of the detection contract: the failure path
23
+ * reports every member as `PackageManagerDetectionError.checked`, and the
24
+ * success path reports the one that fired as
25
+ * `DetectedPackageManager.evidence`. A closed literal union rather than
26
+ * free text, so a consumer logging *why* a workspace was classified asserts
27
+ * against the kit's vocabulary instead of re-deriving the probe with its own
28
+ * filesystem reads.
29
+ *
30
+ * The `package.json#…` spellings name manifest *fields*; the rest are marker
31
+ * files at the workspace root.
32
+ *
33
+ * @public
34
+ */
35
+ const PackageManagerEvidence = Schema.Literals([
36
+ "pnpm-workspace.yaml",
37
+ "bun.lock",
38
+ "bun.lockb",
39
+ "yarn.lock",
40
+ "package.json#workspaces",
41
+ "pnpm-lock.yaml",
42
+ "package-lock.json",
43
+ "package.json#devEngines.packageManager",
44
+ "package.json#packageManager"
45
+ ]);
46
+ /**
18
47
  * The outcome of package-manager detection at a workspace root.
19
48
  *
20
49
  * @remarks
@@ -25,6 +54,15 @@ const PackageManagerName = Schema.Literals([
25
54
  * `devEngines.packageManager`; see {@link PackageManagerDetector} for the
26
55
  * precedence between them.
27
56
  *
57
+ * `evidence` is the rung of the priority order that decided the **name** — the
58
+ * verdict's provenance, in the same vocabulary the failure path reports as
59
+ * `PackageManagerDetectionError.checked`. For the bun and yarn rungs the
60
+ * lockfile is the recorded signal even though the rung is a conjunction (the
61
+ * lockfile *plus* a manifest field naming the manager): the manifest field alone
62
+ * would have resolved in the declaration tier, so the lockfile is what this rung
63
+ * added. The version's provenance is deliberately not carried — it follows the
64
+ * two-field precedence above, which is a rule, not a probe.
65
+ *
28
66
  * @public
29
67
  */
30
68
  var DetectedPackageManager = class extends Schema.Class("DetectedPackageManager")({
@@ -33,7 +71,9 @@ var DetectedPackageManager = class extends Schema.Class("DetectedPackageManager"
33
71
  /** Its version, when a manifest field agrees on the manager and carries one. */
34
72
  version: Schema.Option(Schema.String),
35
73
  /** The JavaScript runtime the manager implies. */
36
- runtime: Schema.Literals(["node", "bun"])
74
+ runtime: Schema.Literals(["node", "bun"]),
75
+ /** The rung of the priority order that decided the name. */
76
+ evidence: PackageManagerEvidence
37
77
  }) {};
38
78
  /** Whether `value` is a non-null, non-array object — corepack's own shape test. */
39
79
  const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -97,18 +137,11 @@ var PackageManagerDetectionError = class extends Schema.TaggedError()("PackageMa
97
137
  return `No package manager detected at ${this.root} (checked ${this.checked.join(", ")})`;
98
138
  }
99
139
  };
100
- /** The markers probed, in priority order. Exposed on the error so the contract is not prose-only. */
101
- const CHECKED = [
102
- "pnpm-workspace.yaml",
103
- "bun.lock",
104
- "bun.lockb",
105
- "yarn.lock",
106
- "package.json#workspaces",
107
- "pnpm-lock.yaml",
108
- "package-lock.json",
109
- "package.json#packageManager",
110
- "package.json#devEngines.packageManager"
111
- ];
140
+ /**
141
+ * The markers probed, in priority order. Derived from the evidence vocabulary so
142
+ * the failure path's `checked` and the success path's `evidence` cannot drift.
143
+ */
144
+ const CHECKED = PackageManagerEvidence.literals;
112
145
  /**
113
146
  * Detects which package manager owns a workspace root.
114
147
  *
@@ -219,44 +252,52 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
219
252
  if (yield* has(root, "pnpm-workspace.yaml")) return DetectedPackageManager.make({
220
253
  name: "pnpm",
221
254
  version: versionFor(hints, "pnpm"),
222
- runtime: "node"
255
+ runtime: "node",
256
+ evidence: "pnpm-workspace.yaml"
223
257
  });
224
- const bunLock = (yield* has(root, "bun.lock")) || (yield* has(root, "bun.lockb"));
225
- if (bunLock && namesManager(hints, "bun")) return DetectedPackageManager.make({
258
+ const bunLock = (yield* has(root, "bun.lock")) ? Option.some("bun.lock") : (yield* has(root, "bun.lockb")) ? Option.some("bun.lockb") : Option.none();
259
+ if (Option.isSome(bunLock) && namesManager(hints, "bun")) return DetectedPackageManager.make({
226
260
  name: "bun",
227
261
  version: versionFor(hints, "bun"),
228
- runtime: "bun"
262
+ runtime: "bun",
263
+ evidence: bunLock.value
229
264
  });
230
265
  if ((yield* has(root, "yarn.lock")) && namesManager(hints, "yarn")) return DetectedPackageManager.make({
231
266
  name: "yarn",
232
267
  version: versionFor(hints, "yarn"),
233
- runtime: "node"
268
+ runtime: "node",
269
+ evidence: "yarn.lock"
234
270
  });
235
271
  const workspaces = Option.map(manifest, (fields) => fields.workspaces);
236
272
  if (Option.isSome(workspaces) && workspaces.value !== void 0 && workspaces.value !== null) return DetectedPackageManager.make({
237
273
  name: "npm",
238
274
  version: versionFor(hints, "npm"),
239
- runtime: "node"
275
+ runtime: "node",
276
+ evidence: "package.json#workspaces"
240
277
  });
241
278
  if (yield* has(root, "pnpm-lock.yaml")) return DetectedPackageManager.make({
242
279
  name: "pnpm",
243
280
  version: versionFor(hints, "pnpm"),
244
- runtime: "node"
281
+ runtime: "node",
282
+ evidence: "pnpm-lock.yaml"
245
283
  });
246
- if (bunLock && namesManager(hints, "bun")) return DetectedPackageManager.make({
284
+ if (Option.isSome(bunLock) && namesManager(hints, "bun")) return DetectedPackageManager.make({
247
285
  name: "bun",
248
286
  version: versionFor(hints, "bun"),
249
- runtime: "bun"
287
+ runtime: "bun",
288
+ evidence: bunLock.value
250
289
  });
251
290
  if ((yield* has(root, "yarn.lock")) && namesManager(hints, "yarn")) return DetectedPackageManager.make({
252
291
  name: "yarn",
253
292
  version: versionFor(hints, "yarn"),
254
- runtime: "node"
293
+ runtime: "node",
294
+ evidence: "yarn.lock"
255
295
  });
256
296
  if (yield* has(root, "package-lock.json")) return DetectedPackageManager.make({
257
297
  name: "npm",
258
298
  version: versionFor(hints, "npm"),
259
- runtime: "node"
299
+ runtime: "node",
300
+ evidence: "package-lock.json"
260
301
  });
261
302
  const declared = declaredName(hints);
262
303
  if (Option.isSome(declared)) {
@@ -264,7 +305,8 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
264
305
  if (name === "pnpm" || name === "npm" || name === "yarn" || name === "bun") return DetectedPackageManager.make({
265
306
  name,
266
307
  version: versionFor(hints, name),
267
- runtime: name === "bun" ? "bun" : "node"
308
+ runtime: name === "bun" ? "bun" : "node",
309
+ evidence: Option.isSome(hints.devEngines) ? "package.json#devEngines.packageManager" : "package.json#packageManager"
268
310
  });
269
311
  }
270
312
  return yield* Effect.fail(new PackageManagerDetectionError({
@@ -307,7 +349,12 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
307
349
  * const TestDetector = PackageManagerDetector.layerTest({
308
350
  * detect: () =>
309
351
  * Effect.succeed(
310
- * DetectedPackageManager.make({ name: "pnpm", version: Option.none(), runtime: "node" }),
352
+ * DetectedPackageManager.make({
353
+ * name: "pnpm",
354
+ * version: Option.none(),
355
+ * runtime: "node",
356
+ * evidence: "pnpm-workspace.yaml",
357
+ * }),
311
358
  * ),
312
359
  * });
313
360
  * ```
@@ -331,4 +378,4 @@ var PackageManagerDetector = class PackageManagerDetector extends Context.Servic
331
378
  };
332
379
 
333
380
  //#endregion
334
- export { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerName };
381
+ export { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerEvidence, PackageManagerName };
package/index.d.ts CHANGED
@@ -1069,6 +1069,32 @@ declare const PackageManagerName: Schema.Literals<readonly ["npm", "pnpm", "yarn
1069
1069
  * @public
1070
1070
  */
1071
1071
  type PackageManagerName = typeof PackageManagerName.Type;
1072
+ /**
1073
+ * The markers {@link PackageManagerDetector} probes, in the priority order it
1074
+ * probes them.
1075
+ *
1076
+ * @remarks
1077
+ * One vocabulary serves both halves of the detection contract: the failure path
1078
+ * reports every member as `PackageManagerDetectionError.checked`, and the
1079
+ * success path reports the one that fired as
1080
+ * `DetectedPackageManager.evidence`. A closed literal union rather than
1081
+ * free text, so a consumer logging *why* a workspace was classified asserts
1082
+ * against the kit's vocabulary instead of re-deriving the probe with its own
1083
+ * filesystem reads.
1084
+ *
1085
+ * The `package.json#…` spellings name manifest *fields*; the rest are marker
1086
+ * files at the workspace root.
1087
+ *
1088
+ * @public
1089
+ */
1090
+ declare const PackageManagerEvidence: Schema.Literals<readonly ["pnpm-workspace.yaml", "bun.lock", "bun.lockb", "yarn.lock", "package.json#workspaces", "pnpm-lock.yaml", "package-lock.json", "package.json#devEngines.packageManager", "package.json#packageManager"]>;
1091
+ /**
1092
+ * The decoded type of {@link (PackageManagerEvidence:variable)}: the marker
1093
+ * that decided a detection.
1094
+ *
1095
+ * @public
1096
+ */
1097
+ type PackageManagerEvidence = typeof PackageManagerEvidence.Type;
1072
1098
  declare const DetectedPackageManager_base: Schema.Class<DetectedPackageManager, Schema.Struct<{
1073
1099
  /** The detected manager. */
1074
1100
  readonly name: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun"]>;
@@ -1076,6 +1102,8 @@ declare const DetectedPackageManager_base: Schema.Class<DetectedPackageManager,
1076
1102
  readonly version: Schema.Option<Schema.String>;
1077
1103
  /** The JavaScript runtime the manager implies. */
1078
1104
  readonly runtime: Schema.Literals<readonly ["node", "bun"]>;
1105
+ /** The rung of the priority order that decided the name. */
1106
+ readonly evidence: Schema.Literals<readonly ["pnpm-workspace.yaml", "bun.lock", "bun.lockb", "yarn.lock", "package.json#workspaces", "pnpm-lock.yaml", "package-lock.json", "package.json#devEngines.packageManager", "package.json#packageManager"]>;
1079
1107
  }>, {}>;
1080
1108
  /**
1081
1109
  * The outcome of package-manager detection at a workspace root.
@@ -1088,6 +1116,15 @@ declare const DetectedPackageManager_base: Schema.Class<DetectedPackageManager,
1088
1116
  * `devEngines.packageManager`; see {@link PackageManagerDetector} for the
1089
1117
  * precedence between them.
1090
1118
  *
1119
+ * `evidence` is the rung of the priority order that decided the **name** — the
1120
+ * verdict's provenance, in the same vocabulary the failure path reports as
1121
+ * `PackageManagerDetectionError.checked`. For the bun and yarn rungs the
1122
+ * lockfile is the recorded signal even though the rung is a conjunction (the
1123
+ * lockfile *plus* a manifest field naming the manager): the manifest field alone
1124
+ * would have resolved in the declaration tier, so the lockfile is what this rung
1125
+ * added. The version's provenance is deliberately not carried — it follows the
1126
+ * two-field precedence above, which is a rule, not a probe.
1127
+ *
1091
1128
  * @public
1092
1129
  */
1093
1130
  declare class DetectedPackageManager extends DetectedPackageManager_base {}
@@ -1209,7 +1246,12 @@ declare class PackageManagerDetector extends PackageManagerDetector_base {
1209
1246
  * const TestDetector = PackageManagerDetector.layerTest({
1210
1247
  * detect: () =>
1211
1248
  * Effect.succeed(
1212
- * DetectedPackageManager.make({ name: "pnpm", version: Option.none(), runtime: "node" }),
1249
+ * DetectedPackageManager.make({
1250
+ * name: "pnpm",
1251
+ * version: Option.none(),
1252
+ * runtime: "node",
1253
+ * evidence: "pnpm-workspace.yaml",
1254
+ * }),
1213
1255
  * ),
1214
1256
  * });
1215
1257
  * ```
@@ -3030,5 +3072,5 @@ interface GetWorkspacePackagesSyncOptions extends WorkspacesSyncOptions {
3030
3072
  */
3031
3073
  declare const getWorkspacePackagesSync: (root: string, options: GetWorkspacePackagesSyncOptions) => ReadonlyArray<WorkspacePackage>;
3032
3074
  //#endregion
3033
- export { type CatalogAssemblyFailure, CatalogSet, ChangeDetectionError, type ChangeDetectionFailure, ChangeDetectionOptions, ChangeDetector, type ChangeDetectorShape, type ClassifyOptions, ConfigDependencyHooks, type ConfigDependencyHooksShape, CyclicDependencyError, type DependencyDiff, DependencyGraph, DetectedPackageManager, type FindWorkspaceRootOptions, type GetWorkspacePackagesSyncOptions, type HookInjection, type ImporterVersions, LockfileReadError, type LockfileReadFailure, LockfileReader, type LockfileReaderOptions, type LockfileReaderShape, PackageManagerDetectionError, type PackageManagerDetectionFailure, PackageManagerDetector, type PackageManagerDetectorShape, PackageManagerName, PackageNotFoundError, type PackageRelease, PackageStateSnapshot, PublishConfig, PublishTarget, PublishabilityDetector, type PublishabilityDetectorShape, ReleaseTag, type SyncFileSystem, type SyncPath, type TagClassification, type TagFormatOptions, TagStyle, TrackingTag, type TrackingTagOptions, type VersioningDetectOptions, VersioningStrategy, VersioningStrategyType, WORKSPACE_MARKERS, WorkspaceCatalogs, type WorkspaceCatalogsOptions, type WorkspaceCatalogsShape, WorkspaceDiscovery, WorkspaceDiscoveryError, type WorkspaceDiscoveryFailure, type WorkspaceDiscoveryOptions, type WorkspaceDiscoveryShape, WorkspaceInfo, type WorkspaceLookupFailure, WorkspaceManifestError, WorkspacePackage, WorkspacePatternError, WorkspaceRoot, WorkspaceRootNotFoundError, type WorkspaceRootShape, type WorkspaceSnapshotAtFailure, type WorkspaceSnapshotWorktreeFailure, WorkspaceSnapshots, type WorkspaceSnapshotsOptions, type WorkspaceSnapshotsShape, WorkspaceStateSnapshot, Workspaces, type WorkspacesOptions, type WorkspacesServices, type WorkspacesSyncOptions, classifyTag, findWorkspaceRootSync, getWorkspacePackagesSync };
3075
+ export { type CatalogAssemblyFailure, CatalogSet, ChangeDetectionError, type ChangeDetectionFailure, ChangeDetectionOptions, ChangeDetector, type ChangeDetectorShape, type ClassifyOptions, ConfigDependencyHooks, type ConfigDependencyHooksShape, CyclicDependencyError, type DependencyDiff, DependencyGraph, DetectedPackageManager, type FindWorkspaceRootOptions, type GetWorkspacePackagesSyncOptions, type HookInjection, type ImporterVersions, LockfileReadError, type LockfileReadFailure, LockfileReader, type LockfileReaderOptions, type LockfileReaderShape, PackageManagerDetectionError, type PackageManagerDetectionFailure, PackageManagerDetector, type PackageManagerDetectorShape, PackageManagerEvidence, PackageManagerName, PackageNotFoundError, type PackageRelease, PackageStateSnapshot, PublishConfig, PublishTarget, PublishabilityDetector, type PublishabilityDetectorShape, ReleaseTag, type SyncFileSystem, type SyncPath, type TagClassification, type TagFormatOptions, TagStyle, TrackingTag, type TrackingTagOptions, type VersioningDetectOptions, VersioningStrategy, VersioningStrategyType, WORKSPACE_MARKERS, WorkspaceCatalogs, type WorkspaceCatalogsOptions, type WorkspaceCatalogsShape, WorkspaceDiscovery, WorkspaceDiscoveryError, type WorkspaceDiscoveryFailure, type WorkspaceDiscoveryOptions, type WorkspaceDiscoveryShape, WorkspaceInfo, type WorkspaceLookupFailure, WorkspaceManifestError, WorkspacePackage, WorkspacePatternError, WorkspaceRoot, WorkspaceRootNotFoundError, type WorkspaceRootShape, type WorkspaceSnapshotAtFailure, type WorkspaceSnapshotWorktreeFailure, WorkspaceSnapshots, type WorkspaceSnapshotsOptions, type WorkspaceSnapshotsShape, WorkspaceStateSnapshot, Workspaces, type WorkspacesOptions, type WorkspacesServices, type WorkspacesSyncOptions, classifyTag, findWorkspaceRootSync, getWorkspacePackagesSync };
3034
3076
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -4,7 +4,7 @@ import { PackageNotFoundError, WorkspaceDiscovery, WorkspaceDiscoveryError, Work
4
4
  import { CyclicDependencyError, DependencyGraph } from "./DependencyGraph.js";
5
5
  import { ChangeDetectionError, ChangeDetectionOptions, ChangeDetector } from "./ChangeDetector.js";
6
6
  import { ConfigDependencyHooks } from "./ConfigDependencyHooks.js";
7
- import { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerName } from "./PackageManagerName.js";
7
+ import { DetectedPackageManager, PackageManagerDetectionError, PackageManagerDetector, PackageManagerEvidence, PackageManagerName } from "./PackageManagerName.js";
8
8
  import { LockfileReadError, LockfileReader } from "./LockfileReader.js";
9
9
  import { PublishTarget, PublishabilityDetector } from "./Publishability.js";
10
10
  import { ReleaseTag, TagStyle, TrackingTag, classifyTag } from "./ReleaseTag.js";
@@ -15,4 +15,4 @@ import { WorkspaceSnapshots } from "./WorkspaceSnapshots.js";
15
15
  import { Workspaces } from "./Workspaces.js";
16
16
  import { findWorkspaceRootSync, getWorkspacePackagesSync } from "./WorkspacesSync.js";
17
17
 
18
- export { CatalogSet, ChangeDetectionError, ChangeDetectionOptions, ChangeDetector, ConfigDependencyHooks, CyclicDependencyError, DependencyGraph, DetectedPackageManager, LockfileReadError, LockfileReader, PackageManagerDetectionError, PackageManagerDetector, PackageManagerName, PackageNotFoundError, PackageStateSnapshot, PublishConfig, PublishTarget, PublishabilityDetector, ReleaseTag, TagStyle, TrackingTag, VersioningStrategy, VersioningStrategyType, WORKSPACE_MARKERS, WorkspaceCatalogs, WorkspaceDiscovery, WorkspaceDiscoveryError, WorkspaceInfo, WorkspaceManifestError, WorkspacePackage, WorkspacePatternError, WorkspaceRoot, WorkspaceRootNotFoundError, WorkspaceSnapshots, WorkspaceStateSnapshot, Workspaces, classifyTag, findWorkspaceRootSync, getWorkspacePackagesSync };
18
+ export { CatalogSet, ChangeDetectionError, ChangeDetectionOptions, ChangeDetector, ConfigDependencyHooks, CyclicDependencyError, DependencyGraph, DetectedPackageManager, LockfileReadError, LockfileReader, PackageManagerDetectionError, PackageManagerDetector, PackageManagerEvidence, PackageManagerName, PackageNotFoundError, PackageStateSnapshot, PublishConfig, PublishTarget, PublishabilityDetector, ReleaseTag, TagStyle, TrackingTag, VersioningStrategy, VersioningStrategyType, WORKSPACE_MARKERS, WorkspaceCatalogs, WorkspaceDiscovery, WorkspaceDiscoveryError, WorkspaceInfo, WorkspaceManifestError, WorkspacePackage, WorkspacePatternError, WorkspaceRoot, WorkspaceRootNotFoundError, WorkspaceSnapshots, WorkspaceStateSnapshot, Workspaces, classifyTag, findWorkspaceRootSync, getWorkspacePackagesSync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/workspaces",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Monorepo workspace tooling as Effect services — root discovery, package enumeration, the dependency graph, package-manager detection, pnpm catalog resolution, lockfile IO and git-based change detection.",
6
6
  "keywords": [
@@ -47,11 +47,11 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@effected/commands": "^0.4.0",
50
- "@effected/git": "^0.7.0",
50
+ "@effected/git": "^0.8.0",
51
51
  "@effected/glob": "^0.3.0",
52
52
  "@effected/lockfiles": "^0.4.1",
53
53
  "@effected/npm": "^0.9.0",
54
- "@effected/package-json": "^0.8.0",
54
+ "@effected/package-json": "^0.9.0",
55
55
  "@effected/semver": "^0.4.0",
56
56
  "@effected/walker": "^0.4.0",
57
57
  "@effected/yaml": "^0.8.0",