Skip to content

Commit

Permalink
chore: bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Atatakai authored and Atatakai committed Aug 20, 2024
1 parent 45ad9f4 commit f16d6da
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
92 changes: 46 additions & 46 deletions electron/install.js
Original file line number Diff line number Diff line change
@@ -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();
}
Expand All @@ -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`);
Expand All @@ -97,38 +97,38 @@ 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) {
const writer = fs.createWriteStream(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);
}
}

Expand All @@ -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);
Expand All @@ -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();
}
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "olas-operate-middleware"
version = "0.1.0-rc111"
version = "0.1.0-rc113"
description = ""
authors = ["David Vilela <[email protected]>", "Viraj Patel <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit f16d6da

Please sign in to comment.