@teambit/importer 0.0.308 → 0.0.310
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 +11 -26
- package/dist/fetch-cmd.js.map +1 -1
- package/dist/import-components.d.ts +11 -11
- package/dist/import-components.js +69 -92
- package/dist/import-components.js.map +1 -1
- package/dist/import.cmd.js +26 -34
- package/dist/import.cmd.js.map +1 -1
- package/dist/importer.main.runtime.d.ts +7 -6
- package/dist/importer.main.runtime.js +26 -37
- package/dist/importer.main.runtime.js.map +1 -1
- package/package-tar/teambit-importer-0.0.310.tgz +0 -0
- package/package.json +11 -13
- package/{preview-1665805128745.js → preview-1666409808293.js} +2 -2
- package/package-tar/teambit-importer-0.0.308.tgz +0 -0
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
|
-
|
|
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 (
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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(
|
|
91
|
+
function formatPlainComponentItemWithVersions(bitId, importDetails) {
|
|
106
92
|
const status = importDetails.status;
|
|
107
|
-
const id =
|
|
108
|
-
const versions = importDetails.versions.length ? `new versions: ${importDetails.versions.join(', ')}` : '';
|
|
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 '';
|
package/dist/fetch-cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FetchCmd","constructor","importer","report","ids","lanes","components","json","fromOriginalScope","
|
|
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 )} ${versions}${usedVersion} ${getConflictMessage()}${deprecated} ${missingDeps}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;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,CAC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3B,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,32 +50,29 @@ export declare type ImportDetails = {
|
|
|
47
50
|
removed?: boolean;
|
|
48
51
|
};
|
|
49
52
|
export declare type ImportResult = {
|
|
50
|
-
|
|
51
|
-
|
|
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(
|
|
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[];
|
|
75
|
-
private _importObjectsDisregardLocalCache;
|
|
76
76
|
private _importComponentsObjects;
|
|
77
77
|
/**
|
|
78
78
|
* consider the following use cases:
|
|
@@ -96,7 +96,7 @@ export default class ImportComponents {
|
|
|
96
96
|
/**
|
|
97
97
|
* get import details, includes the diff between the versions array before import and after import
|
|
98
98
|
*/
|
|
99
|
-
_getImportDetails(currentVersions: ImportedVersions, components:
|
|
99
|
+
_getImportDetails(currentVersions: ImportedVersions, components: VersionDependencies[]): Promise<ImportDetails[]>;
|
|
100
100
|
_throwForPotentialIssues(ids: BitIds): Promise<void>;
|
|
101
101
|
_throwForModifiedOrNewComponents(ids: BitIds): Promise<void>;
|
|
102
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
|
|
|
@@ -256,18 +240,17 @@ function _versionDependencies() {
|
|
|
256
240
|
}
|
|
257
241
|
|
|
258
242
|
class ImportComponents {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
243
|
+
constructor(workspace, graph, options) {
|
|
244
|
+
this.workspace = workspace;
|
|
245
|
+
this.graph = graph;
|
|
246
|
+
this.options = options;
|
|
262
247
|
(0, _defineProperty2().default)(this, "consumer", void 0);
|
|
263
248
|
(0, _defineProperty2().default)(this, "scope", void 0);
|
|
264
|
-
(0, _defineProperty2().default)(this, "options", void 0);
|
|
265
249
|
(0, _defineProperty2().default)(this, "mergeStatus", void 0);
|
|
266
250
|
(0, _defineProperty2().default)(this, "laneObjects", void 0);
|
|
267
251
|
(0, _defineProperty2().default)(this, "divergeData", []);
|
|
268
|
-
this.consumer = consumer;
|
|
269
|
-
this.scope = consumer.scope;
|
|
270
|
-
this.options = options;
|
|
252
|
+
this.consumer = this.workspace.consumer;
|
|
253
|
+
this.scope = this.consumer.scope;
|
|
271
254
|
this.laneObjects = this.options.lanes ? this.options.lanes.lanes : [];
|
|
272
255
|
}
|
|
273
256
|
|
|
@@ -300,7 +283,7 @@ class ImportComponents {
|
|
|
300
283
|
const bitIds = await this.getBitIds();
|
|
301
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`);
|
|
302
285
|
const beforeImportVersions = await this._getCurrentVersions(bitIds);
|
|
303
|
-
const
|
|
286
|
+
const versionDependenciesArr = await this._importComponentsObjects(bitIds, {
|
|
304
287
|
allHistory: this.options.allHistory,
|
|
305
288
|
lane
|
|
306
289
|
}); // import lane components from their original scope, this way, it's possible to run diff/merge on them.
|
|
@@ -324,29 +307,25 @@ class ImportComponents {
|
|
|
324
307
|
const mergeAllLanesResults = await (0, _pMapSeries().default)(this.laneObjects, laneObject => this.scope.sources.mergeLane(laneObject, true));
|
|
325
308
|
const mergedLanes = mergeAllLanesResults.map(result => result.mergeLane);
|
|
326
309
|
await Promise.all(mergedLanes.map(mergedLane => this.scope.lanes.saveLane(mergedLane)));
|
|
327
|
-
|
|
328
|
-
const componentsWithDependenciesFiltered = this._filterComponentsWithLowerVersions(componentsWithDependencies);
|
|
329
|
-
|
|
330
|
-
await this._fetchDivergeData(componentsWithDependenciesFiltered);
|
|
331
|
-
|
|
332
|
-
this._throwForDivergedHistory();
|
|
333
|
-
|
|
334
|
-
await this._writeToFileSystem(componentsWithDependenciesFiltered);
|
|
335
|
-
await this._saveLaneDataIfNeeded(componentsWithDependenciesFiltered);
|
|
336
|
-
const importDetails = await this._getImportDetails(beforeImportVersions, componentsWithDependencies);
|
|
310
|
+
const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);
|
|
337
311
|
return {
|
|
338
|
-
|
|
312
|
+
importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
|
|
313
|
+
importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
|
|
339
314
|
importDetails
|
|
340
315
|
};
|
|
341
316
|
}
|
|
342
317
|
|
|
343
318
|
async importSpecificComponents() {
|
|
319
|
+
var _this$laneObjects;
|
|
320
|
+
|
|
344
321
|
_logger().default.debug(`importSpecificComponents, Ids: ${this.options.ids.join(', ')}`);
|
|
345
322
|
|
|
346
323
|
const bitIds = await this.getBitIds();
|
|
347
324
|
const beforeImportVersions = await this._getCurrentVersions(bitIds);
|
|
348
325
|
await this._throwForPotentialIssues(bitIds);
|
|
349
|
-
const
|
|
326
|
+
const versionDependenciesArr = await this._importComponentsObjects(bitIds, {
|
|
327
|
+
lane: (_this$laneObjects = this.laneObjects) === null || _this$laneObjects === void 0 ? void 0 : _this$laneObjects[0]
|
|
328
|
+
});
|
|
350
329
|
|
|
351
330
|
if (this.laneObjects && this.options.objectsOnly) {
|
|
352
331
|
// merge the lane objects
|
|
@@ -355,17 +334,24 @@ class ImportComponents {
|
|
|
355
334
|
await Promise.all(mergedLanes.map(mergedLane => this.scope.lanes.saveLane(mergedLane)));
|
|
356
335
|
}
|
|
357
336
|
|
|
358
|
-
|
|
337
|
+
let writtenComponents = [];
|
|
359
338
|
|
|
360
|
-
|
|
339
|
+
if (!this.options.objectsOnly) {
|
|
340
|
+
const componentsWithDependencies = await (0, _versionDependencies().multipleVersionDependenciesToConsumer)(versionDependenciesArr, this.scope.objects);
|
|
341
|
+
await this._fetchDivergeData(componentsWithDependencies);
|
|
361
342
|
|
|
362
|
-
|
|
343
|
+
this._throwForDivergedHistory();
|
|
363
344
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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);
|
|
367
351
|
return {
|
|
368
|
-
|
|
352
|
+
importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
|
|
353
|
+
importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
|
|
354
|
+
writtenComponents,
|
|
369
355
|
importDetails
|
|
370
356
|
};
|
|
371
357
|
}
|
|
@@ -399,30 +385,6 @@ class ImportComponents {
|
|
|
399
385
|
throw new (_componentsPendingMerge().default)(divergeData);
|
|
400
386
|
}
|
|
401
387
|
}
|
|
402
|
-
/**
|
|
403
|
-
* it can happen for example when importing a component with `--dependent` flag and the component has
|
|
404
|
-
* the same dependent with different versions. we only want the one with the higher version
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
_filterComponentsWithLowerVersions(componentsWithDependencies) {
|
|
409
|
-
return componentsWithDependencies.filter(comp => {
|
|
410
|
-
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));
|
|
411
|
-
return !sameIdHigherVersion;
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
async _importObjectsDisregardLocalCache(ids, lanes = []) {
|
|
416
|
-
const scopeComponentsImporter = _scopeComponentsImporter().default.getInstance(this.scope);
|
|
417
|
-
|
|
418
|
-
const versionDependenciesArr = await scopeComponentsImporter.importMany({
|
|
419
|
-
ids,
|
|
420
|
-
cache: false,
|
|
421
|
-
lanes
|
|
422
|
-
});
|
|
423
|
-
const componentWithDependencies = await (0, _pMapSeries().default)(versionDependenciesArr, versionDependencies => versionDependencies.toConsumer(this.scope.objects));
|
|
424
|
-
return componentWithDependencies;
|
|
425
|
-
}
|
|
426
388
|
|
|
427
389
|
async _importComponentsObjects(ids, {
|
|
428
390
|
fromOriginalScope = false,
|
|
@@ -436,13 +398,12 @@ class ImportComponents {
|
|
|
436
398
|
|
|
437
399
|
_loader().default.start(`import ${ids.length} components with their dependencies (if missing)`);
|
|
438
400
|
|
|
439
|
-
const
|
|
401
|
+
const results = fromOriginalScope ? await scopeComponentsImporter.importManyFromOriginalScopes(ids) : await scopeComponentsImporter.importMany({
|
|
440
402
|
ids,
|
|
441
403
|
ignoreMissingHead,
|
|
442
404
|
lanes: lane ? [lane] : undefined
|
|
443
405
|
});
|
|
444
|
-
|
|
445
|
-
return componentWithDependencies;
|
|
406
|
+
return results;
|
|
446
407
|
}
|
|
447
408
|
/**
|
|
448
409
|
* consider the following use cases:
|
|
@@ -530,9 +491,14 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
530
491
|
}
|
|
531
492
|
|
|
532
493
|
if (this.options.importDependents) {
|
|
533
|
-
const
|
|
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);
|
|
534
498
|
|
|
535
|
-
|
|
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));
|
|
536
502
|
}
|
|
537
503
|
}
|
|
538
504
|
|
|
@@ -582,25 +548,36 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
582
548
|
|
|
583
549
|
await this._throwForModifiedOrNewComponents(componentsIdsToImport);
|
|
584
550
|
const beforeImportVersions = await this._getCurrentVersions(componentsIdsToImport);
|
|
585
|
-
let componentsAndDependencies = [];
|
|
586
551
|
|
|
587
|
-
if (componentsIdsToImport.length) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
552
|
+
if (!componentsIdsToImport.length) {
|
|
553
|
+
return {
|
|
554
|
+
importedIds: [],
|
|
555
|
+
importedDeps: [],
|
|
556
|
+
importDetails: []
|
|
557
|
+
};
|
|
558
|
+
}
|
|
593
559
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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);
|
|
599
574
|
}
|
|
600
575
|
|
|
601
|
-
const importDetails = await this._getImportDetails(beforeImportVersions,
|
|
576
|
+
const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);
|
|
602
577
|
return {
|
|
603
|
-
|
|
578
|
+
importedIds: versionDependenciesArr.map(v => v.component.id).flat(),
|
|
579
|
+
importedDeps: versionDependenciesArr.map(v => v.allDependenciesIds).flat(),
|
|
580
|
+
writtenComponents,
|
|
604
581
|
importDetails
|
|
605
582
|
};
|
|
606
583
|
}
|
|
@@ -649,7 +626,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
649
626
|
|
|
650
627
|
const filesStatus = this.mergeStatus && this.mergeStatus[idStr] ? this.mergeStatus[idStr] : null;
|
|
651
628
|
const deprecated = await modelComponent.isDeprecated(this.scope.objects);
|
|
652
|
-
const removed = component.component.
|
|
629
|
+
const removed = await component.component.component.isRemoved(this.scope.objects);
|
|
653
630
|
const latestVersion = modelComponent.latest();
|
|
654
631
|
return {
|
|
655
632
|
id: idStr,
|
|
@@ -657,7 +634,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
657
634
|
latestVersion: versionDifference.includes(latestVersion) ? latestVersion : null,
|
|
658
635
|
status: getStatus(),
|
|
659
636
|
filesStatus,
|
|
660
|
-
missingDeps: component.
|
|
637
|
+
missingDeps: component.getMissingDependencies(),
|
|
661
638
|
deprecated,
|
|
662
639
|
removed
|
|
663
640
|
};
|