forked from ByMykel/CSGO-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
70 lines (61 loc) · 1.99 KB
/
update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as fs from "fs";
import { loadData, getManifestId } from "./services/main.js";
import { getCollectibles } from "./services/collectibles.js";
import { getKeys } from "./services/keys.js";
import { getAgents } from "./services/agents.js";
import { getCrates } from "./services/crates.js";
import { getCollections } from "./services/collections.js";
import { loadTranslations } from "./services/translations.js";
import { getGraffiti } from "./services/graffiti.js";
import { getPatches } from "./services/patches.js";
import { getStickers } from "./services/stickers.js";
import { getKeychains } from "./services/keychains.js";
import { getSkins } from "./services/skins.js";
import { LANGUAGES_URL } from "./constants.js";
import { getMusicKits } from "./services/musicKits.js";
import { getSkinsNotGrouped } from "./services/skinsNotGrouped.js";
import { getTools } from "./services/tools.js";
let existingManifestId = "";
const latestManifestId = await getManifestId();
try {
existingManifestId = fs.readFileSync("./manifestIdUpdate.txt");
} catch (err) {
if (err.code != "ENOENT") {
throw err;
}
}
if (existingManifestId == latestManifestId) {
console.log("Latest manifest Id matches existing manifest Id, exiting");
process.exit(0);
} else {
console.log(
"Latest manifest Id does not match existing manifest Id, generating new data."
);
}
await loadData();
for (const language of LANGUAGES_URL) {
console.log(`Language: ${language.language}`);
try {
await loadTranslations(language);
getAgents();
getCollectibles();
getCollections();
getCrates();
getGraffiti();
getKeys();
getMusicKits();
getPatches();
getSkins();
getSkinsNotGrouped();
getStickers();
getKeychains();
getTools();
} catch (error) {
console.log(error);
}
}
try {
fs.writeFileSync("./manifestIdUpdate.txt", latestManifestId.toString());
} catch (err) {
throw err;
}