diff --git a/packages/core/test/generate.test.ts b/packages/core/test/generate.test.ts index 68d56235a00..b36d9c53031 100644 --- a/packages/core/test/generate.test.ts +++ b/packages/core/test/generate.test.ts @@ -55,7 +55,6 @@ const integrations = Layer.mock(Integration.Service, { }) const npm = Layer.mock(Npm.Service, { add: () => Effect.die("unused"), - install: () => Effect.die("unused"), which: () => Effect.die("unused"), }) const aisdk = Layer.mock(AISDK.Service, { diff --git a/packages/core/test/plugin/fixture.ts b/packages/core/test/plugin/fixture.ts index e51df1a3589..ba7c33d515e 100644 --- a/packages/core/test/plugin/fixture.ts +++ b/packages/core/test/plugin/fixture.ts @@ -29,7 +29,6 @@ const npmLayer = Layer.succeed( Npm.Service, Npm.Service.of({ add: () => Effect.succeed({ directory: "", entrypoint: undefined }), - install: () => Effect.void, which: () => Effect.succeed(undefined), }), ) diff --git a/packages/core/test/plugin/provider-dynamic.test.ts b/packages/core/test/plugin/provider-dynamic.test.ts index 437c64bbf4d..d8949fd7d05 100644 --- a/packages/core/test/plugin/provider-dynamic.test.ts +++ b/packages/core/test/plugin/provider-dynamic.test.ts @@ -23,7 +23,6 @@ const itWithAISDK = testEffect(Layer.mergeAll(PluginTestLayer, AppNodeBuilder.bu function npmEntrypoint(entrypoint?: string) { return Npm.Service.of({ add: () => Effect.succeed({ directory: "", entrypoint }), - install: () => Effect.void, which: () => Effect.succeed(undefined), }) } diff --git a/packages/core/test/plugin/provider-sap-ai-core.test.ts b/packages/core/test/plugin/provider-sap-ai-core.test.ts index 5524c93af05..3ce68ad8268 100644 --- a/packages/core/test/plugin/provider-sap-ai-core.test.ts +++ b/packages/core/test/plugin/provider-sap-ai-core.test.ts @@ -14,7 +14,6 @@ const fixtureProvider = new URL("./fixtures/provider-factory.ts", import.meta.ur const it = testEffect(PluginTestLayer) const npm = Npm.Service.of({ add: () => Effect.succeed({ directory: "", entrypoint: undefined }), - install: () => Effect.void, which: () => Effect.succeed(undefined), }) diff --git a/packages/util/src/npm.ts b/packages/util/src/npm.ts index 28b05a4bbf1..e2722f33bbc 100644 --- a/packages/util/src/npm.ts +++ b/packages/util/src/npm.ts @@ -30,15 +30,6 @@ export interface Interface { pkg: string, options?: { readonly subpaths?: readonly string[] }, ) => Effect.Effect - readonly install: ( - dir: string, - input?: { - add: { - name: string - version?: string - }[] - }, - ) => Effect.Effect readonly which: (pkg: string, bin?: string) => Effect.Effect } @@ -143,59 +134,6 @@ const layer = Layer.effect( return resolveEntryPoint(first.name, first.path, options?.subpaths) }, Effect.scoped) - const install: Interface["install"] = Effect.fn("Npm.install")(function* (dir, input) { - const canWrite = yield* afs.access(dir, { writable: true }).pipe( - Effect.as(true), - Effect.orElseSucceed(() => false), - ) - if (!canWrite) return - - const add = input?.add.map((pkg) => [pkg.name, pkg.version].filter(Boolean).join("@")) ?? [] - if ( - yield* Effect.gen(function* () { - const nodeModulesExists = yield* afs.existsSafe(path.join(dir, "node_modules")) - if (!nodeModulesExists) { - yield* reify({ add, dir }) - return true - } - return false - }).pipe(Effect.withSpan("Npm.checkNodeModules")) - ) - return - - yield* Effect.gen(function* () { - const pkg = yield* afs.readJson(path.join(dir, "package.json")).pipe(Effect.orElseSucceed(() => ({}))) - const lock = yield* afs.readJson(path.join(dir, "package-lock.json")).pipe(Effect.orElseSucceed(() => ({}))) - - const pkgAny = pkg as any - const lockAny = lock as any - const declared = new Set([ - ...Object.keys(pkgAny?.dependencies || {}), - ...Object.keys(pkgAny?.devDependencies || {}), - ...Object.keys(pkgAny?.peerDependencies || {}), - ...Object.keys(pkgAny?.optionalDependencies || {}), - ...(input?.add || []).map((pkg) => pkg.name), - ]) - - const root = lockAny?.packages?.[""] || {} - const locked = new Set([ - ...Object.keys(root?.dependencies || {}), - ...Object.keys(root?.devDependencies || {}), - ...Object.keys(root?.peerDependencies || {}), - ...Object.keys(root?.optionalDependencies || {}), - ]) - - for (const name of declared) { - if (!locked.has(name)) { - yield* reify({ dir, add }) - return - } - } - }).pipe(Effect.withSpan("Npm.checkDirty")) - - return - }, Effect.scoped) - const which = Effect.fn("Npm.which")(function* (pkg: string, bin?: string) { const dir = directory(pkg) const binDir = path.join(dir, "node_modules", ".bin") @@ -249,7 +187,6 @@ const layer = Layer.effect( return Service.of({ add, - install, which, }) }), @@ -263,10 +200,6 @@ export const node = makeGlobalNode({ const { runPromise } = makeRuntime(Service, LayerNode.compile(node)) -export async function install(...args: Parameters) { - return runPromise((svc) => svc.install(...args)) -} - export async function add(...args: Parameters) { return runPromise((svc) => svc.add(...args)) }