719032b19f
Update Schema / Update configuration json schema (push) Has been cancelled
Memory Benchmark / Memory Test (Full Analysis) (push) Has been cancelled
CI Quality / Lint GitHub Actions (actionlint) (push) Has been cancelled
CI Quality / Lint GitHub Actions (zizmor) (push) Has been cancelled
CI Quality / Check typos (push) Has been cancelled
CI / Test coverage (push) Has been cancelled
CI / Test (22.x, windows-latest) (push) Has been cancelled
CI / Test (24.x, macos-latest) (push) Has been cancelled
CI / Test (24.x, ubuntu-latest) (push) Has been cancelled
CI / Test (24.x, windows-latest) (push) Has been cancelled
CI / Test (26.x, macos-latest) (push) Has been cancelled
CI / Test (26.x, ubuntu-latest) (push) Has been cancelled
CI / Test (26.x, windows-latest) (push) Has been cancelled
CI / Test with Bun (latest, macos-latest) (push) Has been cancelled
CI / Test with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Test with Bun (latest, windows-latest) (push) Has been cancelled
CI / Build and run (22.x, macos-latest) (push) Has been cancelled
CI / Build and run (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (22.x, windows-latest) (push) Has been cancelled
autofix.ci / autofix (push) Has been cancelled
CI Browser Extension / Lint Browser Extension (push) Has been cancelled
CI Browser Extension / Test Browser Extension (push) Has been cancelled
Memory Benchmark / Memory Test (push) Has been cancelled
CI Website / Lint Website Client (push) Has been cancelled
CI Website / Lint Website Server (push) Has been cancelled
CI Website / Test Website Server (push) Has been cancelled
CI Website / Bundle Website Server (push) Has been cancelled
CI / Lint Biome (push) Has been cancelled
CI / Lint oxlint (push) Has been cancelled
CI / Lint TypeScript (push) Has been cancelled
CI / Lint Secretlint (push) Has been cancelled
CI / Test (22.x, macos-latest) (push) Has been cancelled
CI / Test (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, macos-latest) (push) Has been cancelled
CI / Build and run (24.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, windows-latest) (push) Has been cancelled
CI / Build and run (26.x, macos-latest) (push) Has been cancelled
CI / Build and run (26.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (26.x, windows-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, macos-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Docker / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Docker / build (linux/arm/v7, ubuntu-24.04-arm) (push) Has been cancelled
Docker / build (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Docker / merge (push) Has been cancelled
Pack repository with Repomix / pack-repo (push) Has been cancelled
Performance Benchmark History / Benchmark (macos-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (ubuntu-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (windows-latest) (push) Has been cancelled
Performance Benchmark History / Store Results (push) Has been cancelled
Test Repomix Action / Test Node.js 22 (push) Has been cancelled
Test Repomix Action / Test Node.js 24 (push) Has been cancelled
Test Repomix Action / Test Node.js 26 (push) Has been cancelled
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import sharp from 'sharp';
|
|
|
|
const ICON_SIZES: readonly number[] = [16, 19, 32, 38, 48, 64, 128] as const;
|
|
const INPUT_SVG_PATH = path.join(__dirname, '../app/images/icon.svg');
|
|
const OUTPUT_DIR = path.join(__dirname, '../app/images');
|
|
|
|
/**
|
|
* Ensures the output directory exists
|
|
*/
|
|
function ensureOutputDirectory(): void {
|
|
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
console.log(`Created output directory: ${OUTPUT_DIR}`);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Generates a PNG icon of the specified size
|
|
*/
|
|
async function generateIcon(size: number): Promise<void> {
|
|
try {
|
|
const outputPath = path.join(OUTPUT_DIR, `icon-${size}.png`);
|
|
|
|
await sharp(INPUT_SVG_PATH).resize(size, size).png().toFile(outputPath);
|
|
|
|
console.log(`✅ Generated ${size}x${size} icon: ${outputPath}`);
|
|
} catch (error) {
|
|
console.error(`❌ Error generating ${size}x${size} icon:`, error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Validates that the input SVG file exists
|
|
*/
|
|
function validateInputFile(): void {
|
|
if (!fs.existsSync(INPUT_SVG_PATH)) {
|
|
throw new Error(`Input SVG file not found: ${INPUT_SVG_PATH}`);
|
|
}
|
|
console.log(`📁 Input SVG: ${INPUT_SVG_PATH}`);
|
|
}
|
|
|
|
/**
|
|
* Main function to generate all icon sizes
|
|
*/
|
|
async function generateAllIcons(): Promise<void> {
|
|
console.log('🚀 Starting icon generation...');
|
|
|
|
try {
|
|
validateInputFile();
|
|
ensureOutputDirectory();
|
|
|
|
// Generate all icons in parallel
|
|
const iconPromises = ICON_SIZES.map((size) => generateIcon(size));
|
|
await Promise.all(iconPromises);
|
|
|
|
console.log(`🎉 Successfully generated ${ICON_SIZES.length} icons!`);
|
|
console.log(`📂 Output directory: ${OUTPUT_DIR}`);
|
|
} catch (error) {
|
|
console.error('💥 Failed to generate icons:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Execute if this file is run directly
|
|
if (require.main === module) {
|
|
void generateAllIcons();
|
|
}
|
|
|
|
export { generateAllIcons, generateIcon, ICON_SIZES };
|