forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.command.ts
More file actions
44 lines (40 loc) · 1.64 KB
/
Copy pathfetch.command.ts
File metadata and controls
44 lines (40 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Command, Flag } from "effect/unstable/cli";
import type * as CliCommand from "effect/unstable/cli/Command";
import { withJsonErrorHandling } from "../../../../shared/output/json-error-handling.ts";
import { withLegacyCommandInstrumentation } from "../../../telemetry/legacy-command-instrumentation.ts";
import { legacyMigrationDbRuntimeLayer } from "../migration.layers.ts";
import { legacyMigrationFetch } from "./fetch.handler.ts";
const config = {
dbUrl: Flag.string("db-url").pipe(
Flag.withDescription(
"Fetches migrations from the database specified by the connection string (must be percent-encoded).",
),
Flag.optional,
),
linked: Flag.boolean("linked").pipe(
Flag.withDescription("Fetches migration history from the linked project."),
// Go: `fetchFlags.Bool("linked", true, …)`.
Flag.withDefault(true),
),
local: Flag.boolean("local").pipe(
Flag.withDescription("Fetches migration history from the local database."),
),
} as const;
export type LegacyMigrationFetchFlags = CliCommand.Command.Config.Infer<typeof config>;
export const legacyMigrationFetchCommand = Command.make("fetch", config).pipe(
Command.withDescription("Fetch migration files from history table."),
Command.withShortDescription("Fetch migration files from history table"),
Command.withHandler((flags) =>
legacyMigrationFetch(flags).pipe(
withLegacyCommandInstrumentation({
flags: {
"db-url": flags.dbUrl,
linked: flags.linked,
local: flags.local,
},
}),
withJsonErrorHandling,
),
),
Command.provide(legacyMigrationDbRuntimeLayer(["migration", "fetch"])),
);