clew-code 0.2.24 → 0.2.26

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.
Files changed (3) hide show
  1. package/bin/clew.cjs +45 -6
  2. package/dist/main.js +1750 -1750
  3. package/package.json +2 -2
package/bin/clew.cjs CHANGED
@@ -55,20 +55,59 @@ function printBunInstallHelp() {
55
55
  process.platform === 'win32'
56
56
  ? 'powershell -c "irm bun.sh/install.ps1 | iex"'
57
57
  : 'curl -fsSL https://bun.sh/install | bash';
58
-
59
58
  console.error('Clew requires Bun at runtime.');
60
- console.error('This npm package installs the launcher, but the CLI itself runs with Bun.');
61
- console.error('');
62
59
  console.error('Install Bun, then run `clew` again:');
63
60
  console.error(` ${installCommand}`);
64
61
  }
65
62
 
63
+ function installBunSync() {
64
+ console.error('Clew requires Bun at runtime. Installing Bun automatically...');
65
+ console.error('');
66
+
67
+ try {
68
+ if (process.platform === 'linux') {
69
+ // Try apt first for unzip, then install bun
70
+ spawnSync('sudo', ['apt-get', 'install', '-y', 'unzip'], { stdio: 'inherit', shell: false });
71
+ const result = spawnSync('bash', ['-c', 'curl -fsSL https://bun.sh/install | bash'], {
72
+ stdio: 'inherit',
73
+ shell: false,
74
+ });
75
+ return result.status === 0;
76
+ }
77
+ if (process.platform === 'darwin') {
78
+ const result = spawnSync('bash', ['-c', 'curl -fsSL https://bun.sh/install | bash'], {
79
+ stdio: 'inherit',
80
+ shell: false,
81
+ });
82
+ return result.status === 0;
83
+ }
84
+ if (process.platform === 'win32') {
85
+ const result = spawnSync('powershell', ['-c', 'irm bun.sh/install.ps1 | iex'], {
86
+ stdio: 'inherit',
87
+ shell: false,
88
+ });
89
+ return result.status === 0;
90
+ }
91
+ } catch {
92
+ // fall through to help text
93
+ }
94
+ return false;
95
+ }
96
+
66
97
  const mainJs = path.join(__dirname, '..', 'dist', 'main.js');
67
- const bunCommand = resolveBunCommand();
98
+ let bunCommand = resolveBunCommand();
68
99
 
69
100
  if (!bunCommand) {
70
- printBunInstallHelp();
71
- process.exit(1);
101
+ if (!installBunSync()) {
102
+ printBunInstallHelp();
103
+ process.exit(1);
104
+ }
105
+ // Re-resolve after install
106
+ bunCommand = resolveBunCommand();
107
+ if (!bunCommand) {
108
+ console.error('Bun installed but still not found. Try restarting your shell.');
109
+ process.exit(1);
110
+ }
72
111
  }
73
112
 
74
113
  try {