Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Merge branch 'cudos-dev' into CUDOS-653
Browse files Browse the repository at this point in the history
  • Loading branch information
aemil145 committed Mar 14, 2022
2 parents 9baadda + 3af9370 commit d36de93
Show file tree
Hide file tree
Showing 11 changed files with 715 additions and 64 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ To start a fresh local Cudos node run
blast node start
```
or you can leave the current terminal window free by running the local node in background. To do this use `--daemon` or `-d`.
or you can show the node logging output in current terminal window. To do this use `--log` or `-l`.
```bash
blast node start -d
blast node start -l
```
To see how to manage local node accounts go [here](#managing-accounts).
Expand Down
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"blast": "./packages/blast-cmd/blast-cmd.js"
},
"dependencies": {
"cudosjs": "0.0.18",
"axios": "^0.25.0",
"cudosjs": "^0.0.19",
"axios": "^0.26.0",
"bip39": "^3.0.4",
"find-up": "^5.0.0",
"fs-extra": "^10.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/blast-cmd/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ const nodeInfo = {
describe: 'Manage a local CUDOS node',
builder: (yargs) => {
yargs.command('start', 'Start a fresh local node', () => {
yargs.option('daemon', {
alias: 'd',
yargs.option('log', {
alias: 'l',
type: 'boolean',
default: false,
description: 'Run the node in background'
description: 'Continuously output the node logs'
})
}, node.startNodeCmd)
.command('stop', 'Stop the running local node', () => {}, node.stopNodeCmd)
Expand Down
2 changes: 1 addition & 1 deletion packages/blast-cmd/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const BlastError = require('../../blast-utilities/blast-error')
const startNodeCmd = async function(argv) {
await checkNodeOffline()

if (argv.daemon) {
if (!argv.logs) {
executeCompose('up --build -d')
} else {
executeComposeAsync('up --build')
Expand Down
2 changes: 2 additions & 0 deletions packages/blast-cmd/run/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ const fs = require('fs')
const vm = require('vm')
const path = require('path')
const BlastError = require('../../blast-utilities/blast-error')
const { checkNodeOnline } = require('../../blast-utilities/get-node-status')

async function runCmd(argv) {
if (!fs.existsSync(`${path.resolve('.')}/${argv.scriptFilePath}`)) {
throw new BlastError(`Script at location ${path.resolve('.')}/${argv.scriptFilePath} does not exist.`)
}
await checkNodeOnline()
require('../../blast-utilities/global-functions')
const ds = new vm.Script(fs.readFileSync(argv.scriptFilePath))
return ds.runInThisContext()
Expand Down
4 changes: 3 additions & 1 deletion packages/blast-cmd/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ const {
getPackageRootPath,
getProjectRootPath
} = require('../../blast-utilities/package-info')
const { checkNodeOnline } = require('../../blast-utilities/get-node-status')

const JS_TESTS_FOLDER_NAME = 'tests'
const GLOBAL_FUNCTIONS = path.join(getPackageRootPath(), 'packages/blast-utilities/global-functions.js')
const JEST_BINARY = path.join(getPackageRootPath(), 'node_modules/.bin/jest')

function testCmd(argv) {
async function testCmd(argv) {
const TEST_DIR = path.join(getProjectRootPath(), JS_TESTS_FOLDER_NAME)
if (!fs.existsSync(TEST_DIR)) {
throw new BlastError('No tests folder found! Make sure to place your JavaScript tests in /' +
JS_TESTS_FOLDER_NAME)
}
await checkNodeOnline()
console.log('Running JavaScript tests...')

spawnSync(`${JEST_BINARY} ${TEST_DIR} --setupFilesAfterEnv=${GLOBAL_FUNCTIONS} --testTimeout=15000 --silent`, {
Expand Down
28 changes: 0 additions & 28 deletions packages/blast-config/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source ./packages/blast-tests/e2e-tests/vars.sh

echo -n 'blast node start...'
cd template
blast node start -d &> /dev/null
blast node start &> /dev/null
cd ..
sleep 45
timer=30
Expand Down
5 changes: 3 additions & 2 deletions packages/blast-utilities/get-node-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ const BlastError = require('./blast-error')
async function checkNodeOnline() {
const nodeStatus = await getNodeStatus()
if (!nodeStatus.isConnected) {
throw new BlastError('Local node is not running.')
throw new BlastError('The node is offline. \n' +
'Make sure you have the correct node URL in the config file and run "blast node start" for a local node')
}
}

async function checkNodeOffline() {
const nodeStatus = await getNodeStatus()
if (nodeStatus.isConnected) {
throw new BlastError('Local node is already running.')
throw new BlastError('A node is already running.')
}
}

Expand Down

0 comments on commit d36de93

Please sign in to comment.