forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.command.ts
More file actions
46 lines (42 loc) · 2.09 KB
/
Copy pathdelete.command.ts
File metadata and controls
46 lines (42 loc) · 2.09 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
45
46
import { Argument, Command, Flag } from "effect/unstable/cli";
import type * as CliCommand from "effect/unstable/cli/Command";
import { FUNCTIONS_PROJECT_REF_SAFE_FLAGS } from "../../../../shared/functions/functions.shared.ts";
import { withJsonErrorHandling } from "../../../../shared/output/json-error-handling.ts";
import { legacyManagementApiRuntimeLayer } from "../../../shared/legacy-management-api-runtime.layer.ts";
import { withLegacyCommandInstrumentation } from "../../../telemetry/legacy-command-instrumentation.ts";
import { legacyFunctionsDelete } from "./delete.handler.ts";
const config = {
functionName: Argument.string("Function name").pipe(
Argument.withDescription("Name of the Function to delete."),
),
projectRef: Flag.string("project-ref").pipe(
Flag.withDescription("Project ref of the Supabase project."),
Flag.optional,
),
} as const;
export type LegacyFunctionsDeleteFlags = CliCommand.Command.Config.Infer<typeof config>;
// Exported so integration tests can drive the exact wiring `Command.withHandler`
// uses below, instead of re-asserting the generic instrumentation mechanism.
export const legacyFunctionsDeleteHandler = (flags: LegacyFunctionsDeleteFlags) =>
legacyFunctionsDelete(flags).pipe(
withLegacyCommandInstrumentation({ flags, safeFlags: FUNCTIONS_PROJECT_REF_SAFE_FLAGS }),
withJsonErrorHandling,
);
export const legacyFunctionsDeleteCommand = Command.make("delete", config).pipe(
Command.withDescription(
"Delete a Function from the linked Supabase project. This does NOT remove the Function locally.",
),
Command.withShortDescription("Delete a Function from Supabase"),
Command.withExamples([
{
command: "supabase functions delete hello-world",
description: "Delete a deployed function from the linked project",
},
{
command: "supabase functions delete hello-world --project-ref abcdefghijklmnopqrst",
description: "Delete a deployed function from a specific project",
},
]),
Command.withHandler(legacyFunctionsDeleteHandler),
Command.provide(legacyManagementApiRuntimeLayer(["functions", "delete"])),
);