-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
180 lines (164 loc) · 6.16 KB
/
Makefile
File metadata and controls
180 lines (164 loc) · 6.16 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
# Text Intelligence Makefile
# Framework-agnostic commands for managing the project and git submodules
# Use corepack to ensure correct pnpm version
PNPM := corepack pnpm
.PHONY: help check check-prereqs init install install-frontend start start-backend start-frontend test update clean status
# Default target: show help
help:
@echo "Text Intelligence - Available Commands"
@echo "======================================"
@echo ""
@echo "Setup:"
@echo " make check-prereqs Check required tools are installed"
@echo " make init Initialize submodules and install all dependencies"
@echo " make install Install backend dependencies only"
@echo " make install-frontend Install frontend dependencies only"
@echo ""
@echo "Development:"
@echo " make start Start both backend and frontend servers in parallel"
@echo " make start-backend Start backend API server only (port 8081)"
@echo " make start-frontend Start frontend dev server only (port 8080)"
@echo " make test Run contract conformance tests"
@echo ""
@echo "Maintenance:"
@echo " make update Update submodules to latest commits"
@echo " make clean Remove node_modules and build artifacts"
@echo " make status Show git and submodule status"
@echo ""
# Check required 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 node >/dev/null 2>&1 || { echo "❌ node is required but not installed. Visit https://nodejs.org"; exit 1; }
@command -v pnpm >/dev/null 2>&1 || { echo "⚠️ pnpm not found. Run: corepack enable"; exit 1; }
@echo "✓ All prerequisites installed"
# Alias for check-prereqs (contract compliance)
check: check-prereqs
# Initialize project: clone submodules and install dependencies
init: check-prereqs
@echo "==> Initializing submodules..."
git submodule update --init --recursive
@echo ""
@echo "==> Installing backend dependencies..."
$(PNPM) install
@echo ""
@echo "==> Installing frontend dependencies..."
cd frontend && $(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 ""
# Install backend dependencies
install:
@echo "==> Installing backend dependencies..."
$(PNPM) 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 && $(PNPM) install
# Start both servers in parallel
start:
@$(MAKE) start-backend & $(MAKE) start-frontend & wait
# Start backend API server only
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"
$(PNPM) run start-backend
# Start frontend dev server only
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 && $(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..."
@bash contracts/tests/run-text-intelligence-app.sh
# Clean all dependencies and build artifacts
clean:
@echo "==> Cleaning node_modules and build artifacts..."
rm -rf node_modules
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 ""
@echo "Submodule Branches:"
@cd frontend && echo "frontend: $$(git branch --show-current) ($$(git rev-parse --short HEAD))"
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."