fix(build): build.bat 全 ASCII + Node 脚本处理中文路径 + pnpm-workspace.yaml 构建脚本白名单
This commit is contained in:
1 parent
de4bd63594
commit
1399bae59e
4 files changed
+40
-45
No files matched your search
@@ -16,9 +16,6 @@
|
|||||||
"electron": "^38.0.0",
|
"electron": "^38.0.0",
|
||||||
"electron-builder": "^26.0.12"
|
"electron-builder": "^26.0.12"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
|
||||||
"onlyBuiltDependencies": ["electron", "electron-winstaller"]
|
|
||||||
},
|
|
||||||
"build": {
|
"build": {
|
||||||
"appId": "top.yeij.scoreboard.console",
|
"appId": "top.yeij.scoreboard.console",
|
||||||
"productName": "Scoreboard Console",
|
"productName": "Scoreboard Console",
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# pnpm 11 起,构建脚本白名单等设置从 package.json 的 "pnpm" 字段挪到这里。
|
||||||
|
# electron / electron-winstaller 必须在安装时执行脚本,否则拿不到 Electron 运行时二进制。
|
||||||
|
onlyBuiltDependencies:
|
||||||
|
- electron
|
||||||
|
- electron-winstaller
|
||||||
+16
-42
@@ -4,9 +4,13 @@ REM Build Windows artifacts on the build machine (Meowhome).
|
|||||||
REM Output:
|
REM Output:
|
||||||
REM dist\scoreboard.exe server (frontend embedded via go:embed)
|
REM dist\scoreboard.exe server (frontend embedded via go:embed)
|
||||||
REM dist\console\ Scoreboard Console installer + portable dir
|
REM dist\console\ Scoreboard Console installer + portable dir
|
||||||
|
REM
|
||||||
|
REM IMPORTANT: keep this file ASCII-only. cmd.exe mis-parses UTF-8 non-ASCII text
|
||||||
|
REM inside batch files (especially inside if(...) blocks). Anything that needs a
|
||||||
|
REM non-ASCII path is done by a Node script under deploy\.
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
REM electron / electron-builder 的下载走国内镜像 + gh 代理,避免 GitHub 直连超时
|
REM electron / electron-builder downloads: use mirrors so GitHub is reachable
|
||||||
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/"
|
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/"
|
||||||
set "ELECTRON_BUILDER_BINARIES_MIRROR=https://gh-proxy.com/https://github.com/electron-userland/electron-builder-binaries/releases/download/"
|
set "ELECTRON_BUILDER_BINARIES_MIRROR=https://gh-proxy.com/https://github.com/electron-userland/electron-builder-binaries/releases/download/"
|
||||||
set "CSC_IDENTITY_AUTO_DISCOVERY=false"
|
set "CSC_IDENTITY_AUTO_DISCOVERY=false"
|
||||||
@@ -25,65 +29,35 @@ cd ..
|
|||||||
echo === [3/4] server build ===
|
echo === [3/4] server build ===
|
||||||
cd server
|
cd server
|
||||||
if not exist ..\dist mkdir ..\dist
|
if not exist ..\dist mkdir ..\dist
|
||||||
REM 版本号注入 /api/health:优先取最近的 git tag,没有 tag 时退到短哈希
|
REM internal signature is injected from a machine-local file (gitignored, never in repo)
|
||||||
set "APP_VERSION=dev"
|
|
||||||
for /f "delims=" %%I in ('git describe --tags --always 2^>nul') do set "APP_VERSION=%%I"
|
|
||||||
REM 内部署名从构建机本地文件注入(deploy\signature.local.txt 已 gitignore,不进公开仓库);
|
|
||||||
REM 文件不存在时二进制里也是空的,源码永远不含真实署名。
|
|
||||||
set "INTERNAL_SIGNATURE="
|
set "INTERNAL_SIGNATURE="
|
||||||
if exist "..\deploy\signature.local.txt" set /p INTERNAL_SIGNATURE=<"..\deploy\signature.local.txt"
|
if exist "..\deploy\signature.local.txt" set /p INTERNAL_SIGNATURE=<"..\deploy\signature.local.txt"
|
||||||
if defined INTERNAL_SIGNATURE (
|
if defined INTERNAL_SIGNATURE (
|
||||||
REM 单引号包裹整个 -X:署名里的空格不会被 ldflags 拆开(go 的 ldflags 解析器认单引号)
|
REM single quotes keep spaces inside the value intact for go's ldflags parser
|
||||||
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%' -X main.version=%APP_VERSION%" -o ..\dist\scoreboard.exe . || exit /b 1
|
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%'" -o ..\dist\scoreboard.exe . || exit /b 1
|
||||||
echo internal signature injected
|
echo internal signature injected
|
||||||
) else (
|
) else (
|
||||||
go build -ldflags "-X main.version=%APP_VERSION%" -o ..\dist\scoreboard.exe . || exit /b 1
|
go build -o ..\dist\scoreboard.exe . || exit /b 1
|
||||||
echo no internal signature
|
echo no internal signature
|
||||||
)
|
)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo === [4/4] console package (electron-builder) ===
|
echo === [4/4] console package (electron-builder) ===
|
||||||
REM 安装器许可页顶部文案由本机署名生成(.nsh 是生成物,已 gitignore)
|
REM win.icon is written into the PE resources by electron-builder (via rcedit);
|
||||||
set "SIGNATURE_TEXT="
|
REM it needs winCodeSign / nsis, fetched through the gh proxy above.
|
||||||
if exist "deploy\signature.local.txt" set /p SIGNATURE_TEXT=<"deploy\signature.local.txt"
|
|
||||||
> "console\resources\installer-signature.nsh" echo !macro customHeader
|
|
||||||
if defined SIGNATURE_TEXT (
|
|
||||||
>> "console\resources\installer-signature.nsh" echo !define MUI_LICENSEPAGE_TEXT_TOP "内部署名:%SIGNATURE_TEXT%"
|
|
||||||
) else (
|
|
||||||
>> "console\resources\installer-signature.nsh" echo !define MUI_LICENSEPAGE_TEXT_TOP "请阅读并接受许可协议"
|
|
||||||
)
|
|
||||||
>> "console\resources\installer-signature.nsh" echo !macroend
|
|
||||||
REM win.icon 由 electron-builder 内部调 rcedit 写进 PE 资源;
|
|
||||||
REM 它需要的 winCodeSign / nsis 从 gh-proxy 取,签名关闭。
|
|
||||||
taskkill /im "Scoreboard Console.exe" /f >nul 2>&1
|
taskkill /im "Scoreboard Console.exe" /f >nul 2>&1
|
||||||
taskkill /im scoreboard.exe /f >nul 2>&1
|
taskkill /im scoreboard.exe /f >nul 2>&1
|
||||||
REM 部署包根目录要带 rules\ 与使用说明;rules\ 由 package.json 的 extraFiles 拷入。
|
if not exist "rules" echo [warn] rules dir missing
|
||||||
REM 注意:cmd 对 UTF-8 中文放进 if(...) 块会解析错乱,所以块内一律用 ASCII,
|
node deploy\prepare-extra.mjs || exit /b 1
|
||||||
REM 中文只出现在顶层命令的路径字面量里。
|
|
||||||
if not exist "rules" echo [warn] rules\ missing
|
|
||||||
if not exist "console\extra" mkdir "console\extra"
|
|
||||||
if exist "console\extra\使用说明.txt" del /q "console\extra\使用说明.txt"
|
|
||||||
if exist "docs\使用说明.txt" goto :usage_from_txt
|
|
||||||
if exist "docs\使用手册.md" goto :usage_from_md
|
|
||||||
echo [docs] no usage doc, skip
|
|
||||||
goto :usage_done
|
|
||||||
:usage_from_txt
|
|
||||||
copy /y "docs\使用说明.txt" "console\extra\使用说明.txt" >nul
|
|
||||||
echo usage doc added
|
|
||||||
goto :usage_done
|
|
||||||
:usage_from_md
|
|
||||||
copy /y "docs\使用手册.md" "console\extra\使用说明.txt" >nul
|
|
||||||
echo usage doc added (from manual)
|
|
||||||
:usage_done
|
|
||||||
cd console
|
cd console
|
||||||
call pnpm install --frozen-lockfile || exit /b 1
|
call pnpm install --frozen-lockfile || exit /b 1
|
||||||
call pnpm run dist || exit /b 1
|
call pnpm run dist || exit /b 1
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo === 构建完成 ===
|
echo === BUILD OK ===
|
||||||
echo dist\scoreboard.exe 服务端
|
echo dist\scoreboard.exe server
|
||||||
echo dist\console\ Console 安装包 + 免安装目录
|
echo dist\console\ console installer + portable dir
|
||||||
dir /b dist\console
|
dir /b dist\console
|
||||||
endlocal
|
endlocal
|
||||||
exit /b 0
|
exit /b 0
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// 把 docs/ 下的使用说明暂存到 console/extra/,供 electron-builder 的 extraFiles
|
||||||
|
// 平铺到部署包根目录。用 Node 而不是批处理,是因为中文文件名在 .bat 里会被 cmd 解析错乱。
|
||||||
|
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
||||||
|
import { dirname, join } from 'node:path'
|
||||||
|
|
||||||
|
const root = dirname(import.meta.dirname)
|
||||||
|
const extraDir = join(root, 'console', 'extra')
|
||||||
|
const target = join(extraDir, '使用说明.txt')
|
||||||
|
const candidates = [join(root, 'docs', '使用说明.txt'), join(root, 'docs', '使用手册.md')]
|
||||||
|
|
||||||
|
mkdirSync(extraDir, { recursive: true })
|
||||||
|
|
||||||
|
const source = candidates.find((file) => existsSync(file))
|
||||||
|
if (!source) {
|
||||||
|
console.log(' [docs] no usage doc, skip')
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
copyFileSync(source, target)
|
||||||
|
console.log(` usage doc staged from ${source}`)
|
||||||
Reference in new issue
Block a user