.PHONY: dev dev-backend dev-frontend build build-backend build-frontend test test-backend test-frontend

FRONTEND_DIR = internal/dashboard/frontend

# Default target
dev:
	@$(MAKE) -j 2 dev-backend dev-frontend

# Development commands
dev-backend:
	go run . -config config.dev.json

dev-frontend:
	pnpm --prefix $(FRONTEND_DIR) dev

# Build commands
build: build-frontend build-backend

build-backend:
	go build -o honeypot .

build-frontend:
	pnpm --prefix $(FRONTEND_DIR) build
	sed -i 's|https://cdn.plot.ly/un/|/|g' $(FRONTEND_DIR)/dist/assets/chart-*.js

# Test commands
test: test-backend test-frontend

test-backend: gotest gosec govulncheck golint godeadcode

test-frontend: pnpm-test knip

pnpm-test:
	pnpm --prefix $(FRONTEND_DIR) test

knip:
	cd $(FRONTEND_DIR) && pnpm knip

gotest:
	go test ./...

gosec:
	gosec -quiet -exclude G104,G201,G115,G304 ./...

govulncheck:
	govulncheck ./...

golint:
	golangci-lint run -D errcheck ./...

godeadcode:
	deadcode ./...

release:
	bash scripts/tag-release.sh $(version)

update-db:
	scp -P 31096 -r honeypot@172.16.0.50:/mnt/ssd/honeypot.db data/honeypot.db
	scp -P 31096 -r honeypot@172.16.0.50:/mnt/ssd/honeypot.db.wal data/honeypot.db.wal