storebound/tools/ci.ts
CRT 82066de5ed No hand-written SVG: visx charts, lucide icons, Mermaid journey diagram
- desktop: Growth chart, Health and portfolio sparklines and the rollout bar drawn with visx (responsive width,
  crosshair tooltip with real values, arrow keys, theme tokens, no animation); icons from lucide-react behind the
  existing Icon names; empty states are lucide icons on token tiles; store marks are generic lucide icons; stars are
  lucide; the brand mark moves to ui/brand.tsx as the one allowed inline SVG
- fixtures: app icons and store art stand-ins are PNGs rendered by tools/fixture-art.ts (lucide on gradients)
- site: icons are lucide's own files in site/img/icons (tools/site-icons.ts, with the ISC licence) shown as CSS masks;
  the journey diagram is rendered from docs/diagrams/journey.mmd by tools/diagrams.ts (Mermaid CLI), with a tall
  variant for phones
- tests/no-handmade-svg.test.ts fails on new inline SVG drawing in apps/desktop/src and site/*.html
- desktop bundle: 598.7 -> 695.5 kB minified, 174.6 -> 206.0 kB gzip
2026-10-11 00:49:30 +00:00

39 lines
2.4 KiB
TypeScript

#!/usr/bin/env bun
// Everything CI runs, in order; stops at the first failure. bun run ci
// `bun test` covers the CLI and the desktop webview (apps/desktop/tests: model, i18n, theme contrast, webview rules),
// and the no-hand-written-SVG guard (tests/no-handmade-svg.test.ts: visx charts, lucide icons, Mermaid diagrams).
// The desktop Rust host (cargo test, clippy
// with warnings as errors) runs when cargo is installed; set STOREBOUND_CI_RUST=0 to skip it on a machine without Rust.
import { join } from 'node:path';
const root = new URL('..', import.meta.url).pathname;
const tauri = join(root, 'apps/desktop/src-tauri');
const cargo = process.env.STOREBOUND_CI_RUST === '0' ? null : Bun.which('cargo');
const steps: [string, string[], string?][] = [
['adapters', ['bun', 'tools/gen-adapters.ts', '--check']],
// one desktop version: package.json desktopVersion = apps/desktop/package.json = tauri.conf.json = Cargo.toml / .lock
['desktop version', ['bun', 'tools/desktop-version.ts']],
['tests', ['bun', 'test']],
['typecheck', ['bunx', 'tsc', '--noEmit']],
['desktop i18n', ['bun', 'tools/i18n-check.ts']],
['desktop typecheck', ['bunx', 'tsc', '--noEmit', '-p', 'apps/desktop']],
['desktop build', ['bun', 'run', '--cwd', 'apps/desktop', 'build']],
// the release bundle must not carry the dev fixture mode (apps/desktop/tests/webview.test.ts checks dist/ when present)
['desktop bundle check', ['bun', 'test', 'apps/desktop/tests/webview.test.ts']],
...(cargo ? [
// tauri's build script needs the host sidecar binary (gitignored), so a clean checkout builds it first
['desktop sidecar (host)', ['bun', 'tools/build-sidecars.ts', '--host']],
['desktop rust tests', [cargo, 'test', '--quiet'], tauri],
['desktop clippy', [cargo, 'clippy', '--all-targets', '--quiet', '--', '-D', 'warnings'], tauri],
] as [string, string[], string][] : []),
['scrub', ['bun', 'tools/scrub.ts']],
];
if (!cargo) console.log('ci: cargo not found (or STOREBOUND_CI_RUST=0): desktop Rust tests and clippy skipped');
for (const [name, cmd, cwd] of steps) {
const t = Date.now();
console.log(`\n== ${name}: ${cmd.join(' ')}`);
const r = Bun.spawnSync(cmd, { cwd: cwd ?? root, stdout: 'inherit', stderr: 'inherit' });
if (r.exitCode !== 0) { console.error(`\nci: ${name} failed (exit ${r.exitCode})`); process.exit(1); }
console.log(`== ${name} ok (${((Date.now() - t) / 1000).toFixed(1)}s)`);
}
console.log('\nci: all green');