fix: Fixed Windows launcher and installer batch scripts - Use goto for OpenCode check to avoid nested if/else issues - Replace deprecated wmic with PowerShell for arch detection - Consistent use of delayed expansion

This commit is contained in:
Gemini AI
2025-12-26 10:21:42 +04:00
Unverified
parent 4bd2893864
commit 9980225be2
3 changed files with 123 additions and 126 deletions

View File

@@ -43,33 +43,37 @@ for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i
echo [OK] npm: %NPM_VERSION%
echo.
echo [PREFLIGHT 2/7] Checking OpenCode CLI (Optional)...
echo [PREFLIGHT 2/7] Checking OpenCode CLI...
where opencode >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo [OK] OpenCode CLI available in PATH - Full Mode
) else (
if exist "bin\opencode.exe" (
echo [OK] OpenCode binary found in bin/ - Full Mode
) else (
echo [INFO] OpenCode CLI not found - Using Binary-Free Mode
echo [INFO] Free models (GPT-5 Nano, Grok Code, GLM-4.7) available via OpenCode Zen
set BINARY_FREE_MODE=1
)
echo [OK] OpenCode CLI in PATH - Full Mode
goto :opencode_check_done
)
if exist "bin\opencode.exe" (
echo [OK] OpenCode binary in bin/ - Full Mode
goto :opencode_check_done
)
echo [INFO] OpenCode CLI not found - Using Binary-Free Mode
echo [INFO] Free models: GPT-5 Nano, Grok Code, GLM-4.7 via OpenCode Zen
set BINARY_FREE_MODE=1
:opencode_check_done
echo.
echo [PREFLIGHT 3/7] Checking Dependencies...
if not exist "node_modules" (
echo [INFO] Dependencies not installed. Installing now...
call npm install
if %ERRORLEVEL% neq 0 (
if !ERRORLEVEL! neq 0 (
echo [ERROR] Dependency installation failed!
pause
exit /b 1
)
echo [OK] Dependencies installed (auto-fix)
echo [OK] Dependencies installed
set /a AUTO_FIXED+=1
) else (
echo [OK] Dependencies found
@@ -107,14 +111,14 @@ if not exist "packages\ui\dist\index.html" (
echo [INFO] Running UI build...
pushd packages\ui
call npm run build
if %ERRORLEVEL% neq 0 (
if !ERRORLEVEL! neq 0 (
echo [ERROR] UI build failed!
popd
set /a ERRORS+=1
goto :final_launch_check
)
popd
echo [OK] UI build completed (auto-fix)
echo [OK] UI build completed
set /a AUTO_FIXED+=1
) else (
echo [OK] UI build directory exists
@@ -124,12 +128,12 @@ if not exist "packages\electron-app\dist\main\main.js" (
echo [WARN] Electron build incomplete
echo [INFO] Running full build...
call npm run build
if %ERRORLEVEL% neq 0 (
if !ERRORLEVEL! neq 0 (
echo [ERROR] Full build failed!
set /a ERRORS+=1
goto :final_launch_check
)
echo [OK] Full build completed (auto-fix)
echo [OK] Full build completed
set /a AUTO_FIXED+=1
)
@@ -140,19 +144,19 @@ echo [STATUS]
echo.
echo Node.js: %NODE_VERSION%
echo npm: %NPM_VERSION%
if %BINARY_FREE_MODE% equ 1 (
echo Mode: Binary-Free Mode ^(No OpenCode binary required^)
if !BINARY_FREE_MODE! equ 1 (
echo Mode: Binary-Free Mode
echo Free Models: GPT-5 Nano, Grok Code, GLM-4.7, Doubao, Big Pickle
) else (
echo Mode: Full Mode ^(OpenCode binary available^)
echo Mode: Full Mode with OpenCode
)
echo Auto-fixes applied: !AUTO_FIXED!
echo Warnings: %WARNINGS%
echo Errors: %ERRORS%
echo Warnings: !WARNINGS!
echo Errors: !ERRORS!
echo Server Port: !SERVER_PORT!
echo.
if %ERRORS% gtr 0 (
if !ERRORS! gtr 0 (
echo [RESULT] Cannot start due to errors!
echo.
echo Please fix the errors above and try again.
@@ -188,14 +192,14 @@ echo ========================================
set "VITE_DEV_SERVER_URL=http://localhost:!UI_PORT!"
set "NOMADARCH_OPEN_DEVTOOLS=false"
set "NOMADARCH_BINARY_FREE_MODE=%BINARY_FREE_MODE%"
set "NOMADARCH_BINARY_FREE_MODE=!BINARY_FREE_MODE!"
call npm run dev:electron
if %ERRORLEVEL% neq 0 (
if !ERRORLEVEL! neq 0 (
echo.
echo [ERROR] NomadArch exited with an error!
echo.
echo Error Code: %ERRORLEVEL%
echo Error Code: !ERRORLEVEL!
echo.
echo Troubleshooting:
echo 1. Ensure port !SERVER_PORT! is not in use
@@ -208,4 +212,4 @@ if %ERRORLEVEL% neq 0 (
echo.
echo Press any key to exit...
pause >nul
exit /b %ERRORS%
exit /b !ERRORS!