forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserve.command.ts
More file actions
62 lines (59 loc) · 2.45 KB
/
Copy pathserve.command.ts
File metadata and controls
62 lines (59 loc) · 2.45 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Layer } from "effect";
import { Command, Flag } from "effect/unstable/cli";
import { withJsonErrorHandling } from "../../../../shared/output/json-error-handling.ts";
import { commandRuntimeLayer } from "../../../../shared/runtime/command-runtime.layer.ts";
import {
FUNCTIONS_SERVE_INSPECT_MODES,
serveFileWatcherLayer,
} from "../../../../shared/functions/serve.ts";
import { legacyCliConfigLayer } from "../../../config/legacy-cli-config.layer.ts";
import { legacyDebugLoggerLayer } from "../../../shared/legacy-debug-logger.layer.ts";
import { withLegacyCommandInstrumentation } from "../../../telemetry/legacy-command-instrumentation.ts";
import { legacyTelemetryStateLayer } from "../../../telemetry/legacy-telemetry-state.layer.ts";
import { legacyFunctionsServe } from "./serve.handler.ts";
const cliConfig = legacyCliConfigLayer.pipe(Layer.provide(legacyDebugLoggerLayer));
const legacyFunctionsServeRuntimeLayer = Layer.mergeAll(
serveFileWatcherLayer,
cliConfig,
legacyDebugLoggerLayer,
legacyTelemetryStateLayer,
commandRuntimeLayer(["functions", "serve"]),
);
const config = {
noVerifyJwt: Flag.boolean("no-verify-jwt").pipe(
Flag.withDescription("Disable JWT verification for the Function."),
Flag.optional,
),
envFile: Flag.string("env-file").pipe(
Flag.withDescription("Path to an env file to be populated to the Function environment."),
Flag.optional,
),
importMap: Flag.string("import-map").pipe(
Flag.withDescription("Path to import map file."),
Flag.optional,
),
inspect: Flag.boolean("inspect").pipe(Flag.withDescription("Alias of --inspect-mode brk.")),
inspectMode: Flag.choice("inspect-mode", FUNCTIONS_SERVE_INSPECT_MODES).pipe(
Flag.withDescription("Activate inspector capability for debugging."),
Flag.optional,
),
inspectMain: Flag.boolean("inspect-main").pipe(
Flag.withDescription("Allow inspecting the main worker."),
),
all: Flag.boolean("all").pipe(
Flag.withDescription("Serve all Functions."),
Flag.withDefault(true),
Flag.withHidden,
),
} as const;
export const legacyFunctionsServeCommand = Command.make("serve", config).pipe(
Command.withDescription("Serve all Functions locally."),
Command.withShortDescription("Serve all Functions locally"),
Command.withHandler((flags) =>
legacyFunctionsServe(flags).pipe(
withLegacyCommandInstrumentation({ flags, config }),
withJsonErrorHandling,
),
),
Command.provide(legacyFunctionsServeRuntimeLayer),
);