@xaidenlabs/uso 1.1.50 → 1.1.53

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.50",
3
+ "version": "1.1.53",
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"
@@ -15,14 +15,18 @@ const { installWsl } = require('../platforms/wsl');
15
15
  const init = async (component, options) => {
16
16
  const platform = os.platform();
17
17
 
18
- // Check for Stealth WSL Mode
19
- if (options && options.wsl) {
20
- if (platform !== 'win32') {
21
- log.error("❌ WSL Stealth Mode is only available on Windows.");
18
+ // --- AUTO-DETECT: On Windows, silently use WSL Stealth Mode if available ---
19
+ if (platform === 'win32') {
20
+ const forceWsl = options && options.wsl;
21
+ // Check if WSL + Ubuntu is available (quick check: wsl -d Ubuntu -e true)
22
+ const wslCheck = shell.exec('wsl -d Ubuntu -e true', { silent: true });
23
+ const wslAvailable = wslCheck.code === 0;
24
+
25
+ if (forceWsl || wslAvailable) {
26
+ await installWsl();
22
27
  return;
23
28
  }
24
- await installWsl();
25
- return;
29
+ // If WSL not available and --wsl not forced, fall through to native install
26
30
  }
27
31
 
28
32
  if (component) {
@@ -74,88 +74,149 @@ const installWsl = async () => {
74
74
 
75
75
  log.info("⚙️ Initializing Uso Engine environment...");
76
76
 
77
- const setupScript = `
78
- #!/bin/bash
79
- set -e
80
-
81
- # 1. Hush Login
82
- touch ~/.hushlogin
83
-
84
- # 2. Update & Install Build Dependencies (ALWAYS check for cc linker)
85
- if ! command -v cc &> /dev/null || ! command -v pkg-config &> /dev/null; then
86
- echo "Installing build tools..."
87
- sudo apt-get update -y && sudo apt-get install -y curl build-essential pkg-config libssl-dev libudev-dev
88
- fi
89
-
90
- # 3. Install Rust
91
- if ! command -v cargo &> /dev/null; then
92
- echo "Installing Rust..."
93
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
94
- fi
95
- # Always source cargo env for subsequent steps
77
+ // --- PHASE 1: System Dependencies (as root, no sudo needed) ---
78
+ const rootScript = `
79
+ #!/bin/bash
80
+ set -e
81
+ export DEBIAN_FRONTEND=noninteractive
82
+
83
+ if ! command -v cc &> /dev/null || ! command -v pkg-config &> /dev/null; then
84
+ echo "📦 Installing system build tools..."
85
+ apt-get update -y -qq
86
+ apt-get install -y -qq curl build-essential pkg-config libssl-dev libudev-dev
87
+ echo "✅ Build tools installed."
88
+ else
89
+ echo "✅ Build tools already present."
90
+ fi
91
+ `.replace(/\r\n/g, '\n');
92
+
93
+ const rootScriptPath = path.join(process.cwd(), 'uso_root_setup.sh');
94
+ fs.writeFileSync(rootScriptPath, rootScript);
95
+ const wslRootScriptPath = toWslPath(rootScriptPath);
96
+
97
+ const spin1 = spinner('Phase 1/2: Installing system dependencies...').start();
98
+ const rootRes = shell.exec(`wsl -d Ubuntu -u root -e bash "${wslRootScriptPath}"`);
99
+ fs.unlinkSync(rootScriptPath);
100
+
101
+ if (rootRes.code !== 0) {
102
+ spin1.fail('System dependency installation failed.');
103
+ log.error(rootRes.stderr || 'Unknown error during root setup.');
104
+ return false;
105
+ }
106
+ spin1.succeed('System dependencies ready.');
107
+
108
+ // --- PHASE 2: User Tools (Rust, Solana, Anchor as normal user) ---
109
+ const userScript = `
110
+ #!/bin/bash
111
+ # NO set -e — we handle errors per-step
112
+ FAILURES=""
113
+
114
+ # Hush login
115
+ touch ~/.hushlogin
116
+
117
+ # --- Rust ---
118
+ source $HOME/.cargo/env 2>/dev/null || true
119
+ if ! command -v cargo &> /dev/null; then
120
+ echo "🦀 Installing Rust..."
121
+ if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; then
96
122
  source $HOME/.cargo/env 2>/dev/null || true
97
-
98
- # 4. Install Solana
99
- if ! command -v solana &> /dev/null; then
100
- echo "Installing Solana CLI..."
101
- # Try official installer first, fall back to Agave
102
- if ! sh -c "$(curl -sSfL https://release.solana.com/stable/install)" 2>/dev/null; then
103
- echo "Retrying with Agave installer..."
104
- sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)" 2>/dev/null || true
105
- fi
106
- export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
123
+ echo "✅ Rust installed."
124
+ else
125
+ FAILURES="$FAILURES rust"
126
+ echo " Rust installation failed."
127
+ fi
128
+ else
129
+ echo " Rust already installed."
130
+ fi
131
+ source $HOME/.cargo/env 2>/dev/null || true
132
+
133
+ # --- Solana ---
134
+ export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
135
+ if ! command -v solana &> /dev/null; then
136
+ echo "☀️ Installing Solana CLI..."
137
+ if sh -c "$(curl -sSfL https://release.solana.com/stable/install)" 2>/dev/null; then
138
+ echo "✅ Solana installed."
139
+ elif sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)" 2>/dev/null; then
140
+ echo "✅ Solana installed (via Agave)."
141
+ else
142
+ FAILURES="$FAILURES solana"
143
+ echo "⚠️ Solana install timed out. Run 'uso setup' again later to retry."
144
+ fi
145
+ export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
146
+ else
147
+ echo "✅ Solana already installed."
148
+ fi
149
+
150
+ # --- Anchor (AVM) ---
151
+ if ! command -v anchor &> /dev/null; then
152
+ # Install AVM if not present
153
+ if ! command -v avm &> /dev/null; then
154
+ echo "⚓ Installing AVM (compiling from source, ~5 min)..."
155
+ if cargo install --git https://github.com/coral-xyz/anchor avm --locked --force; then
156
+ echo "✅ AVM compiled."
157
+ else
158
+ FAILURES="$FAILURES avm"
159
+ echo "❌ AVM compilation failed."
107
160
  fi
108
-
109
- # 5. Install Anchor (AVM)
110
- if ! command -v avm &> /dev/null; then
111
- echo "Installing AVM..."
112
- cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
113
- avm install latest
161
+ else
162
+ echo "✅ AVM already installed."
163
+ fi
164
+
165
+ # Install Anchor via AVM (try binary first, then compile from source)
166
+ if command -v avm &> /dev/null; then
167
+ echo "⚓ Installing Anchor CLI..."
168
+ if avm install latest 2>/dev/null; then
114
169
  avm use latest
170
+ echo "✅ Anchor installed."
171
+ else
172
+ echo "⚠️ Binary download timed out. Building from source (this takes ~10 min)..."
173
+ if avm install latest --force 2>/dev/null; then
174
+ avm use latest
175
+ echo "✅ Anchor built from source."
176
+ else
177
+ FAILURES="$FAILURES anchor"
178
+ echo "⚠️ Anchor install timed out. Run 'uso setup' again later."
179
+ fi
115
180
  fi
116
-
117
- echo "✅ Uso Engine Setup Complete."
118
- `;
119
-
120
- // Write script to a temporary file in Windows (which is mounted in WSL)
121
- const scriptPath = path.join(process.cwd(), 'setup_wsl.sh');
122
- fs.writeFileSync(scriptPath, setupScript);
123
-
124
- // Convert path to WSL format
125
- const wslScriptPath = toWslPath(scriptPath);
126
-
127
- // Run the script inside WSL
128
- // We pipe the script content to bash to avoid permission issues with the file itself
129
- // Or just run it. Let's run it.
130
-
131
- const spin = spinner('Running Linux setup script (this takes a while)...').start();
132
-
133
- // Ensure line endings are LF
134
- const linuxScript = setupScript.replace(/\r\n/g, '\n');
135
- fs.writeFileSync(scriptPath, linuxScript);
136
-
137
- const res = shell.exec(`wsl -d Ubuntu -e bash "${wslScriptPath}"`);
138
-
139
- // Clean up
140
- fs.unlinkSync(scriptPath);
141
-
142
- if (res.code === 0) {
143
- spin.succeed('Linux environment configured successfully.');
144
-
145
- // 4. Set "Stealth Mode" config (could be a local file or env var)
146
- // For now, we assume if the user ran --wsl, they want to use it.
147
- // We could create a .uso-config.json
148
- const configPath = path.join(os.homedir(), '.uso-config.json');
149
- const config = { mode: 'wsl', distro: 'Ubuntu' };
150
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
151
-
152
- log.success("✅ Stealth Mode Enabled. 'uso' commands will now run via WSL.");
153
- return true;
181
+ fi
182
+ else
183
+ echo "✅ Anchor already installed."
184
+ fi
185
+
186
+ # --- Report ---
187
+ if [ -z "$FAILURES" ]; then
188
+ echo "✅ Uso Engine Setup Complete."
189
+ exit 0
190
+ else
191
+ echo ""
192
+ echo "⚠️ Partial setup. Failed:$FAILURES"
193
+ echo "Run 'uso setup' again to retry failed components."
194
+ exit 1
195
+ fi
196
+ `.replace(/\r\n/g, '\n');
197
+
198
+ const userScriptPath = path.join(process.cwd(), 'uso_user_setup.sh');
199
+ fs.writeFileSync(userScriptPath, userScript);
200
+ const wslUserScriptPath = toWslPath(userScriptPath);
201
+
202
+ const spin2 = spinner('Phase 2/2: Installing Rust, Solana, Anchor (this takes a while)...').start();
203
+ const userRes = shell.exec(`wsl -d Ubuntu -e bash "${wslUserScriptPath}"`);
204
+ fs.unlinkSync(userScriptPath);
205
+
206
+ if (userRes.code === 0) {
207
+ spin2.succeed('Uso Engine configured successfully.');
154
208
  } else {
155
- spin.fail('Setup script failed.');
156
- log.error(res.stderr);
157
- return false;
209
+ spin2.warn('Uso Engine partially configured (some downloads timed out).');
210
+ log.info("👉 Run 'uso setup' again to retry failed components.");
158
211
  }
212
+
213
+ // Always set stealth mode config — even partial setup enables routing
214
+ const configPath = path.join(os.homedir(), '.uso-config.json');
215
+ const config = { mode: 'wsl', distro: 'Ubuntu' };
216
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
217
+
218
+ log.success("✅ Stealth Mode Enabled. 'uso' commands will now run via WSL.");
219
+ return true;
159
220
  };
160
221
 
161
222
  const hideFromWindowsTerminal = () => {