UNPKG

r8s-cli

Version:

A command line tool for Reaction Commerce to be used with kubernetes

85 lines (62 loc) 2.98 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _filter2 = require('lodash/filter'); var _filter3 = _interopRequireDefault(_filter2); var _child_process = require('child_process'); var _utils = require('../../utils'); var _list = require('./list'); var _list2 = _interopRequireDefault(_list); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } exports.default = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref2) { var name = _ref2.name, path = _ref2.path; var apps, app, namespace, remoteName, remoteAddCommand; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0, _list2.default)(); case 2: apps = _utils.Config.get('global', 'launchdock.apps', []); app = (0, _filter3.default)(apps, function (a) { return a.name === name; })[0]; if (!app) { _utils.Log.warn('\nApp deployment not found'); process.exit(1); } (0, _utils.setGitSSHKeyEnv)(); _utils.Log.info('\nCloning app from the Reaction Platform...\n'); try { (0, _child_process.execSync)('git clone ' + app.git.ssh_url_to_repo + ' ' + (path || ''), { stdio: 'inherit' }); } catch (err) { _utils.Log.error('Failed to clone app'); process.exit(1); } namespace = app.group.namespace; remoteName = namespace + '-' + name; remoteAddCommand = 'git remote add ' + remoteName + ' ' + app.git.ssh_url_to_repo; try { (0, _child_process.execSync)('cd ' + (path || name) + ' && ' + remoteAddCommand, { stdio: 'ignore' }); } catch (err) { _utils.Log.error('Failed to update git remote url. Try adding it manually with: ' + _utils.Log.magenta('' + remoteAddCommand)); process.exit(1); } _utils.Log.info('\nSuccess! App has been cloned into directory: ' + _utils.Log.magenta(path || name) + '\n'); case 13: case 'end': return _context.stop(); } } }, _callee, this); })); function appClone(_x) { return _ref.apply(this, arguments); } return appClone; }();