7
7
require ( 'dotenv' ) . config ( )
8
8
const version = require ( '../src/version.json' )
9
9
const builder = require ( 'electron-builder' )
10
- const execa = require ( 'execa ' )
10
+ const myExec = require ( './libs/my_exec ' )
11
11
const fse = require ( 'fs-extra' )
12
12
const homedir = require ( 'os' ) . homedir ( )
13
13
const path = require ( 'path' )
14
14
15
15
const root_dir = path . normalize ( path . join ( __dirname , '..' ) )
16
16
const dist_dir = path . normalize ( path . join ( __dirname , '..' , 'dist' ) )
17
17
18
- const electronLanguages = [ 'en' , 'zh_CN' ]
18
+ const electronLanguages = [ 'en' , 'fr' , ' zh_CN']
19
19
20
20
const TARGET_PLATFORMS_configs = {
21
21
mac : {
22
22
mac : [ 'default' ] ,
23
23
} ,
24
- mas : {
25
- mac : [ 'mas' ] ,
26
- } ,
27
24
macs : {
28
- mac : [ 'default ' , 'mas ' ] ,
25
+ mac : [ 'dmg:x64 ' , 'dmg:arm64 ' ] ,
29
26
} ,
30
27
win : {
31
- win : [ 'nsis:ia32' , 'portable:ia32' ] ,
28
+ win : [ 'nsis:ia32' , 'nsis:x64' , ' portable:ia32'] ,
32
29
} ,
33
30
all : {
34
- mac : [ 'default ' ] ,
35
- linux : [ /*'zip:x64', */ 'AppImage:x64' , 'deb:x64' ] ,
31
+ mac : [ 'dmg:x64' , 'dmg:arm64 '] ,
32
+ linux : [ 'AppImage:x64' , 'deb:x64' ] ,
36
33
win : [ 'nsis:ia32' , 'nsis:x64' , 'portable:ia32' ] ,
37
34
} ,
38
35
}
@@ -53,24 +50,6 @@ const cfg_common = {
53
50
} ,
54
51
}
55
52
56
- const sign = async ( ) => {
57
- console . log ( '-> to sign...' )
58
- let wd = process . cwd ( )
59
- process . chdir ( __dirname )
60
-
61
- let cmd = path . join ( __dirname , 'sign-mac.sh' )
62
- try {
63
- const { stdout } = await execa ( cmd )
64
- console . log ( stdout )
65
- } catch ( e ) {
66
- //console.error(e)
67
- console . log ( e . stdout )
68
- console . error ( e . stderr )
69
- }
70
-
71
- process . chdir ( wd )
72
- }
73
-
74
53
const beforeMake = async ( ) => {
75
54
console . log ( '-> beforeMake...' )
76
55
fse . removeSync ( dist_dir )
@@ -105,79 +84,27 @@ const afterMake = async () => {
105
84
console . log ( '-> afterMake...' )
106
85
}
107
86
108
- const makeMacArm = async ( ) => {
109
- console . log ( '-> makeMacArm...' )
110
-
111
- await builder . build ( {
112
- config : {
113
- ...cfg_common ,
114
- appId : 'SwitchHosts' ,
115
- productName : APP_NAME ,
116
- mac : {
117
- target : [
118
- {
119
- target : 'dmg' ,
120
- arch : [
121
- //'x64',
122
- 'arm64' ,
123
- ] ,
124
- } ,
125
- ] ,
126
- category : 'public.app-category.productivity' ,
127
- icon : 'assets/app.icns' ,
128
- gatekeeperAssess : false ,
129
- electronLanguages,
130
- identity : IDENTITY ,
131
- hardenedRuntime : true ,
132
- entitlements : 'scripts/entitlements.mac.plist' ,
133
- entitlementsInherit : 'scripts/entitlements.mac.plist' ,
134
- provisioningProfile : 'scripts/app.provisionprofile' ,
135
- artifactName : '${productName}_arm64_${version}(${buildVersion}).${ext}' ,
136
- } ,
137
- dmg : {
138
- //backgroundColor: '#f1f1f6',
139
- background : 'assets/dmg-bg.png' ,
140
- //icon: 'assets/dmg-icon.icns',
141
- iconSize : 160 ,
142
- window : {
143
- width : 600 ,
144
- height : 420 ,
145
- } ,
146
- contents : [
147
- {
148
- x : 150 ,
149
- y : 200 ,
150
- } ,
151
- {
152
- x : 450 ,
153
- y : 200 ,
154
- type : 'link' ,
155
- path : '/Applications' ,
156
- } ,
157
- ] ,
158
- sign : false ,
159
- artifactName : '${productName}_arm64_${version}(${buildVersion}).${ext}' ,
160
- } ,
161
- } ,
162
- } )
163
-
164
- console . log ( 'done!' )
165
- }
87
+ const doMake = async ( ) => {
88
+ console . log ( '-> make...' )
166
89
167
- const makeDefault = async ( ) => {
168
- console . log ( '-> makeDefault...' )
169
- // forFullVersion.task(APP_NAME)
90
+ let targets = TARGET_PLATFORMS_configs . all
91
+ if ( process . env . MAKE_FOR === 'dev' ) {
92
+ targets = TARGET_PLATFORMS_configs . macs
93
+ } else if ( process . env . MAKE_FOR === 'mac' ) {
94
+ targets = TARGET_PLATFORMS_configs . mac
95
+ } else if ( process . env . MAKE_FOR === 'win' ) {
96
+ targets = TARGET_PLATFORMS_configs . win
97
+ }
170
98
171
99
await builder . build ( {
172
100
//targets: Platform.MAC.createTarget(),
173
- //...TARGET_PLATFORMS_configs.mac,
174
- //...TARGET_PLATFORMS_configs.win,
175
- ...TARGET_PLATFORMS_configs . all ,
101
+ ...targets ,
176
102
config : {
177
103
...cfg_common ,
178
104
appId : 'SwitchHosts' ,
179
105
productName : APP_NAME ,
180
106
mac : {
107
+ type : 'distribution' ,
181
108
category : 'public.app-category.productivity' ,
182
109
icon : 'assets/app.icns' ,
183
110
gatekeeperAssess : false ,
@@ -187,7 +114,11 @@ const makeDefault = async () => {
187
114
entitlements : 'scripts/entitlements.mac.plist' ,
188
115
entitlementsInherit : 'scripts/entitlements.mac.plist' ,
189
116
provisioningProfile : 'scripts/app.provisionprofile' ,
190
- artifactName : '${productName}_${version}(${buildVersion}).${ext}' ,
117
+ extendInfo : {
118
+ ITSAppUsesNonExemptEncryption : false ,
119
+ CFBundleLocalizations : electronLanguages ,
120
+ CFBundleDevelopmentRegion : 'en' ,
121
+ } ,
191
122
} ,
192
123
dmg : {
193
124
//backgroundColor: '#f1f1f6',
@@ -211,7 +142,8 @@ const makeDefault = async () => {
211
142
} ,
212
143
] ,
213
144
sign : false ,
214
- artifactName : '${productName}_${version}(${buildVersion}).${ext}' ,
145
+ artifactName :
146
+ '${productName}_mac_${arch}_${version}(${buildVersion}).${ext}' ,
215
147
} ,
216
148
win : {
217
149
icon : 'assets/app.ico' ,
@@ -222,16 +154,23 @@ const makeDefault = async () => {
222
154
oneClick : false ,
223
155
allowToChangeInstallationDirectory : true ,
224
156
artifactName :
225
- '${productName}_installer_${version}(${buildVersion}).${ext}' ,
157
+ '${productName}_installer_${arch}_${ version}(${buildVersion}).${ext}' ,
226
158
} ,
227
159
portable : {
228
160
artifactName :
229
- '${productName}_portable_${version}(${buildVersion}).${ext}' ,
161
+ '${productName}_portable_${arch}_${ version}(${buildVersion}).${ext}' ,
230
162
} ,
231
163
linux : {
232
164
icon : 'assets/app.png' ,
233
- artifactName : '${productName}_linux_${version}(${buildVersion}).${ext}' ,
234
- category : 'Office' ,
165
+ artifactName :
166
+ '${productName}_linux_${arch}_${version}(${buildVersion}).${ext}' ,
167
+ category : 'Utility' ,
168
+ synopsis : 'An App for hosts management and switching.' ,
169
+ desktop : {
170
+ Name : 'SwitchHosts' ,
171
+ Type : 'Application' ,
172
+ GenericName : 'An App for hosts management and switching.' ,
173
+ } ,
235
174
} ,
236
175
} ,
237
176
} )
@@ -242,15 +181,10 @@ const makeDefault = async () => {
242
181
; ( async ( ) => {
243
182
try {
244
183
await beforeMake ( )
245
-
246
- await makeMacArm ( )
247
- await makeDefault ( )
248
-
184
+ await doMake ( )
249
185
await afterMake ( )
250
- await sign ( )
251
-
252
- console . log ( '-> meke Done!' )
186
+ console . log ( '-> make Done!' )
253
187
} catch ( e ) {
254
- console . log ( e )
188
+ console . error ( e )
255
189
}
256
190
} ) ( )
0 commit comments