77require ( 'dotenv' ) . config ( )
88const version = require ( '../src/version.json' )
99const builder = require ( 'electron-builder' )
10- const execa = require ( 'execa ' )
10+ const myExec = require ( './libs/my_exec ' )
1111const fse = require ( 'fs-extra' )
1212const homedir = require ( 'os' ) . homedir ( )
1313const path = require ( 'path' )
1414
1515const root_dir = path . normalize ( path . join ( __dirname , '..' ) )
1616const dist_dir = path . normalize ( path . join ( __dirname , '..' , 'dist' ) )
1717
18- const electronLanguages = [ 'en' , 'zh_CN' ]
18+ const electronLanguages = [ 'en' , 'fr' , ' zh_CN']
1919
2020const TARGET_PLATFORMS_configs = {
2121 mac : {
2222 mac : [ 'default' ] ,
2323 } ,
24- mas : {
25- mac : [ 'mas' ] ,
26- } ,
2724 macs : {
28- mac : [ 'default ' , 'mas ' ] ,
25+ mac : [ 'dmg:x64 ' , 'dmg:arm64 ' ] ,
2926 } ,
3027 win : {
31- win : [ 'nsis:ia32' , 'portable:ia32' ] ,
28+ win : [ 'nsis:ia32' , 'nsis:x64' , ' portable:ia32'] ,
3229 } ,
3330 all : {
34- mac : [ 'default ' ] ,
35- linux : [ /*'zip:x64', */ 'AppImage:x64' , 'deb:x64' ] ,
31+ mac : [ 'dmg:x64' , 'dmg:arm64 '] ,
32+ linux : [ 'AppImage:x64' , 'deb:x64' ] ,
3633 win : [ 'nsis:ia32' , 'nsis:x64' , 'portable:ia32' ] ,
3734 } ,
3835}
@@ -53,24 +50,6 @@ const cfg_common = {
5350 } ,
5451}
5552
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-
7453const beforeMake = async ( ) => {
7554 console . log ( '-> beforeMake...' )
7655 fse . removeSync ( dist_dir )
@@ -105,79 +84,27 @@ const afterMake = async () => {
10584 console . log ( '-> afterMake...' )
10685}
10786
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...' )
16689
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+ }
17098
17199 await builder . build ( {
172100 //targets: Platform.MAC.createTarget(),
173- //...TARGET_PLATFORMS_configs.mac,
174- //...TARGET_PLATFORMS_configs.win,
175- ...TARGET_PLATFORMS_configs . all ,
101+ ...targets ,
176102 config : {
177103 ...cfg_common ,
178104 appId : 'SwitchHosts' ,
179105 productName : APP_NAME ,
180106 mac : {
107+ type : 'distribution' ,
181108 category : 'public.app-category.productivity' ,
182109 icon : 'assets/app.icns' ,
183110 gatekeeperAssess : false ,
@@ -187,7 +114,11 @@ const makeDefault = async () => {
187114 entitlements : 'scripts/entitlements.mac.plist' ,
188115 entitlementsInherit : 'scripts/entitlements.mac.plist' ,
189116 provisioningProfile : 'scripts/app.provisionprofile' ,
190- artifactName : '${productName}_${version}(${buildVersion}).${ext}' ,
117+ extendInfo : {
118+ ITSAppUsesNonExemptEncryption : false ,
119+ CFBundleLocalizations : electronLanguages ,
120+ CFBundleDevelopmentRegion : 'en' ,
121+ } ,
191122 } ,
192123 dmg : {
193124 //backgroundColor: '#f1f1f6',
@@ -211,7 +142,8 @@ const makeDefault = async () => {
211142 } ,
212143 ] ,
213144 sign : false ,
214- artifactName : '${productName}_${version}(${buildVersion}).${ext}' ,
145+ artifactName :
146+ '${productName}_mac_${arch}_${version}(${buildVersion}).${ext}' ,
215147 } ,
216148 win : {
217149 icon : 'assets/app.ico' ,
@@ -222,16 +154,23 @@ const makeDefault = async () => {
222154 oneClick : false ,
223155 allowToChangeInstallationDirectory : true ,
224156 artifactName :
225- '${productName}_installer_${version}(${buildVersion}).${ext}' ,
157+ '${productName}_installer_${arch}_${ version}(${buildVersion}).${ext}' ,
226158 } ,
227159 portable : {
228160 artifactName :
229- '${productName}_portable_${version}(${buildVersion}).${ext}' ,
161+ '${productName}_portable_${arch}_${ version}(${buildVersion}).${ext}' ,
230162 } ,
231163 linux : {
232164 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+ } ,
235174 } ,
236175 } ,
237176 } )
@@ -242,15 +181,10 @@ const makeDefault = async () => {
242181; ( async ( ) => {
243182 try {
244183 await beforeMake ( )
245-
246- await makeMacArm ( )
247- await makeDefault ( )
248-
184+ await doMake ( )
249185 await afterMake ( )
250- await sign ( )
251-
252- console . log ( '-> meke Done!' )
186+ console . log ( '-> make Done!' )
253187 } catch ( e ) {
254- console . log ( e )
188+ console . error ( e )
255189 }
256190} ) ( )
0 commit comments