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.
- package/CHANGELOG.md +173 -0
- package/README.md +42 -32
- package/dist/analytics.d.ts +59 -0
- package/dist/analytics.js +193 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api.d.ts +20 -0
- package/dist/api.js +85 -0
- package/dist/api.js.map +1 -0
- package/dist/args.d.ts +44 -0
- package/dist/args.js +127 -0
- package/dist/args.js.map +1 -0
- package/dist/bin-manager.d.ts +1 -0
- package/dist/bin-manager.js +209 -0
- package/dist/bin-manager.js.map +1 -0
- package/dist/binary.d.ts +42 -0
- package/dist/binary.js +119 -0
- package/dist/binary.js.map +1 -0
- package/dist/config-manager.d.ts +54 -0
- package/dist/config-manager.js +129 -0
- package/dist/config-manager.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +61 -0
- package/dist/constants.js +86 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/lang.d.ts +38 -0
- package/dist/lang.js +217 -0
- package/dist/lang.js.map +1 -0
- package/dist/state.d.ts +82 -0
- package/dist/state.js +139 -0
- package/dist/state.js.map +1 -0
- package/dist/tunnel.d.ts +16 -0
- package/dist/tunnel.js +101 -0
- package/dist/tunnel.js.map +1 -0
- package/dist/types/analytics.d.ts +91 -0
- package/dist/types/analytics.js +8 -0
- package/dist/types/analytics.js.map +1 -0
- package/dist/types/config.d.ts +89 -0
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/i18n.d.ts +75 -0
- package/dist/types/i18n.js +5 -0
- package/dist/types/i18n.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/tunnel.d.ts +74 -0
- package/dist/types/tunnel.js +8 -0
- package/dist/types/tunnel.js.map +1 -0
- package/dist/types/version.d.ts +25 -0
- package/dist/types/version.js +5 -0
- package/dist/types/version.js.map +1 -0
- package/dist/ui.d.ts +54 -0
- package/dist/ui.js +120 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +16 -0
- package/dist/version.js +49 -0
- package/dist/version.js.map +1 -0
- package/package.json +18 -7
- package/scripts/postinstall.js +25 -0
- package/index.js +0 -110
- package/src/analytics.js +0 -265
- package/src/api.js +0 -104
- package/src/args.js +0 -122
- package/src/bin-manager.js +0 -379
- package/src/binary.js +0 -126
- package/src/config-manager.js +0 -139
- package/src/config.js +0 -88
- package/src/lang.js +0 -293
- package/src/state.js +0 -115
- package/src/tunnel.js +0 -116
- package/src/ui.js +0 -103
- package/src/version.js +0 -56
package/src/ui.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { CONFIG } from "./config.js";
|
|
3
|
-
import { lang } from "./lang.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* UI Display Manager
|
|
7
|
-
* Handles all console output and user interface with multilingual support
|
|
8
|
-
*/
|
|
9
|
-
export class UI {
|
|
10
|
-
static displayProjectInfo() {
|
|
11
|
-
const line = "─".repeat(56);
|
|
12
|
-
const headerText = lang.t("header");
|
|
13
|
-
// Calculate proper padding (accounting for emojis which take visual space)
|
|
14
|
-
const visualLength = 59; // Target visual width
|
|
15
|
-
const padding = " ".repeat(Math.max(0, visualLength - headerText.length - 4));
|
|
16
|
-
|
|
17
|
-
console.log(chalk.gray(`\n ╭${line}╮`));
|
|
18
|
-
console.log(chalk.cyan.bold(` │ ${headerText}`) + padding + chalk.gray("│"));
|
|
19
|
-
console.log(chalk.gray(` ╰${line}╯\n`));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static displayStartupBanner(port) {
|
|
23
|
-
this.displayProjectInfo();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static displayTunnelSuccess(url, port, updateInfo) {
|
|
27
|
-
console.log(); // Extra spacing
|
|
28
|
-
console.log(chalk.cyan.bold(` 👉 ${url} 👈\n`));
|
|
29
|
-
console.log(chalk.gray(" " + "─".repeat(54) + "\n"));
|
|
30
|
-
console.log(chalk.gray(` ${lang.t("timeRemaining", { hours: CONFIG.TUNNEL_TIMEOUT_HOURS })}\n`));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static displayFooter(updateInfo) {
|
|
34
|
-
console.log(chalk.gray(" " + "─".repeat(54) + "\n"));
|
|
35
|
-
console.log(chalk.yellow.bold(` ${lang.t("footerTitle")}\n`));
|
|
36
|
-
console.log(chalk.gray(` ${lang.t("footerSubtitle")}\n`));
|
|
37
|
-
console.log(chalk.cyan(` ${lang.t("dropStar")}`) + chalk.white("https://github.com/tuanngocptn/nport"));
|
|
38
|
-
console.log(chalk.yellow(` ${lang.t("sendCoffee")}`) + chalk.white("https://buymeacoffee.com/tuanngocptn"));
|
|
39
|
-
|
|
40
|
-
if (updateInfo && updateInfo.shouldUpdate) {
|
|
41
|
-
console.log(chalk.red.bold(`\n ${lang.t("newVersion", { version: updateInfo.latest })}`));
|
|
42
|
-
console.log(chalk.gray(" ") + chalk.cyan(lang.t("updateCommand")));
|
|
43
|
-
}
|
|
44
|
-
console.log();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static displayTimeoutWarning() {
|
|
48
|
-
console.log(
|
|
49
|
-
chalk.yellow(
|
|
50
|
-
`\n⏰ Tunnel has been running for ${CONFIG.TUNNEL_TIMEOUT_HOURS} hours.`
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
console.log(chalk.yellow(" Automatically shutting down..."));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static displayError(error, spinner = null) {
|
|
57
|
-
if (spinner) {
|
|
58
|
-
spinner.fail("Failed to connect to server.");
|
|
59
|
-
}
|
|
60
|
-
console.error(chalk.red(error.message));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static displayCleanupStart() {
|
|
64
|
-
console.log(chalk.red.bold(`\n\n ${lang.t("tunnelShutdown")}\n`));
|
|
65
|
-
process.stdout.write(chalk.gray(` ${lang.t("cleaningUp")}`));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static displayCleanupSuccess() {
|
|
69
|
-
console.log(chalk.green(lang.t("cleanupDone")));
|
|
70
|
-
console.log(chalk.gray(` ${lang.t("subdomainReleased")}\n`));
|
|
71
|
-
this.displayGoodbye();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static displayCleanupError() {
|
|
75
|
-
console.log(chalk.red(lang.t("cleanupFailed")));
|
|
76
|
-
console.log(chalk.gray(` ${lang.t("serverBusy")}\n`));
|
|
77
|
-
this.displayGoodbye();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static displayGoodbye() {
|
|
81
|
-
console.log(chalk.gray(" " + "─".repeat(54) + "\n"));
|
|
82
|
-
console.log(chalk.cyan.bold(` ${lang.t("goodbyeTitle")}\n`));
|
|
83
|
-
console.log(chalk.gray(` ${lang.t("goodbyeMessage")}\n`));
|
|
84
|
-
console.log(chalk.cyan(` ${lang.t("website")}`) + chalk.white("https://nport.link"));
|
|
85
|
-
console.log(chalk.cyan(` ${lang.t("author")}`) + chalk.white("Nick Pham (https://github.com/tuanngocptn)"));
|
|
86
|
-
console.log(chalk.cyan(` ${lang.t("changeLanguage")}`) + chalk.yellow(lang.t("changeLanguageHint")));
|
|
87
|
-
console.log();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
static displayVersion(current, updateInfo) {
|
|
91
|
-
console.log(chalk.cyan.bold(`\n${lang.t("versionTitle", { version: current })}`));
|
|
92
|
-
console.log(chalk.gray(`${lang.t("versionSubtitle")}\n`));
|
|
93
|
-
|
|
94
|
-
if (updateInfo && updateInfo.shouldUpdate) {
|
|
95
|
-
console.log(chalk.yellow(lang.t("versionAvailable", { version: updateInfo.latest })));
|
|
96
|
-
console.log(chalk.cyan(lang.t("versionUpdate")) + chalk.white(`npm install -g nport@latest\n`));
|
|
97
|
-
} else {
|
|
98
|
-
console.log(chalk.green(`${lang.t("versionLatest")}\n`));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
console.log(chalk.gray(lang.t("learnMore")) + chalk.cyan("https://nport.link\n"));
|
|
102
|
-
}
|
|
103
|
-
}
|
package/src/version.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { CONFIG } from "./config.js";
|
|
3
|
-
import { analytics } from "./analytics.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Version Manager
|
|
7
|
-
* Handles version checking and update notifications
|
|
8
|
-
*/
|
|
9
|
-
export class VersionManager {
|
|
10
|
-
static async checkForUpdates() {
|
|
11
|
-
try {
|
|
12
|
-
const response = await axios.get(
|
|
13
|
-
`https://registry.npmjs.org/${CONFIG.PACKAGE_NAME}/latest`,
|
|
14
|
-
{ timeout: CONFIG.UPDATE_CHECK_TIMEOUT }
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const latestVersion = response.data.version;
|
|
18
|
-
const shouldUpdate =
|
|
19
|
-
this.compareVersions(latestVersion, CONFIG.CURRENT_VERSION) > 0;
|
|
20
|
-
|
|
21
|
-
// Track update notification if available
|
|
22
|
-
if (shouldUpdate) {
|
|
23
|
-
analytics.trackUpdateAvailable(CONFIG.CURRENT_VERSION, latestVersion);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
current: CONFIG.CURRENT_VERSION,
|
|
28
|
-
latest: latestVersion,
|
|
29
|
-
shouldUpdate,
|
|
30
|
-
};
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// Silently fail if can't check for updates
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static compareVersions(v1, v2) {
|
|
38
|
-
const parts1 = v1.split(".").map(Number);
|
|
39
|
-
const parts2 = v2.split(".").map(Number);
|
|
40
|
-
|
|
41
|
-
// Compare up to the maximum length of both version arrays
|
|
42
|
-
const maxLength = Math.max(parts1.length, parts2.length);
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < maxLength; i++) {
|
|
45
|
-
// Treat missing parts as 0 (e.g., "1.0" is "1.0.0")
|
|
46
|
-
const part1 = parts1[i] || 0;
|
|
47
|
-
const part2 = parts2[i] || 0;
|
|
48
|
-
|
|
49
|
-
if (part1 > part2) return 1;
|
|
50
|
-
if (part1 < part2) return -1;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|