Skip to content

Commit

Permalink
Merge pull request #200 from PhyrexTsai/master
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
PhyrexTsai authored Nov 18, 2019
2 parents c50fd50 + 72e150e commit 9559897
Show file tree
Hide file tree
Showing 19 changed files with 335 additions and 114 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,34 @@ KAIZEN is an one stop solution for dapp and dweb developer. With KAIZEN, you get
- [Licence](#licence)

## <a name="quick-start"></a>🚀 Quick Start
1. Install via npm:
STEP 1. Install via npm:
```
npm install -g kaizen-cli
```

2. Create a project:
STEP 2. Create a project:
```
kaizen create --template react --name myproject
```

3. Deploy smart contracts:
STEP 3. Deploy smart contracts:
```
kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20
```

4. Upload project to [IPFS](https://ipfs.io) or [BTFS](https://www.bittorrent.com/btfs/):
STEP 4. Upload project to [IPFS](https://ipfs.io) or [BTFS](https://www.bittorrent.com/btfs/):
```
# Upload to IPFS
kaizen upload ipfs ./build
# or upload to BTFS
kaizen upload btfs ./build
```

STEP 5. Hosting instance on AWS
```
kaizen instances run nym-loopix-mixnode
```

## <a name="command-topics"></a>🔨 Command Topics

- [`kaizen config`](commands/config.md) - Configure KAIZEN
Expand Down
13 changes: 9 additions & 4 deletions README_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,34 @@
- [라이센스](#licence)

## <a name="quick-start"></a>🚀 Quick Start
1. Install via npm:
STEP 1. Install via npm:
```
npm install -g kaizen-cli
```

2. Create a project:
STEP 2. Create a project:
```
kaizen create --template react --name myproject
```

3. Deploy smart contracts:
STEP 3. Deploy smart contracts:
```
kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20
```

4. Upload project to [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/):
STEP 4. Upload project to [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/):
```
# Upload to IPFS
kaizen upload ipfs ./build
# or upload to BTFS
kaizen upload btfs ./build
```

STEP 5. Hosting instance on AWS
```
kaizen instances run nym-loopix-mixnode
```

## <a name="command-topics"></a>🔨 Command Topics

- [`kaizen config`](commands/config.md) - Configure KAIZEN
Expand Down
13 changes: 9 additions & 4 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,34 @@ KAIZEN 包括:
- [許可證](#licence)

## <a name="quick-start"></a>🚀 快速開始
1. 透過 npm 安裝 KAIZEN:
STEP 1. 透過 npm 安裝 KAIZEN:
```
npm install -g kaizen-cli
```

2. 創建專案:
STEP 2. 創建專案:
```
kaizen create --template react --name myproject
```

3. 部署智能合約:
STEP 3. 部署智能合約:
```
kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20
```

4. 上傳專案到 [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/):
STEP 4. 上傳專案到 [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/):
```
# Upload to IPFS
kaizen upload ipfs ./build
# or upload to BTFS
kaizen upload btfs ./build
```

STEP 5. 部署實例於 AWS 上
```
kaizen instances run nym-loopix-mixnode
```

## <a name="command-topics"></a>🔨 指令集

- [`kaizen config`](commands/config.md) - 設定 KAIZEN
Expand Down
105 changes: 105 additions & 0 deletions build/components/Instances/Run/golem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
"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; }

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 Log = require('../../../lib/Log');

var AWSService = require('../../../lib/aws/AWSService');

var path = require('path');

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

module.exports =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(instance, type) {
var kaizenrc, region, awsService, isExists, keyPair, _instance, instances, configuration;

return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'));
region = 'us-east-1';

if (!kaizenrc['accessKey']) {
Log.NormalLog("Please set AWS access key by 'kaizen config set --key accessKey --value [Access Key Value]'");
}

if (!kaizenrc['secretKey']) {
Log.NormalLog("Please set AWS secret key by 'kaizen config set --key secretKey --value [Secret Key Value]'");
}

if (kaizenrc['region']) {
region = kaizenrc['region'];
}

awsService = new AWSService(kaizenrc['accessKey'], kaizenrc['secretKey'], region);
_context.next = 9;
return awsService.isKeyPairsExists('kaizen-cli');

case 9:
isExists = _context.sent;
keyPair = 'kaizen-cli';

if (isExists) {
_context.next = 16;
break;
}

Log.NormalLog('Creating Key Pair:\n'.underline.yellow + 'kaizen-cli.pem'.yellow);
_context.next = 15;
return awsService.createKeyPair();

case 15:
keyPair = _context.sent;

case 16:
_context.next = 18;
return awsService.runInstance(_instance, type);

case 18:
_instance = _context.sent;
instances = [];

if (kaizenrc['instances']) {
instances = kaizenrc['instances'];
}

instances.push(_instance);
configuration = _objectSpread({}, kaizenrc, {
"keyPair": keyPair,
"instances": instances
});
fsx.writeJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'), configuration);
_context.next = 30;
break;

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

case 30:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 26]]);
}));

return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}();
41 changes: 29 additions & 12 deletions build/components/Instances/Run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ var Spinner = require('../../../lib/Spinner');

var nymLoopixMixnodeHandler = require('./nym-loopix-mixnode.js');

var golemHandler = require('./golem.js');

function builder(yargs) {
return yargs.positional('instance', {
alias: 'i',
type: 'string',
describe: 'instance name',
require: true
}).example('kaizen instances run nym-loopix-mixnode').demandOption(['instance'], '');
}).option('type', {
alias: 't',
type: 'string',
describe: 'instance type'
}).example('kaizen instances run nym-loopix-mixnode').example('kaizen instances run golem --type t2.xlarge').demandOption(['instance'], '');
}

function handler(_x) {
Expand All @@ -27,13 +33,13 @@ function _handler() {
_handler = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(argv) {
var instance;
var instance, type;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
instance = argv.instance;
instance = argv.instance, type = argv.type;

if (instance) {
_context.next = 5;
Expand All @@ -45,40 +51,51 @@ function _handler() {

case 5:
_context.t0 = instance;
_context.next = _context.t0 === 'nym-loopix-mixnode' ? 8 : 15;
_context.next = _context.t0 === 'nym-loopix-mixnode' ? 8 : _context.t0 === 'golem' ? 15 : 22;
break;

case 8:
Log.NormalLog("Starting ".concat(instance, " instance, please wait a second..."));
Spinner.start();
_context.next = 12;
return nymLoopixMixnodeHandler();
return nymLoopixMixnodeHandler(instance, type);

case 12:
Spinner.stop();
Log.SuccessLog("Start instance ".concat(instance, " Successfully"));
return _context.abrupt("break", 16);
return _context.abrupt("break", 23);

case 15:
Log.NormalLog("Starting ".concat(instance, " instance, please wait a second..."));
Spinner.start();
_context.next = 19;
return golemHandler(instance, type);

case 19:
Spinner.stop();
Log.SuccessLog("Start instance ".concat(instance, " Successfully"));
return _context.abrupt("break", 23);

case 22:
Log.NormalLog('Instance not support yet');

case 16:
_context.next = 23;
case 23:
_context.next = 30;
break;

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

case 23:
case 30:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 18]]);
}, _callee, this, [[0, 25]]);
}));
return _handler.apply(this, arguments);
}
Expand Down
Loading

0 comments on commit 9559897

Please sign in to comment.