2024-01-07 20:07:45 -06:00
|
|
|
import { readdir } from 'fs/promises';
|
2024-04-08 09:23:26 -05:00
|
|
|
import sharp from 'sharp';
|
|
|
|
|
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
|
2024-01-20 21:35:36 -06:00
|
|
|
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
|
|
|
|
import { FileChange } from '../../src/core/blitzkrieg/commitMultipleFiles';
|
2024-02-20 11:21:01 -06:00
|
|
|
import { DATA, POI } from './constants';
|
2024-01-07 20:07:45 -06:00
|
|
|
|
2024-01-29 17:14:51 -06:00
|
|
|
export async function moduleIcons(production: boolean) {
|
2024-01-07 20:07:45 -06:00
|
|
|
console.log('Building module icons...');
|
|
|
|
|
|
|
|
|
|
const changes = await Promise.all(
|
2024-01-16 16:58:00 -06:00
|
|
|
(await readdir(`${DATA}/${POI.moduleIcons}`))
|
2024-01-07 20:07:45 -06:00
|
|
|
.filter(
|
|
|
|
|
(file) =>
|
|
|
|
|
!file.endsWith('@2x.packed.webp.dvpl') && file.startsWith('vehicle'),
|
|
|
|
|
)
|
|
|
|
|
.map(async (file) => {
|
|
|
|
|
const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1];
|
|
|
|
|
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
2024-04-08 09:23:26 -05:00
|
|
|
const content = (
|
|
|
|
|
await sharp(await readDVPLFile(`${DATA}/${POI.moduleIcons}/${file}`))
|
|
|
|
|
.trim()
|
|
|
|
|
.toBuffer()
|
|
|
|
|
).toString('base64');
|
2024-01-07 20:07:45 -06:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
content,
|
|
|
|
|
path: `icons/modules/${name}.webp`,
|
|
|
|
|
encoding: 'base64',
|
|
|
|
|
} satisfies FileChange;
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
2024-01-21 00:01:32 -06:00
|
|
|
await commitAssets('module icons', changes, production);
|
2024-01-07 20:07:45 -06:00
|
|
|
}
|