-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdist.js
executable file
·151 lines (131 loc) · 3.83 KB
/
dist.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* eslint-disable no-console */
const path = require('path');
const fs = require('fs-extra');
const builder = require('electron-builder');
const { Platform } = builder;
console.log(`Machine: ${process.platform}`);
Promise.resolve()
.then(() => {
let targets;
if (process.env.NODE_ENV === 'production') {
targets = Platform.MAC.createTarget();
} else {
targets = Platform.MAC.createTarget(['dir']);
}
// const asarUnpack = [
// ...asarUnpackedMainDependencies.map(name => `node_modules/${name}/**/*`),
// 'build/libs/install-app-async/script.js',
// ];
// console.log('Unpack these files from asar: ');
// asarUnpack.forEach(name => console.log(name));
const opts = {
targets,
config: {
appId: 'com.webcatalog.resurrected',
// asar: true,
asar: false,
// asarUnpack,
files: [
'!docs/**/*',
'!tests/**/*',
],
directories: {
buildResources: 'build-resources',
},
mac: {
category: 'public.app-category.utilities',
extendInfo: {
CFBundleURLTypes: [
{
CFBundleURLName: 'com.webcatalog.app.launch',
CFBundleURLSchemes: [
'webcatalog',
],
},
],
},
},
dmg: {
icon: 'build-resources/installerIcon.icns',
background: 'build-resources/background.tiff',
iconSize: 100,
contents: [
{
x: 164,
y: 182,
},
{
x: 383,
y: 182,
type: 'link',
path: '/Applications',
},
],
window: {
x: 550,
y: 315,
},
},
afterPack: ({ appOutDir }) => {
console.log('appOutDir:', appOutDir);
const resourcesAppPath = process.platform === 'darwin'
? path.join(
appOutDir,
'WebCatalog.app',
'Contents',
'Resources',
'app',
)
: path.join(
appOutDir,
'resources',
'app',
);
const sourceNodeModulesPath = path.join(
__dirname,
'node_modules', 'appifier', 'app', 'node_modules',
);
const destNodeModulesPath = path.join(
resourcesAppPath,
'node_modules',
'appifier', 'app', 'node_modules',
);
const sourceElectronIconPath = path.join(
__dirname,
'electron-icon.png',
);
const destElectronIconPath = path.join(
resourcesAppPath,
'electron-icon.png',
);
const widevineLibDir = path.join(
destNodeModulesPath,
'electron-widevinecdm', 'widevine',
);
console.log('Copying additional files...');
return fs.copy(sourceElectronIconPath, destElectronIconPath)
.then(() => fs.copy(sourceNodeModulesPath, destNodeModulesPath))
.then(() => fs.readdir(widevineLibDir))
.then((dirs) => {
const acceptedName = `${process.platform}_${process.arch}`;
const p = dirs.map((dir) => {
if (dir !== acceptedName) {
console.log(`Removing node_modules/electron-widevinecdm/widevine/${dir}`);
return fs.remove(path.join(widevineLibDir, dir));
}
return null;
});
return Promise.all(p);
});
},
},
};
return builder.build(opts);
})
.then(() => {
console.log('build successful');
})
.catch((err) => {
console.log(err);
process.exit(1);
});