forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.command.ts
More file actions
44 lines (38 loc) · 1.83 KB
/
Copy pathnew.command.ts
File metadata and controls
44 lines (38 loc) · 1.83 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 { Layer } from "effect";
import { Argument, 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 { commandRuntimeLayer } from "../../../../shared/runtime/command-runtime.layer.ts";
import { legacyCliConfigLayer } from "../../../config/legacy-cli-config.layer.ts";
import { legacyDebugLoggerLayer } from "../../../shared/legacy-debug-logger.layer.ts";
import { legacyTelemetryStateLayer } from "../../../telemetry/legacy-telemetry-state.layer.ts";
import { withLegacyCommandInstrumentation } from "../../../telemetry/legacy-command-instrumentation.ts";
import { legacyFunctionsNew } from "./new.handler.ts";
const AUTH_MODE_VALUES = ["none", "apikey", "user"] as const;
const config = {
functionName: Argument.string("Function name").pipe(
Argument.withDescription("Name of the Function to create."),
),
auth: Flag.choice("auth", AUTH_MODE_VALUES).pipe(
Flag.withDescription("use a specific auth mode"),
Flag.withDefault("apikey" as const),
),
} as const;
export type LegacyFunctionsNewFlags = CliCommand.Command.Config.Infer<typeof config>;
const cliConfig = legacyCliConfigLayer.pipe(Layer.provide(legacyDebugLoggerLayer));
const legacyFunctionsNewRuntimeLayer = Layer.mergeAll(
cliConfig,
legacyTelemetryStateLayer,
commandRuntimeLayer(["functions", "new"]),
);
export const legacyFunctionsNewCommand = Command.make("new", config).pipe(
Command.withDescription("Create a new Function locally."),
Command.withShortDescription("Create a new Function locally"),
Command.withHandler((flags) =>
legacyFunctionsNew(flags).pipe(
withLegacyCommandInstrumentation({ flags, config }),
withJsonErrorHandling,
),
),
Command.provide(legacyFunctionsNewRuntimeLayer),
);