mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: moved tankopedia and tankaverages into a runtime cache
This commit is contained in:
1 parent
95b105cb65
commit
00b721f34f
29 files changed
+268
-235
No files matched your search
+1
-24
@@ -1,5 +1,5 @@
|
||||
import { build } from 'esbuild';
|
||||
import { copyFile, mkdir, rm, writeFile } from 'fs/promises';
|
||||
import { copyFile, mkdir, rm } from 'fs/promises';
|
||||
import { argv } from 'process';
|
||||
|
||||
const isProd = !argv.includes('--dev');
|
||||
@@ -17,29 +17,6 @@ if (isProd) {
|
||||
await mkdir('dist');
|
||||
console.log('✅ Dist created');
|
||||
|
||||
console.log('🟡 Caching tankopedia...');
|
||||
fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
.then((response) => response.text())
|
||||
.then((tankopedia) => writeFile('./dist/tankopedia.json', tankopedia))
|
||||
.then(() => console.log('✅ Tankopedia cached'));
|
||||
|
||||
console.log('🟡 Caching tank averages...');
|
||||
fetch('https://www.blitzstars.com/api/tankaverages.json')
|
||||
.then((response) => response.json())
|
||||
.then((individualTankAverages) => {
|
||||
const tankAverages = {};
|
||||
|
||||
individualTankAverages.forEach((individualTankAverage) => {
|
||||
tankAverages[individualTankAverage.tank_id] = individualTankAverage;
|
||||
});
|
||||
|
||||
return writeFile(
|
||||
'./dist/tankaverages.json',
|
||||
JSON.stringify(tankAverages),
|
||||
);
|
||||
})
|
||||
.then(() => console.log('✅ Tank averages cached'));
|
||||
|
||||
console.log('🟡 Copying package.json...');
|
||||
copyFile('package.dist.json', 'dist/package.json').then(() =>
|
||||
console.log('✅ package.json copied'),
|
||||
|
||||
Reference in new issue
Block a user