1
1
/**
2
- * make
2
+ * make.js
3
3
* @author : oldj
4
4
* @homepage : https://oldj.net
5
5
*/
6
6
7
7
require ( 'dotenv' ) . config ( )
8
+ const path = require ( 'path' )
9
+ const fse = require ( 'fs-extra' )
8
10
const version = require ( '../src/version.json' )
9
11
const builder = require ( 'electron-builder' )
10
- const fse = require ( 'fs-extra' )
11
12
const homedir = require ( 'os' ) . homedir ( )
12
- const path = require ( 'path' )
13
-
14
- const root_dir = path . normalize ( path . join ( __dirname , '..' ) )
15
- const dist_dir = path . normalize ( path . join ( __dirname , '..' , 'dist' ) )
16
-
17
- const electronLanguages = [ 'en' , 'fr' , 'zh_CN' , 'de' , 'ja' , 'tr' , 'ko' ]
13
+ const { APP_NAME , root_dir, dist_dir, electronLanguages } = require ( './vars' )
18
14
19
15
const TARGET_PLATFORMS_configs = {
20
16
mac : {
21
- mac : [ 'default' ] ,
22
- } ,
23
- macs : {
24
17
mac : [ 'dmg:x64' , 'dmg:arm64' ] ,
25
18
} ,
26
- linux : {
27
- linux : [
28
- 'AppImage:x64' ,
29
- 'deb:x64' ,
30
- 'AppImage:arm64' ,
31
- 'deb:arm64' ,
32
- 'AppImage:armv7l' ,
33
- 'deb:armv7l' ,
34
- ] ,
35
- } ,
36
19
win : {
37
- win : [ 'nsis:ia32' , 'nsis:x64' , 'portable:ia32' ] ,
20
+ win : [ 'nsis:ia32' , 'nsis:x64' , 'nsis:arm64' , 'portable:x64' ] ,
21
+ } ,
22
+ linux : {
23
+ linux : [ 'AppImage:x64' , 'AppImage:arm64' , 'deb:x64' , 'deb:arm64' ] ,
38
24
} ,
39
25
all : {
40
- mac : [ 'dmg:x64' , 'dmg:arm64' ] ,
41
- linux : [
42
- 'AppImage:x64' ,
43
- 'deb:x64' ,
44
- 'AppImage:arm64' ,
45
- 'deb:arm64' ,
46
- 'AppImage:armv7l' ,
47
- 'deb:armv7l' ,
48
- ] ,
49
- win : [ 'nsis:ia32' , 'nsis:x64' , 'portable:ia32' ] ,
26
+ mac : [ 'dmg:x64' , 'dmg:arm64' , 'zip:universal' ] ,
27
+ win : [ 'nsis:ia32' , 'nsis:x64' , 'nsis:arm64' , 'portable:x64' , 'zip:x64' /* , 'appx:x64'*/ ] ,
28
+ linux : [ 'AppImage:x64' , 'AppImage:arm64' , 'deb:x64' , 'deb:arm64' ] ,
50
29
} ,
51
30
}
52
31
53
- const APP_NAME = 'SwitchHosts'
54
- const { IDENTITY } = process . env
32
+ const { APP_BUNDLE_ID , IDENTITY } = process . env
33
+ console . log ( `APP_BUNDLE_ID: ${ APP_BUNDLE_ID } ` )
55
34
56
35
const cfg_common = {
57
36
copyright : `Copyright © ${ new Date ( ) . getFullYear ( ) } ` ,
@@ -62,8 +41,9 @@ const cfg_common = {
62
41
} ,
63
42
electronDownload : {
64
43
cache : path . join ( homedir , '.electron' ) ,
65
- mirror : 'https://npm.taobao.org/mirrors /electron/' ,
44
+ mirror : 'https://registry.npmmirror.com/-/binary /electron/' ,
66
45
} ,
46
+ asar : true ,
67
47
}
68
48
69
49
const beforeMake = async ( ) => {
@@ -104,14 +84,12 @@ const doMake = async () => {
104
84
let targets = TARGET_PLATFORMS_configs . all
105
85
106
86
cfg_common . compression = 'maximum'
107
- if ( MAKE_FOR && MAKE_FOR !== 'all' ) {
108
- cfg_common . compression = 'store'
109
- }
110
87
111
88
if ( MAKE_FOR === 'dev' ) {
112
89
targets = TARGET_PLATFORMS_configs . mac
90
+ cfg_common . compression = 'store'
113
91
} else if ( MAKE_FOR === 'mac' ) {
114
- targets = TARGET_PLATFORMS_configs . macs
92
+ targets = TARGET_PLATFORMS_configs . mac
115
93
} else if ( MAKE_FOR === 'win' ) {
116
94
targets = TARGET_PLATFORMS_configs . win
117
95
} else if ( MAKE_FOR === 'linux' ) {
@@ -140,6 +118,7 @@ const doMake = async () => {
140
118
CFBundleLocalizations : electronLanguages ,
141
119
CFBundleDevelopmentRegion : 'en' ,
142
120
} ,
121
+ notarize : false ,
143
122
} ,
144
123
dmg : {
145
124
//backgroundColor: '#f1f1f6',
@@ -173,6 +152,8 @@ const doMake = async () => {
173
152
installerIcon : 'assets/installer-icon.ico' ,
174
153
oneClick : false ,
175
154
allowToChangeInstallationDirectory : true ,
155
+ deleteAppDataOnUninstall : false ,
156
+ shortcutName : 'SwitchHosts' ,
176
157
artifactName : '${productName}_windows_installer_${arch}_${version}(${buildVersion}).${ext}' ,
177
158
} ,
178
159
portable : {
@@ -205,8 +186,10 @@ const doMake = async () => {
205
186
await beforeMake ( )
206
187
await doMake ( )
207
188
await afterMake ( )
189
+ //await macSign()
190
+
208
191
console . log ( '-> make Done!' )
209
192
} catch ( e ) {
210
- console . error ( e )
193
+ console . log ( e )
211
194
}
212
195
} ) ( )
0 commit comments