1
0
Эх сурвалжийг харах

Update packaging and building scripts; Some detail improvements.

oldj 1 жил өмнө
parent
commit
cf2d9e6f56

+ 1 - 1
app/package.json

@@ -1,7 +1,7 @@
 {
   "name": "switchhosts",
   "productName": "SwitchHosts",
-  "version": "4.2.0.6105",
+  "version": "4.2.0.6119",
   "description": "Switch hosts quickly!",
   "main": "./main.js",
   "author": {

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 293 - 274
package-lock.json


+ 4 - 4
package.json

@@ -10,8 +10,8 @@
     "dev:renderer": "vite --config ./vite.render.config.mts",
     "version:up": "node ./scripts/version_up.js",
     "_build": "npm run clean:build && npm run version:up && concurrently \"npm run build:main\" \"npm run build:renderer\"",
-    "build:main": "cross-env NODE_ENV=production vite build --config ./vite.main.config.ts",
-    "build:renderer": "cross-env NODE_ENV=production vite build --config ./vite.render.config.ts",
+    "build:main": "cross-env NODE_ENV=production vite build --config ./vite.main.config.mts",
+    "build:renderer": "cross-env NODE_ENV=production vite build --config ./vite.render.config.mts",
     "build": "npm run _build",
     "make": "node scripts/make.js",
     "make:dev": "cross-env SKIP_NOTARIZATION=1 cross-env MAKE_FOR=dev npm run make",
@@ -36,6 +36,7 @@
   },
   "devDependencies": {
     "@chakra-ui/react": "2.8.2",
+    "@electron/notarize": "^2.3.2",
     "@emotion/react": "11.13.0",
     "@emotion/styled": "11.13.0",
     "@tabler/icons-react": "3.11.0",
@@ -60,7 +61,6 @@
     "dotenv": "16.4.5",
     "electron": "30.1.2",
     "electron-builder": "24.13.3",
-    "electron-notarize": "1.2.1",
     "espower-typescript": "10.0.1",
     "execa": "9.3.0",
     "fs-extra": "11.2.0",
@@ -79,7 +79,7 @@
     "smooth-scroll-into-view-if-needed": "2.0.2",
     "ts-node": "10.9.2",
     "typescript": "5.5.4",
-    "vite": "5.3.5",
+    "vite": "4.5.3",
     "vite-plugin-static-copy": "1.0.6",
     "vite-plugin-svgr": "4.2.0",
     "vite-tsconfig-paths": "4.3.2"

+ 23 - 40
scripts/make.js

@@ -1,57 +1,36 @@
 /**
- * make
+ * make.js
  * @author: oldj
  * @homepage: https://oldj.net
  */
 
 require('dotenv').config()
+const path = require('path')
+const fse = require('fs-extra')
 const version = require('../src/version.json')
 const builder = require('electron-builder')
-const fse = require('fs-extra')
 const homedir = require('os').homedir()
-const path = require('path')
-
-const root_dir = path.normalize(path.join(__dirname, '..'))
-const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
-
-const electronLanguages = ['en', 'fr', 'zh_CN', 'de', 'ja', 'tr', 'ko']
+const { APP_NAME, root_dir, dist_dir, electronLanguages } = require('./vars')
 
 const TARGET_PLATFORMS_configs = {
   mac: {
-    mac: ['default'],
-  },
-  macs: {
     mac: ['dmg:x64', 'dmg:arm64'],
   },
-  linux: {
-    linux: [
-      'AppImage:x64',
-      'deb:x64',
-      'AppImage:arm64',
-      'deb:arm64',
-      'AppImage:armv7l',
-      'deb:armv7l',
-    ],
-  },
   win: {
-    win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
+    win: ['nsis:ia32', 'nsis:x64', 'nsis:arm64', 'portable:x64'],
+  },
+  linux: {
+    linux: ['AppImage:x64', 'AppImage:arm64', 'deb:x64', 'deb:arm64'],
   },
   all: {
-    mac: ['dmg:x64', 'dmg:arm64'],
-    linux: [
-      'AppImage:x64',
-      'deb:x64',
-      'AppImage:arm64',
-      'deb:arm64',
-      'AppImage:armv7l',
-      'deb:armv7l',
-    ],
-    win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
+    mac: ['dmg:x64', 'dmg:arm64', 'zip:universal'],
+    win: ['nsis:ia32', 'nsis:x64', 'nsis:arm64', 'portable:x64', 'zip:x64' /* , 'appx:x64'*/],
+    linux: ['AppImage:x64', 'AppImage:arm64', 'deb:x64', 'deb:arm64'],
   },
 }
 
-const APP_NAME = 'SwitchHosts'
-const { IDENTITY } = process.env
+const { APP_BUNDLE_ID, IDENTITY } = process.env
+console.log(`APP_BUNDLE_ID: ${APP_BUNDLE_ID}`)
 
 const cfg_common = {
   copyright: `Copyright © ${new Date().getFullYear()}`,
@@ -62,8 +41,9 @@ const cfg_common = {
   },
   electronDownload: {
     cache: path.join(homedir, '.electron'),
-    mirror: 'https://npm.taobao.org/mirrors/electron/',
+    mirror: 'https://registry.npmmirror.com/-/binary/electron/',
   },
+  asar: true,
 }
 
 const beforeMake = async () => {
@@ -104,14 +84,12 @@ const doMake = async () => {
   let targets = TARGET_PLATFORMS_configs.all
 
   cfg_common.compression = 'maximum'
-  if (MAKE_FOR && MAKE_FOR !== 'all') {
-    cfg_common.compression = 'store'
-  }
 
   if (MAKE_FOR === 'dev') {
     targets = TARGET_PLATFORMS_configs.mac
+    cfg_common.compression = 'store'
   } else if (MAKE_FOR === 'mac') {
-    targets = TARGET_PLATFORMS_configs.macs
+    targets = TARGET_PLATFORMS_configs.mac
   } else if (MAKE_FOR === 'win') {
     targets = TARGET_PLATFORMS_configs.win
   } else if (MAKE_FOR === 'linux') {
@@ -140,6 +118,7 @@ const doMake = async () => {
           CFBundleLocalizations: electronLanguages,
           CFBundleDevelopmentRegion: 'en',
         },
+        notarize: false,
       },
       dmg: {
         //backgroundColor: '#f1f1f6',
@@ -173,6 +152,8 @@ const doMake = async () => {
         installerIcon: 'assets/installer-icon.ico',
         oneClick: false,
         allowToChangeInstallationDirectory: true,
+        deleteAppDataOnUninstall: false,
+        shortcutName: 'SwitchHosts',
         artifactName: '${productName}_windows_installer_${arch}_${version}(${buildVersion}).${ext}',
       },
       portable: {
@@ -205,8 +186,10 @@ const doMake = async () => {
     await beforeMake()
     await doMake()
     await afterMake()
+    //await macSign()
+
     console.log('-> make Done!')
   } catch (e) {
-    console.error(e)
+    console.log(e)
   }
 })()

+ 29 - 6
scripts/notarize.js

@@ -5,7 +5,21 @@
  */
 
 require('dotenv').config()
-const { notarize } = require('electron-notarize')
+const { notarize } = require('@electron/notarize')
+const { exec } = require('child_process')
+
+function getPasswordFromKeychain(account, service) {
+  return new Promise((resolve, reject) => {
+    const command = `security find-generic-password -a '${account}' -s '${service}' -w`
+    exec(command, (error, stdout, stderr) => {
+      if (error) {
+        reject(new Error(`Error fetching password: ${stderr}`))
+      } else {
+        resolve(stdout.trim())
+      }
+    })
+  })
+}
 
 exports.default = async function notarizing(context) {
   const appName = context.packager.appInfo.productFilename
@@ -21,23 +35,32 @@ exports.default = async function notarizing(context) {
   }
 
   let appPath = `${appOutDir}/${appName}.app`
-  let { appleId, appBundleId, ascProvider, appleIdPassword } = process.env
+  let {
+    APP_BUNDLE_ID: appBundleId,
+    TEAM_ID: teamId,
+    APPLE_ID: appleId,
+    APPLE_APP_SPECIFIC_PASSWORD: appleIdPassword,
+  } = process.env
   if (!appleIdPassword) {
-    appleIdPassword = `@keychain:Apple Notarize: ${appleId}`
+    //appleIdPassword = `@keychain:"Apple Notarize: ${appleId}"`
+    appleIdPassword = await getPasswordFromKeychain(appleId, `Apple Notarize: ${appleId}`)
+    process.env.APPLE_APP_SPECIFIC_PASSWORD = appleIdPassword
   }
 
-  if (!appleId || !appBundleId || !ascProvider || !appleIdPassword) {
+  if (!appleId || !appBundleId || !teamId || !appleIdPassword) {
     console.log('Not notarized.')
     return
   }
 
   console.log('Start notarizing...')
   await notarize({
-    appBundleId,
     appPath,
-    ascProvider,
+    tool: 'notarytool',
+    //appBundleId,
+    //ascProvider,
     appleId,
     appleIdPassword,
+    teamId,
   })
   console.log('Notarize done.')
 }

+ 15 - 0
scripts/vars.js

@@ -0,0 +1,15 @@
+const path = require('path')
+
+const root_dir = path.normalize(path.join(__dirname, '..'))
+const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
+
+const APP_NAME = 'SwitchHosts'
+
+const electronLanguages = ['en', 'fr', 'zh_CN', 'de', 'ja', 'tr', 'ko']
+
+module.exports = {
+  APP_NAME,
+  root_dir,
+  dist_dir,
+  electronLanguages,
+}

+ 1 - 0
src/renderer/components/List/ListItem.module.scss

@@ -77,6 +77,7 @@
   flex: 0 0 auto;
   display: flex;
   align-items: center;
+  gap: 5px;
   margin: auto 6px auto auto;
 }
 

+ 1 - 0
src/renderer/index.tsx

@@ -11,6 +11,7 @@ import React from 'react'
 import { createRoot } from 'react-dom/client'
 import { createHashRouter, RouterProvider } from 'react-router-dom'
 import { ChakraProvider, ColorModeScript } from '@chakra-ui/react'
+import './styles/common.scss'
 import theme from './theme'
 
 const router = createHashRouter([

+ 0 - 17
src/renderer/styles/common.scss

@@ -1,19 +1,2 @@
 @import "fn";
 
-html, body {
-  margin: 0;
-  padding: 0;
-  font-size: 14px;
-  line-height: 1.5em;
-  box-sizing: border-box;
-  color: var(--swh-font-color);
-  color-scheme: var(--swh-color-scheme);
-}
-
-button, a, input {
-  &:focus:not(:focus-visible) {
-    outline: 0;
-    box-shadow: none;
-  }
-}
-

+ 16 - 0
src/renderer/styles/global.scss

@@ -0,0 +1,16 @@
+html, body {
+  margin: 0;
+  padding: 0;
+  font-size: 14px;
+  line-height: 1.5em;
+  box-sizing: border-box;
+  color: var(--swh-font-color);
+  color-scheme: var(--swh-color-scheme);
+}
+
+button, a, input {
+  &:focus:not(:focus-visible) {
+    outline: 0;
+    box-shadow: none;
+  }
+}

+ 1 - 1
src/version.json

@@ -1 +1 @@
-[4, 2, 0, 6105]
+[4, 2, 0, 6119]

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно