forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
52 lines (45 loc) · 1.13 KB
/
auth.ts
File metadata and controls
52 lines (45 loc) · 1.13 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
#!/usr/bin/env node
import { defineCommand } from "citty"
import consola from "consola"
import { PATHS, ensurePaths } from "./lib/paths"
import { state } from "./lib/state"
import { setupGitHubToken } from "./lib/token"
interface RunAuthOptions {
verbose: boolean
showToken: boolean
}
export async function runAuth(options: RunAuthOptions): Promise<void> {
if (options.verbose) {
consola.level = 5
consola.info("Verbose logging enabled")
}
state.showToken = options.showToken
await ensurePaths()
await setupGitHubToken({ force: true })
consola.success("GitHub token written to", PATHS.GITHUB_TOKEN_PATH)
}
export const auth = defineCommand({
meta: {
name: "auth",
description: "Run GitHub auth flow without running the server",
},
args: {
verbose: {
alias: "v",
type: "boolean",
default: false,
description: "Enable verbose logging",
},
"show-token": {
type: "boolean",
default: false,
description: "Show GitHub token on auth",
},
},
run({ args }) {
return runAuth({
verbose: args.verbose,
showToken: args["show-token"],
})
},
})