@xaidenlabs/uso 1.1.69 → 1.1.70

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaidenlabs/uso",
3
- "version": "1.1.69",
3
+ "version": "1.1.70",
4
4
  "description": "Universal Solana Development Toolchain. Native or Stealth WSL Mode. Build, test, and deploy without the friction.",
5
5
  "bin": {
6
6
  "uso": "bin/index.js"
@@ -1,241 +1,250 @@
1
- const os = require('os');
2
- const shell = require('shelljs');
3
- const { log, spinner } = require('../utils/logger');
4
- const { installWindows } = require('../platforms/windows');
5
- const { installMacOS } = require('../platforms/macos');
6
- const { installLinux } = require('../platforms/linux');
7
- const { getCargoBinPath } = require('../utils/paths');
8
- const { checkRust, checkSolana, checkAnchor } = require('./doctor');
9
- const { ensureWalletInteractive } = require('../utils/wallet');
10
- const path = require('path');
11
- const fs = require('fs');
12
-
13
- const { installWsl, installWslFeature } = require('../platforms/wsl');
1
+ const os = require("os");
2
+ const shell = require("shelljs");
3
+ const { log, spinner } = require("../utils/logger");
4
+ const { installWindows } = require("../platforms/windows");
5
+ const { installMacOS } = require("../platforms/macos");
6
+ const { installLinux } = require("../platforms/linux");
7
+ const { getCargoBinPath } = require("../utils/paths");
8
+ const { checkRust, checkSolana, checkAnchor } = require("./doctor");
9
+ const { ensureWalletInteractive } = require("../utils/wallet");
10
+ const path = require("path");
11
+ const fs = require("fs");
12
+
13
+ const { installWsl, installWslFeature } = require("../platforms/wsl");
14
14
 
15
15
  const init = async (component, options) => {
16
- const platform = os.platform();
16
+ const platform = os.platform();
17
17
 
18
- // --- On Windows, ALWAYS use the WSL path ---
19
- if (platform === 'win32') {
20
- const hasWslBinary = !!shell.which('wsl');
18
+ // --- On Windows, ALWAYS use the WSL path ---
19
+ if (platform === "win32") {
20
+ const hasWslBinary = !!shell.which("wsl");
21
21
 
22
- if (!hasWslBinary) {
23
- // WSL is not installed at all — request admin elevation to enable the feature
24
- log.header("🐧 Windows Subsystem for Linux (WSL) not found.");
25
- log.info("šŸ›”ļø Requesting administrator permission to install WSL...");
26
- log.info("šŸ‘‰ Please click 'Yes' in the UAC popup that appears to allow this.");
27
- console.log("");
22
+ if (!hasWslBinary) {
23
+ // WSL is not installed at all — request admin elevation to enable the feature
24
+ log.header("🐧 Windows Subsystem for Linux (WSL) not found.");
25
+ log.info("šŸ›”ļø Requesting administrator permission to install WSL...");
26
+ log.info(
27
+ "šŸ‘‰ Please click 'Yes' in the UAC popup that appears to allow this.",
28
+ );
29
+ console.log("");
28
30
 
29
- const wslInstalled = await installWslFeature();
31
+ const wslInstalled = await installWslFeature();
30
32
 
31
- if (!wslInstalled && !shell.which('wsl')) {
32
- // installWslFeature already printed the relevant error/reboot message
33
- return;
34
- }
35
-
36
- // If wsl.exe is now available, continue straight into the Ubuntu setup.
37
- // On some machines this still needs a reboot, but we let the distro phase
38
- // run immediately so setup can continue as far as the system allows.
39
- }
40
-
41
- // WSL binary is present — run the full WSL toolchain install
42
- await installWsl();
33
+ if (!wslInstalled && !shell.which("wsl")) {
34
+ // installWslFeature already printed the relevant error/reboot message
43
35
  return;
44
- }
45
-
46
- if (component) {
47
- component = component.toLowerCase();
48
- log.info(`šŸŽÆ Targeted installation: ${component}`);
49
-
50
- if (component === 'rust') {
51
- if (checkRust(true)) {
52
- log.success("āœ… Rust is already installed.");
53
- return;
54
- }
55
- log.info("šŸ¦€ Installing Rust...");
56
- let success = false;
57
- if (platform === 'win32') success = await installWindows(true, false);
58
- else if (platform === 'darwin') success = await installMacOS(true, false);
59
- else success = await installLinux(true, false);
60
-
61
- if (success) log.success("āœ… Rust installed successfully.");
62
- else log.error("āŒ Rust installation failed.");
63
- return;
64
- }
65
-
66
- if (component === 'solana') {
67
- if (checkSolana(true)) {
68
- log.success("āœ… Solana CLI is already installed.");
69
- return;
70
- }
71
- log.info("ā˜€ļø Installing Solana CLI...");
72
- let success = false;
73
- if (platform === 'win32') success = await installWindows(false, true);
74
- else if (platform === 'darwin') success = await installMacOS(false, true);
75
- else success = await installLinux(false, true);
76
-
77
- if (success) log.success("āœ… Solana CLI installed successfully.");
78
- else log.error("āŒ Solana CLI installation failed.");
79
- return;
80
- }
36
+ }
81
37
 
82
- if (component === 'anchor') {
83
- if (checkAnchor(true)) {
84
- log.success("āœ… Anchor is already installed.");
85
- return;
86
- }
87
- // Fall through to Anchor installation logic below, but skip others
88
- } else if (component !== 'anchor') { // If it's not rust, solana, or anchor
89
- log.error(`āŒ Unknown component: ${component}. Available: rust, solana, anchor`);
90
- return;
91
- }
38
+ // If wsl.exe is now available, continue straight into the Ubuntu setup.
39
+ // On some machines this still needs a reboot, but we let the distro phase
40
+ // run immediately so setup can continue as far as the system allows.
92
41
  }
93
42
 
94
- // --- FULL INSTALLATION / ANCHOR ONLY FLOW ---
43
+ // WSL binary is present — run the full WSL toolchain install
44
+ await installWsl();
45
+ return;
46
+ }
95
47
 
96
- // If authenticating for just Anchor, we assume Rust/Solana are prerequisites or we skip them
97
- let installRust = !checkRust(true);
98
- let installSolana = !checkSolana(true);
99
- const hasAnchor = checkAnchor(true);
48
+ if (component) {
49
+ component = component.toLowerCase();
50
+ log.info(`šŸŽÆ Targeted installation: ${component}`);
100
51
 
101
- if (component === 'anchor') {
102
- // ensuring prerequisites for anchor
103
- if (installRust) {
104
- log.warn("āš ļø Rust is required for Anchor but not installed.");
105
- // asking or just failing? For granular, let's just fail or warn.
106
- // But let's proceed to install Anchor logic which handles cargo check
107
- }
108
- installRust = false; // Don't run platform installers for these
109
- installSolana = false;
52
+ if (component === "rust") {
53
+ if (checkRust(true)) {
54
+ log.success("āœ… Rust is already installed.");
55
+ return;
56
+ }
57
+ log.info("šŸ¦€ Installing Rust...");
58
+ let success = false;
59
+ if (platform === "win32") success = await installWindows(true, false);
60
+ else if (platform === "darwin") success = await installMacOS(true, false);
61
+ else success = await installLinux(true, false);
62
+
63
+ if (success) log.success("āœ… Rust installed successfully.");
64
+ else log.error("āŒ Rust installation failed.");
65
+ return;
110
66
  }
111
67
 
112
- // Validating state for full install
113
- if (!component && !installRust && !installSolana && hasAnchor) {
114
- log.success("šŸŽ‰ Everything is already installed!");
115
- await ensureWalletInteractive();
68
+ if (component === "solana") {
69
+ if (checkSolana(true)) {
70
+ log.success("āœ… Solana CLI is already installed.");
116
71
  return;
72
+ }
73
+ log.info("ā˜€ļø Installing Solana CLI...");
74
+ let success = false;
75
+ if (platform === "win32") success = await installWindows(false, true);
76
+ else if (platform === "darwin") success = await installMacOS(false, true);
77
+ else success = await installLinux(false, true);
78
+
79
+ if (success) log.success("āœ… Solana CLI installed successfully.");
80
+ else log.error("āŒ Solana CLI installation failed.");
81
+ return;
117
82
  }
118
83
 
119
- if (!component) {
120
- log.header("šŸ” Checking current environment state...");
121
- log.info(`\nšŸ“¦ Missing components:`);
122
- if (installRust) log.error(" - Rust");
123
- if (installSolana) log.error(" - Solana CLI");
124
- if (!hasAnchor) log.error(" - Anchor");
125
- console.log("");
126
-
127
- const spin = spinner('Starting Installation...').start();
128
-
129
- try {
130
- let success = false;
131
-
132
- if (platform === 'win32') {
133
- spin.stop();
134
- success = await installWindows(installRust, installSolana);
135
- } else if (platform === 'darwin') {
136
- spin.stop();
137
- success = await installMacOS(installRust, installSolana);
138
- } else {
139
- spin.stop();
140
- success = await installLinux(installRust, installSolana);
141
- }
142
-
143
- if (!success) {
144
- log.error("āŒ Platform-specific installation failed.");
145
- return;
146
- }
147
- } catch (e) {
148
- spin.stop();
149
- log.error(e.message);
150
- return;
151
- }
84
+ if (component === "anchor") {
85
+ if (checkAnchor(true)) {
86
+ log.success("āœ… Anchor is already installed.");
87
+ return;
88
+ }
89
+ // Fall through to Anchor installation logic below, but skip others
90
+ } else if (component !== "anchor") {
91
+ // If it's not rust, solana, or anchor
92
+ log.error(
93
+ `āŒ Unknown component: ${component}. Available: rust, solana, anchor`,
94
+ );
95
+ return;
152
96
  }
97
+ }
153
98
 
154
- // Install Anchor (Universal) - Runs if component='anchor' OR full install
155
- if (!hasAnchor && (!component || component === 'anchor')) {
156
- log.info("āš“ Installing Anchor Framework...");
99
+ // --- FULL INSTALLATION / ANCHOR ONLY FLOW ---
157
100
 
158
- const cargoBin = getCargoBinPath();
159
- const cargoExe = platform === 'win32' ? 'cargo.exe' : 'cargo';
160
- const avmExe = platform === 'win32' ? 'avm.exe' : 'avm';
101
+ // If authenticating for just Anchor, we assume Rust/Solana are prerequisites or we skip them
102
+ let installRust = !checkRust(true);
103
+ let installSolana = !checkSolana(true);
104
+ const hasAnchor = checkAnchor(true);
161
105
 
162
- // Resolve cargo command
163
- let cargoCmd = cargoExe;
164
- if (fs.existsSync(path.join(cargoBin, cargoExe))) {
165
- cargoCmd = `"${path.join(cargoBin, cargoExe)}"`;
166
- } else if (!installRust && checkRust(true)) {
167
- cargoCmd = 'cargo';
168
- }
106
+ if (component === "anchor") {
107
+ // ensuring prerequisites for anchor
108
+ if (installRust) {
109
+ log.warn("āš ļø Rust is required for Anchor but not installed.");
110
+ // asking or just failing? For granular, let's just fail or warn.
111
+ // But let's proceed to install Anchor logic which handles cargo check
112
+ }
113
+ installRust = false; // Don't run platform installers for these
114
+ installSolana = false;
115
+ }
116
+
117
+ // Validating state for full install
118
+ if (!component && !installRust && !installSolana && hasAnchor) {
119
+ log.success("šŸŽ‰ Everything is already installed!");
120
+ await ensureWalletInteractive();
121
+ return;
122
+ }
123
+
124
+ if (!component) {
125
+ log.header("šŸ” Checking current environment state...");
126
+ log.info(`\nšŸ“¦ Missing components:`);
127
+ if (installRust) log.error(" - Rust");
128
+ if (installSolana) log.error(" - Solana CLI");
129
+ if (!hasAnchor) log.error(" - Anchor");
130
+ console.log("");
131
+
132
+ const spin = spinner("Starting Installation...").start();
133
+
134
+ try {
135
+ let success = false;
136
+
137
+ if (platform === "win32") {
138
+ spin.stop();
139
+ success = await installWindows(installRust, installSolana);
140
+ } else if (platform === "darwin") {
141
+ spin.stop();
142
+ success = await installMacOS(installRust, installSolana);
143
+ } else {
144
+ spin.stop();
145
+ success = await installLinux(installRust, installSolana);
146
+ }
147
+
148
+ if (!success) {
149
+ log.error("āŒ Platform-specific installation failed.");
150
+ return;
151
+ }
152
+ } catch (e) {
153
+ spin.stop();
154
+ log.error(e.message);
155
+ return;
156
+ }
157
+ }
158
+
159
+ // Install Anchor (Universal) - Runs if component='anchor' OR full install
160
+ if (!hasAnchor && (!component || component === "anchor")) {
161
+ log.info("āš“ Installing Anchor Framework...");
162
+
163
+ const cargoBin = getCargoBinPath();
164
+ const cargoExe = platform === "win32" ? "cargo.exe" : "cargo";
165
+ const avmExe = platform === "win32" ? "avm.exe" : "avm";
166
+
167
+ // Resolve cargo command
168
+ let cargoCmd = cargoExe;
169
+ if (fs.existsSync(path.join(cargoBin, cargoExe))) {
170
+ cargoCmd = `"${path.join(cargoBin, cargoExe)}"`;
171
+ } else if (!installRust && checkRust(true)) {
172
+ cargoCmd = "cargo";
173
+ }
169
174
 
170
- log.subHeader(`Using cargo: ${cargoCmd}`);
171
-
172
- // Try installing AVM first (Preferred)
173
- log.info(" Attempting AVM install...");
174
- const avmInstall = shell.exec(`${cargoCmd} install --git https://github.com/coral-xyz/anchor avm --locked --force`);
175
-
176
- if (avmInstall.code === 0) {
177
- // Use AVM
178
- let avmCmd = avmExe;
179
- if (fs.existsSync(path.join(cargoBin, avmExe))) {
180
- avmCmd = `"${path.join(cargoBin, avmExe)}"`;
181
- }
182
-
183
- log.subHeader(`Using avm: ${avmCmd}`);
184
- const avmUse = shell.exec(`${avmCmd} install latest`);
185
-
186
- // Detect Permission Error for AVM
187
- if (avmUse.code !== 0) {
188
- const output = avmUse.stderr + avmUse.stdout;
189
- if (output.includes("os error 1314") && platform === 'win32') {
190
- log.warn("āš ļø AVM Permission denied (Symlink creation failed).");
191
- log.info("šŸ›”ļø Triggering Run as Administrator (UAC) for Anchor...");
192
- const absAvmPath = path.join(cargoBin, avmExe);
193
- const elevateCmd = `powershell -Command "Start-Process -FilePath '${absAvmPath}' -ArgumentList 'install latest' -Verb RunAs -Wait; Start-Process -FilePath '${absAvmPath}' -ArgumentList 'use latest' -Verb RunAs -Wait"`;
194
- const elevatedRun = shell.exec(elevateCmd);
195
-
196
- if (elevatedRun.code === 0) {
197
- log.success("āœ… Anchor installed (Elevated).");
198
- } else {
199
- log.error("āŒ Elevated installation failed. Trying fallback...");
200
- fallbackDirectInstall(cargoCmd);
201
- }
202
-
203
- } else {
204
- log.warn("āš ļø AVM installation failed. Trying fallback...");
205
- fallbackDirectInstall(cargoCmd);
206
- }
207
- } else {
208
- shell.exec(`${avmCmd} use latest`);
209
- log.success("āœ… Anchor installed.");
210
- }
175
+ log.subHeader(`Using cargo: ${cargoCmd}`);
176
+
177
+ // Try installing AVM first (Preferred)
178
+ log.info(" Attempting AVM install...");
179
+ const avmInstall = shell.exec(
180
+ `${cargoCmd} install --git https://github.com/coral-xyz/anchor avm --locked --force`,
181
+ );
182
+
183
+ if (avmInstall.code === 0) {
184
+ // Use AVM
185
+ let avmCmd = avmExe;
186
+ if (fs.existsSync(path.join(cargoBin, avmExe))) {
187
+ avmCmd = `"${path.join(cargoBin, avmExe)}"`;
188
+ }
189
+
190
+ log.subHeader(`Using avm: ${avmCmd}`);
191
+ const avmUse = shell.exec(`${avmCmd} install latest`);
192
+
193
+ // Detect Permission Error for AVM
194
+ if (avmUse.code !== 0) {
195
+ const output = avmUse.stderr + avmUse.stdout;
196
+ if (output.includes("os error 1314") && platform === "win32") {
197
+ log.warn("āš ļø AVM Permission denied (Symlink creation failed).");
198
+ log.info("šŸ›”ļø Triggering Run as Administrator (UAC) for Anchor...");
199
+ const absAvmPath = path.join(cargoBin, avmExe);
200
+ const elevateCmd = `powershell -Command "Start-Process -FilePath '${absAvmPath}' -ArgumentList 'install latest' -Verb RunAs -Wait; Start-Process -FilePath '${absAvmPath}' -ArgumentList 'use latest' -Verb RunAs -Wait"`;
201
+ const elevatedRun = shell.exec(elevateCmd);
202
+
203
+ if (elevatedRun.code === 0) {
204
+ log.success("āœ… Anchor installed (Elevated).");
205
+ } else {
206
+ log.error("āŒ Elevated installation failed. Trying fallback...");
207
+ fallbackDirectInstall(cargoCmd);
208
+ }
211
209
  } else {
212
- log.error("āŒ Failed to install AVM via Cargo.");
213
- return;
210
+ log.warn("āš ļø AVM installation failed. Trying fallback...");
211
+ fallbackDirectInstall(cargoCmd);
214
212
  }
215
- } else if (component === 'anchor' && hasAnchor) {
216
- log.success("āœ… Anchor is already installed.");
213
+ } else {
214
+ shell.exec(`${avmCmd} use latest`);
215
+ log.success("āœ… Anchor installed.");
216
+ }
217
+ } else {
218
+ log.error("āŒ Failed to install AVM via Cargo.");
219
+ return;
217
220
  }
218
-
219
-
220
- if (!component) {
221
- log.header('\nāœ… Uso Setup Complete!');
222
- await ensureWalletInteractive();
223
-
224
- if (installRust || installSolana || !hasAnchor) {
225
- log.warn('šŸ‘‰ Please RESTART your terminal/VS Code to ensure all PATH variables are updated.');
226
- }
227
- log.info('šŸš€ Try running: uso verify');
221
+ } else if (component === "anchor" && hasAnchor) {
222
+ log.success("āœ… Anchor is already installed.");
223
+ }
224
+
225
+ if (!component) {
226
+ log.header("\nāœ… Uso Setup Complete!");
227
+ await ensureWalletInteractive();
228
+
229
+ if (installRust || installSolana || !hasAnchor) {
230
+ log.warn(
231
+ "šŸ‘‰ Please RESTART your terminal/VS Code to ensure all PATH variables are updated.",
232
+ );
228
233
  }
234
+ log.info("šŸš€ Try running: uso verify");
235
+ }
229
236
  };
230
237
 
231
238
  const fallbackDirectInstall = (cargoCmd) => {
232
- log.info("šŸ‘‰ Falling back to direct 'anchor-cli' installation...");
233
- const directInstall = shell.exec(`${cargoCmd} install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force`);
234
- if (directInstall.code !== 0) {
235
- log.error("āŒ Failed to install Anchor via fallback method.");
236
- } else {
237
- log.success("āœ… Anchor installed (Direct Cargo).");
238
- }
239
+ log.info("šŸ‘‰ Falling back to direct 'anchor-cli' installation...");
240
+ const directInstall = shell.exec(
241
+ `${cargoCmd} install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force`,
242
+ );
243
+ if (directInstall.code !== 0) {
244
+ log.error("āŒ Failed to install Anchor via fallback method.");
245
+ } else {
246
+ log.success("āœ… Anchor installed (Direct Cargo).");
247
+ }
239
248
  };
240
249
 
241
250
  module.exports = { init };
@@ -281,14 +281,54 @@ source $HOME/.cargo/env 2>/dev/null || true
281
281
  export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
282
282
  if ! command -v solana &> /dev/null; then
283
283
  echo "ā˜€ļø Installing Solana CLI..."
284
- if run_with_progress "ā˜€ļø Installing Solana CLI..." 35 60 bash -lc 'sh -c "$(curl -sSfL https://release.solana.com/stable/install)"'; then
284
+
285
+ # Helper to download with retries and proper SSL handling
286
+ install_solana_with_retry() {
287
+ local url="$1"
288
+ local description="$2"
289
+ local max_attempts=3
290
+ local attempt=1
291
+
292
+ while [ $attempt -le $max_attempts ]; do
293
+ if [ $attempt -gt 1 ]; then
294
+ echo " Retry attempt $attempt/$max_attempts..."
295
+ sleep 2
296
+ fi
297
+
298
+ # Download installer script with SSL options and timeout
299
+ if curl --proto '=https' --tlsv1.2 -sSf --max-time 60 --connect-timeout 10 \
300
+ --cacert /etc/ssl/certs/ca-certificates.crt \
301
+ "$url" > /tmp/solana_install.sh 2>/dev/null; then
302
+ # Execute the downloaded script
303
+ if bash /tmp/solana_install.sh; then
304
+ rm -f /tmp/solana_install.sh
305
+ return 0
306
+ fi
307
+ fi
308
+
309
+ attempt=$((attempt + 1))
310
+ done
311
+
312
+ rm -f /tmp/solana_install.sh
313
+ return 1
314
+ }
315
+
316
+ solana_installed=0
317
+
318
+ # Try official Solana release
319
+ if install_solana_with_retry "https://release.solana.com/stable/install" "Solana"; then
320
+ solana_installed=1
285
321
  echo "āœ… Solana installed."
286
- elif run_with_progress "ā˜€ļø Installing Solana CLI..." 35 60 bash -lc 'sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"'; then
322
+ # Fallback to Agave (community-maintained)
323
+ elif install_solana_with_retry "https://release.anza.xyz/stable/install" "Agave"; then
324
+ solana_installed=1
287
325
  echo "āœ… Solana installed (via Agave)."
288
326
  else
289
327
  FAILURES="$FAILURES solana"
290
- echo "āš ļø Solana install timed out. Run 'uso setup' again later to retry."
328
+ echo "āš ļø Solana install failed after retries. Network or certificate issue detected."
329
+ echo " Run 'uso init' again to retry."
291
330
  fi
331
+
292
332
  export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
293
333
  else
294
334
  echo "āœ… Solana already installed."