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
76 lines (63 loc) • 2.46 kB
JavaScript
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 _bitId() {
const data = require("../bit-id");
_bitId = function () {
return data;
};
return data;
}
class RemovedObjects {
constructor({
removedComponentIds,
missingComponents,
removedDependencies,
dependentBits
}) {
(0, _defineProperty2().default)(this, "removedComponentIds", void 0);
(0, _defineProperty2().default)(this, "missingComponents", void 0);
(0, _defineProperty2().default)(this, "removedDependencies", void 0);
(0, _defineProperty2().default)(this, "dependentBits", void 0);
this.removedComponentIds = removedComponentIds || new (_bitId().BitIds)();
this.missingComponents = missingComponents || new (_bitId().BitIds)();
this.removedDependencies = removedDependencies || new (_bitId().BitIds)();
this.dependentBits = dependentBits || {};
}
serialize() {
return {
removedComponentIds: this.removedComponentIds.serialize(),
missingComponents: this.missingComponents.serialize(),
removedDependencies: this.removedDependencies.serialize(),
dependentBits: this.dependentBits
};
}
static fromObjects(payload) {
// this function being called from an ssh, so the ids must have a remote scope
const missingComponents = new (_bitId().BitIds)(...payload.missingComponents.map(id => _bitId().BitId.parse(id, true)));
const removedComponentIds = new (_bitId().BitIds)(...payload.removedComponentIds.map(id => _bitId().BitId.parse(id, true)));
const removedDependencies = new (_bitId().BitIds)(...payload.removedDependencies.map(id => _bitId().BitId.parse(id, true)));
const dependentBits = Object.keys(payload.dependentBits).reduce((acc, current) => {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
acc[current] = new (_bitId().BitIds)(...payload.dependentBits[current].map(id => new (_bitId().BitId)(id)));
return acc;
}, {});
return new RemovedObjects({
missingComponents,
removedComponentIds,
removedDependencies,
dependentBits
});
}
}
exports.default = RemovedObjects;
;