@wfcd/relics 2.0.25 → 2.0.27
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/index.mjs +2 -271
- package/package.json +6 -81
- package/dist/index.d.ts +0 -236
- package/dist/index.js +0 -308
package/dist/index.mjs
CHANGED
|
@@ -1,272 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import { n as Generator, t as VersionManager } from "./VersionManager-DUIsq0rq.mjs";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
import fs from "fs/promises";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import fetch from "node-fetch";
|
|
8
|
-
|
|
9
|
-
// src/Config.ts
|
|
10
|
-
var Config = {
|
|
11
|
-
warframeRelicDropUrl: "https://drops.warframestat.us/data/relics.json",
|
|
12
|
-
warframeMarketItemUrl: "https://api.warframe.market/v1/items",
|
|
13
|
-
warframeItemsUrl: "https://api.warframestat.us/items/search/Relics?by=category",
|
|
14
|
-
warframeRelicDropInfoUrl: "https://drops.warframestat.us/data/info.json",
|
|
15
|
-
warframePatchlogsUrl: "https://raw.githubusercontent.com/WFCD/warframe-patchlogs/master/data/patchlogs.json"
|
|
16
|
-
};
|
|
17
|
-
var Config_default = Config;
|
|
18
|
-
|
|
19
|
-
// src/Logger.ts
|
|
20
|
-
import * as console from "console";
|
|
21
|
-
var fromString = /* @__PURE__ */ __name((logLevelIsh) => {
|
|
22
|
-
switch (logLevelIsh == null ? void 0 : logLevelIsh.toLowerCase()) {
|
|
23
|
-
case "fatal":
|
|
24
|
-
return -1 /* FATAL */;
|
|
25
|
-
case "error":
|
|
26
|
-
case "bad":
|
|
27
|
-
return 0 /* ERROR */;
|
|
28
|
-
case "info":
|
|
29
|
-
case "log":
|
|
30
|
-
return 1 /* LOG */;
|
|
31
|
-
case "debug":
|
|
32
|
-
return 2 /* DEBUG */;
|
|
33
|
-
default:
|
|
34
|
-
return -1 /* FATAL */;
|
|
35
|
-
}
|
|
36
|
-
}, "fromString");
|
|
37
|
-
var _Logger = class _Logger {
|
|
38
|
-
logLevel = fromString(process.env.LOG_LEVEL || "fatal");
|
|
39
|
-
log(message) {
|
|
40
|
-
if (this.logLevel >= 1 /* LOG */) console.log(message);
|
|
41
|
-
}
|
|
42
|
-
error(message) {
|
|
43
|
-
if (this.logLevel >= 0 /* ERROR */) console.error(message);
|
|
44
|
-
}
|
|
45
|
-
debug(message) {
|
|
46
|
-
if (this.logLevel === 2 /* DEBUG */) console.debug(message);
|
|
47
|
-
}
|
|
48
|
-
fatal(message) {
|
|
49
|
-
if (this.logLevel >= -1 /* FATAL */) {
|
|
50
|
-
console.error(`FATAL: ${message}`);
|
|
51
|
-
throw new Error(message);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
__name(_Logger, "Logger");
|
|
56
|
-
var Logger = _Logger;
|
|
57
|
-
var Logger_default = new Logger();
|
|
58
|
-
|
|
59
|
-
// src/Generator.ts
|
|
60
|
-
var _Generator = class _Generator {
|
|
61
|
-
relicsRaw;
|
|
62
|
-
wfcdItems;
|
|
63
|
-
wfmItems;
|
|
64
|
-
relics;
|
|
65
|
-
constructor() {
|
|
66
|
-
this.relics = [];
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Main function to fetch and generate the relic data
|
|
70
|
-
* @returns {Promise<Array<TitaniaRelic>>} The Relics data array
|
|
71
|
-
*/
|
|
72
|
-
async generate() {
|
|
73
|
-
Logger_default.log("Starting Generation");
|
|
74
|
-
await this.fetchRawData();
|
|
75
|
-
this.filterWFCDRelics();
|
|
76
|
-
this.generateTitaniaRelics();
|
|
77
|
-
return this.relics;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Fetches all required data from WFCD and WFM.
|
|
81
|
-
*/
|
|
82
|
-
async fetchRawData() {
|
|
83
|
-
var _a;
|
|
84
|
-
const relicRequest = await fetch(Config_default.warframeRelicDropUrl);
|
|
85
|
-
if (!relicRequest.ok) {
|
|
86
|
-
Logger_default.error("Failed to fetch Warframe relics from WFCD!");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
this.relicsRaw = (_a = await relicRequest.json()) == null ? void 0 : _a.relics;
|
|
90
|
-
const wfmRequest = await fetch(Config_default.warframeMarketItemUrl);
|
|
91
|
-
if (!wfmRequest.ok) {
|
|
92
|
-
Logger_default.error("Failed to fetch items from WFM!");
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.wfmItems = await wfmRequest.json();
|
|
96
|
-
const wfcdItemRequest = await fetch(Config_default.warframeItemsUrl);
|
|
97
|
-
if (!wfcdItemRequest.ok) {
|
|
98
|
-
Logger_default.error("Failed to fetch items from WFCD! ");
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
this.wfcdItems = await wfcdItemRequest.json();
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Generates the relic data
|
|
105
|
-
* uses WFCD/warframe-drop-data to check what relics exist,
|
|
106
|
-
* and adds information from WFCD/warframe-items and WFM
|
|
107
|
-
*/
|
|
108
|
-
generateTitaniaRelics() {
|
|
109
|
-
if (typeof this.relicsRaw === "undefined" || typeof this.wfmItems === "undefined") {
|
|
110
|
-
Logger_default.log("Failed to load relics/item data");
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const { length } = this.relicsRaw;
|
|
114
|
-
for (let i = 0; i < length; i += 1) {
|
|
115
|
-
const rawRelic = this.relicsRaw[i];
|
|
116
|
-
Logger_default.debug(`[${i + 1}/${length}] ${rawRelic.tier} ${rawRelic.relicName}`);
|
|
117
|
-
const relic = this.generateTitaniaRelic(rawRelic);
|
|
118
|
-
this.relics.push(relic);
|
|
119
|
-
}
|
|
120
|
-
Logger_default.debug(`Finished parsing ${this.relics.length} relics`);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Writes the fully generated data to disk.
|
|
124
|
-
* @param {string} dataDir Directory to store the relic data in. Default: ../data/
|
|
125
|
-
* @param {string} fileName Filename base ex: "Relics" becomes "Relics.json" and "Relics.min.json". Default: "Relics"
|
|
126
|
-
* @param {boolean} generateMin True if a minified json should be generated too. Default: true
|
|
127
|
-
*/
|
|
128
|
-
async writeData(dataDir, fileName, generateMin) {
|
|
129
|
-
const DataDir = dataDir ?? path.join(__dirname, "..", "data");
|
|
130
|
-
const RelicPath = fileName ? path.join(DataDir, `${fileName}.json`) : path.join(DataDir, "Relics.json");
|
|
131
|
-
await fs.writeFile(RelicPath, JSON.stringify(this.relics, void 0, 4));
|
|
132
|
-
if (generateMin) {
|
|
133
|
-
const RelicMinPath = fileName ? path.join(DataDir, `${fileName}.min.json`) : path.join(DataDir, "Relics.min.json");
|
|
134
|
-
await fs.writeFile(RelicMinPath, JSON.stringify(this.relics));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Generates a single relic from all available data
|
|
139
|
-
* @param {WFCDRelic} rawRelic relic to pull Titania data from
|
|
140
|
-
* @returns {TitaniaRelicReward}
|
|
141
|
-
*/
|
|
142
|
-
generateTitaniaRelic(rawRelic) {
|
|
143
|
-
var _a, _b;
|
|
144
|
-
const name = `${rawRelic.tier} ${rawRelic.relicName}`;
|
|
145
|
-
const rewards = rawRelic.rewards.map((rawReward) => {
|
|
146
|
-
var _a2, _b2, _c;
|
|
147
|
-
const { chance } = rawReward;
|
|
148
|
-
const { rarity } = rawReward;
|
|
149
|
-
const wfmInfo = (_a2 = this.wfmItems) == null ? void 0 : _a2.payload.items.find((x) => x.item_name === rawReward.itemName);
|
|
150
|
-
const isSpecial = ["Forma", "Kuva", "Exilus", "Riven"].find(
|
|
151
|
-
(x) => (
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/comma-dangle
|
|
153
|
-
rawReward.itemName.toLowerCase().includes(x.toLowerCase())
|
|
154
|
-
)
|
|
155
|
-
);
|
|
156
|
-
if (!(wfmInfo || isSpecial)) {
|
|
157
|
-
Logger_default.debug(`Failed to find wfm item for ${rawReward.itemName}`);
|
|
158
|
-
}
|
|
159
|
-
const item = {
|
|
160
|
-
name: rawReward.itemName,
|
|
161
|
-
uniqueName: ((_c = (_b2 = this.wfcdItems) == null ? void 0 : _b2.find((x) => x.name.toLowerCase() === `${name.trim()} Intact`.toLowerCase())) == null ? void 0 : _c.uniqueName) || "",
|
|
162
|
-
warframeMarket: void 0
|
|
163
|
-
};
|
|
164
|
-
if (wfmInfo) {
|
|
165
|
-
item.warframeMarket = { id: wfmInfo.id, urlName: wfmInfo.url_name };
|
|
166
|
-
}
|
|
167
|
-
return { rarity, chance, item };
|
|
168
|
-
});
|
|
169
|
-
let drops = [];
|
|
170
|
-
const wfcdItem = (_a = this.wfcdItems) == null ? void 0 : _a.find((x) => x.name.toLowerCase() === `${name.trim()} Intact`.toLowerCase());
|
|
171
|
-
if (!wfcdItem) {
|
|
172
|
-
Logger_default.error(`Failed to get WFCD item for relic: ${name}`);
|
|
173
|
-
}
|
|
174
|
-
if (wfcdItem && wfcdItem.drops) {
|
|
175
|
-
drops = wfcdItem.drops.map((rawDrop) => {
|
|
176
|
-
return { rarity: rawDrop.rarity, chance: rawDrop.chance, location: rawDrop.location };
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
const wfm = (_b = this.wfmItems) == null ? void 0 : _b.payload.items.find((x) => x.item_name === `${name.trim()} Relic`);
|
|
180
|
-
if (!wfm) {
|
|
181
|
-
Logger_default.error(`Failed to get relic item from wfm: ${name}`);
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
name,
|
|
185
|
-
rewards,
|
|
186
|
-
locations: drops,
|
|
187
|
-
uniqueName: (wfcdItem == null ? void 0 : wfcdItem.uniqueName) || "",
|
|
188
|
-
vaultInfo: { vaulted: drops.length === 0 },
|
|
189
|
-
...(wfm == null ? void 0 : wfm.id) && (wfm == null ? void 0 : wfm.url_name) && { warframeMarket: { id: wfm == null ? void 0 : wfm.id, urlName: wfm == null ? void 0 : wfm.url_name } }
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Filters WFCD's relic data to only include Intact variants, since we just need the base.
|
|
194
|
-
*/
|
|
195
|
-
filterWFCDRelics() {
|
|
196
|
-
var _a, _b, _c;
|
|
197
|
-
const before = ((_a = this.relicsRaw) == null ? void 0 : _a.length) || 0;
|
|
198
|
-
this.relicsRaw = (_b = this.relicsRaw) == null ? void 0 : _b.filter((x) => x.state === "Intact");
|
|
199
|
-
Logger_default.log(`Filtered relics to intact variants. Before: ${before} After: ${((_c = this.relicsRaw) == null ? void 0 : _c.length) || 0}`);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
__name(_Generator, "Generator");
|
|
203
|
-
var Generator = _Generator;
|
|
204
|
-
|
|
205
|
-
// src/VersionManager.ts
|
|
206
|
-
import path2 from "path";
|
|
207
|
-
import fs2 from "fs/promises";
|
|
208
|
-
import fetch2 from "node-fetch";
|
|
209
|
-
var _VersionManager = class _VersionManager {
|
|
210
|
-
versionPath;
|
|
211
|
-
versionRawPath;
|
|
212
|
-
hashPath;
|
|
213
|
-
/**
|
|
214
|
-
* Creates a new VersionManager instance.
|
|
215
|
-
* @param {string} dataDir Folder to write version information to.
|
|
216
|
-
* @constructor
|
|
217
|
-
*/
|
|
218
|
-
constructor(dataDir) {
|
|
219
|
-
const DataDir = dataDir ?? path2.join(__dirname, "..", "data");
|
|
220
|
-
this.versionPath = path2.join(DataDir, "version.json");
|
|
221
|
-
this.versionRawPath = path2.join(DataDir, "version.txt");
|
|
222
|
-
this.hashPath = path2.join(DataDir, "hash.json");
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Checks if the current data needs an update
|
|
226
|
-
*/
|
|
227
|
-
async updateNeeded() {
|
|
228
|
-
const infoReq = await fetch2(Config_default.warframeRelicDropInfoUrl);
|
|
229
|
-
if (!infoReq.ok) {
|
|
230
|
-
Logger_default.fatal("Failed to fetch version info!");
|
|
231
|
-
}
|
|
232
|
-
const info = await infoReq.json();
|
|
233
|
-
try {
|
|
234
|
-
await fs2.access(this.hashPath);
|
|
235
|
-
const infoFile = JSON.parse(await fs2.readFile(this.hashPath, "utf-8"));
|
|
236
|
-
return infoFile.hash !== info.hash;
|
|
237
|
-
} catch (ex) {
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Writes both game and drop version metadata
|
|
243
|
-
* @param {number} timestamp Timestamp the build was started at
|
|
244
|
-
*/
|
|
245
|
-
async writeVersion(timestamp) {
|
|
246
|
-
const patchLogsReq = await fetch2(Config_default.warframePatchlogsUrl);
|
|
247
|
-
if (!patchLogsReq.ok) {
|
|
248
|
-
Logger_default.error("Failed to fetch patchlogs");
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
const patchlogs = await patchLogsReq.json();
|
|
252
|
-
const version = patchlogs[0].name.replace(/ \+ /g, "--").replace(/[^0-9\-.]/g, "").trim();
|
|
253
|
-
const hashReq = await fetch2(Config_default.warframeRelicDropInfoUrl);
|
|
254
|
-
if (!hashReq.ok) {
|
|
255
|
-
Logger_default.error("Failed to fetch hashInfo");
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
const hashInfo = await hashReq.json();
|
|
259
|
-
const versionInfo = { version, title: patchlogs[0].name };
|
|
260
|
-
const hashFile = { hash: hashInfo.hash, deUpdated: hashInfo.modified, timestamp };
|
|
261
|
-
await fs2.writeFile(this.hashPath, JSON.stringify(hashFile, void 0, 2), "utf-8");
|
|
262
|
-
await fs2.writeFile(this.versionPath, JSON.stringify(versionInfo, void 0, 2), "utf-8");
|
|
263
|
-
await fs2.writeFile(this.versionRawPath, version, "utf-8");
|
|
264
|
-
Logger_default.debug("Finished writing version info");
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
__name(_VersionManager, "VersionManager");
|
|
268
|
-
var VersionManager = _VersionManager;
|
|
269
|
-
export {
|
|
270
|
-
Generator,
|
|
271
|
-
VersionManager
|
|
272
|
-
};
|
|
3
|
+
export { Generator, VersionManager };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wfcd/relics",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
4
4
|
"description": "Relic Data for Warframe",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "
|
|
17
|
+
"build": "tsdown ./src/index.ts ./src/Build.ts",
|
|
18
18
|
"coverage": "npm test && nyc report --reporter=text-lcov | coveralls",
|
|
19
19
|
"lint": "eslint .",
|
|
20
20
|
"lint:fix": "eslint . --fix",
|
|
@@ -47,97 +47,22 @@
|
|
|
47
47
|
"nyc": "^17.0.0",
|
|
48
48
|
"precommit-hook": "^3.0.0",
|
|
49
49
|
"ts-mocha": "^11.1.0",
|
|
50
|
-
"ts-node": "^10.9.1",
|
|
51
50
|
"tsconfig-paths": "^4.1.0",
|
|
52
|
-
"
|
|
51
|
+
"tsdown": "^0.20.3",
|
|
52
|
+
"tsx": "^4.21.0",
|
|
53
53
|
"typescript": "^5.0.4"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
57
|
+
"@semantic-release/git": "^10.0.1",
|
|
56
58
|
"node-fetch": "^2.6.7",
|
|
57
59
|
"warframe-patchlogs": "^2.3.3"
|
|
58
60
|
},
|
|
59
|
-
"eslintIgnore": [
|
|
60
|
-
"dist/**"
|
|
61
|
-
],
|
|
62
|
-
"eslintConfig": {
|
|
63
|
-
"extends": [
|
|
64
|
-
"@wfcd/eslint-config/typescript"
|
|
65
|
-
],
|
|
66
|
-
"parserOptions": {
|
|
67
|
-
"project": "tsconfig.json"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"prettier": "@wfcd/eslint-config/prettier",
|
|
71
|
-
"babel": {
|
|
72
|
-
"presets": [
|
|
73
|
-
"@babel/preset-env"
|
|
74
|
-
],
|
|
75
|
-
"plugins": [
|
|
76
|
-
"@babel/plugin-proposal-class-properties",
|
|
77
|
-
"@babel/plugin-proposal-private-methods"
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
"release": {
|
|
81
|
-
"plugins": [
|
|
82
|
-
"@semantic-release/commit-analyzer",
|
|
83
|
-
"@semantic-release/release-notes-generator",
|
|
84
|
-
"@semantic-release/npm",
|
|
85
|
-
"@semantic-release/github",
|
|
86
|
-
[
|
|
87
|
-
"@semantic-release/changelog",
|
|
88
|
-
{
|
|
89
|
-
"assets": [
|
|
90
|
-
"CHANGELOG.md"
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
"@semantic-release/git",
|
|
96
|
-
{
|
|
97
|
-
"assets": [
|
|
98
|
-
"package.json",
|
|
99
|
-
"package-lock.json",
|
|
100
|
-
"CHANGELOG.md"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
],
|
|
105
|
-
"branches": "development"
|
|
106
|
-
},
|
|
107
|
-
"mocha": {
|
|
108
|
-
"exit": true,
|
|
109
|
-
"spec": "src/spec/**/*.spec.ts",
|
|
110
|
-
"timeout": "1000",
|
|
111
|
-
"loader": "ts-node/esm",
|
|
112
|
-
"extension": "ts"
|
|
113
|
-
},
|
|
114
|
-
"nyc": {
|
|
115
|
-
"exclude": [
|
|
116
|
-
"src/spec/**",
|
|
117
|
-
"dist/**"
|
|
118
|
-
],
|
|
119
|
-
"skip-full": true,
|
|
120
|
-
"reporter": [
|
|
121
|
-
"lcov",
|
|
122
|
-
"text"
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
61
|
"pre-commit": [
|
|
126
62
|
"lint",
|
|
127
63
|
"test",
|
|
128
64
|
"validate"
|
|
129
65
|
],
|
|
130
|
-
"tsup": {
|
|
131
|
-
"dts": true,
|
|
132
|
-
"clean": true,
|
|
133
|
-
"keepNames": true,
|
|
134
|
-
"target": "node14",
|
|
135
|
-
"splitting": false,
|
|
136
|
-
"format": [
|
|
137
|
-
"cjs",
|
|
138
|
-
"esm"
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
66
|
"publishConfig": {
|
|
142
67
|
"provenance": true
|
|
143
68
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
interface WarframeMarketRoot {
|
|
2
|
-
payload: {
|
|
3
|
-
items: Array<WarframeMarketItem>;
|
|
4
|
-
};
|
|
5
|
-
}
|
|
6
|
-
interface WarframeMarketItem {
|
|
7
|
-
/**
|
|
8
|
-
* WFM Item ID
|
|
9
|
-
*/
|
|
10
|
-
id: string;
|
|
11
|
-
/**
|
|
12
|
-
* Url name for querying WFM
|
|
13
|
-
*/
|
|
14
|
-
url_name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Thumbnail URL relative to wfm api base
|
|
17
|
-
*/
|
|
18
|
-
thumb: string;
|
|
19
|
-
/**
|
|
20
|
-
* Item Name
|
|
21
|
-
*/
|
|
22
|
-
item_name: string;
|
|
23
|
-
}
|
|
24
|
-
interface WFCDRelic {
|
|
25
|
-
/**
|
|
26
|
-
* Relic Tier (Axi, Neo, etc.)
|
|
27
|
-
*/
|
|
28
|
-
tier: string;
|
|
29
|
-
/**
|
|
30
|
-
* Relic Name (A1, A10, etc.)
|
|
31
|
-
*/
|
|
32
|
-
relicName: string;
|
|
33
|
-
/**
|
|
34
|
-
* Relic Refinement state
|
|
35
|
-
*/
|
|
36
|
-
state: 'Intact' | 'Exceptional' | 'Flawless' | 'Radiant';
|
|
37
|
-
/**
|
|
38
|
-
* Relic Rewards
|
|
39
|
-
*/
|
|
40
|
-
rewards: Array<WFCDRelicReward>;
|
|
41
|
-
/**
|
|
42
|
-
* Internal WFCD id
|
|
43
|
-
*/
|
|
44
|
-
_id: string;
|
|
45
|
-
}
|
|
46
|
-
interface WFCDRelicReward {
|
|
47
|
-
/**
|
|
48
|
-
* Dropped Item name
|
|
49
|
-
*/
|
|
50
|
-
itemName: string;
|
|
51
|
-
/**
|
|
52
|
-
* Dropchance Rarity (Uncommon/Rare ?)
|
|
53
|
-
*/
|
|
54
|
-
rarity: 'Uncommon' | 'Rare';
|
|
55
|
-
/**
|
|
56
|
-
* Actual Dropchance in %
|
|
57
|
-
*/
|
|
58
|
-
chance: number;
|
|
59
|
-
/**
|
|
60
|
-
* Internal ID
|
|
61
|
-
*/
|
|
62
|
-
_id: string;
|
|
63
|
-
}
|
|
64
|
-
interface WFCDItem {
|
|
65
|
-
/**
|
|
66
|
-
* Item Name
|
|
67
|
-
*/
|
|
68
|
-
name: string;
|
|
69
|
-
/** Unique identifying name */
|
|
70
|
-
uniqueName: string;
|
|
71
|
-
/**
|
|
72
|
-
* Item Drop Location
|
|
73
|
-
*/
|
|
74
|
-
drops?: Array<WFCDItemDropLocation>;
|
|
75
|
-
}
|
|
76
|
-
interface WFCDItemDropLocation {
|
|
77
|
-
/**
|
|
78
|
-
* Dropchance in %
|
|
79
|
-
*/
|
|
80
|
-
chance: number;
|
|
81
|
-
/**
|
|
82
|
-
* Mission location
|
|
83
|
-
*/
|
|
84
|
-
location: string;
|
|
85
|
-
/**
|
|
86
|
-
* Drop rarity
|
|
87
|
-
*/
|
|
88
|
-
rarity: string;
|
|
89
|
-
/**
|
|
90
|
-
* Relic Type
|
|
91
|
-
*/
|
|
92
|
-
type: string;
|
|
93
|
-
}
|
|
94
|
-
interface TitaniaRelic {
|
|
95
|
-
/**
|
|
96
|
-
* Relic Combined Name (Ex: Axi A1)
|
|
97
|
-
*/
|
|
98
|
-
name: string;
|
|
99
|
-
/**
|
|
100
|
-
* Relic Rewards when opened
|
|
101
|
-
*/
|
|
102
|
-
rewards: Array<TitaniaRelicReward>;
|
|
103
|
-
/**
|
|
104
|
-
* Drop Locations for the relics
|
|
105
|
-
*/
|
|
106
|
-
locations: Array<TitaniaRelicLocation>;
|
|
107
|
-
/**
|
|
108
|
-
* Warframe Market Information
|
|
109
|
-
* undefined for untradable
|
|
110
|
-
*/
|
|
111
|
-
warframeMarket?: TitaniaWFMInfo;
|
|
112
|
-
/**
|
|
113
|
-
* Relic Vault Information
|
|
114
|
-
*/
|
|
115
|
-
vaultInfo: TitaniaRelicVaultedInfo;
|
|
116
|
-
/** unique name for corresponding warframe-items Item */
|
|
117
|
-
uniqueName: string;
|
|
118
|
-
}
|
|
119
|
-
interface TitaniaRelicReward {
|
|
120
|
-
/**
|
|
121
|
-
* Relic Rarity (Uncommon,Rare ?)
|
|
122
|
-
*/
|
|
123
|
-
rarity: 'Uncommon' | 'Rare';
|
|
124
|
-
/**
|
|
125
|
-
* Reward Drop Chance in %
|
|
126
|
-
*/
|
|
127
|
-
chance: number;
|
|
128
|
-
/**
|
|
129
|
-
* Item Information
|
|
130
|
-
*/
|
|
131
|
-
item: TitaniaRelicRewardItem;
|
|
132
|
-
}
|
|
133
|
-
interface TitaniaRelicRewardItem {
|
|
134
|
-
/**
|
|
135
|
-
* Item Name
|
|
136
|
-
*/
|
|
137
|
-
name: string;
|
|
138
|
-
/** unique name for corresponding warframe-items Item */
|
|
139
|
-
uniqueName: string;
|
|
140
|
-
/**
|
|
141
|
-
* WarframeMarket Info
|
|
142
|
-
*/
|
|
143
|
-
warframeMarket?: TitaniaWFMInfo;
|
|
144
|
-
}
|
|
145
|
-
type Rarity = 'Uncommon' | 'Rare' | 'Legendary' | 'Common';
|
|
146
|
-
interface TitaniaRelicLocation {
|
|
147
|
-
/** Location Info $planet-$node (Ex: Eris - Phalan) */
|
|
148
|
-
location: string;
|
|
149
|
-
/**
|
|
150
|
-
* Rarity (Uncommon, Rare ?)
|
|
151
|
-
*/
|
|
152
|
-
rarity: Rarity;
|
|
153
|
-
/**
|
|
154
|
-
* Dropchance in %
|
|
155
|
-
*/
|
|
156
|
-
chance: number;
|
|
157
|
-
}
|
|
158
|
-
interface TitaniaWFMInfo {
|
|
159
|
-
/**
|
|
160
|
-
* Warframe Market ID
|
|
161
|
-
*/
|
|
162
|
-
id: string;
|
|
163
|
-
/**
|
|
164
|
-
* Warframe market URL parameter
|
|
165
|
-
*/
|
|
166
|
-
urlName: string;
|
|
167
|
-
}
|
|
168
|
-
interface TitaniaRelicVaultedInfo {
|
|
169
|
-
/**
|
|
170
|
-
* If the relic is vaulted
|
|
171
|
-
*/
|
|
172
|
-
vaulted: boolean;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
declare class Generator {
|
|
176
|
-
relicsRaw: Array<WFCDRelic> | undefined;
|
|
177
|
-
wfcdItems: Array<WFCDItem> | undefined;
|
|
178
|
-
wfmItems: WarframeMarketRoot | undefined;
|
|
179
|
-
relics: Array<TitaniaRelic>;
|
|
180
|
-
constructor();
|
|
181
|
-
/**
|
|
182
|
-
* Main function to fetch and generate the relic data
|
|
183
|
-
* @returns {Promise<Array<TitaniaRelic>>} The Relics data array
|
|
184
|
-
*/
|
|
185
|
-
generate(): Promise<Array<TitaniaRelic>>;
|
|
186
|
-
/**
|
|
187
|
-
* Fetches all required data from WFCD and WFM.
|
|
188
|
-
*/
|
|
189
|
-
fetchRawData(): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Generates the relic data
|
|
192
|
-
* uses WFCD/warframe-drop-data to check what relics exist,
|
|
193
|
-
* and adds information from WFCD/warframe-items and WFM
|
|
194
|
-
*/
|
|
195
|
-
generateTitaniaRelics(): void;
|
|
196
|
-
/**
|
|
197
|
-
* Writes the fully generated data to disk.
|
|
198
|
-
* @param {string} dataDir Directory to store the relic data in. Default: ../data/
|
|
199
|
-
* @param {string} fileName Filename base ex: "Relics" becomes "Relics.json" and "Relics.min.json". Default: "Relics"
|
|
200
|
-
* @param {boolean} generateMin True if a minified json should be generated too. Default: true
|
|
201
|
-
*/
|
|
202
|
-
writeData(dataDir?: string, fileName?: string, generateMin?: boolean): Promise<void>;
|
|
203
|
-
/**
|
|
204
|
-
* Generates a single relic from all available data
|
|
205
|
-
* @param {WFCDRelic} rawRelic relic to pull Titania data from
|
|
206
|
-
* @returns {TitaniaRelicReward}
|
|
207
|
-
*/
|
|
208
|
-
private generateTitaniaRelic;
|
|
209
|
-
/**
|
|
210
|
-
* Filters WFCD's relic data to only include Intact variants, since we just need the base.
|
|
211
|
-
*/
|
|
212
|
-
private filterWFCDRelics;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
declare class VersionManager {
|
|
216
|
-
versionPath: string;
|
|
217
|
-
versionRawPath: string;
|
|
218
|
-
hashPath: string;
|
|
219
|
-
/**
|
|
220
|
-
* Creates a new VersionManager instance.
|
|
221
|
-
* @param {string} dataDir Folder to write version information to.
|
|
222
|
-
* @constructor
|
|
223
|
-
*/
|
|
224
|
-
constructor(dataDir?: string);
|
|
225
|
-
/**
|
|
226
|
-
* Checks if the current data needs an update
|
|
227
|
-
*/
|
|
228
|
-
updateNeeded(): Promise<boolean>;
|
|
229
|
-
/**
|
|
230
|
-
* Writes both game and drop version metadata
|
|
231
|
-
* @param {number} timestamp Timestamp the build was started at
|
|
232
|
-
*/
|
|
233
|
-
writeVersion(timestamp: number): Promise<void>;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export { Generator, type Rarity, type TitaniaRelic, type TitaniaRelicLocation, type TitaniaRelicReward, type TitaniaRelicRewardItem, type TitaniaRelicVaultedInfo, type TitaniaWFMInfo, VersionManager, type WFCDItem, type WFCDItemDropLocation, type WFCDRelic, type WFCDRelicReward, type WarframeMarketItem, type WarframeMarketRoot };
|
package/dist/index.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
Generator: () => Generator,
|
|
35
|
-
VersionManager: () => VersionManager
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
|
|
39
|
-
// src/Generator.ts
|
|
40
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
41
|
-
var import_node_path = __toESM(require("path"));
|
|
42
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
43
|
-
|
|
44
|
-
// src/Config.ts
|
|
45
|
-
var Config = {
|
|
46
|
-
warframeRelicDropUrl: "https://drops.warframestat.us/data/relics.json",
|
|
47
|
-
warframeMarketItemUrl: "https://api.warframe.market/v1/items",
|
|
48
|
-
warframeItemsUrl: "https://api.warframestat.us/items/search/Relics?by=category",
|
|
49
|
-
warframeRelicDropInfoUrl: "https://drops.warframestat.us/data/info.json",
|
|
50
|
-
warframePatchlogsUrl: "https://raw.githubusercontent.com/WFCD/warframe-patchlogs/master/data/patchlogs.json"
|
|
51
|
-
};
|
|
52
|
-
var Config_default = Config;
|
|
53
|
-
|
|
54
|
-
// src/Logger.ts
|
|
55
|
-
var console = __toESM(require("console"));
|
|
56
|
-
var fromString = /* @__PURE__ */ __name((logLevelIsh) => {
|
|
57
|
-
switch (logLevelIsh == null ? void 0 : logLevelIsh.toLowerCase()) {
|
|
58
|
-
case "fatal":
|
|
59
|
-
return -1 /* FATAL */;
|
|
60
|
-
case "error":
|
|
61
|
-
case "bad":
|
|
62
|
-
return 0 /* ERROR */;
|
|
63
|
-
case "info":
|
|
64
|
-
case "log":
|
|
65
|
-
return 1 /* LOG */;
|
|
66
|
-
case "debug":
|
|
67
|
-
return 2 /* DEBUG */;
|
|
68
|
-
default:
|
|
69
|
-
return -1 /* FATAL */;
|
|
70
|
-
}
|
|
71
|
-
}, "fromString");
|
|
72
|
-
var _Logger = class _Logger {
|
|
73
|
-
logLevel = fromString(process.env.LOG_LEVEL || "fatal");
|
|
74
|
-
log(message) {
|
|
75
|
-
if (this.logLevel >= 1 /* LOG */) console.log(message);
|
|
76
|
-
}
|
|
77
|
-
error(message) {
|
|
78
|
-
if (this.logLevel >= 0 /* ERROR */) console.error(message);
|
|
79
|
-
}
|
|
80
|
-
debug(message) {
|
|
81
|
-
if (this.logLevel === 2 /* DEBUG */) console.debug(message);
|
|
82
|
-
}
|
|
83
|
-
fatal(message) {
|
|
84
|
-
if (this.logLevel >= -1 /* FATAL */) {
|
|
85
|
-
console.error(`FATAL: ${message}`);
|
|
86
|
-
throw new Error(message);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
__name(_Logger, "Logger");
|
|
91
|
-
var Logger = _Logger;
|
|
92
|
-
var Logger_default = new Logger();
|
|
93
|
-
|
|
94
|
-
// src/Generator.ts
|
|
95
|
-
var _Generator = class _Generator {
|
|
96
|
-
relicsRaw;
|
|
97
|
-
wfcdItems;
|
|
98
|
-
wfmItems;
|
|
99
|
-
relics;
|
|
100
|
-
constructor() {
|
|
101
|
-
this.relics = [];
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Main function to fetch and generate the relic data
|
|
105
|
-
* @returns {Promise<Array<TitaniaRelic>>} The Relics data array
|
|
106
|
-
*/
|
|
107
|
-
async generate() {
|
|
108
|
-
Logger_default.log("Starting Generation");
|
|
109
|
-
await this.fetchRawData();
|
|
110
|
-
this.filterWFCDRelics();
|
|
111
|
-
this.generateTitaniaRelics();
|
|
112
|
-
return this.relics;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Fetches all required data from WFCD and WFM.
|
|
116
|
-
*/
|
|
117
|
-
async fetchRawData() {
|
|
118
|
-
var _a;
|
|
119
|
-
const relicRequest = await (0, import_node_fetch.default)(Config_default.warframeRelicDropUrl);
|
|
120
|
-
if (!relicRequest.ok) {
|
|
121
|
-
Logger_default.error("Failed to fetch Warframe relics from WFCD!");
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this.relicsRaw = (_a = await relicRequest.json()) == null ? void 0 : _a.relics;
|
|
125
|
-
const wfmRequest = await (0, import_node_fetch.default)(Config_default.warframeMarketItemUrl);
|
|
126
|
-
if (!wfmRequest.ok) {
|
|
127
|
-
Logger_default.error("Failed to fetch items from WFM!");
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
this.wfmItems = await wfmRequest.json();
|
|
131
|
-
const wfcdItemRequest = await (0, import_node_fetch.default)(Config_default.warframeItemsUrl);
|
|
132
|
-
if (!wfcdItemRequest.ok) {
|
|
133
|
-
Logger_default.error("Failed to fetch items from WFCD! ");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.wfcdItems = await wfcdItemRequest.json();
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Generates the relic data
|
|
140
|
-
* uses WFCD/warframe-drop-data to check what relics exist,
|
|
141
|
-
* and adds information from WFCD/warframe-items and WFM
|
|
142
|
-
*/
|
|
143
|
-
generateTitaniaRelics() {
|
|
144
|
-
if (typeof this.relicsRaw === "undefined" || typeof this.wfmItems === "undefined") {
|
|
145
|
-
Logger_default.log("Failed to load relics/item data");
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const { length } = this.relicsRaw;
|
|
149
|
-
for (let i = 0; i < length; i += 1) {
|
|
150
|
-
const rawRelic = this.relicsRaw[i];
|
|
151
|
-
Logger_default.debug(`[${i + 1}/${length}] ${rawRelic.tier} ${rawRelic.relicName}`);
|
|
152
|
-
const relic = this.generateTitaniaRelic(rawRelic);
|
|
153
|
-
this.relics.push(relic);
|
|
154
|
-
}
|
|
155
|
-
Logger_default.debug(`Finished parsing ${this.relics.length} relics`);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Writes the fully generated data to disk.
|
|
159
|
-
* @param {string} dataDir Directory to store the relic data in. Default: ../data/
|
|
160
|
-
* @param {string} fileName Filename base ex: "Relics" becomes "Relics.json" and "Relics.min.json". Default: "Relics"
|
|
161
|
-
* @param {boolean} generateMin True if a minified json should be generated too. Default: true
|
|
162
|
-
*/
|
|
163
|
-
async writeData(dataDir, fileName, generateMin) {
|
|
164
|
-
const DataDir = dataDir ?? import_node_path.default.join(__dirname, "..", "data");
|
|
165
|
-
const RelicPath = fileName ? import_node_path.default.join(DataDir, `${fileName}.json`) : import_node_path.default.join(DataDir, "Relics.json");
|
|
166
|
-
await import_promises.default.writeFile(RelicPath, JSON.stringify(this.relics, void 0, 4));
|
|
167
|
-
if (generateMin) {
|
|
168
|
-
const RelicMinPath = fileName ? import_node_path.default.join(DataDir, `${fileName}.min.json`) : import_node_path.default.join(DataDir, "Relics.min.json");
|
|
169
|
-
await import_promises.default.writeFile(RelicMinPath, JSON.stringify(this.relics));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Generates a single relic from all available data
|
|
174
|
-
* @param {WFCDRelic} rawRelic relic to pull Titania data from
|
|
175
|
-
* @returns {TitaniaRelicReward}
|
|
176
|
-
*/
|
|
177
|
-
generateTitaniaRelic(rawRelic) {
|
|
178
|
-
var _a, _b;
|
|
179
|
-
const name = `${rawRelic.tier} ${rawRelic.relicName}`;
|
|
180
|
-
const rewards = rawRelic.rewards.map((rawReward) => {
|
|
181
|
-
var _a2, _b2, _c;
|
|
182
|
-
const { chance } = rawReward;
|
|
183
|
-
const { rarity } = rawReward;
|
|
184
|
-
const wfmInfo = (_a2 = this.wfmItems) == null ? void 0 : _a2.payload.items.find((x) => x.item_name === rawReward.itemName);
|
|
185
|
-
const isSpecial = ["Forma", "Kuva", "Exilus", "Riven"].find(
|
|
186
|
-
(x) => (
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/comma-dangle
|
|
188
|
-
rawReward.itemName.toLowerCase().includes(x.toLowerCase())
|
|
189
|
-
)
|
|
190
|
-
);
|
|
191
|
-
if (!(wfmInfo || isSpecial)) {
|
|
192
|
-
Logger_default.debug(`Failed to find wfm item for ${rawReward.itemName}`);
|
|
193
|
-
}
|
|
194
|
-
const item = {
|
|
195
|
-
name: rawReward.itemName,
|
|
196
|
-
uniqueName: ((_c = (_b2 = this.wfcdItems) == null ? void 0 : _b2.find((x) => x.name.toLowerCase() === `${name.trim()} Intact`.toLowerCase())) == null ? void 0 : _c.uniqueName) || "",
|
|
197
|
-
warframeMarket: void 0
|
|
198
|
-
};
|
|
199
|
-
if (wfmInfo) {
|
|
200
|
-
item.warframeMarket = { id: wfmInfo.id, urlName: wfmInfo.url_name };
|
|
201
|
-
}
|
|
202
|
-
return { rarity, chance, item };
|
|
203
|
-
});
|
|
204
|
-
let drops = [];
|
|
205
|
-
const wfcdItem = (_a = this.wfcdItems) == null ? void 0 : _a.find((x) => x.name.toLowerCase() === `${name.trim()} Intact`.toLowerCase());
|
|
206
|
-
if (!wfcdItem) {
|
|
207
|
-
Logger_default.error(`Failed to get WFCD item for relic: ${name}`);
|
|
208
|
-
}
|
|
209
|
-
if (wfcdItem && wfcdItem.drops) {
|
|
210
|
-
drops = wfcdItem.drops.map((rawDrop) => {
|
|
211
|
-
return { rarity: rawDrop.rarity, chance: rawDrop.chance, location: rawDrop.location };
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const wfm = (_b = this.wfmItems) == null ? void 0 : _b.payload.items.find((x) => x.item_name === `${name.trim()} Relic`);
|
|
215
|
-
if (!wfm) {
|
|
216
|
-
Logger_default.error(`Failed to get relic item from wfm: ${name}`);
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
name,
|
|
220
|
-
rewards,
|
|
221
|
-
locations: drops,
|
|
222
|
-
uniqueName: (wfcdItem == null ? void 0 : wfcdItem.uniqueName) || "",
|
|
223
|
-
vaultInfo: { vaulted: drops.length === 0 },
|
|
224
|
-
...(wfm == null ? void 0 : wfm.id) && (wfm == null ? void 0 : wfm.url_name) && { warframeMarket: { id: wfm == null ? void 0 : wfm.id, urlName: wfm == null ? void 0 : wfm.url_name } }
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Filters WFCD's relic data to only include Intact variants, since we just need the base.
|
|
229
|
-
*/
|
|
230
|
-
filterWFCDRelics() {
|
|
231
|
-
var _a, _b, _c;
|
|
232
|
-
const before = ((_a = this.relicsRaw) == null ? void 0 : _a.length) || 0;
|
|
233
|
-
this.relicsRaw = (_b = this.relicsRaw) == null ? void 0 : _b.filter((x) => x.state === "Intact");
|
|
234
|
-
Logger_default.log(`Filtered relics to intact variants. Before: ${before} After: ${((_c = this.relicsRaw) == null ? void 0 : _c.length) || 0}`);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
__name(_Generator, "Generator");
|
|
238
|
-
var Generator = _Generator;
|
|
239
|
-
|
|
240
|
-
// src/VersionManager.ts
|
|
241
|
-
var import_node_path2 = __toESM(require("path"));
|
|
242
|
-
var import_promises2 = __toESM(require("fs/promises"));
|
|
243
|
-
var import_node_fetch2 = __toESM(require("node-fetch"));
|
|
244
|
-
var _VersionManager = class _VersionManager {
|
|
245
|
-
versionPath;
|
|
246
|
-
versionRawPath;
|
|
247
|
-
hashPath;
|
|
248
|
-
/**
|
|
249
|
-
* Creates a new VersionManager instance.
|
|
250
|
-
* @param {string} dataDir Folder to write version information to.
|
|
251
|
-
* @constructor
|
|
252
|
-
*/
|
|
253
|
-
constructor(dataDir) {
|
|
254
|
-
const DataDir = dataDir ?? import_node_path2.default.join(__dirname, "..", "data");
|
|
255
|
-
this.versionPath = import_node_path2.default.join(DataDir, "version.json");
|
|
256
|
-
this.versionRawPath = import_node_path2.default.join(DataDir, "version.txt");
|
|
257
|
-
this.hashPath = import_node_path2.default.join(DataDir, "hash.json");
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Checks if the current data needs an update
|
|
261
|
-
*/
|
|
262
|
-
async updateNeeded() {
|
|
263
|
-
const infoReq = await (0, import_node_fetch2.default)(Config_default.warframeRelicDropInfoUrl);
|
|
264
|
-
if (!infoReq.ok) {
|
|
265
|
-
Logger_default.fatal("Failed to fetch version info!");
|
|
266
|
-
}
|
|
267
|
-
const info = await infoReq.json();
|
|
268
|
-
try {
|
|
269
|
-
await import_promises2.default.access(this.hashPath);
|
|
270
|
-
const infoFile = JSON.parse(await import_promises2.default.readFile(this.hashPath, "utf-8"));
|
|
271
|
-
return infoFile.hash !== info.hash;
|
|
272
|
-
} catch (ex) {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Writes both game and drop version metadata
|
|
278
|
-
* @param {number} timestamp Timestamp the build was started at
|
|
279
|
-
*/
|
|
280
|
-
async writeVersion(timestamp) {
|
|
281
|
-
const patchLogsReq = await (0, import_node_fetch2.default)(Config_default.warframePatchlogsUrl);
|
|
282
|
-
if (!patchLogsReq.ok) {
|
|
283
|
-
Logger_default.error("Failed to fetch patchlogs");
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const patchlogs = await patchLogsReq.json();
|
|
287
|
-
const version = patchlogs[0].name.replace(/ \+ /g, "--").replace(/[^0-9\-.]/g, "").trim();
|
|
288
|
-
const hashReq = await (0, import_node_fetch2.default)(Config_default.warframeRelicDropInfoUrl);
|
|
289
|
-
if (!hashReq.ok) {
|
|
290
|
-
Logger_default.error("Failed to fetch hashInfo");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const hashInfo = await hashReq.json();
|
|
294
|
-
const versionInfo = { version, title: patchlogs[0].name };
|
|
295
|
-
const hashFile = { hash: hashInfo.hash, deUpdated: hashInfo.modified, timestamp };
|
|
296
|
-
await import_promises2.default.writeFile(this.hashPath, JSON.stringify(hashFile, void 0, 2), "utf-8");
|
|
297
|
-
await import_promises2.default.writeFile(this.versionPath, JSON.stringify(versionInfo, void 0, 2), "utf-8");
|
|
298
|
-
await import_promises2.default.writeFile(this.versionRawPath, version, "utf-8");
|
|
299
|
-
Logger_default.debug("Finished writing version info");
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
__name(_VersionManager, "VersionManager");
|
|
303
|
-
var VersionManager = _VersionManager;
|
|
304
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
305
|
-
0 && (module.exports = {
|
|
306
|
-
Generator,
|
|
307
|
-
VersionManager
|
|
308
|
-
});
|