nport 2.0.2 → 2.0.4

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/index.js +35 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -302,7 +302,26 @@ class APIClient {
302
302
  if (error.response?.data?.error) {
303
303
  const errorMsg = error.response.data.error;
304
304
 
305
- // Check for duplicate tunnel error
305
+ // Check for subdomain in use (active tunnel)
306
+ if (
307
+ errorMsg.includes("SUBDOMAIN_IN_USE:") ||
308
+ errorMsg.includes("currently in use") ||
309
+ errorMsg.includes("already exists and is currently active")
310
+ ) {
311
+ return new Error(
312
+ chalk.red(`āœ— Subdomain "${subdomain}" is already in use!\n\n`) +
313
+ chalk.yellow(`šŸ’” This subdomain is currently being used by another active tunnel.\n\n`) +
314
+ chalk.white(`Choose a different subdomain:\n`) +
315
+ chalk.gray(` 1. Add a suffix: `) +
316
+ chalk.cyan(`nport ${state.port || CONFIG.DEFAULT_PORT} -s ${subdomain}-2\n`) +
317
+ chalk.gray(` 2. Try a variation: `) +
318
+ chalk.cyan(`nport ${state.port || CONFIG.DEFAULT_PORT} -s my-${subdomain}\n`) +
319
+ chalk.gray(` 3. Use random name: `) +
320
+ chalk.cyan(`nport ${state.port || CONFIG.DEFAULT_PORT}\n`)
321
+ );
322
+ }
323
+
324
+ // Check for duplicate tunnel error (other Cloudflare errors)
306
325
  if (
307
326
  errorMsg.includes("already have a tunnel") ||
308
327
  errorMsg.includes("[1013]")
@@ -393,6 +412,13 @@ class UI {
393
412
  if (!updateInfo || !updateInfo.shouldUpdate) return;
394
413
 
395
414
  const border = "═".repeat(59);
415
+ const boxWidth = 59;
416
+
417
+ // Calculate padding dynamically
418
+ const currentVersionText = ` Current version: v${updateInfo.current}`;
419
+ const latestVersionText = ` Latest version: v${updateInfo.latest}`;
420
+ const runCommandText = ` Run: npm install -g ${CONFIG.PACKAGE_NAME}@latest`;
421
+
396
422
  console.log(chalk.yellow(`\nā•”${border}ā•—`));
397
423
  console.log(
398
424
  chalk.yellow("ā•‘") +
@@ -405,14 +431,14 @@ class UI {
405
431
  chalk.yellow("ā•‘") +
406
432
  chalk.gray(` Current version: `) +
407
433
  chalk.red(`v${updateInfo.current}`) +
408
- " ".repeat(26) +
434
+ " ".repeat(boxWidth - currentVersionText.length) +
409
435
  chalk.yellow("ā•‘")
410
436
  );
411
437
  console.log(
412
438
  chalk.yellow("ā•‘") +
413
439
  chalk.gray(` Latest version: `) +
414
440
  chalk.green(`v${updateInfo.latest}`) +
415
- " ".repeat(26) +
441
+ " ".repeat(boxWidth - latestVersionText.length) +
416
442
  chalk.yellow("ā•‘")
417
443
  );
418
444
  console.log(chalk.yellow(`ā• ${border}ā•£`));
@@ -420,7 +446,7 @@ class UI {
420
446
  chalk.yellow("ā•‘") +
421
447
  chalk.cyan(` Run: `) +
422
448
  chalk.bold(`npm install -g ${CONFIG.PACKAGE_NAME}@latest`) +
423
- " ".repeat(10) +
449
+ " ".repeat(boxWidth - runCommandText.length) +
424
450
  chalk.yellow("ā•‘")
425
451
  );
426
452
  console.log(chalk.yellow(`ā•š${border}ā•\n`));
@@ -536,7 +562,9 @@ class TunnelOrchestrator {
536
562
 
537
563
  // Validate binary
538
564
  if (!BinaryManager.validate(PATHS.BIN_PATH)) {
539
- await analytics.trackTunnelError("binary_missing", "Cloudflared binary not found");
565
+ analytics.trackTunnelError("binary_missing", "Cloudflared binary not found");
566
+ // Give analytics a moment to send before exiting
567
+ await new Promise(resolve => setTimeout(resolve, 100));
540
568
  process.exit(1);
541
569
  }
542
570
 
@@ -576,6 +604,8 @@ class TunnelOrchestrator {
576
604
  analytics.trackTunnelError(errorType, error.message);
577
605
 
578
606
  UI.displayError(error, spinner);
607
+ // Give analytics a moment to send before exiting
608
+ await new Promise(resolve => setTimeout(resolve, 100));
579
609
  process.exit(1);
580
610
  }
581
611
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nport",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Free & open source ngrok alternative - Tunnel HTTP/HTTPS connections via Cloudflare Edge with custom subdomains",
5
5
  "type": "module",
6
6
  "main": "index.js",