Skip to content

Commit

Permalink
(WIP) Fix public OTA
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmlxn committed Jun 3, 2024
1 parent c588be8 commit 90d8aef
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 171 deletions.
5 changes: 3 additions & 2 deletions electron/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"plugins": ["prettier", "no-unused-imports"],
"ignorePatterns": [".next/"],
"rules": {
"prettier/prettier": [
Expand All @@ -11,7 +11,8 @@
"singleQuote": true
}
],
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-unused-imports/no-unused-imports": "error"
},
"parserOptions": {
"ecmaVersion": "latest",
Expand Down
3 changes: 2 additions & 1 deletion electron/constants/publishOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const publishOptions = {
releaseType: 'draft',
token: process.env.GH_TOKEN,
private: false,
publishAutoUpdate: false,
publishAutoUpdate: true,

};

module.exports = { publishOptions };
52 changes: 28 additions & 24 deletions electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs');
const os = require('os');
const sudo = require('sudo-prompt');
const process = require('process');
const axios = require("axios")
const axios = require('axios');

const Docker = require('dockerode');
const { spawnSync } = require('child_process');
Expand All @@ -29,18 +29,21 @@ const SudoOptions = {
};
const TendermintUrls = {
darwin: {
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",
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',
},
linux: {
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",
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',
},
win32: {
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"
}
}
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',
},
};

function getBinPath(command) {
return spawnSync('/usr/bin/which', [command], { env: Env })
Expand Down Expand Up @@ -133,36 +136,37 @@ async function downloadFile(url, dest) {
const response = await axios({
url,
method: 'GET',
responseType: 'stream'
responseType: 'stream',
});
response.data.pipe(writer);
return new Promise((resolve, reject) => {
writer.on('finish', resolve);
writer.on('error', reject);
});
} catch (err) {
fs.unlink(dest, () => { }); // Delete the file if there is an error
fs.unlink(dest, () => {}); // Delete the file if there is an error
console.error('Error downloading the file:', err.message);
}
}

async function installTendermintUnix() {
const cwd = process.cwd()
process.chdir(TempDir)
const cwd = process.cwd();
process.chdir(TempDir);

console.log(appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`))
const url = TendermintUrls[os.platform()][process.arch]
console.log(
appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`),
);
const url = TendermintUrls[os.platform()][process.arch];

console.log(appendLog(`Downloading ${url}, might take a while...`))
await downloadFile(url, `${TempDir}/tendermint.tar.gz`)
console.log(appendLog(`Downloading ${url}, might take a while...`));
await downloadFile(url, `${TempDir}/tendermint.tar.gz`);

console.log(appendLog(`Installing tendermint binary`))
await runCmdUnix("tar", ["-xvf", "tendermint.tar.gz"])
await runSudoUnix("install", "tendermint /usr/local/bin")
process.chdir(cwd)
console.log(appendLog(`Installing tendermint binary`));
await runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']);
await runSudoUnix('install', 'tendermint /usr/local/bin');
process.chdir(cwd);
}


function isDockerInstalledDarwin() {
return Boolean(getBinPath('docker'));
}
Expand Down Expand Up @@ -310,7 +314,7 @@ async function setupDarwin(ipcChannel) {
if (!isTendermintInstalledUnix()) {
ipcChannel.send('response', 'Installing Pearl Daemon');
console.log(appendLog('Installing tendermint'));
await installTendermintUnix()
await installTendermintUnix();
}

if (!fs.existsSync(VenvDir)) {
Expand Down Expand Up @@ -364,7 +368,7 @@ async function setupUbuntu(ipcChannel) {
if (!isTendermintInstalledUnix()) {
ipcChannel.send('response', 'Installing Pearl Daemon');
console.log(appendLog('Installing tendermint'));
await installTendermintUnix()
await installTendermintUnix();
}

if (!fs.existsSync(VenvDir)) {
Expand Down
Loading

0 comments on commit 90d8aef

Please sign in to comment.