hedgequantx 2.9.58 → 2.9.60
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 +11 -2
- package/src/ui/menu.js +6 -1
- package/src/utils/prompts.js +35 -82
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -136,8 +136,17 @@ const banner = async () => {
|
|
|
136
136
|
|
|
137
137
|
console.log(chalk.cyan('╠' + '═'.repeat(innerWidth) + '╣'));
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
if (isMobile) {
|
|
140
|
+
const tagline = `HQX V${version}`;
|
|
141
|
+
console.log(chalk.cyan('║') + chalk.yellow(centerText(tagline, innerWidth)) + chalk.cyan('║'));
|
|
142
|
+
} else {
|
|
143
|
+
const taglineBase = 'PROP FUTURES ALGO TRADING ';
|
|
144
|
+
const taglineVersion = `V${version}`;
|
|
145
|
+
const totalLen = taglineBase.length + taglineVersion.length;
|
|
146
|
+
const padLeft = Math.floor((innerWidth - totalLen) / 2);
|
|
147
|
+
const padRight = innerWidth - totalLen - padLeft;
|
|
148
|
+
console.log(chalk.cyan('║') + ' '.repeat(padLeft) + chalk.yellow(taglineBase) + chalk.magenta(taglineVersion) + ' '.repeat(padRight) + chalk.cyan('║'));
|
|
149
|
+
}
|
|
141
150
|
|
|
142
151
|
// ALWAYS close the banner
|
|
143
152
|
console.log(chalk.cyan('╚' + '═'.repeat(innerWidth) + '╝'));
|
package/src/ui/menu.js
CHANGED
|
@@ -48,7 +48,12 @@ const createBoxMenu = async (title, items, options = {}) => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
console.log(chalk.cyan('╠' + '═'.repeat(innerWidth) + '╣'));
|
|
51
|
-
|
|
51
|
+
const taglineBase = 'PROP FUTURES ALGO TRADING ';
|
|
52
|
+
const taglineVersion = `V${version}`;
|
|
53
|
+
const totalLen = taglineBase.length + taglineVersion.length;
|
|
54
|
+
const padLeft = Math.floor((innerWidth - totalLen) / 2);
|
|
55
|
+
const padRight = innerWidth - totalLen - padLeft;
|
|
56
|
+
console.log(chalk.cyan('║') + ' '.repeat(padLeft) + chalk.yellow(taglineBase) + chalk.magenta(taglineVersion) + ' '.repeat(padRight) + chalk.cyan('║'));
|
|
52
57
|
|
|
53
58
|
// Stats bar if provided
|
|
54
59
|
if (options.statsLine) {
|
package/src/utils/prompts.js
CHANGED
|
@@ -2,42 +2,14 @@
|
|
|
2
2
|
* @fileoverview Centralized prompts utility
|
|
3
3
|
* @module utils/prompts
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Simple prompts using inquirer for user input.
|
|
6
|
+
* No spinners on prompts - spinners are only for data loading (use ora).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const inquirer = require('inquirer');
|
|
10
10
|
const readline = require('readline');
|
|
11
11
|
const chalk = require('chalk');
|
|
12
12
|
|
|
13
|
-
// Spinner characters for yellow waiting indicator
|
|
14
|
-
const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
15
|
-
let spinnerInterval = null;
|
|
16
|
-
let spinnerFrame = 0;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Start yellow spinner to show we're waiting for user input
|
|
20
|
-
*/
|
|
21
|
-
const startSpinner = () => {
|
|
22
|
-
if (spinnerInterval) return;
|
|
23
|
-
spinnerFrame = 0;
|
|
24
|
-
spinnerInterval = setInterval(() => {
|
|
25
|
-
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES.length;
|
|
26
|
-
process.stdout.write(`\r${chalk.yellow(SPINNER_FRAMES[spinnerFrame])} `);
|
|
27
|
-
}, 80);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Stop spinner and clear line
|
|
32
|
-
*/
|
|
33
|
-
const stopSpinner = () => {
|
|
34
|
-
if (spinnerInterval) {
|
|
35
|
-
clearInterval(spinnerInterval);
|
|
36
|
-
spinnerInterval = null;
|
|
37
|
-
process.stdout.write('\r \r'); // Clear spinner
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
13
|
/** @type {readline.Interface|null} */
|
|
42
14
|
let rl = null;
|
|
43
15
|
|
|
@@ -72,64 +44,45 @@ const closeReadline = () => {
|
|
|
72
44
|
};
|
|
73
45
|
|
|
74
46
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param {string} message -
|
|
77
|
-
* @returns {Promise<string>}
|
|
78
|
-
*/
|
|
79
|
-
const nativePrompt = (message) => {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
try {
|
|
82
|
-
prepareStdin();
|
|
83
|
-
closeReadline();
|
|
84
|
-
|
|
85
|
-
rl = readline.createInterface({
|
|
86
|
-
input: process.stdin,
|
|
87
|
-
output: process.stdout,
|
|
88
|
-
terminal: true,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
let answered = false;
|
|
92
|
-
|
|
93
|
-
rl.question(`${message} `, (answer) => {
|
|
94
|
-
answered = true;
|
|
95
|
-
closeReadline();
|
|
96
|
-
resolve(answer || '');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
rl.on('close', () => {
|
|
100
|
-
if (!answered) {
|
|
101
|
-
rl = null;
|
|
102
|
-
resolve('');
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
} catch {
|
|
106
|
-
resolve('');
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Wait for Enter key + yellow spinner
|
|
113
|
-
* @param {string} [message='Press Enter to continue...'] - Message to display
|
|
47
|
+
* Wait for Enter key
|
|
48
|
+
* @param {string} [message='Press Enter to continue...'] - Message
|
|
114
49
|
* @returns {Promise<void>}
|
|
115
50
|
*/
|
|
116
51
|
const waitForEnter = async (message = 'Press Enter to continue...') => {
|
|
117
|
-
|
|
52
|
+
closeReadline();
|
|
53
|
+
prepareStdin();
|
|
54
|
+
|
|
55
|
+
await inquirer.prompt([{
|
|
56
|
+
type: 'input',
|
|
57
|
+
name: 'continue',
|
|
58
|
+
message,
|
|
59
|
+
prefix: '',
|
|
60
|
+
}]);
|
|
118
61
|
};
|
|
119
62
|
|
|
120
63
|
/**
|
|
121
|
-
* Text input
|
|
64
|
+
* Text input
|
|
122
65
|
* @param {string} message - Prompt message
|
|
123
66
|
* @param {string} [defaultVal=''] - Default value
|
|
124
67
|
* @returns {Promise<string>}
|
|
125
68
|
*/
|
|
126
69
|
const textInput = async (message, defaultVal = '') => {
|
|
127
|
-
|
|
128
|
-
|
|
70
|
+
closeReadline();
|
|
71
|
+
prepareStdin();
|
|
72
|
+
|
|
73
|
+
const { value } = await inquirer.prompt([{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'value',
|
|
76
|
+
message,
|
|
77
|
+
default: defaultVal,
|
|
78
|
+
prefix: '',
|
|
79
|
+
}]);
|
|
80
|
+
|
|
81
|
+
return value;
|
|
129
82
|
};
|
|
130
83
|
|
|
131
84
|
/**
|
|
132
|
-
* Password input (masked)
|
|
85
|
+
* Password input (masked)
|
|
133
86
|
* @param {string} message - Prompt message
|
|
134
87
|
* @returns {Promise<string>}
|
|
135
88
|
*/
|
|
@@ -140,7 +93,7 @@ const passwordInput = async (message) => {
|
|
|
140
93
|
const { value } = await inquirer.prompt([{
|
|
141
94
|
type: 'password',
|
|
142
95
|
name: 'value',
|
|
143
|
-
message
|
|
96
|
+
message,
|
|
144
97
|
mask: '*',
|
|
145
98
|
prefix: '',
|
|
146
99
|
}]);
|
|
@@ -149,7 +102,7 @@ const passwordInput = async (message) => {
|
|
|
149
102
|
};
|
|
150
103
|
|
|
151
104
|
/**
|
|
152
|
-
* Confirm prompt with
|
|
105
|
+
* Confirm prompt with Yes/No selection
|
|
153
106
|
* @param {string} message - Prompt message
|
|
154
107
|
* @param {boolean} [defaultVal=true] - Default value
|
|
155
108
|
* @returns {Promise<boolean>}
|
|
@@ -165,7 +118,7 @@ const confirmPrompt = async (message, defaultVal = true) => {
|
|
|
165
118
|
const { value } = await inquirer.prompt([{
|
|
166
119
|
type: 'list',
|
|
167
120
|
name: 'value',
|
|
168
|
-
message
|
|
121
|
+
message,
|
|
169
122
|
choices,
|
|
170
123
|
prefix: '',
|
|
171
124
|
loop: false,
|
|
@@ -175,7 +128,7 @@ const confirmPrompt = async (message, defaultVal = true) => {
|
|
|
175
128
|
};
|
|
176
129
|
|
|
177
130
|
/**
|
|
178
|
-
* Number input with validation
|
|
131
|
+
* Number input with validation
|
|
179
132
|
* @param {string} message - Prompt message
|
|
180
133
|
* @param {number} [defaultVal=1] - Default value
|
|
181
134
|
* @param {number} [min=1] - Minimum value
|
|
@@ -189,7 +142,7 @@ const numberInput = async (message, defaultVal = 1, min = 1, max = 1000) => {
|
|
|
189
142
|
const { value } = await inquirer.prompt([{
|
|
190
143
|
type: 'input',
|
|
191
144
|
name: 'value',
|
|
192
|
-
message: `${
|
|
145
|
+
message: `${message} (${min}-${max})`,
|
|
193
146
|
default: String(defaultVal),
|
|
194
147
|
prefix: '',
|
|
195
148
|
validate: (v) => {
|
|
@@ -205,7 +158,7 @@ const numberInput = async (message, defaultVal = 1, min = 1, max = 1000) => {
|
|
|
205
158
|
};
|
|
206
159
|
|
|
207
160
|
/**
|
|
208
|
-
* Select from options with arrow keys
|
|
161
|
+
* Select from options with arrow keys
|
|
209
162
|
* @param {string} message - Prompt message
|
|
210
163
|
* @param {Array<{label: string, value: any, disabled?: boolean}>} options - Options
|
|
211
164
|
* @returns {Promise<any>}
|
|
@@ -224,11 +177,11 @@ const selectOption = async (message, options) => {
|
|
|
224
177
|
const { value } = await inquirer.prompt([{
|
|
225
178
|
type: 'list',
|
|
226
179
|
name: 'value',
|
|
227
|
-
message
|
|
180
|
+
message,
|
|
228
181
|
choices,
|
|
229
182
|
prefix: '',
|
|
230
183
|
loop: false,
|
|
231
|
-
pageSize:
|
|
184
|
+
pageSize: 15,
|
|
232
185
|
}]);
|
|
233
186
|
|
|
234
187
|
return value;
|