-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
198 lines (174 loc) Β· 7.37 KB
/
Makefile
File metadata and controls
198 lines (174 loc) Β· 7.37 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
190
191
192
193
194
195
196
197
198
# Fantasy Football Draft Tracker - Conda-Compatible Makefile
.PHONY: help ff setup backend frontend install clean test lint format stop
# Default target
.DEFAULT_GOAL := help
# Colors for output
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
MAGENTA := \033[35m
CYAN := \033[36m
RESET := \033[0m
# Project directories
BACKEND_DIR := auto-draft-backend
FRONTEND_DIR := ff-rankings-app
CONDA_ENV := fantasy-football
help: ## Show this help message
@echo "$(CYAN)Fantasy Football Draft Tracker (Conda Version)$(RESET)"
@echo "$(YELLOW)Available commands:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-12s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
ff: ## π Start both Python backend and React frontend
@echo "$(CYAN)Starting Fantasy Football Draft Tracker...$(RESET)"
@$(MAKE) check-deps
@echo "$(YELLOW)Starting React frontend...$(RESET)"
@cd $(FRONTEND_DIR) && npm run dev &
@echo "$(GREEN)β
Both servers started!$(RESET)"
@echo "$(BLUE)Python API: http://localhost:5001$(RESET)"
@echo "$(BLUE)React App: http://localhost:5173$(RESET)"
@echo "$(MAGENTA)Backend logs: tail -f $(BACKEND_DIR)/backend.log$(RESET)"
@echo "$(MAGENTA)Press Ctrl+C to stop servers$(RESET)"
@trap 'make stop' INT; wait
setup: ## π§ Complete project setup (conda version)
@echo "$(CYAN)Setting up Fantasy Football Draft Tracker with Conda...$(RESET)"
@$(MAKE) create-dirs
@$(MAKE) create-conda-env
@$(MAKE) install-python-deps
@$(MAKE) install-node-deps
@echo "$(GREEN)β
Setup complete!$(RESET)"
@echo "$(BLUE)Run 'make ff' to start the application$(RESET)"
create-dirs: ## Create necessary directories
@echo "$(YELLOW)Creating project directories...$(RESET)"
@mkdir -p $(BACKEND_DIR)
@mkdir -p $(FRONTEND_DIR)
@if [ ! -f "$(BACKEND_DIR)/auto_draft_api.py" ]; then \
echo "$(YELLOW)Moving Python files to backend directory...$(RESET)"; \
find . -maxdepth 1 -name "*.py" -exec mv {} $(BACKEND_DIR)/ \; 2>/dev/null || true; \
fi
create-conda-env: ## Create conda environment
@echo "$(YELLOW)Creating conda environment: $(CONDA_ENV)$(RESET)"
@if conda env list | grep -q "^$(CONDA_ENV) "; then \
echo "$(BLUE)Conda environment $(CONDA_ENV) already exists$(RESET)"; \
else \
conda create -n $(CONDA_ENV) python=3.9 -y; \
echo "$(GREEN)β
Conda environment created$(RESET)"; \
fi
install-python-deps: ## Install Python dependencies
@echo "$(YELLOW)Installing Python dependencies in conda environment...$(RESET)"
@conda run -n $(CONDA_ENV) pip install flask flask-cors pandas pydantic
@echo "$(GREEN)β
Python dependencies installed$(RESET)"
install-node-deps: ## Install Node.js dependencies
@echo "$(YELLOW)Installing Node.js dependencies...$(RESET)"
@if [ ! -d "$(FRONTEND_DIR)" ]; then \
echo "$(RED)β React app directory not found$(RESET)"; \
echo "$(BLUE)Create it with: npm create vite@latest $(FRONTEND_DIR) -- --template react$(RESET)"; \
exit 1; \
fi
@if [ ! -f "$(FRONTEND_DIR)/package.json" ]; then \
echo "$(RED)β No package.json found in $(FRONTEND_DIR)$(RESET)"; \
echo "$(BLUE)Initialize React app first$(RESET)"; \
exit 1; \
fi
@cd $(FRONTEND_DIR) && npm install
@echo "$(GREEN)β
Node.js dependencies installed$(RESET)"
backend: ## π Start only Python backend
@echo "$(CYAN)Starting Python backend with conda...$(RESET)"
@$(MAKE) check-conda-env
@$(MAKE) check-python-files
@cd $(BACKEND_DIR) && conda run -n $(CONDA_ENV) python auto_draft_api.py
frontend: ## βοΈ Start only React frontend
@echo "$(CYAN)Starting React frontend...$(RESET)"
@$(MAKE) check-node-deps
@cd $(FRONTEND_DIR) && npm run dev
check-deps: check-node-deps ## Check all dependencies
check-conda-env: ## Check if conda environment exists
@if ! conda env list | grep -q "^$(CONDA_ENV) "; then \
echo "$(RED)β Conda environment $(CONDA_ENV) not found$(RESET)"; \
echo "$(BLUE)Run: make create-conda-env$(RESET)"; \
exit 1; \
fi
check-python-files: ## Check if Python files exist
@if [ ! -f "$(BACKEND_DIR)/auto_draft_api.py" ]; then \
echo "$(RED)β auto_draft_api.py not found in $(BACKEND_DIR)/$(RESET)"; \
echo "$(BLUE)Run: make create-dirs$(RESET)"; \
exit 1; \
fi
@if [ ! -f "$(BACKEND_DIR)/draft_strategies.py" ]; then \
echo "$(RED)β draft_strategies.py not found in $(BACKEND_DIR)/$(RESET)"; \
echo "$(BLUE)Make sure all Python files are in $(BACKEND_DIR)/$(RESET)"; \
exit 1; \
fi
check-node-deps: ## Check Node.js dependencies
@if [ ! -d "$(FRONTEND_DIR)/node_modules" ]; then \
echo "$(RED)β Node modules not found$(RESET)"; \
echo "$(BLUE)Run: make install-node-deps$(RESET)"; \
exit 1; \
fi
test-backend: ## π§ͺ Test backend connection
@echo "$(YELLOW)Testing Python backend...$(RESET)"
@if curl -s http://localhost:5001/health >/dev/null 2>&1; then \
echo "$(GREEN)β
Backend is running$(RESET)"; \
curl -s http://localhost:5001/health | head -c 200; \
echo; \
else \
echo "$(RED)β Backend is not responding$(RESET)"; \
fi
stop: ## βΉοΈ Stop all running servers
@echo "$(YELLOW)Stopping all servers...$(RESET)"
@pkill -f "auto_draft_api.py" 2>/dev/null || true
@pkill -f "vite" 2>/dev/null || true
@pkill -f "npm run dev" 2>/dev/null || true
@echo "$(GREEN)β
All servers stopped$(RESET)"
clean: ## π§Ή Clean up temporary files
@echo "$(YELLOW)Cleaning up...$(RESET)"
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@rm -f $(BACKEND_DIR)/backend.log 2>/dev/null || true
@echo "$(GREEN)β
Cleanup complete$(RESET)"
logs: ## π Show backend logs
@echo "$(YELLOW)Backend logs:$(RESET)"
@if [ -f "$(BACKEND_DIR)/backend.log" ]; then \
tail -n 30 $(BACKEND_DIR)/backend.log; \
else \
echo "No backend log file found"; \
fi
status: ## π Check server status
@echo "$(CYAN)Server Status:$(RESET)"
@echo -n "$(YELLOW)Conda environment: $(RESET)"
@if conda env list | grep -q "^$(CONDA_ENV) "; then \
echo "$(GREEN)β
$(CONDA_ENV) exists$(RESET)"; \
else \
echo "$(RED)β $(CONDA_ENV) missing$(RESET)"; \
fi
@echo -n "$(YELLOW)Python API (port 5001): $(RESET)"
@if curl -s http://localhost:5001/health >/dev/null 2>&1; then \
echo "$(GREEN)β
Running$(RESET)"; \
else \
echo "$(RED)β Not running$(RESET)"; \
fi
@echo -n "$(YELLOW)React App (port 5173): $(RESET)"
@if curl -s http://localhost:5173 >/dev/null 2>&1; then \
echo "$(GREEN)β
Running$(RESET)"; \
else \
echo "$(RED)β Not running$(RESET)"; \
fi
info: ## βΉοΈ Show project information
@echo "$(CYAN)Fantasy Football Draft Tracker (Conda Version)$(RESET)"
@echo "$(YELLOW)Conda Environment:$(RESET) $(CONDA_ENV)"
@echo "$(YELLOW)Backend Directory:$(RESET) $(BACKEND_DIR)/"
@echo "$(YELLOW)Frontend Directory:$(RESET) $(FRONTEND_DIR)/"
@echo ""
@echo "$(YELLOW)Quick Start:$(RESET)"
@echo " 1. $(GREEN)make setup$(RESET) - First time setup"
@echo " 2. $(GREEN)make ff$(RESET) - Start both servers"
@echo " 3. $(GREEN)make status$(RESET) - Check if running"
@echo ""
@echo "$(YELLOW)Troubleshooting:$(RESET)"
@echo " $(GREEN)make logs$(RESET) - Show backend logs"
@echo " $(GREEN)make test-backend$(RESET) - Test API connection"
@echo " $(GREEN)make backend$(RESET) - Start backend only"
# Quick setup for first-time users
quick-setup: ## π One-command setup
@echo "$(CYAN)Quick Setup for Fantasy Football Draft Tracker$(RESET)"
@$(MAKE) setup
@echo "$(GREEN)π Setup complete! Now run: make ff$(RESET)"