Files
git-heatmap/build.bat
2026-06-23 21:57:49 +08:00

93 lines
1.7 KiB
Batchfile

@echo off
setlocal EnableExtensions
cd /d "%~dp0"
echo.
echo ========================================
echo GitHeatMap Build
echo ========================================
echo.
where npm >nul 2>&1
if errorlevel 1 goto :no_npm
where cargo >nul 2>&1
if errorlevel 1 goto :no_cargo
if exist "%~dp0generate-icons.ps1" goto :gen_icons
goto :build_gitea
:gen_icons
echo [1/4] Generating icons...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0generate-icons.ps1"
if errorlevel 1 goto :icon_fail
echo.
:build_gitea
echo [2/4] Building Gitea HeatMap...
cd /d "%~dp0gitea"
if errorlevel 1 goto :dir_fail
if not exist "node_modules\" goto :gitea_install
goto :gitea_build
:gitea_install
echo npm install...
call npm install
if errorlevel 1 goto :gitea_fail
:gitea_build
call npm run build
if errorlevel 1 goto :gitea_fail
echo gitea OK
echo.
echo [3/4] Building GitHub HeatMap...
cd /d "%~dp0github"
if errorlevel 1 goto :dir_fail
if not exist "node_modules\" goto :github_install
goto :github_build
:github_install
echo npm install...
call npm install
if errorlevel 1 goto :github_fail
:github_build
call npm run build
if errorlevel 1 goto :github_fail
echo github OK
echo.
echo [4/4] Done
echo.
echo Output: %~dp0target\release\
echo gitea-heatmap.exe
echo github-heatmap.exe
echo ========================================
echo.
exit /b 0
:no_npm
echo ERROR: npm not found. Install Node.js first.
exit /b 1
:no_cargo
echo ERROR: cargo not found. Install Rust first.
exit /b 1
:icon_fail
echo ERROR: icon generation failed.
exit /b 1
:dir_fail
echo ERROR: project directory not found.
exit /b 1
:gitea_fail
echo ERROR: Gitea build failed.
exit /b 1
:github_fail
echo ERROR: GitHub build failed.
exit /b 1