1+ @ echo off
2+ rem Development environment setup script for Windows
3+
4+ setlocal enabledelayedexpansion
5+
6+ rem Get script directory and project root
7+ set SCRIPT_DIR = %~dp0
8+ set PROJECT_ROOT = %SCRIPT_DIR% ..
9+
10+ rem Colors for output (using PowerShell for colored output)
11+ set " RED = [31m"
12+ set " GREEN = [32m"
13+ set " YELLOW = [33m"
14+ set " NC = [0m"
15+
16+ :print_header
17+ echo .
18+ echo %GREEN% 🚄 Hyperloop H10 Development Environment%NC%
19+ echo %GREEN% =======================================%NC%
20+ echo %YELLOW% OS: Windows%NC%
21+ echo .
22+ goto :eof
23+
24+ :print_usage
25+ echo Usage: %0 [command]
26+ echo .
27+ echo Commands:
28+ echo setup - Install all dependencies
29+ echo backend - Run backend server
30+ echo ethernet - Run ethernet-view dev server
31+ echo control - Run control-station dev server
32+ echo packet - Run packet-sender
33+ echo all - Run all services in parallel
34+ echo test - Run all tests
35+ echo build - Build all components
36+ echo .
37+ goto :eof
38+
39+ :check_dependencies
40+ echo %YELLOW% Checking dependencies...%NC%
41+
42+ where go > nul 2 >& 1
43+ if errorlevel 1 (
44+ echo %RED% Error: Go is not installed or not in PATH%NC%
45+ exit /b 1
46+ )
47+
48+ where node > nul 2 >& 1
49+ if errorlevel 1 (
50+ echo %RED% Error: Node.js is not installed or not in PATH%NC%
51+ exit /b 1
52+ )
53+
54+ where npm > nul 2 >& 1
55+ if errorlevel 1 (
56+ echo %RED% Error: npm is not installed or not in PATH%NC%
57+ exit /b 1
58+ )
59+
60+ echo %GREEN% ✅ All dependencies found%NC%
61+ goto :eof
62+
63+ :setup_project
64+ echo %YELLOW% Setting up project dependencies...%NC%
65+
66+ cd /d " %PROJECT_ROOT% "
67+
68+ rem Build common-front first
69+ echo 📦 Building common-front...
70+ cd common-front
71+ call npm install
72+ if errorlevel 1 exit /b 1
73+ call npm run build
74+ if errorlevel 1 exit /b 1
75+
76+ rem Install ethernet-view dependencies
77+ echo 📦 Installing ethernet-view dependencies...
78+ cd ..\ethernet-view
79+ call npm install
80+ if errorlevel 1 exit /b 1
81+
82+ rem Install control-station dependencies
83+ echo 📦 Installing control-station dependencies...
84+ cd ..\control-station
85+ call npm install
86+ if errorlevel 1 exit /b 1
87+
88+ rem Download Go dependencies
89+ echo 📦 Downloading Go dependencies...
90+ cd ..\backend
91+ go mod download
92+ if errorlevel 1 exit /b 1
93+
94+ cd ..\packet-sender
95+ go mod download
96+ if errorlevel 1 exit /b 1
97+
98+ echo %GREEN% ✅ Setup complete!%NC%
99+ goto :eof
100+
101+ :run_backend
102+ cd /d " %PROJECT_ROOT% \backend\cmd"
103+ echo %YELLOW% Starting backend server...%NC%
104+ go run .
105+ goto :eof
106+
107+ :run_ethernet_view
108+ cd /d " %PROJECT_ROOT% \ethernet-view"
109+ echo %YELLOW% Starting ethernet-view dev server...%NC%
110+ call npm run dev
111+ goto :eof
112+
113+ :run_control_station
114+ cd /d " %PROJECT_ROOT% \control-station"
115+ echo %YELLOW% Starting control-station dev server...%NC%
116+ call npm run dev
117+ goto :eof
118+
119+ :run_packet_sender
120+ cd /d " %PROJECT_ROOT% \packet-sender"
121+ echo %YELLOW% Starting packet-sender...%NC%
122+ go run .
123+ goto :eof
124+
125+ :run_all_parallel
126+ echo %YELLOW% Starting all services in parallel...%NC%
127+ echo %YELLOW% Use Ctrl+C to stop all services%NC%
128+ echo .
129+
130+ rem Create a temporary batch file to run services in parallel
131+ set TEMP_BATCH = %TEMP% \hyperloop_services.bat
132+
133+ echo @echo off > " %TEMP_BATCH% "
134+ echo start " Backend" /D " %PROJECT_ROOT% \backend\cmd" cmd /k " go run ." >> " %TEMP_BATCH% "
135+ echo start " Ethernet View" /D " %PROJECT_ROOT% \ethernet-view" cmd /k " npm run dev" >> " %TEMP_BATCH% "
136+ echo start " Control Station" /D " %PROJECT_ROOT% \control-station" cmd /k " npm run dev" >> " %TEMP_BATCH% "
137+ echo start " Packet Sender" /D " %PROJECT_ROOT% \packet-sender" cmd /k " go run ." >> " %TEMP_BATCH% "
138+
139+ call " %TEMP_BATCH% "
140+ del " %TEMP_BATCH% "
141+
142+ echo %GREEN% All services started in separate windows%NC%
143+ echo %YELLOW% Close the respective command windows to stop each service%NC%
144+ goto :eof
145+
146+ :run_tests
147+ echo %YELLOW% Running tests...%NC%
148+
149+ cd /d " %PROJECT_ROOT% \backend"
150+ echo 🧪 Running backend tests...
151+ go test -v ./...
152+ if errorlevel 1 exit /b 1
153+
154+ rem Add more test commands as needed
155+ echo %GREEN% ✅ All tests passed%NC%
156+ goto :eof
157+
158+ :build_all
159+ cd /d " %PROJECT_ROOT% "
160+ echo %YELLOW% Building all components...%NC%
161+
162+ rem Check if make is available (e.g., from MinGW or WSL)
163+ where make > nul 2 >& 1
164+ if not errorlevel 1 (
165+ make all
166+ ) else (
167+ echo %YELLOW% Make not found, building components individually...%NC%
168+
169+ rem Build backend
170+ echo Building backend...
171+ cd backend
172+ go build -o backend cmd/main.go cmd/config.go cmd/pid.go cmd/trace.go
173+ if errorlevel 1 exit /b 1
174+
175+ rem Build common-front
176+ echo Building common-front...
177+ cd ..\common-front
178+ call npm run build
179+ if errorlevel 1 exit /b 1
180+
181+ rem Build other frontends
182+ echo Building ethernet-view...
183+ cd ..\ethernet-view
184+ call npm run build
185+ if errorlevel 1 exit /b 1
186+
187+ echo Building control-station...
188+ cd ..\control-station
189+ call npm run build
190+ if errorlevel 1 exit /b 1
191+ )
192+
193+ echo %GREEN% ✅ Build complete!%NC%
194+ goto :eof
195+
196+ rem Main script logic
197+ call :print_header
198+ call :check_dependencies
199+
200+ if " %1 " == " " (
201+ call :print_usage
202+ exit /b 1
203+ )
204+
205+ if " %1 " == " setup" (
206+ call :setup_project
207+ ) else if " %1 " == " backend" (
208+ call :run_backend
209+ ) else if " %1 " == " ethernet" (
210+ call :run_ethernet_view
211+ ) else if " %1 " == " control" (
212+ call :run_control_station
213+ ) else if " %1 " == " packet" (
214+ call :run_packet_sender
215+ ) else if " %1 " == " all" (
216+ call :run_all_parallel
217+ ) else if " %1 " == " test" (
218+ call :run_tests
219+ ) else if " %1 " == " build" (
220+ call :build_all
221+ ) else (
222+ echo %RED% Unknown command: %1 %NC%
223+ call :print_usage
224+ exit /b 1
225+ )
0 commit comments