#!/usr/bin/env bun // The home page's "Desktop app" screenshots (site/img/desktop/*.webp) from the same headless fixture-mode capture as // the teaser (desktop.ts: Vite dev server of apps/desktop with VITE_FIXTURES=1, dev markers hidden), scaled to 1280 px // and encoded with cwebp (quality 75). Run after a desktop UI change: bun media/teaser/site-shots.ts import { existsSync, mkdirSync, statSync } from 'node:fs'; import { join } from 'node:path'; import { captureDesktop } from './desktop'; const ROOT = join(import.meta.dir, '../..'); const SRC = join(import.meta.dir, 'out/desktop'); const OUT = join(ROOT, 'site/img/desktop'); const NAMES = ['portfolio', 'releases', 'checks']; if (process.argv.includes('--fresh') || !NAMES.every(n => existsSync(join(SRC, `${n}.jpg`)))) await captureDesktop(); mkdirSync(OUT, { recursive: true }); for (const n of NAMES) { const out = join(OUT, `${n}.webp`); const p = Bun.spawnSync(['cwebp', '-quiet', '-q', '75', '-m', '6', '-resize', '1280', '0', join(SRC, `${n}.jpg`), '-o', out]); if (p.exitCode !== 0) throw new Error(`cwebp ${n}: ${p.stderr.toString()}`); const kb = statSync(out).size / 1024; if (kb > 150) throw new Error(`${n}.webp is ${kb.toFixed(0)} KB (limit 150)`); console.log(`${n}.webp ${kb.toFixed(0)} KB`); }