mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-14 07:06:14 -05:00
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial * CSS lint * Test CI * Add 1v1, 2v2, and 3v3 Tags (#1771) * Initial * CSS lint * Test CI * Rename step --------- Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import head from "./dicts/GearInfoHead.json";
|
||||
import clothes from "./dicts/GearInfoClothes.json";
|
||||
import head from "./dicts/GearInfoHead.json";
|
||||
import shoes from "./dicts/GearInfoShoes.json";
|
||||
|
||||
import fs from "node:fs";
|
||||
import invariant from "~/utils/invariant";
|
||||
import {
|
||||
LANG_JSONS_TO_CREATE,
|
||||
loadLangDicts,
|
||||
translationJsonFolderName,
|
||||
LANG_JSONS_TO_CREATE,
|
||||
loadLangDicts,
|
||||
translationJsonFolderName,
|
||||
} from "./utils";
|
||||
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
@@ -28,114 +27,114 @@ const LEAN_SHOES_CODE = "Shs";
|
||||
// some items have duplicate ID so redundant to have them here many times
|
||||
// but it's just for clarity
|
||||
const AVAILABLE_SR_GEAR = [
|
||||
21010, 21011, 21015, 21013, 21012, 21014, 21012, 21000, 21001, 21002, 21001,
|
||||
21002, 21001, 21016, 21017, 21018, 21019, 21004, 21002, 21005, 21003, 21002,
|
||||
21005, 21008, 21020, 21015, 21007, 21021, 21006, 21009,
|
||||
21010, 21011, 21015, 21013, 21012, 21014, 21012, 21000, 21001, 21002, 21001,
|
||||
21002, 21001, 21016, 21017, 21018, 21019, 21004, 21002, 21005, 21003, 21002,
|
||||
21005, 21008, 21020, 21015, 21007, 21021, 21006, 21009,
|
||||
];
|
||||
|
||||
async function main() {
|
||||
const allGear: Array<{
|
||||
id: number;
|
||||
internalName: string;
|
||||
type: string;
|
||||
translations: Array<{ language: string; name: string }>;
|
||||
}> = [];
|
||||
const langDicts = await loadLangDicts();
|
||||
const allGear: Array<{
|
||||
id: number;
|
||||
internalName: string;
|
||||
type: string;
|
||||
translations: Array<{ language: string; name: string }>;
|
||||
}> = [];
|
||||
const langDicts = await loadLangDicts();
|
||||
|
||||
for (const gear of [...head, ...clothes, ...shoes]) {
|
||||
if (gear.Season > CURRENT_SEASON || gear.HowToGet === "Impossible") {
|
||||
continue;
|
||||
}
|
||||
for (const gear of [...head, ...clothes, ...shoes]) {
|
||||
if (gear.Season > CURRENT_SEASON || gear.HowToGet === "Impossible") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gear.__RowId.includes("COP") && !AVAILABLE_SR_GEAR.includes(gear.Id)) {
|
||||
continue;
|
||||
}
|
||||
if (gear.__RowId.includes("COP") && !AVAILABLE_SR_GEAR.includes(gear.Id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const [type, internalName] = gear.__RowId.split("_");
|
||||
invariant(type);
|
||||
invariant(internalName);
|
||||
const [type, internalName] = gear.__RowId.split("_");
|
||||
invariant(type);
|
||||
invariant(internalName);
|
||||
|
||||
const categoryKey = `CommonMsg/Gear/GearName_${
|
||||
type === LEAN_CLOTHES_CODE
|
||||
? "Clothes"
|
||||
: type === LEAN_SHOES_CODE
|
||||
? "Shoes"
|
||||
: "Head"
|
||||
}`;
|
||||
const categoryKey = `CommonMsg/Gear/GearName_${
|
||||
type === LEAN_CLOTHES_CODE
|
||||
? "Clothes"
|
||||
: type === LEAN_SHOES_CODE
|
||||
? "Shoes"
|
||||
: "Head"
|
||||
}`;
|
||||
|
||||
allGear.push({
|
||||
id: gear.Id,
|
||||
type,
|
||||
internalName,
|
||||
translations: langDicts.map(([langCode, translations]) => {
|
||||
const name = translations[categoryKey]?.[internalName];
|
||||
invariant(name, `Missing translation for ${internalName}`);
|
||||
allGear.push({
|
||||
id: gear.Id,
|
||||
type,
|
||||
internalName,
|
||||
translations: langDicts.map(([langCode, translations]) => {
|
||||
const name = translations[categoryKey]?.[internalName];
|
||||
invariant(name, `Missing translation for ${internalName}`);
|
||||
|
||||
return {
|
||||
language: langCode,
|
||||
name,
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
return {
|
||||
language: langCode,
|
||||
name,
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
allGear.sort((a, b) => a.id - b.id);
|
||||
allGear.sort((a, b) => a.id - b.id);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "gear.json"),
|
||||
JSON.stringify(allGear, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "gear.json"),
|
||||
JSON.stringify(allGear, null, 2),
|
||||
);
|
||||
|
||||
const headGear = allGear.filter((g) => g.type === LEAN_HEAD_CODE);
|
||||
const clothesGear = allGear.filter((g) => g.type === LEAN_CLOTHES_CODE);
|
||||
const shoesGear = allGear.filter((g) => g.type === LEAN_SHOES_CODE);
|
||||
invariant(headGear.length);
|
||||
invariant(clothesGear.length);
|
||||
invariant(shoesGear.length);
|
||||
const headGear = allGear.filter((g) => g.type === LEAN_HEAD_CODE);
|
||||
const clothesGear = allGear.filter((g) => g.type === LEAN_CLOTHES_CODE);
|
||||
const shoesGear = allGear.filter((g) => g.type === LEAN_SHOES_CODE);
|
||||
invariant(headGear.length);
|
||||
invariant(clothesGear.length);
|
||||
invariant(shoesGear.length);
|
||||
|
||||
const headIds = headGear.map((w) => w.id);
|
||||
const clothesIds = clothesGear.map((w) => w.id);
|
||||
const shoesIds = shoesGear.map((w) => w.id);
|
||||
const headIds = headGear.map((w) => w.id);
|
||||
const clothesIds = clothesGear.map((w) => w.id);
|
||||
const shoesIds = shoesGear.map((w) => w.id);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "head-ids.json"),
|
||||
JSON.stringify(headIds, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "clothes-ids.json"),
|
||||
JSON.stringify(clothesIds, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "shoes-ids.json"),
|
||||
JSON.stringify(shoesIds, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "head-ids.json"),
|
||||
JSON.stringify(headIds, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "clothes-ids.json"),
|
||||
JSON.stringify(clothesIds, null, 2),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_DIR_PATH, "shoes-ids.json"),
|
||||
JSON.stringify(shoesIds, null, 2),
|
||||
);
|
||||
|
||||
for (const langCode of LANG_JSONS_TO_CREATE) {
|
||||
const translationsMap = Object.fromEntries(
|
||||
allGear.map((gear) => {
|
||||
const translation = gear.translations.find(
|
||||
(t) => t.language === langCode,
|
||||
)?.name;
|
||||
invariant(
|
||||
translation,
|
||||
`No translation for ${gear.internalName} in ${langCode}`,
|
||||
);
|
||||
for (const langCode of LANG_JSONS_TO_CREATE) {
|
||||
const translationsMap = Object.fromEntries(
|
||||
allGear.map((gear) => {
|
||||
const translation = gear.translations.find(
|
||||
(t) => t.language === langCode,
|
||||
)?.name;
|
||||
invariant(
|
||||
translation,
|
||||
`No translation for ${gear.internalName} in ${langCode}`,
|
||||
);
|
||||
|
||||
return [`${gear.type.charAt(0).toUpperCase()}_${gear.id}`, translation];
|
||||
}),
|
||||
);
|
||||
return [`${gear.type.charAt(0).toUpperCase()}_${gear.id}`, translation];
|
||||
}),
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"locales",
|
||||
translationJsonFolderName(langCode),
|
||||
`gear.json`,
|
||||
),
|
||||
JSON.stringify(translationsMap, null, 2) + "\n",
|
||||
);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"locales",
|
||||
translationJsonFolderName(langCode),
|
||||
"gear.json",
|
||||
),
|
||||
`${JSON.stringify(translationsMap, null, 2)}\n`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main();
|
||||
|
||||
Reference in New Issue
Block a user