# Makefile for Akiyama Manga

.PHONY: help build run test clean dev install-deps

help:
	@echo "Available commands:"
	@echo "  make install-deps      - Install Go dependencies"
	@echo "  make build            - Build the application"
	@echo "  make run              - Run the application"
	@echo "  make dev              - Run in development mode with hot reload"
	@echo "  make test             - Run tests"
	@echo "  make clean            - Clean build artifacts"
	@echo "  make lint             - Run linter"
	@echo "  make docker-build     - Build Docker image"
	@echo "  make docker-run       - Run Docker container"

install-deps:
	go mod download
	go mod verify

build:
	mkdir -p build
	go build -v -o build/akiyama-manga cmd/server/main.go

run: build
	./build/akiyama-manga

dev:
	@command -v air > /dev/null || go install github.com/cosmtrek/air@latest
	air

test:
	go test -v ./...

test-coverage:
	go test -v -coverprofile=coverage.out ./...
	go tool cover -html=coverage.out

clean:
	rm -rf build/
	go clean

lint:
	@command -v golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
	golangci-lint run ./...

fmt:
	go fmt ./...
	goimports -w .

docker-build:
	docker build -t akiyama-manga:latest .

docker-run:
	docker run -p 8080:8080 --env-file .env akiyama-manga:latest

db-migrate:
	go run cmd/server/main.go

prod-build:
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o build/akiyama-manga-linux cmd/server/main.go

prod-run:
	GIN_MODE=release ./build/akiyama-manga-linux

deps-graph:
	go mod graph | grep -E '^github.com/yourusername/akiyama-manga' | head -20

update-deps:
	go get -u ./...
	go mod tidy
