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

229 lines (171 loc) 4.86 kB
"use strict"; 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 _defineProperty2() { const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); _defineProperty2 = function () { return data; }; return data; } function _scopeLoader() { const data = _interopRequireDefault(require("../../scope-loader")); _scopeLoader = function () { return data; }; return data; } function _scope() { const data = require("../../../api/scope"); _scope = function () { return data; }; return data; } function _exceptions() { const data = require("../exceptions"); _exceptions = function () { return data; }; return data; } function _utils() { const data = require("../../../utils"); _utils = function () { return data; }; return data; } function _search() { const data = require("../../../search"); _search = function () { return data; }; return data; } function _componentsList() { const data = _interopRequireDefault(require("../../../consumer/component/components-list")); _componentsList = function () { return data; }; return data; } function _scopeComponentsImporter() { const data = _interopRequireDefault(require("../../component-ops/scope-components-importer")); _scopeComponentsImporter = function () { return data; }; return data; } function _scopeGraph() { const data = _interopRequireDefault(require("../../graph/scope-graph")); _scopeGraph = function () { return data; }; return data; } class Fs { constructor(scopePath) { (0, _defineProperty2().default)(this, "scopePath", void 0); (0, _defineProperty2().default)(this, "scope", void 0); this.scopePath = scopePath; } close() { return this; } getScope() { if (!this.scope) throw new (_exceptions().FsScopeNotLoaded)(); return this.scope; } describeScope() { return Promise.resolve(this.getScope().describe()); } push(componentObjects) { return this.pushMany([componentObjects]); } pushMany(components) { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return (0, _scope().put)({ path: this.scopePath, componentObjects: components }); } deleteMany(ids, force) { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return (0, _scope().remove)({ path: this.scopePath, ids, force }); } deprecateMany(ids) { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return (0, _scope().deprecate)({ path: this.scopePath, ids }); } undeprecateMany(ids) { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return (0, _scope().undeprecate)({ path: this.scopePath, ids }); } fetch(bitIds, noDependencies = false) { const idsStr = bitIds.serialize(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return (0, _scope().fetch)(this.scopePath, idsStr, noDependencies).then(bitsMatrix => { if (noDependencies) return bitsMatrix; return (0, _utils().flatten)(bitsMatrix); }); } latestVersions(componentIds) { return this.getScope().latestVersions(componentIds).then(componentsIds => componentsIds.map(componentId => componentId.toString())); } list(namespacesUsingWildcards) { return _componentsList().default.listLocalScope(this.getScope(), namespacesUsingWildcards); } search(query, reindex) { return _search().searchAdapter.scopeSearch(this.scopePath, query, reindex); } show(bitId) { const scopeComponentsImporter = _scopeComponentsImporter().default.getInstance(this.getScope()); return scopeComponentsImporter.loadComponent(bitId); } log(bitId) { return this.getScope().loadComponentLogs(bitId); } graph(bitId) { var _this = this; return (0, _bluebird().coroutine)(function* () { const scope = _this.getScope(); const dependencyGraph = yield _scopeGraph().default.loadLatest(scope); // get as string to mimic the exact steps of using ssh const getGraphAsString = () => { if (!bitId) { return dependencyGraph.serialize(); } const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId); return dependencyGraph.serialize(componentGraph); }; const graphStr = getGraphAsString(); return _scopeGraph().default.loadFromString(graphStr); })(); } connect() { return (0, _scopeLoader().default)(this.scopePath).then(scope => { this.scope = scope; return this; }); } } exports.default = Fs;