CLI perf: reduce deps (#22652)

This commit is contained in:
Dax 2026-04-16 02:03:03 -04:00 committed by GitHub
commit 675a46e23e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 1413 additions and 1009 deletions

View file

@ -4,6 +4,12 @@ export abstract class NamedError extends Error {
abstract schema(): z.core.$ZodType
abstract toObject(): { name: string; data: any }
static hasName(error: unknown, name: string): boolean {
return (
typeof error === "object" && error !== null && "name" in error && (error as Record<string, unknown>).name === name
)
}
static create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data) {
const schema = z
.object({

View file

@ -345,10 +345,14 @@ export namespace Flock {
return await fn()
}
export const effect = Effect.fn("Flock.effect")(function* (key: string) {
export const effect = Effect.fn("Flock.effect")(function* (key: string, input: Options = {}) {
return yield* Effect.acquireRelease(
Effect.promise((signal) => Flock.acquire(key, { signal })),
(foo) => Effect.promise(() => foo.release()),
Effect.promise((signal) => Flock.acquire(key, { ...input, signal })).pipe(
Effect.withSpan("Flock.acquire", {
attributes: { key },
}),
),
(lock) => Effect.promise(() => lock.release()).pipe(Effect.withSpan("Flock.release")),
).pipe(Effect.asVoid)
})
}