Files
blitzkit/scripts/buildAssets/circleFlags.ts
T

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-01-07 20:07:45 -06:00
import { readdir } from 'fs/promises';
2024-06-19 20:53:59 -05:00
import sharp from 'sharp';
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
2024-04-23 09:57:59 -05:00
import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
2024-02-20 11:21:01 -06:00
import { DATA, POI } from './constants';
2024-01-07 20:07:45 -06:00
2024-01-25 13:10:20 -06:00
export async function circleFlags(production: boolean) {
2024-01-16 16:58:00 -06:00
const flags = await readdir(`${DATA}/${POI.flags}`);
2024-01-20 21:35:36 -06:00
const changes = await Promise.all(
flags
.filter(
(flag) =>
flag.startsWith('flag_profile-stat_') &&
!flag.endsWith('@2x.packed.webp.dvpl'),
)
.map(async (flag) => {
2024-06-19 20:53:59 -05:00
const image = sharp(await readDVPLFile(`${DATA}/${POI.flags}/${flag}`));
const content = (
await image.trim({ threshold: 100 }).toBuffer()
).toString('base64');
2024-01-20 21:35:36 -06:00
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
2024-01-07 20:07:45 -06:00
2024-01-20 21:35:36 -06:00
return {
content,
encoding: 'base64',
path: `flags/circle/${name}.webp`,
} satisfies FileChange;
}),
2024-01-07 20:07:45 -06:00
);
2024-01-20 21:35:36 -06:00
2024-01-21 00:01:32 -06:00
await commitAssets('circle flags', changes, production);
2024-01-07 20:07:45 -06:00
}