claudekit-cli 3.36.0-dev.29 → 3.36.0-dev.30
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/bin/ck.js +91 -11
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/bin/ck.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* This is the entry point that NPM symlinks to when installing globally.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
9
|
+
import { execSync, spawn } from "node:child_process";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -48,7 +48,59 @@ const getErrorMessage = (err) => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Check if bun runtime is available on the system.
|
|
52
|
+
* Used to run dist/index.js with bun when no platform binary exists (e.g., dev releases).
|
|
53
|
+
* dist/index.js may contain bun-specific imports (bun:sqlite) that Node.js can't handle.
|
|
54
|
+
* Result is cached to avoid repeated execSync calls across fallback paths.
|
|
55
|
+
*/
|
|
56
|
+
let _bunAvailable = undefined;
|
|
57
|
+
const hasBun = () => {
|
|
58
|
+
if (_bunAvailable !== undefined) return _bunAvailable;
|
|
59
|
+
try {
|
|
60
|
+
execSync("bun --version", { stdio: "ignore", timeout: 3000 });
|
|
61
|
+
_bunAvailable = true;
|
|
62
|
+
} catch {
|
|
63
|
+
_bunAvailable = false;
|
|
64
|
+
}
|
|
65
|
+
return _bunAvailable;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Run CLI via bun runtime. Preferred over Node.js when dist/index.js contains
|
|
70
|
+
* bun-specific imports (e.g., bun:sqlite) that the Node.js ESM loader rejects.
|
|
71
|
+
* @param {boolean} showWarning - Whether to show runtime info message
|
|
72
|
+
* @returns {Promise<void>} Resolves when bun process exits
|
|
73
|
+
*/
|
|
74
|
+
const runWithBun = (showWarning = false) => {
|
|
75
|
+
const distPath = join(__dirname, "..", "dist", "index.js");
|
|
76
|
+
if (!existsSync(distPath)) {
|
|
77
|
+
throw new Error("Compiled distribution not found. This may indicate a packaging issue.");
|
|
78
|
+
}
|
|
79
|
+
if (showWarning) {
|
|
80
|
+
console.error("⚠️ Native binary not found, using bun runtime");
|
|
81
|
+
}
|
|
82
|
+
return new Promise((resolve) => {
|
|
83
|
+
const child = spawn("bun", [distPath, ...process.argv.slice(2)], {
|
|
84
|
+
stdio: "inherit",
|
|
85
|
+
windowsHide: true,
|
|
86
|
+
});
|
|
87
|
+
child.on("error", () => {
|
|
88
|
+
// bun spawn failed unexpectedly — caller handles fallback
|
|
89
|
+
resolve(false);
|
|
90
|
+
});
|
|
91
|
+
child.on("exit", (code, signal) => {
|
|
92
|
+
if (signal) {
|
|
93
|
+
process.kill(process.pid, signal);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
process.exitCode = code || 0;
|
|
97
|
+
resolve(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Run CLI via Node.js as last-resort fallback (slower, no bun: protocol support).
|
|
52
104
|
* The imported dist/index.js handles its own process lifecycle via the cac CLI framework.
|
|
53
105
|
* @param {boolean} showWarning - Whether to show fallback warning message
|
|
54
106
|
* @throws {Error} If dist/index.js is missing or fails to load
|
|
@@ -115,17 +167,32 @@ const runBinary = (binaryPath) => {
|
|
|
115
167
|
|
|
116
168
|
child.on("error", async (err) => {
|
|
117
169
|
// Binary execution failed (e.g., ENOENT on Alpine/musl due to missing glibc)
|
|
118
|
-
// Fall back to Node.js
|
|
170
|
+
// Fall back to bun, then Node.js
|
|
119
171
|
errorOccurred = true;
|
|
172
|
+
if (hasBun()) {
|
|
173
|
+
const success = await runWithBun(true);
|
|
174
|
+
if (success) {
|
|
175
|
+
resolve();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
120
179
|
try {
|
|
121
180
|
await runWithNode(true);
|
|
122
181
|
resolve();
|
|
123
182
|
} catch (fallbackErr) {
|
|
183
|
+
const fallbackMsg = getErrorMessage(fallbackErr);
|
|
124
184
|
console.error(`❌ Binary failed: ${getErrorMessage(err)}`);
|
|
125
|
-
console.error(`❌ Fallback also failed: ${
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
185
|
+
console.error(`❌ Fallback also failed: ${fallbackMsg}`);
|
|
186
|
+
if (fallbackMsg.includes("bun:") || fallbackMsg.includes("Received protocol")) {
|
|
187
|
+
console.error("");
|
|
188
|
+
console.error("This version of ClaudeKit CLI requires the bun runtime.");
|
|
189
|
+
console.error("Install bun: curl -fsSL https://bun.sh/install | bash");
|
|
190
|
+
console.error("Or switch to stable: npm install -g claudekit-cli@latest");
|
|
191
|
+
} else {
|
|
192
|
+
console.error(
|
|
193
|
+
"Please report this issue at: https://github.com/mrgoonie/claudekit-cli/issues",
|
|
194
|
+
);
|
|
195
|
+
}
|
|
129
196
|
process.exit(1);
|
|
130
197
|
}
|
|
131
198
|
});
|
|
@@ -148,16 +215,29 @@ const runBinary = (binaryPath) => {
|
|
|
148
215
|
};
|
|
149
216
|
|
|
150
217
|
/**
|
|
151
|
-
* Handle fallback execution
|
|
152
|
-
* @param {string} errorPrefix - Prefix for error message if
|
|
218
|
+
* Handle fallback execution: try bun first (handles bun: imports), then Node.js.
|
|
219
|
+
* @param {string} errorPrefix - Prefix for error message if all fallbacks fail
|
|
153
220
|
* @param {boolean} showIssueLink - Whether to show issue reporting link
|
|
154
221
|
*/
|
|
155
222
|
const handleFallback = async (errorPrefix, showIssueLink = false) => {
|
|
223
|
+
// Prefer bun — dist/index.js may contain bun-specific imports (bun:sqlite)
|
|
224
|
+
if (hasBun()) {
|
|
225
|
+
const success = await runWithBun(true);
|
|
226
|
+
if (success) return;
|
|
227
|
+
}
|
|
228
|
+
// Last resort: Node.js (works for stable builds without bun: imports)
|
|
156
229
|
try {
|
|
157
230
|
await runWithNode();
|
|
158
231
|
} catch (err) {
|
|
159
|
-
|
|
160
|
-
|
|
232
|
+
const errMsg = getErrorMessage(err);
|
|
233
|
+
console.error(`❌ ${errorPrefix}: ${errMsg}`);
|
|
234
|
+
// Detect bun-specific import failures and guide user to install bun
|
|
235
|
+
if (errMsg.includes("bun:") || errMsg.includes("Received protocol")) {
|
|
236
|
+
console.error("");
|
|
237
|
+
console.error("This version of ClaudeKit CLI requires the bun runtime.");
|
|
238
|
+
console.error("Install bun: curl -fsSL https://bun.sh/install | bash");
|
|
239
|
+
console.error("Or switch to stable: npm install -g claudekit-cli@latest");
|
|
240
|
+
} else if (showIssueLink) {
|
|
161
241
|
console.error(
|
|
162
242
|
"Please report this issue at: https://github.com/mrgoonie/claudekit-cli/issues",
|
|
163
243
|
);
|
package/dist/index.js
CHANGED
|
@@ -56626,7 +56626,7 @@ var package_default;
|
|
|
56626
56626
|
var init_package = __esm(() => {
|
|
56627
56627
|
package_default = {
|
|
56628
56628
|
name: "claudekit-cli",
|
|
56629
|
-
version: "3.36.0-dev.
|
|
56629
|
+
version: "3.36.0-dev.30",
|
|
56630
56630
|
description: "CLI tool for bootstrapping and updating ClaudeKit projects",
|
|
56631
56631
|
type: "module",
|
|
56632
56632
|
repository: {
|