@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 +1 -1
- package/src/commands/init.js +10 -6
- package/src/platforms/wsl.js +137 -76
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -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
|
-
//
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
return;
|
|
29
|
+
// If WSL not available and --wsl not forced, fall through to native install
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
if (component) {
|
package/src/platforms/wsl.js
CHANGED
|
@@ -74,88 +74,149 @@ const installWsl = async () => {
|
|
|
74
74
|
|
|
75
75
|
log.info("⚙️ Initializing Uso Engine environment...");
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
156
|
-
log.
|
|
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 = () => {
|