-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdevWrapper.ts
70 lines (66 loc) · 1.75 KB
/
devWrapper.ts
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 { generate, invasions } from './src/index'
import baseStats from './static/baseStats.json'
import tempEvos from './static/tempEvos.json'
import types from './static/types.json'
const main = async () => {
const mfData = await fetch(
'https://raw.githubusercontent.com/PokeMiners/game_masters/master/latest/latest.json',
)
const mf = await mfData.json()
fs.writeFileSync('./latest.json', JSON.stringify(mf, null, 2), 'utf8')
console.time('Generated in')
const data = await generate({
raw: process.argv.includes('--raw'),
test: process.argv.includes('--test'),
pokeApi: process.argv.includes('--pokeapi') || {
baseStats,
tempEvos,
types,
},
})
if (process.argv.includes('--test')) {
if (process.argv.includes('--invasions')) {
fs.writeFile(
'./invasions.json',
JSON.stringify(await invasions(), null, 2),
'utf8',
() => {},
)
}
if (data?.AllPokeApi) {
const { baseStats, tempEvos, types } = data.AllPokeApi
fs.writeFile(
'./static/baseStats.json',
JSON.stringify(baseStats, null, 2),
'utf8',
() => {},
)
fs.writeFile(
'./static/tempEvos.json',
JSON.stringify(tempEvos, null, 2),
'utf8',
() => {},
)
fs.writeFile(
'./static/types.json',
JSON.stringify(types, null, 2),
'utf8',
() => {},
)
delete data.AllPokeApi
}
if (data) {
fs.writeFile(
'./masterfile.json',
JSON.stringify(data, null, 2),
'utf8',
() => {},
)
}
}
console.timeEnd('Generated in')
}
main()
.catch((e) => console.log(e))
.then(() => console.log('New masterfile generated'))