UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

136 lines (103 loc) 3.45 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.CapsuleCreateCmd = void 0; function _bluebird() { const data = require("bluebird"); _bluebird = function () { return data; }; return data; } function _defineProperty2() { const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); _defineProperty2 = function () { return data; }; return data; } function _react() { const data = _interopRequireDefault(require("react")); _react = function () { return data; }; return data; } function _lodash() { const data = _interopRequireDefault(require("lodash")); _lodash = function () { return data; }; return data; } function _ink() { const data = require("ink"); _ink = function () { return data; }; return data; } function _consumer() { const data = require("../../consumer"); _consumer = function () { return data; }; return data; } // eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars class CapsuleCreateCmd { constructor(isolator) { this.isolator = isolator; (0, _defineProperty2().default)(this, "name", 'capsule-create [componentIds...]'); (0, _defineProperty2().default)(this, "description", `create capsule`); (0, _defineProperty2().default)(this, "shortDescription", 'create capsule'); (0, _defineProperty2().default)(this, "group", 'capsules'); (0, _defineProperty2().default)(this, "private", true); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "options", [['b', 'baseDir <name>', 'set base dir of all capsules'], ['a', 'alwaysNew', 'create new environment for capsule'], ['i', 'id <name>', 'reuse capsule of certain name'], ['d', 'installPackages', 'install packages in capsule with npm']]); } create([componentIds], { baseDir, alwaysNew = false, id, installPackages = false }) { var _this = this; return (0, _bluebird().coroutine)(function* () { // TODO: remove this consumer loading from here. it shouldn't be here const consumer = yield (0, _consumer().loadConsumerIfExist)(); // TODO: throw a proper error instance if (!consumer) throw new Error('no consumer found'); const capsuleOptions = _lodash().default.omitBy({ baseDir, installPackages, alwaysNew, name: id }, _lodash().default.isNil); const isolatedEnvironment = yield _this.isolator.createNetworkFromConsumer(componentIds, consumer, capsuleOptions); const capsules = isolatedEnvironment.capsules; return capsules; })(); } render([componentIds], opts) { var _this2 = this; return (0, _bluebird().coroutine)(function* () { // @ts-ignore const capsules = yield _this2.create(componentIds, opts); // TODO: improve output return /*#__PURE__*/_react().default.createElement(_ink().Color, { green: true }, "created capsules ", capsules); })(); } json([componentIds], opts) { var _this3 = this; return (0, _bluebird().coroutine)(function* () { // @ts-ignore const capsules = yield _this3.create(componentIds, opts); return capsules; })(); } } exports.CapsuleCreateCmd = CapsuleCreateCmd;