-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
59 lines (50 loc) · 1.75 KB
/
Copy pathindex.ts
File metadata and controls
59 lines (50 loc) · 1.75 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
import { Command, Option } from "commander";
import { runBuildLogs } from "../../controllers/build";
import { attachCommandDescriptor } from "../../shell/command-meta";
import { runStreamingCommand } from "../../shell/command-runner";
import {
addCompactGlobalFlags,
addGlobalFlags,
} from "../../shell/global-flags";
import { type CliRuntime, configureRuntimeCommand } from "../../shell/runtime";
export function createBuildCommand(runtime: CliRuntime): Command {
const build = attachCommandDescriptor(
configureRuntimeCommand(new Command("build"), runtime),
"build",
);
addCompactGlobalFlags(build);
build.addCommand(createLogsCommand(runtime));
return build;
}
function createLogsCommand(runtime: CliRuntime): Command {
const command = attachCommandDescriptor(
configureRuntimeCommand(new Command("logs"), runtime),
"build.logs",
);
command
.argument("<buildId>", "Build id from a git-push or Console deploy")
.addOption(
new Option(
"--follow",
"Keep the connection open and stream new logs as the build runs",
),
)
.addOption(
new Option("--cursor <cursor>", "Resume from a prior terminal cursor"),
);
addGlobalFlags(command);
command.action(async (buildId: string, options) => {
const follow = (options as { follow?: boolean }).follow;
const cursor = (options as { cursor?: string }).cursor;
await runStreamingCommand(
runtime,
"build.logs",
options as Record<string, unknown>,
(context) => runBuildLogs(context, buildId, { follow, cursor }),
// build logs emits its own per-record JSON ending in a terminal record;
// suppress the redundant wrapper success event.
{ emitJsonSuccessEvent: false },
);
});
return command;
}