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

112 lines (82 loc) 2.96 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; function _defineProperty2() { const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); _defineProperty2 = function () { return data; }; return data; } function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = function () { return data; }; return data; } function _consumer() { const data = require("../../../api/consumer"); _consumer = function () { return data; }; return data; } function _utils() { const data = require("../../../utils"); _utils = function () { return data; }; return data; } function _constants() { const data = require("../../../constants"); _constants = function () { return data; }; return data; } class Build { constructor() { (0, _defineProperty2().default)(this, "name", 'build [id]'); (0, _defineProperty2().default)(this, "description", `build any set of components with a configured compiler (as defined in bit.json)\n https://${_constants().BASE_DOCS_DOMAIN}/docs/building-components`); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "opts", [['v', 'verbose [boolean]', 'showing npm verbose output for inspection'], ['c', 'no-cache', 'ignore component cache when creating dist file']]); (0, _defineProperty2().default)(this, "loader", true); (0, _defineProperty2().default)(this, "migration", true); (0, _defineProperty2().default)(this, "remoteOp", true); } // In case the compiler is not installed yet action([id], { noCache = false, verbose = false }) { if (!id) return (0, _consumer().buildAll)(noCache, verbose); return (0, _consumer().build)(id, noCache, verbose); } report(res) { const noCompilerSpecifiedError = _chalk().default.yellow('compiler is not defined, please define a compiler in bit.json'); if (!res) return noCompilerSpecifiedError; if (Array.isArray(res)) { return _chalk().default.cyan(res.join('\n')); } if (typeof res === 'object') { // got from build-all // $FlowFixMe - res is an object if ((0, _utils().empty)(res)) { return _chalk().default.yellow(`nothing to build learn how to set a build step for components - https://${_constants().BASE_DOCS_DOMAIN}/docs/building-components`); } return Object.keys(res).map(component => { const title = _chalk().default.bold(component); // $FlowFixMe - res is an object const content = Array.isArray(res[component]) ? _chalk().default.cyan(res[component].join('\n')) : noCompilerSpecifiedError; return `${title}\n${content}\n`; }).join('\n'); } // $FlowFixMe - res is a string return res; } } exports.default = Build;