@teambit/importer 0.0.307 → 0.0.309

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fetch-cmd.js CHANGED
@@ -31,16 +31,6 @@ function _chalk() {
31
31
  return data;
32
32
  }
33
33
 
34
- function _ramda() {
35
- const data = _interopRequireDefault(require("ramda"));
36
-
37
- _ramda = function () {
38
- return data;
39
- };
40
-
41
- return data;
42
- }
43
-
44
34
  function _mergeVersion() {
45
35
  const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version");
46
36
 
@@ -70,7 +60,7 @@ class FetchCmd {
70
60
  fromOriginalScope = false
71
61
  }) {
72
62
  const {
73
- dependencies,
63
+ importedIds,
74
64
  importDetails
75
65
  } = await this.importer.fetch(ids, lanes, components, fromOriginalScope);
76
66
 
@@ -80,16 +70,12 @@ class FetchCmd {
80
70
  }, null, 4);
81
71
  }
82
72
 
83
- if (dependencies && !_ramda().default.isEmpty(dependencies)) {
84
- const componentsObj = dependencies.map(_ramda().default.prop('component'));
85
- const title = componentsObj.length === 1 ? 'successfully fetched one component' : `successfully fetched ${componentsObj.length} components`;
86
- const componentDependencies = componentsObj.map(component => {
87
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
88
- const details = importDetails.find(c => c.id === component.id.toStringWithoutVersion()); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
89
-
90
- if (!details) throw new Error(`missing details of component ${component.id.toString()}`); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
91
-
92
- return formatPlainComponentItemWithVersions(component, details);
73
+ if (importedIds.length) {
74
+ const title = importedIds.length === 1 ? 'successfully fetched one component' : `successfully fetched ${importedIds.length} components`;
75
+ const componentDependencies = importedIds.map(id => {
76
+ const details = importDetails.find(c => c.id === id.toStringWithoutVersion());
77
+ if (!details) throw new Error(`missing details of component ${id.toString()}`);
78
+ return formatPlainComponentItemWithVersions(id, details);
93
79
  });
94
80
  const componentDependenciesOutput = [_chalk().default.green(title)].concat(componentDependencies).join('\n');
95
81
  return componentDependenciesOutput;
@@ -102,12 +88,11 @@ class FetchCmd {
102
88
 
103
89
  exports.FetchCmd = FetchCmd;
104
90
 
105
- function formatPlainComponentItemWithVersions(component, importDetails) {
91
+ function formatPlainComponentItemWithVersions(bitId, importDetails) {
106
92
  const status = importDetails.status;
107
- const id = component.id.toStringWithoutVersion();
108
- const versions = importDetails.versions.length ? `new versions: ${importDetails.versions.join(', ')}` : ''; // $FlowFixMe component.version should be set here
109
-
110
- const usedVersion = status === 'added' ? `, currently used version ${component.version}` : '';
93
+ const id = bitId.toStringWithoutVersion();
94
+ const versions = importDetails.versions.length ? `new versions: ${importDetails.versions.join(', ')}` : '';
95
+ const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : '';
111
96
 
112
97
  const getConflictMessage = () => {
113
98
  if (!importDetails.filesStatus) return '';
@@ -1 +1 @@
1
- {"version":3,"names":["FetchCmd","constructor","importer","report","ids","lanes","components","json","fromOriginalScope","dependencies","importDetails","fetch","JSON","stringify","R","isEmpty","componentsObj","map","prop","title","length","componentDependencies","component","details","find","c","id","toStringWithoutVersion","Error","toString","formatPlainComponentItemWithVersions","componentDependenciesOutput","chalk","green","concat","join","yellow","status","versions","usedVersion","version","getConflictMessage","filesStatus","conflictedFiles","Object","keys","filter","file","FileStatus","manual","bold","deprecated","missingDeps","red","d","cyan"],"sources":["fetch-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport R from 'ramda';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport { FileStatus } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport { ImporterMain } from './importer.main.runtime';\nimport { ImportDetails, ImportStatus } from './import-components';\n\nexport class FetchCmd implements Command {\n name = 'fetch [ids...]';\n description = `fetch remote objects and store locally`;\n extendedDescription = `for lanes, use \"/\" as a separator between the remote and the lane name, e.g. teambit.ui/fix-button`;\n alias = '';\n private = true;\n options = [\n [\n 'l',\n 'lanes',\n 'EXPERIMENTAL. fetch component objects from lanes. note, it does not save the remote lanes objects locally, only the refs',\n ],\n ['c', 'components', 'fetch components'],\n ['j', 'json', 'return the output as JSON'],\n [\n '',\n 'from-original-scopes',\n 'fetch indirect dependencies from their original scope as opposed to from their dependents',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(private importer: ImporterMain) {}\n\n async report(\n [ids = []]: [string[]],\n {\n lanes = false,\n components = false,\n json = false,\n fromOriginalScope = false,\n }: {\n lanes?: boolean;\n components?: boolean;\n json?: boolean;\n fromOriginalScope?: boolean;\n }\n ) {\n const { dependencies, importDetails } = await this.importer.fetch(ids, lanes, components, fromOriginalScope);\n if (json) {\n return JSON.stringify({ importDetails }, null, 4);\n }\n if (dependencies && !R.isEmpty(dependencies)) {\n const componentsObj = dependencies.map(R.prop('component'));\n const title =\n componentsObj.length === 1\n ? 'successfully fetched one component'\n : `successfully fetched ${componentsObj.length} components`;\n const componentDependencies = componentsObj.map((component) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const details = importDetails.find((c) => c.id === component.id.toStringWithoutVersion());\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (!details) throw new Error(`missing details of component ${component.id.toString()}`);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return formatPlainComponentItemWithVersions(component, details);\n });\n const componentDependenciesOutput = [chalk.green(title)].concat(componentDependencies).join('\\n');\n\n return componentDependenciesOutput;\n }\n return chalk.yellow('nothing to import');\n }\n}\n\nfunction formatPlainComponentItemWithVersions(component: Component, importDetails: ImportDetails) {\n const status: ImportStatus = importDetails.status;\n const id = component.id.toStringWithoutVersion();\n const versions = importDetails.versions.length ? `new versions: ${importDetails.versions.join(', ')}` : '';\n // $FlowFixMe component.version should be set here\n const usedVersion = status === 'added' ? `, currently used version ${component.version}` : '';\n const getConflictMessage = () => {\n if (!importDetails.filesStatus) return '';\n const conflictedFiles = Object.keys(importDetails.filesStatus) // $FlowFixMe file is set\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n .filter((file) => importDetails.filesStatus[file] === FileStatus.manual);\n if (!conflictedFiles.length) return '';\n return `(the following files were saved with conflicts ${conflictedFiles\n .map((file) => chalk.bold(file))\n .join(', ')}) `;\n };\n const deprecated = importDetails.deprecated ? chalk.yellow('deprecated') : '';\n const missingDeps = importDetails.missingDeps.length\n ? chalk.red(`missing dependencies: ${importDetails.missingDeps.map((d) => d.toString()).join(', ')}`)\n : '';\n return `- ${chalk.green(status)} ${chalk.cyan(\n id\n )} ${versions}${usedVersion} ${getConflictMessage()}${deprecated} ${missingDeps}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,QAAN,CAAkC;EAsBvCC,WAAW,CAASC,QAAT,EAAiC;IAAA,KAAxBA,QAAwB,GAAxBA,QAAwB;IAAA,8CArBrC,gBAqBqC;IAAA,qDApB7B,wCAoB6B;IAAA,6DAnBrB,oGAmBqB;IAAA,+CAlBpC,EAkBoC;IAAA,iDAjBlC,IAiBkC;IAAA,iDAhBlC,CACR,CACE,GADF,EAEE,OAFF,EAGE,0HAHF,CADQ,EAMR,CAAC,GAAD,EAAM,YAAN,EAAoB,kBAApB,CANQ,EAOR,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAPQ,EAQR,CACE,EADF,EAEE,sBAFF,EAGE,2FAHF,CARQ,CAgBkC;IAAA,gDAFnC,IAEmC;EAAE;;EAElC,MAANC,MAAM,CACV,CAACC,GAAG,GAAG,EAAP,CADU,EAEV;IACEC,KAAK,GAAG,KADV;IAEE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BhC,MAA1B,GAChBY,gBAAA,CAAMqB,GAAN,CAAW,yBAAwB3C,aAAa,CAAC0C,WAAd,CAA0BnC,GAA1B,CAA+BqC,CAAD,IAAOA,CAAC,CAACzB,QAAF,EAArC,EAAmDM,IAAnD,CAAwD,IAAxD,CAA8D,EAAjG,CADgB,GAEhB,EAFJ;EAGA,OAAQ,KAAIH,gBAAA,CAAMC,KAAN,CAAYI,MAAZ,CAAoB,IAAGL,gBAAA,CAAMuB,IAAN,CACjC7B,EADiC,CAEjC,IAAGY,QAAS,GAAEC,WAAY,IAAGE,kBAAkB,EAAG,GAAEU,UAAW,IAAGC,WAAY,EAFhF;AAGD"}
1
+ {"version":3,"names":["FetchCmd","constructor","importer","report","ids","lanes","components","json","fromOriginalScope","importedIds","importDetails","fetch","JSON","stringify","length","title","componentDependencies","map","id","details","find","c","toStringWithoutVersion","Error","toString","formatPlainComponentItemWithVersions","componentDependenciesOutput","chalk","green","concat","join","yellow","bitId","status","versions","usedVersion","version","getConflictMessage","filesStatus","conflictedFiles","Object","keys","filter","file","FileStatus","manual","bold","deprecated","missingDeps","red","d","cyan"],"sources":["fetch-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { FileStatus } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport { ImporterMain } from './importer.main.runtime';\nimport { ImportDetails, ImportStatus } from './import-components';\n\nexport class FetchCmd implements Command {\n name = 'fetch [ids...]';\n description = `fetch remote objects and store locally`;\n extendedDescription = `for lanes, use \"/\" as a separator between the remote and the lane name, e.g. teambit.ui/fix-button`;\n alias = '';\n private = true;\n options = [\n [\n 'l',\n 'lanes',\n 'EXPERIMENTAL. fetch component objects from lanes. note, it does not save the remote lanes objects locally, only the refs',\n ],\n ['c', 'components', 'fetch components'],\n ['j', 'json', 'return the output as JSON'],\n [\n '',\n 'from-original-scopes',\n 'fetch indirect dependencies from their original scope as opposed to from their dependents',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(private importer: ImporterMain) {}\n\n async report(\n [ids = []]: [string[]],\n {\n lanes = false,\n components = false,\n json = false,\n fromOriginalScope = false,\n }: {\n lanes?: boolean;\n components?: boolean;\n json?: boolean;\n fromOriginalScope?: boolean;\n }\n ) {\n const { importedIds, importDetails } = await this.importer.fetch(ids, lanes, components, fromOriginalScope);\n if (json) {\n return JSON.stringify({ importDetails }, null, 4);\n }\n if (importedIds.length) {\n const title =\n importedIds.length === 1\n ? 'successfully fetched one component'\n : `successfully fetched ${importedIds.length} components`;\n const componentDependencies = importedIds.map((id) => {\n const details = importDetails.find((c) => c.id === id.toStringWithoutVersion());\n if (!details) throw new Error(`missing details of component ${id.toString()}`);\n return formatPlainComponentItemWithVersions(id, details);\n });\n const componentDependenciesOutput = [chalk.green(title)].concat(componentDependencies).join('\\n');\n\n return componentDependenciesOutput;\n }\n return chalk.yellow('nothing to import');\n }\n}\n\nfunction formatPlainComponentItemWithVersions(bitId: BitId, importDetails: ImportDetails) {\n const status: ImportStatus = importDetails.status;\n const id = bitId.toStringWithoutVersion();\n const versions = importDetails.versions.length ? `new versions: ${importDetails.versions.join(', ')}` : '';\n const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : '';\n const getConflictMessage = () => {\n if (!importDetails.filesStatus) return '';\n const conflictedFiles = Object.keys(importDetails.filesStatus) // $FlowFixMe file is set\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n .filter((file) => importDetails.filesStatus[file] === FileStatus.manual);\n if (!conflictedFiles.length) return '';\n return `(the following files were saved with conflicts ${conflictedFiles\n .map((file) => chalk.bold(file))\n .join(', ')}) `;\n };\n const deprecated = importDetails.deprecated ? chalk.yellow('deprecated') : '';\n const missingDeps = importDetails.missingDeps.length\n ? chalk.red(`missing dependencies: ${importDetails.missingDeps.map((d) => d.toString()).join(', ')}`)\n : '';\n return `- ${chalk.green(status)} ${chalk.cyan(\n id\n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,CAErBI,MAFqB,CAEbC,IAAD,IAAUjC,aAAa,CAAC4B,WAAd,CAA0BK,IAA1B,MAAoCC,0BAAA,CAAWC,MAF3C,CAAxB;IAGA,IAAI,CAACN,eAAe,CAACzB,MAArB,EAA6B,OAAO,EAAP;IAC7B,OAAQ,kDAAiDyB,eAAe,CACrEtB,GADsD,CACjD0B,IAAD,IAAUhB,gBAAA,CAAMmB,IAAN,CAAWH,IAAX,CADwC,EAEtDb,IAFsD,CAEjD,IAFiD,CAE3C,IAFd;EAGD,CATD;;EAUA,MAAMiB,UAAU,GAAGrC,aAAa,CAACqC,UAAd,GAA2BpB,gBAAA,CAAMI,MAAN,CAAa,YAAb,CAA3B,GAAwD,EAA3E;EACA,MAAMiB,WAAW,GAAGtC,aAAa,CAACsC,WAAd,CAA0BlC,MAA1B,GAChBa,gBAAA,CAAMsB,GAAN,CAAW,yBAAwBvC,aAAa,CAACsC,WAAd,CAA0B/B,GAA1B,CAA+BiC,CAAD,IAAOA,CAAC,CAAC1B,QAAF,EAArC,EAAmDM,IAAnD,CAAwD,IAAxD,CAA8D,EAAjG,CADgB,GAEhB,EAFJ;EAGA,OAAQ,KAAIH,gBAAA,CAAMC,KAAN,CAAYK,MAAZ,CAAoB,IAAGN,gBAAA,CAAMwB,IAAN,CACjCjC,EADiC,CAEjC,IAAGgB,QAAS,GAAEC,WAAY,IAAGE,kBAAkB,EAAG,GAAEU,UAAW,IAAGC,WAAY,EAFhF;AAGD"}
@@ -7,6 +7,9 @@ import { Lane } from '@teambit/legacy/dist/scope/models';
7
7
  import Component from '@teambit/legacy/dist/consumer/component';
8
8
  import { FilesStatus, MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';
9
9
  import { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';
10
+ import VersionDependencies from '@teambit/legacy/dist/scope/version-dependencies';
11
+ import { GraphMain } from '@teambit/graph';
12
+ import { Workspace } from '@teambit/workspace';
10
13
  export declare type ImportOptions = {
11
14
  ids: string[];
12
15
  verbose?: boolean;
@@ -47,31 +50,30 @@ export declare type ImportDetails = {
47
50
  removed?: boolean;
48
51
  };
49
52
  export declare type ImportResult = {
50
- dependencies: ComponentWithDependencies[];
51
- envComponents?: Component[];
53
+ importedIds: BitId[];
54
+ importedDeps: BitId[];
55
+ writtenComponents?: Component[];
52
56
  importDetails: ImportDetails[];
53
57
  cancellationMessage?: string;
54
58
  };
55
59
  export default class ImportComponents {
60
+ private workspace;
61
+ private graph;
62
+ options: ImportOptions;
56
63
  consumer: Consumer;
57
64
  scope: Scope;
58
- options: ImportOptions;
59
65
  mergeStatus: {
60
66
  [id: string]: FilesStatus;
61
67
  };
62
68
  private laneObjects;
63
69
  private divergeData;
64
- constructor(consumer: Consumer, options: ImportOptions);
70
+ constructor(workspace: Workspace, graph: GraphMain, options: ImportOptions);
65
71
  importComponents(): Promise<ImportResult>;
66
72
  importObjectsOnLane(): Promise<ImportResult>;
67
73
  importSpecificComponents(): Promise<ImportResult>;
68
74
  _fetchDivergeData(componentsWithDependencies: ComponentWithDependencies[]): Promise<void>;
69
75
  _throwForDivergedHistory(): void;
70
- /**
71
- * it can happen for example when importing a component with `--dependent` flag and the component has
72
- * the same dependent with different versions. we only want the one with the higher version
73
- */
74
- _filterComponentsWithLowerVersions(componentsWithDependencies: ComponentWithDependencies[]): ComponentWithDependencies[];
76
+ private _importComponentsObjects;
75
77
  /**
76
78
  * consider the following use cases:
77
79
  * 1) no ids were provided. it should import all the lanes components objects AND main components objects
@@ -94,7 +96,7 @@ export default class ImportComponents {
94
96
  /**
95
97
  * get import details, includes the diff between the versions array before import and after import
96
98
  */
97
- _getImportDetails(currentVersions: ImportedVersions, components: ComponentWithDependencies[]): Promise<ImportDetails[]>;
99
+ _getImportDetails(currentVersions: ImportedVersions, components: VersionDependencies[]): Promise<ImportDetails[]>;
98
100
  _throwForPotentialIssues(ids: BitIds): Promise<void>;
99
101
  _throwForModifiedOrNewComponents(ids: BitIds): Promise<void>;
100
102
  /**
@@ -2,10 +2,14 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ require("core-js/modules/es.array.flat.js");
6
+
5
7
  require("core-js/modules/es.array.flat-map.js");
6
8
 
7
9
  require("core-js/modules/es.array.iterator.js");
8
10
 
11
+ require("core-js/modules/es.array.unscopables.flat.js");
12
+
9
13
  require("core-js/modules/es.array.unscopables.flat-map.js");
10
14
 
11
15
  require("core-js/modules/es.promise.js");
@@ -45,16 +49,6 @@ function _ramda() {
45
49
  return data;
46
50
  }
47
51
 
48
- function _semver() {
49
- const data = _interopRequireDefault(require("semver"));
50
-
51
- _semver = function () {
52
- return data;
53
- };
54
-
55
- return data;
56
- }
57
-
58
52
  function _bitError() {
59
53
  const data = require("@teambit/bit-error");
60
54
 
@@ -75,16 +69,6 @@ function _pMapSeries() {
75
69
  return data;
76
70
  }
77
71
 
78
- function _componentVersion() {
79
- const data = require("@teambit/component-version");
80
-
81
- _componentVersion = function () {
82
- return data;
83
- };
84
-
85
- return data;
86
- }
87
-
88
72
  function _listScope() {
89
73
  const data = require("@teambit/legacy/dist/api/consumer/lib/list-scope");
90
74
 
@@ -235,19 +219,38 @@ function _manyComponentsWriter() {
235
219
  return data;
236
220
  }
237
221
 
222
+ function _scopeComponentsImporter() {
223
+ const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/component-ops/scope-components-importer"));
224
+
225
+ _scopeComponentsImporter = function () {
226
+ return data;
227
+ };
228
+
229
+ return data;
230
+ }
231
+
232
+ function _versionDependencies() {
233
+ const data = require("@teambit/legacy/dist/scope/version-dependencies");
234
+
235
+ _versionDependencies = function () {
236
+ return data;
237
+ };
238
+
239
+ return data;
240
+ }
241
+
238
242
  class ImportComponents {
239
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
240
- // @ts-ignore
241
- constructor(consumer, options) {
243
+ constructor(workspace, graph, options) {
244
+ this.workspace = workspace;
245
+ this.graph = graph;
246
+ this.options = options;
242
247
  (0, _defineProperty2().default)(this, "consumer", void 0);
243
248
  (0, _defineProperty2().default)(this, "scope", void 0);
244
- (0, _defineProperty2().default)(this, "options", void 0);
245
249
  (0, _defineProperty2().default)(this, "mergeStatus", void 0);
246
250
  (0, _defineProperty2().default)(this, "laneObjects", void 0);
247
251
  (0, _defineProperty2().default)(this, "divergeData", []);
248
- this.consumer = consumer;
249
- this.scope = consumer.scope;
250
- this.options = options;
252
+ this.consumer = this.workspace.consumer;
253
+ this.scope = this.consumer.scope;
251
254
  this.laneObjects = this.options.lanes ? this.options.lanes.lanes : [];
252
255
  }
253
256
 
@@ -280,7 +283,7 @@ class ImportComponents {
280
283
  const bitIds = await this.getBitIds();
281
284
  lane ? _logger().default.debug(`importObjectsOnLane, Lane: ${lane.id()}, Ids: ${bitIds.toString()}`) : _logger().default.debug(`importObjectsOnLane, the lane does not exist on the remote. importing only the main components`);
282
285
  const beforeImportVersions = await this._getCurrentVersions(bitIds);
283
- const componentsWithDependencies = await this.consumer.importComponentsObjects(bitIds, {
286
+ const versionDependenciesArr = await this._importComponentsObjects(bitIds, {
284
287
  allHistory: this.options.allHistory,
285
288
  lane
286
289
  }); // import lane components from their original scope, this way, it's possible to run diff/merge on them.
@@ -294,7 +297,7 @@ class ImportComponents {
294
297
  // scope and once from the lane-scope.
295
298
  const mainIdsLatest = _bitId().BitIds.fromArray(lane.toBitIds().map(m => m.changeVersion(undefined)));
296
299
 
297
- await this.consumer.importComponentsObjects(mainIdsLatest, {
300
+ await this._importComponentsObjects(mainIdsLatest, {
298
301
  allHistory: this.options.allHistory,
299
302
  ignoreMissingHead: true
300
303
  });
@@ -304,29 +307,25 @@ class ImportComponents {
304
307
  const mergeAllLanesResults = await (0, _pMapSeries().default)(this.laneObjects, laneObject => this.scope.sources.mergeLane(laneObject, true));
305
308
  const mergedLanes = mergeAllLanesResults.map(result => result.mergeLane);
306
309
  await Promise.all(mergedLanes.map(mergedLane => this.scope.lanes.saveLane(mergedLane)));
307
-
308
- const componentsWithDependenciesFiltered = this._filterComponentsWithLowerVersions(componentsWithDependencies);
309
-
310
- await this._fetchDivergeData(componentsWithDependenciesFiltered);
311
-
312
- this._throwForDivergedHistory();
313
-
314
- await this._writeToFileSystem(componentsWithDependenciesFiltered);
315
- await this._saveLaneDataIfNeeded(componentsWithDependenciesFiltered);
316
- const importDetails = await this._getImportDetails(beforeImportVersions, componentsWithDependencies);
310
+ const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);
317
311
  return {
318
- dependencies: componentsWithDependenciesFiltered,
312
+ importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
313
+ importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
319
314
  importDetails
320
315
  };
321
316
  }
322
317
 
323
318
  async importSpecificComponents() {
319
+ var _this$laneObjects;
320
+
324
321
  _logger().default.debug(`importSpecificComponents, Ids: ${this.options.ids.join(', ')}`);
325
322
 
326
323
  const bitIds = await this.getBitIds();
327
324
  const beforeImportVersions = await this._getCurrentVersions(bitIds);
328
325
  await this._throwForPotentialIssues(bitIds);
329
- const componentsWithDependencies = await this.consumer.importComponentsHarmony(bitIds, true, this.laneObjects);
326
+ const versionDependenciesArr = await this._importComponentsObjects(bitIds, {
327
+ lane: (_this$laneObjects = this.laneObjects) === null || _this$laneObjects === void 0 ? void 0 : _this$laneObjects[0]
328
+ });
330
329
 
331
330
  if (this.laneObjects && this.options.objectsOnly) {
332
331
  // merge the lane objects
@@ -335,17 +334,24 @@ class ImportComponents {
335
334
  await Promise.all(mergedLanes.map(mergedLane => this.scope.lanes.saveLane(mergedLane)));
336
335
  }
337
336
 
338
- const componentsWithDependenciesFiltered = this._filterComponentsWithLowerVersions(componentsWithDependencies);
337
+ let writtenComponents = [];
339
338
 
340
- await this._fetchDivergeData(componentsWithDependenciesFiltered);
339
+ if (!this.options.objectsOnly) {
340
+ const componentsWithDependencies = await (0, _versionDependencies().multipleVersionDependenciesToConsumer)(versionDependenciesArr, this.scope.objects);
341
+ await this._fetchDivergeData(componentsWithDependencies);
341
342
 
342
- this._throwForDivergedHistory();
343
+ this._throwForDivergedHistory();
343
344
 
344
- await this._writeToFileSystem(componentsWithDependenciesFiltered);
345
- await this._saveLaneDataIfNeeded(componentsWithDependenciesFiltered);
346
- const importDetails = await this._getImportDetails(beforeImportVersions, componentsWithDependencies);
345
+ await this._writeToFileSystem(componentsWithDependencies);
346
+ await this._saveLaneDataIfNeeded(componentsWithDependencies);
347
+ writtenComponents = componentsWithDependencies.map(c => c.component);
348
+ }
349
+
350
+ const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);
347
351
  return {
348
- dependencies: componentsWithDependenciesFiltered,
352
+ importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
353
+ importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
354
+ writtenComponents,
349
355
  importDetails
350
356
  };
351
357
  }
@@ -379,17 +385,25 @@ class ImportComponents {
379
385
  throw new (_componentsPendingMerge().default)(divergeData);
380
386
  }
381
387
  }
382
- /**
383
- * it can happen for example when importing a component with `--dependent` flag and the component has
384
- * the same dependent with different versions. we only want the one with the higher version
385
- */
386
388
 
389
+ async _importComponentsObjects(ids, {
390
+ fromOriginalScope = false,
391
+ allHistory = false,
392
+ lane,
393
+ ignoreMissingHead = false
394
+ }) {
395
+ const scopeComponentsImporter = _scopeComponentsImporter().default.getInstance(this.scope);
387
396
 
388
- _filterComponentsWithLowerVersions(componentsWithDependencies) {
389
- return componentsWithDependencies.filter(comp => {
390
- const sameIdHigherVersion = componentsWithDependencies.find(c => !c.component.id.isEqual(comp.component.id) && c.component.id.isEqualWithoutVersion(comp.component.id) && (0, _componentVersion().isTag)(c.component.id.version) && (0, _componentVersion().isTag)(comp.component.id.version) && _semver().default.gt(c.component.id.version, comp.component.id.version));
391
- return !sameIdHigherVersion;
397
+ await scopeComponentsImporter.importManyDeltaWithoutDeps(ids, allHistory, lane, ignoreMissingHead);
398
+
399
+ _loader().default.start(`import ${ids.length} components with their dependencies (if missing)`);
400
+
401
+ const results = fromOriginalScope ? await scopeComponentsImporter.importManyFromOriginalScopes(ids) : await scopeComponentsImporter.importMany({
402
+ ids,
403
+ ignoreMissingHead,
404
+ lanes: lane ? [lane] : undefined
392
405
  });
406
+ return results;
393
407
  }
394
408
  /**
395
409
  * consider the following use cases:
@@ -477,9 +491,14 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
477
491
  }
478
492
 
479
493
  if (this.options.importDependents) {
480
- const dependentsIds = this._getDependentsFromGraph(bitIds, graphs);
494
+ const graph = await this.graph.getGraph();
495
+ const targetCompIds = await this.workspace.resolveMultipleComponentIds(bitIds);
496
+ const sourceIds = await this.workspace.listIds();
497
+ const ids = graph.findIdsFromSourcesToTargets(sourceIds, targetCompIds);
481
498
 
482
- bitIds.push(...dependentsIds);
499
+ _logger().default.debug(`found ${ids.length} component for --dependents flag`, ids.map(id => id.toString()));
500
+
501
+ bitIds.push(...ids.map(id => id._legacy));
483
502
  }
484
503
  }
485
504
 
@@ -529,25 +548,36 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
529
548
 
530
549
  await this._throwForModifiedOrNewComponents(componentsIdsToImport);
531
550
  const beforeImportVersions = await this._getCurrentVersions(componentsIdsToImport);
532
- let componentsAndDependencies = [];
533
551
 
534
- if (componentsIdsToImport.length) {
535
- // change all ids version to 'latest'. otherwise, it tries to import local tags/snaps from a remote
536
- // const idsWithLatestVersion = componentsIdsToImport.toVersionLatest();
537
- if (!this.options.objectsOnly) {
538
- throw new Error(`bit import with no ids and --merge flag was not implemented yet`);
539
- }
552
+ if (!componentsIdsToImport.length) {
553
+ return {
554
+ importedIds: [],
555
+ importedDeps: [],
556
+ importDetails: []
557
+ };
558
+ }
540
559
 
541
- componentsAndDependencies = await this.consumer.importComponentsObjects(componentsIdsToImport, {
542
- fromOriginalScope: this.options.fromOriginalScope,
543
- allHistory: this.options.allHistory
544
- });
545
- await this._writeToFileSystem(componentsAndDependencies);
560
+ if (!this.options.objectsOnly) {
561
+ throw new Error(`bit import with no ids and --merge flag was not implemented yet`);
562
+ }
563
+
564
+ const versionDependenciesArr = await this._importComponentsObjects(componentsIdsToImport, {
565
+ fromOriginalScope: this.options.fromOriginalScope,
566
+ allHistory: this.options.allHistory
567
+ });
568
+ let writtenComponents = [];
569
+
570
+ if (!this.options.objectsOnly) {
571
+ const componentWithDependencies = await (0, _versionDependencies().multipleVersionDependenciesToConsumer)(versionDependenciesArr, this.scope.objects);
572
+ await this._writeToFileSystem(componentWithDependencies);
573
+ writtenComponents = componentWithDependencies.map(c => c.component);
546
574
  }
547
575
 
548
- const importDetails = await this._getImportDetails(beforeImportVersions, componentsAndDependencies);
576
+ const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);
549
577
  return {
550
- dependencies: componentsAndDependencies,
578
+ importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
579
+ importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
580
+ writtenComponents,
551
581
  importDetails
552
582
  };
553
583
  }
@@ -596,7 +626,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
596
626
 
597
627
  const filesStatus = this.mergeStatus && this.mergeStatus[idStr] ? this.mergeStatus[idStr] : null;
598
628
  const deprecated = await modelComponent.isDeprecated(this.scope.objects);
599
- const removed = component.component.removed;
629
+ const removed = await component.component.component.isRemoved(this.scope.objects);
600
630
  const latestVersion = modelComponent.latest();
601
631
  return {
602
632
  id: idStr,
@@ -604,7 +634,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
604
634
  latestVersion: versionDifference.includes(latestVersion) ? latestVersion : null,
605
635
  status: getStatus(),
606
636
  filesStatus,
607
- missingDeps: component.missingDependencies,
637
+ missingDeps: component.getMissingDependencies(),
608
638
  deprecated,
609
639
  removed
610
640
  };