@sfmc-bds/bds-tools 0.2.0-beta.17 → 0.2.0-beta.18
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/bds-manager.d.ts.map +1 -1
- package/dist/bds-manager.js +8 -1
- package/dist/bds-manager.js.map +2 -2
- package/dist/changelog.d.ts +11 -7
- package/dist/changelog.d.ts.map +1 -1
- package/dist/changelog.js +60 -34
- package/dist/changelog.js.map +2 -2
- package/dist/check-update.d.ts.map +1 -1
- package/dist/check-update.js +50 -13
- package/dist/check-update.js.map +2 -2
- package/dist/qq-events-notify.d.ts +1 -1
- package/dist/qq-events-notify.d.ts.map +1 -1
- package/dist/qq-events-notify.js.map +1 -1
- package/dist/qqutil.d.ts.map +1 -1
- package/dist/qqutil.js +14 -12
- package/dist/qqutil.js.map +2 -2
- package/dist/server-properties-i18n.d.ts.map +1 -1
- package/dist/server-properties-i18n.js +4 -0
- package/dist/server-properties-i18n.js.map +2 -2
- package/dist/server-properties.d.ts +3 -0
- package/dist/server-properties.d.ts.map +1 -1
- package/dist/server-properties.js +15 -0
- package/dist/server-properties.js.map +2 -2
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/dependency-negotiator.test.js +0 -120
- package/dist/dependency-negotiator.test.js.map +0 -7
- package/dist/fsx.test.js +0 -60
- package/dist/fsx.test.js.map +0 -7
- package/dist/level-dat.test.js +0 -172
- package/dist/level-dat.test.js.map +0 -7
- package/dist/pack-manager-lifecycle.test.js +0 -252
- package/dist/pack-manager-lifecycle.test.js.map +0 -7
- package/dist/pack-update/config.test.js +0 -75
- package/dist/pack-update/config.test.js.map +0 -7
- package/dist/pack-update/version-policy.test.js +0 -137
- package/dist/pack-update/version-policy.test.js.map +0 -7
- package/dist/process-probe.test.js +0 -76
- package/dist/process-probe.test.js.map +0 -7
- package/dist/server-properties.test.js +0 -127
- package/dist/server-properties.test.js.map +0 -7
- package/dist/world-packs.test.js +0 -698
- package/dist/world-packs.test.js.map +0 -7
- package/dist/zipx.test.js +0 -36
- package/dist/zipx.test.js.map +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/process-probe.test.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * process-probe \u5355\u5143\u6D4B\u8BD5\uFF1APID \u6587\u4EF6\u7EAF\u51FD\u6570 + \u53EF\u6CE8\u5165 exec \u7684\u63A2\u6D4B\u903B\u8F91\n */\nimport assert from \"node:assert/strict\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { after, describe, it } from \"node:test\";\nimport * as probe from \"./process-probe.js\";\n\ndescribe(\"process-probe pid file\", () => {\n let tempRoot = \"\";\n\n after(() => {\n if (tempRoot) {\n fs.rmSync(tempRoot, { recursive: true, force: true });\n }\n });\n\n it(\"read/write/clear bds.pid \u5728\u72EC\u7ACB temp \u6839\u76EE\u5F55\", () => {\n tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), \"sfmc-probe-\"));\n\n assert.equal(probe.readBdsPidFile(tempRoot), 0);\n\n probe.writeBdsPidFile(4242, tempRoot);\n assert.equal(probe.readBdsPidFile(tempRoot), 4242);\n\n probe.clearBdsPidFile(tempRoot);\n assert.equal(probe.readBdsPidFile(tempRoot), 0);\n });\n});\n\ndescribe(\"process-probe probeBdsStatus\", () => {\n let tempRoot = \"\";\n const calls: string[] = [];\n\n after(() => {\n probe.setExecForTesting(null);\n probe.setIsAliveForTesting(null);\n if (tempRoot) {\n fs.rmSync(tempRoot, { recursive: true, force: true });\n }\n });\n\n it(\"managedPid + hasStdin \u4E14\u8FDB\u7A0B\u5B58\u6D3B \u2192 managed\", async () => {\n tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), \"sfmc-probe-\"));\n calls.length = 0;\n probe.setIsAliveForTesting((pid) => pid === 100);\n\n probe.setExecForTesting(async (cmd) => {\n calls.push(cmd);\n if (cmd.includes(\"PID eq 100\")) {\n return { stdout: \"bedrock_server.exe 100 Console\", stderr: \"\" };\n }\n return { stdout: \"\", stderr: \"\" };\n });\n\n const result = await probe.probeBdsStatus({ managedPid: 100, hasStdin: true, rootDir: tempRoot });\n assert.deepEqual(result, { state: \"managed\", pid: 100 });\n });\n\n it(\"PID \u6587\u4EF6\u5B58\u6D3B\u4F46\u65E0 stdin \u2192 external\", async () => {\n probe.writeBdsPidFile(200, tempRoot);\n probe.setIsAliveForTesting((pid) => pid === 200);\n\n probe.setExecForTesting(async (cmd) => {\n if (cmd.includes(\"PID eq 200\")) {\n return { stdout: \"bedrock_server.exe 200 Console\", stderr: \"\" };\n }\n return { stdout: \"\", stderr: \"\" };\n });\n\n const result = await probe.probeBdsStatus({ managedPid: 200, hasStdin: false, rootDir: tempRoot });\n assert.equal(result.state, \"external\");\n assert.equal(result.pid, 200);\n });\n\n it(\"\u65E0 PID \u6587\u4EF6\u4F46\u6709 bedrock_server \u955C\u50CF \u2192 external\", async () => {\n probe.clearBdsPidFile(tempRoot);\n probe.setIsAliveForTesting(() => false);\n\n probe.setExecForTesting(async (cmd) => {\n if (cmd.includes(\"IMAGENAME eq bedrock_server.exe\")) {\n return { stdout: '\"bedrock_server.exe\",\"555\",\"Console\",\"1\",\"999 K\"\\n', stderr: \"\" };\n }\n if (cmd.includes(\"pgrep\")) {\n return { stdout: \"555\\n\", stderr: \"\" };\n }\n return { stdout: \"\", stderr: \"\" };\n });\n\n const result = await probe.probeBdsStatus({ rootDir: tempRoot });\n assert.deepEqual(result, { state: \"external\", pid: 555 });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAGA,OAAO,YAAY;AACnB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,OAAO,UAAU,UAAU;AACpC,YAAY,WAAW;AAEvB,SAAS,0BAA0B,MAAM;AACvC,MAAI,WAAW;AAEf,QAAM,MAAM;AACV,QAAI,UAAU;AACZ,S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UAAM,gBAAgB,KAAK,QAAQ;AACnC,UAAM,qBAAqB,CAAC,QAAQ,QAAQ,GAAG;AAE/C,UAAM,kBAAkB,OAAO,QAAQ;AACrC,UAAI,IAAI,SAAS,YAAY,GAAG;AAC9B,eAAO,EAAE,QAAQ,mCAAmC,QAAQ,GAAG;AAAA,MACjE;AACA,aAAO,EAAE,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAClC,CAAC;AAED,UAAM,SAAS,MAAM,MAAM,eAAe,EAAE,YAAY,KAAK,UAAU,OAAO,SAAS,SAAS,CAAC;AACjG,WAAO,MAAM,OAAO,OAAO,UAAU;AACrC,WAAO,MAAM,OAAO,KAAK,GAAG;AAAA,EAC9B,CAAC;AAED,KAAG,mFAA2C,YAAY;AACxD,UAAM,gBAAgB,QAAQ;AAC9B,UAAM,qBAAqB,MAAM,KAAK;AAEtC,UAAM,kBAAkB,OAAO,QAAQ;AACrC,UAAI,IAAI,SAAS,iCAAiC,GAAG;AACnD,eAAO,EAAE,QAAQ,sDAAsD,QAAQ,GAAG;AAAA,MACpF;AACA,UAAI,IAAI,SAAS,OAAO,GAAG;AACzB,eAAO,EAAE,QAAQ,SAAS,QAAQ,GAAG;AAAA,MACvC;AACA,aAAO,EAAE,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAClC,CAAC;AAED,UAAM,SAAS,MAAM,MAAM,eAAe,EAAE,SAAS,SAAS,CAAC;AAC/D,WAAO,UAAU,QAAQ,EAAE,OAAO,YAAY,KAAK,IAAI,CAAC;AAAA,EAC1D,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { describe, it } from "node:test";
|
|
6
|
-
import { rmSafe } from "./fsx.js";
|
|
7
|
-
import {
|
|
8
|
-
ensureEmitServerTelemetry,
|
|
9
|
-
localizeServerProperties,
|
|
10
|
-
localizeServerPropertiesContent,
|
|
11
|
-
resolveBdsLocale
|
|
12
|
-
} from "./server-properties.js";
|
|
13
|
-
const SAMPLE_VANILLA_PROPERTIES = `server-name=Dedicated Server
|
|
14
|
-
# Used as the server name
|
|
15
|
-
# Allowed values: Any string without semicolon symbol.
|
|
16
|
-
|
|
17
|
-
gamemode=survival
|
|
18
|
-
# Sets the game mode for new players.
|
|
19
|
-
# Allowed values: "survival", "creative", or "adventure"
|
|
20
|
-
|
|
21
|
-
force-gamemode=false
|
|
22
|
-
# Prevents the server from sending level settings to clients
|
|
23
|
-
|
|
24
|
-
allow-cheats=false
|
|
25
|
-
# If true then cheats like commands can be used.
|
|
26
|
-
|
|
27
|
-
custom-unknown-flag=hello-world
|
|
28
|
-
# This is a third-party or future setting
|
|
29
|
-
`;
|
|
30
|
-
describe("server-properties: localizeServerPropertiesContent", () => {
|
|
31
|
-
it("\u5C06\u5DF2\u77E5\u914D\u7F6E\u9879\u7684\u82F1\u6587\u6CE8\u91CA\u66FF\u6362\u4E3A\u4E2D\u6587\uFF0C\u4E14\u4E25\u683C\u4FDD\u7559\u7528\u6237\u914D\u7F6E\u503C", () => {
|
|
32
|
-
const customText = `server-name=\u6211\u7684\u4E16\u754C\u670D\u52A1\u5668
|
|
33
|
-
# Used as the server name
|
|
34
|
-
|
|
35
|
-
gamemode=creative
|
|
36
|
-
# Sets the game mode for new players.
|
|
37
|
-
|
|
38
|
-
server-port=25565
|
|
39
|
-
`;
|
|
40
|
-
const { content, modified } = localizeServerPropertiesContent(customText, "zh-CN");
|
|
41
|
-
assert.equal(modified, true);
|
|
42
|
-
assert.match(content, /server-name=我的世界服务器/);
|
|
43
|
-
assert.match(content, /gamemode=creative/);
|
|
44
|
-
assert.match(content, /server-port=25565/);
|
|
45
|
-
assert.match(content, /# 服务器名称(显示在客户端局域网\/好友列表中)/);
|
|
46
|
-
assert.match(content, /# 新玩家首次加入世界时的默认游戏模式/);
|
|
47
|
-
assert.match(content, /# 服务端监听的 IPv4 UDP 网络通信端口/);
|
|
48
|
-
});
|
|
49
|
-
it("\u4FDD\u6301\u5E42\u7B49\u6027\uFF1A\u4E8C\u6B21\u8FD0\u884C\u8F93\u51FA\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF0Cmodified \u4E3A false", () => {
|
|
50
|
-
const firstRun = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, "zh-CN");
|
|
51
|
-
assert.equal(firstRun.modified, true);
|
|
52
|
-
const secondRun = localizeServerPropertiesContent(firstRun.content, "zh-CN");
|
|
53
|
-
assert.equal(secondRun.modified, false);
|
|
54
|
-
assert.equal(secondRun.content, firstRun.content);
|
|
55
|
-
});
|
|
56
|
-
it("\u4FDD\u7559\u672A\u6536\u5F55\u7684\u672A\u77E5\u9879\u4E0E\u7B2C\u4E09\u65B9\u6CE8\u91CA\u4E0D\u53D8", () => {
|
|
57
|
-
const { content } = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, "zh-CN");
|
|
58
|
-
assert.match(content, /custom-unknown-flag=hello-world/);
|
|
59
|
-
assert.match(content, /# This is a third-party or future setting/);
|
|
60
|
-
});
|
|
61
|
-
it("\u5F53 locale \u4E3A en \u6216\u975E\u4E2D\u6587\u65F6\uFF0C\u8DF3\u8FC7\u4FEE\u6539\u5E76\u8FD4\u56DE modified: false", () => {
|
|
62
|
-
const resEn = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, "en");
|
|
63
|
-
assert.equal(resEn.modified, false);
|
|
64
|
-
assert.equal(resEn.content, SAMPLE_VANILLA_PROPERTIES);
|
|
65
|
-
});
|
|
66
|
-
it("\u7A7A\u6587\u672C\u5B89\u5168\u5904\u7406", () => {
|
|
67
|
-
const res = localizeServerPropertiesContent("", "zh-CN");
|
|
68
|
-
assert.equal(res.modified, false);
|
|
69
|
-
assert.equal(res.content, "");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe("server-properties: \u6587\u4EF6\u8BFB\u5199\u4E0E\u78C1\u76D8\u96C6\u6210", () => {
|
|
73
|
-
it("localizeServerProperties \u6B63\u786E\u5C31\u5730\u91CD\u5199\u78C1\u76D8\u6587\u4EF6", () => {
|
|
74
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "sfmc-server-props-"));
|
|
75
|
-
try {
|
|
76
|
-
const propFile = path.join(tmp, "server.properties");
|
|
77
|
-
fs.writeFileSync(propFile, "server-name=TestServer\ngamemode=survival\n", "utf8");
|
|
78
|
-
const msgs = [];
|
|
79
|
-
const ok = localizeServerProperties(tmp, {
|
|
80
|
-
locale: "zh-CN",
|
|
81
|
-
logger: { info: (m) => msgs.push(m) }
|
|
82
|
-
});
|
|
83
|
-
assert.equal(ok, true);
|
|
84
|
-
assert.equal(msgs.length, 1);
|
|
85
|
-
const updated = fs.readFileSync(propFile, "utf8");
|
|
86
|
-
assert.match(updated, /server-name=TestServer/);
|
|
87
|
-
assert.match(updated, /# 服务器名称/);
|
|
88
|
-
const okAgain = localizeServerProperties(tmp, { locale: "zh-CN" });
|
|
89
|
-
assert.equal(okAgain, false);
|
|
90
|
-
} finally {
|
|
91
|
-
rmSafe(tmp);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
it("\u7ED3\u5408 ensureEmitServerTelemetry\uFF1A\u65B0\u8FFD\u52A0\u7684\u9065\u6D4B\u5F00\u5173\u540C\u6837\u80FD\u83B7\u5F97\u4E2D\u6587\u6CE8\u91CA", () => {
|
|
95
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "sfmc-server-props-telemetry-"));
|
|
96
|
-
try {
|
|
97
|
-
const propFile = path.join(tmp, "server.properties");
|
|
98
|
-
fs.writeFileSync(propFile, "server-name=Dedicated Server\n", "utf8");
|
|
99
|
-
const wrote = ensureEmitServerTelemetry(tmp);
|
|
100
|
-
assert.equal(wrote, true);
|
|
101
|
-
const ok = localizeServerProperties(tmp, { locale: "zh-CN" });
|
|
102
|
-
assert.equal(ok, true);
|
|
103
|
-
const content = fs.readFileSync(propFile, "utf8");
|
|
104
|
-
assert.match(content, /emit-server-telemetry=true/);
|
|
105
|
-
assert.match(content, /# 是否向 Mojang 发送服务器遥测与运行健康诊断数据/);
|
|
106
|
-
assert.match(content, /# 提示:使用本平台时因您已同意 Mojang EULA 协议,按协议保持启用/);
|
|
107
|
-
} finally {
|
|
108
|
-
rmSafe(tmp);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
it("resolveBdsLocale \u652F\u6301\u73AF\u5883\u53D8\u91CF\u4E0E\u7CFB\u7EDF\u56DE\u9000", () => {
|
|
112
|
-
const oldEnv = process.env.SFMC_LOCALE;
|
|
113
|
-
try {
|
|
114
|
-
process.env.SFMC_LOCALE = "zh-CN";
|
|
115
|
-
assert.equal(resolveBdsLocale(), "zh-CN");
|
|
116
|
-
process.env.SFMC_LOCALE = "en";
|
|
117
|
-
assert.equal(resolveBdsLocale(), "en");
|
|
118
|
-
} finally {
|
|
119
|
-
if (oldEnv !== void 0) {
|
|
120
|
-
process.env.SFMC_LOCALE = oldEnv;
|
|
121
|
-
} else {
|
|
122
|
-
delete process.env.SFMC_LOCALE;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
//# sourceMappingURL=server-properties.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/server-properties.test.ts"],
|
|
4
|
-
"sourcesContent": ["import assert from \"node:assert/strict\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { describe, it } from \"node:test\";\nimport { rmSafe } from \"./fsx.js\";\nimport {\n ensureEmitServerTelemetry,\n localizeServerProperties,\n localizeServerPropertiesContent,\n resolveBdsLocale,\n} from \"./server-properties.js\";\n\nconst SAMPLE_VANILLA_PROPERTIES = `server-name=Dedicated Server\n# Used as the server name\n# Allowed values: Any string without semicolon symbol.\n\ngamemode=survival\n# Sets the game mode for new players.\n# Allowed values: \"survival\", \"creative\", or \"adventure\"\n\nforce-gamemode=false\n# Prevents the server from sending level settings to clients\n\nallow-cheats=false\n# If true then cheats like commands can be used.\n\ncustom-unknown-flag=hello-world\n# This is a third-party or future setting\n`;\n\ndescribe(\"server-properties: localizeServerPropertiesContent\", () => {\n it(\"\u5C06\u5DF2\u77E5\u914D\u7F6E\u9879\u7684\u82F1\u6587\u6CE8\u91CA\u66FF\u6362\u4E3A\u4E2D\u6587\uFF0C\u4E14\u4E25\u683C\u4FDD\u7559\u7528\u6237\u914D\u7F6E\u503C\", () => {\n const customText = `server-name=\u6211\u7684\u4E16\u754C\u670D\u52A1\u5668\n# Used as the server name\n\ngamemode=creative\n# Sets the game mode for new players.\n\nserver-port=25565\n`;\n const { content, modified } = localizeServerPropertiesContent(customText, \"zh-CN\");\n assert.equal(modified, true);\n\n // \u9A8C\u8BC1\u503C\u672A\u88AB\u8986\u76D6\u91CD\u7F6E\n assert.match(content, /server-name=\u6211\u7684\u4E16\u754C\u670D\u52A1\u5668/);\n assert.match(content, /gamemode=creative/);\n assert.match(content, /server-port=25565/);\n\n // \u9A8C\u8BC1\u6CE8\u91CA\u5DF2\u8F6C\u4E3A\u4E2D\u6587\n assert.match(content, /# \u670D\u52A1\u5668\u540D\u79F0\uFF08\u663E\u793A\u5728\u5BA2\u6237\u7AEF\u5C40\u57DF\u7F51\\/\u597D\u53CB\u5217\u8868\u4E2D\uFF09/);\n assert.match(content, /# \u65B0\u73A9\u5BB6\u9996\u6B21\u52A0\u5165\u4E16\u754C\u65F6\u7684\u9ED8\u8BA4\u6E38\u620F\u6A21\u5F0F/);\n assert.match(content, /# \u670D\u52A1\u7AEF\u76D1\u542C\u7684 IPv4 UDP \u7F51\u7EDC\u901A\u4FE1\u7AEF\u53E3/);\n });\n\n it(\"\u4FDD\u6301\u5E42\u7B49\u6027\uFF1A\u4E8C\u6B21\u8FD0\u884C\u8F93\u51FA\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF0Cmodified \u4E3A false\", () => {\n const firstRun = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, \"zh-CN\");\n assert.equal(firstRun.modified, true);\n\n const secondRun = localizeServerPropertiesContent(firstRun.content, \"zh-CN\");\n assert.equal(secondRun.modified, false);\n assert.equal(secondRun.content, firstRun.content);\n });\n\n it(\"\u4FDD\u7559\u672A\u6536\u5F55\u7684\u672A\u77E5\u9879\u4E0E\u7B2C\u4E09\u65B9\u6CE8\u91CA\u4E0D\u53D8\", () => {\n const { content } = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, \"zh-CN\");\n assert.match(content, /custom-unknown-flag=hello-world/);\n assert.match(content, /# This is a third-party or future setting/);\n });\n\n it(\"\u5F53 locale \u4E3A en \u6216\u975E\u4E2D\u6587\u65F6\uFF0C\u8DF3\u8FC7\u4FEE\u6539\u5E76\u8FD4\u56DE modified: false\", () => {\n const resEn = localizeServerPropertiesContent(SAMPLE_VANILLA_PROPERTIES, \"en\");\n assert.equal(resEn.modified, false);\n assert.equal(resEn.content, SAMPLE_VANILLA_PROPERTIES);\n });\n\n it(\"\u7A7A\u6587\u672C\u5B89\u5168\u5904\u7406\", () => {\n const res = localizeServerPropertiesContent(\"\", \"zh-CN\");\n assert.equal(res.modified, false);\n assert.equal(res.content, \"\");\n });\n});\n\ndescribe(\"server-properties: \u6587\u4EF6\u8BFB\u5199\u4E0E\u78C1\u76D8\u96C6\u6210\", () => {\n it(\"localizeServerProperties \u6B63\u786E\u5C31\u5730\u91CD\u5199\u78C1\u76D8\u6587\u4EF6\", () => {\n const tmp = fs.mkdtempSync(path.join(os.tmpdir(), \"sfmc-server-props-\"));\n try {\n const propFile = path.join(tmp, \"server.properties\");\n fs.writeFileSync(propFile, \"server-name=TestServer\\ngamemode=survival\\n\", \"utf8\");\n\n const msgs: string[] = [];\n const ok = localizeServerProperties(tmp, {\n locale: \"zh-CN\",\n logger: { info: (m) => msgs.push(m) },\n });\n\n assert.equal(ok, true);\n assert.equal(msgs.length, 1);\n\n const updated = fs.readFileSync(propFile, \"utf8\");\n assert.match(updated, /server-name=TestServer/);\n assert.match(updated, /# \u670D\u52A1\u5668\u540D\u79F0/);\n\n // \u4E8C\u6B21\u6267\u884C\u8DF3\u8FC7\n const okAgain = localizeServerProperties(tmp, { locale: \"zh-CN\" });\n assert.equal(okAgain, false);\n } finally {\n rmSafe(tmp);\n }\n });\n\n it(\"\u7ED3\u5408 ensureEmitServerTelemetry\uFF1A\u65B0\u8FFD\u52A0\u7684\u9065\u6D4B\u5F00\u5173\u540C\u6837\u80FD\u83B7\u5F97\u4E2D\u6587\u6CE8\u91CA\", () => {\n const tmp = fs.mkdtempSync(path.join(os.tmpdir(), \"sfmc-server-props-telemetry-\"));\n try {\n const propFile = path.join(tmp, \"server.properties\");\n fs.writeFileSync(propFile, \"server-name=Dedicated Server\\n\", \"utf8\");\n\n // 1. \u8FFD\u52A0\u9065\u6D4B\n const wrote = ensureEmitServerTelemetry(tmp);\n assert.equal(wrote, true);\n\n // 2. \u672C\u5730\u5316\n const ok = localizeServerProperties(tmp, { locale: \"zh-CN\" });\n assert.equal(ok, true);\n\n const content = fs.readFileSync(propFile, \"utf8\");\n assert.match(content, /emit-server-telemetry=true/);\n assert.match(content, /# \u662F\u5426\u5411 Mojang \u53D1\u9001\u670D\u52A1\u5668\u9065\u6D4B\u4E0E\u8FD0\u884C\u5065\u5EB7\u8BCA\u65AD\u6570\u636E/);\n assert.match(content, /# \u63D0\u793A\uFF1A\u4F7F\u7528\u672C\u5E73\u53F0\u65F6\u56E0\u60A8\u5DF2\u540C\u610F Mojang EULA \u534F\u8BAE\uFF0C\u6309\u534F\u8BAE\u4FDD\u6301\u542F\u7528/);\n } finally {\n rmSafe(tmp);\n }\n });\n\n it(\"resolveBdsLocale \u652F\u6301\u73AF\u5883\u53D8\u91CF\u4E0E\u7CFB\u7EDF\u56DE\u9000\", () => {\n const oldEnv = process.env.SFMC_LOCALE;\n try {\n process.env.SFMC_LOCALE = \"zh-CN\";\n assert.equal(resolveBdsLocale(), \"zh-CN\");\n\n process.env.SFMC_LOCALE = \"en\";\n assert.equal(resolveBdsLocale(), \"en\");\n } finally {\n if (oldEnv !== undefined) {\n process.env.SFMC_LOCALE = oldEnv;\n } else {\n delete process.env.SFMC_LOCALE;\n }\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,UAAU,UAAU;AAC7B,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBlC,SAAS,sDAAsD,MAAM;AACnE,KAAG,sKAA+B,MAAM;AACtC,UAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQnB,UAAM,EAAE,SAAS,SAAS,IAAI,gCAAgC,YAAY,OAAO;AACjF,WAAO,MAAM,UAAU,IAAI;AAG3B,WAAO,MAAM,SAAS,qBAAqB;AAC3C,WAAO,MAAM,SAAS,mBAAmB;AACzC,WAAO,MAAM,SAAS,mBAAmB;AAGzC,WAAO,MAAM,SAAS,2BAA2B;AACjD,WAAO,MAAM,SAAS,qBAAqB;AAC3C,WAAO,MAAM,SAAS,0BAA0B;AAAA,EAClD,CAAC;AAED,KAAG,2IAAuC,MAAM;AAC9C,UAAM,WAAW,gCAAgC,2BAA2B,OAAO;AACnF,WAAO,MAAM,SAAS,UAAU,IAAI;AAEpC,UAAM,YAAY,gCAAgC,SAAS,SAAS,OAAO;AAC3E,WAAO,MAAM,UAAU,UAAU,KAAK;AACtC,WAAO,MAAM,UAAU,SAAS,SAAS,OAAO;AAAA,EAClD,CAAC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