Skip to content

Commit aab1e24

Browse files
committed
Update dependencies and scripts.
1 parent 71abcfc commit aab1e24

File tree

7 files changed

+6740
-5391
lines changed

7 files changed

+6740
-5391
lines changed

package-lock.json

Lines changed: 6617 additions & 5240 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,77 +13,78 @@
1313
"build": "npm run version:up && concurrently \"npm run build:main\" \"npm run build:renderer\"",
1414
"build:main": "cross-env NODE_ENV=production webpack --config scripts/webpack.main.prod.config.js",
1515
"build:renderer": "cross-env APP_ROOT=src/renderer umi build",
16-
"make": "node scripts/make.js"
16+
"make": "node scripts/make.js",
17+
"make:dev": "cross-env SKIP_NOTARIZATION=1 cross-env MAKE_FOR=dev npm run make"
1718
},
1819
"dependencies": {
19-
"axios": "^0.21.1",
20-
"compare-versions": "^3.6.0",
21-
"dayjs": "^1.10.6",
20+
"axios": "^0.24.0",
21+
"compare-versions": "^4.1.2",
22+
"dayjs": "^1.10.7",
2223
"electron-window-state": "^5.0.3",
23-
"express": "^4.17.1",
24+
"express": "^4.17.2",
2425
"lodash": "^4.17.21",
2526
"md5": "^2.3.0",
2627
"md5-file": "^5.0.0",
2728
"mkdirp": "^1.0.4",
28-
"potdb": "^2.0.4",
29+
"potdb": "^2.2.2",
30+
"tslib": "^2.3.1",
2931
"uuid": "^8.3.2"
3032
},
3133
"devDependencies": {
32-
"@babel/plugin-proposal-class-properties": "^7.14.5",
33-
"@babel/plugin-proposal-decorators": "^7.14.5",
34-
"@babel/preset-env": "^7.15.0",
35-
"@babel/preset-typescript": "^7.15.0",
36-
"@chakra-ui/icons": "^1.0.15",
37-
"@chakra-ui/react": "^1.6.6",
38-
"@emotion/react": "^11.4.1",
39-
"@emotion/styled": "^11.3.0",
40-
"@types/assert": "^1.5.5",
41-
"@types/codemirror": "^5.60.2",
34+
"@babel/plugin-proposal-class-properties": "^7.16.5",
35+
"@babel/plugin-proposal-decorators": "^7.16.5",
36+
"@babel/preset-env": "^7.16.5",
37+
"@babel/preset-typescript": "^7.16.5",
38+
"@chakra-ui/icons": "^1.1.1",
39+
"@chakra-ui/react": "^1.7.3",
40+
"@emotion/react": "^11.7.1",
41+
"@emotion/styled": "^11.6.0",
42+
"@types/assert": "^1.5.6",
43+
"@types/codemirror": "^5.60.5",
4244
"@types/express": "^4.17.13",
43-
"@types/lodash": "^4.14.172",
45+
"@types/lodash": "^4.14.178",
4446
"@types/md5": "^2.3.1",
4547
"@types/mkdirp": "^1.0.2",
4648
"@types/mocha": "^9.0.0",
47-
"@types/node": "^15.6.1",
48-
"@types/react": "^17.0.19",
49-
"@types/react-dom": "^17.0.9",
49+
"@types/node": "^17.0.0",
50+
"@types/react": "^17.0.37",
51+
"@types/react-dom": "^17.0.11",
5052
"@types/react-virtualized-auto-sizer": "^1.0.1",
5153
"@types/react-window": "^1.8.5",
52-
"@types/uuid": "^8.3.1",
53-
"@umijs/preset-react": "1.x",
54-
"@umijs/test": "^3.5.17",
55-
"ahooks": "^2.10.9",
56-
"babel-loader": "^8.2.2",
54+
"@types/uuid": "^8.3.3",
55+
"@umijs/preset-react": "2.x",
56+
"@umijs/test": "^3.5.20",
57+
"ahooks": "^3.0.5",
58+
"babel-loader": "^8.2.3",
5759
"clsx": "^1.1.1",
58-
"codemirror": "^5.62.3",
59-
"concurrently": "^6.2.1",
60-
"copy-webpack-plugin": "^9.0.1",
60+
"codemirror": "^5.64.0",
61+
"concurrently": "^6.5.0",
62+
"copy-webpack-plugin": "^10.2.0",
6163
"cross-env": "^7.0.3",
6264
"dotenv": "^10.0.0",
63-
"electron": "^13.2.1",
64-
"electron-builder": "^22.10.5",
65-
"electron-notarize": "^1.1.0",
65+
"electron": "^16.0.5",
66+
"electron-builder": "^22.14.5",
67+
"electron-notarize": "^1.1.1",
6668
"espower-typescript": "^10.0.0",
67-
"execa": "^5.1.1",
68-
"fork-ts-checker-webpack-plugin": "^6.3.2",
69-
"framer-motion": "^4.1.17",
69+
"execa": "^6.0.0",
70+
"fork-ts-checker-webpack-plugin": "^6.5.0",
7071
"fs-extra": "^10.0.0",
71-
"mocha": "^9.1.0",
72+
"mocha": "^9.1.3",
7273
"power-assert": "^1.6.1",
73-
"prettier": "^2.3.2",
74+
"prettier": "^2.5.1",
7475
"pretty-bytes": "^5.6.0",
7576
"react": "^17.0.2",
7677
"react-dom": "^17.0.2",
77-
"react-icons": "^4.2.0",
78+
"react-icons": "^4.3.1",
7879
"react-virtualized-auto-sizer": "^1.0.6",
7980
"react-window": "^1.8.6",
8081
"smooth-scroll-into-view-if-needed": "^1.1.32",
81-
"ts-node": "^10.2.1",
82-
"tsconfig-paths-webpack-plugin": "^3.5.1",
83-
"typescript": "^4.3.5",
84-
"umi": "^3.5.17",
85-
"webpack": "^5.51.1",
86-
"webpack-cli": "^4.8.0",
82+
"ts-node": "^10.4.0",
83+
"tsconfig-paths-webpack-plugin": "^3.5.2",
84+
"typescript": "^4.5.4",
85+
"umi": "^3.5.20",
86+
"webpack": "^5.65.0",
87+
"webpack-cli": "^4.9.1",
8788
"webpack-merge": "^5.8.0",
8889
"webpack-node-externals": "^3.0.0",
8990
"yorkie": "^2.0.0"

scripts/libs/my_exec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { spawn } = require('child_process')
2+
3+
module.exports = function myExec(cmd, ...args) {
4+
return new Promise((resolve, reject) => {
5+
const run = spawn(cmd, args)
6+
7+
let out = ''
8+
9+
run.stdout.on('data', (data) => {
10+
console.log(`[stdout]: ${data.toString().trimEnd()}`)
11+
out += data.toString()
12+
})
13+
14+
run.stderr.on('data', (data) => {
15+
console.log(`[stderr]: ${data.toString().trimEnd()}`)
16+
})
17+
18+
run.on('exit', function (code) {
19+
console.log('child process exited with code ' + code.toString())
20+
if (code === 0) {
21+
resolve(out)
22+
} else {
23+
reject(code)
24+
}
25+
})
26+
})
27+
}

scripts/make.js

Lines changed: 39 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77
require('dotenv').config()
88
const version = require('../src/version.json')
99
const builder = require('electron-builder')
10-
const execa = require('execa')
10+
const myExec = require('./libs/my_exec')
1111
const fse = require('fs-extra')
1212
const homedir = require('os').homedir()
1313
const path = require('path')
1414

1515
const root_dir = path.normalize(path.join(__dirname, '..'))
1616
const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
1717

18-
const electronLanguages = ['en', 'zh_CN']
18+
const electronLanguages = ['en', 'fr', 'zh_CN']
1919

2020
const 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-
7453
const 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

Comments
 (0)