Skip to content

Commit

Permalink
Merge pull request #114 from PortalNetwork/dev
Browse files Browse the repository at this point in the history
v0.0.15
  • Loading branch information
PhyrexTsai authored Dec 10, 2018
2 parents 3e1a491 + 01586f4 commit b756cb0
Show file tree
Hide file tree
Showing 27 changed files with 286 additions and 54 deletions.
File renamed without changes.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ kaizen upload ipfs ./build
- `kaizen contracts` - Contract management for KAIZEN
- `kaizen contracts deploy` - Deploy smart contract
- `kaizen blockchains` - Blockchain management for KAIZEN
- `kaizen blockchains txresult` - Get transaction result
- `kaizen blockchains tx` - Get transaction result
- `kaizen blockchains balance` - Get account balance
- `kaizen blockchains faucet` - Get testnet token

#### Platform (Alpha)
The KAIZEN Platform is currently in experimental alpha.
- `kaizen login` - Login or sign up for the KAIZEN Platform
- `kaizen logout` - Logout from the KAIZEN Platform
- `kaizen instances` - Instance management of KAIZEN Platform
- `kaizen instances list` - Lists all instances
- `kaizen instances info` - Show instance information
- `kaizen instances deploy` - Deploy an instance

## <a name="plugins"></a>🏗 Plugins
- Bluzelle
Expand Down
4 changes: 2 additions & 2 deletions build/components/Blockchains/Faucet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function builder(yargs) {
alias: 'a',
type: 'string',
describe: 'Your wallet address'
}).demandOption(['blockchain'], 'Please enter blockchain name').demandOption(['network'], 'Please enter network').demandOption(['address'], 'Please enter your wallet address').example('kaizen blockchains faucet --blockchain eth --network 3 --address 0x2d2B3CD3E585fF4065B55668dCac22EBd9E3590D');
}).demandOption(['blockchain', 'network', 'address'], '').example('kaizen blockchains faucet --blockchain eth --network 3 --address 0x2d2B3CD3E585fF4065B55668dCac22EBd9E3590D').epilogue('Support blockchain faucet:\n\n'.underline.yellow + 'ethereum'.underline.yellow + ' - Ethereum Ropsten testnet, network: ' + '3\n'.yellow + 'wanchain'.underline.yellow + ' - Wanchain testnet, network: ' + '3\n'.yellow + 'icon'.underline.yellow + ' - ICON Yeouido testnet, network: ' + '3\n'.yellow + 'quarkchain'.underline.yellow + ' - QuarkChain testnet, network: ' + '3'.yellow);
}

function handler(_x) {
Expand Down Expand Up @@ -162,6 +162,6 @@ function claimToken(name, address) {

module.exports = function (yargs) {
var command = 'faucet';
var commandDescription = 'Claim token';
var commandDescription = 'Get testnet token';
yargs.command(command, commandDescription, builder, handler);
};
4 changes: 1 addition & 3 deletions build/components/Blockchains/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function builder(yargs) {
require('./List')(yargs);

require('./Faucet')(yargs);

require('./Tx')(yargs);

require('./Balance')(yargs);

return yargs.example('kaizen blockchains list').example('kaizen blockchains tx').example('kaizen blockchains balance').example('kaizen blockchains faucet').demandCommand();
return yargs.example('kaizen blockchains tx').example('kaizen blockchains balance').example('kaizen blockchains faucet').demandCommand(1, '').epilogue('Support blockchains:\n\n'.underline.yellow + 'ethereum'.underline.yellow + ' - Etheruem blockchain\n' + 'wanchain'.underline.yellow + ' - Wanchain blockchain\n' + '\nRun ' + '\'kaizen blockchains <command>\''.yellow + ' to interact with blockchain.\n');
}

function handler(_x) {
Expand Down
2 changes: 1 addition & 1 deletion build/components/Config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function builder(yargs) {
alias: 'v',
type: 'string',
describe: 'Configuration value'
}).example('kaizen config --key <KEY> --value <VALUE>').demandOption(['key'], 'Please enter your key').demandOption(['value'], 'Please enter your value');
}).example('kaizen config --key <KEY> --value <VALUE>').demandOption(['key', 'value'], '');
}

function handler(_x) {
Expand Down
2 changes: 1 addition & 1 deletion build/components/Contracts/Deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function builder(yargs) {
alias: 'u',
type: 'string',
describe: 'URL of the template contract'
}).demandOption(['url'], 'Please enter the url of the template contract').example('kaizen contracts deploy -u https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20');
}).example('kaizen contracts deploy -u https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20').demandOption(['url'], '').epilogue('Please enter the url of the template contract\n\n' + 'Support contract template:\n\n'.underline.yellow + 'ERC20'.underline.yellow + ' - ERC20 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20'.underline.yellow + '\n' + 'ERC721'.underline.yellow + ' - ERC721 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC721'.underline.yellow + '\n');
}

function handler(_x) {
Expand Down
2 changes: 1 addition & 1 deletion build/components/Contracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
function builder(yargs) {
require('./Deploy')(yargs);

return yargs.example('kaizen contracts deploy').demandCommand();
return yargs.example('kaizen contracts deploy').demandCommand(1, '').epilogue('You can develop, test, deploy smart contract though KAIZEN CLI\n\n' + 'Support contract template:\n\n'.underline.yellow + 'ERC20'.underline.yellow + ' - ERC20 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20'.underline.yellow + '\n' + 'ERC721'.underline.yellow + ' - ERC721 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC721'.underline.yellow + '\n');
}

function handler(_x) {
Expand Down
2 changes: 1 addition & 1 deletion build/components/Platform/Instances/Deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function builder(yargs) {
describe: 'Network of the instance',
require: true,
choices: ['mainnet', 'testnet']
}).example('kaizen instances deploy --protocol ipfs-gateway --network mainnet').demandOption(['protocol'], 'Please enter instance protocol').demandOption(['network'], 'Please enter instance network');
}).example('kaizen instances deploy --protocol ipfs-gateway --network mainnet').demandOption(['protocol', 'network'], '');
}

function handler(_x) {
Expand Down
109 changes: 109 additions & 0 deletions build/components/Platform/Instances/Info/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use strict";

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var path = require('path');

var fsx = require('fs-extra');

var Table = require('cli-table');

var Log = require('../../../../lib/Log');

var Spinner = require('../../../../lib/Spinner');

var _require = require('../../../../lib/apis'),
apiKaizenInstanceInfo = _require.apiKaizenInstanceInfo;

require('colors');

function builder(yargs) {
return yargs.option('instance', {
alias: 'i',
type: 'string',
describe: 'Instance id',
require: true
}).option('type', {
alias: 't',
type: 'string',
describe: 'Type of the instance',
require: true,
default: 'SHARED',
choices: ['SHARED', 'PUBLIC', 'PRIVATE']
}).example('kaizen instances info --instance 7 --type SHARED');
}

function handler(_x) {
return _handler.apply(this, arguments);
}

function _handler() {
_handler = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(argv) {
var instance, type, config, instanceInfo, data, table;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
instance = argv.instance, type = argv.type;
config = fsx.readJsonSync(path.resolve(__dirname, '../../../../../.kaizenrc'));

if (config.idToken) {
_context.next = 6;
break;
}

Log.ErrorLog('Please login first, use \'kaizen login\' to login into KAIZEN Platform');
return _context.abrupt("return");

case 6:
Spinner.start();
_context.next = 9;
return apiKaizenInstanceInfo(config.idToken, instance, type);

case 9:
instanceInfo = _context.sent;
Spinner.stop();

if (instanceInfo.data) {
Log.SuccessLog('Get instance information'); // TODO table display

data = instanceInfo.data;
table = new Table({
head: ['Instance Id'.green, 'Name'.green, 'Protocol'.green, 'Network'.green, 'Provider'.green, 'Region'.green, 'Public DNS'.green]
});
table.push([data.instanceid, data.name, data.protocol, data.network, data.provider, data.region, data.publicdns]);
console.log(table.toString()); //Log.NormalLog(table.toString());
} else {
Log.NormalLog('Can not find instance');
}

_context.next = 19;
break;

case 14:
_context.prev = 14;
_context.t0 = _context["catch"](0);
Spinner.stop();
Log.ErrorLog('something went wrong!');
console.error(_context.t0);

case 19:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 14]]);
}));
return _handler.apply(this, arguments);
}

module.exports = function (yargs) {
var command = 'info';
var commandDescription = 'Show instance information';
yargs.command(command, commandDescription, builder, handler);
};
6 changes: 4 additions & 2 deletions build/components/Platform/Instances/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function builder(yargs) {

require('./List')(yargs);

return yargs.example('kaizen instances deploy').example('kaizen instances list').demandCommand(1, '');
require('./Info')(yargs);

return yargs.example('kaizen instances deploy').example('kaizen instances info').example('kaizen instances list').demandCommand(1, '');
}

function handler(_x) {
Expand All @@ -35,6 +37,6 @@ function _handler() {

module.exports = function (yargs) {
var command = 'instances';
var commandDescription = 'Instance management for KAIZEN';
var commandDescription = 'Instance management of KAIZEN Platform';
yargs.command(command, commandDescription, builder, handler);
};
4 changes: 3 additions & 1 deletion build/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require("@babel/polyfill");

require('colors');

var yargs = require('yargs');

require('./Config')(yargs);
Expand Down Expand Up @@ -33,5 +35,5 @@ require('./Platform/Logout')(yargs);

require('./Platform/Instances')(yargs);

yargs.demandCommand(1, 'You need at least one command before moving on');
yargs.demandCommand(1, '').epilogue('Welcome to KAIZEN\n\n'.yellow + 'KAIZEN Framework\n'.underline.yellow + 'Not sure how to use?\n'.gray + 'Use ' + '\'kaizen create -t react --n myproject\''.yellow + ' to start a new project.\n' + 'Try ' + '\'kaizen install -u <GITHUB_URL>\''.yellow + ' to download example project.\n\n' + 'KAIZEN Platform (Alpha)\n'.underline.yellow + 'Interact with KAIZEN Platform, please login first.\n'.grey + 'Use ' + '\'kaizen login\''.yellow + ' to login KAIZEN Platform.\n\n' + 'More information and documentation, please visit:\n' + 'https://github.com/PortalNetwork/kaizen-cli'.yellow.underline + '\n');
module.exports = yargs;
12 changes: 12 additions & 0 deletions build/lib/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ exports.apiKaizenInstanceList = function (idToken) {
});
};

exports.apiKaizenInstanceInfo = function (idToken, instanceId, type) {
return axios.get('https://api.portal.network/kaizen/v1/instance/info', {
headers: {
Authorization: idToken
},
params: {
id: instanceId,
type: type
}
});
};

exports.apiKaizenCreateSharedInstance = function (idToken, protocol, network) {
return axios.post('https://api.portal.network/kaizen/v1/instance/shared', {
protocol: protocol,
Expand Down
4 changes: 4 additions & 0 deletions build/lib/aws/AWSService.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ var AWS = require('aws-sdk');
var fs = require('fs');

var instance = require('ami.json');
/**
* DOCS: https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/user-data.html
*/


var AWSService =
/*#__PURE__*/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "kaizen-cli",
"version": "0.0.15",
"bin": {
"kaizen": "kaizen"
},
"version": "0.0.14",
"description": "kaizen-cli",
"main": "index.js",
"main": "kaizen",
"preferGlobal": true,
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/polyfill": "^7.0.0",
Expand Down Expand Up @@ -69,7 +70,8 @@
"lib": "lib"
},
"keywords": [
"blockchain"
"blockchain",
"kaizen"
],
"devDependencies": {
"@babel/cli": "^7.1.0",
Expand Down
15 changes: 10 additions & 5 deletions src/components/Blockchains/Faucet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ function builder(yargs) {
type: 'string',
describe: 'Your wallet address',
})
.demandOption(['blockchain'], 'Please enter blockchain name')
.demandOption(['network'], 'Please enter network')
.demandOption(['address'], 'Please enter your wallet address')
.example('kaizen blockchains faucet --blockchain eth --network 3 --address 0x2d2B3CD3E585fF4065B55668dCac22EBd9E3590D');
.demandOption(['blockchain', 'network', 'address'], '')
.example('kaizen blockchains faucet --blockchain eth --network 3 --address 0x2d2B3CD3E585fF4065B55668dCac22EBd9E3590D')
.epilogue(
'Support blockchain faucet:\n\n'.underline.yellow +
'ethereum'.underline.yellow + ' - Ethereum Ropsten testnet, network: ' + '3\n'.yellow +
'wanchain'.underline.yellow + ' - Wanchain testnet, network: ' + '3\n'.yellow +
'icon'.underline.yellow + ' - ICON Yeouido testnet, network: ' + '3\n'.yellow +
'quarkchain'.underline.yellow + ' - QuarkChain testnet, network: ' + '3'.yellow
);
}

async function handler(argv) {
Expand Down Expand Up @@ -97,6 +102,6 @@ function claimToken(name, address) {

module.exports = function (yargs) {
const command = 'faucet';
const commandDescription = 'Claim token';
const commandDescription = 'Get testnet token';
yargs.command(command, commandDescription, builder, handler);
}
20 changes: 0 additions & 20 deletions src/components/Blockchains/List/index.js

This file was deleted.

11 changes: 8 additions & 3 deletions src/components/Blockchains/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
function builder(yargs) {
require('./List')(yargs);
require('./Faucet')(yargs);
require('./Tx')(yargs);
require('./Balance')(yargs);
return yargs
.example('kaizen blockchains list')
.example('kaizen blockchains tx')
.example('kaizen blockchains balance')
.example('kaizen blockchains faucet')
.demandCommand();
.demandCommand(1, '')
.epilogue(
'Support blockchains:\n\n'.underline.yellow +
'ethereum'.underline.yellow + ' - Etheruem blockchain\n' +
'wanchain'.underline.yellow + ' - Wanchain blockchain\n' +
'\nRun ' + '\'kaizen blockchains <command>\''.yellow +
' to interact with blockchain.\n'
);
}

async function handler(argv) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function builder(yargs) {
describe: 'Configuration value'
})
.example('kaizen config --key <KEY> --value <VALUE>')
.demandOption(['key'], 'Please enter your key')
.demandOption(['value'], 'Please enter your value');
.demandOption(['key', 'value'], '');
}

async function handler(argv) {
Expand Down
Loading

0 comments on commit b756cb0

Please sign in to comment.