hedgequantx 1.2.54 → 1.2.55
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/app.js +30 -38
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -656,66 +656,57 @@ const dashboardMenu = async (service) => {
|
|
|
656
656
|
* Handles the update process with auto-restart
|
|
657
657
|
*/
|
|
658
658
|
const handleUpdate = async () => {
|
|
659
|
-
const { spawn } = require('child_process');
|
|
659
|
+
const { spawn, execSync: exec } = require('child_process');
|
|
660
660
|
const pkg = require('../package.json');
|
|
661
661
|
const currentVersion = pkg.version;
|
|
662
662
|
const spinner = ora('Checking for updates...').start();
|
|
663
663
|
|
|
664
664
|
try {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
const behindCount = execSync('git rev-list HEAD..origin/main --count', { cwd: cliPath, stdio: 'pipe' }).toString().trim();
|
|
665
|
+
// Check latest version on npm
|
|
666
|
+
spinner.text = 'Checking npm registry...';
|
|
667
|
+
let latestVersion;
|
|
668
|
+
try {
|
|
669
|
+
latestVersion = exec('npm view hedgequantx version', { stdio: 'pipe' }).toString().trim();
|
|
670
|
+
} catch (e) {
|
|
671
|
+
spinner.fail('Cannot reach npm registry');
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
675
674
|
|
|
676
|
-
if (
|
|
675
|
+
if (currentVersion === latestVersion) {
|
|
677
676
|
spinner.succeed('Already up to date!');
|
|
678
677
|
console.log(chalk.cyan(` Version: v${currentVersion}`));
|
|
679
|
-
console.log(chalk.gray(` Commit: ${beforeCommit}`));
|
|
680
678
|
return;
|
|
681
679
|
}
|
|
682
680
|
|
|
683
|
-
//
|
|
684
|
-
spinner.text =
|
|
681
|
+
// Update via npm
|
|
682
|
+
spinner.text = `Updating v${currentVersion} -> v${latestVersion}...`;
|
|
685
683
|
try {
|
|
686
|
-
|
|
684
|
+
exec('npm install -g hedgequantx@latest', { stdio: 'pipe' });
|
|
687
685
|
} catch (e) {
|
|
688
|
-
//
|
|
689
|
-
|
|
686
|
+
// Try with sudo on Unix systems
|
|
687
|
+
if (process.platform !== 'win32') {
|
|
688
|
+
try {
|
|
689
|
+
exec('sudo npm install -g hedgequantx@latest', { stdio: 'pipe' });
|
|
690
|
+
} catch (e2) {
|
|
691
|
+
spinner.fail('Update failed - try manually: npm install -g hedgequantx@latest');
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
spinner.fail('Update failed - try manually: npm install -g hedgequantx@latest');
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
690
698
|
}
|
|
691
699
|
|
|
692
|
-
// Pull latest
|
|
693
|
-
spinner.text = 'Downloading updates...';
|
|
694
|
-
execSync('git pull origin main', { cwd: cliPath, stdio: 'pipe' });
|
|
695
|
-
const afterCommit = execSync('git rev-parse --short HEAD', { cwd: cliPath, stdio: 'pipe' }).toString().trim();
|
|
696
|
-
|
|
697
|
-
// Install dependencies
|
|
698
|
-
spinner.text = 'Installing dependencies...';
|
|
699
|
-
try {
|
|
700
|
-
execSync('npm install --silent', { cwd: cliPath, stdio: 'pipe' });
|
|
701
|
-
} catch (e) { /* ignore */ }
|
|
702
|
-
|
|
703
|
-
// Get new version
|
|
704
|
-
delete require.cache[require.resolve('../package.json')];
|
|
705
|
-
const newPkg = require('../package.json');
|
|
706
|
-
const newVersion = newPkg.version;
|
|
707
|
-
|
|
708
700
|
spinner.succeed('CLI updated!');
|
|
709
701
|
console.log();
|
|
710
|
-
console.log(chalk.green(` Version: v${currentVersion} -> v${
|
|
711
|
-
console.log(chalk.gray(` Commits: ${beforeCommit} -> ${afterCommit} (${behindCount} new)`));
|
|
702
|
+
console.log(chalk.green(` Version: v${currentVersion} -> v${latestVersion}`));
|
|
712
703
|
console.log();
|
|
713
704
|
console.log(chalk.cyan(' Restarting...'));
|
|
714
705
|
console.log();
|
|
715
706
|
|
|
716
707
|
// Restart CLI
|
|
717
|
-
const
|
|
718
|
-
|
|
708
|
+
const cliPath = exec('npm root -g', { stdio: 'pipe' }).toString().trim();
|
|
709
|
+
const child = spawn(process.argv[0], [path.join(cliPath, 'hedgequantx', 'bin', 'cli.js')], {
|
|
719
710
|
stdio: 'inherit',
|
|
720
711
|
shell: true
|
|
721
712
|
});
|
|
@@ -729,6 +720,7 @@ const handleUpdate = async () => {
|
|
|
729
720
|
|
|
730
721
|
} catch (error) {
|
|
731
722
|
spinner.fail('Update failed: ' + error.message);
|
|
723
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
732
724
|
}
|
|
733
725
|
};
|
|
734
726
|
|