diff --git a/scripts/electron-builder.config.cjs b/scripts/electron-builder.config.cjs index 019aa2c..04b31ae 100644 --- a/scripts/electron-builder.config.cjs +++ b/scripts/electron-builder.config.cjs @@ -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 } diff --git a/scripts/run-electron-builder.cjs b/scripts/run-electron-builder.cjs index 373c11e..20b60b9 100644 --- a/scripts/run-electron-builder.cjs +++ b/scripts/run-electron-builder.cjs @@ -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)