Skip to content

Build Test and Tooling

matthew edited this page Aug 29, 2026 · 1 revision

Build, test and tooling

Commands, the green gate, toolchain gotchas, the relocation recipe, and the pre-PR checklist. How a change reaches main is on Contributing.

8. Build, test & tooling

Commands

Task Command
Dev server (renderer) ng serve
Renderer production build ng build
Electron main + preload npm run build:electron (tsc --noEmit typecheck → esbuild main + preload)
Tests CI=true ng test --watch=false
Coverage (thresholds) npm run test:coverage — enforces the minima in angular.json coverageThresholds
E2E (Playwright) npm run e2e — drives the built Electron app; build first (ng build + npm run build:electron)
Lint / format npm run lint (eslint .) · npm run format (Prettier)

The green gate (run before every commit)

ng build + npm run lint + npm run format:check + npm run build:electron + CI=true ng test --watch=false. Everything is green from a clean checkout — there is no tolerated baseline of failures or prettier warnings. GitHub Actions (.github/workflows/ci.yml) enforces the same gate on every PR and on main. Green after every commit: if a step can't stay green, it's too big — split it.

Toolchain facts & gotchas

  • node-pty is rebuilt for the Electron ABI on every install — the postinstall hook runs electron-rebuild --only node-pty (scoped deliberately: rebuilding everything caused problems). electron-builder rebuilds again at package time, and the CI pack job verifies the asar-unpack.
  • No baseUrl (TS5090) — alias targets in tsconfig.json paths must be relative (src/...).
  • tsc does not rewrite path aliases in emit. The electron main is esbuild-bundled (like preload): --packages=external --tsconfig=tsconfig.json, so @shared/@features resolve at runtime; tsc --noEmit is typecheck-only. The build output stays at dist-electron/electron/ (the esbuild outfile) so __dirname-relative paths in main.ts are stable. Renderer bootstrap (src/shared/app, src/shared/angular) is excluded from the electron tsconfig — it is Angular/renderer code the node build must skip.
  • styleUrl can't use aliases (Angular). When a component with a shared styleUrl moves, inline the rule into its own .scss (the shared ribbon-row :host block is inlined per migrated ribbon for this reason).
  • Barrels re-exporting types need export type { … } (isolatedModules / TS1205).

The relocation recipe (behaviour-preserving moves)

Moving a directory/service to @shared or a feature is relocation, not a rewrite — do not refactor logic or rename for taste while moving. In order:

  1. git mv <src-dir> <dest-dir> — move the whole directory so internal ./sibling imports survive.
  2. Fix the moved files' own up-paths (a relocated from '../../../shared/X' silently retargets wrong): sed -E -i '' "s#from '(\.\./)+shared/#from '@shared/#g" across the moved files.
  3. Repoint importers with a sibling-safe pattern that catches both ../X/X and services/X/X: grep -rlE "from '[^']*/<dir>/<base>'" src. It does not catch same-dir ./X — repoint those explicitly when splitting a directory. Also grep inbound edges (the selector app-<x>-view and the class import), not just the moved unit's own imports.
  4. prettier --write the touched files; run the green gate.

Standing a feature up adds: gate-check its dependency cone → promote any foreign kitchen deps to @shared first → sever cross-feature embeds → relocate to src/features/<f>/angular → write <f>.feature.ts → add one line to config.ts → delete its @case (if any) from the shell. Splittable into relocate-then-flip commits.

If you drive the Bash tool (it runs zsh)

  • path is a reserved zsh var tied to $PATH — for path in … clobbers $PATH and every external command then fails "command not found". Never loop with path/fpath/cdpath/manpath; use p/f/svc.
  • zsh does not word-split unquoted $var — for f in $(grep -rl …) runs once with the whole blob. Iterate via grep … | while IFS= read -r f; do …; done.
  • macOS BSD sed has no \b (silently no-ops) — use plain s/Old/New/g for symbol renames.

Pre-PR checklist

  • Every class member has an explicit public/protected/private modifier.
  • Every type annotated — members, parameters, return types, and locals. No any.
  • OOP by default; FP only where it reads better. Names intention-revealing.
  • Functions small, one thing, ≤2 params (or an options object). No floating promises; failures throw typed errors, never silent null/undefined.
  • Every member — including private — has genuine TSDoc with the correct opening phrase.
  • Comments explain why; no commented-out code; no untracked TODOs.
  • No file crosses ~500 LOC / ~5 responsibilities without decomposition into modules/collaborators.
  • No dead code shipped: no stub/seed data on production paths, no editable setting without a reader, no unreferenced exports.
  • Angular: standalone, signals/computed, OnPush, inject(), protected template members, built-in control flow. Electron: contextIsolation/sandbox on, nodeIntegration off, narrow contextBridge, IPC validated.
  • New/changed features respect the invariants: shared names no feature; a feature imports only @shared/@features; registry descriptor + one config.ts line.
  • Tests follow AAA + FIRST, named method_condition_expectation, behaviour via public API.
  • The green gate passes (no new failures, no new prettier warnings).

Clone this wiki locally