-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathrun.bat
More file actions
144 lines (120 loc) · 3.57 KB
/
Copy pathrun.bat
File metadata and controls
144 lines (120 loc) · 3.57 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
@echo off
setlocal enabledelayedexpansion
REM --- Check for --mobile flag ---
set MOBILE_FLAG=0
for %%a in (%*) do (
if "%%a"=="--mobile" set MOBILE_FLAG=1
)
if %MOBILE_FLAG% equ 1 (
echo --mobile flag detected.
REM --- Path to your Android project ---
set PROJECT_DIR="\mobile"
REM --- Check if Android Studio exists in common locations ---
set "ANDROID_STUDIO_FOUND=0"
if EXIST "C:\Program Files\Android\Android Studio\bin\studio64.exe" set ANDROID_STUDIO_FOUND=1
if EXIST "C:\Program Files (x86)\Android\Android Studio\bin\studio64.exe" set ANDROID_STUDIO_FOUND=1
if "%ANDROID_STUDIO_FOUND%"=="0" (
echo Android Studio not found. Please install it first.
exit /b 1
) else (
echo Android Studio found.
)
REM --- Check if Gradle wrapper exists ---
if NOT EXIST ".\mobile\gradlew.bat" (
echo Gradle wrapper not found. Are you in an Android project?
exit /b 1
)
REM --- Launch Android Studio in this folder ---
if EXIST "C:\Program Files\Android\Android Studio\bin\studio64.exe" (
start "" "C:\Program Files\Android\Android Studio\bin\studio64.exe" ".\mobile"
) else (
start "" "C:\Program Files (x86)\Android\Android Studio\bin\studio64.exe" ".\mobile"
)
)
REM --- Exit on error ---
set error_flag=0
REM --- Check if Docker is running ---
docker info >nul 2>&1
if %errorlevel% neq 0 (
echo Docker is not running. Please start Docker and try again.
exit /b 1
) else (
echo Docker is running.
)
REM --- Function to check if a port is free ---
call :check_port_free 8000
if !error_flag! equ 1 exit /b 1
call :check_port_free 8080
if !error_flag! equ 1 exit /b 1
call :check_port_free 3306
if !error_flag! equ 1 exit /b 1
REM --- Move into frontend directory ---
if exist "frontend\" (
cd frontend
echo Changed directory to ./frontend.
) else (
echo Directory ./frontend not found.
exit /b 1
)
REM --- Handle .env file creation ---
if exist ".env" (
echo .env already exists. Skipping setup environment
) else if exist ".env.template" (
copy /Y .env.template .env >nul
echo Copy .env.template to .env.
) else (
echo No .env or .env.template file found.
)
REM --- Go back to project root ---
cd ..
echo Returned to project root.
REM --- Move into backend directory ---
if exist "backend\" (
cd backend
echo Changed directory to ./backend.
) else (
echo Directory ./backend not found.
exit /b 1
)
REM --- Handle .env file creation ---
if exist ".env" (
echo .env already exists. Skipping setup environment
) else if exist ".env.template" (
copy /Y .env.template .env >nul
echo Copy .env.template to .env.
) else (
echo No .env or .env.template file found.
)
REM --- Go back to project root ---
cd ..
echo Returned to project root.
REM --- Detect docker compose command ---
where docker-compose >nul 2>&1
if %errorlevel% equ 0 (
set COMPOSE_CMD=docker-compose
) else (
docker compose version >nul 2>&1
if %errorlevel% equ 0 (
set COMPOSE_CMD=docker compose
) else (
echo Neither 'docker-compose' nor 'docker compose' is available.
exit /b 1
)
)
echo Using '%COMPOSE_CMD%' to start containers.
REM --- Run docker compose ---
echo Starting Docker containers...
%COMPOSE_CMD% up --build
exit /b 0
REM --- Port check function ---
:check_port_free
set port=%1
netstat -an | find ":%port% " >nul
if %errorlevel% equ 0 (
echo Port %port% is currently in use. Please free it before continuing.
set error_flag=1
) else (
echo Port %port% is free.
set error_flag=0
)
exit /b 0