build.bat
1.08 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
@echo off
setlocal
chcp 65001 >nul
set "SCRIPT_DIR=%~dp0"
for %%I in ("%SCRIPT_DIR%.") do set "PROJECT_DIR=%%~fI"
set "DIST_DIR=%PROJECT_DIR%\dist"
set "DEPLOY_DIR=%PROJECT_DIR%\..\Build\html\dist"
echo [1/3] Building frontend...
call yarn build:ci
if errorlevel 1 (
echo Build failed.
exit /b 1
)
if not exist "%DIST_DIR%" (
echo Build output not found: "%DIST_DIR%"
exit /b 1
)
echo [2/3] Preparing deploy directory...
if exist "%DEPLOY_DIR%" (
rmdir /s /q "%DEPLOY_DIR%"
if exist "%DEPLOY_DIR%" (
echo Failed to remove old deploy directory: "%DEPLOY_DIR%"
exit /b 1
)
)
mkdir "%DEPLOY_DIR%"
if errorlevel 1 (
echo Failed to create deploy directory: "%DEPLOY_DIR%"
exit /b 1
)
echo [3/3] Copying dist to deploy directory...
robocopy "%DIST_DIR%" "%DEPLOY_DIR%" /E /R:2 /W:1 /NFL /NDL /NJH /NJS /NP
set "ROBOCOPY_EXIT=%ERRORLEVEL%"
if %ROBOCOPY_EXIT% GEQ 8 (
echo Deploy copy failed. Robocopy exit code: %ROBOCOPY_EXIT%
exit /b %ROBOCOPY_EXIT%
)
echo Deploy completed.
echo Source: "%DIST_DIR%"
echo Target: "%DEPLOY_DIR%"
exit /b 0