-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (65 loc) · 2.53 KB
/
Makefile
File metadata and controls
84 lines (65 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
.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 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 " 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
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