From c5c76094f5e8166cda5040e4541c1021ef8ae7b6 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Thu, 21 Oct 2021 10:42:37 +0100 Subject: [PATCH 1/4] Packaged app build script cleanup Adition of portable windows app --- build/electron-builder.json | 9 ++++++++- package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/electron-builder.json b/build/electron-builder.json index 0a0c49fe1..3a9802aa3 100644 --- a/build/electron-builder.json +++ b/build/electron-builder.json @@ -22,7 +22,11 @@ { "target": "nsis", "arch": "x64" - } + }, + { + "target": "portable", + "arch": "x64" + } ], "artifactName": "${productName}-${os}-${version}.${ext}", "icon": "./build/superalgos.ico" @@ -48,5 +52,8 @@ "category": "public.app-category.finance", "target": "default", "icon": "build/icon.icns" + }, + "extraMetadata": { + "main": "electron-wrapper.js" } } \ No newline at end of file diff --git a/package.json b/package.json index 7f7c79781..078b30667 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "start": "node platform minMemo noBrowser", "setup": "node setup noShortcuts", - "dist": "electron-builder", + "dist": "electron-builder -c build/electron-builder.json", "postinstall": "electron-builder install-app-deps" }, "dependencies": { From 6680d4495cf924dfc001afd6979e042f544f9f4e Mon Sep 17 00:00:00 2001 From: NAmorim Date: Thu, 21 Oct 2021 11:54:45 +0100 Subject: [PATCH 2/4] Notify electron that server is running --- PlatformRoot.js | 4 ++++ electron-wrapper.js | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/PlatformRoot.js b/PlatformRoot.js index 2539bdb15..d1cdab872 100644 --- a/PlatformRoot.js +++ b/PlatformRoot.js @@ -15,6 +15,7 @@ The SA object is accesible everywhere at the Superalgos Desktop App. It provides access to all modules built for Superalgos in general. */ global.SA = {} + /* Load Environment Variables */ let ENVIRONMENT = require('./Environment.js'); let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() @@ -84,4 +85,7 @@ async function run(initialWorkspace) { PL.app = require('./Platform/PlatformApp.js').newPlatformApp() await PL.app.run(initialWorkspace) console.log('Superalgos Platform App is Running!') + if(process.send) { + process.send("Running") + } } diff --git a/electron-wrapper.js b/electron-wrapper.js index 73aa9fe08..6b0e73f8a 100644 --- a/electron-wrapper.js +++ b/electron-wrapper.js @@ -27,10 +27,12 @@ function run() { } const { fork } = require('child_process') - fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"]) - - server_ready = true - if (app_ready) open() + const platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}) + platform.on('message', message => { + if(message == "Running") { + open() + } + }) } function open () { From 7d7be12a481bba34d2dbb3dcc84baf4f3f145cac Mon Sep 17 00:00:00 2001 From: NAmorim Date: Thu, 21 Oct 2021 18:44:42 +0100 Subject: [PATCH 3/4] Enable SA data to be stored in user documents folder --- Environment.js | 8 ++++---- Platform/Client/httpInterface.js | 4 ++-- electron-wrapper.js | 9 +++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Environment.js b/Environment.js index 5d7a914af..7f77d2c67 100644 --- a/Environment.js +++ b/Environment.js @@ -28,10 +28,10 @@ exports.newEnvironment = function () { PATH_TO_FONTS: path.join(basePath, './Platform/WebServer/Fonts') } - if (process.env.PORTABLE_EXECUTABLE_DIR) { - thisObject.PATH_TO_DATA_STORAGE = path.join(process.env.PORTABLE_USER_DOCUMENTS, '/Superalgos/Platform/My-Data-Storage') - thisObject.PATH_TO_LOG_FILES = path.join(process.env.PORTABLE_USER_DOCUMENTS, '/Superalgos/Platform/My-Log-Files') - thisObject.PATH_TO_MY_WORKSPACES = path.join(process.env.PORTABLE_USER_DOCUMENTS, '/Superalgos/Platform/My-Workspaces') + if (process.env.DATA_PATH) { + thisObject.PATH_TO_DATA_STORAGE = path.join(process.env.DATA_PATH, '/Superalgos_Data/My-Data-Storage') + thisObject.PATH_TO_LOG_FILES = path.join(process.env.DATA_PATH, '/Superalgos_Data/My-Log-Files') + thisObject.PATH_TO_MY_WORKSPACES = path.join(process.env.DATA_PATH, '/Superalgos_Data/My-Workspaces') } return thisObject diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 637137c32..08e617350 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -598,7 +598,7 @@ exports.newHttpInterface = function newHttpInterface() { function createNewDir(path) { try { - fs.mkdirSync(path) + fs.mkdirSync(path, {recursive: true}) } catch (err) { if (err.message.indexOf('file already exists') < 0) { throw (err) @@ -1805,7 +1805,7 @@ exports.newHttpInterface = function newHttpInterface() { /* Create Dir if it does not exist */ if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); + fs.mkdirSync(dir, {recursive: true}); } fs.writeFile(filePath, fileContent, onFileWritten) diff --git a/electron-wrapper.js b/electron-wrapper.js index 6b0e73f8a..d02e99332 100644 --- a/electron-wrapper.js +++ b/electron-wrapper.js @@ -8,6 +8,7 @@ const {autoUpdater} = require("electron-updater") // Enable non contribution mode (test) process.env.SA_MODE = 'gitDisable' process.env.PACKAGED_PATH = app.getAppPath() +process.env.DATA_PATH = app.getPath('documents') const WINDOW_WIDTH = null const WINDOW_HEIGHT = null @@ -22,12 +23,8 @@ const port = 34248 // Default HTTP port run() function run() { - if (process.env.PORTABLE_EXECUTABLE_DIR) { - process.env.PORTABLE_USER_DOCUMENTS = app.getPath("userData") - } - const { fork } = require('child_process') - const platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}) + const platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc'], env: process.env}) platform.on('message', message => { if(message == "Running") { open() @@ -38,7 +35,7 @@ function run() { function open () { let bw_options = { width: WINDOW_WIDTH ? WINDOW_WIDTH : 1280, - height: WINDOW_HEIGHT ? WINDOW_HEIGHT : 720, + height: WINDOW_HEIGHT ? WINDOW_HEIGHT : 768, resizable: true } From f3c35790f4e3df57568a8c703a9275b5b2620995 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Thu, 21 Oct 2021 22:59:56 +0100 Subject: [PATCH 4/4] Mac ARM64 build --- build/electron-builder.json | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build/electron-builder.json b/build/electron-builder.json index 3a9802aa3..7554534f0 100644 --- a/build/electron-builder.json +++ b/build/electron-builder.json @@ -48,10 +48,19 @@ "artifactName": "${productName}_Setup_${os}_${version}.${ext}" }, "mac": { - "artifactName": "${productName}-${os}-${version}.${ext}", + "artifactName": "${productName}-${os}-${arch}-${version}.${ext}", "category": "public.app-category.finance", - "target": "default", - "icon": "build/icon.icns" + "icon": "./build/icon.icns", + "target": [ + { + "target": "dmg", + "arch": "x64" + }, + { + "target": "dmg", + "arch": "arm64" + } + ] }, "extraMetadata": { "main": "electron-wrapper.js"