The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { Effect } from "effect"; |
| 2 | import * as Context from "effect/Context"; |
| 3 | import type * as Scope from "effect/Scope"; |
| 4 | import { applyAndRender } from "./Deploy.ts"; |
| 5 | import { evalStack } from "./EvalStack.ts"; |
| 6 | import * as Plan from "./Plan.ts"; |
| 7 | import type { StackDefinition } from "./Stack.ts"; |
| 8 | import { build, Stack } from "./Stack.ts"; |
| 9 | |
| 10 | export const destroy = <ROut>({ |
| 11 | stack, |
| 12 | stage, |
| 13 | dev, |
| 14 | scope, |
| 15 | include, |
| 16 | exclude, |
| 17 | }: { |
| 18 | /** The stack to tear down; its program is never run. */ |
| 19 | stack: StackDefinition<ROut>; |
| 20 | stage: string; |
| 21 | dev?: boolean; |
| 22 | /** See {@link evalStack} — when set, scoped resources outlive `destroy`. */ |
| 23 | scope?: Scope.Scope; |
| 24 | /** Destroy always operates on the full stack. */ |
| 25 | include?: never; |
| 26 | exclude?: never; |
| 27 | }) => |
| 28 | include !== undefined || exclude !== undefined |
| 29 | ? Effect.die( |
| 30 | new Plan.InvalidResourceSelection({ message: "Filtered destroy is not supported." }), |
| 31 | ) |
| 32 | : evalStack( |
| 33 | build({ |
| 34 | name: stack.stackName, |
| 35 | providers: stack.providers, |
| 36 | state: stack.state, |
| 37 | secrets: stack.secrets, |
| 38 | }).pipe(Effect.map((services) => ({ services }))), |
| 39 | ({ services }) => |
| 40 | Plan.destroy(Context.get(services, Stack)).pipe(Effect.flatMap(applyAndRender)), |
| 41 | { stage, dev, scope }, |
| 42 | ); |