Skip to content

Commit 680b0bd

Browse files
authored
refactor, extract legacy component-list into a new component "teambit.legacy/component-list" (#9024)
1 parent 10e1278 commit 680b0bd

File tree

20 files changed

+45
-30
lines changed

20 files changed

+45
-30
lines changed

.bitmap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@
380380
"mainFile": "index.ts",
381381
"rootDir": "components/component-issues"
382382
},
383+
"component-list": {
384+
"name": "component-list",
385+
"scope": "teambit.legacy",
386+
"version": "0.0.2",
387+
"mainFile": "index.ts",
388+
"rootDir": "components/legacy/component-list"
389+
},
383390
"component-log": {
384391
"name": "component-log",
385392
"scope": "teambit.component",

src/consumer/component/components-list.spec.ts renamed to components/legacy/component-list/components-list.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'chai';
22
import { ComponentID, ComponentIdList } from '@teambit/component-id';
3-
import { ModelComponent } from '../../scope/models';
4-
import ComponentsList from './components-list';
3+
import { ModelComponent } from '@teambit/legacy/dist/scope/models';
4+
import { ComponentsList } from './components-list';
55

66
describe('ComponentList', function () {
77
// @ts-ignore
@@ -42,7 +42,7 @@ describe('ComponentList', function () {
4242
const results = await componentList.listAll(false, true);
4343
const result = results[0];
4444
expect(result).to.have.property('id');
45-
expect(result.id).to.be.an.instanceOf(ComponentID);
45+
expect(result.id.constructor.name).to.equal(ComponentID.name);
4646
});
4747
});
4848
describe('filterComponentsByWildcard', () => {

src/consumer/component/components-list.ts renamed to components/legacy/component-list/components-list.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import { compact } from 'lodash';
22
import pFilter from 'p-filter';
33
import { ComponentID, ComponentIdList } from '@teambit/component-id';
44
import R from 'ramda';
5-
import { LATEST } from '../../constants';
6-
import { SnapsDistance } from '../../scope/component-ops/snaps-distance';
7-
import { getDivergeData } from '../../scope/component-ops/get-diverge-data';
8-
import { Lane } from '../../scope/models';
9-
import ModelComponent from '../../scope/models/model-component';
10-
import Scope from '../../scope/scope';
11-
import { fetchRemoteVersions } from '../../scope/scope-remotes';
5+
import { LATEST } from '@teambit/legacy/dist/constants';
6+
import { SnapsDistance } from '@teambit/legacy/dist/scope/component-ops/snaps-distance';
7+
import { getDivergeData } from '@teambit/legacy/dist/scope/component-ops/get-diverge-data';
8+
import { Lane } from '@teambit/legacy/dist/scope/models';
9+
import ModelComponent from '@teambit/legacy/dist/scope/models/model-component';
10+
import Scope from '@teambit/legacy/dist/scope/scope';
11+
import { fetchRemoteVersions } from '@teambit/legacy/dist/scope/scope-remotes';
1212
import { isBitIdMatchByWildcards } from '@teambit/legacy.utils';
1313
import { BitMap, ComponentMap } from '@teambit/legacy.bit-map';
14-
import Component from '../component';
15-
import { InvalidComponent } from '../component/consumer-component';
16-
import Consumer from '../consumer';
17-
import { ComponentLoadOptions } from './component-loader';
14+
import Component from '@teambit/legacy/dist/consumer/component';
15+
import { InvalidComponent } from '@teambit/legacy/dist/consumer/component/consumer-component';
16+
import Consumer from '@teambit/legacy/dist/consumer/consumer';
17+
import { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
1818

1919
export type DivergeDataPerId = { id: ComponentID; divergeData: SnapsDistance };
2020
export type ListScopeResult = {
@@ -29,7 +29,7 @@ export type ListScopeResult = {
2929
export type DivergedComponent = { id: ComponentID; diverge: SnapsDistance };
3030
export type OutdatedComponent = { id: ComponentID; headVersion: string; latestVersion?: string };
3131

32-
export default class ComponentsList {
32+
export class ComponentsList {
3333
consumer: Consumer;
3434
scope: Scope;
3535
bitMap: BitMap;
@@ -43,6 +43,7 @@ export default class ComponentsList {
4343
constructor(consumer: Consumer) {
4444
this.consumer = consumer;
4545
this.scope = consumer.scope;
46+
// @ts-ignore todo: remove after deleting teambit.legacy
4647
this.bitMap = consumer.bitMap;
4748
}
4849

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ComponentsList, DivergeDataPerId, ListScopeResult } from './components-list';

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"@pnpm/node-fetch": "^1.0.0",
119119
"@teambit/defender.fs.global-bit-temp-dir": "0.0.1",
120120
"@teambit/legacy.analytics": "~0.0.1",
121+
"@teambit/legacy.component-list": "~0.0.2",
121122
"@teambit/component.sources": "~0.0.1",
122123
"@teambit/bit.get-bit-version": "~0.0.1",
123124
"@teambit/legacy.utils": "~0.0.2",

scopes/component/lister/lister.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ComponentID } from '@teambit/component-id';
66
import { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';
77
import { Remote } from '@teambit/legacy/dist/remotes';
88
import getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';
9-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
9+
import { ComponentsList } from '@teambit/legacy.component-list';
1010
import { BitError } from '@teambit/bit-error';
1111
import { ListCmd } from './list.cmd';
1212
import { ListerAspect } from './lister.aspect';

scopes/component/merging/merging.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
22
import { WorkspaceAspect, OutsideWorkspaceError, Workspace } from '@teambit/workspace';
33
import { Consumer } from '@teambit/legacy/dist/consumer';
4-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
4+
import { ComponentsList } from '@teambit/legacy.component-list';
55
import { SnappingAspect, SnappingMain, TagResults } from '@teambit/snapping';
66
import mapSeries from 'p-map-series';
77
import { ComponentID, ComponentIdList } from '@teambit/component-id';

scopes/component/remove/remove-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Http } from '@teambit/legacy/dist/scope/network/http';
1111
import { Remotes } from '@teambit/legacy/dist/remotes';
1212
import { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';
1313
import { deleteComponentsFiles } from './delete-component-files';
14-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
14+
import { ComponentsList } from '@teambit/legacy.component-list';
1515
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
1616
import RemovedObjects from '@teambit/legacy/dist/scope/removed-components';
1717
import pMapSeries from 'p-map-series';

scopes/component/snapping/reset-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BitError } from '@teambit/bit-error';
22
import { ComponentID } from '@teambit/component-id';
33
import { Scope } from '@teambit/legacy/dist/scope';
44
import { Consumer } from '@teambit/legacy/dist/consumer';
5-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
5+
import { ComponentsList } from '@teambit/legacy.component-list';
66
import logger from '@teambit/legacy/dist/logger/logger';
77
import { Lane, ModelComponent } from '@teambit/legacy/dist/scope/models';
88

scopes/component/snapping/snapping.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { compact, difference, uniq } from 'lodash';
88
import { ComponentID, ComponentIdList } from '@teambit/component-id';
99
import { Extensions, LATEST, BuildStatus } from '@teambit/legacy/dist/constants';
1010
import { Consumer } from '@teambit/legacy/dist/consumer';
11-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
11+
import { ComponentsList } from '@teambit/legacy.component-list';
1212
import pMapSeries from 'p-map-series';
1313
import loader from '@teambit/legacy/dist/cli/loader';
1414
import ComponentsPendingImport from '@teambit/legacy/dist/consumer/exceptions/components-pending-import';

scopes/component/status/status.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { BEFORE_STATUS } from '@teambit/legacy/dist/cli/loader/loader-messages';
1111
import { RemoveAspect, RemoveMain } from '@teambit/remove';
1212
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
1313
import ComponentsPendingImport from '@teambit/legacy/dist/consumer/exceptions/components-pending-import';
14-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
14+
import { ComponentsList } from '@teambit/legacy.component-list';
1515
import { ModelComponent } from '@teambit/legacy/dist/scope/models';
1616
import { InsightsAspect, InsightsMain } from '@teambit/insights';
1717
import { SnapsDistance } from '@teambit/legacy/dist/scope/component-ops/snaps-distance';

scopes/lanes/lanes/create-lane.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ScopeMain } from '@teambit/scope';
55
// import { ComponentIdList } from '@teambit/component-id';
66
import Lane, { LaneComponent } from '@teambit/legacy/dist/scope/models/lane';
77
import { isSnap } from '@teambit/component-version';
8-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
8+
import { ComponentsList } from '@teambit/legacy.component-list';
99
import { Ref } from '@teambit/legacy/dist/scope/objects';
1010
import { Workspace } from '@teambit/workspace';
1111
import { compact } from 'lodash';

scopes/lanes/lanes/lanes.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { SnapsDistance } from '@teambit/legacy/dist/scope/component-ops/snaps-di
3131
import { RemoveAspect, RemoveMain } from '@teambit/remove';
3232
import { CheckoutAspect, CheckoutMain } from '@teambit/checkout';
3333
import { ChangeType } from '@teambit/lanes.entities.lane-diff';
34-
import ComponentsList, { DivergeDataPerId } from '@teambit/legacy/dist/consumer/component/components-list';
34+
import { ComponentsList, DivergeDataPerId } from '@teambit/legacy.component-list';
3535
import { NoCommonSnap } from '@teambit/legacy/dist/scope/exceptions/no-common-snap';
3636
import { concurrentComponentsLimit } from '@teambit/harmony.modules.concurrency';
3737
import { SUPPORT_LANE_HISTORY, isFeatureEnabled } from '@teambit/harmony.modules.feature-toggle';

scopes/scope/export/export.main.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { CENTRAL_BIT_HUB_NAME, CENTRAL_BIT_HUB_URL } from '@teambit/legacy/dist/constants';
1414
import { Consumer } from '@teambit/legacy/dist/consumer';
1515
import { BitMap } from '@teambit/legacy.bit-map';
16-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
16+
import { ComponentsList } from '@teambit/legacy.component-list';
1717
import { RemoveAspect, RemoveMain } from '@teambit/remove';
1818
import { Lane, ModelComponent, Symlink, Version } from '@teambit/legacy/dist/scope/models';
1919
import { hasWildcard } from '@teambit/legacy.utils';

scopes/workspace/workspace/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { LaneId } from '@teambit/lane-id';
3737
import { Consumer, loadConsumer } from '@teambit/legacy/dist/consumer';
3838
import { GetBitMapComponentOptions, MissingBitMapComponent } from '@teambit/legacy.bit-map';
3939
import { getMaxSizeForComponents, InMemoryCache, createInMemoryCache } from '@teambit/harmony.modules.in-memory-cache';
40-
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
40+
import { ComponentsList } from '@teambit/legacy.component-list';
4141
import { ExtensionDataList, ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
4242
import {
4343
PathOsBased,

src/remotes/remote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentID } from '@teambit/component-id';
22
import { PushOptions, CURRENT_FETCH_SCHEMA, FETCH_OPTIONS } from '@teambit/legacy.scope-api';
3-
import { ListScopeResult } from '../consumer/component/components-list';
3+
import { ListScopeResult } from '@teambit/legacy.component-list';
44
import Component from '../consumer/component/consumer-component';
55
import logger from '../logger/logger';
66
import type { Scope } from '../scope';

src/scope/graph/scope-graph.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import GraphLib, { Graph } from 'graphlib';
22
import pMapSeries from 'p-map-series';
33
import { ComponentID, ComponentIdList } from '@teambit/component-id';
44
import { VERSION_DELIMITER } from '../../constants';
5-
import ComponentsList from '../../consumer/component/components-list';
5+
import { ComponentsList } from '@teambit/legacy.component-list';
66
import Component from '../../consumer/component/consumer-component';
77
import { DEPENDENCIES_TYPES_UI_MAP } from '../../consumer/component/dependencies/dependencies';
88
import Consumer from '../../consumer/consumer';
@@ -135,7 +135,9 @@ export default class DependencyGraph {
135135

136136
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
137137
static async buildGraphFromWorkspace(consumer: Consumer, onlyLatest = false, reverse = false): Promise<Graph> {
138+
// @ts-ignore todo: remove after deleting teambit.legacy
138139
const componentsList = new ComponentsList(consumer);
140+
// @ts-ignore todo: remove after deleting teambit.legacy
139141
const workspaceComponents: Component[] = await componentsList.getFromFileSystem();
140142
const graph = new Graph();
141143
const allModelComponents: ModelComponent[] = await consumer.scope.list();
@@ -170,7 +172,9 @@ export default class DependencyGraph {
170172
* returns a graph that each node is a ComponentID object.
171173
*/
172174
static async buildGraphFromCurrentlyUsedComponents(consumer: Consumer): Promise<Graph> {
175+
// @ts-ignore todo: remove after deleting teambit.legacy
173176
const componentsList = new ComponentsList(consumer);
177+
// @ts-ignore todo: remove after deleting teambit.legacy
174178
const workspaceComponents: Component[] = await componentsList.getComponentsFromFS();
175179
const graph = new Graph();
176180
workspaceComponents.forEach((component: Component) => {

src/scope/network/fs/fs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentID } from '@teambit/component-id';
22
import { fetch, put, remove, action, FETCH_OPTIONS, PushOptions } from '@teambit/legacy.scope-api';
3-
import ComponentsList, { ListScopeResult } from '../../../consumer/component/components-list';
3+
import { ComponentsList, ListScopeResult } from '@teambit/legacy.component-list';
44
import Component from '../../../consumer/component/consumer-component';
55
import DependencyGraph from '../../graph/scope-graph';
66
import { LaneData } from '../../lanes/lanes';
@@ -65,6 +65,7 @@ export default class Fs implements Network {
6565
}
6666

6767
list(namespacesUsingWildcards?: string): Promise<ListScopeResult[]> {
68+
// @ts-ignore todo: remove after deleting teambit.legacy
6869
return ComponentsList.listLocalScope(this.getScope(), namespacesUsingWildcards);
6970
}
7071

src/scope/network/http/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { HttpProxyAgent } from 'http-proxy-agent';
1010
import { CLOUD_IMPORTER, CLOUD_IMPORTER_V2, isFeatureEnabled } from '@teambit/harmony.modules.feature-toggle';
1111
import { LaneId } from '@teambit/lane-id';
1212
import { getAgent, AgentOptions } from '@teambit/toolbox.network.agent';
13+
import { ListScopeResult } from '@teambit/legacy.component-list';
1314
import { Network } from '../network';
1415
import Component from '../../../consumer/component';
15-
import { ListScopeResult } from '../../../consumer/component/components-list';
1616
import DependencyGraph from '../../graph/scope-graph';
1717
import { LaneData } from '../../lanes/lanes';
1818
import { ComponentLog } from '../../models/model-component';

src/scope/network/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentID, ComponentIdList } from '@teambit/component-id';
22
import { PushOptions, FETCH_OPTIONS } from '@teambit/legacy.scope-api';
33
import Component from '../../consumer/component';
4-
import { ListScopeResult } from '../../consumer/component/components-list';
4+
import { ListScopeResult } from '@teambit/legacy.component-list';
55
import DependencyGraph from '../graph/scope-graph';
66
import { LaneData } from '../lanes/lanes';
77
import { ComponentLog } from '../models/model-component';

0 commit comments

Comments
 (0)