feat: migration

This commit is contained in:
tresabhi committed 2025-04-06 22:57:35 -05:00
1 parent 4253cd3e1b
commit cc6c4faa2d
4 files changed
+44

No files matched your search

@@ -18,6 +18,7 @@ import { definitions } from './definitions';
import { equipmentIcons } from './equipmentIcons';
import { flags } from './flags';
import { gameModeBanners } from './gameModeBanners';
import { migration } from './migration';
import { moduleIcons } from './moduleIcons';
import { shellIcons } from './shellIcons';
import { skillIcons } from './skillIcons';
@@ -28,6 +29,7 @@ import { tankModels } from './tankModels';
if (!targets && !allTargets) throw new Error('No target(s) specified');
const methods = [
migration,
definitions,
tankModels,
tankArmors,
@@ -0,0 +1,38 @@
import { toUniqueId } from '@blitzkit/core';
import { readdir } from 'fs/promises';
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
import { commitAssets } from '../core/github/commitAssets';
import { DATA } from './constants';
import { VehicleDefinitionList } from './definitions';
export async function migration() {
console.log('Building migration map...');
const map: Record<string, number> = {};
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'),
);
await Promise.all(
nations.map(async (nation) => {
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`,
);
for (const tankKey in tankList.root) {
const tank = tankList.root[tankKey];
const tankId = toUniqueId(nation, tank.id);
const davaKey = `${nation}:${tankKey}`;
map[davaKey] = tankId;
}
}),
);
await commitAssets('migration', [
{
path: 'definitions/migration.json',
content: Buffer.from(JSON.stringify(map)),
},
]);
}