@effected/workspaces 0.9.4 → 0.9.6
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/WorkspaceDiscovery.js +20 -2
- package/package.json +5 -5
package/WorkspaceDiscovery.js
CHANGED
|
@@ -259,6 +259,15 @@ var WorkspaceDiscovery = class WorkspaceDiscovery extends Context.Service()("@ef
|
|
|
259
259
|
for (const entry of index) if (filePath.startsWith(entry.prefix)) return Option.some(entry.package);
|
|
260
260
|
return Option.none();
|
|
261
261
|
};
|
|
262
|
+
const packageIndexes = /* @__PURE__ */ new WeakMap();
|
|
263
|
+
const packagesByName = (all) => {
|
|
264
|
+
const cached = packageIndexes.get(all);
|
|
265
|
+
if (cached !== void 0) return cached;
|
|
266
|
+
const index = /* @__PURE__ */ new Map();
|
|
267
|
+
for (const pkg of all) if (!index.has(pkg.name)) index.set(pkg.name, pkg);
|
|
268
|
+
packageIndexes.set(all, index);
|
|
269
|
+
return index;
|
|
270
|
+
};
|
|
262
271
|
return {
|
|
263
272
|
info: Effect.fn("WorkspaceDiscovery.info")(function* () {
|
|
264
273
|
return (yield* memo).info;
|
|
@@ -272,7 +281,7 @@ var WorkspaceDiscovery = class WorkspaceDiscovery extends Context.Service()("@ef
|
|
|
272
281
|
}),
|
|
273
282
|
getPackage: Effect.fn("WorkspaceDiscovery.getPackage")(function* (name) {
|
|
274
283
|
const all = yield* packages;
|
|
275
|
-
const found = all.
|
|
284
|
+
const found = packagesByName(all).get(name);
|
|
276
285
|
if (found !== void 0) return found;
|
|
277
286
|
return yield* Effect.fail(new PackageNotFoundError({
|
|
278
287
|
name,
|
|
@@ -436,7 +445,16 @@ var WorkspaceDiscovery = class WorkspaceDiscovery extends Context.Service()("@ef
|
|
|
436
445
|
*/
|
|
437
446
|
static workspaceResolver = Layer.effect(WorkspaceResolver, Effect.gen(function* () {
|
|
438
447
|
const discovery = yield* WorkspaceDiscovery;
|
|
439
|
-
|
|
448
|
+
const versionIndexes = /* @__PURE__ */ new WeakMap();
|
|
449
|
+
const versionsByName = (all) => {
|
|
450
|
+
const cached = versionIndexes.get(all);
|
|
451
|
+
if (cached !== void 0) return cached;
|
|
452
|
+
const index = /* @__PURE__ */ new Map();
|
|
453
|
+
for (const pkg of all) if (!index.has(pkg.name)) index.set(pkg.name, pkg.version);
|
|
454
|
+
versionIndexes.set(all, index);
|
|
455
|
+
return index;
|
|
456
|
+
};
|
|
457
|
+
return { versionOf: (packageName) => discovery.listPackages().pipe(Effect.map((all) => Option.fromUndefinedOr(versionsByName(all).get(packageName))), Effect.mapError((cause) => new DependencyResolutionError({
|
|
440
458
|
specifier: `workspace:${packageName}`,
|
|
441
459
|
cause
|
|
442
460
|
}))) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/workspaces",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
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": [
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"@effected/commands": "^0.2.1",
|
|
50
50
|
"@effected/git": "^0.5.2",
|
|
51
51
|
"@effected/glob": "^0.2.2",
|
|
52
|
-
"@effected/lockfiles": "^0.3.
|
|
53
|
-
"@effected/npm": "^0.8.
|
|
54
|
-
"@effected/package-json": "^0.7.
|
|
55
|
-
"@effected/semver": "^0.3.
|
|
52
|
+
"@effected/lockfiles": "^0.3.2",
|
|
53
|
+
"@effected/npm": "^0.8.2",
|
|
54
|
+
"@effected/package-json": "^0.7.3",
|
|
55
|
+
"@effected/semver": "^0.3.2",
|
|
56
56
|
"@effected/walker": "^0.3.4",
|
|
57
57
|
"@effected/yaml": "^0.6.1",
|
|
58
58
|
"@pnpm/catalogs.config": "^1100.0.0",
|