buncargo 1.0.19 → 1.0.22
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/cli.ts +5 -10
- package/dist/bin.js +2 -2
- package/dist/cli.js +1 -1
- package/dist/index-qzwpzjbx.js +137 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -53,22 +53,17 @@ export async function runCli<
|
|
|
53
53
|
process.exit(0);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
if (running) {
|
|
59
|
-
console.log("✓ Containers already running");
|
|
60
|
-
} else {
|
|
61
|
-
await env.start({ startServers: false, wait: true });
|
|
62
|
-
}
|
|
56
|
+
// All other paths need containers + migrations + seeding
|
|
57
|
+
await env.start({ startServers: false, wait: true });
|
|
63
58
|
|
|
64
|
-
// Handle --migrate (
|
|
59
|
+
// Handle --migrate (exit after migrations)
|
|
65
60
|
if (args.includes("--migrate")) {
|
|
66
61
|
console.log("");
|
|
67
62
|
console.log("✅ Migrations applied successfully");
|
|
68
63
|
process.exit(0);
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
// Handle --seed (
|
|
66
|
+
// Handle --seed (run seeders, then exit)
|
|
72
67
|
if (args.includes("--seed")) {
|
|
73
68
|
console.log("🌱 Running seeders...");
|
|
74
69
|
const result = await env.exec("bun run run:seeder", {
|
|
@@ -89,7 +84,7 @@ export async function runCli<
|
|
|
89
84
|
process.exit(0);
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
// Handle --up-only
|
|
87
|
+
// Handle --up-only (exit after containers ready)
|
|
93
88
|
if (args.includes("--up-only")) {
|
|
94
89
|
console.log("");
|
|
95
90
|
console.log("✅ Containers started. Environment ready.");
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
3
|
runCli
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-qzwpzjbx.js";
|
|
5
5
|
import {
|
|
6
6
|
loadDevEnv
|
|
7
7
|
} from "./index-3h3dhtf2.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
var require_package = __commonJS((exports, module) => {
|
|
23
23
|
module.exports = {
|
|
24
24
|
name: "buncargo",
|
|
25
|
-
version: "1.0.
|
|
25
|
+
version: "1.0.22",
|
|
26
26
|
description: "A Bun-powered development environment CLI for managing Docker Compose services, dev servers, and environment variables",
|
|
27
27
|
type: "module",
|
|
28
28
|
module: "./dist/index.js",
|
package/dist/cli.js
CHANGED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spawnWatchdog,
|
|
3
|
+
startHeartbeat,
|
|
4
|
+
stopHeartbeat
|
|
5
|
+
} from "./index-ggq3yryx.js";
|
|
6
|
+
import {
|
|
7
|
+
killProcessesOnAppPorts
|
|
8
|
+
} from "./index-1yvbwj4k.js";
|
|
9
|
+
|
|
10
|
+
// cli.ts
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
async function runCli(env, options = {}) {
|
|
13
|
+
const {
|
|
14
|
+
args = process.argv.slice(2),
|
|
15
|
+
watchdog = true,
|
|
16
|
+
watchdogTimeout = 10,
|
|
17
|
+
devServersCommand
|
|
18
|
+
} = options;
|
|
19
|
+
env.logInfo();
|
|
20
|
+
if (args.includes("--down")) {
|
|
21
|
+
await env.stop();
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
if (args.includes("--reset")) {
|
|
25
|
+
await env.stop({ removeVolumes: true });
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
await env.start({ startServers: false, wait: true });
|
|
29
|
+
if (args.includes("--migrate")) {
|
|
30
|
+
console.log("");
|
|
31
|
+
console.log("✅ Migrations applied successfully");
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
if (args.includes("--seed")) {
|
|
35
|
+
console.log("\uD83C\uDF31 Running seeders...");
|
|
36
|
+
const result = await env.exec("bun run run:seeder", {
|
|
37
|
+
throwOnError: false
|
|
38
|
+
});
|
|
39
|
+
if (result.exitCode !== 0) {
|
|
40
|
+
console.error("❌ Seeding failed");
|
|
41
|
+
if (result.stderr) {
|
|
42
|
+
console.error(result.stderr);
|
|
43
|
+
}
|
|
44
|
+
if (result.stdout) {
|
|
45
|
+
console.error(result.stdout);
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
console.log("");
|
|
50
|
+
console.log("✅ Seeding complete");
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
if (args.includes("--up-only")) {
|
|
54
|
+
console.log("");
|
|
55
|
+
console.log("✅ Containers started. Environment ready.");
|
|
56
|
+
console.log("");
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
if (watchdog) {
|
|
60
|
+
await spawnWatchdog(env.projectName, env.root, {
|
|
61
|
+
timeoutMinutes: watchdogTimeout,
|
|
62
|
+
verbose: true
|
|
63
|
+
});
|
|
64
|
+
startHeartbeat(env.projectName);
|
|
65
|
+
}
|
|
66
|
+
const command = devServersCommand ?? buildDevServersCommand(env.apps);
|
|
67
|
+
if (!command) {
|
|
68
|
+
console.log("✅ Containers ready. No apps configured.");
|
|
69
|
+
await new Promise(() => {});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await killProcessesOnAppPorts(env.apps, env.ports);
|
|
73
|
+
console.log("");
|
|
74
|
+
console.log("\uD83D\uDD27 Starting dev servers...");
|
|
75
|
+
console.log("");
|
|
76
|
+
await runCommand(command, env.root, env.buildEnvVars());
|
|
77
|
+
stopHeartbeat();
|
|
78
|
+
}
|
|
79
|
+
function buildDevServersCommand(apps) {
|
|
80
|
+
const appEntries = Object.entries(apps);
|
|
81
|
+
if (appEntries.length === 0)
|
|
82
|
+
return null;
|
|
83
|
+
const commands = [];
|
|
84
|
+
const names = [];
|
|
85
|
+
const colors = ["blue", "green", "yellow", "magenta", "cyan", "red"];
|
|
86
|
+
for (const [name, config] of appEntries) {
|
|
87
|
+
names.push(name);
|
|
88
|
+
const cwdPart = config.cwd ? `--cwd ${config.cwd}` : "";
|
|
89
|
+
commands.push(`"bun run ${cwdPart} ${config.devCommand}"`.replace(/\s+/g, " ").trim());
|
|
90
|
+
}
|
|
91
|
+
const namesArg = `-n ${names.join(",")}`;
|
|
92
|
+
const colorsArg = `-c ${colors.slice(0, names.length).join(",")}`;
|
|
93
|
+
const commandsArg = commands.join(" ");
|
|
94
|
+
return `bun concurrently ${namesArg} ${colorsArg} ${commandsArg}`;
|
|
95
|
+
}
|
|
96
|
+
function runCommand(command, cwd, envVars) {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const proc = spawn(command, [], {
|
|
99
|
+
cwd,
|
|
100
|
+
env: { ...process.env, ...envVars },
|
|
101
|
+
stdio: "inherit",
|
|
102
|
+
shell: true
|
|
103
|
+
});
|
|
104
|
+
proc.on("close", (code) => {
|
|
105
|
+
if (code === 0 || code === null) {
|
|
106
|
+
resolve();
|
|
107
|
+
} else {
|
|
108
|
+
reject(new Error(`Command exited with code ${code}`));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
proc.on("error", reject);
|
|
112
|
+
const cleanup = () => {
|
|
113
|
+
proc.kill("SIGTERM");
|
|
114
|
+
};
|
|
115
|
+
process.on("SIGINT", cleanup);
|
|
116
|
+
process.on("SIGTERM", cleanup);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function hasFlag(args, flag) {
|
|
120
|
+
return args.includes(flag);
|
|
121
|
+
}
|
|
122
|
+
function getFlagValue(args, flag) {
|
|
123
|
+
const prefixed = args.find((arg) => arg.startsWith(`${flag}=`));
|
|
124
|
+
if (prefixed) {
|
|
125
|
+
return prefixed.split("=")[1];
|
|
126
|
+
}
|
|
127
|
+
const index = args.indexOf(flag);
|
|
128
|
+
if (index !== -1 && index + 1 < args.length) {
|
|
129
|
+
const nextArg = args[index + 1];
|
|
130
|
+
if (nextArg !== undefined && !nextArg.startsWith("-")) {
|
|
131
|
+
return nextArg;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { runCli, hasFlag, getFlagValue };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED