The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Command from "effect/cli/Command"; |
| 2 | import * as Console from "effect/Console"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import { setExitCode } from "./errors.ts"; |
| 5 | |
| 6 | export const compatibilityCommands = { |
| 7 | login: "alchemy profile", |
| 8 | tail: "alchemy logs --tail", |
| 9 | sync: "alchemy drift --repair", |
| 10 | aws: "alchemy provider aws", |
| 11 | cloudflare: "alchemy provider cloudflare", |
| 12 | prisma: "alchemy provider prisma", |
| 13 | } as const; |
| 14 | |
| 15 | export type CompatibilityCommand = keyof typeof compatibilityCommands; |
| 16 | |
| 17 | /** |
| 18 | * An unlisted command that only points at its replacement and exits 1, so a |
| 19 | * script still invoking the old command fails loudly instead of silently |
| 20 | * doing nothing. |
| 21 | */ |
| 22 | export const movedCommand = (name: string, path: string, replacement: string) => |
| 23 | Command.make(name, {}, () => |
| 24 | Effect.gen(function* () { |
| 25 | yield* Console.error(`The \`${path}\` command has been moved.`); |
| 26 | yield* Console.error(`Run \`${replacement}\` instead.`); |
| 27 | yield* setExitCode(1); |
| 28 | }), |
| 29 | ).pipe(Command.unlisted); |
| 30 | |
| 31 | export const compatibilityCommand = (name: CompatibilityCommand) => |
| 32 | movedCommand(name, `alchemy ${name}`, compatibilityCommands[name]); |