.PHONY: dev frontend build test integration e2e assets

dev: frontend
	go run ./cmd/clashweb

frontend:
	cd web && npm ci && npm run build

build: frontend
	mkdir -p bin
	CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o bin/clashweb ./cmd/clashweb

test: frontend
	go test -race ./...
	cd web && npm run typecheck && npm run test

assets:
	python3 scripts/fetch-mihomo.py
	python3 scripts/fetch-rules.py

integration: frontend
	CLASHWEB_TEST_MIHOMO_BIN="$(CURDIR)/bin/mihomo" CLASHWEB_TEST_RULES_DIR="$(CURDIR)/data/mihomo/rules" go test -race ./...

e2e: build
	python3 scripts/test-e2e.py
