From b314ee5b05cb69d63d43b9c268b66b0893e9dff5 Mon Sep 17 00:00:00 2001 From: jash Date: Mon, 8 Oct 2018 18:10:48 +0200 Subject: [PATCH] better readability --- .../generators/app/prompters/000_proxy.js | 18 +++++++++++---- .../generators/app/prompters/100_bitcoin.js | 23 ++++++++++++++----- .../generators/app/prompters/200_lightning.js | 16 ++++++++++--- .../generators/app/prompters/300_electrum.js | 15 ++++++++++-- .../generators/app/prompters/400_otsclient.js | 12 +++++++++- .../generators/app/prompters/999_installer.js | 20 +++++++++++----- 6 files changed, 82 insertions(+), 22 deletions(-) diff --git a/install/generator-cyphernode/generators/app/prompters/000_proxy.js b/install/generator-cyphernode/generators/app/prompters/000_proxy.js index 70d6954..3804458 100644 --- a/install/generator-cyphernode/generators/app/prompters/000_proxy.js +++ b/install/generator-cyphernode/generators/app/prompters/000_proxy.js @@ -1,5 +1,15 @@ +const chalk = require('chalk'); + const name = 'proxy'; +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + module.exports = { name: function() { return name; @@ -10,14 +20,14 @@ module.exports = { // input, confirm, list, rawlist, expand, checkbox, password, editor type: 'checkbox', name: 'features', - message: 'What features do you want to add to your cyphernode?'+'\n', + message: prefix()+'What features do you want to add to your cyphernode?'+'\n', choices: utils._featureChoices() }, { type: 'list', name: 'net', default: utils._getDefault( 'net' ), - message: 'What net do you want to run on?'+'\n', + message: prefix()+'What net do you want to run on?'+'\n', choices: [{ name: "Testnet", value: "testnet" @@ -30,14 +40,14 @@ module.exports = { type: 'input', name: 'xpub', default: utils._getDefault( 'xpub' ), - message: 'What is your xpub to watch?'+'\n', + message: prefix()+'What is your xpub to watch?'+'\n', validate: utils._xkeyValidator }, { type: 'input', name: 'derivation_path', default: utils._getDefault( 'derivation_path' ), - message: 'What is your address derivation path?'+'\n', + message: prefix()+'What is your address derivation path?'+'\n', validate: utils._derivationPathValidator }]; }, diff --git a/install/generator-cyphernode/generators/app/prompters/100_bitcoin.js b/install/generator-cyphernode/generators/app/prompters/100_bitcoin.js index bd5e6d4..97fe606 100644 --- a/install/generator-cyphernode/generators/app/prompters/100_bitcoin.js +++ b/install/generator-cyphernode/generators/app/prompters/100_bitcoin.js @@ -1,4 +1,15 @@ +const chalk = require('chalk'); + const name = 'bitcoin'; + +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + const bitcoinExternal = function(props) { return props.bitcoin_mode === 'external' }; @@ -17,7 +28,7 @@ module.exports = { type: 'list', name: 'bitcoin_mode', default: utils._getDefault( 'bitcoin_mode' ), - message: 'Where is your bitcoin full node running?'+'\n', + message: prefix()+'Where is your bitcoin full node running?'+'\n', choices: [ { name: 'Nowhere! I want cyphernode to run one.', @@ -35,33 +46,33 @@ module.exports = { name: 'bitcoin_node_ip', default: utils._getDefault( 'bitcoin_node_ip' ), validate: utils._ipOrFQDNValidator, - message: 'What is your full node ip address?'+'\n', + message: prefix()+'What is your full node ip address?'+'\n', }, { type: 'input', name: 'bitcoin_rpcuser', default: utils._getDefault( 'bitcoin_rpcuser' ), - message: 'Name of bitcoin rpc user?'+'\n', + message: prefix()+'Name of bitcoin rpc user?'+'\n', }, { type: 'password', name: 'bitcoin_rpcpassword', default: utils._getDefault( 'bitcoin_rpcpassword' ), - message: 'Password of bitcoin rpc user?'+'\n', + message: prefix()+'Password of bitcoin rpc user?'+'\n', }, { when: bitcoinInternal, type: 'confirm', name: 'bitcoin_prune', default: utils._getDefault( 'bitcoin_prune' ), - message: 'Run bitcoin node in prune mode?'+'\n', + message: prefix()+'Run bitcoin node in prune mode?'+'\n', }, { when: bitcoinInternal, type: 'input', name: 'bitcoin_uacomment', default: utils._getDefault( 'bitcoin_uacomment' ), - message: 'Any UA comment?'+'\n', + message: prefix()+'Any UA comment?'+'\n', }]; }, env: function( props ) { diff --git a/install/generator-cyphernode/generators/app/prompters/200_lightning.js b/install/generator-cyphernode/generators/app/prompters/200_lightning.js index 8553a6f..c4d8dba 100644 --- a/install/generator-cyphernode/generators/app/prompters/200_lightning.js +++ b/install/generator-cyphernode/generators/app/prompters/200_lightning.js @@ -1,14 +1,24 @@ const path = require('path'); +const chalk = require('chalk'); const name = 'lightning'; + +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + const featureCondition = function(props) { return props.features && props.features.indexOf( name ) != -1; -} +}; const templates = { 'lnd': [ path.join('lnd','lnd.conf') ], 'c-lightning': [ path.join('c-lightning','config') ] -} +}; module.exports = { name: function() { @@ -20,7 +30,7 @@ module.exports = { type: 'list', name: 'lightning_implementation', default: utils._getDefault( 'lightning_implementation' ), - message: 'What lightning implementation do you want to use?'+'\n', + message: prefix()+'What lightning implementation do you want to use?'+'\n', choices: [ { name: 'C-lightning', diff --git a/install/generator-cyphernode/generators/app/prompters/300_electrum.js b/install/generator-cyphernode/generators/app/prompters/300_electrum.js index c374918..e5949c5 100644 --- a/install/generator-cyphernode/generators/app/prompters/300_electrum.js +++ b/install/generator-cyphernode/generators/app/prompters/300_electrum.js @@ -1,7 +1,18 @@ +const chalk = require('chalk'); + const name = 'electrum'; + +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + const featureCondition = function(props) { return props.features && props.features.indexOf( name ) != -1; -} +}; module.exports = { name: function() { @@ -13,7 +24,7 @@ module.exports = { type: 'list', name: 'electrum_implementation', default: utils._getDefault( 'electrum_implementation' ), - message: 'What electrum implementation do you want to use?'+'\n', + message: prefix()+'What electrum implementation do you want to use?'+'\n', choices: [ { name: 'Electrum personal server', diff --git a/install/generator-cyphernode/generators/app/prompters/400_otsclient.js b/install/generator-cyphernode/generators/app/prompters/400_otsclient.js index 80cd80c..ad78afd 100644 --- a/install/generator-cyphernode/generators/app/prompters/400_otsclient.js +++ b/install/generator-cyphernode/generators/app/prompters/400_otsclient.js @@ -1,8 +1,18 @@ +const chalk = require('chalk'); const name = 'otsclient'; + +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + const featureCondition = function(props) { return props.features && props.features.indexOf( name ) != -1; -} +}; module.exports = { name: function() { diff --git a/install/generator-cyphernode/generators/app/prompters/999_installer.js b/install/generator-cyphernode/generators/app/prompters/999_installer.js index b0c6544..68ab366 100644 --- a/install/generator-cyphernode/generators/app/prompters/999_installer.js +++ b/install/generator-cyphernode/generators/app/prompters/999_installer.js @@ -3,6 +3,14 @@ const chalk = require('chalk'); const name = 'installer'; +const capitalise = function( txt ) { + return txt.charAt(0).toUpperCase() + txt.substr(1); +}; + +const prefix = function() { + return chalk.green(capitalise(name)+': '); +}; + const installerDocker = function(props) { return props.installer_mode === 'docker' }; @@ -20,7 +28,7 @@ module.exports = { type: 'list', name: 'installer_mode', default: utils._getDefault( 'installer_mode' ), - message: chalk.red('Where do you want to install cyphernode?')+'\n', + message: prefix()+chalk.red('Where do you want to install cyphernode?')+'\n', choices: [{ name: "Docker", value: "docker" @@ -36,7 +44,7 @@ module.exports = { name: 'proxy_datapath', default: utils._getDefault( 'proxy_datapath' ), validate: utils._pathValidator, - message: 'Where to store your proxy db?'+'\n', + message: prefix()+'Where to store your proxy db?'+'\n', }, { when: function(props) { return installerDocker(props) && props.bitcoin_mode === 'internal' }, @@ -44,7 +52,7 @@ module.exports = { name: 'bitcoin_datapath', default: utils._getDefault( 'bitcoin_datapath' ), validate: utils._pathValidator, - message: 'Where is your blockchain data?'+'\n', + message: prefix()+'Where is your blockchain data?'+'\n', }, { when: function(props) { return installerDocker(props) && props.features.indexOf('lightning') !== -1 }, @@ -52,21 +60,21 @@ module.exports = { name: 'lightning_datapath', default: utils._getDefault( 'lightning_datapath' ), validate: utils._pathValidator, - message: 'Where is your lightning node data?'+'\n', + message: prefix()+'Where is your lightning node data?'+'\n', }, { when: function(props) { return installerDocker(props) && props.bitcoin_mode === 'internal' }, type: 'confirm', name: 'bitcoin_expose', default: utils._getDefault( 'bitcoin_expose' ), - message: 'Expose bitcoin full node outside of the docker network?'+'\n', + message: prefix()+'Expose bitcoin full node outside of the docker network?'+'\n', }, { when: installerLunanode, type: 'confirm', name: 'installer_confirm_lunanode', default: utils._getDefault( 'installer_confirm_lunanode' ), - message: 'Lunanode?! No wayyyy!'+'\n' + message: prefix()+'Lunanode?! No wayyyy!'+'\n' }]; }, templates: function( props ) {