1
0

refactor: Some minor refinements
Remote Deploy / deploy (push) Successful in 1m28s

This commit is contained in:
2026-06-05 18:24:54 +02:00
parent e94c43ca6e
commit 8fe2bd3bf2
7 changed files with 46 additions and 296 deletions
+40 -7
View File
@@ -14,17 +14,50 @@
import ExcelJS from "exceljs"
//import parseV1V2 from "./parse/v1_v2.js";
import parseV3 from "./parse/v3.js";
import generateArchivedV1_V2 from "./parse/archived/v1_v2.js";
import parseV3 from "./parse/v3.js";
import fs from "fs/promises";
import { fileURLToPath } from "url";
export default async function parseThisShit(downloadedFilePath: string) {
type Save = {
filePath: string | string[],
parser: (workbook: ExcelJS.Workbook, downloadedFilePath: string) => Promise<any>
}
async function doAll(saves: Save[], workbook: ExcelJS.Workbook, downloadedFilePath: string) {
const promises = saves.map(save => {
return (async function() {
const res = await save.parser(workbook, downloadedFilePath);
if (typeof save.filePath === "string") {
save.filePath = [save.filePath];
}
await Promise.all(
save.filePath.map(filePath => fs.writeFile(filePath, JSON.stringify(res)))
);
})()
})
await Promise.all(promises);
}
export default async function parseAll(downloadedFilePath: string) {
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(downloadedFilePath);
//await parseV1V2(workbook);
await generateArchivedV1_V2();
await parseV3(workbook, downloadedFilePath);
await doAll([
{
filePath: ["volume/db/v1.json", "volume/db/v2.json"],
parser: generateArchivedV1_V2,
},
{
filePath: "volume/db/v3.json",
parser: parseV3
},
], workbook, downloadedFilePath);
}
//parseThisShit("volume/db/current.xlsx")
if (process.argv[1] === fileURLToPath(import.meta.url)) {
await parseAll("volume/db/current.xlsx");
}