From d7d3cd1af7ea339ac9cb8bc53245bb36dcca88d5 Mon Sep 17 00:00:00 2001 From: sneak Date: Sat, 9 May 2026 21:30:34 +0200 Subject: [PATCH] Add Makefile with check, build, docker, hooks targets Targets: test (vitest, with conditional verbose rerun pattern), lint (eslint + prettier), fmt / fmt-check (prettier), check (test + lint + fmt-check), build (tsc), dev (tsc --watch), clean, docker, hooks. Uses GNU timeout when available to hard-cap make test at 30 seconds, per repo policy. Falls through without a cap on systems where timeout is absent. --- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..381241f --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +.PHONY: test lint fmt fmt-check check build dev clean docker hooks + +# Use `timeout` (GNU coreutils) when available so `make test` is hard-capped. +# On macOS without coreutils this is empty and the cap is skipped. +TIMEOUT := $(shell command -v timeout 2>/dev/null || command -v gtimeout 2>/dev/null) + +YARN := yarn run + +test: + @$(TIMEOUT) $(if $(TIMEOUT),30s,) $(YARN) vitest run --reporter=dot || \ + { echo "--- Rerunning with verbose for details ---"; \ + $(YARN) vitest run --reporter=verbose; exit 1; } + +lint: + @$(YARN) eslint . + @$(YARN) prettier --check . + +fmt: + @$(YARN) prettier --write . + +fmt-check: + @$(YARN) prettier --check . + +check: test lint fmt-check + +build: + @$(YARN) tsc + +dev: + @$(YARN) tsc --watch + +clean: + @rm -rf dist coverage .vitest-cache *.tsbuildinfo + +docker: + docker build -t quack . + +hooks: + @printf '#!/bin/sh\nset -e\nmake check\n' > .git/hooks/pre-commit + @chmod +x .git/hooks/pre-commit + @echo "Installed pre-commit hook (runs make check)."