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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app.js +30 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "1.2.54",
3
+ "version": "1.2.55",
4
4
  "description": "Prop Futures Algo Trading CLI - Connect to Topstep, Alpha Futures, and other prop firms",
5
5
  "main": "src/app.js",
6
6
  "bin": {
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
- const cliPath = path.resolve(__dirname, '..');
666
-
667
- // Get current commit
668
- const beforeCommit = execSync('git rev-parse --short HEAD', { cwd: cliPath, stdio: 'pipe' }).toString().trim();
669
-
670
- // Fetch to check for updates
671
- execSync('git fetch origin main', { cwd: cliPath, stdio: 'pipe' });
672
-
673
- // Check if behind
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 (parseInt(behindCount) === 0) {
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
- // Stash local changes
684
- spinner.text = 'Stashing local changes...';
681
+ // Update via npm
682
+ spinner.text = `Updating v${currentVersion} -> v${latestVersion}...`;
685
683
  try {
686
- execSync('git stash --include-untracked', { cwd: cliPath, stdio: 'pipe' });
684
+ exec('npm install -g hedgequantx@latest', { stdio: 'pipe' });
687
685
  } catch (e) {
688
- // If stash fails, reset
689
- execSync('git checkout -- .', { cwd: cliPath, stdio: 'pipe' });
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${newVersion}`));
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 child = spawn(process.argv[0], [path.join(cliPath, 'bin', 'cli.js')], {
718
- cwd: cliPath,
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