-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(project): correctly pack app to zip on MacOS
As of `[email protected]`, the built zip files has been incorrect. On the other hand, older versions of `electron-builder` are unable to build application on MacOS 10.15 Catalina. Due to above, this commit removes `zip` from MacOS targets and adds a script that adds the built application to a correct zip archive. Related electron-userland/electron-builder#3534 Closes #1529
- Loading branch information
Showing
3 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
module.exports = async function(context) { | ||
|
||
const handlers = [ | ||
require('./after-all-artifact-build/build-mac-zip') | ||
]; | ||
|
||
let result = []; | ||
|
||
for (const handler of handlers) { | ||
const additionalArtifacts = await handler(context); | ||
|
||
if (additionalArtifacts) { | ||
result = result.concat(...additionalArtifacts); | ||
} | ||
} | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
const exec = require('execa').sync; | ||
|
||
const del = require('del').sync; | ||
|
||
const path = require('path'); | ||
|
||
/** | ||
* Build zip artifact for MacOS since electron-builder breaks zips | ||
* | ||
* @param {import('electron-builder').BuildResult} context | ||
* | ||
* @return {Promise<any>} | ||
*/ | ||
module.exports = async function(context) { | ||
|
||
if (!isBuildingMacDistro(context)) { | ||
return; | ||
} | ||
|
||
const { | ||
artifactPaths, | ||
configuration, | ||
outDir | ||
} = context; | ||
|
||
const { | ||
productName | ||
} = configuration; | ||
|
||
const dmgPath = artifactPaths.find(path => /\.dmg$/.test(path)); | ||
const zipPath = dmgPath.replace(/dmg$/, 'zip'); | ||
|
||
const appDir = path.join(outDir, 'mac'); | ||
|
||
console.log(` • building target=ZIP arch=x64 file=${zipPath}`); | ||
|
||
del(zipPath); | ||
|
||
exec('zip', [ '--symlinks', '-r', zipPath, `${productName}.app` ], { cwd: appDir }); | ||
|
||
// TODO: update dist/latest-mac.yml with blockmap information | ||
// As of `[email protected]`, the `app-builder-bin` blockmap utility | ||
// modifies the digested ZIP file and thus makes the central record directory broken. | ||
|
||
return [ zipPath ]; | ||
}; | ||
|
||
|
||
function isBuildingMacDistro(context) { | ||
const { | ||
platformToTargets | ||
} = context; | ||
|
||
for (const platform of platformToTargets.keys()) { | ||
if (platform.name === 'mac') { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} |