-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelectron-builder.conf.js
118 lines (114 loc) · 3.72 KB
/
electron-builder.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const cp = require('child_process');
const fs = require('fs');
const packageJson = require('./package.json');
require('dotenv').config();
const { notarize } = require('@electron/notarize');
/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
module.exports = {
artifactName: '${name}_v${version}_${os}_${arch}.${ext}',
appId: 'fr.inria.epoc-editor',
productName: 'ePoc Editor',
copyright: 'Copyright © 2022 ${author}',
buildNumber: cp.execSync('git rev-parse --short HEAD').toString().trim(),
publish: {
provider: 'github',
repo: 'epoc-editor',
owner: 'inrialearninglab',
releaseType: 'draft'
},
mac: {
category: 'public.app-category.utilities',
identity: process.env.APPLE_SIGNING_ID,
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: './entitlements.plist',
entitlementsInherit: './entitlements.plist',
},
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true
},
files: [
'dist/**/*',
'electron/**/*'
],
directories: {
buildResources: 'assets',
output: 'dist_electron'
},
extraMetadata: {
// Get the most recent git tag otherwise use the version from package.json
version: tcDefault(() => { cp.execSync('git describe --tags --abbrev=0', { stdio: [] }).toString().trim(); }, packageJson.version)
},
extraResources: [
{from: 'public/preview.zip', to: 'preview.zip'}
],
beforePack: async (context) => {
// Write an appInfo file to be used in prod
const appInfo = {
description: context.packager.appInfo.description,
version: context.packager.appInfo.version,
buildNumber: context.packager.appInfo.buildNumber,
buildVersion: context.packager.appInfo.buildVersion,
productName: context.packager.appInfo.productName
};
fs.writeFileSync('dist/appInfo.json', JSON.stringify(appInfo, null, 2));
},
fileAssociations: [
{
ext: 'epoc',
name: 'ePoc',
description: 'ePoc publication',
mimeType: 'application/zip',
role: 'Mobile Application',
isPackage: false,
rank: 'Default',
icon: 'assets/icon-mobile.png'
},
{
ext: 'epocproject',
name: 'ePoc Project',
description: 'ePoc project content package',
mimeType: 'application/zip',
role: 'Editor',
isPackage: false,
rank: 'Default',
}
],
afterSign: async (context) => {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== 'darwin' || process.env.NO_NOTARIZE) {
return;
}
const appName = context.packager.appInfo.productFilename;
try {
return await notarize({
tool: 'notarytool',
appBundleId: 'fr.inria.epoc-editor',
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
ascProvider: process.env.APPLE_ASC
});
} catch (e) {
console.log('Could not notarize');
}
}
};
/**
* Try catch the execution of a function and return the default value in case of errors
* @param func the function to be catched
* @param def the default value in case of an error
* @returns {*}
*/
function tcDefault(func, def) {
try {
return func();
} catch {
return def;
}
}