-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (107 loc) · 3.75 KB
/
Makefile
File metadata and controls
126 lines (107 loc) · 3.75 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
# Makefile for Django project with Tailwind CSS integration
# Usage example from root, type:
# make help - To show this help message
.PHONY: help setup dev server tailwind install migrate makemigrations createsuperuser shell test clean collectstatic build check-venv
help:
@echo "Available commands:"
@echo " make dev - Run Django server and Tailwind watch in parallel"
@echo " make server - Run Django development server"
@echo " make tailwind - Run Tailwind watch mode"
@echo " make install - Install Python and npm dependencies"
@echo " make migrate - Run database migrations"
@echo " make makemigrations - Create new migrations"
@echo " make createsuperuser - Create Django superuser"
@echo " make shell - Open Django shell"
@echo " make test - Run tests"
@echo " make collectstatic - Collect static files"
@echo " make build - Build Tailwind CSS for production"
@echo " make clean - Remove generated files"
# What 'make setup' does:
@echo " make setup - Complete project setup (venv, deps, migrations)"
# FIRST TIME SETUP ONLY!!
# Checks venv is activated (exits if not)
# Upgrades pip to latest version
# Installs requirements.txt dependencies
# Runs pip check for broken dependencies
# Installs safety and checks for known vulnerabilities
# Installs npm dependencies for Tailwind
# Runs migrations
# Collects static files
# FIRST TIME SETUP ONLY!!
# To use:
# 1. Create virtual environment (if not already created):
python3 -m venv .venv
# 2. Activate virtual environment:
source .venv/bin/activate
make setup
# Daily development
# make dev
# List of commands below
setup: check-venv check-env
@echo "🔧 Setting up project..."
@echo "📦 Installing Python dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
@echo "🔒 Checking for security vulnerabilities..."
pip check
pip install safety
safety check --json || echo "⚠️ Security issues found - review above"
@echo "📦 Installing npm dependencies..."
cd theme/static_src && npm install
@echo "🎨 Building Tailwind CSS for production..."
cd theme/static_src && npm run build
@echo "🗄️ Running migrations..."
python manage.py migrate
@echo "📁 Collecting static files..."
python manage.py collectstatic --noinput
@echo "✅ Setup complete! Run 'make dev' to start."
check-venv:
@if [ -z "$$VIRTUAL_ENV" ]; then \
echo "❌ Virtual environment not activated!"; \
echo "Run: source .venv/bin/activate"; \
exit 1; \
else \
echo "✅ Virtual environment active: $$VIRTUAL_ENV"; \
fi
check-env:
@if [ ! -f .env ]; then \
echo "❌ .env file not found!"; \
echo "Create it with:"; \
echo " cp .env.example .env"; \
echo "Or manually:"; \
echo " echo 'SECRET_KEY=\"your-secret-key\"' > .env"; \
exit 1; \
else \
echo "✅ .env file exists"; \
fi
dev: check-venv
honcho start -f Procfile.tailwind
server: check-venv
python manage.py runserver
tailwind:
cd theme/static_src && npm run dev
install: check-venv
pip install -r requirements.txt
cd theme/static_src && npm install
migrate: check-venv
python manage.py migrate
makemigrations: check-venv
python manage.py makemigrations
createsuperuser: check-venv
python manage.py createsuperuser
shell: check-venv
python manage.py shell
test: check-venv
python manage.py test
collectstatic: check-venv
python manage.py collectstatic --noinput
build: check-venv
cd theme/static_src && npm run build
python manage.py collectstatic --noinput
clean:
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name "*.egg-info" -exec rm -rf {} +
rm -rf staticfiles/
rm -rf theme/static/css/dist/