netspeed-test-cli 1.0.1 → 1.3.1

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/bin/cli.js +95 -3
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -126,9 +126,7 @@ function printResult(type, value, icon) {
126
126
  console.log(chalk.white(' └' + '─'.repeat(20) + '┘'));
127
127
  }
128
128
 
129
- async function main() {
130
- printHeader();
131
-
129
+ async function runSpeedTest() {
132
130
  console.log(chalk.gray(' Starting speed test...\n'));
133
131
 
134
132
  const pingStop = showSpinner('Measuring ping...');
@@ -152,6 +150,100 @@ async function main() {
152
150
  console.log();
153
151
  console.log(chalk.gray(' ' + '─'.repeat(40)));
154
152
  console.log();
153
+
154
+ console.log(chalk.gray('\n Press ENTER to continue...'));
155
+ const readline = await import('readline');
156
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
157
+ rl.question('', () => { rl.close(); main(); });
158
+ }
159
+
160
+ async function showMenu() {
161
+ printHeader();
162
+ console.log(chalk.white(' ┌──────────────────────────┐'));
163
+ console.log(chalk.white(' │') + chalk.cyan(' SELECT OPTION ') + chalk.white('│'));
164
+ console.log(chalk.white(' ├──────────────────────────┤'));
165
+ console.log(chalk.white(' │ ') + chalk.green('1.') + chalk.white(' Run Speed Test ') + chalk.white('│'));
166
+ console.log(chalk.white(' │ ') + chalk.yellow('2.') + chalk.white(' View Version ') + chalk.white('│'));
167
+ console.log(chalk.white(' │ ') + chalk.cyan('3.') + chalk.white(' Update ') + chalk.white('│'));
168
+ console.log(chalk.white(' │ ') + chalk.red('4.') + chalk.white(' Exit ') + chalk.white('│'));
169
+ console.log(chalk.white(' └──────────────────────────┘'));
170
+ console.log();
171
+
172
+ const readline = await import('readline');
173
+ const rl = readline.createInterface({
174
+ input: process.stdin,
175
+ output: process.stdout
176
+ });
177
+
178
+ return new Promise((resolve) => {
179
+ rl.question(chalk.gray(' Enter your choice: '), async (answer) => {
180
+ rl.close();
181
+ console.log();
182
+ resolve(answer.trim());
183
+ });
184
+ });
185
+ }
186
+
187
+ async function updatePackage() {
188
+ console.log(chalk.cyan(' Checking for updates...\n'));
189
+
190
+ const { execSync } = await import('child_process');
191
+
192
+ try {
193
+ execSync('npm install -g netspeed-test-cli', { stdio: 'inherit' });
194
+ console.log(chalk.green('\n ✓ Update successful!'));
195
+ } catch (e) {
196
+ console.log(chalk.red('\n ✗ Update failed. Try running: npm install -g netspeed-test-cli'));
197
+ }
198
+
199
+ console.log(chalk.gray('\n Press ENTER to continue...'));
200
+ const readline = await import('readline');
201
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
202
+ rl.question('', () => { rl.close(); main(); });
203
+ }
204
+
205
+ function showVersion() {
206
+ console.log(chalk.white(' ┌──────────────────────────┐'));
207
+ console.log(chalk.white(' │') + chalk.cyan(' VERSION INFO ') + chalk.white('│'));
208
+ console.log(chalk.white(' ├──────────────────────────┤'));
209
+ console.log(chalk.white(' │ netspeed-cli: ') + chalk.green('1.1.0') + chalk.white(' '.repeat(14) + '│'));
210
+ console.log(chalk.white(' │ Node.js: ') + chalk.green(process.version) + chalk.white(' '.repeat(14 - process.version.length) + '│'));
211
+ console.log(chalk.white(' └──────────────────────────┘'));
212
+ console.log();
213
+ console.log(chalk.gray(' Press ENTER to continue...'));
214
+ }
215
+
216
+ async function main() {
217
+ const choice = await showMenu();
218
+
219
+ switch (choice) {
220
+ case '1':
221
+ await runSpeedTest();
222
+ break;
223
+ case '2':
224
+ showVersion();
225
+ await waitForEnter();
226
+ await main();
227
+ break;
228
+ case '3':
229
+ await updatePackage();
230
+ break;
231
+ case '4':
232
+ console.log(chalk.gray(' Goodbye! 👋\n'));
233
+ process.exit(0);
234
+ default:
235
+ console.log(chalk.red(' Invalid choice. Press ENTER to try again.'));
236
+ await waitForEnter();
237
+ await main();
238
+ }
239
+ }
240
+
241
+ async function waitForEnter() {
242
+ const readline = await import('readline');
243
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
244
+ return new Promise((resolve) => {
245
+ rl.question('', () => { rl.close(); resolve(); });
246
+ });
155
247
  }
156
248
 
157
249
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netspeed-test-cli",
3
- "version": "1.0.1",
3
+ "version": "1.3.1",
4
4
  "description": "Internet speed test CLI tool",
5
5
  "bin": {
6
6
  "netspeed": "bin/cli.js"