@xaidenlabs/uso 1.1.79 → 1.1.81
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/index.js +2 -0
- package/package.json +1 -1
- package/src/commands/init.js +16 -0
- package/src/commands/uninstall.js +57 -26
- package/src/platforms/wsl.js +27 -1
package/bin/index.js
CHANGED
|
@@ -16,12 +16,14 @@ program
|
|
|
16
16
|
.command('init [component]')
|
|
17
17
|
.alias('install')
|
|
18
18
|
.description('Install Rust, Solana CLI, Anchor Framework, or specific component (rust, solana, anchor)')
|
|
19
|
+
.option('-g, --global', 'Compatibility flag (ignored). uso manages toolchain components, not npm packages')
|
|
19
20
|
.option('--wsl', 'Install in Stealth WSL Mode (Windows Only)')
|
|
20
21
|
.action(init);
|
|
21
22
|
|
|
22
23
|
program
|
|
23
24
|
.command('setup [component]')
|
|
24
25
|
.description('Alias for init (Install components)')
|
|
26
|
+
.option('-g, --global', 'Compatibility flag (ignored). uso manages toolchain components, not npm packages')
|
|
25
27
|
.option('--wsl', 'Install in Stealth WSL Mode (Windows Only)')
|
|
26
28
|
.action(init);
|
|
27
29
|
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -15,6 +15,22 @@ const { installWsl, installWslFeature } = require("../platforms/wsl");
|
|
|
15
15
|
const init = async (component, options) => {
|
|
16
16
|
const platform = os.platform();
|
|
17
17
|
|
|
18
|
+
if (options?.global) {
|
|
19
|
+
log.warn(
|
|
20
|
+
"⚠️ '-g/--global' is an npm flag and is ignored by 'uso install'.",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
typeof component === "string" &&
|
|
26
|
+
(component.startsWith("@") || component.includes("/"))
|
|
27
|
+
) {
|
|
28
|
+
log.error(`❌ '${component}' is not a valid uso component.`);
|
|
29
|
+
log.info("👉 Use one of: rust, solana, anchor");
|
|
30
|
+
log.info("👉 To install this CLI globally, run: npm install -g @xaidenlabs/uso");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
// --- On Windows, ALWAYS use the WSL path ---
|
|
19
35
|
if (platform === "win32") {
|
|
20
36
|
const hasWslBinary = !!shell.which("wsl");
|
|
@@ -47,6 +47,61 @@ const wslPathExists = (wslPath, stealth) => {
|
|
|
47
47
|
return result.code === 0;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
const getInstalledAvmVersions = (stealth) => {
|
|
51
|
+
const listResult = stealth.enabled
|
|
52
|
+
? runInStealth("avm list", stealth, true)
|
|
53
|
+
: shell.exec("avm list", { silent: true });
|
|
54
|
+
|
|
55
|
+
if (listResult.code !== 0) return [];
|
|
56
|
+
|
|
57
|
+
const versions = [];
|
|
58
|
+
for (const rawLine of listResult.stdout.split(/\r?\n/)) {
|
|
59
|
+
const line = rawLine.trim();
|
|
60
|
+
if (!line) continue;
|
|
61
|
+
|
|
62
|
+
// avm list output can contain markers like "* 0.30.1" or "0.30.1 (current)"
|
|
63
|
+
const match = line.match(/(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)/);
|
|
64
|
+
if (match) versions.push(match[1]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return [...new Set(versions)];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const isCargoPackageInstalled = (packageName, stealth) => {
|
|
71
|
+
const checkCmd = `cargo install --list | grep -q '^${packageName} v'`;
|
|
72
|
+
const result = stealth.enabled
|
|
73
|
+
? runInStealth(checkCmd, stealth, true)
|
|
74
|
+
: shell.exec(checkCmd, { silent: true });
|
|
75
|
+
return result.code === 0;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const uninstallAnchorComponents = (stealth) => {
|
|
79
|
+
if (commandExists("avm", stealth)) {
|
|
80
|
+
const versions = getInstalledAvmVersions(stealth);
|
|
81
|
+
if (versions.length > 0) {
|
|
82
|
+
for (const version of versions) {
|
|
83
|
+
runOrElevate(`avm uninstall ${version}`, `Uninstall Anchor (AVM ${version})`, stealth);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
log.info("No AVM-managed Anchor versions found to remove.");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (isCargoPackageInstalled("anchor-cli", stealth)) {
|
|
91
|
+
runOrElevate(
|
|
92
|
+
"cargo uninstall anchor-cli",
|
|
93
|
+
"Uninstall anchor-cli",
|
|
94
|
+
stealth,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (isCargoPackageInstalled("avm", stealth)) {
|
|
99
|
+
runOrElevate("cargo uninstall avm", "Uninstall avm", stealth);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
log.success("Anchor removal steps completed.");
|
|
103
|
+
};
|
|
104
|
+
|
|
50
105
|
/**
|
|
51
106
|
* Runs a command and attempts to elevate privileges if it fails with a permission error.
|
|
52
107
|
*/
|
|
@@ -136,21 +191,7 @@ const uninstall = async (component) => {
|
|
|
136
191
|
const anchorInstalled = commandExists("anchor", stealth);
|
|
137
192
|
if (anchorInstalled) {
|
|
138
193
|
log.info("Removing Anchor...");
|
|
139
|
-
|
|
140
|
-
if (commandExists("avm", stealth)) {
|
|
141
|
-
runOrElevate(
|
|
142
|
-
"avm uninstall latest",
|
|
143
|
-
"Uninstall Anchor (AVM)",
|
|
144
|
-
stealth,
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
runOrElevate(
|
|
148
|
-
"cargo uninstall anchor-cli",
|
|
149
|
-
"Uninstall anchor-cli",
|
|
150
|
-
stealth,
|
|
151
|
-
);
|
|
152
|
-
runOrElevate("cargo uninstall avm", "Uninstall avm", stealth);
|
|
153
|
-
log.success("Anchor removal steps completed.");
|
|
194
|
+
uninstallAnchorComponents(stealth);
|
|
154
195
|
} else {
|
|
155
196
|
log.success("✅ Anchor is not installed.");
|
|
156
197
|
}
|
|
@@ -253,17 +294,7 @@ const uninstall = async (component) => {
|
|
|
253
294
|
);
|
|
254
295
|
if (removeAnchor.toLowerCase() === "y") {
|
|
255
296
|
log.info("Removing Anchor...");
|
|
256
|
-
|
|
257
|
-
if (commandExists("avm", stealth)) {
|
|
258
|
-
runOrElevate("avm uninstall latest", "Uninstall Anchor (AVM)", stealth);
|
|
259
|
-
}
|
|
260
|
-
runOrElevate(
|
|
261
|
-
"cargo uninstall anchor-cli",
|
|
262
|
-
"Uninstall anchor-cli",
|
|
263
|
-
stealth,
|
|
264
|
-
);
|
|
265
|
-
runOrElevate("cargo uninstall avm", "Uninstall avm", stealth);
|
|
266
|
-
log.success("Anchor removal steps completed.");
|
|
297
|
+
uninstallAnchorComponents(stealth);
|
|
267
298
|
}
|
|
268
299
|
}
|
|
269
300
|
|
package/src/platforms/wsl.js
CHANGED
|
@@ -277,6 +277,32 @@ else
|
|
|
277
277
|
fi
|
|
278
278
|
source $HOME/.cargo/env 2>/dev/null || true
|
|
279
279
|
|
|
280
|
+
# --- Solana SBPF Toolchain (required for anchor build) ---
|
|
281
|
+
if ! rustup target list 2>/dev/null | grep -q "sbpf-solana-solana"; then
|
|
282
|
+
echo "🎯 Installing Solana SBPF toolchain..."
|
|
283
|
+
if run_with_progress "🎯 Installing Solana SBPF target..." 35 55 rustup target add sbpf-solana-solana; then
|
|
284
|
+
echo "✅ SBPF target installed."
|
|
285
|
+
else
|
|
286
|
+
FAILURES="$FAILURES sbpf-target"
|
|
287
|
+
echo "❌ SBPF target installation failed."
|
|
288
|
+
fi
|
|
289
|
+
else
|
|
290
|
+
echo "✅ SBPF target already installed."
|
|
291
|
+
fi
|
|
292
|
+
|
|
293
|
+
# Install cargo-build-sbf
|
|
294
|
+
if ! command -v cargo-build-sbf &> /dev/null; then
|
|
295
|
+
echo "🔨 Installing cargo-build-sbf..."
|
|
296
|
+
if run_with_progress "🔨 Installing cargo-build-sbf..." 55 60 cargo install cargo-build-sbf; then
|
|
297
|
+
echo "✅ cargo-build-sbf installed."
|
|
298
|
+
else
|
|
299
|
+
FAILURES="$FAILURES cargo-build-sbf"
|
|
300
|
+
echo "⚠️ cargo-build-sbf install failed (run 'uso init' to retry)."
|
|
301
|
+
fi
|
|
302
|
+
else
|
|
303
|
+
echo "✅ cargo-build-sbf already installed."
|
|
304
|
+
fi
|
|
305
|
+
|
|
280
306
|
# --- Solana ---
|
|
281
307
|
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
|
|
282
308
|
if ! command -v solana &> /dev/null; then
|
|
@@ -339,7 +365,7 @@ if ! command -v anchor &> /dev/null; then
|
|
|
339
365
|
# Install AVM if not present
|
|
340
366
|
if ! command -v avm &> /dev/null; then
|
|
341
367
|
echo "⚓ Installing AVM (compiling from source, ~5 min)..."
|
|
342
|
-
if run_with_progress "⚓ Installing AVM (compiling from source)..."
|
|
368
|
+
if run_with_progress "⚓ Installing AVM (compiling from source)..." 65 85 cargo install --git https://github.com/coral-xyz/anchor avm --locked --force; then
|
|
343
369
|
echo "✅ AVM compiled."
|
|
344
370
|
else
|
|
345
371
|
FAILURES="$FAILURES avm"
|