-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron-builder.mjs
More file actions
81 lines (69 loc) · 2 KB
/
electron-builder.mjs
File metadata and controls
81 lines (69 loc) · 2 KB
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
import pkg from './package.json' with { type: 'json' };
import mapWorkspaces from '@npmcli/map-workspaces';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import os from 'node:os';
/** @type import('electron-builder').Configuration */
const platformSpecificConfig = {}
switch (os.platform()) {
case "linux":
platformSpecificConfig.linux = {
target: ['deb', 'AppImage'],
icon: "buildResources",
}
break;
case "darwin":
if (os.arch() == "x64") {
platformSpecificConfig.mac = {
identity: null,
target: [
{ target: "dmg", arch: ["x64"] },
{ target: "zip", arch: ["x64"] },
],
icon: "buildResources/icon.icns",
}
} else if (os.arch() == "arm64") {
// uses the default config for now
}
break;
case "win32":
// uses the default config for now
break;
}
export default /** @type import('electron-builder').Configuration */
({
...platformSpecificConfig,
directories: {
output: 'dist',
buildResources: 'buildResources',
},
asarUnpack: [
"node_modules/@dbmate/**",
"node_modules/@app/main/dist/migrations/**",
],
generateUpdatesFilesForAllChannels: true,
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
files: [
'LICENSE*',
pkg.main,
...await getListOfFilesFromEachWorkspace(),
],
});
async function getListOfFilesFromEachWorkspace() {
/**
* @type {Map<string, string>}
*/
const workspaces = await mapWorkspaces({
cwd: process.cwd(),
pkg,
});
const allFilesToInclude = [];
for (const [name, path] of workspaces) {
const pkgPath = join(path, 'package.json');
const { default: workspacePkg } = await import(pathToFileURL(pkgPath), { with: { type: 'json' } });
let patterns = workspacePkg.files || ['dist/**', 'package.json'];
patterns = patterns.map(p => join('node_modules', name, p));
allFilesToInclude.push(...patterns);
}
return allFilesToInclude;
}