thaddeus 1.0.15 → 1.0.16
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/thaddeus.js +61 -8
- package/package.json +1 -1
package/bin/thaddeus.js
CHANGED
|
@@ -14,17 +14,70 @@ const ROOT = path.resolve(__dirname, '..');
|
|
|
14
14
|
// ── Find Bun ──────────────────────────────────────────────
|
|
15
15
|
const isWin = process.platform === 'win32';
|
|
16
16
|
const bunName = isWin ? 'bun.exe' : 'bun';
|
|
17
|
-
let bunPath = path.join(os.homedir(), '.bun', 'bin', bunName);
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
//
|
|
18
|
+
function findBun() {
|
|
19
|
+
// 1. ~/.bun/bin/bun (macOS/Linux standard, also some Windows setups)
|
|
20
|
+
const homeBun = path.join(os.homedir(), '.bun', 'bin', bunName);
|
|
21
|
+
if (fs.existsSync(homeBun)) return homeBun;
|
|
22
|
+
|
|
23
|
+
// 2. %LOCALAPPDATA%\bun\bun.exe (Windows official install location)
|
|
24
|
+
if (isWin) {
|
|
25
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
|
26
|
+
const winBun = path.join(localAppData, 'bun', bunName);
|
|
27
|
+
if (fs.existsSync(winBun)) return winBun;
|
|
28
|
+
// Also check %USERPROFILE%\.bun\bin
|
|
29
|
+
const userBun = path.join(os.homedir(), '.bun', 'bin', bunName);
|
|
30
|
+
if (fs.existsSync(userBun)) return userBun;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 3. System PATH
|
|
34
|
+
try {
|
|
35
|
+
const found = execSync(isWin ? 'where bun' : 'which bun', {
|
|
36
|
+
encoding: 'utf-8',
|
|
37
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
38
|
+
}).trim().split('\n')[0];
|
|
39
|
+
if (found && fs.existsSync(found)) return found;
|
|
40
|
+
} catch { /* not in PATH */ }
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function installBun() {
|
|
46
|
+
console.log('\x1b[33mBun not found — installing automatically...\x1b[0m');
|
|
21
47
|
try {
|
|
22
|
-
bunPath = execSync(isWin ? 'where bun' : 'which bun', { encoding: 'utf-8' }).trim().split('\n')[0];
|
|
23
|
-
} catch {
|
|
24
|
-
console.error('\x1b[31mERROR: Bun not found.\x1b[0m');
|
|
25
|
-
console.error('Install Bun first:');
|
|
26
48
|
if (isWin) {
|
|
27
|
-
|
|
49
|
+
// Use PowerShell with bypassed execution policy to install Bun
|
|
50
|
+
execSync(
|
|
51
|
+
'powershell -ExecutionPolicy Bypass -Command "irm bun.sh/install.ps1 | iex"',
|
|
52
|
+
{ stdio: 'inherit', timeout: 120000 }
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
execSync('curl -fsSL https://bun.sh/install | bash', {
|
|
56
|
+
stdio: 'inherit',
|
|
57
|
+
timeout: 120000,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Re-search after install
|
|
61
|
+
return findBun();
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error('\x1b[31mAuto-install failed.\x1b[0m');
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let bunPath = findBun();
|
|
69
|
+
|
|
70
|
+
if (!bunPath) {
|
|
71
|
+
// Try auto-install
|
|
72
|
+
bunPath = installBun();
|
|
73
|
+
if (!bunPath) {
|
|
74
|
+
console.error('\x1b[31mERROR: Bun not found and auto-install failed.\x1b[0m');
|
|
75
|
+
console.error('Install Bun manually:');
|
|
76
|
+
if (isWin) {
|
|
77
|
+
console.error(' 1. Open PowerShell as Administrator');
|
|
78
|
+
console.error(' 2. Run: powershell -ExecutionPolicy Bypass -c "irm bun.sh/install.ps1 | iex"');
|
|
79
|
+
console.error(' 3. Close and reopen your terminal');
|
|
80
|
+
console.error(' 4. Run: thaddeus');
|
|
28
81
|
} else {
|
|
29
82
|
console.error(' curl -fsSL https://bun.sh/install | bash');
|
|
30
83
|
}
|