From 20aff4f54ed15cb5bfeef51d6b7065aa49ab9ca3 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 11:57:04 +0100 Subject: [PATCH 1/8] Change binaries default folder --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 77cf8ef6a..2ac6db886 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ node_modules launch.json package-lock.json .idea -build +dist From 4799d41466dd85800ead3206ad067b6dc222888b Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 11:57:49 +0100 Subject: [PATCH 2/8] Update paths for RO vitual fs --- Environment.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Environment.js b/Environment.js index e3d44a91c..4fb8e38cd 100644 --- a/Environment.js +++ b/Environment.js @@ -1,20 +1,32 @@ const path = require("path") +if (process.env.PACKAGED_PATH) { + basePath = process.env.PACKAGED_PATH +} else { + basePath = __dirname +} exports.newEnvironment = function () { let thisObject = { + BASE_PATH: basePath, WEB_SERVER_URL: 'localhost', CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041, CLIENT_HTTP_INTERFACE_PORT: 34248, - PATH_TO_DATA_STORAGE: path.join(__dirname, './Platform/My-Data-Storage'), - PATH_TO_PROJECTS: path.join(__dirname, './Projects'), - PATH_TO_LOG_FILES: path.join(__dirname, './Platform/My-Log-Files'), - PATH_TO_PROJECTS_REQUIRED: path.join(__dirname, './Projects'), - PATH_TO_PROJECT_SCHEMA: path.join(__dirname, './Projects/ProjectsSchema.json'), - PATH_TO_CLIENT: path.join(__dirname, './Platform'), - PATH_TO_DEFAULT_WORKSPACE: path.join(__dirname, './Projects/Foundations/Plugins/Workspaces'), - PATH_TO_MY_WORKSPACES: path.join(__dirname, './Platform/My-Workspaces'), - PATH_TO_FONTS: path.join(__dirname, './Platform/WebServer/Fonts') + PATH_TO_DATA_STORAGE: path.join(basePath, './Platform/My-Data-Storage'), + PATH_TO_PROJECTS: path.join(basePath, './Projects'), + PATH_TO_LOG_FILES: path.join(basePath, './Platform/My-Log-Files'), + PATH_TO_PROJECTS_REQUIRED: path.join(basePath, './Projects'), + PATH_TO_PROJECT_SCHEMA: path.join(basePath, './Projects/ProjectsSchema.json'), + PATH_TO_CLIENT: path.join(basePath, './Platform'), + PATH_TO_DEFAULT_WORKSPACE: path.join(basePath, './Projects/Foundations/Plugins/Workspaces'), + PATH_TO_MY_WORKSPACES: path.join(basePath, './Platform/My-Workspaces'), + 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') } return thisObject From dd80c80b14df63b20d348b46a399d60140cd571b Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 11:59:09 +0100 Subject: [PATCH 3/8] Updates to enable Windows installer --- package.json | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 2c1bf7587..c20a28cb7 100644 --- a/package.json +++ b/package.json @@ -9,18 +9,16 @@ "name": "Luis-Fernando-Molina" }, "scripts": { - "start-dev": "node platform minMemo noBrowser", + "start": "node platform minMemo noBrowser", "setup": "node setup noShortcuts", - "release-dev": "electron-builder --dir", - "release-win": "electron-builder --win", - "release-mac": "electron-builder --mac", - "start": "electron . noBrowser", + "release": "electron-builder -w", "postinstall": "electron-builder install-app-deps" }, "dependencies": { "@octokit/rest": "^18.11.4", "ccxt": "^1.57.36", "child_process": "^1.0.2", + "electron-updater": "^4.3.9", "ethereumjs-common": "^1.5.2", "ethereumjs-tx": "^2.1.2", "ethers": "^5.4.7", @@ -45,18 +43,15 @@ "build": { "appId": "org.superalgos.platform", "productName": "Superalgos", - "directories": { - "output": "build" - }, + "asar": false, "files": [ "**/*", - "!.github${/*}", - "!.vscode${/*}", + "!.github", + "!.vscode", "!.dockerignore${/*}", - "!Data-Storage/*", - "!Log-Files/*", - "!My-Workspaces/*", - "!build", + "!Platform/My-Data-Storage/*", + "!Platform/My-Log-Files/*", + "!Platform/My-Workspaces/*", "!Docker", "!Launch-Scripts", "!run.js", @@ -65,17 +60,12 @@ ], "win": { "target": [ - { - "target": "portable", - "arch": "x64" - }, { "target": "nsis", "arch": "x64" } ], - "icon": "./Launch-Scripts/superalgos.ico", - "publish": "github" + "icon": "./build/superalgos.ico" }, "nsis": { "oneClick": false, @@ -86,15 +76,6 @@ "createStartMenuShortcut": true, "license": "./LICENSE", "runAfterFinish": false - }, - "mac": { - "category": "public.app-category.finance", - "target": "dmg", - "type": "development", - "publish": "github" - }, - "linux": { - "maintainer": "na.amorim@gmail.com" } } } From 23b774109a046d9a6c78892c0254e64a83999a4a Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 12:00:03 +0100 Subject: [PATCH 4/8] Update to reference Windows installer --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df3065d2c..44f31a488 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,15 @@ In order to run Superalgos on your computer, you will need the latest versions o ### Windows Install -Follow the install wizards to install the latest NodeJS and Github Desktop applications. +You can use the windows installer (Setup file) which will install all the necessary dependencies and files for you to run the platform. Also the shortcuts are placed. This application will notify you and update as new releases come (to be released). + + **IMPORTANT:** + The single executable and the installer do not have Tensorflow active yet. + +> **NOTE** +> There's a known issue where the screen stays white. In this case, go to "View/Reload" and it should work. + +The manual installation option, tailored for users who are experienced and who want to contribute to the project (highly appreciated and rewarded with SA tokens). Follow the install wizards to install the latest NodeJS and Github Desktop applications. - [Node.js download page](https://nodejs.org/en/download/). Select "Current" then "Windows Installer", then follow the wizard to install after the download completes. - [GitHub Desktop downloat page](https://desktop.github.com/). Click the "Download for Windows" button and follow the wizard to install after the download completes. From 0169214b3f24a24b231f044056fdcf1ff0103154 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 12:00:41 +0100 Subject: [PATCH 5/8] Disable git check when running as packaged app --- Platform/Client/httpInterface.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index dd933ba67..79832c2f3 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -631,7 +631,13 @@ exports.newHttpInterface = function newHttpInterface() { break case 'App': { + // If running the electron app do not try to get git tool. I don't allow it. + if (process.env.SA_MODE === 'gitDisable') { + console.log('[WARNING] No contributions on binary distributions. Do manual installation') + break + } switch (requestPath[2]) { // switch by command + case 'Contribute': { try { let commitMessage = unescape(requestPath[3]) @@ -641,7 +647,7 @@ exports.newHttpInterface = function newHttpInterface() { const contributionsBranch = unescape(requestPath[7]) let error - /* Unsavping # */ + /* Unsaving # */ for (let i = 0; i < 10; i++) { commitMessage = commitMessage.replace('_SLASH_', '/') commitMessage = commitMessage.replace('_HASHTAG_', '#') @@ -649,11 +655,11 @@ exports.newHttpInterface = function newHttpInterface() { contribute() - async function contribute() { + async function contribute() { const { lookpath } = SA.nodeModules.lookpath const gitpath = await lookpath('git') if (gitpath === undefined) { - console.log('[ERROR] `git` not installed.') + console.log('[ERROR] `git` not installed. Line 656') } else { await doGit() if (error !== undefined) { From 281beba0bee910f90dcc420e511764b83ac6bf15 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 12:01:16 +0100 Subject: [PATCH 6/8] Enable autoUpdate additions for Mac app --- electron-wrapper.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/electron-wrapper.js b/electron-wrapper.js index 92566cc6e..c1e3da424 100644 --- a/electron-wrapper.js +++ b/electron-wrapper.js @@ -2,6 +2,12 @@ const {app, Menu, BrowserWindow} = require('electron') const path = require('path') const fs = require('fs') +// To check for update on Github repo +const {autoUpdater} = require("electron-updater"); + +// Enable non contribution mode (test) +process.env.SA_MODE = 'gitDisable' +process.env.PACKAGED_PATH = app.getAppPath() const WINDOW_WIDTH = null const WINDOW_HEIGHT = null @@ -13,30 +19,15 @@ var server_ready = false const port = 34248 // Default HTTP port -/* To check if the folders where user data do exist. If not, create them */ -function userData() { - const dataStorage = path.join(process.cwd(), '/Platform/My-Data-Storage') - const logFiles = path.join(process.cwd(), '/Platform/My-Log-Files') - const workspace = path.join(process.cwd(), '/Platform/My-Workspaces') - - if (!fs.existsSync(dataStorage)) { - fs.mkdirSync(dataStorage) - } - - if (!fs.existsSync(logFiles)) { - fs.mkdirSync(logFiles) - } - - if (!fs.existsSync(workspace)) { - fs.mkdirSync(workspace) - } -} run() function run() { - userData() + if (process.env.PORTABLE_EXECUTABLE_DIR) { + process.env.PORTABLE_USER_DOCUMENTS = app.getPath("documents") + } + const { fork } = require('child_process') - fork(path.join(__dirname, './PlatformRoot.js'), process.argv) + fork(path.join(__dirname, './PlatformRoot.js'), ["noBrowser"]) server_ready = true if (app_ready) open() @@ -66,12 +57,17 @@ function open () { app.on('ready', function () { app_ready = true + autoUpdater.checkForUpdatesAndNotify(); create_menus() if (server_ready) open() }) app.on('window-all-closed', function () { - app.quit() + if (process.platform !== 'darwin') app.quit() +}) + +app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow() }) function create_menus () { From 5b1b1b9b3574be1ec2fa98c813e35f746feb6141 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 12:03:16 +0100 Subject: [PATCH 7/8] Remove debug info --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 79832c2f3..1505b6184 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -659,7 +659,7 @@ exports.newHttpInterface = function newHttpInterface() { const { lookpath } = SA.nodeModules.lookpath const gitpath = await lookpath('git') if (gitpath === undefined) { - console.log('[ERROR] `git` not installed. Line 656') + console.log('[ERROR] `git` not installed.') } else { await doGit() if (error !== undefined) { From f7c5b27ede8dabe13bb56b6d0fe15dd71e1e13a5 Mon Sep 17 00:00:00 2001 From: NAmorim Date: Mon, 11 Oct 2021 12:19:32 +0100 Subject: [PATCH 8/8] Another try at relese build --- .github/workflows/release_build.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/release_build.yml diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml new file mode 100644 index 000000000..7d3550a2f --- /dev/null +++ b/.github/workflows/release_build.yml @@ -0,0 +1,34 @@ +name: Build/release + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest] + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Build/release Electron app + uses: samuelmeuli/action-electron-builder@v1 + with: + # GitHub token, automatically provided to the action + # (No need to define this secret in the repo settings) + github_token: ${{ secrets.github_token }} + + # If the commit is tagged with a version (e.g. "v1.0.0"), + # release the app after building + release: ${{ startsWith(github.ref, 'refs/tags/v') }}