1import * as Console from "effect/Console";
2import * as Effect from "effect/Effect";
3import * as Command from "effect/cli/Command";
4import { setExitCode } from "./errors.ts";
5
6export 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} as const;
13
14export type CompatibilityCommand = keyof typeof compatibilityCommands;
15
16export const compatibilityCommand = (name: CompatibilityCommand) =>
17 Command.make(name, {}, () =>
18 Effect.gen(function* () {
19 yield* Console.error(`The \`alchemy ${name}\` command has been moved.`);
20 yield* Console.error(`Run \`${compatibilityCommands[name]}\` instead.`);
21 // Exit non-zero: a CI script still invoking the old command must fail
22 // loudly, not "succeed" while doing nothing.
23 yield* setExitCode(1);
24 }),
25 ).pipe(Command.unlisted);