-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (175 loc) · 6.52 KB
/
Makefile
File metadata and controls
190 lines (175 loc) · 6.52 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
# PHP Text Intelligence Makefile
# Framework-agnostic commands for managing the project and git submodules
.PHONY: help check check-prereqs init install install-frontend build start start-backend start-frontend clean status update test eject-frontend
# Default target: show help
help:
@echo "PHP Text Intelligence - Available Commands"
@echo "==========================================="
@echo ""
@echo "Setup:"
@echo " make check-prereqs Check if prerequisites are installed"
@echo " make init Initialize submodules and install dependencies"
@echo " make install Install PHP dependencies"
@echo " make install-frontend Install frontend dependencies"
@echo ""
@echo "Development:"
@echo " make start Start development servers (backend + frontend)"
@echo " make start-backend Start backend server only"
@echo " make start-frontend Start frontend server only"
@echo " make build Build frontend for production"
@echo ""
@echo "Maintenance:"
@echo " make update Update submodules to latest commits"
@echo " make clean Remove build artifacts"
@echo " make status Show git and submodule status"
@echo ""
# Check prerequisites
check-prereqs:
@command -v git >/dev/null 2>&1 || { echo "❌ git is required but not installed. Visit https://git-scm.com"; exit 1; }
@command -v php >/dev/null 2>&1 || { echo "❌ php is required but not installed. Visit https://www.php.net"; exit 1; }
@command -v composer >/dev/null 2>&1 || { echo "❌ composer is required but not installed. Visit https://getcomposer.org"; exit 1; }
@command -v pnpm >/dev/null 2>&1 || { echo "⚠️ pnpm not found. Run: corepack enable"; exit 1; }
@echo "✓ All prerequisites installed"
check: check-prereqs
# Install PHP dependencies
install:
@echo "==> Installing PHP dependencies..."
composer install
# Install frontend dependencies (requires submodule to be initialized)
install-frontend:
@echo "==> Installing frontend dependencies..."
@if [ ! -d "frontend" ] || [ -z "$$(ls -A frontend)" ]; then \
echo "❌ Error: Frontend submodule not initialized. Run 'make init' first."; \
exit 1; \
fi
cd frontend && corepack pnpm install
# Initialize project: clone submodules and install dependencies
init:
@echo "==> Initializing submodules..."
git submodule update --init --recursive
@echo ""
@echo "==> Installing PHP dependencies..."
composer install
@echo ""
@echo "==> Installing frontend dependencies..."
cd frontend && corepack pnpm install
@echo ""
@echo "✓ Project initialized successfully!"
@echo ""
@echo "Next steps:"
@echo " 1. Copy sample.env to .env and add your DEEPGRAM_API_KEY"
@echo " 2. Run 'make start' to start development servers"
@echo ""
# Build frontend for production
build:
@echo "==> Building frontend..."
@if [ ! -d "frontend" ] || [ -z "$$(ls -A frontend)" ]; then \
echo "❌ Error: Frontend submodule not initialized. Run 'make init' first."; \
exit 1; \
fi
cd frontend && corepack pnpm build
@echo "✓ Frontend built to frontend/dist/"
# Start both servers (backend + frontend)
start:
@$(MAKE) start-backend & $(MAKE) start-frontend & wait
# Start backend server
start-backend:
@if [ ! -f ".env" ]; then \
echo "❌ Error: .env file not found. Copy sample.env to .env and add your DEEPGRAM_API_KEY"; \
exit 1; \
fi
@echo "==> Starting backend on http://localhost:8081"
php -S 0.0.0.0:8081 server.php
# Start frontend dev server
start-frontend:
@if [ ! -d "frontend" ] || [ -z "$$(ls -A frontend)" ]; then \
echo "❌ Error: Frontend submodule not initialized. Run 'make init' first."; \
exit 1; \
fi
@echo "==> Starting frontend on http://localhost:8080"
cd frontend && corepack pnpm run dev -- --port 8080 --no-open
# Update submodules to latest commits
update:
@echo "==> Updating submodules..."
git submodule update --remote --merge
@echo "✓ Submodules updated"
# Run contract conformance tests
test:
@if [ ! -f ".env" ]; then \
echo "❌ Error: .env file not found. Copy sample.env to .env and add your DEEPGRAM_API_KEY"; \
exit 1; \
fi
@if [ ! -d "contracts" ] || [ -z "$$(ls -A contracts)" ]; then \
echo "❌ Error: Contracts submodule not initialized. Run 'make init' first."; \
exit 1; \
fi
@echo "==> Running contract conformance tests..."
cd contracts && ./tests/run-text-intelligence-app.sh
# Clean build artifacts
clean:
@echo "==> Cleaning build artifacts..."
rm -rf vendor
rm -rf frontend/node_modules
rm -rf frontend/dist
@echo "✓ Cleaned successfully"
# Show git and submodule status
status:
@echo "==> Repository Status"
@echo "====================="
@echo ""
@echo "Main Repository:"
git status --short
@echo ""
@echo "Submodule Status:"
git submodule status
@echo ""
@if [ -d "frontend" ] && [ -n "$$(ls -A frontend)" ]; then \
echo "Submodule Branches:"; \
cd frontend && echo "frontend: $$(git branch --show-current) ($$(git rev-parse --short HEAD))"; \
fi
@echo ""
# Eject frontend submodule into a regular directory (irreversible)
eject-frontend:
@echo ""
@echo "⚠️ This will:"
@echo " 1. Copy frontend submodule files into a regular 'frontend/' directory"
@echo " 2. Remove the frontend git submodule configuration"
@echo " 3. Remove the contracts git submodule"
@echo " 4. Remove .gitmodules file"
@echo ""
@echo " After ejecting, frontend changes can be committed directly"
@echo " with your backend changes. This cannot be undone."
@echo ""
@read -p " Continue? [Y/n] " confirm; \
if [ "$$confirm" != "Y" ] && [ "$$confirm" != "y" ] && [ -n "$$confirm" ]; then \
echo " Cancelled."; \
exit 1; \
fi
@echo ""
@echo "==> Ejecting frontend submodule..."
@FRONTEND_TMP=$$(mktemp -d); \
cp -r frontend/. "$$FRONTEND_TMP/"; \
git submodule deinit -f frontend; \
git rm -f frontend; \
rm -rf .git/modules/frontend; \
mkdir -p frontend; \
cp -r "$$FRONTEND_TMP/." frontend/; \
rm -rf "$$FRONTEND_TMP"; \
rm -rf frontend/.git; \
echo " ✅ Frontend ejected to regular directory"
@echo "==> Removing contracts submodule..."
@if git config --file .gitmodules submodule.contracts.url > /dev/null 2>&1; then \
git submodule deinit -f contracts; \
git rm -f contracts; \
rm -rf .git/modules/contracts; \
echo " ✅ Contracts submodule removed"; \
else \
echo " ℹ️ No contracts submodule found"; \
fi
@if [ -f .gitmodules ] && [ ! -s .gitmodules ]; then \
git rm -f .gitmodules; \
echo " ✅ Empty .gitmodules removed"; \
fi
@echo ""
@echo "✅ Eject complete! Frontend files are now regular tracked files."
@echo " Run 'git add . && git commit' to save the changes."