@teambit/workspace 0.0.534 → 0.0.539

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,94 +1,96 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "0.0.534",
3
+ "version": "0.0.539",
4
4
  "homepage": "https://bit.dev/teambit/workspace/workspace",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "workspace",
9
- "version": "0.0.534"
9
+ "version": "0.0.539"
10
10
  },
11
11
  "dependencies": {
12
+ "lodash.compact": "3.0.1",
13
+ "lodash": "4.17.21",
14
+ "p-map-series": "2.1.0",
12
15
  "chalk": "2.4.2",
13
16
  "ink": "3.0.8",
14
17
  "semver": "7.3.4",
15
18
  "@teambit/harmony": "0.2.11",
16
19
  "graphql-tag": "2.12.1",
17
20
  "fs-extra": "10.0.0",
18
- "lodash": "4.17.21",
19
- "p-map-series": "2.1.0",
20
21
  "react-router-dom": "5.2.0",
21
22
  "detect-indent": "5.0.0",
22
23
  "detect-newline": "3.1.0",
23
24
  "stringify-package": "1.0.1",
24
25
  "moment": "2.29.1",
25
26
  "chokidar": "3.5.1",
26
- "classnames": "2.2.6",
27
27
  "@react-hook/latest": "1.0.3",
28
28
  "pluralize": "8.0.0",
29
29
  "reset-css": "5.0.1",
30
+ "classnames": "2.2.6",
30
31
  "@babel/runtime": "7.12.18",
31
32
  "core-js": "^3.0.0",
32
- "@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
33
33
  "@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
34
34
  "@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
35
+ "@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
36
+ "@teambit/bit-error": "0.0.366",
37
+ "@teambit/legacy-bit-id": "0.0.369",
38
+ "@teambit/logger": "0.0.461",
39
+ "@teambit/scope": "0.0.539",
35
40
  "@teambit/cli": "0.0.380",
36
- "@teambit/isolator": "0.0.534",
41
+ "@teambit/isolator": "0.0.539",
37
42
  "@teambit/component-tree": "0.0.366",
38
- "@teambit/component.ui.component-status-resolver": "0.0.454",
39
- "@teambit/harmony.modules.resolved-component": "0.0.448",
40
- "@teambit/dependency-resolver": "0.0.534",
41
- "@teambit/logger": "0.0.456",
42
- "@teambit/compiler": "0.0.534",
43
- "@teambit/component": "0.0.534",
44
- "@teambit/graphql": "0.0.534",
45
- "@teambit/aspect-loader": "0.0.534",
46
- "@teambit/bundler": "0.0.534",
47
- "@teambit/envs": "0.0.534",
48
- "@teambit/pubsub": "0.0.534",
49
- "@teambit/scope": "0.0.534",
50
- "@teambit/ui": "0.0.534",
51
- "@teambit/variants": "0.0.458",
52
- "@teambit/legacy-bit-id": "0.0.369",
53
- "@teambit/bit-error": "0.0.366",
43
+ "@teambit/component.ui.component-status-resolver": "0.0.459",
44
+ "@teambit/harmony.modules.resolved-component": "0.0.453",
45
+ "@teambit/dependency-resolver": "0.0.539",
46
+ "@teambit/compiler": "0.0.539",
47
+ "@teambit/component": "0.0.539",
48
+ "@teambit/graphql": "0.0.539",
49
+ "@teambit/aspect-loader": "0.0.539",
50
+ "@teambit/bundler": "0.0.539",
51
+ "@teambit/envs": "0.0.539",
52
+ "@teambit/pubsub": "0.0.539",
53
+ "@teambit/ui": "0.0.539",
54
+ "@teambit/variants": "0.0.463",
54
55
  "@teambit/component-issues": "0.0.15",
55
56
  "@teambit/config": "0.0.391",
56
- "@teambit/harmony.modules.requireable-component": "0.0.448",
57
- "@teambit/workspace.modules.match-pattern": "0.0.450",
58
- "@teambit/command-bar": "0.0.534",
57
+ "@teambit/harmony.modules.requireable-component": "0.0.453",
58
+ "@teambit/workspace.modules.match-pattern": "0.0.455",
59
+ "@teambit/command-bar": "0.0.539",
59
60
  "@teambit/design.ui.surfaces.menu.link-item": "0.0.374",
60
- "@teambit/graph": "0.0.534",
61
- "@teambit/react-router": "0.0.534",
62
- "@teambit/sidebar": "0.0.534",
63
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.450",
64
- "@teambit/ui-foundation.ui.menu": "0.0.450",
65
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.452",
66
- "@teambit/toolbox.time.time-format": "0.0.447",
61
+ "@teambit/graph": "0.0.539",
62
+ "@teambit/react-router": "0.0.539",
63
+ "@teambit/sidebar": "0.0.539",
64
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.455",
65
+ "@teambit/ui-foundation.ui.menu": "0.0.455",
66
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.457",
67
+ "@teambit/toolbox.time.time-format": "0.0.452",
68
+ "@teambit/component-id": "0.0.370",
69
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.456",
70
+ "@teambit/deprecation": "0.0.539",
71
+ "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.455",
72
+ "@teambit/ui-foundation.ui.buttons.collapser": "0.0.160",
73
+ "@teambit/ui-foundation.ui.corner": "0.0.462",
74
+ "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.456",
75
+ "@teambit/ui-foundation.ui.top-bar": "0.0.457",
67
76
  "@teambit/design.ui.styles.ellipsis": "0.0.346",
68
77
  "@teambit/design.ui.styles.muted-italic": "0.0.35",
69
- "@teambit/ui-foundation.ui.full-loader": "0.0.450",
70
- "@teambit/ui-foundation.ui.side-bar": "0.0.454",
71
- "@teambit/ui-foundation.ui.tree.drawer": "0.0.450",
72
- "@teambit/component-id": "0.0.370",
73
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.451",
74
- "@teambit/deprecation": "0.0.534",
75
- "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.450",
76
- "@teambit/ui-foundation.ui.buttons.collapser": "0.0.155",
77
- "@teambit/ui-foundation.ui.corner": "0.0.457",
78
- "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.451",
79
- "@teambit/ui-foundation.ui.top-bar": "0.0.452",
80
- "@teambit/explorer.ui.gallery.component-grid": "0.0.450",
81
- "@teambit/workspace.ui.empty-workspace": "0.0.452",
82
- "@teambit/workspace.ui.workspace-component-card": "0.0.453"
78
+ "@teambit/ui-foundation.ui.full-loader": "0.0.455",
79
+ "@teambit/ui-foundation.ui.side-bar": "0.0.459",
80
+ "@teambit/ui-foundation.ui.tree.drawer": "0.0.455",
81
+ "@teambit/explorer.ui.gallery.component-grid": "0.0.455",
82
+ "@teambit/workspace.ui.empty-workspace": "0.0.457",
83
+ "@teambit/workspace.ui.workspace-component-card": "0.0.458"
83
84
  },
84
85
  "devDependencies": {
86
+ "@types/lodash.compact": "3.0.6",
87
+ "@types/lodash": "4.14.165",
85
88
  "@types/react": "^17.0.8",
86
89
  "@types/semver": "7.3.4",
87
90
  "@types/fs-extra": "9.0.7",
88
- "@types/lodash": "4.14.165",
89
91
  "@types/react-router-dom": "5.1.7",
90
- "@types/classnames": "2.2.11",
91
92
  "@types/pluralize": "0.0.29",
93
+ "@types/classnames": "2.2.11",
92
94
  "@types/mocha": "5.2.7",
93
95
  "@types/testing-library__jest-dom": "5.9.5",
94
96
  "@types/jest": "^26.0.0",
package/workspace.ts CHANGED
@@ -55,7 +55,6 @@ import { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';
55
55
  import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
56
56
  import { NoComponentDir } from '@teambit/legacy/dist/consumer/component/exceptions/no-component-dir';
57
57
  import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
58
- import { buildOneGraphForComponents } from '@teambit/legacy/dist/scope/graph/components-graph';
59
58
  import { pathIsInside } from '@teambit/legacy/dist/utils';
60
59
  import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
61
60
  import { PathOsBased, PathOsBasedRelative, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
@@ -89,6 +88,7 @@ import {
89
88
  } from './workspace.provider';
90
89
  import { WorkspaceComponentLoader } from './workspace-component/workspace-component-loader';
91
90
  import { IncorrectEnvAspect } from './exceptions/incorrect-env-aspect';
91
+ import { GraphFromFsBuilder, ShouldIgnoreFunc } from './build-graph-from-fs';
92
92
 
93
93
  export type EjectConfResult = {
94
94
  configPath: string;
@@ -392,7 +392,7 @@ export class Workspace implements ComponentFactory {
392
392
 
393
393
  const legacyIds = ids.map((id) => id._legacy);
394
394
 
395
- const legacyGraph = await buildOneGraphForComponents(legacyIds, this.consumer);
395
+ const legacyGraph = await this.buildOneGraphForComponents(legacyIds);
396
396
  return legacyGraph;
397
397
  }
398
398
 
@@ -608,7 +608,7 @@ export class Workspace implements ComponentFactory {
608
608
  * @param forCapsule
609
609
  */
610
610
  async importAndGetMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {
611
- await this.scope.import(ids);
611
+ await this.scope.import(ids, { reFetchUnBuiltVersion: shouldReFetchUnBuiltVersion() });
612
612
  return this.componentLoader.getMany(ids, forCapsule);
613
613
  }
614
614
 
@@ -631,7 +631,7 @@ export class Workspace implements ComponentFactory {
631
631
  const addResults = await addComponent.add();
632
632
  // @todo: the legacy commands have `consumer.onDestroy()` on command completion, it writes the
633
633
  // .bitmap file. workspace needs a similar mechanism. once done, remove the next line.
634
- await this.consumer.bitMap.write(this.consumer.componentFsCache);
634
+ await this.writeBitMap();
635
635
  return addResults;
636
636
  }
637
637
 
@@ -894,7 +894,7 @@ export class Workspace implements ComponentFactory {
894
894
  return componentConfigFile;
895
895
  }
896
896
 
897
- async getGraphWithoutCore(components: Component[]) {
897
+ async getAspectsGraphWithoutCore(components: Component[], isAspect?: ShouldIgnoreFunc) {
898
898
  const ids = components.map((component) => component.id._legacy);
899
899
  const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();
900
900
  const coreAspectsComponentIds = coreAspectsStringIds.map((id) => BitId.parse(id, true));
@@ -917,7 +917,7 @@ export class Workspace implements ComponentFactory {
917
917
  // This come to solve a circular loop when an env aspect use an aspect (as regular dep) and the aspect use the env aspect as its env
918
918
  // TODO: @gilad it causes many issues we need to find a better solution. removed for now.
919
919
  const ignoredIds = coreAspectsBitIds.concat([]);
920
- return buildOneGraphForComponents(ids, this.consumer, undefined, BitIds.fromArray(ignoredIds));
920
+ return this.buildOneGraphForComponents(ids, BitIds.fromArray(ignoredIds), isAspect);
921
921
  }
922
922
 
923
923
  /**
@@ -932,14 +932,10 @@ export class Workspace implements ComponentFactory {
932
932
  const idsWithoutCore: string[] = difference(notLoadedIds, coreAspectsStringIds);
933
933
  const componentIds = await this.resolveMultipleComponentIds(idsWithoutCore);
934
934
  const components = await this.importAndGetAspects(componentIds);
935
- const graph = await this.getGraphWithoutCore(components);
936
- const allIdsP = graph.nodes().map(async (id) => {
937
- return this.resolveComponentId(id);
938
- });
939
- const allIds = await Promise.all(allIdsP);
940
- const allComponents = await this.getMany(allIds as ComponentID[]);
941
935
 
942
- const aspects = allComponents.filter((component: Component) => {
936
+ const isAspect = async (bitId: BitId) => {
937
+ const id = await this.resolveComponentId(bitId);
938
+ const component = await this.get(id);
943
939
  let data = component.config.extensions.findExtension(EnvsAspect.id)?.data;
944
940
  if (!data) {
945
941
  // TODO: remove this once we re-export old components used to store the data here
@@ -959,11 +955,13 @@ export class Workspace implements ComponentFactory {
959
955
  }
960
956
  }
961
957
  return data.type === 'aspect';
962
- });
963
- // no need to filter core aspects as they are not included in the graph
964
- // here we are trying to load extensions from the workspace.
958
+ };
959
+
960
+ const graph = await this.getAspectsGraphWithoutCore(components, isAspect);
961
+ const idsStr = graph.nodes();
962
+ const compIds = await this.resolveMultipleComponentIds(idsStr);
963
+ const aspects = await this.getMany(compIds);
965
964
  const { workspaceComps, scopeComps } = await this.groupComponentsByWorkspaceAndScope(aspects);
966
- // load the scope first because we might need it for custom envs that extend external aspects
967
965
  const scopeIds = scopeComps.map((aspect) => aspect.id.toString());
968
966
  const workspaceAspects = await this.requireComponents(workspaceComps);
969
967
  const workspaceManifests = await this.aspectLoader.getManifestsFromRequireableExtensions(
@@ -978,6 +976,20 @@ export class Workspace implements ComponentFactory {
978
976
  await this.aspectLoader.loadExtensionsByManifests(allManifests, throwOnError);
979
977
  }
980
978
 
979
+ /**
980
+ * Note - this gets called from Harmony only.
981
+ * returns one graph that includes all dependencies types. each edge has a label of the dependency
982
+ * type. the nodes content is the Component object.
983
+ */
984
+ async buildOneGraphForComponents(
985
+ ids: BitId[],
986
+ ignoreIds?: BitIds,
987
+ shouldIgnoreFunc?: ShouldIgnoreFunc
988
+ ): Promise<LegacyGraph> {
989
+ const graphFromFsBuilder = new GraphFromFsBuilder(this, this.logger, ignoreIds, shouldIgnoreFunc);
990
+ return graphFromFsBuilder.buildGraph(ids);
991
+ }
992
+
981
993
  async resolveAspects(runtimeName?: string, componentIds?: ComponentID[]): Promise<AspectDefinition[]> {
982
994
  let missingPaths = false;
983
995
  const stringIds: string[] = [];
@@ -1287,17 +1299,15 @@ your workspace.jsonc has this component-id set. you might want to remove/change
1287
1299
  verbose: false,
1288
1300
  merge: false,
1289
1301
  objectsOnly: true,
1290
- withEnvironments: false,
1291
1302
  override: false,
1292
1303
  writeDists: false,
1293
1304
  writeConfig: false,
1294
1305
  installNpmPackages: false,
1295
- writePackageJson: false,
1296
1306
  importDependenciesDirectly: false,
1297
1307
  importDependents: false,
1298
1308
  };
1299
1309
  try {
1300
- const res = await importAction({ tester: false, compiler: false }, importOptions, []);
1310
+ const res = await importAction(importOptions, []);
1301
1311
  return res;
1302
1312
  } catch (err: any) {
1303
1313
  // TODO: this is a hack since the legacy throw an error, we should provide a way to not throw this error from the legacy
@@ -1470,4 +1480,17 @@ your workspace.jsonc has this component-id set. you might want to remove/change
1470
1480
  }
1471
1481
  }
1472
1482
 
1483
+ /**
1484
+ * this is a super hacky way to do it. problem is that loadAspect is running as onStart hook, where we don't
1485
+ * have the CLI fully loaded yet, so we can't get the command from the CLI aspect, we have to retrieve it from
1486
+ * process.argv.
1487
+ * in general, we don't want every command to try again and again fetching un-built versions. otherwise, every time
1488
+ * Bit loads (even bit --help), it'll fetch them and slow down everything.
1489
+ * instead, long-running commands and those that need the artifacts from the Version objects, should try to re-fetch.
1490
+ */
1491
+ function shouldReFetchUnBuiltVersion() {
1492
+ const commandsToReFetch = ['build', 'show', 'start', 'tag', 'install', 'link', 'import'];
1493
+ return commandsToReFetch.includes(process.argv[2]);
1494
+ }
1495
+
1473
1496
  export default Workspace;