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
84 lines (65 loc) • 3.1 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _ramda() {
const data = _interopRequireDefault(require("ramda"));
_ramda = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _bitId() {
const data = require("../../bit-id");
_bitId = function () {
return data;
};
return data;
}
var _default = ({
dependentBits,
modifiedComponents = [],
removedComponentIds,
missingComponents
}, isRemote) => {
const paintMissingComponents = () => {
if (_ramda().default.isEmpty(missingComponents)) return '';
return _chalk().default.red('missing components (try to `bit untrack` them instead):') + (0, _chalk().default)(` ${missingComponents.map(id => {
if (!(id instanceof _bitId().BitId)) id = new (_bitId().BitId)(id); // when the id was received from a remote it's not an instance of BitId
return id.version === 'latest' ? id.toStringWithoutVersion() : id.toString();
})}\n`);
};
const paintRemoved = () => {
if (_ramda().default.isEmpty(removedComponentIds)) return '';
const msg = isRemote ? 'successfully removed components from the remote scope:' : 'successfully removed components from the local scope (to remove from the remote scope, please re-run the command with --remote flag):';
return _chalk().default.green(msg) + (0, _chalk().default)(` ${removedComponentIds.map(id => id.version === 'latest' ? id.toStringWithoutVersion() : id.toString())}\n`);
};
const paintUnRemovedComponents = () => {
if (_ramda().default.isEmpty(dependentBits)) return '';
return Object.keys(dependentBits).map(key => {
const header = _chalk().default.underline.red(`error: unable to delete ${key}, because the following components depend on it:`);
const body = dependentBits[key].join('\n');
return `${header}\n${body}`;
}).join('\n\n');
};
const paintModifiedComponents = () => !_ramda().default.isEmpty(modifiedComponents) ? `${_chalk().default.red('error: unable to remove modified components (please use --force to remove modified components)\n') + (0, _chalk().default)( // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
`- ${modifiedComponents.map(id => id.version === 'latest' ? id.toStringWithoutVersion() : id.toString())}`)}` : '';
return (// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
paintUnRemovedComponents(dependentBits) + // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
paintRemoved(removedComponentIds) + // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
paintMissingComponents(missingComponents) + // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
paintModifiedComponents(modifiedComponents)
);
};
exports.default = _default;