.PHONY: build check serve serve-brands check-brands

build:
	python3 scripts/build-site.py
	python3 scripts/export-source.py

check: build
	python3 scripts/validate-site.py
	node --test tests/engine.test.cjs
	node --test tests/visitor-counter.test.mjs
	node --check api/visitors.mjs
	@for file in dist/*.js; do node --check "$$file" || exit 1; done
	@for file in dist/brands/*/*.js; do node --check "$$file" || exit 1; done
	@if [ -d brands ]; then $(MAKE) check-brands; fi

serve: build
	python3 -m http.server 8080 --bind 127.0.0.1 --directory dist

serve-brands:
	python3 -m http.server 8081 --bind 127.0.0.1 --directory brands

check-brands:
	@for site in brands/*/vercel.json; do node brands/build.mjs "$$(basename "$$(dirname "$$site")")"; done
	python3 scripts/validate-brands.py
	node --check brands/build.mjs
	@for file in brands/*/*.js; do node --check "$$file" || exit 1; done
