-
Notifications
You must be signed in to change notification settings - Fork 11
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 #114 from PortalNetwork/dev
v0.0.15
- Loading branch information
Showing
27 changed files
with
286 additions
and
54 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
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
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,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); | ||
}; |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 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
Oops, something went wrong.