diff --git a/electron/install.js b/electron/install.js index 9da1dcad6..a73d5acba 100644 --- a/electron/install.js +++ b/electron/install.js @@ -1,62 +1,62 @@ // Installation helpers. -const fs = require('fs'); -const os = require('os'); -const sudo = require('sudo-prompt'); -const process = require('process'); -const axios = require('axios'); -const { spawnSync } = require('child_process'); -const { logger } = require('./logger'); +const fs = require("fs"); +const os = require("os"); +const sudo = require("sudo-prompt"); +const process = require("process"); +const axios = require("axios"); +const { spawnSync } = require("child_process"); +const { logger } = require("./logger"); -const { paths } = require('./constants'); +const { paths } = require("./constants"); /** * current version of the pearl release * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc111'; +const OlasMiddlewareVersion = "0.1.0rc113"; -const path = require('path'); -const { app } = require('electron'); +const path = require("path"); +const { app } = require("electron"); // load env vars -require('dotenv').config({ +require("dotenv").config({ path: app.isPackaged - ? path.join(process.resourcesPath, '.env') - : path.resolve(process.cwd(), '.env'), + ? path.join(process.resourcesPath, ".env") + : path.resolve(process.cwd(), ".env"), }); const Env = { ...process.env, PATH: `${process.env.PATH}:/opt/homebrew/bin:/usr/local/bin`, - HOMEBREW_NO_AUTO_UPDATE: '1', + HOMEBREW_NO_AUTO_UPDATE: "1", }; const SudoOptions = { - name: 'Pearl', + name: "Pearl", env: Env, }; const TendermintUrls = { darwin: { - x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz', + x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz", arm64: - 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz', + "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz", }, linux: { - x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz', + x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz", arm64: - 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz', + "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz", }, win32: { - x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz', + x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz", arm64: - 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz', + "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz", }, }; function getBinPath(command) { - return spawnSync('/usr/bin/which', [command], { env: Env }) + return spawnSync("/usr/bin/which", [command], { env: Env }) .stdout?.toString() .trim(); } @@ -71,7 +71,7 @@ function runCmdUnix(command, options) { if (output.error) { throw new Error( `Error running ${command} with options ${options}; - Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, + Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}` ); } logger.electron(`Executed ${command} ${options} with`); @@ -97,20 +97,20 @@ function runSudoUnix(command, options) { if (output.error) { throw new Error( `Error running ${command} with options ${options}; - Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, + Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}` ); } logger.electron(`Executed ${command} ${options} with`); logger.electron(`===== stdout ===== \n${output.stdout}`); logger.electron(`===== stderr ===== \n${output.stderr}`); resolve(); - }, + } ); }); } function isTendermintInstalledUnix() { - return Boolean(getBinPath('tendermint')); + return Boolean(getBinPath("tendermint")); } async function downloadFile(url, dest) { @@ -118,17 +118,17 @@ async function downloadFile(url, dest) { try { const response = await axios({ url, - method: 'GET', - responseType: 'stream', + method: "GET", + responseType: "stream", }); response.data.pipe(writer); return new Promise((resolve, reject) => { - writer.on('finish', resolve); - writer.on('error', reject); + writer.on("finish", resolve); + writer.on("error", reject); }); } catch (err) { fs.unlink(dest, () => {}); // Delete the file if there is an error - console.error('Error downloading the file:', err.message); + console.error("Error downloading the file:", err.message); } } @@ -140,21 +140,21 @@ async function installTendermintUnix() { const url = TendermintUrls[os.platform()][process.arch]; logger.electron( - `Downloading ${url} to ${paths.tempDir}. This might take a while...`, + `Downloading ${url} to ${paths.tempDir}. This might take a while...` ); await downloadFile(url, `${paths.tempDir}/tendermint.tar.gz`); logger.electron(`Installing tendermint binary`); - runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']); + runCmdUnix("tar", ["-xvf", "tendermint.tar.gz"]); // TOFIX: Install tendermint in .operate instead of globally if (!Env.CI) { - if (!fs.existsSync('/usr/local/bin')) { - await runSudoUnix('mkdir', '/usr/local/bin'); + if (!fs.existsSync("/usr/local/bin")) { + await runSudoUnix("mkdir", "/usr/local/bin"); } await runSudoUnix( - 'install', - `${paths.tempDir}/tendermint /usr/local/bin/tendermint`, + "install", + `${paths.tempDir}/tendermint /usr/local/bin/tendermint` ); } process.chdir(cwd); @@ -176,28 +176,28 @@ function createDirectory(path) { /*******************************/ async function setupDarwin(ipcChannel) { - logger.electron('Creating required directories'); + logger.electron("Creating required directories"); await createDirectory(`${paths.dotOperateDirectory}`); await createDirectory(`${paths.tempDir}`); - logger.electron('Checking tendermint installation'); + logger.electron("Checking tendermint installation"); if (!isTendermintInstalledUnix()) { - ipcChannel.send('response', 'Installing Pearl Daemon'); - logger.electron('Installing tendermint'); + ipcChannel.send("response", "Installing Pearl Daemon"); + logger.electron("Installing tendermint"); await installTendermintUnix(); } } // TODO: Add Tendermint installation async function setupUbuntu(ipcChannel) { - logger.electron('Creating required directories'); + logger.electron("Creating required directories"); await createDirectory(`${paths.dotOperateDirectory}`); await createDirectory(`${paths.tempDir}`); - logger.electron('Checking tendermint installation'); + logger.electron("Checking tendermint installation"); if (!isTendermintInstalledUnix()) { - ipcChannel.send('response', 'Installing Pearl Daemon'); - logger.electron('Installing tendermint'); + ipcChannel.send("response", "Installing Pearl Daemon"); + logger.electron("Installing tendermint"); await installTendermintUnix(); } } diff --git a/package.json b/package.json index 3388ad3f0..74307f774 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh", "build:pearl": "sh build_pearl.sh" - }, - "version": "0.1.0-rc111" + "version": "0.1.0-rc113" } diff --git a/pyproject.toml b/pyproject.toml index 79c64ca42..dbd94ff6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc111" +version = "0.1.0-rc113" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md"