nport 2.0.7 → 2.1.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 (77) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/README.md +42 -32
  3. package/dist/analytics.d.ts +59 -0
  4. package/dist/analytics.js +193 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/api.d.ts +20 -0
  7. package/dist/api.js +85 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/args.d.ts +44 -0
  10. package/dist/args.js +127 -0
  11. package/dist/args.js.map +1 -0
  12. package/dist/bin-manager.d.ts +1 -0
  13. package/dist/bin-manager.js +209 -0
  14. package/dist/bin-manager.js.map +1 -0
  15. package/dist/binary.d.ts +42 -0
  16. package/dist/binary.js +119 -0
  17. package/dist/binary.js.map +1 -0
  18. package/dist/config-manager.d.ts +54 -0
  19. package/dist/config-manager.js +129 -0
  20. package/dist/config-manager.js.map +1 -0
  21. package/dist/config.d.ts +25 -0
  22. package/dist/config.js +59 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/constants.d.ts +61 -0
  25. package/dist/constants.js +86 -0
  26. package/dist/constants.js.map +1 -0
  27. package/dist/index.d.ts +7 -0
  28. package/dist/index.js +92 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/lang.d.ts +38 -0
  31. package/dist/lang.js +217 -0
  32. package/dist/lang.js.map +1 -0
  33. package/dist/state.d.ts +82 -0
  34. package/dist/state.js +139 -0
  35. package/dist/state.js.map +1 -0
  36. package/dist/tunnel.d.ts +16 -0
  37. package/dist/tunnel.js +101 -0
  38. package/dist/tunnel.js.map +1 -0
  39. package/dist/types/analytics.d.ts +91 -0
  40. package/dist/types/analytics.js +8 -0
  41. package/dist/types/analytics.js.map +1 -0
  42. package/dist/types/config.d.ts +89 -0
  43. package/dist/types/config.js +8 -0
  44. package/dist/types/config.js.map +1 -0
  45. package/dist/types/i18n.d.ts +75 -0
  46. package/dist/types/i18n.js +5 -0
  47. package/dist/types/i18n.js.map +1 -0
  48. package/dist/types/index.d.ts +10 -0
  49. package/dist/types/index.js +7 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/types/tunnel.d.ts +74 -0
  52. package/dist/types/tunnel.js +8 -0
  53. package/dist/types/tunnel.js.map +1 -0
  54. package/dist/types/version.d.ts +25 -0
  55. package/dist/types/version.js +5 -0
  56. package/dist/types/version.js.map +1 -0
  57. package/dist/ui.d.ts +54 -0
  58. package/dist/ui.js +120 -0
  59. package/dist/ui.js.map +1 -0
  60. package/dist/version.d.ts +16 -0
  61. package/dist/version.js +49 -0
  62. package/dist/version.js.map +1 -0
  63. package/package.json +18 -7
  64. package/scripts/postinstall.js +25 -0
  65. package/index.js +0 -110
  66. package/src/analytics.js +0 -265
  67. package/src/api.js +0 -104
  68. package/src/args.js +0 -122
  69. package/src/bin-manager.js +0 -379
  70. package/src/binary.js +0 -126
  71. package/src/config-manager.js +0 -139
  72. package/src/config.js +0 -88
  73. package/src/lang.js +0 -293
  74. package/src/state.js +0 -115
  75. package/src/tunnel.js +0 -116
  76. package/src/ui.js +0 -103
  77. package/src/version.js +0 -56
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Analytics type definitions
3
+ *
4
+ * These types define the structure of analytics events
5
+ * and tracking data.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/types/analytics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Configuration type definitions
3
+ *
4
+ * These types define the structure of application configuration,
5
+ * user preferences, and runtime settings.
6
+ */
7
+ /**
8
+ * Parsed command-line arguments
9
+ */
10
+ export interface ParsedArguments {
11
+ /** Local port to tunnel (default: 8080) */
12
+ port: number;
13
+ /** Subdomain to use (generated if not provided) */
14
+ subdomain: string;
15
+ /** Language code, 'prompt', or null */
16
+ language: string | null;
17
+ /** Custom backend URL or null */
18
+ backendUrl: string | null;
19
+ /** Backend URL to save, 'clear', or null */
20
+ setBackend: string | null;
21
+ }
22
+ /**
23
+ * User configuration stored in ~/.nport/config.json
24
+ */
25
+ export interface UserConfig {
26
+ /** Preferred language code (e.g., "en", "vi") */
27
+ language?: string;
28
+ /** Custom backend URL */
29
+ backendUrl?: string;
30
+ }
31
+ /**
32
+ * Application constants configuration
33
+ */
34
+ export interface AppConfig {
35
+ /** npm package name */
36
+ PACKAGE_NAME: string;
37
+ /** Current package version */
38
+ CURRENT_VERSION: string;
39
+ /** Backend API URL */
40
+ BACKEND_URL: string;
41
+ /** Default port if not specified */
42
+ DEFAULT_PORT: number;
43
+ /** Prefix for random subdomains */
44
+ SUBDOMAIN_PREFIX: string;
45
+ /** Auto-cleanup timeout in hours */
46
+ TUNNEL_TIMEOUT_HOURS: number;
47
+ /** Timeout for npm version check in ms */
48
+ UPDATE_CHECK_TIMEOUT: number;
49
+ }
50
+ /**
51
+ * Platform-specific configuration
52
+ */
53
+ export interface PlatformConfig {
54
+ /** True if running on Windows */
55
+ IS_WINDOWS: boolean;
56
+ /** Binary filename ("cloudflared" or "cloudflared.exe") */
57
+ BIN_NAME: string;
58
+ }
59
+ /**
60
+ * File system paths configuration
61
+ */
62
+ export interface PathsConfig {
63
+ /** Directory containing the cloudflared binary */
64
+ BIN_DIR: string;
65
+ /** Full path to the cloudflared binary */
66
+ BIN_PATH: string;
67
+ }
68
+ /**
69
+ * Log pattern categories for filtering cloudflared output
70
+ */
71
+ export interface LogPatterns {
72
+ /** Patterns indicating successful connection */
73
+ readonly SUCCESS: readonly string[];
74
+ /** Patterns indicating critical errors */
75
+ readonly ERROR: readonly string[];
76
+ /** Patterns for network connectivity issues */
77
+ readonly NETWORK_WARNING: readonly string[];
78
+ /** Patterns for harmless messages to suppress */
79
+ readonly IGNORE: readonly string[];
80
+ }
81
+ /**
82
+ * Network warning display configuration
83
+ */
84
+ export interface NetworkConfig {
85
+ /** Number of errors before showing warning */
86
+ WARNING_THRESHOLD: number;
87
+ /** Minimum ms between warnings */
88
+ WARNING_COOLDOWN: number;
89
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Configuration type definitions
3
+ *
4
+ * These types define the structure of application configuration,
5
+ * user preferences, and runtime settings.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Internationalization type definitions
3
+ */
4
+ /**
5
+ * Supported language codes
6
+ */
7
+ export type LanguageCode = 'en' | 'vi';
8
+ /**
9
+ * Translation keys used in the application
10
+ */
11
+ export interface TranslationKeys {
12
+ header: string;
13
+ creatingTunnel: string;
14
+ checkingUpdates: string;
15
+ tunnelLive: string;
16
+ connection1: string;
17
+ connection2: string;
18
+ timeRemaining: string;
19
+ footerTitle: string;
20
+ footerSubtitle: string;
21
+ dropStar: string;
22
+ sendCoffee: string;
23
+ newVersion: string;
24
+ updateCommand: string;
25
+ tunnelShutdown: string;
26
+ cleaningUp: string;
27
+ cleanupDone: string;
28
+ cleanupFailed: string;
29
+ subdomainReleased: string;
30
+ serverBusy: string;
31
+ goodbyeTitle: string;
32
+ goodbyeMessage: string;
33
+ website: string;
34
+ author: string;
35
+ changeLanguage: string;
36
+ changeLanguageHint: string;
37
+ versionTitle: string;
38
+ versionSubtitle: string;
39
+ versionLatest: string;
40
+ versionAvailable: string;
41
+ versionUpdate: string;
42
+ learnMore: string;
43
+ languagePrompt: string;
44
+ languageQuestion: string;
45
+ languageEnglish: string;
46
+ languageVietnamese: string;
47
+ languageInvalid: string;
48
+ languageSaved: string;
49
+ networkIssueTitle: string;
50
+ networkIssueDesc: string;
51
+ networkIssueTunnel: string;
52
+ networkIssueReasons: string;
53
+ networkIssueReason1: string;
54
+ networkIssueReason2: string;
55
+ networkIssueReason3: string;
56
+ networkIssueFix: string;
57
+ networkIssueFix1: string;
58
+ networkIssueFix2: string;
59
+ networkIssueFix3: string;
60
+ networkIssueFix4: string;
61
+ networkIssueIgnore: string;
62
+ }
63
+ /**
64
+ * Translation dictionary for all languages
65
+ */
66
+ export type Translations = Record<LanguageCode, TranslationKeys>;
67
+ /**
68
+ * Variables that can be substituted in translation strings
69
+ */
70
+ export interface TranslationVariables {
71
+ port?: number;
72
+ hours?: number;
73
+ version?: string;
74
+ [key: string]: string | number | undefined;
75
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Internationalization type definitions
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/types/i18n.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * NPort - Shared Types
3
+ *
4
+ * Central export for all type definitions used across the application.
5
+ */
6
+ export type { TunnelConfig, TunnelResponse, ApiResponse, CreateTunnelApiResponse, TunnelState, ShutdownReason, TunnelEvent, } from './tunnel.js';
7
+ export type { ParsedArguments, UserConfig, AppConfig, PlatformConfig, PathsConfig, LogPatterns, NetworkConfig, } from './config.js';
8
+ export type { AnalyticsEvent, CliStartEventParams, TunnelCreatedEventParams, TunnelErrorEventParams, TunnelShutdownEventParams, UpdateAvailableEventParams, SystemInfo, GA4Payload, } from './analytics.js';
9
+ export type { UpdateCheckResult, NpmPackageInfo, } from './version.js';
10
+ export type { LanguageCode, TranslationKeys, Translations, TranslationVariables, } from './i18n.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * NPort - Shared Types
3
+ *
4
+ * Central export for all type definitions used across the application.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Tunnel-related type definitions
3
+ *
4
+ * These types define the data structures used for tunnel creation,
5
+ * management, and communication between CLI and backend.
6
+ */
7
+ /**
8
+ * Configuration for creating a new tunnel
9
+ */
10
+ export interface TunnelConfig {
11
+ /** Local port to tunnel (e.g., 3000) */
12
+ port: number;
13
+ /** Subdomain to use (e.g., "myapp" for myapp.nport.link) */
14
+ subdomain: string;
15
+ /** Custom backend URL or null for default */
16
+ backendUrl: string | null;
17
+ /** Language code or null for default */
18
+ language: string | null;
19
+ }
20
+ /**
21
+ * Response from the backend after creating a tunnel
22
+ */
23
+ export interface TunnelResponse {
24
+ /** UUID of the created tunnel */
25
+ tunnelId: string;
26
+ /** Base64-encoded token for cloudflared authentication */
27
+ tunnelToken: string;
28
+ /** Full HTTPS URL of the tunnel (e.g., "https://myapp.nport.link") */
29
+ url: string;
30
+ }
31
+ /**
32
+ * Backend API response wrapper
33
+ */
34
+ export interface ApiResponse<T = unknown> {
35
+ /** Whether the request was successful */
36
+ success: boolean;
37
+ /** Error message if success is false */
38
+ error?: string;
39
+ /** Response data if success is true */
40
+ data?: T;
41
+ }
42
+ /**
43
+ * Create tunnel API response
44
+ */
45
+ export interface CreateTunnelApiResponse extends ApiResponse {
46
+ tunnelId?: string;
47
+ tunnelToken?: string;
48
+ url?: string;
49
+ }
50
+ /**
51
+ * Tunnel state information
52
+ */
53
+ export interface TunnelState {
54
+ /** UUID of the current tunnel */
55
+ tunnelId: string | null;
56
+ /** Current subdomain */
57
+ subdomain: string | null;
58
+ /** Local port being tunneled */
59
+ port: number | null;
60
+ /** Custom backend URL */
61
+ backendUrl: string | null;
62
+ /** Number of established connections */
63
+ connectionCount: number;
64
+ /** Timestamp when tunnel was created */
65
+ startTime: number | null;
66
+ }
67
+ /**
68
+ * Shutdown reason types
69
+ */
70
+ export type ShutdownReason = 'manual' | 'timeout' | 'error';
71
+ /**
72
+ * Tunnel lifecycle events
73
+ */
74
+ export type TunnelEvent = 'created' | 'connected' | 'disconnected' | 'error' | 'shutdown';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tunnel-related type definitions
3
+ *
4
+ * These types define the data structures used for tunnel creation,
5
+ * management, and communication between CLI and backend.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=tunnel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/types/tunnel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Version-related type definitions
3
+ */
4
+ /**
5
+ * Result of checking for updates
6
+ */
7
+ export interface UpdateCheckResult {
8
+ /** Currently installed version */
9
+ current: string;
10
+ /** Latest version available on npm */
11
+ latest: string;
12
+ /** True if latest > current */
13
+ shouldUpdate: boolean;
14
+ }
15
+ /**
16
+ * npm registry package response (partial)
17
+ */
18
+ export interface NpmPackageInfo {
19
+ /** Package name */
20
+ name: string;
21
+ /** Latest version */
22
+ version: string;
23
+ /** Package description */
24
+ description?: string;
25
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Version-related type definitions
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/types/version.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { UpdateCheckResult } from './types/index.js';
2
+ /**
3
+ * UI Display Manager
4
+ *
5
+ * Handles all console output and user interface formatting.
6
+ */
7
+ export declare class UI {
8
+ /**
9
+ * Displays the project info header box.
10
+ */
11
+ static displayProjectInfo(): void;
12
+ /**
13
+ * Displays the startup banner.
14
+ */
15
+ static displayStartupBanner(_port: number): void;
16
+ /**
17
+ * Displays the tunnel success message.
18
+ */
19
+ static displayTunnelSuccess(url: string, _port: number, _updateInfo: UpdateCheckResult | null): void;
20
+ /**
21
+ * Displays the footer with call-to-action links.
22
+ */
23
+ static displayFooter(updateInfo: UpdateCheckResult | null): void;
24
+ /**
25
+ * Displays timeout warning.
26
+ */
27
+ static displayTimeoutWarning(): void;
28
+ /**
29
+ * Displays an error message.
30
+ */
31
+ static displayError(error: Error, spinner?: {
32
+ fail: (msg: string) => void;
33
+ } | null): void;
34
+ /**
35
+ * Displays cleanup start.
36
+ */
37
+ static displayCleanupStart(): void;
38
+ /**
39
+ * Displays cleanup success.
40
+ */
41
+ static displayCleanupSuccess(): void;
42
+ /**
43
+ * Displays cleanup error.
44
+ */
45
+ static displayCleanupError(): void;
46
+ /**
47
+ * Displays goodbye message.
48
+ */
49
+ static displayGoodbye(): void;
50
+ /**
51
+ * Displays version information.
52
+ */
53
+ static displayVersion(current: string, updateInfo: UpdateCheckResult | null): void;
54
+ }
package/dist/ui.js ADDED
@@ -0,0 +1,120 @@
1
+ import chalk from 'chalk';
2
+ import { GITHUB_URL, COFFEE_URL, WEBSITE_URL } from './constants.js';
3
+ import { CONFIG } from './config.js';
4
+ import { lang } from './lang.js';
5
+ /**
6
+ * UI Display Manager
7
+ *
8
+ * Handles all console output and user interface formatting.
9
+ */
10
+ export class UI {
11
+ /**
12
+ * Displays the project info header box.
13
+ */
14
+ static displayProjectInfo() {
15
+ const line = '─'.repeat(56);
16
+ const headerText = lang.t('header');
17
+ const visualLength = 59;
18
+ const padding = ' '.repeat(Math.max(0, visualLength - headerText.length - 4));
19
+ console.log(chalk.gray(`\n ╭${line}╮`));
20
+ console.log(chalk.cyan.bold(` │ ${headerText}`) + padding + chalk.gray('│'));
21
+ console.log(chalk.gray(` ╰${line}╯\n`));
22
+ }
23
+ /**
24
+ * Displays the startup banner.
25
+ */
26
+ static displayStartupBanner(_port) {
27
+ this.displayProjectInfo();
28
+ }
29
+ /**
30
+ * Displays the tunnel success message.
31
+ */
32
+ static displayTunnelSuccess(url, _port, _updateInfo) {
33
+ console.log();
34
+ console.log(chalk.cyan.bold(` 👉 ${url} 👈\n`));
35
+ console.log(chalk.gray(' ' + '─'.repeat(54) + '\n'));
36
+ console.log(chalk.gray(` ${lang.t('timeRemaining', { hours: CONFIG.TUNNEL_TIMEOUT_HOURS })}\n`));
37
+ }
38
+ /**
39
+ * Displays the footer with call-to-action links.
40
+ */
41
+ static displayFooter(updateInfo) {
42
+ console.log(chalk.gray(' ' + '─'.repeat(54) + '\n'));
43
+ console.log(chalk.yellow.bold(` ${lang.t('footerTitle')}\n`));
44
+ console.log(chalk.gray(` ${lang.t('footerSubtitle')}\n`));
45
+ console.log(chalk.cyan(` ${lang.t('dropStar')}`) + chalk.white(GITHUB_URL));
46
+ console.log(chalk.yellow(` ${lang.t('sendCoffee')}`) + chalk.white(COFFEE_URL));
47
+ if (updateInfo?.shouldUpdate) {
48
+ console.log(chalk.red.bold(`\n ${lang.t('newVersion', { version: updateInfo.latest })}`));
49
+ console.log(chalk.gray(' ') + chalk.cyan(lang.t('updateCommand')));
50
+ }
51
+ console.log();
52
+ }
53
+ /**
54
+ * Displays timeout warning.
55
+ */
56
+ static displayTimeoutWarning() {
57
+ console.log(chalk.yellow(`\n⏰ Tunnel has been running for ${CONFIG.TUNNEL_TIMEOUT_HOURS} hours.`));
58
+ console.log(chalk.yellow(' Automatically shutting down...'));
59
+ }
60
+ /**
61
+ * Displays an error message.
62
+ */
63
+ static displayError(error, spinner = null) {
64
+ if (spinner) {
65
+ spinner.fail('Failed to connect to server.');
66
+ }
67
+ console.error(chalk.red(error.message));
68
+ }
69
+ /**
70
+ * Displays cleanup start.
71
+ */
72
+ static displayCleanupStart() {
73
+ console.log(chalk.red.bold(`\n\n ${lang.t('tunnelShutdown')}\n`));
74
+ process.stdout.write(chalk.gray(` ${lang.t('cleaningUp')}`));
75
+ }
76
+ /**
77
+ * Displays cleanup success.
78
+ */
79
+ static displayCleanupSuccess() {
80
+ console.log(chalk.green(lang.t('cleanupDone')));
81
+ console.log(chalk.gray(` ${lang.t('subdomainReleased')}\n`));
82
+ this.displayGoodbye();
83
+ }
84
+ /**
85
+ * Displays cleanup error.
86
+ */
87
+ static displayCleanupError() {
88
+ console.log(chalk.red(lang.t('cleanupFailed')));
89
+ console.log(chalk.gray(` ${lang.t('serverBusy')}\n`));
90
+ this.displayGoodbye();
91
+ }
92
+ /**
93
+ * Displays goodbye message.
94
+ */
95
+ static displayGoodbye() {
96
+ console.log(chalk.gray(' ' + '─'.repeat(54) + '\n'));
97
+ console.log(chalk.cyan.bold(` ${lang.t('goodbyeTitle')}\n`));
98
+ console.log(chalk.gray(` ${lang.t('goodbyeMessage')}\n`));
99
+ console.log(chalk.cyan(` ${lang.t('website')}`) + chalk.white(WEBSITE_URL));
100
+ console.log(chalk.cyan(` ${lang.t('author')}`) + chalk.white('Nick Pham (https://github.com/tuanngocptn)'));
101
+ console.log(chalk.cyan(` ${lang.t('changeLanguage')}`) + chalk.yellow(lang.t('changeLanguageHint')));
102
+ console.log();
103
+ }
104
+ /**
105
+ * Displays version information.
106
+ */
107
+ static displayVersion(current, updateInfo) {
108
+ console.log(chalk.cyan.bold(`\n${lang.t('versionTitle', { version: current })}`));
109
+ console.log(chalk.gray(`${lang.t('versionSubtitle')}\n`));
110
+ if (updateInfo?.shouldUpdate) {
111
+ console.log(chalk.yellow(lang.t('versionAvailable', { version: updateInfo.latest })));
112
+ console.log(chalk.cyan(lang.t('versionUpdate')) + chalk.white('npm install -g nport@latest\n'));
113
+ }
114
+ else {
115
+ console.log(chalk.green(`${lang.t('versionLatest')}\n`));
116
+ }
117
+ console.log(chalk.gray(lang.t('learnMore')) + chalk.cyan(`${WEBSITE_URL}\n`));
118
+ }
119
+ }
120
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAA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+ *
5
+ * Handles version checking and update notifications.
6
+ */
7
+ export declare class VersionManager {
8
+ /**
9
+ * Checks the npm registry for available updates.
10
+ */
11
+ static checkForUpdates(): Promise<UpdateCheckResult | null>;
12
+ /**
13
+ * Compares two semantic version strings.
14
+ */
15
+ static compareVersions(v1: string, v2: string): number;
16
+ }
@@ -0,0 +1,49 @@
1
+ import axios from 'axios';
2
+ import { CONFIG } from './config.js';
3
+ import { analytics } from './analytics.js';
4
+ /**
5
+ * Version Manager
6
+ *
7
+ * Handles version checking and update notifications.
8
+ */
9
+ export class VersionManager {
10
+ /**
11
+ * Checks the npm registry for available updates.
12
+ */
13
+ static async checkForUpdates() {
14
+ try {
15
+ const response = await axios.get(`https://registry.npmjs.org/${CONFIG.PACKAGE_NAME}/latest`, { timeout: CONFIG.UPDATE_CHECK_TIMEOUT });
16
+ const latestVersion = response.data.version;
17
+ const shouldUpdate = this.compareVersions(latestVersion, CONFIG.CURRENT_VERSION) > 0;
18
+ if (shouldUpdate) {
19
+ analytics.trackUpdateAvailable(CONFIG.CURRENT_VERSION, latestVersion);
20
+ }
21
+ return {
22
+ current: CONFIG.CURRENT_VERSION,
23
+ latest: latestVersion,
24
+ shouldUpdate,
25
+ };
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ /**
32
+ * Compares two semantic version strings.
33
+ */
34
+ static compareVersions(v1, v2) {
35
+ const parts1 = v1.split('.').map(Number);
36
+ const parts2 = v2.split('.').map(Number);
37
+ const maxLength = Math.max(parts1.length, parts2.length);
38
+ for (let i = 0; i < maxLength; i++) {
39
+ const part1 = parts1[i] || 0;
40
+ const part2 = parts2[i] || 0;
41
+ if (part1 > part2)
42
+ return 1;
43
+ if (part1 < part2)
44
+ return -1;
45
+ }
46
+ return 0;
47
+ }
48
+ }
49
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MA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,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAE7B,IAAI,KAAK,GAAG,KAAK;gBAAE,OAAO,CAAC,CAAC;YAC5B,IAAI,KAAK,GAAG,KAAK;gBAAE,OAAO,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "nport",
3
- "version": "2.0.7",
3
+ "version": "2.1.1",
4
4
  "description": "Free & open source ngrok alternative - Tunnel HTTP/HTTPS connections via Cloudflare Edge with custom subdomains",
5
5
  "type": "module",
6
- "main": "index.js",
6
+ "main": "dist/index.js",
7
7
  "bin": {
8
- "nport": "index.js"
8
+ "nport": "dist/index.js"
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=20.0.0",
@@ -63,17 +63,28 @@
63
63
  }
64
64
  ],
65
65
  "scripts": {
66
- "postinstall": "node src/bin-manager.js",
67
- "start": "node index.js"
66
+ "build": "tsc",
67
+ "dev": "tsc --watch",
68
+ "start": "node dist/index.js",
69
+ "postinstall": "node scripts/postinstall.js",
70
+ "test": "vitest run",
71
+ "test:watch": "vitest",
72
+ "lint": "tsc --noEmit"
68
73
  },
69
74
  "dependencies": {
70
75
  "axios": "^1.13.2",
71
76
  "chalk": "^5.6.2",
72
77
  "ora": "^9.0.0"
73
78
  },
79
+ "devDependencies": {
80
+ "@types/node": "^22.0.0",
81
+ "typescript": "^5.7.0",
82
+ "vitest": "~3.2.0"
83
+ },
74
84
  "files": [
75
- "index.js",
76
- "src/",
85
+ "dist/",
86
+ "bin/",
87
+ "scripts/",
77
88
  "README.md",
78
89
  "CHANGELOG.md",
79
90
  "LICENSE"