@teambit/workspace 0.0.549 → 0.0.555

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.
@@ -11,16 +11,47 @@ import { RouteProps } from 'react-router-dom';
11
11
  import { CommandBarUI, ComponentSearcher } from '@teambit/command-bar';
12
12
  export declare type SidebarWidgetSlot = SlotRegistry<ComponentTreeNode>;
13
13
  export declare class WorkspaceUI {
14
+ /**
15
+ * route slot.
16
+ */
14
17
  private routeSlot;
18
+ /**
19
+ * component ui extension.
20
+ */
15
21
  private componentUi;
22
+ /**
23
+ * menu slot
24
+ */
16
25
  private menuSlot;
17
26
  private menuItemSlot;
18
27
  private sidebar;
19
28
  private sidebarSlot;
29
+ /**
30
+ * sidebar link slot
31
+ */
20
32
  private sidebarItemSlot;
21
33
  private commandBarUI;
22
- constructor(routeSlot: RouteSlot, componentUi: ComponentUI, menuSlot: RouteSlot, menuItemSlot: MenuItemSlot, sidebar: SidebarUI, sidebarSlot: SidebarWidgetSlot, sidebarItemSlot: SidebarItemSlot, commandBarUI: CommandBarUI, reactRouterUI: ReactRouterUI);
34
+ constructor(
35
+ /**
36
+ * route slot.
37
+ */
38
+ routeSlot: RouteSlot,
39
+ /**
40
+ * component ui extension.
41
+ */
42
+ componentUi: ComponentUI,
43
+ /**
44
+ * menu slot
45
+ */
46
+ menuSlot: RouteSlot, menuItemSlot: MenuItemSlot, sidebar: SidebarUI, sidebarSlot: SidebarWidgetSlot,
47
+ /**
48
+ * sidebar link slot
49
+ */
50
+ sidebarItemSlot: SidebarItemSlot, commandBarUI: CommandBarUI, reactRouterUI: ReactRouterUI);
23
51
  private setKeyBindHandler;
52
+ /**
53
+ * register a route to the workspace.
54
+ */
24
55
  registerRoute(route: RouteProps): this;
25
56
  registerSidebarWidget(componentTreeNode: ComponentTreeNode): this;
26
57
  registerMenuItem: (menuItems: MenuItem[]) => void;
package/install.cmd.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from '@teambit/cli';
2
- import { DependencyLifecycleType } from '@teambit/dependency-resolver';
2
+ import { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';
3
3
  import { Logger } from '@teambit/logger';
4
4
  import chalk from 'chalk';
5
5
 
@@ -7,7 +7,7 @@ import { Workspace, WorkspaceInstallOptions } from './workspace';
7
7
 
8
8
  type InstallCmdOptions = {
9
9
  variants: string;
10
- type: DependencyLifecycleType;
10
+ type: WorkspaceDependencyLifecycleType;
11
11
  skipDedupe: boolean;
12
12
  skipImport: boolean;
13
13
  updateExisting: boolean;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "0.0.549",
3
+ "version": "0.0.555",
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.549"
9
+ "version": "0.0.555"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash.compact": "3.0.1",
@@ -18,6 +18,7 @@
18
18
  "@teambit/harmony": "0.2.11",
19
19
  "graphql-tag": "2.12.1",
20
20
  "fs-extra": "10.0.0",
21
+ "memoizee": "0.4.15",
21
22
  "react-router-dom": "5.2.0",
22
23
  "detect-indent": "5.0.0",
23
24
  "detect-newline": "3.1.0",
@@ -33,55 +34,55 @@
33
34
  "@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
34
35
  "@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
35
36
  "@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.465",
39
- "@teambit/scope": "0.0.549",
40
- "@teambit/cli": "0.0.380",
41
- "@teambit/isolator": "0.0.549",
42
- "@teambit/component-tree": "0.0.366",
43
- "@teambit/component.ui.component-status-resolver": "0.0.463",
44
- "@teambit/harmony.modules.resolved-component": "0.0.457",
45
- "@teambit/dependency-resolver": "0.0.549",
46
- "@teambit/compiler": "0.0.549",
47
- "@teambit/component": "0.0.549",
48
- "@teambit/graphql": "0.0.549",
49
- "@teambit/aspect-loader": "0.0.549",
50
- "@teambit/bundler": "0.0.549",
51
- "@teambit/envs": "0.0.549",
52
- "@teambit/pubsub": "0.0.549",
53
- "@teambit/ui": "0.0.549",
54
- "@teambit/variants": "0.0.467",
55
- "@teambit/component-issues": "0.0.15",
56
- "@teambit/config": "0.0.391",
57
- "@teambit/harmony.modules.requireable-component": "0.0.457",
58
- "@teambit/importer": "0.0.7",
59
- "@teambit/workspace.modules.match-pattern": "0.0.459",
60
- "@teambit/command-bar": "0.0.549",
37
+ "@teambit/bit-error": "0.0.372",
38
+ "@teambit/legacy-bit-id": "0.0.375",
39
+ "@teambit/logger": "0.0.471",
40
+ "@teambit/scope": "0.0.555",
41
+ "@teambit/cli": "0.0.386",
42
+ "@teambit/isolator": "0.0.555",
43
+ "@teambit/component-tree": "0.0.372",
44
+ "@teambit/component.ui.component-status-resolver": "0.0.467",
45
+ "@teambit/harmony.modules.resolved-component": "0.0.461",
46
+ "@teambit/dependency-resolver": "0.0.555",
47
+ "@teambit/compiler": "0.0.555",
48
+ "@teambit/component": "0.0.555",
49
+ "@teambit/graphql": "0.0.555",
50
+ "@teambit/aspect-loader": "0.0.555",
51
+ "@teambit/bundler": "0.0.555",
52
+ "@teambit/envs": "0.0.555",
53
+ "@teambit/pubsub": "0.0.555",
54
+ "@teambit/ui": "0.0.555",
55
+ "@teambit/variants": "0.0.473",
56
+ "@teambit/component-issues": "0.0.21",
57
+ "@teambit/config": "0.0.397",
58
+ "@teambit/harmony.modules.requireable-component": "0.0.461",
59
+ "@teambit/importer": "0.0.13",
60
+ "@teambit/workspace.modules.match-pattern": "0.0.465",
61
+ "@teambit/command-bar": "0.0.555",
61
62
  "@teambit/design.ui.surfaces.menu.link-item": "0.0.374",
62
- "@teambit/graph": "0.0.549",
63
- "@teambit/react-router": "0.0.549",
64
- "@teambit/sidebar": "0.0.549",
65
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.459",
66
- "@teambit/ui-foundation.ui.menu": "0.0.459",
67
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.461",
68
- "@teambit/toolbox.time.time-format": "0.0.456",
69
- "@teambit/component-id": "0.0.370",
70
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.460",
71
- "@teambit/deprecation": "0.0.549",
72
- "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.459",
73
- "@teambit/ui-foundation.ui.buttons.collapser": "0.0.164",
74
- "@teambit/ui-foundation.ui.corner": "0.0.466",
75
- "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.460",
76
- "@teambit/ui-foundation.ui.top-bar": "0.0.461",
63
+ "@teambit/graph": "0.0.555",
64
+ "@teambit/react-router": "0.0.555",
65
+ "@teambit/sidebar": "0.0.555",
66
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.463",
67
+ "@teambit/ui-foundation.ui.menu": "0.0.463",
68
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.465",
69
+ "@teambit/toolbox.time.time-format": "0.0.460",
70
+ "@teambit/component-id": "0.0.376",
71
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.464",
72
+ "@teambit/deprecation": "0.0.555",
73
+ "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.463",
74
+ "@teambit/ui-foundation.ui.buttons.collapser": "0.0.168",
75
+ "@teambit/ui-foundation.ui.corner": "0.0.470",
76
+ "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.464",
77
+ "@teambit/ui-foundation.ui.top-bar": "0.0.465",
77
78
  "@teambit/design.ui.styles.ellipsis": "0.0.346",
78
79
  "@teambit/design.ui.styles.muted-italic": "0.0.35",
79
- "@teambit/ui-foundation.ui.full-loader": "0.0.459",
80
- "@teambit/ui-foundation.ui.side-bar": "0.0.465",
81
- "@teambit/ui-foundation.ui.tree.drawer": "0.0.459",
82
- "@teambit/explorer.ui.gallery.component-grid": "0.0.459",
83
- "@teambit/workspace.ui.empty-workspace": "0.0.461",
84
- "@teambit/workspace.ui.workspace-component-card": "0.0.462"
80
+ "@teambit/ui-foundation.ui.full-loader": "0.0.463",
81
+ "@teambit/ui-foundation.ui.side-bar": "0.0.469",
82
+ "@teambit/ui-foundation.ui.tree.drawer": "0.0.463",
83
+ "@teambit/explorer.ui.gallery.component-grid": "0.0.463",
84
+ "@teambit/workspace.ui.empty-workspace": "0.0.465",
85
+ "@teambit/workspace.ui.workspace-component-card": "0.0.466"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@types/lodash.compact": "3.0.6",
@@ -89,6 +90,7 @@
89
90
  "@types/react": "^17.0.8",
90
91
  "@types/semver": "7.3.4",
91
92
  "@types/fs-extra": "9.0.7",
93
+ "@types/memoizee": "0.4.5",
92
94
  "@types/react-router-dom": "5.1.7",
93
95
  "@types/pluralize": "0.0.29",
94
96
  "@types/classnames": "2.2.11",
@@ -100,7 +102,7 @@
100
102
  },
101
103
  "peerDependencies": {
102
104
  "@apollo/client": "^3.0.0",
103
- "@teambit/legacy": "1.0.76",
105
+ "@teambit/legacy": "1.0.172",
104
106
  "react-dom": "^16.8.0 || ^17.0.0",
105
107
  "react": "^16.8.0 || ^17.0.0"
106
108
  },
@@ -128,7 +130,7 @@
128
130
  "react": "-"
129
131
  },
130
132
  "peerDependencies": {
131
- "@teambit/legacy": "1.0.76",
133
+ "@teambit/legacy": "1.0.172",
132
134
  "react-dom": "^16.8.0 || ^17.0.0",
133
135
  "react": "^16.8.0 || ^17.0.0"
134
136
  }
package/tsconfig.json CHANGED
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },
package/workspace.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import chalk from 'chalk';
2
+ import memoize from 'memoizee';
2
3
  import mapSeries from 'p-map-series';
3
4
  import type { PubsubMain } from '@teambit/pubsub';
4
5
  import { IssuesList } from '@teambit/component-issues';
@@ -19,7 +20,7 @@ import {
19
20
  import { Importer } from '@teambit/importer';
20
21
  import { ComponentScopeDirMap, Config } from '@teambit/config';
21
22
  import {
22
- DependencyLifecycleType,
23
+ WorkspaceDependencyLifecycleType,
23
24
  DependencyResolverMain,
24
25
  PackageManagerInstallOptions,
25
26
  ComponentDependency,
@@ -106,7 +107,7 @@ export interface EjectConfOptions {
106
107
 
107
108
  export type WorkspaceInstallOptions = {
108
109
  variants?: string;
109
- lifecycleType?: DependencyLifecycleType;
110
+ lifecycleType?: WorkspaceDependencyLifecycleType;
110
111
  dedupe: boolean;
111
112
  import: boolean;
112
113
  copyPeerToRuntimeOnRoot?: boolean;
@@ -201,6 +202,15 @@ export class Workspace implements ComponentFactory {
201
202
  this.owner = this.config?.defaultOwner;
202
203
  this.componentLoader = new WorkspaceComponentLoader(this, logger, dependencyResolver, envs);
203
204
  this.validateConfig();
205
+ // memoize this method to improve performance.
206
+ this.componentDefaultScopeFromComponentDirAndNameWithoutConfigFile = memoize(
207
+ this.componentDefaultScopeFromComponentDirAndNameWithoutConfigFile.bind(this),
208
+ {
209
+ primitive: true,
210
+ promise: true,
211
+ maxAge: 60 * 1000, // 1 min
212
+ }
213
+ );
204
214
  }
205
215
 
206
216
  private validateConfig() {
@@ -1182,8 +1192,8 @@ export class Workspace implements ComponentFactory {
1182
1192
  */
1183
1193
  async install(packages?: string[], options?: WorkspaceInstallOptions) {
1184
1194
  if (packages && packages.length) {
1185
- if (!options?.variants && options?.lifecycleType === 'dev') {
1186
- throw new DependencyTypeNotSupportedInPolicy(options?.lifecycleType);
1195
+ if (!options?.variants && (options?.lifecycleType as string) === 'dev') {
1196
+ throw new DependencyTypeNotSupportedInPolicy(options?.lifecycleType as string);
1187
1197
  }
1188
1198
  this.logger.debug(`installing the following packages: ${packages.join()}`);
1189
1199
  const resolver = this.dependencyResolver.getVersionResolver();
@@ -1278,6 +1288,8 @@ export class Workspace implements ComponentFactory {
1278
1288
  private async generateFilterFnForDepsFromLocalRemote() {
1279
1289
  // TODO: once scope create a new API for this, replace it with the new one
1280
1290
  const remotes = await this.scope._legacyRemotes();
1291
+ const reg = await this.dependencyResolver.getRegistries();
1292
+ const packageScopes = Object.keys(reg.scopes);
1281
1293
  return (dependencyList: DependencyList): DependencyList => {
1282
1294
  const filtered = dependencyList.filter((dep) => {
1283
1295
  if (!(dep instanceof ComponentDependency)) {
@@ -1286,6 +1298,9 @@ export class Workspace implements ComponentFactory {
1286
1298
  if (remotes.isHub(dep.componentId.scope)) {
1287
1299
  return true;
1288
1300
  }
1301
+ if (packageScopes.some((scope) => dep.packageName.startsWith(`@${scope}/`))) {
1302
+ return true;
1303
+ }
1289
1304
  return false;
1290
1305
  });
1291
1306
  return filtered;
@@ -1448,11 +1463,18 @@ your workspace.jsonc has this component-id set. you might want to remove/change
1448
1463
  return ComponentID.fromLegacy(legacyId);
1449
1464
  }
1450
1465
  }
1451
- const relativeComponentDir = this.componentDirFromLegacyId(legacyId, undefined, { relative: true });
1452
- const defaultScope = await this.componentDefaultScopeFromComponentDirAndName(
1453
- relativeComponentDir,
1454
- legacyId.toStringWithoutScopeAndVersion()
1455
- );
1466
+ const getDefaultScope = async (bitId: BitId) => {
1467
+ if (bitId.scope) {
1468
+ return bitId.scope;
1469
+ }
1470
+ const relativeComponentDir = this.componentDirFromLegacyId(bitId, undefined, { relative: true });
1471
+ const defaultScope = await this.componentDefaultScopeFromComponentDirAndName(
1472
+ relativeComponentDir,
1473
+ bitId.toStringWithoutScopeAndVersion()
1474
+ );
1475
+ return defaultScope;
1476
+ };
1477
+ const defaultScope = await getDefaultScope(legacyId);
1456
1478
  return ComponentID.fromLegacy(legacyId, defaultScope);
1457
1479
  }
1458
1480