chore: generate
This commit is contained in:
@@ -136,7 +136,9 @@ export const layer: Layer.Layer<Service, never, HttpClient.HttpClient | ChildPro
|
|||||||
const args = method === "bun" ? ["pm", "view", spec, "version", "--json"] : ["view", spec, "version", "--json"]
|
const args = method === "bun" ? ["pm", "view", spec, "version", "--json"] : ["view", spec, "version", "--json"]
|
||||||
const result = yield* run([method, ...args])
|
const result = yield* run([method, ...args])
|
||||||
if (result.code !== 0 || !result.stdout.trim()) {
|
if (result.code !== 0 || !result.stdout.trim()) {
|
||||||
return yield* new UpgradeFailedError({ stderr: result.stderr || result.stdout || `Failed to resolve ${spec}` })
|
return yield* new UpgradeFailedError({
|
||||||
|
stderr: result.stderr || result.stdout || `Failed to resolve ${spec}`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String))(result.stdout)
|
return yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String))(result.stdout)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -110,25 +110,22 @@ export const layer = Layer.effect(
|
|||||||
const flock = yield* EffectFlock.Service
|
const flock = yield* EffectFlock.Service
|
||||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
||||||
const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg))
|
const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg))
|
||||||
const runView = Effect.fnUntraced(
|
const runView = Effect.fnUntraced(function* (cmd: string[]) {
|
||||||
function* (cmd: string[]) {
|
const handle = yield* spawner.spawn(
|
||||||
const handle = yield* spawner.spawn(
|
ChildProcess.make(cmd[0], cmd.slice(1), {
|
||||||
ChildProcess.make(cmd[0], cmd.slice(1), {
|
extendEnv: true,
|
||||||
extendEnv: true,
|
}),
|
||||||
}),
|
)
|
||||||
)
|
const [stdout, stderr] = yield* Effect.all(
|
||||||
const [stdout, stderr] = yield* Effect.all(
|
[Stream.mkString(Stream.decodeText(handle.stdout)), Stream.mkString(Stream.decodeText(handle.stderr))],
|
||||||
[Stream.mkString(Stream.decodeText(handle.stdout)), Stream.mkString(Stream.decodeText(handle.stderr))],
|
{ concurrency: 2 },
|
||||||
{ concurrency: 2 },
|
)
|
||||||
)
|
const code = yield* handle.exitCode
|
||||||
const code = yield* handle.exitCode
|
if (code !== 0 || !stdout.trim()) {
|
||||||
if (code !== 0 || !stdout.trim()) {
|
return yield* Effect.fail(stderr || stdout || `Failed to run ${cmd.join(" ")}`)
|
||||||
return yield* Effect.fail(stderr || stdout || `Failed to run ${cmd.join(" ")}`)
|
}
|
||||||
}
|
return yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String))(stdout)
|
||||||
return yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String))(stdout)
|
}, Effect.scoped)
|
||||||
},
|
|
||||||
Effect.scoped,
|
|
||||||
)
|
|
||||||
const viewLatestVersion = Effect.fnUntraced(function* (pkg: string) {
|
const viewLatestVersion = Effect.fnUntraced(function* (pkg: string) {
|
||||||
return yield* runView(["npm", "view", pkg, "dist-tags.latest", "--json"]).pipe(
|
return yield* runView(["npm", "view", pkg, "dist-tags.latest", "--json"]).pipe(
|
||||||
Effect.catch(() =>
|
Effect.catch(() =>
|
||||||
|
|||||||
@@ -103,7 +103,9 @@ describe("Npm.outdated", () => {
|
|||||||
return ""
|
return ""
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await Effect.runPromise(Npm.Service.use((svc) => svc.outdated("example", "1.0.0")).pipe(Effect.provide(layer)))
|
const result = await Effect.runPromise(
|
||||||
|
Npm.Service.use((svc) => svc.outdated("example", "1.0.0")).pipe(Effect.provide(layer)),
|
||||||
|
)
|
||||||
|
|
||||||
expect(result).toBe(true)
|
expect(result).toBe(true)
|
||||||
expect(calls).toContainEqual(["npm", "view", "example", "dist-tags.latest", "--json"])
|
expect(calls).toContainEqual(["npm", "view", "example", "dist-tags.latest", "--json"])
|
||||||
@@ -130,7 +132,9 @@ describe("Npm.outdated", () => {
|
|||||||
return ""
|
return ""
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await Effect.runPromise(Npm.Service.use((svc) => svc.outdated("example", "1.0.0")).pipe(Effect.provide(layer)))
|
const result = await Effect.runPromise(
|
||||||
|
Npm.Service.use((svc) => svc.outdated("example", "1.0.0")).pipe(Effect.provide(layer)),
|
||||||
|
)
|
||||||
|
|
||||||
expect(result).toBe(true)
|
expect(result).toBe(true)
|
||||||
expect(calls).toContainEqual(["npm", "view", "example", "dist-tags.latest", "--json"])
|
expect(calls).toContainEqual(["npm", "view", "example", "dist-tags.latest", "--json"])
|
||||||
|
|||||||
Reference in New Issue
Block a user