Files
blitzkit/packages/scripts/src/buildAssets/migration.ts
T

34 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-10-23 21:22:21 -05:00
import { toUniqueId } from "@blitzkit/core";
import { AssetUploader } from "../core/github/assetUploader";
2025-11-26 13:18:44 -06:00
import { vfs } from "./constants";
2025-10-23 21:22:21 -05:00
import { VehicleDefinitionList } from "./definitions";
2025-04-06 22:57:35 -05:00
export async function migration() {
2025-10-23 21:22:21 -05:00
console.log("Building migration map...");
2025-04-06 22:57:35 -05:00
2025-10-23 21:22:21 -05:00
using uploader = new AssetUploader("migration map");
2025-04-06 22:57:35 -05:00
const map: Record<string, number> = {};
2026-04-01 21:40:15 -05:00
const nations = await vfs
.dir(`Data/XML/item_defs/vehicles`)
.then((files) => files.filter((nation) => nation !== "common"));
2025-04-06 22:57:35 -05:00
2025-10-23 21:22:21 -05:00
for (const nation of nations) {
2025-11-26 13:18:44 -06:00
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
2026-04-01 21:40:15 -05:00
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
2025-10-23 21:22:21 -05:00
);
2025-04-06 22:57:35 -05:00
2025-10-23 21:22:21 -05:00
for (const tankKey in tankList.root) {
const tank = tankList.root[tankKey];
const tankId = toUniqueId(nation, tank.id);
const davaKey = `${nation}:${tankKey}`;
2025-04-06 22:57:35 -05:00
2025-10-23 21:22:21 -05:00
map[davaKey] = tankId;
}
}
2025-04-06 22:57:35 -05:00
2025-10-23 21:22:21 -05:00
await uploader.add({
path: "definitions/migration.json",
content: new TextEncoder().encode(JSON.stringify(map)),
});
await uploader.flush();
2025-04-06 22:57:35 -05:00
}