@teambit/workspace 1.0.311 → 1.0.312

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "1.0.311",
3
+ "version": "1.0.312",
4
4
  "homepage": "https://bit.cloud/teambit/workspace/workspace",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "workspace",
9
- "version": "1.0.311"
9
+ "version": "1.0.312"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -51,43 +51,43 @@
51
51
  "@teambit/scopes.scope-id": "0.0.7",
52
52
  "@teambit/workspace.ui.empty-workspace": "0.0.508",
53
53
  "@teambit/explorer.ui.component-card": "0.0.30",
54
- "@teambit/component": "1.0.311",
55
- "@teambit/dependency-resolver": "1.0.311",
56
- "@teambit/envs": "1.0.311",
57
- "@teambit/logger": "0.0.981",
58
- "@teambit/scope": "1.0.311",
59
- "@teambit/graph": "1.0.311",
60
- "@teambit/cli": "0.0.888",
61
- "@teambit/isolator": "1.0.311",
62
- "@teambit/component-tree": "1.0.311",
54
+ "@teambit/component": "1.0.312",
55
+ "@teambit/dependency-resolver": "1.0.312",
56
+ "@teambit/envs": "1.0.312",
57
+ "@teambit/logger": "0.0.982",
58
+ "@teambit/scope": "1.0.312",
59
+ "@teambit/graph": "1.0.312",
60
+ "@teambit/cli": "0.0.889",
61
+ "@teambit/isolator": "1.0.312",
62
+ "@teambit/component-tree": "1.0.312",
63
63
  "@teambit/harmony.modules.resolved-component": "0.0.497",
64
- "@teambit/watcher": "1.0.311",
65
- "@teambit/aspect-loader": "1.0.311",
66
- "@teambit/config": "0.0.1062",
67
- "@teambit/global-config": "0.0.891",
64
+ "@teambit/watcher": "1.0.312",
65
+ "@teambit/aspect-loader": "1.0.312",
66
+ "@teambit/config": "0.0.1063",
67
+ "@teambit/global-config": "0.0.892",
68
68
  "@teambit/harmony.modules.requireable-component": "0.0.497",
69
69
  "@teambit/toolbox.modules.module-resolver": "0.0.7",
70
70
  "@teambit/workspace.modules.node-modules-linker": "0.0.174",
71
- "@teambit/graphql": "1.0.311",
72
- "@teambit/bundler": "1.0.311",
73
- "@teambit/pubsub": "1.0.311",
74
- "@teambit/ui": "1.0.311",
75
- "@teambit/variants": "0.0.1155",
71
+ "@teambit/graphql": "1.0.312",
72
+ "@teambit/bundler": "1.0.312",
73
+ "@teambit/pubsub": "1.0.312",
74
+ "@teambit/ui": "1.0.312",
75
+ "@teambit/variants": "0.0.1156",
76
76
  "@teambit/component-issues": "0.0.149",
77
77
  "@teambit/workspace.modules.match-pattern": "0.0.505",
78
78
  "@teambit/component.ui.component-drawer": "0.0.401",
79
79
  "@teambit/lanes.hooks.use-lane-components": "0.0.264",
80
80
  "@teambit/lanes.hooks.use-lanes": "0.0.264",
81
81
  "@teambit/lanes.ui.models.lanes-model": "0.0.216",
82
- "@teambit/command-bar": "1.0.311",
82
+ "@teambit/command-bar": "1.0.312",
83
83
  "@teambit/component.ui.component-filters.component-filter-context": "0.0.222",
84
84
  "@teambit/component.ui.component-filters.deprecate-filter": "0.0.220",
85
85
  "@teambit/component.ui.component-filters.env-filter": "0.0.230",
86
86
  "@teambit/component.ui.component-filters.show-main-filter": "0.0.213",
87
- "@teambit/sidebar": "1.0.311",
87
+ "@teambit/sidebar": "1.0.312",
88
88
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.509",
89
89
  "@teambit/component-descriptor": "0.0.421",
90
- "@teambit/deprecation": "1.0.311",
90
+ "@teambit/deprecation": "1.0.312",
91
91
  "@teambit/ui-foundation.ui.buttons.collapser": "0.0.222",
92
92
  "@teambit/cloud.hooks.use-cloud-scopes": "0.0.3",
93
93
  "@teambit/design.ui.tooltip": "0.0.369",
@@ -41,6 +41,7 @@ type LoadGroupMetadata = {
41
41
  core?: boolean;
42
42
  aspects?: boolean;
43
43
  seeders?: boolean;
44
+ envs?: boolean;
44
45
  };
45
46
 
46
47
  type GetAndLoadSlotOpts = ComponentLoadOptions & LoadGroupMetadata;
@@ -92,7 +93,11 @@ export class WorkspaceComponentLoader {
92
93
  * Cache extension list for components. used by get many for perf improvements.
93
94
  * And to make sure we load extensions first.
94
95
  */
95
- private componentsExtensionsCache: InMemoryCache<{ extensions: ExtensionDataList; errors: Error[] | undefined }>;
96
+ private componentsExtensionsCache: InMemoryCache<{
97
+ extensions: ExtensionDataList;
98
+ errors: Error[] | undefined;
99
+ envId: string | undefined;
100
+ }>;
96
101
 
97
102
  private componentLoadedSelfAsAspects: InMemoryCache<boolean>; // cache loaded components
98
103
  constructor(
@@ -171,13 +176,13 @@ export class WorkspaceComponentLoader {
171
176
  }
172
177
  const groupsRes = compact(
173
178
  await mapSeries(groupsToHandle, async (group, index) => {
174
- const { scopeIds, workspaceIds, aspects, core, seeders } = group;
179
+ const { scopeIds, workspaceIds, aspects, core, seeders, envs } = group;
175
180
  const groupDesc = `getMany-${callId} group ${index + 1}/${groupsToHandle.length} - ${loadGroupToStr(group)}`;
176
181
  this.logger.profile(groupDesc);
177
182
  if (!workspaceIds.length && !scopeIds.length) {
178
183
  throw new Error('getAndLoadSlotOrdered - group has no ids to load');
179
184
  }
180
- const res = await this.getAndLoadSlot(workspaceIds, scopeIds, { ...loadOpts, core, seeders, aspects });
185
+ const res = await this.getAndLoadSlot(workspaceIds, scopeIds, { ...loadOpts, core, seeders, aspects, envs });
181
186
  this.logger.profile(groupDesc);
182
187
  // We don't want to return components that were not asked originally (we do want to load them)
183
188
  if (!group.seeders) return undefined;
@@ -197,7 +202,9 @@ export class WorkspaceComponentLoader {
197
202
  }
198
203
 
199
204
  private async buildLoadGroups(workspaceScopeIdsMap: WorkspaceScopeIdsMap): Promise<Array<LoadGroup>> {
200
- const allIds = [...workspaceScopeIdsMap.workspaceIds.values(), ...workspaceScopeIdsMap.scopeIds.values()];
205
+ const wsIds = Array.from(workspaceScopeIdsMap.workspaceIds.values());
206
+ const scopeIds = Array.from(workspaceScopeIdsMap.scopeIds.values());
207
+ const allIds = [...wsIds, ...scopeIds];
201
208
  const groupedByIsCoreEnvs = groupBy(allIds, (id) => {
202
209
  return this.envs.isCoreEnv(id.toStringWithoutVersion());
203
210
  });
@@ -219,9 +226,30 @@ export class WorkspaceComponentLoader {
219
226
  const allExtCompIds = Array.from(allExtIds.values());
220
227
  await this.populateScopeAndExtensionsCache(allExtCompIds || [], workspaceScopeIdsMap);
221
228
 
222
- const allExtIdsStr = allExtCompIds.map((id) => id.toString());
229
+ // const allExtIdsStr = allExtCompIds.map((id) => id.toString());
230
+
231
+ const envsIdsOfWsComps = new Set<string>();
232
+ wsIds.forEach((id) => {
233
+ const idStr = id.toString();
234
+ const fromCache = this.componentsExtensionsCache.get(idStr);
235
+ if (!fromCache || !fromCache.extensions) {
236
+ return;
237
+ }
238
+ const envId = fromCache.envId;
239
+ if (envId) {
240
+ envsIdsOfWsComps.add(envId);
241
+ }
242
+ });
243
+
244
+ const groupedByIsEnvOfWsComps = groupBy(allExtCompIds, (id) => {
245
+ const idStr = id.toString();
246
+ const withoutVersion = idStr.split('@')[0];
247
+ return envsIdsOfWsComps.has(idStr) || envsIdsOfWsComps.has(withoutVersion);
248
+ });
249
+ const notEnvOfWsCompsStrs = (groupedByIsEnvOfWsComps.false || []).map((id) => id.toString());
250
+
223
251
  const groupedByIsExtOfAnother = groupBy(nonCoreEnvs, (id) => {
224
- return allExtIdsStr.includes(id.toString());
252
+ return notEnvOfWsCompsStrs.includes(id.toString());
225
253
  });
226
254
  const extIdsFromTheList = (groupedByIsExtOfAnother.true || []).map((id) => id.toString());
227
255
  const extsNotFromTheList: ComponentID[] = [];
@@ -240,15 +268,17 @@ export class WorkspaceComponentLoader {
240
268
  core: false,
241
269
  aspects: true,
242
270
  seeders: true,
271
+ envs: false,
243
272
  };
244
273
  });
245
274
 
246
275
  const groupsToHandle = [
247
276
  // Always load first core envs
248
- { ids: groupedByIsCoreEnvs.true || [], core: true, aspects: true, seeders: true },
249
- { ids: extsNotFromTheList || [], core: false, aspects: true, seeders: false },
277
+ { ids: groupedByIsCoreEnvs.true || [], core: true, aspects: true, seeders: true, envs: true },
278
+ { ids: groupedByIsEnvOfWsComps.true || [], core: false, aspects: true, seeders: false, envs: true },
279
+ { ids: extsNotFromTheList || [], core: false, aspects: true, seeders: false, envs: false },
250
280
  ...layeredExtGroups,
251
- { ids: groupedByIsExtOfAnother.false || [], core: false, aspects: false, seeders: true },
281
+ { ids: groupedByIsExtOfAnother.false || [], core: false, aspects: false, seeders: true, envs: false },
252
282
  ];
253
283
  const groupsByWsScope = groupsToHandle.map((group) => {
254
284
  if (!group.ids?.length) return undefined;
@@ -261,6 +291,7 @@ export class WorkspaceComponentLoader {
261
291
  core: group.core,
262
292
  aspects: group.aspects,
263
293
  seeders: group.seeders,
294
+ envs: group.envs,
264
295
  };
265
296
  });
266
297
  return compact(groupsByWsScope);
@@ -287,9 +318,10 @@ export class WorkspaceComponentLoader {
287
318
  loadOpts
288
319
  );
289
320
 
290
- const components = workspaceComponents.concat(scopeComponents);
291
-
292
- const allExtensions: ExtensionDataList[] = components.map((component) => {
321
+ // If we are here it means we are on workspace, in that case we don't want to load
322
+ // aspects of scope components as aspects only aspects of workspace components
323
+ // const components = workspaceComponents.concat(scopeComponents);
324
+ const allExtensions: ExtensionDataList[] = workspaceComponents.map((component) => {
293
325
  return component.state._consumer.extensions;
294
326
  });
295
327
 
@@ -392,10 +424,15 @@ export class WorkspaceComponentLoader {
392
424
  }
393
425
  if (!this.componentsExtensionsCache.has(idStr) && workspaceScopeIdsMap.workspaceIds.has(idStr)) {
394
426
  componentFromScope = componentFromScope || this.scopeComponentsCache.get(idStr);
395
- const { extensions, errors } = await this.workspace.componentExtensions(id, componentFromScope, undefined, {
396
- loadExtensions: false,
397
- });
398
- this.componentsExtensionsCache.set(idStr, { extensions, errors });
427
+ const { extensions, errors, envId } = await this.workspace.componentExtensions(
428
+ id,
429
+ componentFromScope,
430
+ undefined,
431
+ {
432
+ loadExtensions: false,
433
+ }
434
+ );
435
+ this.componentsExtensionsCache.set(idStr, { extensions, errors, envId });
399
436
  }
400
437
  });
401
438
  }
@@ -537,11 +574,14 @@ export class WorkspaceComponentLoader {
537
574
  // as when loading the next batch of components (next group) we won't have the envs loaded
538
575
 
539
576
  try {
577
+ const scopeComponents = await this.workspace.scope.getMany(scopeIds);
578
+
540
579
  // We don't want to load envs as part of this step, they will be loaded later
541
- const scopeComponents = await this.workspace.scope.loadMany(scopeIds, undefined, {
542
- loadApps: false,
543
- loadEnvs: false,
544
- });
580
+ // const scopeComponents = await this.workspace.scope.loadMany(scopeIds, undefined, {
581
+ // loadApps: false,
582
+ // loadEnvs: true,
583
+ // loadCompAspects: false,
584
+ // });
545
585
  return {
546
586
  workspaceComponents: components,
547
587
  scopeComponents,
@@ -855,7 +895,7 @@ function sortKeys(obj: Object) {
855
895
 
856
896
  function printGroupsToHandle(groupsToHandle: Array<LoadGroup>, logger: Logger): void {
857
897
  groupsToHandle.forEach((group) => {
858
- const { scopeIds, workspaceIds, aspects, core, seeders } = group;
898
+ const { scopeIds, workspaceIds, aspects, core, seeders, envs } = group;
859
899
  logger.console(
860
900
  `workspace-component-loader ~ groupsToHandle ${JSON.stringify(
861
901
  {
@@ -864,6 +904,7 @@ function printGroupsToHandle(groupsToHandle: Array<LoadGroup>, logger: Logger):
864
904
  aspects,
865
905
  core,
866
906
  seeders,
907
+ envs,
867
908
  },
868
909
  null,
869
910
  2
@@ -873,12 +914,13 @@ function printGroupsToHandle(groupsToHandle: Array<LoadGroup>, logger: Logger):
873
914
  }
874
915
 
875
916
  function loadGroupToStr(loadGroup: LoadGroup): string {
876
- const { scopeIds, workspaceIds, aspects, core, seeders } = loadGroup;
917
+ const { scopeIds, workspaceIds, aspects, core, seeders, envs } = loadGroup;
877
918
 
878
919
  const attr: string[] = [];
879
920
  if (aspects) attr.push('aspects');
880
921
  if (core) attr.push('core');
881
922
  if (seeders) attr.push('seeders');
923
+ if (envs) attr.push('envs');
882
924
 
883
925
  return `workspaceIds: ${workspaceIds.length}, scopeIds: ${scopeIds.length}, (${attr.join('+')})`;
884
926
  }