build: build.bat 改用 ASCII 注释 + chcp 65001,避免中文注释被 GBK 解析拆行
This commit is contained in:
1 parent
29162f5c1d
commit
1af62a690e
1 file changed
+20
-18
+20
-18
@@ -1,14 +1,15 @@
|
||||
@echo off
|
||||
REM 在 Windows 构建机(Meowhome)上一键构建 Windows 产物。
|
||||
REM 产物:
|
||||
REM dist\scoreboard.exe 服务端(前端已 go:embed 内嵌)
|
||||
REM dist\console\ScoreboardConsole\ 便携版 GUI 管理器(双击即用,免安装)
|
||||
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 说明:不用 electron-builder 的 NSIS 打包,因为它会从 GitHub 下载签名工具,
|
||||
REM 离线/受限网络下必失败。改为手动组装便携版:Electron 运行时 + resources\app。
|
||||
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 Electron 版本必须与 console\package.json 的 devDependencies.electron 一致(锁在 console\pnpm-lock.yaml)
|
||||
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"
|
||||
@@ -18,27 +19,28 @@ cd /d "%~dp0.."
|
||||
echo === [1/5] git pull ===
|
||||
git pull || exit /b 1
|
||||
|
||||
echo === [2/5] 前端依赖与构建 ===
|
||||
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] 服务端构建 ===
|
||||
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 依赖 + Electron 二进制 ===
|
||||
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] 组装便携版 Console ===
|
||||
REM 旧版本可能在运行;Electron 解压出的 .pak 带只读属性,整目录删除很容易失败,
|
||||
REM 改为「就地覆盖」:只清掉我们自己的 resources\app,运行时文件直接覆盖。
|
||||
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
|
||||
@@ -48,7 +50,7 @@ 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 必须放在 exe 同级(Console 按 exe 目录解析配置)
|
||||
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
|
||||
@@ -62,16 +64,16 @@ dir "%CONSOLE_OUT%"
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
REM ---- 确保 Electron 二进制就位(pnpm 默认跳过 postinstall) -------------------
|
||||
REM ---- ensure electron binary exists (pnpm skips postinstall by default) -------
|
||||
:ensure_electron
|
||||
if exist node_modules\electron\dist\electron.exe (
|
||||
echo Electron 二进制已就绪
|
||||
echo electron binary ready
|
||||
exit /b 0
|
||||
)
|
||||
echo 下载 Electron %ELECTRON_VERSION% ...
|
||||
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 二进制已放置
|
||||
echo electron binary placed
|
||||
exit /b 0
|
||||
Reference in new issue
Block a user