troxy-cli 1.30.20 → 1.30.21
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/troxy.js +8 -2
- package/package.json +1 -1
package/bin/troxy.js
CHANGED
|
@@ -686,20 +686,26 @@ switch (command) {
|
|
|
686
686
|
process.stdout.write(' Installing... ');
|
|
687
687
|
try {
|
|
688
688
|
try {
|
|
689
|
-
|
|
689
|
+
// The exact version, fetched fresh: `@latest` resolves from npm's own
|
|
690
|
+
// cache, which can still point at the old version for minutes after a
|
|
691
|
+
// publish, and then this "updated" to the version already installed.
|
|
692
|
+
execSync(`npm install -g troxy-cli@${latest} --prefer-online`, { stdio: 'pipe' });
|
|
690
693
|
} catch (err) {
|
|
691
694
|
const stderr = err.stderr?.toString() || '';
|
|
692
695
|
if (stderr.includes('ENOTEMPTY')) {
|
|
693
696
|
// npm bug on macOS/Homebrew: rename fails because dir has contents.
|
|
694
697
|
// rm -rf the stale dir directly, then reinstall cleanly.
|
|
695
698
|
const globalRoot = execSync('npm root -g', { stdio: 'pipe' }).toString().trim();
|
|
696
|
-
execSync(`rm -rf "${globalRoot}/troxy-cli" && npm install -g troxy-cli
|
|
699
|
+
execSync(`rm -rf "${globalRoot}/troxy-cli" && npm install -g troxy-cli@${latest} --prefer-online`, { stdio: 'pipe', shell: true });
|
|
697
700
|
} else {
|
|
698
701
|
throw err;
|
|
699
702
|
}
|
|
700
703
|
}
|
|
701
704
|
// Also refresh the npx cache so MCP servers (e.g. OpenClaw) pick up the new version
|
|
702
705
|
try { execSync(`npx --yes troxy-cli@${latest} --version`, { stdio: 'pipe' }); } catch { /* non-fatal */ }
|
|
706
|
+
const globalRoot = execSync('npm root -g', { stdio: 'pipe' }).toString().trim();
|
|
707
|
+
const installed = JSON.parse((await import('fs')).readFileSync(`${globalRoot}/troxy-cli/package.json`, 'utf8')).version;
|
|
708
|
+
if (installed !== latest) throw new Error(`npm installed ${installed}, not ${latest}. Try again in a few minutes.`);
|
|
703
709
|
console.log(`✓\n\n Updated to ${latest}.`);
|
|
704
710
|
|
|
705
711
|
// Re-run the exact same client/hook provisioning `troxy init` does,
|