forked from dmitryplyaskin/SillyInnkeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
124 lines (115 loc) · 2.95 KB
/
Copy pathstart.bat
File metadata and controls
124 lines (115 loc) · 2.95 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
@echo off
echo ========================================
echo Starting SillyInnkeeper Project
echo ========================================
echo.
echo [0/7] Checking package manager...
where yarn >nul 2>&1
if %errorlevel% equ 0 (
set PACKAGE_MANAGER=yarn
echo Using yarn as package manager
) else (
set PACKAGE_MANAGER=npm
echo Using npm as package manager (yarn not found)
)
echo.
echo [1/7] Checking backend dependencies (server)...
pushd server
if not exist "node_modules" (
echo Installing backend dependencies with %PACKAGE_MANAGER%...
if "%PACKAGE_MANAGER%"=="yarn" (
call yarn install --prefer-offline --silent
) else (
call npm install --prefer-offline --no-audit --no-fund
)
if %errorlevel% neq 0 (
popd
echo Error installing backend dependencies!
pause
exit /b 1
)
) else (
echo Backend dependencies already installed, skipping...
)
popd
echo.
echo [2/7] Checking frontend dependencies (client)...
pushd client
if not exist "node_modules" (
echo Installing frontend dependencies with %PACKAGE_MANAGER%...
if "%PACKAGE_MANAGER%"=="yarn" (
call yarn install --prefer-offline --silent
) else (
call npm install --prefer-offline --no-audit --no-fund
)
if %errorlevel% neq 0 (
popd
echo Error installing frontend dependencies!
pause
exit /b 1
)
) else (
echo Frontend dependencies already installed, skipping...
)
popd
echo.
echo [3/7] Checking frontend build...
if not exist "client\dist\index.html" (
echo Building frontend with %PACKAGE_MANAGER%...
pushd client
if "%PACKAGE_MANAGER%"=="yarn" (
call yarn build
) else (
call npm run build
)
if %errorlevel% neq 0 (
popd
echo Error building frontend!
pause
exit /b 1
)
popd
) else (
echo Frontend build already exists, skipping...
)
echo.
echo [4/7] Checking backend build...
if not exist "server\dist\server.js" (
echo Building backend with %PACKAGE_MANAGER%...
pushd server
if "%PACKAGE_MANAGER%"=="yarn" (
call yarn build
) else (
call npm run build
)
if %errorlevel% neq 0 (
popd
echo Error building backend!
pause
exit /b 1
)
popd
) else (
echo Backend build already exists, skipping...
)
echo.
echo [5/7] Starting production server...
set "INNKEEPER_PORT_EFFECTIVE=%INNKEEPER_PORT%"
if "%INNKEEPER_PORT_EFFECTIVE%"=="" set "INNKEEPER_PORT_EFFECTIVE=%PORT%"
if "%INNKEEPER_PORT_EFFECTIVE%"=="" set "INNKEEPER_PORT_EFFECTIVE=48912"
set "OPEN_URL=http://127.0.0.1:%INNKEEPER_PORT_EFFECTIVE%"
echo Project will be available at: %OPEN_URL%
echo Press Ctrl+C to stop the server
echo.
echo [6/7] Opening browser...
timeout /t 3 /nobreak >nul
start %OPEN_URL%
echo [7/7] Starting server with %PACKAGE_MANAGER%...
pushd server
if "%PACKAGE_MANAGER%"=="yarn" (
call yarn start
) else (
call npm run start
)
popd
pause