Tighten mac packaging outputs

This commit is contained in:
ILoveBingLu
2026-04-08 18:36:10 +08:00
parent 08dbbf8f93
commit 081f4f50fc
2 changed files with 52 additions and 0 deletions
+30
View File
@@ -96,6 +96,29 @@ function getFiles(buildTarget) {
)
}
if (buildTarget === 'mac') {
return appendUnique(
withoutItems(baseFiles, [
'node_modules/koffi/build/**/*',
'!node_modules/sherpa-onnx-node/bin/!(win-x64)/**/*',
'!node_modules/ffmpeg-static/bin/!(win32-x64)/**/*'
]),
[
...commonFiles,
'!node_modules/onnxruntime-node/bin/**/linux/**/*',
'!node_modules/onnxruntime-node/bin/**/win32/**/*',
'node_modules/onnxruntime-node/bin/**/darwin/**/*',
'!node_modules/sherpa-onnx-win-*/**/*',
'!node_modules/sherpa-onnx-linux-*/**/*',
'node_modules/sherpa-onnx-darwin-*/**/*',
'!node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-win-*/**/*',
'!node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-linux-*/**/*',
'node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-darwin-*/**/*',
'node_modules/koffi/build/koffi/darwin_*/**/*'
]
)
}
return appendUnique(baseFiles, commonFiles)
}
@@ -109,6 +132,13 @@ function getAsarUnpack(buildTarget) {
)
}
if (buildTarget === 'mac') {
return appendUnique(
withoutItems(baseAsarUnpack, ['node_modules/koffi/**/*']),
['node_modules/koffi/build/koffi/darwin_*/**/*']
)
}
return baseAsarUnpack
}
+22
View File
@@ -13,6 +13,26 @@ if (!target || !['win', 'mac'].includes(target)) {
const cliPath = require.resolve('electron-builder/cli.js')
const configPath = path.join(__dirname, 'electron-builder.config.cjs')
function cleanupBlockmapFiles(buildTarget) {
if (buildTarget !== 'mac') {
return
}
const releaseDir = path.join(__dirname, '..', 'release')
if (!fs.existsSync(releaseDir)) {
return
}
for (const name of fs.readdirSync(releaseDir)) {
if (!name.endsWith('.dmg.blockmap')) {
continue
}
fs.rmSync(path.join(releaseDir, name), { force: true })
console.log(`🧹 Removed obsolete blockmap: ${name}`)
}
}
const result = spawnSync(
process.execPath,
[cliPath, `--${target}`, '--publish', 'never', '--config', configPath],
@@ -33,3 +53,5 @@ const artifactName = target === 'mac'
if (!fs.existsSync(path.join(__dirname, '..', artifactName))) {
process.exit(result.status || 1)
}
cleanupBlockmapFiles(target)