hedgequantx 2.7.65 → 2.7.66
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 +42 -24
package/package.json
CHANGED
package/src/menus/dashboard.js
CHANGED
|
@@ -159,75 +159,94 @@ const dashboardMenu = async (service) => {
|
|
|
159
159
|
* Handle update process
|
|
160
160
|
*/
|
|
161
161
|
const handleUpdate = async () => {
|
|
162
|
+
console.clear();
|
|
163
|
+
displayBanner();
|
|
162
164
|
prepareStdin();
|
|
163
165
|
|
|
166
|
+
const boxWidth = getLogoWidth();
|
|
167
|
+
const W = boxWidth - 2;
|
|
168
|
+
|
|
169
|
+
console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
|
|
170
|
+
console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('UPDATE HQX', W)) + chalk.cyan('║'));
|
|
171
|
+
console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
|
|
172
|
+
|
|
164
173
|
let spinner = null;
|
|
165
174
|
let currentVersion = 'unknown';
|
|
166
175
|
|
|
167
176
|
try {
|
|
177
|
+
// Get current version
|
|
168
178
|
try {
|
|
169
179
|
currentVersion = require('../../package.json').version || 'unknown';
|
|
170
180
|
} catch (e) {}
|
|
171
181
|
|
|
172
|
-
console.log(chalk.cyan(`\n CURRENT VERSION: V${currentVersion}`));
|
|
182
|
+
console.log(chalk.cyan(`\n CURRENT VERSION: V${currentVersion.toUpperCase()}`));
|
|
173
183
|
spinner = ora({ text: 'CHECKING FOR UPDATES...', color: 'yellow' }).start();
|
|
174
184
|
|
|
185
|
+
// Check latest version from npm
|
|
175
186
|
let latestVersion;
|
|
176
187
|
try {
|
|
177
|
-
latestVersion = execSync('npm view hedgequantx version', {
|
|
188
|
+
latestVersion = execSync('npm view hedgequantx version 2>/dev/null', {
|
|
178
189
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
179
190
|
timeout: 30000,
|
|
180
191
|
encoding: 'utf8'
|
|
181
192
|
}).trim();
|
|
182
193
|
|
|
183
194
|
if (!latestVersion || !/^\d+\.\d+\.\d+/.test(latestVersion)) {
|
|
184
|
-
throw new Error('
|
|
195
|
+
throw new Error('INVALID VERSION FORMAT');
|
|
185
196
|
}
|
|
186
197
|
} catch (e) {
|
|
187
198
|
spinner.fail('CANNOT REACH NPM REGISTRY');
|
|
188
|
-
console.log(chalk.
|
|
189
|
-
console.log(chalk.yellow(' TRY MANUALLY: npm install -g hedgequantx@latest'));
|
|
199
|
+
console.log(chalk.yellow('\n TRY MANUALLY: npm update -g hedgequantx'));
|
|
190
200
|
await prompts.waitForEnter();
|
|
191
201
|
return;
|
|
192
202
|
}
|
|
193
203
|
|
|
194
|
-
spinner.succeed(`LATEST VERSION: V${latestVersion}`);
|
|
204
|
+
spinner.succeed(`LATEST VERSION: V${latestVersion.toUpperCase()}`);
|
|
195
205
|
|
|
206
|
+
// Already up to date
|
|
196
207
|
if (currentVersion === latestVersion) {
|
|
197
|
-
console.log(chalk.green(' ALREADY UP TO DATE!'));
|
|
208
|
+
console.log(chalk.green('\n ✓ ALREADY UP TO DATE!'));
|
|
198
209
|
await prompts.waitForEnter();
|
|
199
210
|
return;
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
|
|
213
|
+
// Update available
|
|
214
|
+
console.log(chalk.yellow(`\n UPDATE AVAILABLE: V${currentVersion} → V${latestVersion}`));
|
|
203
215
|
spinner = ora({ text: 'INSTALLING UPDATE...', color: 'yellow' }).start();
|
|
204
216
|
|
|
217
|
+
// Try to install update
|
|
205
218
|
try {
|
|
206
|
-
|
|
207
|
-
const isWindows = process.platform === 'win32';
|
|
208
|
-
const cmd = isWindows
|
|
209
|
-
? 'npm install -g hedgequantx@latest'
|
|
210
|
-
: 'npm install -g hedgequantx@latest';
|
|
211
|
-
|
|
212
|
-
execSync(cmd, {
|
|
219
|
+
execSync('npm update -g hedgequantx 2>/dev/null', {
|
|
213
220
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
214
221
|
timeout: 180000,
|
|
215
222
|
encoding: 'utf8'
|
|
216
223
|
});
|
|
217
224
|
} catch (e) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
// Try without redirecting stderr
|
|
226
|
+
try {
|
|
227
|
+
execSync('npm update -g hedgequantx', {
|
|
228
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
229
|
+
timeout: 180000,
|
|
230
|
+
encoding: 'utf8'
|
|
231
|
+
});
|
|
232
|
+
} catch (e2) {
|
|
233
|
+
spinner.fail('UPDATE FAILED');
|
|
234
|
+
console.log(chalk.yellow('\n TRY MANUALLY:'));
|
|
235
|
+
console.log(chalk.white(' npm update -g hedgequantx'));
|
|
236
|
+
console.log(chalk.gray(' OR WITH SUDO:'));
|
|
237
|
+
console.log(chalk.white(' sudo npm update -g hedgequantx'));
|
|
238
|
+
await prompts.waitForEnter();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
spinner.succeed(`UPDATED TO V${latestVersion}!`);
|
|
244
|
+
console.log(chalk.green('\n ✓ UPDATE SUCCESSFUL!'));
|
|
227
245
|
console.log(chalk.cyan(' RESTARTING HQX...'));
|
|
228
246
|
|
|
229
|
-
await new Promise(r => setTimeout(r,
|
|
247
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
230
248
|
|
|
249
|
+
// Restart HQX
|
|
231
250
|
try {
|
|
232
251
|
const child = spawn('hqx', [], {
|
|
233
252
|
stdio: 'inherit',
|
|
@@ -244,8 +263,7 @@ const handleUpdate = async () => {
|
|
|
244
263
|
|
|
245
264
|
} catch (error) {
|
|
246
265
|
if (spinner) spinner.fail('UPDATE ERROR');
|
|
247
|
-
console.log(chalk.
|
|
248
|
-
console.log(chalk.yellow(' TRY MANUALLY: npm install -g hedgequantx@latest'));
|
|
266
|
+
console.log(chalk.yellow('\n TRY MANUALLY: npm update -g hedgequantx'));
|
|
249
267
|
await prompts.waitForEnter();
|
|
250
268
|
}
|
|
251
269
|
};
|