@xaidenlabs/uso 1.1.85 → 1.1.86

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.85",
3
+ "version": "1.1.86",
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"
@@ -100,6 +100,98 @@ const uninstallAnchorComponents = (stealth) => {
100
100
  }
101
101
 
102
102
  log.success("Anchor removal steps completed.");
103
+ };
104
+
105
+ /**
106
+ * Runs a command and attempts to elevate privileges if it fails with a permission error.
107
+ */
108
+ const runOrElevate = (
109
+ command,
110
+ description,
111
+ stealth = { enabled: false, distro: "Ubuntu" },
112
+ ) => {
113
+ if (stealth.enabled) {
114
+ const result = runInStealth(command, stealth, true);
115
+
116
+ if (result.code === 0) {
117
+ if (result.stdout) console.log(result.stdout);
118
+ return true;
119
+ }
120
+
121
+ if (result.stdout) console.log(result.stdout);
122
+ if (result.stderr) console.error(result.stderr);
123
+ log.error(`❌ Command failed in WSL: ${description}`);
124
+ return false;
125
+ }
126
+
127
+ // We run without silent:true initially to let the user see output,
128
+ // but detecting the error code is what matters.
129
+ // actually, to detect the specific string "os error 1314", we need to capture output.
130
+ // So we run silently first? Or we just run and if it fails, we assume it *might* be elevation if on Windows?
131
+ // Let's run synchronously and capture output.
132
+
133
+ const result = shell.exec(command, { silent: true });
134
+
135
+ if (result.code === 0) {
136
+ console.log(result.stdout);
137
+ return true;
138
+ }
139
+
140
+ // Print the error output to the user
141
+ console.log(result.stdout);
142
+ console.error(result.stderr);
143
+
144
+ const output = result.stderr + result.stdout;
145
+
146
+ // Check for common permission errors
147
+ // "os error 1314" is specific to Windows symlink privilege
148
+ if (
149
+ (output.includes("os error 1314") ||
150
+ output.includes("EPERM") ||
151
+ output.includes("permission denied")) &&
152
+ os.platform() === "win32"
153
+ ) {
154
+ log.warn(`⚠️ Permission denied during: ${description}`);
155
+ log.info("🛡️ Triggering Run as Administrator (UAC) to retry...");
156
+
157
+ // Construct PowerShell command to run cmd /c <command> as admin
158
+ // We need to be careful with quoting.
159
+ const escapedCommand = command.replace(/'/g, "''"); // Basic PowerShell escaping for single quotes
160
+ const elevateCmd = `powershell -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c ${escapedCommand}' -Verb RunAs -Wait"`;
161
+
162
+ const elevatedRun = shell.exec(elevateCmd);
163
+
164
+ if (elevatedRun.code === 0) {
165
+ log.success(`✅ ${description} completed (Elevated).`);
166
+ return true;
167
+ } else {
168
+ log.error(`❌ Elevated execution failed for: ${description}`);
169
+ return false;
170
+ }
171
+ }
172
+
173
+ log.error(`❌ Command failed: ${description}`);
174
+ return false;
175
+ };
176
+
177
+ const uninstall = async (component) => {
178
+ const stealth = getStealthContext();
179
+ log.header("🗑️ USO Uninstallation & Cleanup");
180
+ if (stealth.enabled) {
181
+ log.info(
182
+ `🐧 Stealth Mode detected. Uninstall targets WSL distro: ${stealth.distro}`,
183
+ );
184
+ }
185
+
186
+ if (component) {
187
+ component = component.toLowerCase();
188
+ log.info(`🎯 Targeted uninstallation: ${component}`);
189
+
190
+ if (component === "anchor") {
191
+ const anchorInstalled = commandExists("anchor", stealth);
192
+ if (anchorInstalled) {
193
+ log.info("Removing Anchor...");
194
+ uninstallAnchorComponents(stealth);
103
195
  } else {
104
196
  log.success("✅ Anchor is not installed.");
105
197
  }
@@ -270,7 +362,6 @@ const uninstallAnchorComponents = (stealth) => {
270
362
  }
271
363
  }
272
364
 
273
- <<<<<<< HEAD
274
365
  // 3.5 Remove WSL Distro (if stealth mode is active)
275
366
  if (stealth.enabled && os.platform() === "win32") {
276
367
  const removeWslDistro = await askQuestion(
@@ -300,8 +391,6 @@ const uninstallAnchorComponents = (stealth) => {
300
391
  }
301
392
  }
302
393
 
303
- =======
304
- >>>>>>> d47ca156cb2a252419c54c520c7fcd0f0c18c525
305
394
  // 4. WALLET REMOVAL (DANGER)
306
395
  const walletPath = path.join(os.homedir(), ".config", "solana", "id.json");
307
396
  const wslWalletPath = "$HOME/.config/solana/id.json";