feat: flags path

This commit is contained in:
TrèsAbhi committed 2023-12-03 09:56:08 -06:00
1 parent 17935fbe89
commit d1fb5da002
1 file changed
+48 -43
+48 -43
View File
@@ -8,7 +8,6 @@ import { ElementCompact, xml2js } from 'xml-js';
import { parse } from 'yaml'; import { parse } from 'yaml';
import { NATION_IDS } from '../src/constants/nations'; import { NATION_IDS } from '../src/constants/nations';
import { BlitzkriegTankopedia, Tier } from '../src/core/blitzkrieg/tankopedia'; import { BlitzkriegTankopedia, Tier } from '../src/core/blitzkrieg/tankopedia';
import commitMultipleFiles, { FileChange } from './commitMultipleFiles';
const LANGUAGE = 'en'; const LANGUAGE = 'en';
const TEMP = 'temp/blitz'; const TEMP = 'temp/blitz';
@@ -27,6 +26,7 @@ const directoriesOfInterest = {
tankParameters: 'assets/Data/3d/Tanks/Parameters', tankParameters: 'assets/Data/3d/Tanks/Parameters',
smallIcons: 'assets/Data/Gfx/UI/BattleScreenHUD/SmallTankIcons', smallIcons: 'assets/Data/Gfx/UI/BattleScreenHUD/SmallTankIcons',
bigIcons: 'assets/Data/Gfx/UI/BigTankIcons', bigIcons: 'assets/Data/Gfx/UI/BigTankIcons',
flags: 'assets/Data/Gfx/Lobby/flags',
}; };
const directoriesOfInterestArray = Object.values(directoriesOfInterest); const directoriesOfInterestArray = Object.values(directoriesOfInterest);
@@ -129,50 +129,55 @@ Promise.all(
).then(async () => { ).then(async () => {
if (publish) { if (publish) {
const octokit = new Octokit({ auth: env.GH_TOKEN }); const octokit = new Octokit({ auth: env.GH_TOKEN });
const tankopediaChange: FileChange = { // const tankopediaChange: FileChange = {
content: JSON.stringify(tankopedia), // content: JSON.stringify(tankopedia),
path: 'tankopedia.json', // path: 'tankopedia.json',
encoding: 'utf-8', // encoding: 'utf-8',
}; // };
const iconsChange = ( // const iconsChange = (
await Promise.all( // await Promise.all(
tankIds.map(async (id) => { // tankIds.map(async (id) => {
try { // try {
const [contentSmall, contentBig] = await Promise.all([ // const [contentSmall, contentBig] = await Promise.all([
readFile(images[id].small, { encoding: 'base64' }), // readFile(images[id].small, { encoding: 'base64' }),
readFile(images[id].big, { encoding: 'base64' }), // readFile(images[id].big, { encoding: 'base64' }),
]); // ]);
return [ // return [
{ // {
content: contentBig, // content: contentBig,
path: `icons/big/${id}.webp`, // path: `icons/big/${id}.webp`,
encoding: 'base64', // encoding: 'base64',
}, // },
{ // {
content: contentSmall, // content: contentSmall,
path: `icons/small/${id}.webp`, // path: `icons/small/${id}.webp`,
encoding: 'base64', // encoding: 'base64',
}, // },
]; // ];
} catch (error) { // } catch (error) {
console.log(error); // console.log(error);
return undefined; // return undefined;
} // }
}), // }),
) // )
).flat() as FileChange[]; // ).flat() as FileChange[];
const flagChanges = await readdir(
`${TEMP}/${directoriesOfInterest.flags}`,
).then((flags) => flags.filter((flag) => flag.startsWith('flag_text')));
console.log('Writing files...'); console.log(flagChanges);
await commitMultipleFiles(
octokit, // console.log('Writing files...');
'tresabhi', // await commitMultipleFiles(
'blitzkrieg-assets', // octokit,
'main', // 'tresabhi',
new Date().toString(), // 'blitzkrieg-assets',
[tankopediaChange, ...iconsChange], // 'main',
true, // new Date().toString(),
); // [tankopediaChange, ...iconsChange],
// true,
// );
} else { } else {
writeFile( writeFile(
'dist/tankopedia/tankopedia.json', 'dist/tankopedia/tankopedia.json',