From 39a48759abb3095bebd1970b4778da434b3eca0b Mon Sep 17 00:00:00 2001 From: aipaw Date: Fri, 9 Jul 2021 09:20:18 +0800 Subject: [PATCH] no message --- electron/index.js | 38 ++++++++++++++++++++------------------ electron/package.json | 8 +++++--- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/electron/index.js b/electron/index.js index c9d50910..3c3dcdd6 100644 --- a/electron/index.js +++ b/electron/index.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path') const inquirer = require('inquirer'); const child_process = require('child_process'); -const config = require('./package.json') +const config = require('../package.json') const argv = process.argv; // 删除 @@ -155,31 +155,25 @@ const questions = [ validate: function (value) { return value !== '' } - }, { + } +]; +if (argv[2] == 'build') { + questions.push({ type: 'list', name: 'platform', message: "选择操作系统平台", choices: [{ name: "MacOS Intel", - value: { - platform: 'mac', - arch: 'x64', - } + value: "build-mac-intel" }, { - name: "MacOS Arm64", - value: { - platform: 'mac', - arch: 'arm64', - } + name: "MacOS M1", + value: "build-mac-m1" }, { name: "Window x86_64", - value: { - platform: 'windows', - arch: 'x64', - } + value: "build-mac-win" }] - } -]; + }) +} inquirer.prompt(questions).then(answers => { let data = `window.systemInformation = { @@ -189,7 +183,15 @@ inquirer.prompt(questions).then(answers => { }`; fs.writeFileSync(nativeCachePath, formatUrl(answers.targetUrl)); fs.writeFileSync(electronDir + "/config.js", data, 'utf8'); - exec("cd electron && npm run " + (argv[2] || "start")).then(r => {}) + // + let packageFile = path.resolve(__dirname, "package.json"); + let packageString = fs.readFileSync(packageFile, 'utf8'); + packageString = packageString.replace(/"version":\s*"(.*?)"/, `"version": "${config.version}"`); + packageString = packageString.replace(/"name":\s*"(.*?)"/, `"name": "${config.name}"`); + fs.writeFileSync(packageFile, packageString, 'utf8'); + // + let platform = argv[2] == "build" ? answers.platform : "start"; + exec("cd electron && npm run " + (platform)).then(r => {}) }); diff --git a/electron/package.json b/electron/package.json index 772a4c23..b77f3622 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,12 +1,15 @@ { "name": "DooTask", - "version": "1.0.0", + "version": "0.2.71", "description": "DooTask is task management system.", "main": "main.js", "license": "MIT", "scripts": { "start": "electron-forge start", "build": "electron-builder", + "build-mac-intel": "electron-builder --mac", + "build-mac-m1": "electron-builder --mac --arm64", + "build-win": "electron-builder --win", "package": "electron-forge package", "make": "electron-forge make", "publish": "electron-forge publish" @@ -30,8 +33,7 @@ "preload.js" ], "mac": { - "icon": "../resources/assets/statics/public/images/logo-app.png", - "target" : { "target": "dir", "arch": "arm64" } + "icon": "../resources/assets/statics/public/images/logo-app.png" }, "win": { "icon": "../resources/assets/statics/public/images/logo-app.ico"