-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
201 lines (184 loc) · 6.81 KB
/
Makefile
File metadata and controls
201 lines (184 loc) · 6.81 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
199
200
201
# Java Flux Makefile
# Framework-agnostic commands for managing the project and git submodules
.PHONY: help check check-prereqs init install install-backend install-frontend build start start-backend start-frontend test update clean status eject-frontend
# Default target: show help
help:
@echo "Java Flux (Javalin) - 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-backend Install backend dependencies only"
@echo " make install-frontend Install frontend dependencies only"
@echo ""
@echo "Development:"
@echo " make build Build the backend shaded JAR"
@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 ""
@echo "Maintenance:"
@echo " make update Update submodules to latest commits"
@echo " make clean Remove build artifacts and dependencies"
@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 java >/dev/null 2>&1 || { echo "java is required but not installed. Visit https://adoptium.net"; exit 1; }
@command -v mvn >/dev/null 2>&1 || { echo "mvn (Maven) is required but not installed. Visit https://maven.apache.org"; 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 "==> Building Java project..."
mvn package -q -DskipTests
@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 ""
# Install all dependencies
install: init
# Install backend dependencies and build
install-backend:
@echo "==> Building Java project..."
mvn package -q -DskipTests
# 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
# Build the backend shaded JAR
build:
@echo "==> Building Java project..."
mvn package -q -DskipTests
# Start both servers in parallel
start:
@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 "frontend" ] || [ -z "$$(ls -A frontend)" ]; then \
echo "Error: Frontend submodule not initialized. Run 'make init' first."; \
exit 1; \
fi
@echo "==> Starting application..."
@echo " Backend: http://localhost:8081"
@echo " Frontend: http://localhost:8080"
@echo ""
@$(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
@if [ ! -f "target/java-flux-1.0.0-shaded.jar" ]; then \
echo "==> JAR not found, building..."; \
mvn package -q -DskipTests; \
fi
@echo "==> Starting backend on http://localhost:8081"
java -jar target/java-flux-1.0.0-shaded.jar
# 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 && 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..."
@bash contracts/tests/run-flux-app.sh
# Clean all dependencies and build artifacts
clean:
@echo "==> Cleaning build artifacts..."
rm -rf target
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."