Three issues caught by the code review of scripts/gen-icons.mjs: (1) Missing source SVG validation. Spec requires the script "refuses to run if any source SVG is missing." Added an existsSync guard at the top of main() that throws a targeted message rather than letting sharp fail with a raw ENOENT. (2) Summary table missing byte sizes. Spec says the summary prints "each output, its size in pixels, its file size in bytes." trace() now captures statSync().size; the printout has a size column with human-readable formatting and a total at the end. (3) writeMaskablePng's intermediate buffer used .png() without the compressionLevel/palette options that every other render uses. Zero functional impact (the buffer is only piped into composite, never written to disk) but inconsistent and misleading. Aligned with the rest of the script. README: replaced 'git add -A' with explicit directory paths matching the project's convention — the generator writes to a fixed set of three directories and shouldn't accidentally stage unrelated working-tree changes during a regen. Plan updated to match the corrected code so Task 3's source-of-truth stays consistent.
47 lines
2.0 KiB
Markdown
47 lines
2.0 KiB
Markdown
# Icon Generator
|
|
|
|
Regenerates every brand artefact from `assets/brand/*.svg`:
|
|
|
|
- macOS `.icns`, Windows `.ico`, Linux per-size PNGs (`packages/desktop/build/`)
|
|
- Tray icons for all three platforms (`packages/desktop/resources/`)
|
|
- Web favicons, PWA manifest icons, maskable, in-app `logo.png` (`packages/web/public/icons/`)
|
|
|
|
## When to run
|
|
|
|
After changing any file under `assets/brand/`, **or** after bumping `sharp`,
|
|
`png-to-ico`, or `png2icons` in the root `package.json`. Commit the diff in
|
|
the same PR.
|
|
|
|
```bash
|
|
pnpm gen-icons
|
|
git status # review which files changed
|
|
git add packages/desktop/build/ packages/desktop/resources/ packages/web/public/icons/
|
|
git commit -m "chore: regenerate brand icons"
|
|
```
|
|
|
|
(Stage explicit paths rather than `git add -A` — the generator only writes to those three directories, and an unrelated working-tree change shouldn't accidentally land in a "regenerate icons" commit.)
|
|
|
|
## Determinism
|
|
|
|
Output is byte-stable for a given lockfile. The same SVGs in produce the
|
|
same PNG/ICO/ICNS bytes out, every time, on every OS — Sharp uses resvg
|
|
internally and writes deterministic PNGs, png-to-ico and png2icons don't
|
|
embed timestamps.
|
|
|
|
**Caveat:** byte-stability is *not* guaranteed across version bumps of
|
|
the three encoder deps. After a Renovate / dependabot PR upgrades any of
|
|
them, run `pnpm gen-icons` once and commit the resulting diff inside the
|
|
same PR. That follow-up commit isn't an artwork change — it's encoder
|
|
output drift, and gating it inside the dep PR keeps the artwork-change
|
|
git history clean.
|
|
|
|
## Source SVGs
|
|
|
|
| Brand source | Drives |
|
|
|---------------------------------|-----------------------------------------------|
|
|
| `assets/brand/app-icon.svg` | Every full app icon, all favicons, PWA |
|
|
| `assets/brand/mark.svg` | Win/Linux tray, in-app logo, PWA maskable |
|
|
| `assets/brand/mark-mono-dark.svg` | macOS menu-bar template (alpha + black) |
|
|
|
|
`Artworks-Backspace/` is the design archive — never read by this script.
|