-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathstart-all.bat
174 lines (146 loc) · 4.22 KB
/
start-all.bat
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
@echo off
setlocal enabledelayedexpansion
:menu
echo Choose an option:
echo 1. Install all (Recommended for first time setup)
echo 2. Update and install dependencies (For updating existing setup)
echo 3. Run existing version
echo 4. Exit
set /p choice="Enter your choice (1, 2, 3, or 4): "
if "%choice%"=="1" goto install
if "%choice%"=="2" goto update_and_run
if "%choice%"=="3" goto run
if "%choice%"=="4" goto end
echo Invalid choice. Please try again.
goto menu
:install
REM Clone all repositories first
echo Cloning repositories...
echo Checking app repository...
if not exist "steadfast-app\.git" (
echo Cloning app...
git clone https://github.com/narenkram/steadfast-app.git
) else (
echo App repository already exists, skipping clone...
)
echo Checking API repository...
if not exist "steadfast-api\.git" (
echo Cloning API...
git clone https://github.com/narenkram/steadfast-api.git
) else (
echo API repository already exists, skipping clone...
)
echo Checking WebSocket repository...
if not exist "steadfast-websocket\.git" (
echo Cloning WebSocket...
git clone https://github.com/narenkram/steadfast-websocket.git
) else (
echo WebSocket repository already exists, skipping clone...
)
REM Now install dependencies for each repository
echo Installing dependencies for all repositories...
echo Installing app dependencies...
cd steadfast-app
call npm install
if !errorlevel! neq 0 (
echo Error occurred while installing app dependencies.
goto :error
)
cd ..
echo Installing API dependencies...
cd steadfast-api
call npm install
if !errorlevel! neq 0 (
echo Error occurred while installing API dependencies.
goto :error
)
cd ..
echo Installing WebSocket dependencies...
cd steadfast-websocket
pip install -r requirements.txt
if !errorlevel! neq 0 (
echo Error occurred while installing WebSocket dependencies.
goto :error
)
REM Install NorenRestApi without dependencies
echo Installing NorenRestApi...
pip install --no-deps NorenRestApi
if !errorlevel! neq 0 (
echo Error occurred while installing NorenRestApi.
goto :error
)
cd ..
echo Repositories cloned and dependencies installed successfully.
goto menu
:update_and_run
REM Update the entire monorepo
echo Updating steadfast-monorepo...
git pull https://github.com/narenkram/steadfast-monorepo main
if !errorlevel! neq 0 (
echo Error updating steadfast-monorepo.
goto :error
)
REM Update steadfast-app
echo Updating steadfast-app...
cd steadfast-app
git pull https://github.com/narenkram/steadfast-app main
if !errorlevel! neq 0 (
echo Error updating steadfast-app.
goto :error
)
echo Installing app dependencies...
call npm install
call npm audit fix
cd ..
REM Update steadfast-api
echo Updating steadfast-api...
cd steadfast-api
git pull https://github.com/narenkram/steadfast-api main
if !errorlevel! neq 0 (
echo Error updating steadfast-api.
goto :error
)
echo Installing api dependencies...
call npm install
call npm audit fix
cd ..
REM Update steadfast-websocket
echo Updating steadfast-websocket...
cd steadfast-websocket
git pull https://github.com/narenkram/steadfast-websocket main
if !errorlevel! neq 0 (
echo Error updating steadfast-websocket.
goto :error
)
cd ..
echo Update complete.
goto menu
:run
REM Start the API in a new command prompt window
echo Starting API...
start /min cmd /c "cd steadfast-api && node server.js"
REM Start the app in a new command prompt window
echo Starting app...
start /min cmd /c "cd steadfast-app && npm run dev"
REM Start the WebSocket server in a new command prompt window
echo Starting WebSocket server...
start /min cmd /c "cd steadfast-websocket && python main.py"
REM Wait for a few seconds to allow the app to start
timeout /t 5
REM Open the default browser to the API's URL
echo Opening browser to API's URL...
start http://localhost:3000
REM Open the default browser to the app's URL
echo Opening browser to app's URL...
start http://localhost:5173
echo Services started and browsers opened. Close this window to stop all services.
echo Press any key to stop all services...
pause > nul
REM Kill all node processes
taskkill /F /IM node.exe > nul 2>&1
REM Kill all python processes
taskkill /F /IM python.exe > nul 2>&1
echo All services stopped.
goto menu
:end
endlocal