@bulolo/hermes-link 0.1.0
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/dist/chunk-C24HF73Y.js +1843 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +525 -0
- package/dist/http/app.d.ts +111 -0
- package/dist/http/app.js +6 -0
- package/package.json +69 -0
- package/scripts/check-node-version.mjs +70 -0
- package/scripts/postinstall.mjs +45 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
|
|
3
|
+
const MINIMUM_NODE_VERSION = "20.0.0";
|
|
4
|
+
|
|
5
|
+
function parseVersion(input) {
|
|
6
|
+
const normalized = String(input ?? "")
|
|
7
|
+
.trim()
|
|
8
|
+
.replace(/^v/i, "");
|
|
9
|
+
const [major = "0", minor = "0", patch = "0"] = normalized.split(".");
|
|
10
|
+
return [
|
|
11
|
+
Number.parseInt(major, 10) || 0,
|
|
12
|
+
Number.parseInt(minor, 10) || 0,
|
|
13
|
+
Number.parseInt(patch, 10) || 0,
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function compareVersions(left, right) {
|
|
18
|
+
for (let index = 0; index < 3; index += 1) {
|
|
19
|
+
if (left[index] > right[index]) return 1;
|
|
20
|
+
if (left[index] < right[index]) return -1;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function detectLanguage() {
|
|
26
|
+
const candidates = [
|
|
27
|
+
process.env.HERMESLINK_LANG,
|
|
28
|
+
process.env.HERMESLINK_LANGUAGE,
|
|
29
|
+
process.env.LC_ALL,
|
|
30
|
+
process.env.LC_MESSAGES,
|
|
31
|
+
process.env.LANG,
|
|
32
|
+
process.env.LANGUAGE?.split(":")[0],
|
|
33
|
+
Intl.DateTimeFormat().resolvedOptions().locale,
|
|
34
|
+
];
|
|
35
|
+
for (const candidate of candidates) {
|
|
36
|
+
const normalized = String(candidate ?? "").trim().replace("_", "-").toLowerCase();
|
|
37
|
+
if (normalized.startsWith("zh")) return "zh-CN";
|
|
38
|
+
if (normalized.startsWith("en")) return "en";
|
|
39
|
+
}
|
|
40
|
+
return "en";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const current = parseVersion(process.versions.node);
|
|
44
|
+
const minimum = parseVersion(MINIMUM_NODE_VERSION);
|
|
45
|
+
|
|
46
|
+
if (compareVersions(current, minimum) < 0) {
|
|
47
|
+
const language = detectLanguage();
|
|
48
|
+
console.error("");
|
|
49
|
+
if (language === "zh-CN") {
|
|
50
|
+
console.error("Hermes Link 需要 Node.js 20.0.0 或更新版本。");
|
|
51
|
+
console.error(`当前使用的是 Node.js ${process.versions.node}。`);
|
|
52
|
+
console.error("");
|
|
53
|
+
console.error("为什么需要这样做:");
|
|
54
|
+
console.error("- Hermes Link 与 hermes-agent 的 Node.js 20+ 要求保持一致。");
|
|
55
|
+
console.error("- 如果继续在旧版 Node.js 上安装,后续配对、后台服务或本地数据库可能会失败。");
|
|
56
|
+
console.error("");
|
|
57
|
+
console.error("请先升级 Node.js,然后重新运行安装命令。");
|
|
58
|
+
} else {
|
|
59
|
+
console.error("Hermes Link needs Node.js 20.0.0 or newer.");
|
|
60
|
+
console.error(`You are using Node.js ${process.versions.node}.`);
|
|
61
|
+
console.error("");
|
|
62
|
+
console.error("Why this is required:");
|
|
63
|
+
console.error("- Hermes Link now matches hermes-agent's Node.js 20+ requirement.");
|
|
64
|
+
console.error("- If installation continued on an older Node.js version, pairing, the background service, or the local database could fail later.");
|
|
65
|
+
console.error("");
|
|
66
|
+
console.error("Please update Node.js first, then run the install command again.");
|
|
67
|
+
}
|
|
68
|
+
console.error("");
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
|
|
3
|
+
function isTruthy(value) {
|
|
4
|
+
return ["1", "true", "yes", "on"].includes(String(value ?? "").toLowerCase());
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function shouldPrintInstallHint() {
|
|
8
|
+
if (isTruthy(process.env.HERMESLINK_POSTINSTALL_QUIET)) return false;
|
|
9
|
+
if (isTruthy(process.env.CI)) return false;
|
|
10
|
+
return process.env.npm_config_global === "true";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function detectLanguage() {
|
|
14
|
+
const candidates = [
|
|
15
|
+
process.env.HERMESLINK_LANG,
|
|
16
|
+
process.env.HERMESLINK_LANGUAGE,
|
|
17
|
+
process.env.LC_ALL,
|
|
18
|
+
process.env.LC_MESSAGES,
|
|
19
|
+
process.env.LANG,
|
|
20
|
+
process.env.LANGUAGE?.split(":")[0],
|
|
21
|
+
Intl.DateTimeFormat().resolvedOptions().locale,
|
|
22
|
+
];
|
|
23
|
+
for (const candidate of candidates) {
|
|
24
|
+
const normalized = String(candidate ?? "").trim().replace("_", "-").toLowerCase();
|
|
25
|
+
if (normalized.startsWith("zh")) return "zh-CN";
|
|
26
|
+
if (normalized.startsWith("en")) return "en";
|
|
27
|
+
}
|
|
28
|
+
return "en";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
if (!shouldPrintInstallHint()) return;
|
|
33
|
+
const language = detectLanguage();
|
|
34
|
+
console.log("");
|
|
35
|
+
if (language === "zh-CN") {
|
|
36
|
+
console.log("Hermes Link 已安装。");
|
|
37
|
+
console.log("运行 `hermeslink pair`,把这台电脑连接到 App。");
|
|
38
|
+
} else {
|
|
39
|
+
console.log("Hermes Link installed.");
|
|
40
|
+
console.log("Run `hermeslink pair` to connect this computer with the App.");
|
|
41
|
+
}
|
|
42
|
+
console.log("");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main().catch(() => {});
|