forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogin.command.ts
More file actions
71 lines (68 loc) · 2.72 KB
/
Copy pathlogin.command.ts
File metadata and controls
71 lines (68 loc) · 2.72 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
63
64
65
66
67
68
69
70
71
import { Command, Flag } from "effect/unstable/cli";
import type * as CliCommand from "effect/unstable/cli/Command";
import { apiLayer } from "../../auth/api.layer.ts";
import { credentialsLayer } from "../../auth/credentials.layer.ts";
import { cryptoLayer } from "../../auth/crypto.layer.ts";
import { withJsonErrorHandling } from "../../../shared/output/json-error-handling.ts";
import { browserLayer } from "../../../shared/runtime/browser.layer.ts";
import { commandRuntimeLayer } from "../../../shared/runtime/command-runtime.layer.ts";
import { withCommandInstrumentation } from "../../../shared/telemetry/command-instrumentation.ts";
import { stdinLayer } from "../../../shared/runtime/stdin.layer.ts";
import { login } from "./login.handler.ts";
const flags = {
token: Flag.string("token").pipe(
Flag.withDescription("Access token (or enter interactively)"),
Flag.optional,
),
name: Flag.string("name").pipe(
Flag.withDescription("Token name stored in dashboard"),
Flag.optional,
),
noBrowser: Flag.boolean("no-browser").pipe(
Flag.withDescription("Do not open browser automatically"),
),
} as const;
export type LoginFlags = CliCommand.Command.Config.Infer<typeof flags>;
export const loginCommand = Command.make("login", flags).pipe(
Command.withDescription(
"Log in to Supabase by providing an access token or using browser-based OAuth.\n\n" +
"Token resolution priority: --token flag > SUPABASE_ACCESS_TOKEN env > piped stdin > interactive browser flow.\n\n" +
"In CI environments, you can skip `supabase login` entirely by setting the SUPABASE_ACCESS_TOKEN environment variable.",
),
Command.withShortDescription("Log in to Supabase"),
Command.withExamples([
{
command: "supabase login",
description: "Log in with browser OAuth (default)",
},
{
command: "supabase login --token sbp_your_token_here",
description: "Log in with a token",
},
{
command: "supabase login --name my-dev-machine",
description: "Log in with a custom token name",
},
{
command: "supabase login --no-browser",
description: "Log in without opening browser",
},
{
command: "SUPABASE_ACCESS_TOKEN=sbp_your_token_here supabase login",
description: "Log in via environment variable",
},
{
command: 'echo "sbp_your_token_here" | supabase login',
description: "Log in via piped stdin",
},
]),
Command.withHandler((flags) =>
login(flags).pipe(withCommandInstrumentation(), withJsonErrorHandling),
),
Command.provide(apiLayer),
Command.provide(credentialsLayer),
Command.provide(cryptoLayer),
Command.provide(browserLayer),
Command.provide(stdinLayer),
Command.provide(commandRuntimeLayer(["login"])),
);