Skip to content

Commit

Permalink
improve import performance of multiple components with multiple versi…
Browse files Browse the repository at this point in the history
…ons (#1851)

* fix #1710, improve bit-import performance when importing many components that have many versions by not traveling multiple times to the SSH

* fix the loader when importing with wildcards to indicate once the component list is ready and it started to import
  • Loading branch information
davidfirst authored Jul 24, 2019
1 parent f5b4f08 commit 97fa286
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

- [#1710](https://github.com/teambit/bit/issues/1710) improve performance of importing an entire collection

## [14.2.2] - 2019-07-24

### New
Expand Down
1 change: 1 addition & 0 deletions src/consumer/component-ops/import-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default class ImportComponents {
if (!listResult.length) {
throw new GeneralError(`no components found on the remote scope matching the "${idStr}" pattern`);
}
loader.start(BEFORE_IMPORT_ACTION); // it stops the previous loader of BEFORE_REMOTE_LIST
const ids = listResult.map(result => result.id);
bitIds.push(...ids);
} else {
Expand Down
13 changes: 6 additions & 7 deletions src/scope/component-ops/scope-components-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,18 @@ export default class ScopeComponentsImporter {
const idsWithoutNils = removeNils(ids);
if (R.isEmpty(idsWithoutNils)) return Promise.resolve([]);
const versionDependenciesArr: VersionDependencies[] = await this.importMany(idsWithoutNils, cache);
const importAllVersions = (versionDependencies) => {

const allIdsWithAllVersions = new BitIds();
versionDependenciesArr.forEach((versionDependencies) => {
const versions = versionDependencies.component.component.listVersions();
const idsWithAllVersions = versions.map((version) => {
if (version === versionDependencies.component.version) return null; // imported already
const versionId = versionDependencies.component.id;
return versionId.changeVersion(version);
});
// $FlowFixMe
const bitIdsWithAllVersions = BitIds.fromArray(idsWithAllVersions.filter(x => x));
return this.importManyWithoutDependencies(bitIdsWithAllVersions);
};

await pMapSeries(versionDependenciesArr, importAllVersions);
allIdsWithAllVersions.push(...removeNils(idsWithAllVersions));
});
await this.importManyWithoutDependencies(allIdsWithAllVersions);

return versionDependenciesArr;
}
Expand Down

0 comments on commit 97fa286

Please sign in to comment.