Updated package and distributor to work with S3. Added menu update.
This commit is contained in:
106
electron/main.js
106
electron/main.js
@@ -1,10 +1,20 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { app, BrowserWindow, Tray, Menu, ipcMain } = require("electron");
|
const {
|
||||||
|
app,
|
||||||
|
BrowserWindow,
|
||||||
|
Tray,
|
||||||
|
Menu,
|
||||||
|
ipcMain,
|
||||||
|
dialog,
|
||||||
|
shell,
|
||||||
|
globalShortcut,
|
||||||
|
} = require("electron");
|
||||||
const isDev = require("electron-is-dev");
|
const isDev = require("electron-is-dev");
|
||||||
const { default: ipcTypes } = require("../src/ipc.types");
|
const { default: ipcTypes } = require("../src/ipc.types");
|
||||||
const { store } = require("./electron-store");
|
const { store } = require("./electron-store");
|
||||||
const { autoUpdater } = require("electron-updater");
|
const { autoUpdater } = require("electron-updater");
|
||||||
const log = require("electron-log");
|
const log = require("electron-log");
|
||||||
|
const { default: logger } = require("redux-logger");
|
||||||
require("./ipc-main-handler");
|
require("./ipc-main-handler");
|
||||||
|
|
||||||
autoUpdater.logger = log;
|
autoUpdater.logger = log;
|
||||||
@@ -13,18 +23,69 @@ log.info("App starting...");
|
|||||||
|
|
||||||
// Conditionally include the dev tools installer to load React Dev Tools
|
// Conditionally include the dev tools installer to load React Dev Tools
|
||||||
let installExtension, REACT_DEVELOPER_TOOLS;
|
let installExtension, REACT_DEVELOPER_TOOLS;
|
||||||
if (isDev) {
|
// if (isDev) {
|
||||||
const devTools = require("electron-devtools-installer");
|
// const devTools = require("electron-devtools-installer");
|
||||||
installExtension = devTools.default;
|
// installExtension = devTools.default;
|
||||||
REACT_DEVELOPER_TOOLS = devTools.REACT_DEVELOPER_TOOLS;
|
// REACT_DEVELOPER_TOOLS = devTools.REACT_DEVELOPER_TOOLS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
var menu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: "File",
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Relaunch",
|
||||||
|
click() {
|
||||||
|
app.exit();
|
||||||
|
app.relaunch();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Clear Settings",
|
||||||
|
click() {
|
||||||
|
store.reset("filePaths");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Exit",
|
||||||
|
click() {
|
||||||
|
app.quit();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// Other code removed for brevity
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Help",
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Rescue",
|
||||||
|
click() {
|
||||||
|
shell.openExternal("http://imexrescue.com");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Check for Updates",
|
||||||
|
click() {
|
||||||
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Open Log File",
|
||||||
|
click() {
|
||||||
|
shell.openPath(store.path);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
let tray = null;
|
let tray = null;
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
makeSingleInstance();
|
makeSingleInstance();
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
|
Menu.setApplicationMenu(menu);
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
@@ -33,7 +94,7 @@ function createWindow() {
|
|||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
enableRemoteModule: false,
|
enableRemoteModule: false,
|
||||||
webSecurity: false,
|
webSecurity: true,
|
||||||
worldSafeExecuteJavaScript: true,
|
worldSafeExecuteJavaScript: true,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: path.join(__dirname, "preload.js"), // use a preload script
|
preload: path.join(__dirname, "preload.js"), // use a preload script
|
||||||
@@ -73,6 +134,10 @@ function createWindow() {
|
|||||||
|
|
||||||
mainWindow.maximize();
|
mainWindow.maximize();
|
||||||
autoUpdater.checkForUpdatesAndNotify();
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
|
||||||
|
globalShortcut.register("CommandOrControl+Shift+I", () => {
|
||||||
|
mainWindow.webContents.toggleDevTools();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.mainWindow = mainWindow;
|
exports.mainWindow = mainWindow;
|
||||||
@@ -175,10 +240,23 @@ autoUpdater.on("update-downloaded", (ev, info) => {
|
|||||||
console.log("Update downloaded; will install in 5 seconds");
|
console.log("Update downloaded; will install in 5 seconds");
|
||||||
});
|
});
|
||||||
autoUpdater.on("update-downloaded", (ev, info) => {
|
autoUpdater.on("update-downloaded", (ev, info) => {
|
||||||
// Wait 5 seconds, then quit and install
|
if (process.env.NODE_ENV === "production") {
|
||||||
// In your application, you don't need to wait 5 seconds.
|
dialog.showMessageBox(
|
||||||
// You could call autoUpdater.quitAndInstall(); immediately
|
{
|
||||||
setTimeout(function () {
|
type: "info",
|
||||||
autoUpdater.quitAndInstall();
|
title: "Found Updates",
|
||||||
}, 5000);
|
message: "Found updates, do you want update now?",
|
||||||
|
buttons: ["Sure", "No"],
|
||||||
|
},
|
||||||
|
(buttonIndex) => {
|
||||||
|
if (buttonIndex === 0) {
|
||||||
|
const isSilent = true;
|
||||||
|
const isForceRunAfter = true;
|
||||||
|
autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||||
|
} else {
|
||||||
|
logger.warn("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -6440,8 +6440,7 @@
|
|||||||
"deep-diff": {
|
"deep-diff": {
|
||||||
"version": "0.3.8",
|
"version": "0.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/deep-diff/-/deep-diff-0.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/deep-diff/-/deep-diff-0.3.8.tgz",
|
||||||
"integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ=",
|
"integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"deep-equal": {
|
"deep-equal": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
@@ -16551,7 +16550,6 @@
|
|||||||
"version": "3.0.6",
|
"version": "3.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/redux-logger/-/redux-logger-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/redux-logger/-/redux-logger-3.0.6.tgz",
|
||||||
"integrity": "sha1-91VZZvMJjzyIYExEnPC69XeCdL8=",
|
"integrity": "sha1-91VZZvMJjzyIYExEnPC69XeCdL8=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"deep-diff": "^0.3.5"
|
"deep-diff": "^0.3.5"
|
||||||
}
|
}
|
||||||
|
|||||||
20
package.json
20
package.json
@@ -35,6 +35,7 @@
|
|||||||
"react-scripts": "3.4.3",
|
"react-scripts": "3.4.3",
|
||||||
"recharts": "^1.8.5",
|
"recharts": "^1.8.5",
|
||||||
"redux": "^4.0.5",
|
"redux": "^4.0.5",
|
||||||
|
"redux-logger": "^3.0.6",
|
||||||
"redux-persist": "^6.0.0",
|
"redux-persist": "^6.0.0",
|
||||||
"redux-saga": "^1.1.3",
|
"redux-saga": "^1.1.3",
|
||||||
"reselect": "^4.0.0",
|
"reselect": "^4.0.0",
|
||||||
@@ -48,8 +49,10 @@
|
|||||||
"dev": "concurrently -k \"npm start\" \"npm:electron\"",
|
"dev": "concurrently -k \"npm start\" \"npm:electron\"",
|
||||||
"electron": "wait-on tcp:3000 && electron .",
|
"electron": "wait-on tcp:3000 && electron .",
|
||||||
"pack": "electron-builder --dir",
|
"pack": "electron-builder --dir",
|
||||||
"dist": "electron-builder",
|
"dist": "npm run build && electron-builder",
|
||||||
"postinstall": "electron-builder install-app-deps"
|
"distp": "npm run build && electron-builder --publish always",
|
||||||
|
"distpnb": "npm run build && electron-builder --publish always",
|
||||||
|
"postinstall": "npm run build && electron-builder install-app-deps"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": "react-app"
|
"extends": "react-app"
|
||||||
@@ -73,24 +76,23 @@
|
|||||||
"electron-devtools-installer": "^3.1.1",
|
"electron-devtools-installer": "^3.1.1",
|
||||||
"enzyme": "^3.11.0",
|
"enzyme": "^3.11.0",
|
||||||
"enzyme-adapter-react-16": "^1.15.5",
|
"enzyme-adapter-react-16": "^1.15.5",
|
||||||
"redux-logger": "^3.0.6",
|
|
||||||
"wait-on": "^5.2.0"
|
"wait-on": "^5.2.0"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"extends": null,
|
"extends": null,
|
||||||
"appId": "com.imex.rps",
|
"appId": "com.imex.rps",
|
||||||
|
"copyright": "Copyright © Snapt Software Inc.",
|
||||||
"files": [
|
"files": [
|
||||||
"build/**",
|
"build/**",
|
||||||
"electron/**",
|
"electron/**",
|
||||||
"src/ipc.types.js",
|
"src/ipc.types.js",
|
||||||
"src/assets/**"
|
"src/assets/**"
|
||||||
],
|
],
|
||||||
"publish": [
|
"publish": {
|
||||||
{
|
"provider": "s3",
|
||||||
"provider": "generic",
|
"bucket": "rps-updater",
|
||||||
"url": "https://update.rps.bodyshop.app"
|
"region": "ca-central-1"
|
||||||
}
|
},
|
||||||
],
|
|
||||||
"win": {
|
"win": {
|
||||||
"target": "nsis",
|
"target": "nsis",
|
||||||
"icon": "src/icons/win/icon.ico"
|
"icon": "src/icons/win/icon.ico"
|
||||||
|
|||||||
Reference in New Issue
Block a user