@nighthawk42/wow-api-mcp 0.1.0 → 0.2.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/README.md +71 -19
- package/data/_manifest.json +174 -0
- package/data/_names.json.gz +0 -0
- package/data/beta.json.gz +0 -0
- package/data/classic.json.gz +0 -0
- package/data/classic_anniversary.json.gz +0 -0
- package/data/classic_beta.json.gz +0 -0
- package/data/classic_era.json.gz +0 -0
- package/data/classic_era_ptr.json.gz +0 -0
- package/data/classic_ptr.json.gz +0 -0
- package/data/classic_titan.json.gz +0 -0
- package/data/forever.json.gz +0 -0
- package/data/live.json.gz +0 -0
- package/data/ptr.json.gz +0 -0
- package/data/ptr2.json.gz +0 -0
- package/dist/data/loader.js +76 -34
- package/dist/data/loader.js.map +1 -1
- package/dist/data/manifest.js +102 -0
- package/dist/data/manifest.js.map +1 -0
- package/dist/data/paths.js +66 -0
- package/dist/data/paths.js.map +1 -0
- package/dist/default-flavor.js +73 -0
- package/dist/default-flavor.js.map +1 -0
- package/dist/flavors.js +170 -0
- package/dist/flavors.js.map +1 -0
- package/dist/install/build-info.js +68 -0
- package/dist/install/build-info.js.map +1 -0
- package/dist/install/detect.js +249 -0
- package/dist/install/detect.js.map +1 -0
- package/dist/install/pe-version.js +135 -0
- package/dist/install/pe-version.js.map +1 -0
- package/dist/install/resolve.js +84 -0
- package/dist/install/resolve.js.map +1 -0
- package/dist/install/toc.js +73 -0
- package/dist/install/toc.js.map +1 -0
- package/dist/lua/parse-docs.js +14 -2
- package/dist/lua/parse-docs.js.map +1 -1
- package/dist/server.js +13 -4
- package/dist/server.js.map +1 -1
- package/dist/source/repo-cache.js +102 -30
- package/dist/source/repo-cache.js.map +1 -1
- package/dist/tools/api.js +144 -63
- package/dist/tools/api.js.map +1 -1
- package/dist/tools/common.js +55 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/install.js +173 -0
- package/dist/tools/install.js.map +1 -0
- package/dist/tools/source.js +39 -22
- package/dist/tools/source.js.map +1 -1
- package/dist/tools/wiki.js +8 -8
- package/dist/tools/wiki.js.map +1 -1
- package/dist/types.js +13 -1
- package/dist/types.js.map +1 -1
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/dist/wiki/client.js +24 -6
- package/dist/wiki/client.js.map +1 -1
- package/package.json +12 -6
- package/data/classic.json +0 -189806
- package/data/classic_anniversary.json +0 -189819
- package/data/classic_era.json +0 -137338
- package/data/live.json +0 -242751
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Resolves the bundled `data/` directory and its file naming. */
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import zlib from "node:zlib";
|
|
5
|
+
/** Data lives next to the compiled output: dist/data/.. and src/data/.. both resolve to <pkg>/data. */
|
|
6
|
+
export const DATA_DIR = process.env.WOW_API_MCP_DATA_DIR
|
|
7
|
+
? path.resolve(process.env.WOW_API_MCP_DATA_DIR)
|
|
8
|
+
: path.resolve(import.meta.dirname, "..", "..", "data");
|
|
9
|
+
export const MANIFEST_FILE = "_manifest.json";
|
|
10
|
+
export const NAMES_FILE = "_names.json.gz";
|
|
11
|
+
/** Flavor payloads are gzipped (~13:1); a plain `.json` is still accepted. */
|
|
12
|
+
export function flavorFile(flavor) {
|
|
13
|
+
for (const name of [`${flavor}.json.gz`, `${flavor}.json`]) {
|
|
14
|
+
const file = path.join(DATA_DIR, name);
|
|
15
|
+
if (fs.existsSync(file))
|
|
16
|
+
return file;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Reads a data file as text, transparently gunzipping a `.gz`. */
|
|
21
|
+
export function readText(file) {
|
|
22
|
+
const raw = fs.readFileSync(file);
|
|
23
|
+
return file.endsWith(".gz") ? zlib.gunzipSync(raw).toString("utf8") : raw.toString("utf8");
|
|
24
|
+
}
|
|
25
|
+
export function readJson(file) {
|
|
26
|
+
return JSON.parse(readText(file));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes a data file, skipping the write when the decompressed content already
|
|
30
|
+
* matches. Returns true when the file actually changed.
|
|
31
|
+
*
|
|
32
|
+
* Comparing content rather than bytes is the whole point: gzip output is *not*
|
|
33
|
+
* stable across zlib builds, so the same input compressed on a Windows dev box
|
|
34
|
+
* and on the Linux refresh runner differs by a byte or two. Rewriting
|
|
35
|
+
* unconditionally would make the daily job commit megabytes of churn forever
|
|
36
|
+
* without a single API having changed.
|
|
37
|
+
*/
|
|
38
|
+
export function writeJson(file, value) {
|
|
39
|
+
// Small uncompressed files (the manifest) stay pretty-printed so their diffs
|
|
40
|
+
// are readable in the auto-refresh commits; payloads are minified then gzipped.
|
|
41
|
+
const text = (file.endsWith(".gz") ? JSON.stringify(value) : JSON.stringify(value, null, 2)) + "\n";
|
|
42
|
+
try {
|
|
43
|
+
if (readText(file) === text)
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Missing or unreadable — fall through and write it.
|
|
48
|
+
}
|
|
49
|
+
fs.writeFileSync(file, file.endsWith(".gz") ? zlib.gzipSync(Buffer.from(text, "utf8"), { level: 9 }) : text);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/** Flavor IDs present in the data directory, unordered. */
|
|
53
|
+
export function discoverFlavorFiles() {
|
|
54
|
+
if (!fs.existsSync(DATA_DIR))
|
|
55
|
+
return [];
|
|
56
|
+
const ids = new Set();
|
|
57
|
+
for (const name of fs.readdirSync(DATA_DIR)) {
|
|
58
|
+
if (name.startsWith("_"))
|
|
59
|
+
continue;
|
|
60
|
+
const match = /^(.+?)\.json(\.gz)?$/.exec(name);
|
|
61
|
+
if (match)
|
|
62
|
+
ids.add(match[1]);
|
|
63
|
+
}
|
|
64
|
+
return [...ids];
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","source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,CAAC;QAChD,IAAI,KAAK;YAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Works out which flavor tool calls should assume when the caller does not say.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. `WOW_API_MCP_FLAVOR` — an explicit flavor ID pins it; `auto` forces a scan.
|
|
6
|
+
* 2. `WOW_INSTALL_PATH` — resolve the release client in that installation.
|
|
7
|
+
* 3. `live` (or the first available flavor).
|
|
8
|
+
*
|
|
9
|
+
* Step 2 only runs when the variable is set, so a normal startup touches no
|
|
10
|
+
* filesystem beyond `data/`; `auto` opts into probing the usual install
|
|
11
|
+
* locations, which is the slower path.
|
|
12
|
+
*/
|
|
13
|
+
import { flavorSpec, sortFlavors } from "./flavors.js";
|
|
14
|
+
import { availableFlavors, fallbackFlavor } from "./data/manifest.js";
|
|
15
|
+
import { detectInstalls } from "./install/detect.js";
|
|
16
|
+
let cached;
|
|
17
|
+
/**
|
|
18
|
+
* Best flavor from an installation.
|
|
19
|
+
*
|
|
20
|
+
* A machine with retail, Classic and Classic Era installed has no objectively
|
|
21
|
+
* correct default, so pick deterministically rather than by match score: live
|
|
22
|
+
* clients beat test realms, and among those the curated flavor order decides
|
|
23
|
+
* (live, then classic, then classic_era, ...). Someone who only has Classic Era
|
|
24
|
+
* installed still gets classic_era, because it is the only candidate.
|
|
25
|
+
*/
|
|
26
|
+
function fromInstalls(startPath) {
|
|
27
|
+
const found = new Set();
|
|
28
|
+
for (const install of detectInstalls(startPath)) {
|
|
29
|
+
for (const client of install.clients) {
|
|
30
|
+
const resolved = client.resolution.best;
|
|
31
|
+
if (!client.clientPresent || !resolved)
|
|
32
|
+
continue;
|
|
33
|
+
if (client.resolution.confidence === "low" || client.resolution.confidence === "none")
|
|
34
|
+
continue;
|
|
35
|
+
found.add(resolved.flavor);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (found.size === 0)
|
|
39
|
+
return undefined;
|
|
40
|
+
const ranked = sortFlavors([...found]);
|
|
41
|
+
return ranked.find((f) => flavorSpec(f).channel === "release") ?? ranked[0];
|
|
42
|
+
}
|
|
43
|
+
export function defaultFlavor() {
|
|
44
|
+
if (cached)
|
|
45
|
+
return cached;
|
|
46
|
+
const flavors = availableFlavors();
|
|
47
|
+
const pinned = process.env.WOW_API_MCP_FLAVOR?.trim();
|
|
48
|
+
if (pinned && pinned !== "auto") {
|
|
49
|
+
if (flavors.includes(pinned))
|
|
50
|
+
return (cached = pinned);
|
|
51
|
+
console.error(`wow-api-mcp: WOW_API_MCP_FLAVOR="${pinned}" is not an available flavor; ignoring.`);
|
|
52
|
+
}
|
|
53
|
+
const installPath = process.env.WOW_INSTALL_PATH?.trim();
|
|
54
|
+
if (pinned === "auto" || installPath) {
|
|
55
|
+
try {
|
|
56
|
+
// With an explicit path, resolve inside it; with `auto`, probe the usual spots.
|
|
57
|
+
const detected = fromInstalls(pinned === "auto" ? undefined : installPath);
|
|
58
|
+
if (detected && flavors.includes(detected)) {
|
|
59
|
+
console.error(`wow-api-mcp: defaulting to flavor "${detected}" from the detected game install.`);
|
|
60
|
+
return (cached = detected);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error(`wow-api-mcp: install detection failed (${error instanceof Error ? error.message : error}).`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return (cached = fallbackFlavor());
|
|
68
|
+
}
|
|
69
|
+
/** Test seam. */
|
|
70
|
+
export function resetDefaultFlavor() {
|
|
71
|
+
cached = undefined;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=default-flavor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-flavor.js","sourceRoot":"","sources":["../src/default-flavor.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we ingest.
|
|
3
|
+
*
|
|
4
|
+
* Flavor IDs are exactly the upstream branch names — never invent aliases.
|
|
5
|
+
* This table only carries presentation and install-detection hints; which
|
|
6
|
+
* flavors are actually *available* is decided by what `data/` contains
|
|
7
|
+
* (see `src/data/manifest.ts`), so a new upstream branch becomes a working
|
|
8
|
+
* flavor as soon as the ingest job writes its data file.
|
|
9
|
+
*/
|
|
10
|
+
/** Upstream branches that carry no game data and must never be ingested. */
|
|
11
|
+
export const IGNORED_BRANCHES = new Set(["automation", "gh-pages", "master"]);
|
|
12
|
+
const SPECS = [
|
|
13
|
+
{
|
|
14
|
+
id: "live",
|
|
15
|
+
label: "Retail",
|
|
16
|
+
line: "retail",
|
|
17
|
+
channel: "release",
|
|
18
|
+
products: ["wow"],
|
|
19
|
+
installDirs: ["_retail_"],
|
|
20
|
+
executables: ["Wow.exe", "World of Warcraft.app"],
|
|
21
|
+
description: "Live retail client — the current expansion on live realms.",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "ptr",
|
|
25
|
+
label: "Retail PTR",
|
|
26
|
+
line: "retail",
|
|
27
|
+
channel: "ptr",
|
|
28
|
+
products: ["wowt"],
|
|
29
|
+
installDirs: ["_ptr_"],
|
|
30
|
+
executables: ["WowT.exe"],
|
|
31
|
+
description: "Retail public test realm.",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "ptr2",
|
|
35
|
+
label: "Retail PTR 2 (XPTR)",
|
|
36
|
+
line: "retail",
|
|
37
|
+
channel: "ptr",
|
|
38
|
+
products: ["wowxptr"],
|
|
39
|
+
installDirs: ["_xptr_"],
|
|
40
|
+
executables: ["WowT.exe"],
|
|
41
|
+
description: "Second retail test realm, usually a patch ahead of `ptr`.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "beta",
|
|
45
|
+
label: "Retail Beta",
|
|
46
|
+
line: "retail",
|
|
47
|
+
channel: "beta",
|
|
48
|
+
products: ["wow_beta"],
|
|
49
|
+
installDirs: ["_beta_"],
|
|
50
|
+
executables: ["WowB.exe"],
|
|
51
|
+
description: "Retail expansion beta.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "classic",
|
|
55
|
+
label: "Classic (current expansion)",
|
|
56
|
+
line: "classic",
|
|
57
|
+
channel: "release",
|
|
58
|
+
products: ["wow_classic"],
|
|
59
|
+
installDirs: ["_classic_"],
|
|
60
|
+
executables: ["WowClassic.exe"],
|
|
61
|
+
description: "Progression Classic — whichever expansion Classic realms are on.",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "classic_ptr",
|
|
65
|
+
label: "Classic PTR",
|
|
66
|
+
line: "classic",
|
|
67
|
+
channel: "ptr",
|
|
68
|
+
products: ["wow_classic_ptr"],
|
|
69
|
+
installDirs: ["_classic_ptr_"],
|
|
70
|
+
executables: ["WowClassicT.exe"],
|
|
71
|
+
description: "Progression Classic public test realm.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "classic_beta",
|
|
75
|
+
label: "Classic Beta",
|
|
76
|
+
line: "classic",
|
|
77
|
+
channel: "beta",
|
|
78
|
+
products: ["wow_classic_beta"],
|
|
79
|
+
installDirs: ["_classic_beta_"],
|
|
80
|
+
executables: ["WowClassicB.exe", "WowB.exe"],
|
|
81
|
+
description: "Progression Classic beta.",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "classic_era",
|
|
85
|
+
label: "Classic Era (vanilla)",
|
|
86
|
+
line: "classic_era",
|
|
87
|
+
channel: "release",
|
|
88
|
+
products: ["wow_classic_era"],
|
|
89
|
+
installDirs: ["_classic_era_"],
|
|
90
|
+
executables: ["WowClassic.exe"],
|
|
91
|
+
description: "Classic Era / Hardcore — permanent vanilla realms.",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "classic_era_ptr",
|
|
95
|
+
label: "Classic Era PTR",
|
|
96
|
+
line: "classic_era",
|
|
97
|
+
channel: "ptr",
|
|
98
|
+
products: ["wow_classic_era_ptr"],
|
|
99
|
+
installDirs: ["_classic_era_ptr_"],
|
|
100
|
+
executables: ["WowClassicT.exe"],
|
|
101
|
+
description: "Classic Era test realm; also used for Anniversary PTR builds.",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "classic_anniversary",
|
|
105
|
+
label: "Classic Anniversary",
|
|
106
|
+
line: "classic_era",
|
|
107
|
+
channel: "release",
|
|
108
|
+
products: ["wow_classic_era"],
|
|
109
|
+
installDirs: ["_anniversary_", "_classic_era_"],
|
|
110
|
+
executables: ["WowClassic.exe"],
|
|
111
|
+
description: "Anniversary realms running on the Classic Era client line.",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "classic_titan",
|
|
115
|
+
label: "Classic Titan",
|
|
116
|
+
line: "other",
|
|
117
|
+
channel: "beta",
|
|
118
|
+
products: [],
|
|
119
|
+
installDirs: [],
|
|
120
|
+
executables: [],
|
|
121
|
+
description: "Internal Blizzard track mirrored upstream; no public client.",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "forever",
|
|
125
|
+
label: "WoW Forever",
|
|
126
|
+
line: "other",
|
|
127
|
+
channel: "beta",
|
|
128
|
+
products: ["wow_classic_beta"],
|
|
129
|
+
installDirs: ["_classic_beta_"],
|
|
130
|
+
executables: ["WowB.exe", "WowClassicB.exe"],
|
|
131
|
+
description: "The 1.60 'Forever' track; currently ships in the Classic beta slot.",
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
const byId = new Map(SPECS.map((s) => [s.id, s]));
|
|
135
|
+
/** Display/ordering priority — release lines first, then test realms. */
|
|
136
|
+
const ORDER = SPECS.map((s) => s.id);
|
|
137
|
+
export function flavorSpec(id) {
|
|
138
|
+
return (byId.get(id) ?? {
|
|
139
|
+
id,
|
|
140
|
+
label: id,
|
|
141
|
+
line: "other",
|
|
142
|
+
channel: "release",
|
|
143
|
+
products: [],
|
|
144
|
+
installDirs: [],
|
|
145
|
+
executables: [],
|
|
146
|
+
description: `Upstream branch \`${id}\`.`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export function knownFlavorSpecs() {
|
|
150
|
+
return [...SPECS];
|
|
151
|
+
}
|
|
152
|
+
/** Sorts flavor IDs into the curated order, with unknown branches appended alphabetically. */
|
|
153
|
+
export function sortFlavors(ids) {
|
|
154
|
+
return [...ids].sort((a, b) => {
|
|
155
|
+
const ia = ORDER.indexOf(a);
|
|
156
|
+
const ib = ORDER.indexOf(b);
|
|
157
|
+
if (ia >= 0 && ib >= 0)
|
|
158
|
+
return ia - ib;
|
|
159
|
+
if (ia >= 0)
|
|
160
|
+
return -1;
|
|
161
|
+
if (ib >= 0)
|
|
162
|
+
return 1;
|
|
163
|
+
return a.localeCompare(b);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** All client executable names we know about, for install detection. */
|
|
167
|
+
export const CLIENT_EXECUTABLES = [
|
|
168
|
+
...new Set(SPECS.flatMap((s) => s.executables).filter((e) => e.endsWith(".exe"))),
|
|
169
|
+
];
|
|
170
|
+
//# sourceMappingURL=flavors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flavors.js","sourceRoot":"","sources":["../src/flavors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsBH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE9E,MAAM,KAAK,GAAiB;IAC1B;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,WAAW,EAAE,CAAC,SAAS,EAAE,uBAAuB,CAAC;QACjD,WAAW,EAAE,4DAA4D;KAC1E;IACD;QACE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I,CAAC,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QACvC,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;QACtB,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;CAClF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Readers for the small metadata files Battle.net drops into a World of
|
|
3
|
+
* Warcraft installation.
|
|
4
|
+
*
|
|
5
|
+
* Both use the same pipe-delimited "Blizzard CSV" shape: a header row of
|
|
6
|
+
* `Name!TYPE:size` columns followed by data rows.
|
|
7
|
+
*
|
|
8
|
+
* .build.info at the install root, one row per installed product
|
|
9
|
+
* .flavor.info inside each `_retail_` / `_classic_` / ... directory
|
|
10
|
+
*/
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
function parseDelimited(text) {
|
|
14
|
+
const lines = text.split(/\r?\n/).filter((l) => l.trim().length > 0);
|
|
15
|
+
if (lines.length < 2)
|
|
16
|
+
return [];
|
|
17
|
+
// Header cells look like "Version!STRING:0"; keep the name before "!".
|
|
18
|
+
const headers = lines[0].split("|").map((h) => h.split("!")[0].trim());
|
|
19
|
+
return lines.slice(1).map((line) => {
|
|
20
|
+
const cells = line.split("|");
|
|
21
|
+
const row = {};
|
|
22
|
+
headers.forEach((header, i) => {
|
|
23
|
+
row[header] = (cells[i] ?? "").trim();
|
|
24
|
+
});
|
|
25
|
+
return row;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Reads `<installRoot>/.build.info`. Returns [] when absent or unreadable. */
|
|
29
|
+
export function readBuildInfo(installRoot) {
|
|
30
|
+
let text;
|
|
31
|
+
try {
|
|
32
|
+
text = fs.readFileSync(path.join(installRoot, ".build.info"), "utf8");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const rows = [];
|
|
38
|
+
for (const row of parseDelimited(text)) {
|
|
39
|
+
const product = row["Product"] ?? "";
|
|
40
|
+
if (!product)
|
|
41
|
+
continue;
|
|
42
|
+
rows.push({
|
|
43
|
+
product,
|
|
44
|
+
version: row["Version"] ?? "",
|
|
45
|
+
branch: row["Branch"] || undefined,
|
|
46
|
+
active: row["Active"] !== "0",
|
|
47
|
+
tags: row["Tags"] || undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return rows;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reads the product code from `<flavorDir>/.flavor.info`. The file is two
|
|
54
|
+
* lines: a `Product Flavor!STRING:0` header and the code itself.
|
|
55
|
+
*/
|
|
56
|
+
export function readFlavorInfo(flavorDir) {
|
|
57
|
+
let text;
|
|
58
|
+
try {
|
|
59
|
+
text = fs.readFileSync(path.join(flavorDir, ".flavor.info"), "utf8");
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const lines = text.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
65
|
+
const value = lines[1];
|
|
66
|
+
return value && !value.includes("!") ? value : undefined;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=build-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-info.js","sourceRoot":"","sources":["../../src/install/build-info.ts"],"names":[],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AC3D,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovers World of Warcraft installations on disk and works out which
|
|
3
|
+
* wow-ui-source track each installed client corresponds to.
|
|
4
|
+
*
|
|
5
|
+
* Signals, strongest first:
|
|
6
|
+
* 1. `<root>/.build.info` — product code + exact build for installed products
|
|
7
|
+
* 2. `<flavor>/.flavor.info` — product code for that directory
|
|
8
|
+
* 3. the client executable — version resource (works when .build.info omits the product)
|
|
9
|
+
* 4. a bundled Blizzard addon `.toc` — `## Interface` number
|
|
10
|
+
*
|
|
11
|
+
* Any path inside an install works as a starting point: the install root, a
|
|
12
|
+
* `_retail_` directory, `Interface/AddOns`, or an addon folder.
|
|
13
|
+
*/
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import os from "node:os";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { CLIENT_EXECUTABLES, flavorSpec, knownFlavorSpecs } from "../flavors.js";
|
|
18
|
+
import { interfaceVersionFromBuild } from "../types.js";
|
|
19
|
+
import { readBuildInfo, readFlavorInfo } from "./build-info.js";
|
|
20
|
+
import { readPeVersion } from "./pe-version.js";
|
|
21
|
+
import { resolveFlavor } from "./resolve.js";
|
|
22
|
+
import { readAddonTocs } from "./toc.js";
|
|
23
|
+
const KNOWN_INSTALL_DIRS = new Set(knownFlavorSpecs().flatMap((s) => s.installDirs));
|
|
24
|
+
function isInstallRoot(dir) {
|
|
25
|
+
if (fs.existsSync(path.join(dir, ".build.info")))
|
|
26
|
+
return true;
|
|
27
|
+
return flavorDirs(dir).length > 0;
|
|
28
|
+
}
|
|
29
|
+
function flavorDirs(root) {
|
|
30
|
+
let names;
|
|
31
|
+
try {
|
|
32
|
+
names = fs.readdirSync(root);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return names
|
|
38
|
+
.filter((n) => /^_.+_$/.test(n) || KNOWN_INSTALL_DIRS.has(n))
|
|
39
|
+
.filter((n) => {
|
|
40
|
+
try {
|
|
41
|
+
return fs.statSync(path.join(root, n)).isDirectory();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.sort();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Blizzard packs builds above 65535 into the 16-bit version-resource fields as
|
|
51
|
+
* decimal digit groups: 12.1.0.69814 is stored as 1201.0.6981.4. Unpack that
|
|
52
|
+
* shape and pass anything else through unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export function decodeExeVersion(fileVersion) {
|
|
55
|
+
const parts = fileVersion.split(".").map((p) => Number.parseInt(p, 10));
|
|
56
|
+
if (parts.length !== 4 || parts.some((p) => !Number.isFinite(p)))
|
|
57
|
+
return fileVersion;
|
|
58
|
+
const [a, b, c, d] = parts;
|
|
59
|
+
if (d <= 9 && c >= 1000 && a >= 100) {
|
|
60
|
+
return [Math.floor(a / 100), a % 100, b, c * 10 + d].join(".");
|
|
61
|
+
}
|
|
62
|
+
return fileVersion;
|
|
63
|
+
}
|
|
64
|
+
/** Walks up from any path inside an install to the directory holding the flavor folders. */
|
|
65
|
+
export function findInstallRoot(startPath) {
|
|
66
|
+
let current = path.resolve(startPath);
|
|
67
|
+
try {
|
|
68
|
+
if (!fs.statSync(current).isDirectory())
|
|
69
|
+
current = path.dirname(current);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < 12; i++) {
|
|
75
|
+
if (isInstallRoot(current))
|
|
76
|
+
return current;
|
|
77
|
+
const parent = path.dirname(current);
|
|
78
|
+
if (parent === current)
|
|
79
|
+
break;
|
|
80
|
+
current = parent;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
function findExecutable(clientDir) {
|
|
85
|
+
let names;
|
|
86
|
+
try {
|
|
87
|
+
names = fs.readdirSync(clientDir);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const known = new Set(CLIENT_EXECUTABLES.map((e) => e.toLowerCase()));
|
|
93
|
+
// Prefer a known client name; otherwise any Wow*.exe that is not a helper.
|
|
94
|
+
const candidates = names.filter((n) => known.has(n.toLowerCase()));
|
|
95
|
+
for (const name of names) {
|
|
96
|
+
if (/^wow.*\.exe$/i.test(name) && !/loader|error|launcher/i.test(name) && !candidates.includes(name)) {
|
|
97
|
+
candidates.push(name);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
for (const name of candidates) {
|
|
101
|
+
const pe = readPeVersion(path.join(clientDir, name));
|
|
102
|
+
if (pe)
|
|
103
|
+
return { name, version: decodeExeVersion(pe.fileVersion) };
|
|
104
|
+
}
|
|
105
|
+
return candidates[0] ? { name: candidates[0] } : undefined;
|
|
106
|
+
}
|
|
107
|
+
/** Highest interface number found in the client's bundled Blizzard addons. */
|
|
108
|
+
function interfaceFromBundledAddons(clientDir) {
|
|
109
|
+
const addonsDir = path.join(clientDir, "Interface", "AddOns");
|
|
110
|
+
let entries;
|
|
111
|
+
try {
|
|
112
|
+
entries = fs.readdirSync(addonsDir);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const versions = [];
|
|
118
|
+
for (const entry of entries.slice(0, 400)) {
|
|
119
|
+
for (const toc of readAddonTocs(path.join(addonsDir, entry))) {
|
|
120
|
+
versions.push(...toc.interfaceVersions);
|
|
121
|
+
}
|
|
122
|
+
if (versions.length >= 5)
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (versions.length === 0)
|
|
126
|
+
return undefined;
|
|
127
|
+
// Bundled Blizzard addons all carry the live interface number; user addons
|
|
128
|
+
// may lag, so take the most common value rather than the maximum.
|
|
129
|
+
const counts = new Map();
|
|
130
|
+
for (const v of versions)
|
|
131
|
+
counts.set(v, (counts.get(v) ?? 0) + 1);
|
|
132
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1] || b[0] - a[0])[0][0];
|
|
133
|
+
}
|
|
134
|
+
/** Inspects one installation root and resolves every client directory it holds. */
|
|
135
|
+
export function inspectInstall(root) {
|
|
136
|
+
const buildInfo = readBuildInfo(root);
|
|
137
|
+
const byProduct = new Map(buildInfo.filter((r) => r.version).map((r) => [r.product, r]));
|
|
138
|
+
const clients = [];
|
|
139
|
+
for (const directory of flavorDirs(root)) {
|
|
140
|
+
const clientPath = path.join(root, directory);
|
|
141
|
+
const product = readFlavorInfo(clientPath);
|
|
142
|
+
const exe = findExecutable(clientPath);
|
|
143
|
+
let version;
|
|
144
|
+
let versionSource = "unknown";
|
|
145
|
+
const fromBuildInfo = product ? byProduct.get(product) : undefined;
|
|
146
|
+
if (fromBuildInfo?.version) {
|
|
147
|
+
version = fromBuildInfo.version;
|
|
148
|
+
versionSource = "build.info";
|
|
149
|
+
}
|
|
150
|
+
else if (exe?.version) {
|
|
151
|
+
version = exe.version;
|
|
152
|
+
versionSource = "executable";
|
|
153
|
+
}
|
|
154
|
+
let interfaceVersion = version ? interfaceVersionFromBuild(version) : undefined;
|
|
155
|
+
if (!version) {
|
|
156
|
+
const fromToc = interfaceFromBundledAddons(clientPath);
|
|
157
|
+
if (fromToc) {
|
|
158
|
+
interfaceVersion = fromToc;
|
|
159
|
+
versionSource = "toc";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const clientPresent = Boolean(product || exe);
|
|
163
|
+
clients.push({
|
|
164
|
+
directory,
|
|
165
|
+
path: clientPath,
|
|
166
|
+
product,
|
|
167
|
+
version,
|
|
168
|
+
interfaceVersion,
|
|
169
|
+
versionSource,
|
|
170
|
+
executable: exe?.name,
|
|
171
|
+
clientPresent,
|
|
172
|
+
// A directory with no client is a leftover addon/WTF folder; its stale
|
|
173
|
+
// .toc numbers must not be treated as evidence of an installed build.
|
|
174
|
+
resolution: clientPresent
|
|
175
|
+
? resolveFlavor({ product, version, interfaceVersion, installDir: directory })
|
|
176
|
+
: { candidates: [], confidence: "none" },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// A product listed in .build.info without its own directory (a partially
|
|
180
|
+
// installed client) is still worth reporting.
|
|
181
|
+
for (const row of buildInfo) {
|
|
182
|
+
if (clients.some((c) => c.product === row.product))
|
|
183
|
+
continue;
|
|
184
|
+
const spec = knownFlavorSpecs().find((s) => s.products.includes(row.product));
|
|
185
|
+
clients.push({
|
|
186
|
+
directory: spec?.installDirs[0] ?? row.product,
|
|
187
|
+
path: root,
|
|
188
|
+
product: row.product,
|
|
189
|
+
version: row.version || undefined,
|
|
190
|
+
interfaceVersion: row.version ? interfaceVersionFromBuild(row.version) : undefined,
|
|
191
|
+
versionSource: row.version ? "build.info" : "unknown",
|
|
192
|
+
clientPresent: true,
|
|
193
|
+
resolution: resolveFlavor({ product: row.product, version: row.version }),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return { root, clients };
|
|
197
|
+
}
|
|
198
|
+
/** Common install locations per platform, plus `WOW_INSTALL_PATH`. */
|
|
199
|
+
export function candidateInstallPaths() {
|
|
200
|
+
const paths = [];
|
|
201
|
+
const env = process.env.WOW_INSTALL_PATH?.trim();
|
|
202
|
+
if (env)
|
|
203
|
+
paths.push(...env.split(path.delimiter).filter(Boolean));
|
|
204
|
+
const relative = [
|
|
205
|
+
"World of Warcraft",
|
|
206
|
+
"Games/World of Warcraft",
|
|
207
|
+
"Program Files (x86)/World of Warcraft",
|
|
208
|
+
"Program Files/World of Warcraft",
|
|
209
|
+
"Battle.net/World of Warcraft",
|
|
210
|
+
];
|
|
211
|
+
if (process.platform === "win32") {
|
|
212
|
+
for (let code = "C".charCodeAt(0); code <= "Z".charCodeAt(0); code++) {
|
|
213
|
+
const drive = `${String.fromCharCode(code)}:\\`;
|
|
214
|
+
if (!fs.existsSync(drive))
|
|
215
|
+
continue;
|
|
216
|
+
for (const rel of relative)
|
|
217
|
+
paths.push(path.join(drive, rel));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else if (process.platform === "darwin") {
|
|
221
|
+
paths.push("/Applications/World of Warcraft");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const home = os.homedir();
|
|
225
|
+
paths.push(path.join(home, "Games/world-of-warcraft/drive_c/Program Files (x86)/World of Warcraft"), path.join(home, ".wine/drive_c/Program Files (x86)/World of Warcraft"), path.join(home, "Games/World of Warcraft"));
|
|
226
|
+
}
|
|
227
|
+
return [...new Set(paths.map((p) => path.resolve(p)))];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Finds installs. With `startPath` it walks up from that path; otherwise it
|
|
231
|
+
* probes the usual locations for the platform.
|
|
232
|
+
*/
|
|
233
|
+
export function detectInstalls(startPath) {
|
|
234
|
+
const roots = [];
|
|
235
|
+
if (startPath) {
|
|
236
|
+
const root = findInstallRoot(startPath);
|
|
237
|
+
if (root)
|
|
238
|
+
roots.push(root);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
for (const candidate of candidateInstallPaths()) {
|
|
242
|
+
if (isInstallRoot(candidate))
|
|
243
|
+
roots.push(candidate);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return [...new Set(roots)].map(inspectInstall);
|
|
247
|
+
}
|
|
248
|
+
export { flavorSpec };
|
|
249
|
+
//# sourceMappingURL=detect.js.map
|