Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Stop a universal macOS build with its own message

Fei241106d7c529f9a4
diff --git a/app/scripts/before-pack.mjs b/app/scripts/before-pack.mjs
index 463eeced..05c6014f 100644
--- a/app/scripts/before-pack.mjs
+++ b/app/scripts/before-pack.mjs
@@ -8,14 +8,19 @@ const WHERE = {
}
/** @returns {string | undefined} why this Node cannot build an app for `target` */
-export function archProblem({ target, platform, host = process.arch }) {
+export function archProblem({ target, platform, host = process.arch, targets = [] }) {
+ // electron-builder packs a universal app one architecture at a time: the hook only sees the
+ // inner x64/arm64 builds, so a universal request is known from the requested targets.
+ if (target === 'universal' || targets.includes('universal')) return 'A universal app would need the native modules of both architectures. Build one app per architecture.'
if (target === host) return undefined
- if (target === 'universal') return 'A universal app would need the native modules of both architectures. Build one app per architecture.'
const where = WHERE[platform]?.[target] ?? `with an ${target} Node`
return `This Node runs on ${host}, so npm installed ${host} native modules, and an ${target} app with them would not start. Install the dependencies and build ${where}.`
}
export async function beforePack(context) {
- const problem = archProblem({ target: Arch[context.arch], platform: context.electronPlatformName })
+ const targets = []
+ for (const archToNames of context.packager?.packagerOptions?.targets?.values() ?? [])
+ for (const arch of archToNames.keys()) targets.push(Arch[arch])
+ const problem = archProblem({ target: Arch[context.arch], platform: context.electronPlatformName, targets })
if (problem !== undefined) throw new Error(problem)
}
diff --git a/app/test/before-pack.test.mjs b/app/test/before-pack.test.mjs
index eb3c0959..d1a70e15 100644
--- a/app/test/before-pack.test.mjs
+++ b/app/test/before-pack.test.mjs
@@ -20,6 +20,14 @@ test('a build for another architecture stops and says where to build it', async
await assert.rejects(beforePack({ arch: Arch[other], electronPlatformName: process.platform }), new RegExp(`an ${other} app with them would not start`))
})
+test('a requested universal build stops before packing either architecture', async () => {
+ // electron-builder's MacPackager.doUniversalPack packs x64 then arm64: the hook sees a concrete
+ // arch each time, and the universal request only shows in packager.packagerOptions.targets.
+ const packager = { packagerOptions: { targets: new Map([[{ nodeName: 'darwin' }, new Map([[Arch.universal, ['dmg']]])]]) } }
+ await assert.rejects(beforePack({ arch: Arch.x64, electronPlatformName: 'darwin', packager }), /Build one app per architecture\./)
+ await assert.rejects(beforePack({ arch: Arch.arm64, electronPlatformName: 'darwin', packager }), /Build one app per architecture\./)
+})
+
test('electron-builder runs the check before it packs', () => {
assert.match(readFileSync(new URL('../electron-builder.yml', import.meta.url), 'utf8'), /^beforePack: \.\/scripts\/before-pack\.mjs$/m)
})