-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (147 loc) · 4.51 KB
/
Makefile
File metadata and controls
189 lines (147 loc) · 4.51 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Notes Taking App - Makefile
# ============================
# Common commands for development
.PHONY: help build up down restart logs shell-backend shell-frontend migrate makemigrations createsuperuser test test-backend test-frontend test-cov lint clean
# Default target
help:
@echo "Notes Taking App - Available Commands"
@echo "======================================"
@echo ""
@echo "Docker Commands:"
@echo " make build - Build all Docker containers"
@echo " make up - Start all services"
@echo " make down - Stop all services"
@echo " make restart - Restart all services"
@echo " make logs - View logs from all services"
@echo " make logs-backend - View backend logs"
@echo " make logs-frontend - View frontend logs"
@echo ""
@echo "Backend Commands:"
@echo " make shell-backend - Open Django shell"
@echo " make migrate - Run database migrations"
@echo " make makemigrations - Create new migrations"
@echo " make createsuperuser - Create admin user"
@echo ""
@echo "Frontend Commands:"
@echo " make shell-frontend - Open shell in frontend container"
@echo ""
@echo "Testing Commands (run locally):"
@echo " make test - Run all tests (backend + frontend)"
@echo " make test-cov - Run all tests with coverage"
@echo " make test-backend - Run backend tests with pytest"
@echo " make test-backend-cov - Run backend tests with coverage"
@echo " make test-frontend - Run frontend tests with Jest"
@echo " make test-frontend-cov - Run frontend tests with coverage"
@echo ""
@echo "Utility Commands:"
@echo " make lint - Run linters"
@echo " make lint-fix - Run linters with auto-fix"
@echo " make clean - Remove all containers and volumes"
@echo " make reset-db - Reset database (DESTRUCTIVE)"
# =============
# Docker Commands
# =============
build:
docker compose build
up:
docker compose up -d
up-logs:
docker compose up
down:
docker compose down
restart:
docker compose restart
logs:
docker compose logs -f
logs-backend:
docker compose logs -f backend
logs-frontend:
docker compose logs -f frontend
logs-db:
docker compose logs -f postgres
# =============
# Backend Commands
# =============
shell-backend:
docker compose exec backend python manage.py shell
bash-backend:
docker compose exec backend bash
migrate:
docker compose exec backend python manage.py migrate
makemigrations:
docker compose exec backend python manage.py makemigrations
createsuperuser:
docker compose exec backend python manage.py createsuperuser
test-backend:
cd backend && poetry run pytest
test-backend-cov:
cd backend && poetry run pytest --cov --cov-report=term-missing --cov-report=html
collectstatic:
docker compose exec backend python manage.py collectstatic --noinput
# =============
# Frontend Commands
# =============
shell-frontend:
docker compose exec frontend sh
bash-frontend:
docker compose exec frontend sh
test-frontend:
cd frontend && npm test
test-frontend-cov:
cd frontend && npm run test:coverage
test-frontend-watch:
cd frontend && npm run test:watch
lint-frontend:
docker compose exec frontend npm run lint
# =============
# Combined Testing
# =============
test: test-backend test-frontend
test-cov: test-backend-cov test-frontend-cov
# =============
# Utility Commands
# =============
lint:
docker compose exec backend ruff check . || true
docker compose exec frontend npm run lint || true
lint-fix:
docker compose exec backend ruff check --fix . || true
docker compose exec frontend npm run lint -- --fix || true
clean:
docker compose down -v --rmi local
reset-db:
docker compose down -v
docker compose up -d postgres
sleep 5
docker compose up -d
# =============
# Development Setup
# =============
setup:
@echo "Setting up development environment..."
cp backend/.env.example backend/.env 2>/dev/null || true
cp frontend/.env.example frontend/.env.local 2>/dev/null || true
make build
make up
sleep 10
make migrate
@echo ""
@echo "Setup complete! Services are running:"
@echo " - Frontend: http://localhost:3000"
@echo " - Backend API: http://localhost:8000/api/v1"
@echo " - API Docs: http://localhost:8000/api/docs"
@echo " - Mailcatcher: http://localhost:1080"
@echo ""
@echo "Run 'make createsuperuser' to create an admin user."
# =============
# Quick Commands
# =============
# Quick restart backend
rb:
docker compose restart backend
# Quick restart frontend
rf:
docker compose restart frontend
# View all running containers
ps:
docker compose ps