@echo off chcp 65001 >nul REM Build Windows artifacts on the build machine (Meowhome). REM Output: REM dist\scoreboard.exe server (frontend embedded via go:embed) REM dist\console\ScoreboardConsole\ portable GUI manager (double-click to run) REM REM We do NOT use electron-builder NSIS: it downloads signing tools from GitHub, REM which fails on restricted networks. Instead we assemble a portable app manually. setlocal REM Must match console\package.json devDependencies.electron (pinned in console\pnpm-lock.yaml) set "ELECTRON_VERSION=38.8.6" set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron" set "CONSOLE_OUT=dist\console\ScoreboardConsole" cd /d "%~dp0.." echo === [1/5] git pull === git pull || exit /b 1 echo === [2/5] web deps + build === cd web call pnpm install --frozen-lockfile || exit /b 1 call pnpm build || exit /b 1 cd .. echo === [3/5] server build === cd server if not exist ..\dist mkdir ..\dist go build -o ..\dist\scoreboard.exe . || exit /b 1 cd .. echo === [4/5] console deps + electron binary === cd console call pnpm install --frozen-lockfile || exit /b 1 call :ensure_electron || exit /b 1 cd .. echo === [5/5] assemble portable console === REM Old build may still be running; .pak files from the electron zip are read-only, REM so full directory removal is fragile. Overwrite in place instead: only wipe our REM own resources\app, let the runtime files be overwritten. taskkill /im "Scoreboard Console.exe" /f >nul 2>&1 taskkill /im scoreboard.exe /f >nul 2>&1 if not exist "%CONSOLE_OUT%" mkdir "%CONSOLE_OUT%" || exit /b 1 xcopy /e /i /y "console\node_modules\electron\dist" "%CONSOLE_OUT%" >nul || exit /b 1 if exist "%CONSOLE_OUT%\resources\app" rmdir /s /q "%CONSOLE_OUT%\resources\app" mkdir "%CONSOLE_OUT%\resources\app" 2>nul xcopy /e /i /y "console\main" "%CONSOLE_OUT%\resources\app\main" >nul || exit /b 1 xcopy /e /i /y "console\renderer" "%CONSOLE_OUT%\resources\app\renderer" >nul || exit /b 1 copy /y "console\package.json" "%CONSOLE_OUT%\resources\app\package.json" >nul || exit /b 1 REM config.json must sit next to the exe: the console resolves it from the exe dir copy /y "console\config.json" "%CONSOLE_OUT%\config.json" >nul || exit /b 1 copy /y "dist\scoreboard.exe" "%CONSOLE_OUT%\scoreboard.exe" >nul || exit /b 1 copy /y "config.yaml" "%CONSOLE_OUT%\config.yaml" >nul || exit /b 1 if exist "%CONSOLE_OUT%\electron.exe" ren "%CONSOLE_OUT%\electron.exe" "Scoreboard Console.exe" echo. echo === 构建完成 === echo dist\scoreboard.exe 服务端 echo %CONSOLE_OUT%\Scoreboard Console.exe GUI 管理器(双击运行) dir "%CONSOLE_OUT%" endlocal exit /b 0 REM ---- ensure electron binary exists (pnpm skips postinstall by default) ------- :ensure_electron if exist node_modules\electron\dist\electron.exe ( echo electron binary ready exit /b 0 ) echo downloading electron %ELECTRON_VERSION% ... curl -L --fail --max-time 900 -o electron-dl.zip "%ELECTRON_MIRROR%/%ELECTRON_VERSION%/electron-v%ELECTRON_VERSION%-win32-x64.zip" || exit /b 1 powershell -NoProfile -Command "Expand-Archive -LiteralPath 'electron-dl.zip' -DestinationPath 'node_modules/electron/dist' -Force" || exit /b 1 del /q electron-dl.zip echo electron.exe> node_modules\electron\path.txt echo electron binary placed exit /b 0