hedgequantx 1.8.18 → 1.8.20
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/README.md +188 -171
- package/package.json +1 -1
- package/src/utils/prompts.js +29 -7
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# HedgeQuantX CLI
|
|
2
2
|
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
3
5
|
```
|
|
4
6
|
██╗ ██╗███████╗██████╗ ██████╗ ███████╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ ██╗
|
|
5
7
|
██║ ██║██╔════╝██╔══██╗██╔════╝ ██╔════╝██╔═══██╗██║ ██║██╔══██╗████╗ ██║╚══██╔══╝╚██╗██╔╝
|
|
@@ -9,37 +11,51 @@
|
|
|
9
11
|
╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚══════╝ ╚══▀▀═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝
|
|
10
12
|
```
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
### Prop Futures Algo Trading CLI
|
|
15
|
+
|
|
16
|
+
*Connect to 37+ prop firms and automate your futures trading*
|
|
17
|
+
|
|
18
|
+
[](https://www.npmjs.com/package/hedgequantx)
|
|
19
|
+
[](https://www.npmjs.com/package/hedgequantx)
|
|
20
|
+
[](https://github.com/HedgeQuantX/HQX-CLI)
|
|
21
|
+
[](LICENSE)
|
|
22
|
+
|
|
23
|
+
[](https://nodejs.org/)
|
|
24
|
+
[](https://github.com/HedgeQuantX/HQX-CLI)
|
|
25
|
+
[](https://github.com/HedgeQuantX/HQX-CLI/pulls)
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
[Installation](#-installation) | [Features](#-features) | [Usage](#-usage) | [Algo Trading](#-algo-trading) | [Support](#-support)
|
|
15
28
|
|
|
16
|
-
|
|
17
|
-
[](https://www.npmjs.com/package/hedgequantx)
|
|
29
|
+
</div>
|
|
18
30
|
|
|
19
31
|
---
|
|
20
32
|
|
|
21
33
|
## Features
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
| Feature | Description |
|
|
36
|
+
|---------|-------------|
|
|
37
|
+
| **Multi-Platform** | ProjectX & Rithmic APIs |
|
|
38
|
+
| **37+ Prop Firms** | TopStep, Apex, Bulenox, and more |
|
|
39
|
+
| **Multi-Account** | Connect multiple accounts simultaneously |
|
|
40
|
+
| **Real-Time Stats** | Balance, P&L, positions, orders |
|
|
41
|
+
| **Algo Trading** | One Account & Copy Trading modes |
|
|
42
|
+
| **Ultra-Scalping** | VWAP Mean Reversion + Order Flow |
|
|
43
|
+
| **Market Hours** | Auto-blocks when market closed |
|
|
44
|
+
| **Cloud Execution** | HQX Server low-latency engine |
|
|
45
|
+
| **Secure Storage** | AES-256-GCM encrypted sessions |
|
|
46
|
+
| **Auto-Update** | Built-in version checker |
|
|
31
47
|
|
|
32
48
|
---
|
|
33
49
|
|
|
34
50
|
## Installation
|
|
35
51
|
|
|
36
|
-
###
|
|
52
|
+
### NPM (Recommended)
|
|
37
53
|
|
|
38
54
|
```bash
|
|
39
55
|
npm install -g hedgequantx
|
|
40
56
|
```
|
|
41
57
|
|
|
42
|
-
###
|
|
58
|
+
### From Source
|
|
43
59
|
|
|
44
60
|
```bash
|
|
45
61
|
git clone https://github.com/HedgeQuantX/HQX-CLI.git
|
|
@@ -54,78 +70,19 @@ npm link
|
|
|
54
70
|
|
|
55
71
|
```bash
|
|
56
72
|
# Launch CLI
|
|
57
|
-
hedgequantx
|
|
58
|
-
|
|
59
|
-
# Or use short alias
|
|
60
73
|
hqx
|
|
61
74
|
|
|
75
|
+
# Or full command
|
|
76
|
+
hedgequantx
|
|
77
|
+
|
|
62
78
|
# Show version
|
|
63
|
-
|
|
79
|
+
hqx --version
|
|
64
80
|
```
|
|
65
81
|
|
|
66
82
|
---
|
|
67
83
|
|
|
68
|
-
##
|
|
84
|
+
## Dashboard Preview
|
|
69
85
|
|
|
70
|
-
### One Account Mode
|
|
71
|
-
Trade on a single account with automated signals and risk management.
|
|
72
|
-
|
|
73
|
-
- Symbol selection (ES, NQ, MNQ, etc.)
|
|
74
|
-
- Configurable contracts quantity
|
|
75
|
-
- Daily target and max risk limits
|
|
76
|
-
- Real-time P&L tracking
|
|
77
|
-
- Activity log with trade history
|
|
78
|
-
|
|
79
|
-
### Copy Trading Mode
|
|
80
|
-
Mirror trades from a Lead account to Follower accounts.
|
|
81
|
-
|
|
82
|
-
- Lead -> Follower trade copying
|
|
83
|
-
- Different symbols per account
|
|
84
|
-
- Configurable contract ratios
|
|
85
|
-
- Privacy mode (hide account names)
|
|
86
|
-
- Low-latency execution via HQX Server
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Supported Prop Firms (37+)
|
|
91
|
-
|
|
92
|
-
| ProjectX (19) | Rithmic (16) | Tradovate (2) |
|
|
93
|
-
|---------------|--------------|---------------|
|
|
94
|
-
| TopStep | Apex Trader Funding | Apex |
|
|
95
|
-
| Alpha Futures | TopstepTrader | TakeProfitTrader |
|
|
96
|
-
| TickTickTrader | MES Capital | |
|
|
97
|
-
| Bulenox | Bulenox | |
|
|
98
|
-
| TradeDay | TradeFundrr | |
|
|
99
|
-
| Blusky | TheTradingPit | |
|
|
100
|
-
| Goat Futures | FundedFuturesNetwork | |
|
|
101
|
-
| The Futures Desk | PropShopTrader | |
|
|
102
|
-
| DayTraders | 4PropTrader | |
|
|
103
|
-
| E8 Futures | DayTraders.com | |
|
|
104
|
-
| Blue Guardian Futures | 10XFutures | |
|
|
105
|
-
| FuturesElite | LucidTrading | |
|
|
106
|
-
| FXIFY | ThriveTrading | |
|
|
107
|
-
| Hola Prime | LegendsTrading | |
|
|
108
|
-
| Top One Futures | Earn2Trade | |
|
|
109
|
-
| Funding Futures | Tradesea | |
|
|
110
|
-
| TX3 Funding | | |
|
|
111
|
-
| Lucid Trading | | |
|
|
112
|
-
| Tradeify | | |
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## Dashboard Features
|
|
117
|
-
|
|
118
|
-
- **View Accounts** - List all trading accounts with balance and status
|
|
119
|
-
- **View Stats** - Trading metrics, equity curve, P&L calendar
|
|
120
|
-
- **Add Prop-Account** - Connect multiple prop firms
|
|
121
|
-
- **Algo-Trading** - One Account & Copy Trading modes
|
|
122
|
-
- **Update HQX** - Auto-update with confirmation and restart
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Screenshots
|
|
127
|
-
|
|
128
|
-
### Main Dashboard
|
|
129
86
|
```
|
|
130
87
|
╔════════════════════════════════════════════════════════════════════════════════════════════════╗
|
|
131
88
|
║ ██╗ ██╗███████╗██████╗ ██████╗ ███████╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ ██╗ ║
|
|
@@ -135,111 +92,161 @@ Mirror trades from a Lead account to Follower accounts.
|
|
|
135
92
|
║ ██║ ██║███████╗██████╔╝╚██████╔╝███████╗╚██████╔╝╚██████╔╝██║ ██║██║ ╚████║ ██║ ██╔╝ ██╗ ║
|
|
136
93
|
║ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚══════╝ ╚══▀▀═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ║
|
|
137
94
|
╠════════════════════════════════════════════════════════════════════════════════════════════════╣
|
|
138
|
-
║
|
|
95
|
+
║ Prop Futures Algo Trading v1.8.18 ║
|
|
139
96
|
╠════════════════════════════════════════════════════════════════════════════════════════════════╣
|
|
140
|
-
║ Connections: 2 Accounts: 3 Balance: $601,526 P&L: +$1,526 (+0.3%) ║
|
|
141
|
-
╚════════════════════════════════════════════════════════════════════════════════════════════════╝
|
|
142
|
-
|
|
143
|
-
╔════════════════════════════════════════════════════════════════════════════════════════════════╗
|
|
144
97
|
║ Welcome, HQX Trader! ║
|
|
145
98
|
╠════════════════════════════════════════════════════════════════════════════════════════════════╣
|
|
146
|
-
║
|
|
147
|
-
|
|
148
|
-
║
|
|
99
|
+
║ ● TopStep ● Apex Trader Funding ║
|
|
100
|
+
╠════════════════════════════════════════════════════════════════════════════════════════════════╣
|
|
101
|
+
║ Connections: 2 Accounts: 2 Balance: $449,682 P&L: +$0 ║
|
|
149
102
|
╠════════════════════════════════════════════════════════════════════════════════════════════════╣
|
|
150
|
-
║ [1] View Accounts
|
|
151
|
-
║ [+] Add Prop-Account
|
|
152
|
-
║ [U] Update HQX
|
|
103
|
+
║ [1] View Accounts [2] View Stats ║
|
|
104
|
+
║ [+] Add Prop-Account [A] Algo-Trading ║
|
|
105
|
+
║ [U] Update HQX [X] Disconnect ║
|
|
153
106
|
╚════════════════════════════════════════════════════════════════════════════════════════════════╝
|
|
154
107
|
```
|
|
155
108
|
|
|
156
109
|
---
|
|
157
110
|
|
|
158
|
-
##
|
|
111
|
+
## Algo Trading
|
|
112
|
+
|
|
113
|
+
### One Account Mode
|
|
114
|
+
|
|
115
|
+
Trade on a single account with HQX Ultra-Scalping strategy.
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
╠════════════════════════════════════════════════╤═══════════════════════════════════════════════╣
|
|
119
|
+
║ Account: PRAC-V2-153156 │ Symbol: ES Mar26 ║
|
|
120
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
121
|
+
║ Qty: 1 │ P&L: +$0.00 ║
|
|
122
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
123
|
+
║ Target: $200.00 │ Risk: $100.00 ║
|
|
124
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
125
|
+
║ Trades: 0 W/L: 0/0 │ Server: ON ║
|
|
126
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
127
|
+
║ Latency: 45ms │ Propfirm: TopStep ║
|
|
128
|
+
╚════════════════════════════════════════════════╧═══════════════════════════════════════════════╝
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Copy Trading Mode
|
|
132
|
+
|
|
133
|
+
Mirror trades from Lead to Follower accounts.
|
|
159
134
|
|
|
160
135
|
```
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
│
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
│ │ ├── connect.js # Connection menus
|
|
171
|
-
│ │ └── dashboard.js # Dashboard & update
|
|
172
|
-
│ ├── pages/
|
|
173
|
-
│ │ ├── algo/
|
|
174
|
-
│ │ │ ├── ui.js # Algo trading UI
|
|
175
|
-
│ │ │ ├── one-account.js # One Account mode
|
|
176
|
-
│ │ │ └── copy-trading.js # Copy Trading mode
|
|
177
|
-
│ │ ├── accounts.js
|
|
178
|
-
│ │ └── stats.js
|
|
179
|
-
│ ├── security/
|
|
180
|
-
│ │ ├── encryption.js # AES-256-GCM
|
|
181
|
-
│ │ ├── validation.js # Input sanitization
|
|
182
|
-
│ │ └── rateLimit.js # API rate limiting
|
|
183
|
-
│ ├── services/
|
|
184
|
-
│ │ ├── projectx/ # ProjectX API
|
|
185
|
-
│ │ ├── rithmic/ # Rithmic API
|
|
186
|
-
│ │ ├── tradovate/ # Tradovate API
|
|
187
|
-
│ │ ├── hqx-server.js # HQX Server API
|
|
188
|
-
│ │ └── session.js # Encrypted sessions
|
|
189
|
-
│ └── ui/
|
|
190
|
-
│ ├── box.js
|
|
191
|
-
│ ├── table.js
|
|
192
|
-
│ └── device.js
|
|
193
|
-
├── package.json
|
|
194
|
-
└── README.md
|
|
136
|
+
╠════════════════════════════════════════════════╤═══════════════════════════════════════════════╣
|
|
137
|
+
║ Lead: Apex ***** │ Follower: TopStep ***** ║
|
|
138
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
139
|
+
║ Symbol: NQ Mar26 │ Symbol: NQ Mar26 ║
|
|
140
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
141
|
+
║ Qty: 1 │ Qty: 1 ║
|
|
142
|
+
╠════════════════════════════════════════════════╪═══════════════════════════════════════════════╣
|
|
143
|
+
║ Target: $400.00 │ Risk: $200.00 ║
|
|
144
|
+
╚════════════════════════════════════════════════╧═══════════════════════════════════════════════╝
|
|
195
145
|
```
|
|
196
146
|
|
|
197
147
|
---
|
|
198
148
|
|
|
149
|
+
## Supported Prop Firms
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary><b>ProjectX (19 firms)</b></summary>
|
|
153
|
+
|
|
154
|
+
| Firm | Status |
|
|
155
|
+
|------|--------|
|
|
156
|
+
| TopStep | Active |
|
|
157
|
+
| Alpha Futures | Active |
|
|
158
|
+
| TickTickTrader | Active |
|
|
159
|
+
| Bulenox | Active |
|
|
160
|
+
| TradeDay | Active |
|
|
161
|
+
| Blusky | Active |
|
|
162
|
+
| Goat Futures | Active |
|
|
163
|
+
| The Futures Desk | Active |
|
|
164
|
+
| DayTraders | Active |
|
|
165
|
+
| E8 Futures | Active |
|
|
166
|
+
| Blue Guardian Futures | Active |
|
|
167
|
+
| FuturesElite | Active |
|
|
168
|
+
| FXIFY | Active |
|
|
169
|
+
| Hola Prime | Active |
|
|
170
|
+
| Top One Futures | Active |
|
|
171
|
+
| Funding Futures | Active |
|
|
172
|
+
| TX3 Funding | Active |
|
|
173
|
+
| Lucid Trading | Active |
|
|
174
|
+
| Tradeify | Active |
|
|
175
|
+
|
|
176
|
+
</details>
|
|
177
|
+
|
|
178
|
+
<details>
|
|
179
|
+
<summary><b>Rithmic (16 firms)</b></summary>
|
|
180
|
+
|
|
181
|
+
| Firm | Status |
|
|
182
|
+
|------|--------|
|
|
183
|
+
| Apex Trader Funding | Active |
|
|
184
|
+
| TopstepTrader | Active |
|
|
185
|
+
| MES Capital | Active |
|
|
186
|
+
| Bulenox | Active |
|
|
187
|
+
| TradeFundrr | Active |
|
|
188
|
+
| TheTradingPit | Active |
|
|
189
|
+
| FundedFuturesNetwork | Active |
|
|
190
|
+
| PropShopTrader | Active |
|
|
191
|
+
| 4PropTrader | Active |
|
|
192
|
+
| DayTraders.com | Active |
|
|
193
|
+
| 10XFutures | Active |
|
|
194
|
+
| LucidTrading | Active |
|
|
195
|
+
| ThriveTrading | Active |
|
|
196
|
+
| LegendsTrading | Active |
|
|
197
|
+
| Earn2Trade | Active |
|
|
198
|
+
| Tradesea | Active |
|
|
199
|
+
|
|
200
|
+
</details>
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
199
204
|
## Security
|
|
200
205
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
| Feature | Implementation |
|
|
207
|
+
|---------|---------------|
|
|
208
|
+
| Encryption | AES-256-GCM |
|
|
209
|
+
| Key Binding | Machine-bound keys |
|
|
210
|
+
| Input | Validated & sanitized |
|
|
211
|
+
| Rate Limiting | API protection |
|
|
212
|
+
| File Permissions | 0600 (owner only) |
|
|
213
|
+
| Credentials | Never stored in plain text |
|
|
207
214
|
|
|
208
215
|
---
|
|
209
216
|
|
|
210
|
-
##
|
|
217
|
+
## Changelog
|
|
211
218
|
|
|
212
|
-
|
|
219
|
+
<details>
|
|
220
|
+
<summary><b>v1.8.x (Current)</b></summary>
|
|
213
221
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
- Separate UI for One Account and Copy Trading
|
|
223
|
+
- Market hours validation
|
|
224
|
+
- Arrow keys navigation
|
|
225
|
+
- Contracts from API
|
|
226
|
+
- Native readline input
|
|
227
|
+
- Seamless UI design
|
|
228
|
+
- 40 visible activity logs
|
|
219
229
|
|
|
220
|
-
|
|
230
|
+
</details>
|
|
221
231
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
```
|
|
232
|
+
<details>
|
|
233
|
+
<summary><b>v1.7.x</b></summary>
|
|
225
234
|
|
|
226
|
-
|
|
235
|
+
- HQX Ultra-Scalping strategy
|
|
236
|
+
- Copy Trading single symbol
|
|
237
|
+
- Spinner indicators
|
|
238
|
+
- Cyan color theme
|
|
227
239
|
|
|
228
|
-
|
|
240
|
+
</details>
|
|
229
241
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
- Robust update function with confirmation
|
|
233
|
-
- Fixed stdin leak in menus
|
|
234
|
-
- Split services into modules
|
|
235
|
-
- Algo UI: logs now show newest at bottom
|
|
242
|
+
<details>
|
|
243
|
+
<summary><b>v1.3.x</b></summary>
|
|
236
244
|
|
|
237
|
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- Privacy mode for account names
|
|
245
|
+
- Major refactoring
|
|
246
|
+
- Robust update function
|
|
247
|
+
- Modular services
|
|
248
|
+
|
|
249
|
+
</details>
|
|
243
250
|
|
|
244
251
|
---
|
|
245
252
|
|
|
@@ -247,17 +254,28 @@ npm install -g hedgequantx@latest
|
|
|
247
254
|
|
|
248
255
|
- [x] ProjectX integration
|
|
249
256
|
- [x] Rithmic integration
|
|
250
|
-
- [x]
|
|
251
|
-
- [x] Multi-account
|
|
252
|
-
- [x] Stats
|
|
257
|
+
- [x] 37+ prop firms
|
|
258
|
+
- [x] Multi-account
|
|
259
|
+
- [x] Stats & equity curve
|
|
253
260
|
- [x] Encrypted sessions
|
|
254
|
-
- [x]
|
|
255
|
-
- [x]
|
|
256
|
-
- [x] HQX Server
|
|
257
|
-
- [
|
|
258
|
-
- [ ] Real-time
|
|
259
|
-
- [ ] Advanced
|
|
260
|
-
- [ ] Mobile
|
|
261
|
+
- [x] One Account mode
|
|
262
|
+
- [x] Copy Trading mode
|
|
263
|
+
- [x] HQX Server
|
|
264
|
+
- [x] Market hours check
|
|
265
|
+
- [ ] Real-time streaming
|
|
266
|
+
- [ ] Advanced orders
|
|
267
|
+
- [ ] Mobile app
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Support
|
|
272
|
+
|
|
273
|
+
<div align="center">
|
|
274
|
+
|
|
275
|
+
[](https://discord.gg/UBKCERctZu)
|
|
276
|
+
[](https://github.com/HedgeQuantX/HQX-CLI/issues)
|
|
277
|
+
|
|
278
|
+
</div>
|
|
261
279
|
|
|
262
280
|
---
|
|
263
281
|
|
|
@@ -269,15 +287,14 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
269
287
|
|
|
270
288
|
## Disclaimer
|
|
271
289
|
|
|
272
|
-
This software is for educational and informational purposes only. Trading futures involves substantial risk of loss and is not suitable for all investors. Past performance is not indicative of future results.
|
|
290
|
+
> This software is for educational and informational purposes only. Trading futures involves substantial risk of loss and is not suitable for all investors. Past performance is not indicative of future results.
|
|
273
291
|
|
|
274
292
|
---
|
|
275
293
|
|
|
276
|
-
|
|
294
|
+
<div align="center">
|
|
277
295
|
|
|
278
|
-
|
|
279
|
-
- GitHub Issues: [https://github.com/HedgeQuantX/HQX-CLI/issues](https://github.com/HedgeQuantX/HQX-CLI/issues)
|
|
296
|
+
**Made with passion by HedgeQuantX**
|
|
280
297
|
|
|
281
|
-
|
|
298
|
+
[](https://github.com/HedgeQuantX)
|
|
282
299
|
|
|
283
|
-
|
|
300
|
+
</div>
|
package/package.json
CHANGED
package/src/utils/prompts.js
CHANGED
|
@@ -6,6 +6,23 @@
|
|
|
6
6
|
const inquirer = require('inquirer');
|
|
7
7
|
const readline = require('readline');
|
|
8
8
|
|
|
9
|
+
// Shared readline instance
|
|
10
|
+
let rl = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get or create readline interface
|
|
14
|
+
*/
|
|
15
|
+
const getReadline = () => {
|
|
16
|
+
if (!rl || rl.closed) {
|
|
17
|
+
rl = readline.createInterface({
|
|
18
|
+
input: process.stdin,
|
|
19
|
+
output: process.stdout,
|
|
20
|
+
terminal: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return rl;
|
|
24
|
+
};
|
|
25
|
+
|
|
9
26
|
/**
|
|
10
27
|
* Ensure stdin is ready
|
|
11
28
|
*/
|
|
@@ -19,17 +36,14 @@ const prepareStdin = () => {
|
|
|
19
36
|
};
|
|
20
37
|
|
|
21
38
|
/**
|
|
22
|
-
* Native readline prompt
|
|
39
|
+
* Native readline prompt
|
|
23
40
|
*/
|
|
24
41
|
const nativePrompt = (message) => {
|
|
25
42
|
return new Promise((resolve) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
output: process.stdout
|
|
29
|
-
});
|
|
43
|
+
prepareStdin();
|
|
44
|
+
const r = getReadline();
|
|
30
45
|
|
|
31
|
-
|
|
32
|
-
rl.close();
|
|
46
|
+
r.question(message + ' ', (answer) => {
|
|
33
47
|
resolve(answer || '');
|
|
34
48
|
});
|
|
35
49
|
});
|
|
@@ -54,6 +68,7 @@ const textInput = async (message, defaultVal = '') => {
|
|
|
54
68
|
* Password input
|
|
55
69
|
*/
|
|
56
70
|
const passwordInput = async (message) => {
|
|
71
|
+
if (rl && !rl.closed) { rl.close(); rl = null; }
|
|
57
72
|
prepareStdin();
|
|
58
73
|
const { value } = await inquirer.prompt([{
|
|
59
74
|
type: 'password',
|
|
@@ -69,6 +84,7 @@ const passwordInput = async (message) => {
|
|
|
69
84
|
* Confirm - arrow keys selection
|
|
70
85
|
*/
|
|
71
86
|
const confirmPrompt = async (message, defaultVal = true) => {
|
|
87
|
+
if (rl && !rl.closed) { rl.close(); rl = null; }
|
|
72
88
|
prepareStdin();
|
|
73
89
|
const choices = defaultVal
|
|
74
90
|
? [{ name: 'Yes', value: true }, { name: 'No', value: false }]
|
|
@@ -89,6 +105,7 @@ const confirmPrompt = async (message, defaultVal = true) => {
|
|
|
89
105
|
* Number input
|
|
90
106
|
*/
|
|
91
107
|
const numberInput = async (message, defaultVal = 1, min = 1, max = 1000) => {
|
|
108
|
+
if (rl && !rl.closed) { rl.close(); rl = null; }
|
|
92
109
|
prepareStdin();
|
|
93
110
|
const { value } = await inquirer.prompt([{
|
|
94
111
|
type: 'input',
|
|
@@ -111,6 +128,11 @@ const numberInput = async (message, defaultVal = 1, min = 1, max = 1000) => {
|
|
|
111
128
|
* Select - arrow keys navigation
|
|
112
129
|
*/
|
|
113
130
|
const selectOption = async (message, options) => {
|
|
131
|
+
// Close shared readline before inquirer to avoid conflicts
|
|
132
|
+
if (rl && !rl.closed) {
|
|
133
|
+
rl.close();
|
|
134
|
+
rl = null;
|
|
135
|
+
}
|
|
114
136
|
prepareStdin();
|
|
115
137
|
|
|
116
138
|
const choices = options.map(opt => ({
|