claudish 7.48.0 → 7.49.0
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/claudish.cjs +69 -25
- package/dist/index.js +1066 -420
- package/package.json +5 -5
package/bin/claudish.cjs
CHANGED
|
@@ -7,18 +7,51 @@
|
|
|
7
7
|
const { execFileSync, execSync } = require("node:child_process");
|
|
8
8
|
const { resolve } = require("node:path");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The shell command that asks PATH where bun is.
|
|
12
|
+
*
|
|
13
|
+
* `which` does not exist in cmd or PowerShell — it throws "'which' is not
|
|
14
|
+
* recognized...", so Windows fell straight through to a list of POSIX-only
|
|
15
|
+
* paths and reported Bun missing even when it was sitting on PATH.
|
|
16
|
+
*/
|
|
17
|
+
function lookupCommand(platform) {
|
|
18
|
+
return platform === "win32" ? "where bun" : "which bun";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Fallback install locations, in probe order.
|
|
23
|
+
*
|
|
24
|
+
* HOME is usually unset on Windows, which would interpolate the literal string
|
|
25
|
+
* "undefined\.bun\..." — so the home directory is resolved per-platform rather
|
|
26
|
+
* than assumed to exist.
|
|
27
|
+
*/
|
|
28
|
+
function bunCandidates(platform, env) {
|
|
29
|
+
const home = env.HOME || env.USERPROFILE || "";
|
|
30
|
+
if (platform === "win32") {
|
|
31
|
+
return [`${home}\\.bun\\bin\\bun.exe`, `${env.LOCALAPPDATA || ""}\\bun\\bun.exe`];
|
|
32
|
+
}
|
|
33
|
+
return [`${home}/.bun/bin/bun`, "/usr/local/bin/bun", "/opt/homebrew/bin/bun"];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The install one-liner, in the shell the user is actually standing in. */
|
|
37
|
+
function installHint(platform) {
|
|
38
|
+
return platform === "win32"
|
|
39
|
+
? 'powershell -c "irm bun.sh/install.ps1 | iex"'
|
|
40
|
+
: "curl -fsSL https://bun.sh/install | bash";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function findBun(platform = process.platform, env = process.env) {
|
|
11
44
|
try {
|
|
12
|
-
const
|
|
45
|
+
const out = execSync(lookupCommand(platform), {
|
|
46
|
+
encoding: "utf-8",
|
|
47
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
48
|
+
});
|
|
49
|
+
// `where` prints EVERY match, one per line. Take the first.
|
|
50
|
+
const path = out.split(/\r?\n/)[0].trim();
|
|
13
51
|
if (path) return path;
|
|
14
52
|
} catch {}
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
`${process.env.HOME}/.bun/bin/bun`,
|
|
18
|
-
"/usr/local/bin/bun",
|
|
19
|
-
"/opt/homebrew/bin/bun",
|
|
20
|
-
];
|
|
21
|
-
for (const c of candidates) {
|
|
53
|
+
|
|
54
|
+
for (const c of bunCandidates(platform, env)) {
|
|
22
55
|
try {
|
|
23
56
|
execFileSync(c, ["--version"], { stdio: "ignore" });
|
|
24
57
|
return c;
|
|
@@ -27,29 +60,40 @@ function findBun() {
|
|
|
27
60
|
return null;
|
|
28
61
|
}
|
|
29
62
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
63
|
+
function main() {
|
|
64
|
+
const bun = findBun();
|
|
65
|
+
if (!bun) {
|
|
66
|
+
console.error(`claudish requires the Bun runtime but it was not found.
|
|
33
67
|
|
|
34
68
|
Install Bun (one command):
|
|
35
|
-
|
|
69
|
+
${installHint(process.platform)}
|
|
36
70
|
|
|
37
71
|
Then retry:
|
|
38
72
|
claudish --version
|
|
39
73
|
|
|
40
74
|
Learn more: https://bun.sh`);
|
|
41
|
-
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Exec into bun with the real entry point
|
|
79
|
+
const entry = resolve(__dirname, "..", "dist", "index.js");
|
|
80
|
+
try {
|
|
81
|
+
const result = require("node:child_process").spawnSync(bun, [entry, ...process.argv.slice(2)], {
|
|
82
|
+
stdio: "inherit",
|
|
83
|
+
env: process.env,
|
|
84
|
+
});
|
|
85
|
+
process.exit(result.status ?? 1);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error("Failed to start claudish:", err.message);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
42
90
|
}
|
|
43
91
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
process.exit(result.status ?? 1);
|
|
52
|
-
} catch (err) {
|
|
53
|
-
console.error("Failed to start claudish:", err.message);
|
|
54
|
-
process.exit(1);
|
|
92
|
+
// Running it as a program launches. Requiring it exposes the helpers so the
|
|
93
|
+
// platform branches can be tested from macOS, which is how the Windows bug
|
|
94
|
+
// stayed alive: nothing here was reachable without actually being on Windows.
|
|
95
|
+
if (require.main === module) {
|
|
96
|
+
main();
|
|
97
|
+
} else {
|
|
98
|
+
module.exports = { findBun, lookupCommand, bunCandidates, installHint };
|
|
55
99
|
}
|