Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new command for setting configuration about IPFS, Ethereum or NKN…
… locally
- Loading branch information
Showing
12 changed files
with
398 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
|
||
var Log = require('../../../lib/Log'); | ||
|
||
var Spinner = require('../../../lib/Spinner'); | ||
|
||
var WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs.option('network', { | ||
type: 'string', | ||
describe: 'network', | ||
require: true | ||
}).option('provider', { | ||
type: 'string', | ||
describe: 'provider', | ||
require: true | ||
}).option('port', { | ||
type: 'string', | ||
describe: 'port', | ||
require: true | ||
}).example('kaizen set-ethereum --network <net work id> --provider <provider> --port <port>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
var network = argv.network, | ||
provider = argv.provider, | ||
port = argv.port; | ||
var settings = { | ||
ethereum: { | ||
network: network, | ||
provider: provider, | ||
port: port | ||
} | ||
}; | ||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== Ethereum configuration setting successfully ===='); | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
var command = 'set-ethereum'; | ||
var commandDescription = 'To set the configuration of Ethereum locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
}; |
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,52 @@ | ||
"use strict"; | ||
|
||
var Log = require('../../../lib/Log'); | ||
|
||
var Spinner = require('../../../lib/Spinner'); | ||
|
||
var WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs.option('host', { | ||
type: 'string', | ||
describe: 'host', | ||
require: true | ||
}).option('port', { | ||
type: 'string', | ||
describe: 'port', | ||
require: true | ||
}).option('protocol', { | ||
type: 'string', | ||
describe: 'protocol', | ||
require: true | ||
}).example('kaizen set-ipfs --host <host> --protocol <protocol> --port <port>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
var host = argv.host, | ||
port = argv.port, | ||
protocol = argv.protocol; | ||
var settings = { | ||
ipfs: { | ||
host: host, | ||
protocol: protocol, | ||
port: port | ||
} | ||
}; | ||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== IPFS configuration setting successfully ===='); | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
var command = 'set-ipfs'; | ||
var commandDescription = 'To set the configuration of IPFS locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
}; |
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,52 @@ | ||
"use strict"; | ||
|
||
var Log = require('../../../lib/Log'); | ||
|
||
var Spinner = require('../../../lib/Spinner'); | ||
|
||
var WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs.option('identifier', { | ||
type: 'string', | ||
describe: 'identifier', | ||
require: true | ||
}).option('private-key', { | ||
type: 'string', | ||
describe: 'private key', | ||
require: true | ||
}).option('rpc-server', { | ||
type: 'string', | ||
describe: 'seed RPC server address', | ||
require: true | ||
}).example('kaizen set-nkn --identifier <identifier> --private-key <private key> --rpc-server <seed RPC server address>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
var identifier = argv.identifier, | ||
privateKey = argv.privateKey, | ||
rpcServer = argv.rpcServer; | ||
var settings = { | ||
nkn: { | ||
identifier: identifier, | ||
privateKey: privateKey, | ||
rpcServer: rpcServer | ||
} | ||
}; | ||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== NKN configuration setting successfully ===='); | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
var command = 'set-nkn'; | ||
var commandDescription = 'To set the configuration of NKN locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
}; |
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,26 @@ | ||
"use strict"; | ||
|
||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
|
||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
var path = require('path'); | ||
|
||
var fsx = require('fs-extra'); | ||
|
||
module.exports = function (settings) { | ||
var configPath = path.resolve('./', 'kaizen.json'); | ||
var kaizenConfiguration = retrieveKaizenConfiguration(configPath); | ||
|
||
var newConfiguration = _objectSpread({}, kaizenConfiguration, settings); | ||
|
||
fsx.writeJsonSync(configPath, newConfiguration); | ||
}; | ||
|
||
function retrieveKaizenConfiguration(configPath) { | ||
if (fsx.existsSync(configPath) === false) { | ||
return {}; | ||
} | ||
|
||
return fsx.readJsonSync(configPath); | ||
} |
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,13 @@ | ||
"use strict"; | ||
|
||
var IPFS_Setting = require('./IPFS'); | ||
|
||
var Ethereum_Setting = require('./Ethereum'); | ||
|
||
var NKN_Setting = require('./NKN'); | ||
|
||
module.exports = function (yargs) { | ||
IPFS_Setting(yargs); | ||
Ethereum_Setting(yargs); | ||
NKN_Setting(yargs); | ||
}; |
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 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,56 @@ | ||
const Log = require('../../../lib/Log'); | ||
const Spinner = require('../../../lib/Spinner'); | ||
const WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs | ||
.option('network', { | ||
type: 'string', | ||
describe: 'network', | ||
require: true | ||
}) | ||
.option('provider', { | ||
type: 'string', | ||
describe: 'provider', | ||
require: true | ||
}) | ||
.option('port', { | ||
type: 'string', | ||
describe: 'port', | ||
require: true | ||
}) | ||
.example('kaizen set-ethereum --network <net work id> --provider <provider> --port <port>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
const { | ||
network, | ||
provider, | ||
port | ||
} = argv; | ||
|
||
const settings = { | ||
ethereum: { | ||
network, | ||
provider, | ||
port | ||
} | ||
}; | ||
|
||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== Ethereum configuration setting successfully ====') | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
const command = 'set-ethereum'; | ||
const commandDescription = 'To set the configuration of Ethereum locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
} |
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,56 @@ | ||
const Log = require('../../../lib/Log'); | ||
const Spinner = require('../../../lib/Spinner'); | ||
const WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs | ||
.option('host', { | ||
type: 'string', | ||
describe: 'host', | ||
require: true | ||
}) | ||
.option('port', { | ||
type: 'string', | ||
describe: 'port', | ||
require: true | ||
}) | ||
.option('protocol', { | ||
type: 'string', | ||
describe: 'protocol', | ||
require: true | ||
}) | ||
.example('kaizen set-ipfs --host <host> --protocol <protocol> --port <port>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
const { | ||
host, | ||
port, | ||
protocol | ||
} = argv; | ||
|
||
const settings = { | ||
ipfs : { | ||
host, | ||
protocol, | ||
port | ||
} | ||
}; | ||
|
||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== IPFS configuration setting successfully ====') | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
const command = 'set-ipfs'; | ||
const commandDescription = 'To set the configuration of IPFS locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
} |
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,56 @@ | ||
const Log = require('../../../lib/Log'); | ||
const Spinner = require('../../../lib/Spinner'); | ||
const WriteKaizen = require('../WriteKaizen.js'); | ||
|
||
function builder(yargs) { | ||
return yargs | ||
.option('identifier', { | ||
type: 'string', | ||
describe: 'identifier', | ||
require: true | ||
}) | ||
.option('private-key', { | ||
type: 'string', | ||
describe: 'private key', | ||
require: true | ||
}) | ||
.option('rpc-server', { | ||
type: 'string', | ||
describe: 'seed RPC server address', | ||
require: true | ||
}) | ||
.example('kaizen set-nkn --identifier <identifier> --private-key <private key> --rpc-server <seed RPC server address>'); | ||
} | ||
|
||
function handler(argv) { | ||
try { | ||
Spinner.start(); | ||
const { | ||
identifier, | ||
privateKey, | ||
rpcServer | ||
} = argv; | ||
|
||
const settings = { | ||
nkn: { | ||
identifier, | ||
privateKey, | ||
rpcServer | ||
} | ||
}; | ||
|
||
WriteKaizen(settings); | ||
Spinner.stop(); | ||
Log.SuccessLog('==== NKN configuration setting successfully ====') | ||
} catch (error) { | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(error); | ||
} | ||
} | ||
|
||
module.exports = function (yargs) { | ||
const command = 'set-nkn'; | ||
const commandDescription = 'To set the configuration of NKN locally'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
} |
Oops, something went wrong.