Browse Source

- add notarization scripts.
- fix some small issues of StatConfirm.

oldj 5 years ago
parent
commit
e641c0206a

+ 3 - 0
.gitignore

@@ -22,3 +22,6 @@ xcdebugger
 npm-debug.log*
 .nyc_output
 coverage/
+
+.env
+

+ 2 - 1
app-ui/frame/MyFrame.jsx

@@ -60,7 +60,7 @@ export default class MyFrame extends React.Component {
     if (!this.props.show) {
       return null
     }
-    let {show, title, body, lang, width, okText, cancelText} = this.props
+    let {show, title, body, lang, width, okText, cancelText, maskClosable} = this.props
 
     return (
       <Modal
@@ -78,6 +78,7 @@ export default class MyFrame extends React.Component {
             {okText || lang.ok}
           </Button>
         ]}
+        maskClosable={maskClosable}
       >
         <div className="prompt-body">{body}</div>
         {/*<div className="prompt">*/}

+ 2 - 1
app-ui/frame/StatConfirm.jsx

@@ -33,12 +33,13 @@ const StatConfirm = (props) => {
       show={show}
       title={lang.pref_tab_usage_data_title}
       body={<div className="ln">{lang.pref_tab_usage_data_desc}</div>}
-      onOK={() => setShow(true)}
+      onOK={() => setSend(true)}
       onCancel={() => setSend(false)}
       lang={lang}
       width={400}
       okText={lang.send_usage_data_ok}
       cancelText={lang.send_usage_data_cancel}
+      maskClosable={false}
     />
   )
 }

File diff suppressed because it is too large
+ 0 - 0
app/ui/app.js


+ 1 - 1
app/ui/common.js.LICENSE

@@ -1,4 +1,4 @@
-/*! SwitchHosts! common.js, 2019-11-25 20:56:14 */
+/*! SwitchHosts! common.js, 2020-01-09 13:52:30 */
 
 /*!
   Copyright (c) 2017 Jed Watson.

+ 1 - 1
app/version.js

@@ -1 +1 @@
-module.exports = [3, 5, 3, 5510]
+module.exports = [3, 5, 3, 5514]

+ 30 - 3
package-lock.json

@@ -7213,9 +7213,9 @@
       }
     },
     "dotenv": {
-      "version": "8.0.0",
-      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz",
-      "integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg==",
+      "version": "8.2.0",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
+      "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
       "dev": true
     },
     "dotenv-expand": {
@@ -7402,6 +7402,33 @@
         }
       }
     },
+    "electron-notarize": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-0.2.1.tgz",
+      "integrity": "sha512-oZ6/NhKeXmEKNROiFmRNfytqu3cxqC95sjooG7kBXQVEUSQkZnbiAhxVh5jXngL881G197pbwpeVPJyM7Ikmxw==",
+      "dev": true,
+      "requires": {
+        "debug": "^4.1.1",
+        "fs-extra": "^8.1.0"
+      },
+      "dependencies": {
+        "debug": {
+          "version": "4.1.1",
+          "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+          "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+          "dev": true,
+          "requires": {
+            "ms": "^2.1.1"
+          }
+        },
+        "ms": {
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+          "dev": true
+        }
+      }
+    },
     "electron-publish": {
       "version": "21.2.0",
       "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-21.2.0.tgz",

+ 6 - 1
package.json

@@ -73,8 +73,10 @@
     "copy-webpack-plugin": "^5.0.5",
     "cross-env": "^6.0.3",
     "css-loader": "^3.2.0",
+    "dotenv": "^8.2.0",
     "electron": "^7.1.2",
     "electron-builder": "^21.2.0",
+    "electron-notarize": "^0.2.1",
     "eslint": "^6.7.1",
     "eslint-config-standard": "^14.1.0",
     "eslint-friendly-formatter": "^4.0.1",
@@ -142,5 +144,8 @@
         "stage-0"
       ]
     }
+  },
+  "build": {
+    "afterSign": "scripts/notarize.js"
   }
-}
+}

+ 8 - 0
scripts/entitlements.mac.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
+        <true/>
+    </dict>
+</plist>

+ 5 - 1
scripts/make.js

@@ -39,7 +39,9 @@ const makeApp = async () => {
         category: 'public.app-category.productivity',
         icon: 'assets/app.icns',
         gatekeeperAssess: false,
-        identity: 'oldj',
+        hardenedRuntime: true,
+        entitlements: 'scripts/entitlements.mac.plist',
+        entitlementsInherit: 'scripts/entitlements.mac.plist',
         artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
       },
       dmg: {
@@ -60,6 +62,7 @@ const makeApp = async () => {
           type: 'link',
           path: '/Applications'
         }],
+        sign: false,
         artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
       },
       win: {
@@ -75,6 +78,7 @@ const makeApp = async () => {
         artifactName: '${productName}_windows_portable_${version}(${buildVersion}).${ext}'
       },
       linux: {
+        category: 'Development',
         artifactName: '${productName}_linux_${arch}_${version}(${buildVersion}).${ext}'
       }
     }

+ 35 - 0
scripts/notarize.js

@@ -0,0 +1,35 @@
+/**
+ * notarize.js
+ *
+ * @see https://oldj.net/blog/2019/12/29/electron-builder-sign-and-notarize-for-macos
+ */
+
+require('dotenv').config()
+const {notarize} = require('electron-notarize')
+
+exports.default = async function notarizing (context) {
+  const appName = context.packager.appInfo.productFilename
+  const {electronPlatformName, appOutDir} = context
+  if (electronPlatformName !== 'darwin') {
+    return
+  }
+
+  let appPath = `${appOutDir}/${appName}.app`
+  let {appleId, appBundleId, ascProvider, appleIdPassword} = process.env
+  if (!appleIdPassword) {
+    appleIdPassword = `@keychain:Application Loader: ${appleId}`
+  }
+
+  if (!appleId || !appBundleId || !ascProvider || !appleIdPassword) {
+    console.log('Not notarized.')
+    return
+  }
+
+  return await notarize({
+    appBundleId,
+    appPath,
+    ascProvider,
+    appleId,
+    appleIdPassword
+  })
+}

Some files were not shown because too many files changed in this diff