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
61 lines (47 loc) • 2.47 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ejectTemplate;
exports.failureEjectMessage = exports.successEjectMessage = void 0;
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../constants");
_constants = function () {
return data;
};
return data;
}
const successEjectMessage = 'successfully ejected the following components';
exports.successEjectMessage = successEjectMessage;
const failureEjectMessage = 'failed to eject the following components';
exports.failureEjectMessage = failureEjectMessage;
function ejectTemplate(ejectResults) {
const getEjectedOutput = () => {
if (!ejectResults.ejectedComponents.length) return '';
return _chalk().default.green(`${successEjectMessage} ${_chalk().default.bold(ejectResults.ejectedComponents.toString())}\n`);
};
const getFailureOutput = () => {
const failures = ejectResults.failedComponents;
const title = _chalk().default.red(`${failureEjectMessage}\n`);
const modified = failures.modifiedComponents.length ? `stopped the eject process for the following components because they have local changes.
${_chalk().default.bold(failures.modifiedComponents.toString())}
ejecting modified components discards all local, unstaged, changes.
use 'bit diff <component id>' to see the changes and decide if to 'bit tag' them or not.
use the '--force' flag to discard local modifications and proceed with the eject process.\n` : '';
const staged = failures.stagedComponents.length ? `components with local versions (use --force to ignore): ${failures.stagedComponents.toString()}\n` : '';
const notExported = failures.notExportedComponents.length ? `local components that were not exported yet: ${failures.notExportedComponents.toString()}\n` : '';
const selfHosted = failures.selfHostedExportedComponents.length ? `components that were exported to a self hosted scope (not ${_constants().BASE_WEB_DOMAIN}): ${failures.selfHostedExportedComponents.toString()}\n` : '';
const body = modified + staged + notExported + selfHosted;
if (body) return _chalk().default.underline(title) + _chalk().default.red(body);
return '';
};
return getEjectedOutput() + getFailureOutput();
}
;