Makefile
Rama main · réplica de lectura del repositorio original.
.PHONY: help dev dev-up dev-down backend-run backend-build backend-test backend-test-coverage migrate-up migrate-down migrate-create frontend-dev frontend-build frontend-test frontend-e2e build clean test
help:
@echo "Available commands:"
@echo " build - Build complete application (frontend + backend)"
@echo " clean - Remove build artifacts"
@echo " dev - Start all development services"
@echo " dev-up - Start Docker Compose services"
@echo " dev-down - Stop Docker Compose services"
@echo " backend-run - Run backend server"
@echo " backend-build - Build backend binary"
@echo " backend-test - Run backend tests"
@echo " migrate-up - Run database migrations"
@echo " migrate-down - Rollback last migration"
@echo " migrate-create - Create new migration (NAME=xxx)"
@echo " frontend-dev - Run frontend dev server"
@echo " frontend-build - Build frontend for production"
@echo " frontend-test - Run frontend tests"
@echo " frontend-e2e - Run browser integration tests against a running app"
@echo " test - Run all tests (backend + frontend)"
@echo " backend-test-coverage - Run backend tests with coverage"
# Combined build (frontend embedded in backend)
build: frontend-build backend-build
@echo "Build complete: backend/bin/attic"
clean:
rm -rf backend/bin
rm -rf backend/cmd/server/dist/*
rm -rf backend/cmd/server/.output
touch backend/cmd/server/dist/.gitkeep
rm -rf frontend/.nuxt frontend/.output
# Development
dev: dev-up backend-run
dev-up:
docker compose up -d -f docker-compose.dev.yml
dev-down:
docker compose down
# Backend
backend-run:
cd backend && go build -o bin/attic ./cmd/server && ./bin/attic
LDFLAGS := -w -s
ifdef ATTIC_TMDB_API_KEY
LDFLAGS += -X github.com/lmmendes/attic/internal/plugin/tmdb.APIKey=$(ATTIC_TMDB_API_KEY)
endif
backend-build:
cd backend && go build -ldflags="$(LDFLAGS)" -o bin/attic ./cmd/server
backend-test:
cd backend && go test -v ./...
backend-test-coverage:
cd backend && go test -v -coverprofile=coverage.out ./...
cd backend && go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: backend/coverage.html"
test: backend-test frontend-test
# Migrations
DATABASE_URL ?= postgres://attic:attic@localhost:5432/attic?sslmode=disable
migrate-up:
migrate -path backend/migrations -database "$(DATABASE_URL)" up
migrate-down:
migrate -path backend/migrations -database "$(DATABASE_URL)" down 1
migrate-create:
migrate create -ext sql -dir backend/migrations -seq $(NAME)
# Frontend
frontend-dev:
cd frontend && bun run dev
frontend-build:
cd frontend && bun run build
frontend-test:
cd frontend && bun run test
frontend-e2e:
cd frontend && bun run test:e2e