-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from valory-xyz/feat/packaging
Packaging
- Loading branch information
Showing
49 changed files
with
12,493 additions
and
894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
|
||
FORK_URL= | ||
NODE_ENV= | ||
|
||
# required for hardhat node in development mode | ||
HARDHAT_GNOSIS_RPC= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// Installation helpers. | ||
|
||
const fs = require('fs'); | ||
const { spawnSync } = require("child_process"); | ||
const os = require('os'); | ||
|
||
const OperateDirectory = `${os.homedir()}/.operate`; | ||
const OperateCmd = `${os.homedir()}/.operate/venv/bin/operate`; | ||
|
||
function runSync(command, options) { | ||
let process = spawnSync(command, options); | ||
return { | ||
error: process.error, | ||
stdout: process.stdout?.toString(), | ||
stderr: process.stderr?.toString(), | ||
} | ||
} | ||
|
||
function isPythonInstalledDarwin() { | ||
return runSync('/opt/homebrew/bin/python3.10', ['--version']); | ||
} | ||
|
||
function installPythonDarwin() { | ||
return runSync('/opt/homebrew/bin/brew', ['install', '[email protected]']) | ||
} | ||
|
||
function createVirtualEnvDarwin(path) { | ||
return runSync( | ||
'/opt/homebrew/bin/python3.10', | ||
[ | ||
'-m', | ||
'venv', | ||
path, | ||
] | ||
) | ||
} | ||
|
||
function isPythonInstalledUbuntu() { | ||
return runSync('/usr/bin/python3.10', ['--version']); | ||
} | ||
|
||
function installPythonUbuntu() { | ||
return runSync('/usr/bin/apt', ['install', 'python3.10 ', 'python3.10-dev']) | ||
} | ||
|
||
function createVirtualEnvUbuntu(path) { | ||
return runSync('/usr/bin/python3.10', ['-m', 'venv', path]) | ||
} | ||
|
||
function installOperatePackage(path) { | ||
return runSync( | ||
`${path}/venv/bin/python3.10`, | ||
[ | ||
'-m', | ||
'pip', | ||
'install', | ||
'git+https://github.com/valory-xyz/olas-operate-app.git@a2d203ad2d6c716a66a8d184ab77909b5ab22a85#egg=operate' | ||
] | ||
) | ||
} | ||
|
||
function installOperateAppDarwin(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.copyFile(`${path}/venv/bin/operate`, "/opt/homebrew/bin/operate", function (error, stdout, stderr) { | ||
resolve(!error) | ||
}) | ||
}); | ||
} | ||
|
||
function installOperateAppUbuntu(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.copyFile(`${path}/venv/bin/operate`, "/usr/local/bin", function (error, stdout, stderr) { | ||
resolve(!error) | ||
}) | ||
}); | ||
} | ||
|
||
function createDirectory(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.mkdir(path, { recursive: true }, (error) => { | ||
resolve(!error); | ||
}); | ||
}); | ||
} | ||
|
||
async function setupDarwin() { | ||
let installCheck | ||
// Python installation check | ||
if (isPythonInstalledDarwin().error) { | ||
installCheck = installPythonDarwin() | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
} | ||
|
||
// Create required directories | ||
await createDirectory(`${OperateDirectory}`) | ||
await createDirectory(`${OperateDirectory}/temp`) | ||
|
||
// Create a virtual environment | ||
installCheck = createVirtualEnvDarwin(`${OperateDirectory}/venv`) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
|
||
// Install operate app | ||
installCheck = installOperatePackage(OperateDirectory) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
installCheck = installOperateAppDarwin(OperateDirectory) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
} | ||
|
||
async function setupUbuntu() { | ||
|
||
// Python installation check | ||
if (!await isPythonInstalledUbuntu()) { | ||
console.log("Installing Python") | ||
if (!await installPythonUbuntu()) { | ||
throw new Error("Could not install python") | ||
} | ||
} | ||
|
||
// Create required directories | ||
await createDirectory(`${OperateDirectory}`) | ||
await createDirectory(`${OperateDirectory}/temp`) | ||
|
||
// Create a virtual environment | ||
installCheck = createVirtualEnvUbuntu(`${OperateDirectory}/venv`) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
|
||
// Install operate app | ||
installCheck = installOperatePackage(OperateDirectory) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
installCheck = installOperateAppUbuntu(OperateDirectory) | ||
if (installCheck.error) { | ||
throw new Error(`Error: ${installCheck.error}; Stdout: ${installCheck.stdout}; Stderr: ${installCheck.stderr}`) | ||
} | ||
|
||
} | ||
|
||
function isInstalled() { | ||
return fs.existsSync(OperateDirectory) | ||
} | ||
|
||
module.exports = { setupDarwin, setupUbuntu, isInstalled, OperateDirectory, OperateCmd } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="./loading.css" /> | ||
</head> | ||
<body> | ||
<span class="loader"></span> | ||
| ||
<div id="text" class="text">Loading</div> | ||
</body> | ||
<script> | ||
const { ipcRenderer } = require("electron"); | ||
ipcRenderer.on("response", (event, arg) => { | ||
document.getElementById("text").innerText = arg; | ||
}); | ||
ipcRenderer.send("check", "Starting check..."); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
* { | ||
box-sizing: border-box; | ||
margin: 0px; | ||
padding: 0px; | ||
height: 100%; | ||
} | ||
|
||
body { | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.text { | ||
font-family: monospace; | ||
font-size: 14px; | ||
height: fit-content; | ||
} | ||
|
||
.loader { | ||
width: 18px; | ||
height: 18px; | ||
border-radius: 50%; | ||
display: inline-block; | ||
position: relative; | ||
background: linear-gradient(0deg, white 10%, purple 100%); | ||
box-sizing: border-box; | ||
animation: rotation 1s linear infinite; | ||
} | ||
|
||
.loader::after { | ||
content: ""; | ||
box-sizing: border-box; | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 14px; | ||
height: 14px; | ||
border-radius: 50%; | ||
background: white; | ||
} | ||
@keyframes rotation { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
Oops, something went wrong.