-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the electron builder config from yaml to js file
Having a js file will enable further customization of the build process. That capability will be used notably for #6535 to download `WinFSP` installer when building the Windows installer.
- Loading branch information
1 parent
b35f511
commit a913d42
Showing
4 changed files
with
141 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,115 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
const builder = require('electron-builder'); | ||
|
||
/** | ||
* @returns {{ | ||
* mode: 'test' | 'prod', | ||
* platform: 'linux' | 'win32' | 'darwin', | ||
* }} | ||
*/ | ||
function cli() { | ||
const { Command, Option } = require('commander'); | ||
const program = new Command(); | ||
|
||
program.name('electron-packager').description('Package the electron app'); | ||
|
||
program.addOption(new Option('--mode <mode>', 'package mode').choices(['test', 'prod']).default('test').makeOptionMandatory(true)); | ||
program.addOption( | ||
new Option('--platform <platform>', 'Build electron for <platform>') | ||
.choices(['linux', 'win32', 'darwin']) | ||
.default(process.platform) | ||
.makeOptionMandatory(true), | ||
); | ||
|
||
program.parse(); | ||
return program.opts(); | ||
} | ||
|
||
/** | ||
* @param {string} platform | ||
* @return {Map<builder.Platform, Map<builder.Arch, string[]>>} | ||
*/ | ||
function getBuildTargets(platform) { | ||
switch (platform) { | ||
case 'linux': | ||
return builder.Platform.LINUX.createTarget(); | ||
case 'darwin': | ||
return builder.Platform.MAC.createTarget(); | ||
case 'win32': | ||
return builder.Platform.WINDOWS.createTarget(); | ||
default: | ||
throw new Error(`Unknown platform: ${platform}`); | ||
} | ||
} | ||
const OPTS = cli(); | ||
console.debug(OPTS); | ||
|
||
const BUILD_TARGETS = getBuildTargets(OPTS.platform); | ||
console.log('BUILD_TARGETS', BUILD_TARGETS); | ||
|
||
const PARSEC_SCHEME = 'parsec3'; | ||
|
||
/** | ||
* @type {import('electron-builder').Configuration} | ||
* @see https://www.electron.build/configuration/configuration | ||
*/ | ||
const options = { | ||
appId: 'cloud.parsec.parsec-v3', | ||
protocols: { | ||
name: 'Parsec-v3', | ||
schemes: [PARSEC_SCHEME], | ||
}, | ||
|
||
compression: OPTS.mode === 'test' ? 'store' : 'normal', | ||
|
||
directories: { | ||
buildResources: 'assets', | ||
}, | ||
|
||
files: ['assets/**/*', 'build/**/*', 'app/**/*'], | ||
|
||
publish: { | ||
provider: 'github', | ||
}, | ||
|
||
nsis: { | ||
allowElevation: true, | ||
oneClick: false, | ||
allowToChangeInstallationDirectory: true, | ||
}, | ||
|
||
win: { | ||
target: 'nsis', | ||
}, | ||
|
||
mac: { | ||
target: 'dmg', | ||
category: 'public.app-category.productivity', | ||
}, | ||
|
||
linux: { | ||
synopsis: 'Secure cloud framework', | ||
description: 'Parsec is an open-source cloud-based application that allow simple yet cryptographically secure file hosting.', | ||
category: 'Office Network FileTransfer FileSystem Security', | ||
desktop: { | ||
MimeType: `x-scheme-handler/${PARSEC_SCHEME}`, | ||
}, | ||
target: 'snap', | ||
}, | ||
|
||
snap: { | ||
base: 'core22', | ||
grade: 'devel', | ||
allowNativeWayland: true, | ||
stagePackages: ['default', 'fuse3'], | ||
}, | ||
|
||
extends: null, | ||
}; | ||
|
||
builder.build({ | ||
targets: BUILD_TARGETS, | ||
publish: 'never', | ||
config: options, | ||
}); |
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