claudekit-cli 3.38.0-dev.2 → 3.38.0-dev.4
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 +26 -5
- package/dist/index.js +493 -427
- package/package.json +1 -1
package/bin/ck.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { execSync, spawn, spawnSync } from "node:child_process";
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
13
|
|
|
@@ -65,6 +65,26 @@ const hasBun = () => {
|
|
|
65
65
|
return _bunAvailable;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
let _installedVersion = undefined;
|
|
69
|
+
const readInstalledPackageVersion = () => {
|
|
70
|
+
if (_installedVersion !== undefined) return _installedVersion;
|
|
71
|
+
try {
|
|
72
|
+
const packageJsonPath = join(__dirname, "..", "package.json");
|
|
73
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
74
|
+
_installedVersion = typeof packageJson.version === "string" ? packageJson.version : null;
|
|
75
|
+
} catch {
|
|
76
|
+
_installedVersion = null;
|
|
77
|
+
}
|
|
78
|
+
return _installedVersion;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const isExpectedBunOnlyRelease = () => {
|
|
82
|
+
const version = readInstalledPackageVersion();
|
|
83
|
+
return typeof version === "string" && /-dev\.\d+$/i.test(version);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const shouldWarnForBunFallback = () => !isExpectedBunOnlyRelease();
|
|
87
|
+
|
|
68
88
|
/**
|
|
69
89
|
* Run CLI via bun runtime. Preferred over Node.js when dist/index.js contains
|
|
70
90
|
* bun-specific imports (e.g., bun:sqlite) that the Node.js ESM loader rejects.
|
|
@@ -213,11 +233,11 @@ const runBinary = (binaryPath) => {
|
|
|
213
233
|
* @param {string} errorPrefix - Prefix for error message if all fallbacks fail
|
|
214
234
|
* @param {boolean} showIssueLink - Whether to show issue reporting link
|
|
215
235
|
*/
|
|
216
|
-
const handleFallback = async (errorPrefix, showIssueLink = false) => {
|
|
236
|
+
const handleFallback = async (errorPrefix, showIssueLink = false, showBunWarning = true) => {
|
|
217
237
|
// Prefer bun — dist/index.js may contain bun-specific imports (bun:sqlite)
|
|
218
238
|
// runWithBun calls process.exit() on success — won't return here
|
|
219
239
|
if (hasBun()) {
|
|
220
|
-
runWithBun(
|
|
240
|
+
runWithBun(showBunWarning);
|
|
221
241
|
}
|
|
222
242
|
// Last resort: Node.js (works for stable builds without bun: imports)
|
|
223
243
|
try {
|
|
@@ -245,13 +265,14 @@ const handleFallback = async (errorPrefix, showIssueLink = false) => {
|
|
|
245
265
|
*/
|
|
246
266
|
const main = async () => {
|
|
247
267
|
const binaryPath = getBinaryPath();
|
|
268
|
+
const showBunWarning = shouldWarnForBunFallback();
|
|
248
269
|
|
|
249
270
|
if (!binaryPath) {
|
|
250
271
|
// No binary for this platform - use Node.js fallback
|
|
251
|
-
await handleFallback("Failed to run CLI");
|
|
272
|
+
await handleFallback("Failed to run CLI", false, showBunWarning);
|
|
252
273
|
} else if (!existsSync(binaryPath)) {
|
|
253
274
|
// Binary should exist but doesn't - try fallback
|
|
254
|
-
await handleFallback("Binary not found and fallback failed", true);
|
|
275
|
+
await handleFallback("Binary not found and fallback failed", true, showBunWarning);
|
|
255
276
|
} else {
|
|
256
277
|
// Execute the binary (handles its own fallback on error)
|
|
257
278
|
await runBinary(binaryPath);
|