-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
85 lines (79 loc) · 2.51 KB
/
Copy pathindex.ts
File metadata and controls
85 lines (79 loc) · 2.51 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { Command, Option } from "commander";
import { runInit } from "../../controllers/init";
import { renderInit, serializeInit } from "../../presenters/init";
import { attachCommandDescriptor } from "../../shell/command-meta";
import { runCommand } from "../../shell/command-runner";
import { addGlobalFlags } from "../../shell/global-flags";
import { type CliRuntime, configureRuntimeCommand } from "../../shell/runtime";
import type { InitResult } from "../../types/init";
export function createInitCommand(runtime: CliRuntime): Command {
const command = attachCommandDescriptor(
configureRuntimeCommand(new Command("init"), runtime),
"init",
);
command
.addOption(
new Option(
"--framework <framework>",
"Framework override; detected when omitted",
),
)
.addOption(
new Option(
"--entry <path>",
"Source entrypoint for entrypoint frameworks (Bun, Hono)",
),
)
.addOption(new Option("--http-port <port>", "HTTP port the app listens on"))
.addOption(
new Option(
"--region <region>",
"Region used when deploy creates the app",
),
)
.addOption(new Option("--name <app-name>", "App name"))
.addOption(new Option("--link", "Link this directory to a Project"))
.addOption(new Option("--no-link", "Skip the Project link step"))
.addOption(
new Option("--project <id-or-name>", "Project to link this directory to"),
)
.addOption(
new Option("--install", "Install @prisma/compute-sdk for config types"),
)
.addOption(new Option("--no-install", "Skip the types install step"));
addGlobalFlags(command);
command.action(async (options) => {
const flags = options as {
framework?: string;
entry?: string;
httpPort?: string;
region?: string;
name?: string;
link?: boolean;
project?: string;
install?: boolean;
};
await runCommand<InitResult>(
runtime,
"init",
options as Record<string, unknown>,
(context) =>
runInit(context, {
framework: flags.framework,
entry: flags.entry,
httpPort: flags.httpPort,
region: flags.region,
name: flags.name,
link: flags.link,
project: flags.project,
install: flags.install,
}),
{
renderHuman: (context, descriptor, result) =>
renderInit(context, descriptor, result),
renderJson: (result) => serializeInit(result),
},
);
});
return command;
}