Skip to content

Commit

Permalink
Merge pull request #205 from PhyrexTsai/master
Browse files Browse the repository at this point in the history
Add Sia
  • Loading branch information
PhyrexTsai authored Dec 2, 2019
2 parents 09a5834 + dd5c7b1 commit 587a72a
Show file tree
Hide file tree
Showing 22 changed files with 419 additions and 35 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ The KAIZEN Platform is currently in experimental alpha.
- [ICON](https://www.npmjs.com/package/icon-sdk-js)
- [Orbit](https://www.npmjs.com/package/orbit-db)
- [Arweave](https://www.npmjs.com/package/arweave)
- [Fluence](https://www.npmjs.com/package/fluence)
- [Sia](https://sia.tech/)
- NOIA

## <a name="instances"></a>⚙️ Instances
Expand Down
2 changes: 2 additions & 0 deletions README_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ The KAIZEN Platform is currently in experimental alpha.
- [ICON](https://www.npmjs.com/package/icon-sdk-js)
- [Orbit](https://www.npmjs.com/package/orbit-db)
- [Arweave](https://www.npmjs.com/package/arweave)
- [Fluence](https://www.npmjs.com/package/fluence)
- [Sia](https://sia.tech/)
- NOIA

## <a name="instances"></a>⚙️ 인스턴스
Expand Down
2 changes: 2 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ KAIZEN Platform 目前正在 Alpha 階段
- [ICON](https://www.npmjs.com/package/icon-sdk-js)
- [Orbit](https://www.npmjs.com/package/orbit-db)
- [Arweave](https://www.npmjs.com/package/arweave)
- [Fluence](https://www.npmjs.com/package/fluence)
- [Sia](https://sia.tech/)
- NOIA

## <a name="instances"></a>⚙️ 實例
Expand Down
47 changes: 47 additions & 0 deletions build/components/Plugins/Install/fluence.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"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 ExecuteCommand = require('../../../lib/ExecuteCommand');

module.exports =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var configPath, userConfig;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return ExecuteCommand('npm install fluence');

case 2:
// update user's kaizen config
configPath = path.resolve('./', 'kaizen.json');
userConfig = fsx.existsSync(configPath) ? fsx.readJsonSync(configPath) : {};

if (!userConfig.plugins) {
userConfig.plugins = [];
}

if (userConfig.plugins.includes('fluence') === false) {
userConfig.plugins.push('fluence');
}

fsx.outputJsonSync(path.resolve('./', 'kaizen.json'), userConfig);

case 7:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
54 changes: 40 additions & 14 deletions build/components/Plugins/Install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ var arweaveHandler = require('./arweave.js');

var bandHandler = require('./band.js');

var fluenceHandler = require('./fluence.js');

var siaHandler = require('./sia.js');

function builder(yargs) {
return yargs.positional('plugin', {
alias: 'p',
Expand Down Expand Up @@ -70,7 +74,7 @@ function _handler() {

case 8:
_context.t0 = plugin;
_context.next = _context.t0 === 'bluzelle' ? 11 : _context.t0 === 'nkn' ? 18 : _context.t0 === 'noia' ? 25 : _context.t0 === 'icon' ? 32 : _context.t0 === 'orbit' ? 39 : _context.t0 === 'arweave' ? 46 : _context.t0 === 'band' ? 53 : 60;
_context.next = _context.t0 === 'bluzelle' ? 11 : _context.t0 === 'nkn' ? 18 : _context.t0 === 'noia' ? 25 : _context.t0 === 'icon' ? 32 : _context.t0 === 'orbit' ? 39 : _context.t0 === 'arweave' ? 46 : _context.t0 === 'band' ? 53 : _context.t0 === 'fluence' ? 60 : _context.t0 === 'sia' ? 67 : 74;
break;

case 11:
Expand All @@ -82,7 +86,7 @@ function _handler() {
case 15:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 18:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -93,7 +97,7 @@ function _handler() {
case 22:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 25:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -104,7 +108,7 @@ function _handler() {
case 29:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 32:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -115,7 +119,7 @@ function _handler() {
case 36:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 39:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -126,7 +130,7 @@ function _handler() {
case 43:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 46:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -137,7 +141,7 @@ function _handler() {
case 50:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 53:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -148,28 +152,50 @@ function _handler() {
case 57:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 61);
return _context.abrupt("break", 75);

case 60:
Log.NormalLog('Installing plugin, please wait a second...');
Spinner.start();
_context.next = 64;
return fluenceHandler();

case 64:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 75);

case 67:
Log.NormalLog('Installing plugin, please wait a second...');
Spinner.start();
_context.next = 71;
return siaHandler();

case 71:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 75);

case 74:
Log.NormalLog('Plugin not support yet');

case 61:
_context.next = 68;
case 75:
_context.next = 82;
break;

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

case 68:
case 82:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 63]]);
}, _callee, this, [[0, 77]]);
}));
return _handler.apply(this, arguments);
}
Expand Down
47 changes: 47 additions & 0 deletions build/components/Plugins/Install/sia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"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 ExecuteCommand = require('../../../lib/ExecuteCommand');

module.exports =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var configPath, userConfig;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return ExecuteCommand('npm install sia.js');

case 2:
// update user's kaizen config
configPath = path.resolve('./', 'kaizen.json');
userConfig = fsx.existsSync(configPath) ? fsx.readJsonSync(configPath) : {};

if (!userConfig.plugins) {
userConfig.plugins = [];
}

if (userConfig.plugins.includes('sia') === false) {
userConfig.plugins.push('sia');
}

fsx.outputJsonSync(path.resolve('./', 'kaizen.json'), userConfig);

case 7:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
4 changes: 3 additions & 1 deletion build/components/Plugins/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ function _handler() {
Log.NormalLog('orbit'.underline.yellow + ' - Orbit information');
Log.NormalLog('arweave'.underline.yellow + ' - Arweave information');
Log.NormalLog('band'.underline.yellow + ' - Band Protocol information');
Log.NormalLog('fluence'.underline.yellow + ' - Fluence information');
Log.NormalLog('sia'.underline.yellow + ' - Sia information');
Log.NormalLog("\nTo install a plugin run " + "'kaizen plugins install <plugin-name-here>'".yellow);
Log.NormalLog("\nIt will be automatically downloaded and added to your " + "'package.json'".yellow + " and " + "'kaizen.json'".yellow + " file\n");

case 10:
case 12:
case "end":
return _context.stop();
}
Expand Down
49 changes: 49 additions & 0 deletions build/components/Plugins/Uninstall/fluence.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"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 ExecuteCommand = require('../../../lib/ExecuteCommand');

module.exports =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var configPath, userConfig;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return ExecuteCommand('npm uninstall fluence');

case 2:
// update user's kaizen config
configPath = path.resolve('./', 'kaizen.json');
userConfig = fsx.existsSync(configPath) ? fsx.readJsonSync(configPath) : {};

if (!userConfig.plugins) {
userConfig.plugins = [];
}

if (userConfig.plugins.includes('fluence') === false) {
userConfig.plugins = userConfig.plugins.filter(function (element) {
return element != 'fluence';
});
}

fsx.outputJsonSync(path.resolve('./', 'kaizen.json'), userConfig);

case 7:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
Loading

0 comments on commit 587a72a

Please sign in to comment.