-
Notifications
You must be signed in to change notification settings - Fork 1
/
distributor.ts
33 lines (28 loc) · 1.25 KB
/
distributor.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
import { parseLumpSumsFiles, CountryLumpSum } from "./parser.js";
import countries from './data/countries.json' assert { type: 'json' }
import packageJSON from './package.json' assert { type: 'json' }
import { writeToDisk } from "./util.js";
const allLumpSums = await parseLumpSumsFiles()
await writeToDisk('package/ALL.json', JSON.stringify(allLumpSums))
for (const country of countries) {
const lumpSums: CountryLumpSum[] = []
const lumpSumCode = country.lumpSumsFrom || country.code
for (const ls of allLumpSums) {
for (const c of ls.data) {
if (c.countryCode === lumpSumCode) {
lumpSums.push(Object.assign(c, { validFrom: ls.validFrom, lumpSumsFrom: country.lumpSumsFrom }))
}
}
}
writeToDisk('package/' + country.code + '.json', JSON.stringify(lumpSums))
}
var latest = ''
for (const lumpSum of allLumpSums) {
if (!latest) {
latest = lumpSum.validFrom
} else {
latest = new Date(lumpSum.validFrom).valueOf() > new Date(latest).valueOf() ? lumpSum.validFrom : latest
}
}
writeToDisk('package/package.json', JSON.stringify(Object.assign(packageJSON, { version: packageJSON.version + '-' + latest, devDependencies: undefined })))
writeToDisk('package/index.js', '')