@buildepicshit/cli 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bes.js +359 -0
- package/dist/bes.js.map +4 -4
- package/package.json +3 -1
- package/src/bes.ts +11 -0
- package/src/completion.ts +12 -0
- package/src/orchestrator/core/command.ts +2 -0
- package/src/orchestrator/presets/docker.ts +3 -3
- package/src/orchestrator/runner/health-runner.ts +5 -3
package/package.json
CHANGED
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
"commander": "^13.1.0",
|
|
8
8
|
"execa": "^9.6.1",
|
|
9
9
|
"jiti": "^2.4.2",
|
|
10
|
+
"omelette": "^0.4.17",
|
|
10
11
|
"open": "^10.1.2",
|
|
11
12
|
"ws": "^8.18.2",
|
|
12
13
|
"zx": "^8.8.5"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
16
|
+
"@types/omelette": "^0.4.5",
|
|
15
17
|
"@types/ws": "^8.18.1",
|
|
16
18
|
"esbuild": "^0.25.5"
|
|
17
19
|
},
|
|
@@ -35,5 +37,5 @@
|
|
|
35
37
|
"typecheck": "tsc --noEmit"
|
|
36
38
|
},
|
|
37
39
|
"type": "module",
|
|
38
|
-
"version": "0.0.
|
|
40
|
+
"version": "0.0.8"
|
|
39
41
|
}
|
package/src/bes.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { setupCompletion } from "./completion.js";
|
|
2
3
|
import { loadConfig } from "./config-loader.js";
|
|
3
4
|
import { createLazyLogger } from "./orchestrator/logger/logger.js";
|
|
4
5
|
import { createEventBus } from "./orchestrator/runner/event-bus.js";
|
|
@@ -18,6 +19,16 @@ program
|
|
|
18
19
|
|
|
19
20
|
async function main() {
|
|
20
21
|
const { root, commands } = await loadConfig();
|
|
22
|
+
const commandNames = Object.keys(commands);
|
|
23
|
+
|
|
24
|
+
// Setup shell autocomplete (handles completion requests and exits)
|
|
25
|
+
const completion = setupCompletion(commandNames);
|
|
26
|
+
|
|
27
|
+
// bes --setup-completion → install shell init file and exit
|
|
28
|
+
if (process.argv.includes("--setup-completion")) {
|
|
29
|
+
completion.setupShellInitFile();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
21
32
|
|
|
22
33
|
// Register each exported function as a CLI command
|
|
23
34
|
for (const [name, fn] of Object.entries(commands)) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import omelette from "omelette";
|
|
2
|
+
|
|
3
|
+
export function setupCompletion(commandNames: string[]) {
|
|
4
|
+
const completion = omelette("bes <command>");
|
|
5
|
+
|
|
6
|
+
completion.on("command", ({ reply }) => {
|
|
7
|
+
reply([...commandNames, "--dry"]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
completion.init();
|
|
11
|
+
return completion;
|
|
12
|
+
}
|
|
@@ -223,7 +223,9 @@ class Command implements ICommand {
|
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
const fullCmd = [built.command, ...built.args].join(" ");
|
|
226
227
|
rtx.logger.starting(name, name);
|
|
228
|
+
rtx.logger.system(` ${fullCmd}`);
|
|
227
229
|
|
|
228
230
|
const proc = spawnProcess(name, name, built);
|
|
229
231
|
rtx.processes.set(name, proc);
|
|
@@ -103,7 +103,7 @@ class DockerCompose implements IDockerCompose {
|
|
|
103
103
|
}
|
|
104
104
|
command = command.arg("up");
|
|
105
105
|
if (this.dcState.detach) {
|
|
106
|
-
command = command.
|
|
106
|
+
command = command.arg("-d");
|
|
107
107
|
}
|
|
108
108
|
return command.build(ctx);
|
|
109
109
|
}
|
|
@@ -116,7 +116,7 @@ class DockerCompose implements IDockerCompose {
|
|
|
116
116
|
}
|
|
117
117
|
command = command.arg("up");
|
|
118
118
|
if (this.dcState.detach) {
|
|
119
|
-
command = command.
|
|
119
|
+
command = command.arg("-d");
|
|
120
120
|
}
|
|
121
121
|
return command.run();
|
|
122
122
|
}
|
|
@@ -144,7 +144,7 @@ export function docker(options?: {
|
|
|
144
144
|
command = command.arg("up");
|
|
145
145
|
|
|
146
146
|
if (options?.detach) {
|
|
147
|
-
command = command.
|
|
147
|
+
command = command.arg("-d");
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if (options?.service) {
|
|
@@ -27,10 +27,12 @@ export async function waitForHealthy(
|
|
|
27
27
|
let retries = 0;
|
|
28
28
|
|
|
29
29
|
while (retries < maxRetries && Date.now() - startTime < timeout) {
|
|
30
|
-
// Bail if process died
|
|
31
|
-
if (proc.status === "failed"
|
|
30
|
+
// Bail if process died (but not if it completed cleanly — e.g. docker compose --detach)
|
|
31
|
+
if (proc.status === "failed") {
|
|
32
|
+
const tail = proc.outputLines.slice(-20).join("\n");
|
|
33
|
+
const output = tail ? `\n\nProcess output:\n${tail}` : "";
|
|
32
34
|
throw new Error(
|
|
33
|
-
`Process "${proc.serviceName}"
|
|
35
|
+
`Process "${proc.serviceName}" failed before becoming healthy${output}`,
|
|
34
36
|
);
|
|
35
37
|
}
|
|
36
38
|
|