diff --git a/backend/mpc-system/services/service-party-app/build-windows.bat b/backend/mpc-system/services/service-party-app/build-windows.bat index 73aa27fe..f2a45f1d 100644 --- a/backend/mpc-system/services/service-party-app/build-windows.bat +++ b/backend/mpc-system/services/service-party-app/build-windows.bat @@ -9,6 +9,40 @@ echo. cd /d "%~dp0" +:: Parse command line arguments +set "DO_CLEAN=0" +set "DO_CLEAN_ALL=0" + +if "%1"=="clean" set "DO_CLEAN=1" +if "%1"=="--clean" set "DO_CLEAN=1" +if "%1"=="-c" set "DO_CLEAN=1" +if "%1"=="cleanall" set "DO_CLEAN_ALL=1" +if "%1"=="--clean-all" set "DO_CLEAN_ALL=1" + +:: Clean all (includes node_modules) +if "%DO_CLEAN_ALL%"=="1" ( + echo [CLEAN] Performing full clean... + if exist "dist" rmdir /s /q "dist" + if exist "dist-electron" rmdir /s /q "dist-electron" + if exist "release" rmdir /s /q "release" + if exist "node_modules" rmdir /s /q "node_modules" + if exist "package-lock.json" del /q "package-lock.json" + if exist "node_modules\.cache" rmdir /s /q "node_modules\.cache" + echo [OK] Full clean completed + echo. +) + +:: Clean build artifacts only +if "%DO_CLEAN%"=="1" ( + echo [CLEAN] Cleaning build artifacts... + if exist "dist" rmdir /s /q "dist" + if exist "dist-electron" rmdir /s /q "dist-electron" + if exist "release" rmdir /s /q "release" + if exist "node_modules\.cache" rmdir /s /q "node_modules\.cache" + echo [OK] Clean completed + echo. +) + :: Check Node.js where node >nul 2>nul if %errorlevel% neq 0 ( @@ -56,7 +90,15 @@ echo [2/4] Installing npm dependencies... echo ============================================ if exist "node_modules" ( - echo Dependencies exist, skipping install + if "%DO_CLEAN_ALL%"=="0" ( + echo Dependencies exist, skipping install + ) else ( + call npm install + if %errorlevel% neq 0 ( + echo [ERROR] npm install failed + goto :error + ) + ) ) else ( call npm install if %errorlevel% neq 0 ( @@ -102,6 +144,14 @@ if exist "release" ( dir /b release\*.exe 2>nul ) +echo. +echo ============================================ +echo Usage Tips +echo ============================================ +echo. +echo build-windows.bat Normal build +echo build-windows.bat clean Clean and rebuild +echo build-windows.bat cleanall Full clean (delete node_modules) and rebuild echo. echo Press any key to exit... pause >nul @@ -111,5 +161,8 @@ exit /b 0 echo. echo Build failed. Please check error messages. echo. +echo If you encounter module/type errors, try: +echo build-windows.bat cleanall +echo. pause exit /b 1