Files
Rosea/apps/rosea-tauri/scripts/icons.ts

35 lines
1.7 KiB
TypeScript

/**
* The app's icons, made from the PWA's icon (`apps/rosea/public/icon.svg`) before every build
* (tauri-platforms.md D8). They are build output, never committed: the only images in git are
* the source SVG and optimised art under art/final/ (CLAUDE.md §5.2). The icon is still a
* placeholder; the real one comes through the art pipeline (GAP_ANALYSIS G0.21).
*
* tsx scripts/icons.ts makes them when missing or older than the SVG, and copies the
* Android launcher icons into gen/android when it exists
*
* The copy is unconditional on purpose: `tauri android init` writes Tauri's own logo into
* gen/android, newer than any icon made before it, so a date check kept Tauri's logo in the first
* APK (review finding). `scripts/android.ts check` compares the bytes.
*/
import { cpSync, existsSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { PACKAGE, SRC_TAURI, tauri } from './tauri.js';
const SOURCE = join(PACKAGE, '..', 'rosea', 'public', 'icon.svg');
const MADE = join(SRC_TAURI, 'icons');
export const ANDROID_ICONS = join(MADE, 'android');
export const ANDROID_RES = join(SRC_TAURI, 'gen', 'android', 'app', 'src', 'main', 'res');
const stale = (file: string): boolean => !existsSync(file) || statSync(file).mtimeMs < statSync(SOURCE).mtimeMs;
if (stale(join(MADE, 'icon.ico')) || stale(join(ANDROID_ICONS, 'mipmap-mdpi', 'ic_launcher.png'))) {
tauri('icon', SOURCE);
console.log('icons: made from apps/rosea/public/icon.svg');
} else {
console.log('icons: up to date');
}
if (existsSync(ANDROID_RES)) {
cpSync(ANDROID_ICONS, ANDROID_RES, { recursive: true });
console.log('icons: Android launcher icons copied into gen/android');
}