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
113 lines (86 loc) • 2.6 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _bluebird() {
const data = require("bluebird");
_bluebird = function () {
return data;
};
return data;
}
function _consumer() {
const data = require("../../../consumer");
_consumer = function () {
return data;
};
return data;
}
function _nothingToCompareTo() {
const data = _interopRequireDefault(require("./exceptions/nothing-to-compare-to"));
_nothingToCompareTo = function () {
return data;
};
return data;
}
function _scopeGraph() {
const data = _interopRequireDefault(require("../../../scope/graph/scope-graph"));
_scopeGraph = function () {
return data;
};
return data;
}
var _default = /*#__PURE__*/function () {
var _getConsumerBit = (0, _bluebird().coroutine)(function* ({
id,
compare,
allVersions,
showRemoteVersions,
showDependents,
showDependencies
}) {
const consumer = yield (0, _consumer().loadConsumer)();
const bitId = consumer.getParsedId(id);
if (allVersions) {
return consumer.loadAllVersionsOfComponentFromModel(bitId);
}
const component = yield consumer.loadComponent(bitId); // loads recent component
let dependenciesInfo = [];
let dependentsInfo = [];
if (showDependents || showDependencies) {
const graph = yield _scopeGraph().default.buildGraphFromWorkspace(consumer);
const dependencyGraph = new (_scopeGraph().default)(graph);
const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(component.id);
const componentDepGraph = new (_scopeGraph().default)(componentGraph);
if (showDependents) {
dependentsInfo = componentDepGraph.getDependentsInfo(component.id);
}
if (showDependencies) {
dependenciesInfo = componentDepGraph.getDependenciesInfo(component.id);
}
}
if (showRemoteVersions) {
yield consumer.addRemoteAndLocalVersionsToDependencies(component, true);
}
if (compare) {
if (!component.componentFromModel) throw new (_nothingToCompareTo().default)(id);
return {
component,
componentModel: component.componentFromModel
};
}
yield consumer.onDestroy();
return {
component,
dependentsInfo,
dependenciesInfo
};
});
function getConsumerBit(_x) {
return _getConsumerBit.apply(this, arguments);
}
return getConsumerBit;
}();
exports.default = _default;
;