fix(build): 恢复安装器许可页文案生成(挪到 prepare-extra.mjs,避免中文进批处理)
This commit is contained in:
1 parent
fc3361f766
commit
d50f5d7524
1 file changed
+27
-12
+27
-12
@@ -1,19 +1,34 @@
|
|||||||
// 把 docs/ 下的使用说明暂存到 console/extra/,供 electron-builder 的 extraFiles
|
// 构建前准备两样东西:
|
||||||
// 平铺到部署包根目录。用 Node 而不是批处理,是因为中文文件名在 .bat 里会被 cmd 解析错乱。
|
// 1) 把 docs/ 下的使用说明暂存到 console/extra/,供 electron-builder 的 extraFiles 平铺到部署包根目录;
|
||||||
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
// 2) 生成安装器许可页顶部文案(console/resources/installer-signature.nsh),署名来自构建机本地文件。
|
||||||
|
// 用 Node 而不是批处理:中文文件名/中文内容在 .bat 里会被 cmd 解析错乱。
|
||||||
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||||
import { dirname, join } from 'node:path'
|
import { dirname, join } from 'node:path'
|
||||||
|
|
||||||
const root = dirname(import.meta.dirname)
|
const root = dirname(import.meta.dirname)
|
||||||
|
|
||||||
|
// ---- 1. usage doc -----------------------------------------------------------
|
||||||
const extraDir = join(root, 'console', 'extra')
|
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 })
|
mkdirSync(extraDir, { recursive: true })
|
||||||
|
const usageTarget = join(extraDir, '使用说明.txt')
|
||||||
const source = candidates.find((file) => existsSync(file))
|
const usageSources = [join(root, 'docs', '使用说明.txt'), join(root, 'docs', '使用手册.md')]
|
||||||
if (!source) {
|
const usageSource = usageSources.find((file) => existsSync(file))
|
||||||
|
if (usageSource) {
|
||||||
|
copyFileSync(usageSource, usageTarget)
|
||||||
|
console.log(` usage doc staged from ${usageSource}`)
|
||||||
|
} else {
|
||||||
console.log(' [docs] no usage doc, skip')
|
console.log(' [docs] no usage doc, skip')
|
||||||
process.exit(0)
|
|
||||||
}
|
}
|
||||||
copyFileSync(source, target)
|
|
||||||
console.log(` usage doc staged from ${source}`)
|
// ---- 2. installer license page text ----------------------------------------
|
||||||
|
const signatureFile = join(root, 'deploy', 'signature.local.txt')
|
||||||
|
const nshFile = join(root, 'console', 'resources', 'installer-signature.nsh')
|
||||||
|
mkdirSync(dirname(nshFile), { recursive: true })
|
||||||
|
|
||||||
|
let topText = '请阅读并接受许可协议'
|
||||||
|
if (existsSync(signatureFile)) {
|
||||||
|
const signature = readFileSync(signatureFile, 'utf8').trim()
|
||||||
|
if (signature !== '') topText = `内部署名:${signature}`
|
||||||
|
}
|
||||||
|
writeFileSync(nshFile, `!macro customHeader\n !define MUI_LICENSEPAGE_TEXT_TOP "${topText}"\n!macroend\n`, 'utf8')
|
||||||
|
console.log(` installer license text ready (${existsSync(signatureFile) ? 'with' : 'without'} internal signature)`)
|
||||||
Reference in new issue
Block a user