hedgequantx 1.8.46 → 1.8.47
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/menus/dashboard.js +40 -16
package/package.json
CHANGED
package/src/menus/dashboard.js
CHANGED
|
@@ -121,59 +121,83 @@ const handleUpdate = async () => {
|
|
|
121
121
|
currentVersion = require('../../package.json').version || 'unknown';
|
|
122
122
|
} catch (e) {}
|
|
123
123
|
|
|
124
|
+
console.log(chalk.cyan(`\n Current version: v${currentVersion}`));
|
|
124
125
|
spinner = ora({ text: 'Checking for updates...', color: 'yellow' }).start();
|
|
125
126
|
|
|
126
127
|
let latestVersion;
|
|
127
128
|
try {
|
|
128
|
-
latestVersion = execSync('npm view hedgequantx version
|
|
129
|
-
stdio: 'pipe',
|
|
129
|
+
latestVersion = execSync('npm view hedgequantx version', {
|
|
130
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
131
|
+
timeout: 30000,
|
|
132
|
+
encoding: 'utf8'
|
|
130
133
|
}).trim();
|
|
131
134
|
|
|
132
135
|
if (!latestVersion || !/^\d+\.\d+\.\d+/.test(latestVersion)) {
|
|
133
|
-
throw new Error('Invalid version');
|
|
136
|
+
throw new Error('Invalid version format');
|
|
134
137
|
}
|
|
135
138
|
} catch (e) {
|
|
136
139
|
spinner.fail('Cannot reach npm registry');
|
|
140
|
+
console.log(chalk.gray(` Error: ${e.message}`));
|
|
141
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
137
142
|
await prompts.waitForEnter();
|
|
138
143
|
return;
|
|
139
144
|
}
|
|
140
145
|
|
|
146
|
+
spinner.succeed(`Latest version: v${latestVersion}`);
|
|
147
|
+
|
|
141
148
|
if (currentVersion === latestVersion) {
|
|
142
|
-
|
|
143
|
-
await
|
|
149
|
+
console.log(chalk.green(' Already up to date!'));
|
|
150
|
+
await prompts.waitForEnter();
|
|
144
151
|
return;
|
|
145
152
|
}
|
|
146
153
|
|
|
147
|
-
|
|
154
|
+
console.log(chalk.yellow(` Update available: v${currentVersion} → v${latestVersion}`));
|
|
155
|
+
spinner = ora({ text: 'Installing update...', color: 'yellow' }).start();
|
|
148
156
|
|
|
149
157
|
try {
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
// Try with sudo first on Unix systems
|
|
159
|
+
const isWindows = process.platform === 'win32';
|
|
160
|
+
const cmd = isWindows
|
|
161
|
+
? 'npm install -g hedgequantx@latest'
|
|
162
|
+
: 'npm install -g hedgequantx@latest';
|
|
163
|
+
|
|
164
|
+
execSync(cmd, {
|
|
165
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
166
|
+
timeout: 180000,
|
|
167
|
+
encoding: 'utf8'
|
|
152
168
|
});
|
|
153
169
|
} catch (e) {
|
|
154
|
-
spinner.fail('Update failed');
|
|
155
|
-
console.log(chalk.
|
|
170
|
+
spinner.fail('Update failed - permission denied?');
|
|
171
|
+
console.log(chalk.gray(` Error: ${e.message}`));
|
|
172
|
+
console.log(chalk.yellow(' Try manually with sudo:'));
|
|
173
|
+
console.log(chalk.white(' sudo npm install -g hedgequantx@latest'));
|
|
156
174
|
await prompts.waitForEnter();
|
|
157
175
|
return;
|
|
158
176
|
}
|
|
159
177
|
|
|
160
|
-
spinner.succeed(`Updated
|
|
161
|
-
console.log(chalk.cyan(' Restarting...'));
|
|
178
|
+
spinner.succeed(`Updated to v${latestVersion}!`);
|
|
179
|
+
console.log(chalk.cyan(' Restarting HQX...'));
|
|
162
180
|
|
|
163
|
-
await new Promise(r => setTimeout(r,
|
|
181
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
164
182
|
|
|
165
183
|
try {
|
|
166
|
-
const child = spawn('
|
|
184
|
+
const child = spawn('hqx', [], {
|
|
185
|
+
stdio: 'inherit',
|
|
186
|
+
detached: true,
|
|
187
|
+
shell: true
|
|
188
|
+
});
|
|
167
189
|
child.unref();
|
|
168
190
|
process.exit(0);
|
|
169
191
|
} catch (e) {
|
|
170
|
-
console.log(chalk.yellow(' Please
|
|
192
|
+
console.log(chalk.yellow('\n Please restart HQX manually:'));
|
|
193
|
+
console.log(chalk.white(' hqx'));
|
|
171
194
|
await prompts.waitForEnter();
|
|
172
195
|
}
|
|
173
196
|
|
|
174
197
|
} catch (error) {
|
|
175
198
|
if (spinner) spinner.fail('Update error');
|
|
176
|
-
console.log(chalk.
|
|
199
|
+
console.log(chalk.gray(` Error: ${error.message}`));
|
|
200
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
177
201
|
await prompts.waitForEnter();
|
|
178
202
|
}
|
|
179
203
|
};
|