浏览代码

Update dependencies and scripts.

oldj 3 年之前
父节点
当前提交
aab1e2488c
共有 7 个文件被更改,包括 425 次插入421 次删除
  1. 302 270
      package-lock.json
  2. 44 43
      package.json
  3. 27 0
      scripts/libs/my_exec.js
  4. 39 105
      scripts/make.js
  5. 10 2
      scripts/notarize.js
  6. 2 0
      src/renderer/components/About/AboutContent.less
  7. 1 1
      src/version.json

文件差异内容过多而无法显示
+ 302 - 270
package-lock.json


+ 44 - 43
package.json

@@ -13,77 +13,78 @@
     "build": "npm run version:up && concurrently \"npm run build:main\" \"npm run build:renderer\"",
     "build:main": "cross-env NODE_ENV=production webpack --config scripts/webpack.main.prod.config.js",
     "build:renderer": "cross-env APP_ROOT=src/renderer umi build",
-    "make": "node scripts/make.js"
+    "make": "node scripts/make.js",
+    "make:dev": "cross-env SKIP_NOTARIZATION=1 cross-env MAKE_FOR=dev npm run make"
   },
   "dependencies": {
-    "axios": "^0.21.1",
-    "compare-versions": "^3.6.0",
-    "dayjs": "^1.10.6",
+    "axios": "^0.24.0",
+    "compare-versions": "^4.1.2",
+    "dayjs": "^1.10.7",
     "electron-window-state": "^5.0.3",
-    "express": "^4.17.1",
+    "express": "^4.17.2",
     "lodash": "^4.17.21",
     "md5": "^2.3.0",
     "md5-file": "^5.0.0",
     "mkdirp": "^1.0.4",
-    "potdb": "^2.0.4",
+    "potdb": "^2.2.2",
+    "tslib": "^2.3.1",
     "uuid": "^8.3.2"
   },
   "devDependencies": {
-    "@babel/plugin-proposal-class-properties": "^7.14.5",
-    "@babel/plugin-proposal-decorators": "^7.14.5",
-    "@babel/preset-env": "^7.15.0",
-    "@babel/preset-typescript": "^7.15.0",
-    "@chakra-ui/icons": "^1.0.15",
-    "@chakra-ui/react": "^1.6.6",
-    "@emotion/react": "^11.4.1",
-    "@emotion/styled": "^11.3.0",
-    "@types/assert": "^1.5.5",
-    "@types/codemirror": "^5.60.2",
+    "@babel/plugin-proposal-class-properties": "^7.16.5",
+    "@babel/plugin-proposal-decorators": "^7.16.5",
+    "@babel/preset-env": "^7.16.5",
+    "@babel/preset-typescript": "^7.16.5",
+    "@chakra-ui/icons": "^1.1.1",
+    "@chakra-ui/react": "^1.7.3",
+    "@emotion/react": "^11.7.1",
+    "@emotion/styled": "^11.6.0",
+    "@types/assert": "^1.5.6",
+    "@types/codemirror": "^5.60.5",
     "@types/express": "^4.17.13",
-    "@types/lodash": "^4.14.172",
+    "@types/lodash": "^4.14.178",
     "@types/md5": "^2.3.1",
     "@types/mkdirp": "^1.0.2",
     "@types/mocha": "^9.0.0",
-    "@types/node": "^15.6.1",
-    "@types/react": "^17.0.19",
-    "@types/react-dom": "^17.0.9",
+    "@types/node": "^17.0.0",
+    "@types/react": "^17.0.37",
+    "@types/react-dom": "^17.0.11",
     "@types/react-virtualized-auto-sizer": "^1.0.1",
     "@types/react-window": "^1.8.5",
-    "@types/uuid": "^8.3.1",
-    "@umijs/preset-react": "1.x",
-    "@umijs/test": "^3.5.17",
-    "ahooks": "^2.10.9",
-    "babel-loader": "^8.2.2",
+    "@types/uuid": "^8.3.3",
+    "@umijs/preset-react": "2.x",
+    "@umijs/test": "^3.5.20",
+    "ahooks": "^3.0.5",
+    "babel-loader": "^8.2.3",
     "clsx": "^1.1.1",
-    "codemirror": "^5.62.3",
-    "concurrently": "^6.2.1",
-    "copy-webpack-plugin": "^9.0.1",
+    "codemirror": "^5.64.0",
+    "concurrently": "^6.5.0",
+    "copy-webpack-plugin": "^10.2.0",
     "cross-env": "^7.0.3",
     "dotenv": "^10.0.0",
-    "electron": "^13.2.1",
-    "electron-builder": "^22.10.5",
-    "electron-notarize": "^1.1.0",
+    "electron": "^16.0.5",
+    "electron-builder": "^22.14.5",
+    "electron-notarize": "^1.1.1",
     "espower-typescript": "^10.0.0",
-    "execa": "^5.1.1",
-    "fork-ts-checker-webpack-plugin": "^6.3.2",
-    "framer-motion": "^4.1.17",
+    "execa": "^6.0.0",
+    "fork-ts-checker-webpack-plugin": "^6.5.0",
     "fs-extra": "^10.0.0",
-    "mocha": "^9.1.0",
+    "mocha": "^9.1.3",
     "power-assert": "^1.6.1",
-    "prettier": "^2.3.2",
+    "prettier": "^2.5.1",
     "pretty-bytes": "^5.6.0",
     "react": "^17.0.2",
     "react-dom": "^17.0.2",
-    "react-icons": "^4.2.0",
+    "react-icons": "^4.3.1",
     "react-virtualized-auto-sizer": "^1.0.6",
     "react-window": "^1.8.6",
     "smooth-scroll-into-view-if-needed": "^1.1.32",
-    "ts-node": "^10.2.1",
-    "tsconfig-paths-webpack-plugin": "^3.5.1",
-    "typescript": "^4.3.5",
-    "umi": "^3.5.17",
-    "webpack": "^5.51.1",
-    "webpack-cli": "^4.8.0",
+    "ts-node": "^10.4.0",
+    "tsconfig-paths-webpack-plugin": "^3.5.2",
+    "typescript": "^4.5.4",
+    "umi": "^3.5.20",
+    "webpack": "^5.65.0",
+    "webpack-cli": "^4.9.1",
     "webpack-merge": "^5.8.0",
     "webpack-node-externals": "^3.0.0",
     "yorkie": "^2.0.0"

+ 27 - 0
scripts/libs/my_exec.js

@@ -0,0 +1,27 @@
+const { spawn } = require('child_process')
+
+module.exports = function myExec(cmd, ...args) {
+  return new Promise((resolve, reject) => {
+    const run = spawn(cmd, args)
+
+    let out = ''
+
+    run.stdout.on('data', (data) => {
+      console.log(`[stdout]: ${data.toString().trimEnd()}`)
+      out += data.toString()
+    })
+
+    run.stderr.on('data', (data) => {
+      console.log(`[stderr]: ${data.toString().trimEnd()}`)
+    })
+
+    run.on('exit', function (code) {
+      console.log('child process exited with code ' + code.toString())
+      if (code === 0) {
+        resolve(out)
+      } else {
+        reject(code)
+      }
+    })
+  })
+}

+ 39 - 105
scripts/make.js

@@ -7,7 +7,7 @@
 require('dotenv').config()
 const version = require('../src/version.json')
 const builder = require('electron-builder')
-const execa = require('execa')
+const myExec = require('./libs/my_exec')
 const fse = require('fs-extra')
 const homedir = require('os').homedir()
 const path = require('path')
@@ -15,24 +15,21 @@ const path = require('path')
 const root_dir = path.normalize(path.join(__dirname, '..'))
 const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
 
-const electronLanguages = ['en', 'zh_CN']
+const electronLanguages = ['en', 'fr', 'zh_CN']
 
 const TARGET_PLATFORMS_configs = {
   mac: {
     mac: ['default'],
   },
-  mas: {
-    mac: ['mas'],
-  },
   macs: {
-    mac: ['default', 'mas'],
+    mac: ['dmg:x64', 'dmg:arm64'],
   },
   win: {
-    win: ['nsis:ia32', 'portable:ia32'],
+    win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
   },
   all: {
-    mac: ['default'],
-    linux: [/*'zip:x64', */ 'AppImage:x64', 'deb:x64'],
+    mac: ['dmg:x64', 'dmg:arm64'],
+    linux: ['AppImage:x64', 'deb:x64'],
     win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
   },
 }
@@ -53,24 +50,6 @@ const cfg_common = {
   },
 }
 
-const sign = async () => {
-  console.log('-> to sign...')
-  let wd = process.cwd()
-  process.chdir(__dirname)
-
-  let cmd = path.join(__dirname, 'sign-mac.sh')
-  try {
-    const { stdout } = await execa(cmd)
-    console.log(stdout)
-  } catch (e) {
-    //console.error(e)
-    console.log(e.stdout)
-    console.error(e.stderr)
-  }
-
-  process.chdir(wd)
-}
-
 const beforeMake = async () => {
   console.log('-> beforeMake...')
   fse.removeSync(dist_dir)
@@ -105,79 +84,27 @@ const afterMake = async () => {
   console.log('-> afterMake...')
 }
 
-const makeMacArm = async () => {
-  console.log('-> makeMacArm...')
-
-  await builder.build({
-    config: {
-      ...cfg_common,
-      appId: 'SwitchHosts',
-      productName: APP_NAME,
-      mac: {
-        target: [
-          {
-            target: 'dmg',
-            arch: [
-              //'x64',
-              'arm64',
-            ],
-          },
-        ],
-        category: 'public.app-category.productivity',
-        icon: 'assets/app.icns',
-        gatekeeperAssess: false,
-        electronLanguages,
-        identity: IDENTITY,
-        hardenedRuntime: true,
-        entitlements: 'scripts/entitlements.mac.plist',
-        entitlementsInherit: 'scripts/entitlements.mac.plist',
-        provisioningProfile: 'scripts/app.provisionprofile',
-        artifactName: '${productName}_arm64_${version}(${buildVersion}).${ext}',
-      },
-      dmg: {
-        //backgroundColor: '#f1f1f6',
-        background: 'assets/dmg-bg.png',
-        //icon: 'assets/dmg-icon.icns',
-        iconSize: 160,
-        window: {
-          width: 600,
-          height: 420,
-        },
-        contents: [
-          {
-            x: 150,
-            y: 200,
-          },
-          {
-            x: 450,
-            y: 200,
-            type: 'link',
-            path: '/Applications',
-          },
-        ],
-        sign: false,
-        artifactName: '${productName}_arm64_${version}(${buildVersion}).${ext}',
-      },
-    },
-  })
-
-  console.log('done!')
-}
+const doMake = async () => {
+  console.log('-> make...')
 
-const makeDefault = async () => {
-  console.log('-> makeDefault...')
-  // forFullVersion.task(APP_NAME)
+  let targets = TARGET_PLATFORMS_configs.all
+  if (process.env.MAKE_FOR === 'dev') {
+    targets = TARGET_PLATFORMS_configs.macs
+  } else if (process.env.MAKE_FOR === 'mac') {
+    targets = TARGET_PLATFORMS_configs.mac
+  } else if (process.env.MAKE_FOR === 'win') {
+    targets = TARGET_PLATFORMS_configs.win
+  }
 
   await builder.build({
     //targets: Platform.MAC.createTarget(),
-    //...TARGET_PLATFORMS_configs.mac,
-    //...TARGET_PLATFORMS_configs.win,
-    ...TARGET_PLATFORMS_configs.all,
+    ...targets,
     config: {
       ...cfg_common,
       appId: 'SwitchHosts',
       productName: APP_NAME,
       mac: {
+        type: 'distribution',
         category: 'public.app-category.productivity',
         icon: 'assets/app.icns',
         gatekeeperAssess: false,
@@ -187,7 +114,11 @@ const makeDefault = async () => {
         entitlements: 'scripts/entitlements.mac.plist',
         entitlementsInherit: 'scripts/entitlements.mac.plist',
         provisioningProfile: 'scripts/app.provisionprofile',
-        artifactName: '${productName}_${version}(${buildVersion}).${ext}',
+        extendInfo: {
+          ITSAppUsesNonExemptEncryption: false,
+          CFBundleLocalizations: electronLanguages,
+          CFBundleDevelopmentRegion: 'en',
+        },
       },
       dmg: {
         //backgroundColor: '#f1f1f6',
@@ -211,7 +142,8 @@ const makeDefault = async () => {
           },
         ],
         sign: false,
-        artifactName: '${productName}_${version}(${buildVersion}).${ext}',
+        artifactName:
+          '${productName}_mac_${arch}_${version}(${buildVersion}).${ext}',
       },
       win: {
         icon: 'assets/app.ico',
@@ -222,16 +154,23 @@ const makeDefault = async () => {
         oneClick: false,
         allowToChangeInstallationDirectory: true,
         artifactName:
-          '${productName}_installer_${version}(${buildVersion}).${ext}',
+          '${productName}_installer_${arch}_${version}(${buildVersion}).${ext}',
       },
       portable: {
         artifactName:
-          '${productName}_portable_${version}(${buildVersion}).${ext}',
+          '${productName}_portable_${arch}_${version}(${buildVersion}).${ext}',
       },
       linux: {
         icon: 'assets/app.png',
-        artifactName: '${productName}_linux_${version}(${buildVersion}).${ext}',
-        category: 'Office',
+        artifactName:
+          '${productName}_linux_${arch}_${version}(${buildVersion}).${ext}',
+        category: 'Utility',
+        synopsis: 'An App for hosts management and switching.',
+        desktop: {
+          Name: 'SwitchHosts',
+          Type: 'Application',
+          GenericName: 'An App for hosts management and switching.',
+        },
       },
     },
   })
@@ -242,15 +181,10 @@ const makeDefault = async () => {
 ;(async () => {
   try {
     await beforeMake()
-
-    await makeMacArm()
-    await makeDefault()
-
+    await doMake()
     await afterMake()
-    await sign()
-
-    console.log('-> meke Done!')
+    console.log('-> make Done!')
   } catch (e) {
-    console.log(e)
+    console.error(e)
   }
 })()

+ 10 - 2
scripts/notarize.js

@@ -10,14 +10,20 @@ const { notarize } = require('electron-notarize')
 exports.default = async function notarizing(context) {
   const appName = context.packager.appInfo.productFilename
   const { electronPlatformName, appOutDir } = context
+  console.log(`in notarize, ${electronPlatformName}...`)
   if (electronPlatformName !== 'darwin') {
     return
   }
 
+  if (process.env.MAKE_FOR === 'dev' || process.env.SKIP_NOTARIZATION) {
+    console.log('skip notarization.')
+    return // for dev, skip notarization
+  }
+
   let appPath = `${appOutDir}/${appName}.app`
   let { appleId, appBundleId, ascProvider, appleIdPassword } = process.env
   if (!appleIdPassword) {
-    appleIdPassword = `@keychain:Application Loader: ${appleId}`
+    appleIdPassword = `@keychain:Apple Notarize: ${appleId}`
   }
 
   if (!appleId || !appBundleId || !ascProvider || !appleIdPassword) {
@@ -25,11 +31,13 @@ exports.default = async function notarizing(context) {
     return
   }
 
-  return await notarize({
+  console.log('Start notarizing...')
+  await notarize({
     appBundleId,
     appPath,
     ascProvider,
     appleId,
     appleIdPassword,
   })
+  console.log('Notarize done.')
 }

+ 2 - 0
src/renderer/components/About/AboutContent.less

@@ -22,8 +22,10 @@
 .names {
   text-align: center;
   margin: 8px 0 20px 0;
+  max-width: 350px;
 
   a {
     margin: 0 0.5em;
+    display: inline-block;
   }
 }

+ 1 - 1
src/version.json

@@ -1 +1 @@
-[4, 0, 3, 6073]
+[4, 0, 4, 6075]

部分文件因为文件数量过多而无法显示