@donkeylabs/cli 0.4.4 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/cli",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "CLI for @donkeylabs/server - project scaffolding and code generation",
6
6
  "main": "./src/index.ts",
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "bun run gen:types && bun run dev:watch & bun --bun vite dev",
7
+ "dev": "bun scripts/dev.ts",
8
8
  "dev:watch": "bun --watch --no-clear-screen scripts/watch-server.ts",
9
9
  "build": "bun run gen:types && vite build",
10
10
  "preview": "bun build/server/entry.js",
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bun
2
+ // Dev script that runs vite and watcher together, ensuring cleanup on exit
3
+
4
+ import { spawn, type Subprocess } from "bun";
5
+
6
+ const children: Subprocess[] = [];
7
+
8
+ function cleanup() {
9
+ for (const child of children) {
10
+ try {
11
+ child.kill();
12
+ } catch {}
13
+ }
14
+ process.exit(0);
15
+ }
16
+
17
+ // Handle all exit signals
18
+ process.on("SIGTERM", cleanup);
19
+ process.on("SIGINT", cleanup);
20
+ process.on("exit", cleanup);
21
+
22
+ // Generate types first
23
+ console.log("\x1b[36m[dev]\x1b[0m Generating types...");
24
+ const genResult = Bun.spawnSync(["bun", "run", "gen:types"], {
25
+ stdout: "inherit",
26
+ stderr: "inherit",
27
+ });
28
+
29
+ if (genResult.exitCode !== 0) {
30
+ console.error("\x1b[31m[dev]\x1b[0m Failed to generate types");
31
+ process.exit(1);
32
+ }
33
+
34
+ // Start watcher
35
+ console.log("\x1b[36m[dev]\x1b[0m Starting file watcher...");
36
+ const watcher = spawn(["bun", "--watch", "--no-clear-screen", "scripts/watch-server.ts"], {
37
+ stdout: "inherit",
38
+ stderr: "inherit",
39
+ });
40
+ children.push(watcher);
41
+
42
+ // Start vite
43
+ console.log("\x1b[36m[dev]\x1b[0m Starting Vite dev server...");
44
+ const vite = spawn(["bun", "--bun", "vite", "dev"], {
45
+ stdout: "inherit",
46
+ stderr: "inherit",
47
+ stdin: "inherit",
48
+ });
49
+ children.push(vite);
50
+
51
+ // When vite exits, cleanup everything
52
+ await vite.exited;
53
+ cleanup();
@@ -10,6 +10,10 @@ const serverDir = join(import.meta.dir, "..", "src", "server");
10
10
  let isGenerating = false;
11
11
  let pendingGenerate = false;
12
12
 
13
+ // Handle signals for clean shutdown (from parent dev.ts)
14
+ process.on("SIGTERM", () => process.exit(0));
15
+ process.on("SIGINT", () => process.exit(0));
16
+
13
17
  async function regenerate() {
14
18
  if (isGenerating) {
15
19
  pendingGenerate = true;