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') }} 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 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 diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index d3a392d2b..b4cdaad67 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,7 +655,7 @@ exports.newHttpInterface = function newHttpInterface() { contribute() - async function contribute() { + async function contribute() { const { lookpath } = SA.nodeModules.lookpath const gitpath = await lookpath('git') if (gitpath === undefined) { 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. 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 () { 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" } } }