@teambit/workspace 0.0.553 → 0.0.557
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/dist/build-graph-from-fs.d.ts +30 -0
- package/dist/build-graph-from-fs.js +4 -1
- package/dist/build-graph-from-fs.js.map +1 -1
- package/dist/install.cmd.d.ts +17 -3
- package/dist/install.cmd.js.map +1 -1
- package/dist/link/link.cmd.d.ts +15 -1
- package/dist/types.d.ts +21 -0
- package/dist/ui/workspace/workspace-model.d.ts +32 -1
- package/dist/ui/workspace/workspace-provider.d.ts +9 -0
- package/dist/ui/workspace/workspace.d.ts +3 -0
- package/dist/watch/output-formatter.d.ts +6 -0
- package/dist/watch/watch.cmd.d.ts +22 -1
- package/dist/watch/watcher.d.ts +9 -0
- package/dist/workspace-component/component-status.d.ts +57 -1
- package/dist/workspace-component/workspace-component-loader.d.ts +7 -0
- package/dist/workspace-component/workspace-component.d.ts +36 -1
- package/dist/workspace.d.ts +236 -3
- package/dist/workspace.js +37 -5
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.ui-root.d.ts +18 -1
- package/dist/workspace.ui.runtime.d.ts +32 -1
- package/package.json +63 -53
- package/tsconfig.json +1 -2
- package/build-graph-from-fs.ts +0 -160
- package/capsule.cmd.ts +0 -136
- package/component-config-file/component-config-file.ts +0 -98
- package/component-config-file/exceptions/already-exists.ts +0 -7
- package/component-config-file/exceptions/index.ts +0 -1
- package/component-config-file/index.ts +0 -2
- package/component-tree.widget.tsx +0 -16
- package/constants.ts +0 -1
- package/eject-conf.cmd.tsx +0 -62
- package/events/index.ts +0 -3
- package/events/on-component-add-event.ts +0 -14
- package/events/on-component-change-event.ts +0 -14
- package/events/on-component-removed-event.ts +0 -14
- package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
- package/exceptions/incorrect-env-aspect.ts +0 -8
- package/exceptions/index.ts +0 -1
- package/index.ts +0 -19
- package/install.cmd.tsx +0 -67
- package/link/component-list-links.ts +0 -50
- package/link/core-aspects-links.ts +0 -50
- package/link/get-package-name-from-target.ts +0 -5
- package/link/index.ts +0 -1
- package/link/link-row.ts +0 -20
- package/link/link-to-dir.ts +0 -13
- package/link/link.cmd.ts +0 -96
- package/link/nested-deps-in-nm-links.ts +0 -47
- package/link/rewire-row.ts +0 -17
- package/list.cmd.tsx +0 -30
- package/on-component-events.ts +0 -14
- package/package-tar/teambit-workspace-0.0.553.tgz +0 -0
- package/tag-cmd.ts +0 -247
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/types.ts +0 -40
- package/ui/index.ts +0 -1
- package/ui/workspace/default-component.ts +0 -7
- package/ui/workspace/index.ts +0 -1
- package/ui/workspace/use-workspace.ts +0 -193
- package/ui/workspace/workspace-context.tsx +0 -5
- package/ui/workspace/workspace-model.ts +0 -66
- package/ui/workspace/workspace-overview/index.ts +0 -1
- package/ui/workspace/workspace-overview/workspace-overview.module.scss +0 -6
- package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
- package/ui/workspace/workspace-provider.tsx +0 -23
- package/ui/workspace/workspace.module.scss +0 -40
- package/ui/workspace/workspace.tsx +0 -99
- package/ui/workspace-components-drawer/index.ts +0 -1
- package/ui/workspace-components-drawer/workspace-components-drawer.module.scss +0 -4
- package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
- package/watch/REFACTOR_GUIDE.md +0 -14
- package/watch/check-types.ts +0 -5
- package/watch/output-formatter.ts +0 -50
- package/watch/watch.cmd.tsx +0 -142
- package/watch/watcher.ts +0 -289
- package/workspace-component/component-status.ts +0 -67
- package/workspace-component/index.ts +0 -2
- package/workspace-component/workspace-component-loader.ts +0 -276
- package/workspace-component/workspace-component.ts +0 -51
- package/workspace-section.ts +0 -14
- package/workspace.aspect.ts +0 -9
- package/workspace.graphql.ts +0 -133
- package/workspace.main.runtime.ts +0 -50
- package/workspace.provider.ts +0 -218
- package/workspace.ts +0 -1517
- package/workspace.ui-root.ts +0 -64
- package/workspace.ui.runtime.tsx +0 -215
|
@@ -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(
|
|
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/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.557",
|
|
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.
|
|
9
|
+
"version": "0.0.557"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash.compact": "3.0.1",
|
|
@@ -18,70 +18,71 @@
|
|
|
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",
|
|
24
25
|
"stringify-package": "1.0.1",
|
|
25
26
|
"moment": "2.29.1",
|
|
26
27
|
"chokidar": "3.5.1",
|
|
27
|
-
"classnames": "2.2.6",
|
|
28
28
|
"@react-hook/latest": "1.0.3",
|
|
29
29
|
"pluralize": "8.0.0",
|
|
30
30
|
"reset-css": "5.0.1",
|
|
31
|
+
"classnames": "2.2.6",
|
|
31
32
|
"@babel/runtime": "7.12.18",
|
|
32
33
|
"core-js": "^3.0.0",
|
|
33
|
-
"@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
|
|
34
34
|
"@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
|
|
35
35
|
"@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
|
|
36
|
-
"@teambit/
|
|
37
|
-
"@teambit/
|
|
38
|
-
"@teambit/
|
|
39
|
-
"@teambit/
|
|
40
|
-
"@teambit/
|
|
41
|
-
"@teambit/
|
|
42
|
-
"@teambit/
|
|
43
|
-
"@teambit/component
|
|
44
|
-
"@teambit/
|
|
45
|
-
"@teambit/
|
|
46
|
-
"@teambit/
|
|
47
|
-
"@teambit/
|
|
48
|
-
"@teambit/
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/
|
|
51
|
-
"@teambit/
|
|
52
|
-
"@teambit/
|
|
53
|
-
"@teambit/
|
|
54
|
-
"@teambit/
|
|
55
|
-
"@teambit/
|
|
56
|
-
"@teambit/
|
|
57
|
-
"@teambit/
|
|
58
|
-
"@teambit/
|
|
59
|
-
"@teambit/
|
|
60
|
-
"@teambit/
|
|
36
|
+
"@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
|
|
37
|
+
"@teambit/bit-error": "0.0.374",
|
|
38
|
+
"@teambit/legacy-bit-id": "0.0.377",
|
|
39
|
+
"@teambit/logger": "0.0.473",
|
|
40
|
+
"@teambit/scope": "0.0.557",
|
|
41
|
+
"@teambit/cli": "0.0.388",
|
|
42
|
+
"@teambit/isolator": "0.0.557",
|
|
43
|
+
"@teambit/component-tree": "0.0.374",
|
|
44
|
+
"@teambit/component.ui.component-status-resolver": "0.0.469",
|
|
45
|
+
"@teambit/harmony.modules.resolved-component": "0.0.463",
|
|
46
|
+
"@teambit/dependency-resolver": "0.0.557",
|
|
47
|
+
"@teambit/compiler": "0.0.557",
|
|
48
|
+
"@teambit/component": "0.0.557",
|
|
49
|
+
"@teambit/graphql": "0.0.557",
|
|
50
|
+
"@teambit/aspect-loader": "0.0.557",
|
|
51
|
+
"@teambit/bundler": "0.0.557",
|
|
52
|
+
"@teambit/envs": "0.0.557",
|
|
53
|
+
"@teambit/pubsub": "0.0.557",
|
|
54
|
+
"@teambit/ui": "0.0.557",
|
|
55
|
+
"@teambit/variants": "0.0.475",
|
|
56
|
+
"@teambit/component-issues": "0.0.23",
|
|
57
|
+
"@teambit/config": "0.0.399",
|
|
58
|
+
"@teambit/harmony.modules.requireable-component": "0.0.463",
|
|
59
|
+
"@teambit/importer": "0.0.15",
|
|
60
|
+
"@teambit/workspace.modules.match-pattern": "0.0.467",
|
|
61
|
+
"@teambit/command-bar": "0.0.557",
|
|
61
62
|
"@teambit/design.ui.surfaces.menu.link-item": "0.0.374",
|
|
62
|
-
"@teambit/graph": "0.0.
|
|
63
|
-
"@teambit/react-router": "0.0.
|
|
64
|
-
"@teambit/sidebar": "0.0.
|
|
65
|
-
"@teambit/ui-foundation.ui.main-dropdown": "0.0.
|
|
66
|
-
"@teambit/ui-foundation.ui.menu": "0.0.
|
|
67
|
-
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.
|
|
68
|
-
"@teambit/toolbox.time.time-format": "0.0.
|
|
63
|
+
"@teambit/graph": "0.0.557",
|
|
64
|
+
"@teambit/react-router": "0.0.557",
|
|
65
|
+
"@teambit/sidebar": "0.0.557",
|
|
66
|
+
"@teambit/ui-foundation.ui.main-dropdown": "0.0.465",
|
|
67
|
+
"@teambit/ui-foundation.ui.menu": "0.0.465",
|
|
68
|
+
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.467",
|
|
69
|
+
"@teambit/toolbox.time.time-format": "0.0.462",
|
|
70
|
+
"@teambit/component-id": "0.0.378",
|
|
71
|
+
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.466",
|
|
72
|
+
"@teambit/deprecation": "0.0.557",
|
|
73
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.465",
|
|
74
|
+
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.170",
|
|
75
|
+
"@teambit/ui-foundation.ui.corner": "0.0.472",
|
|
76
|
+
"@teambit/ui-foundation.ui.notifications.notification-context": "0.0.466",
|
|
77
|
+
"@teambit/ui-foundation.ui.top-bar": "0.0.467",
|
|
69
78
|
"@teambit/design.ui.styles.ellipsis": "0.0.346",
|
|
70
79
|
"@teambit/design.ui.styles.muted-italic": "0.0.35",
|
|
71
|
-
"@teambit/ui-foundation.ui.full-loader": "0.0.
|
|
72
|
-
"@teambit/ui-foundation.ui.side-bar": "0.0.
|
|
73
|
-
"@teambit/ui-foundation.ui.tree.drawer": "0.0.
|
|
74
|
-
"@teambit/component-
|
|
75
|
-
"@teambit/
|
|
76
|
-
"@teambit/
|
|
77
|
-
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.461",
|
|
78
|
-
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.166",
|
|
79
|
-
"@teambit/ui-foundation.ui.corner": "0.0.468",
|
|
80
|
-
"@teambit/ui-foundation.ui.notifications.notification-context": "0.0.462",
|
|
81
|
-
"@teambit/ui-foundation.ui.top-bar": "0.0.463",
|
|
82
|
-
"@teambit/explorer.ui.gallery.component-grid": "0.0.461",
|
|
83
|
-
"@teambit/workspace.ui.empty-workspace": "0.0.463",
|
|
84
|
-
"@teambit/workspace.ui.workspace-component-card": "0.0.464"
|
|
80
|
+
"@teambit/ui-foundation.ui.full-loader": "0.0.465",
|
|
81
|
+
"@teambit/ui-foundation.ui.side-bar": "0.0.471",
|
|
82
|
+
"@teambit/ui-foundation.ui.tree.drawer": "0.0.465",
|
|
83
|
+
"@teambit/explorer.ui.gallery.component-grid": "0.0.465",
|
|
84
|
+
"@teambit/workspace.ui.empty-workspace": "0.0.467",
|
|
85
|
+
"@teambit/workspace.ui.workspace-component-card": "0.0.468"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@types/lodash.compact": "3.0.6",
|
|
@@ -89,9 +90,10 @@
|
|
|
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
|
-
"@types/classnames": "2.2.11",
|
|
94
95
|
"@types/pluralize": "0.0.29",
|
|
96
|
+
"@types/classnames": "2.2.11",
|
|
95
97
|
"@types/mocha": "5.2.7",
|
|
96
98
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
97
99
|
"@types/jest": "^26.0.0",
|
|
@@ -100,7 +102,7 @@
|
|
|
100
102
|
},
|
|
101
103
|
"peerDependencies": {
|
|
102
104
|
"@apollo/client": "^3.0.0",
|
|
103
|
-
"@teambit/legacy": "1.0.
|
|
105
|
+
"@teambit/legacy": "1.0.174",
|
|
104
106
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
105
107
|
"react": "^16.8.0 || ^17.0.0"
|
|
106
108
|
},
|
|
@@ -128,12 +130,20 @@
|
|
|
128
130
|
"react": "-"
|
|
129
131
|
},
|
|
130
132
|
"peerDependencies": {
|
|
131
|
-
"@teambit/legacy": "1.0.
|
|
133
|
+
"@teambit/legacy": "1.0.174",
|
|
132
134
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
133
135
|
"react": "^16.8.0 || ^17.0.0"
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
},
|
|
139
|
+
"files": [
|
|
140
|
+
"dist",
|
|
141
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
142
|
+
"README.md",
|
|
143
|
+
"README.mdx",
|
|
144
|
+
"*.js",
|
|
145
|
+
"*.json"
|
|
146
|
+
],
|
|
137
147
|
"private": false,
|
|
138
148
|
"engines": {
|
|
139
149
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
|
@@ -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/build-graph-from-fs.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import mapSeries from 'p-map-series';
|
|
2
|
-
import { flatten } from 'lodash';
|
|
3
|
-
import { Consumer } from '@teambit/legacy/dist/consumer';
|
|
4
|
-
import BitIds from '@teambit/legacy/dist/bit-id/bit-ids';
|
|
5
|
-
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
6
|
-
import LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';
|
|
7
|
-
import ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';
|
|
8
|
-
import compact from 'lodash.compact';
|
|
9
|
-
import { BitId } from '@teambit/legacy-bit-id';
|
|
10
|
-
import { Logger } from '@teambit/logger';
|
|
11
|
-
import { ComponentNotFound } from '@teambit/scope';
|
|
12
|
-
import { BitError } from '@teambit/bit-error';
|
|
13
|
-
import { Workspace } from './workspace';
|
|
14
|
-
|
|
15
|
-
export type ShouldIgnoreFunc = (bitId: BitId) => Promise<boolean>;
|
|
16
|
-
|
|
17
|
-
export class GraphFromFsBuilder {
|
|
18
|
-
private graph = new LegacyGraph();
|
|
19
|
-
private completed: string[] = [];
|
|
20
|
-
private depth = 1;
|
|
21
|
-
private shouldThrowOnMissingDep = true;
|
|
22
|
-
private consumer: Consumer;
|
|
23
|
-
constructor(
|
|
24
|
-
private workspace: Workspace,
|
|
25
|
-
private logger: Logger,
|
|
26
|
-
private ignoreIds = new BitIds(),
|
|
27
|
-
private shouldLoadItsDeps?: ShouldIgnoreFunc
|
|
28
|
-
) {
|
|
29
|
-
this.consumer = this.workspace.consumer;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* create a graph with all dependencies and flattened dependencies of the given components.
|
|
34
|
-
* the nodes are components and the edges has a label of the dependency type.
|
|
35
|
-
*
|
|
36
|
-
* the way how it is done is iterations by depths. each depth we gather all the dependencies of
|
|
37
|
-
* that depths, make sure all objects exist and then check their dependencies for the next depth.
|
|
38
|
-
* once there is no dependency left, we're on the last depth level and the graph is ready.
|
|
39
|
-
*
|
|
40
|
-
* for example, imagine the following graph:
|
|
41
|
-
* A1 -> A2 -> A3
|
|
42
|
-
* B1 -> B2 -> B3
|
|
43
|
-
* C1 -> C2 -> C3
|
|
44
|
-
*
|
|
45
|
-
* where the buildGraph is given [A1, B1, C1].
|
|
46
|
-
* first, it saves all these components as nodes in the graph. then, it finds the dependencies of
|
|
47
|
-
* the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects
|
|
48
|
-
* are missing. then, it loads them all (some from FS, some from the model) and sets the edges
|
|
49
|
-
* between the component and the dependencies.
|
|
50
|
-
* once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process
|
|
51
|
-
* above. since there are no more dependencies, the graph is completed.
|
|
52
|
-
* in this case, the total depth levels are 3.
|
|
53
|
-
*
|
|
54
|
-
* even with a huge project, there are not many depth levels. by iterating through depth levels
|
|
55
|
-
* we keep performance sane as the importMany doesn't run multiple time and therefore the round
|
|
56
|
-
* trips to the remotes are minimal.
|
|
57
|
-
*
|
|
58
|
-
* normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.
|
|
59
|
-
* however, since this buildGraph is performed on the workspace, a dependency may be new or
|
|
60
|
-
* modified and as such, we don't know its flattened yet.
|
|
61
|
-
*/
|
|
62
|
-
async buildGraph(ids: BitId[]): Promise<LegacyGraph> {
|
|
63
|
-
this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);
|
|
64
|
-
const start = Date.now();
|
|
65
|
-
const components = await this.loadManyComponents(ids, '<none>');
|
|
66
|
-
await this.processManyComponents(components);
|
|
67
|
-
this.logger.debug(
|
|
68
|
-
`GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`
|
|
69
|
-
);
|
|
70
|
-
return this.graph;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private getAllDepsUnfiltered(component: Component) {
|
|
74
|
-
return component.getAllDependenciesIds().difference(this.ignoreIds);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private async getAllDepsFiltered(component: Component): Promise<BitIds> {
|
|
78
|
-
const depsWithoutIgnore = this.getAllDepsUnfiltered(component);
|
|
79
|
-
const shouldLoadFunc = this.shouldLoadItsDeps;
|
|
80
|
-
if (!shouldLoadFunc) return depsWithoutIgnore;
|
|
81
|
-
const deps = await mapSeries(depsWithoutIgnore, async (depId) => {
|
|
82
|
-
const shouldLoad = await shouldLoadFunc(depId);
|
|
83
|
-
if (!shouldLoad) this.ignoreIds.push(depId);
|
|
84
|
-
return shouldLoad ? depId : null;
|
|
85
|
-
});
|
|
86
|
-
return BitIds.fromArray(compact(deps));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private async processManyComponents(components: Component[]) {
|
|
90
|
-
this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);
|
|
91
|
-
this.depth += 1;
|
|
92
|
-
await this.importObjects(components);
|
|
93
|
-
const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));
|
|
94
|
-
const allDependenciesFlattened = flatten(allDependencies);
|
|
95
|
-
if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private async importObjects(components: Component[]) {
|
|
99
|
-
const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();
|
|
100
|
-
const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());
|
|
101
|
-
const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);
|
|
102
|
-
await scopeComponentsImporter.importMany(
|
|
103
|
-
BitIds.uniqFromArray(allDepsWithScope),
|
|
104
|
-
undefined,
|
|
105
|
-
this.shouldThrowOnMissingDep
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private async processOneComponent(component: Component) {
|
|
110
|
-
const idStr = component.id.toString();
|
|
111
|
-
if (this.completed.includes(idStr)) return [];
|
|
112
|
-
const allIds = await this.getAllDepsFiltered(component);
|
|
113
|
-
|
|
114
|
-
const allDependencies = await this.loadManyComponents(allIds, idStr);
|
|
115
|
-
Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {
|
|
116
|
-
depsIds.forEach((depId) => {
|
|
117
|
-
if (this.ignoreIds.has(depId)) return;
|
|
118
|
-
if (!this.graph.hasNode(depId.toString())) {
|
|
119
|
-
throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);
|
|
120
|
-
}
|
|
121
|
-
this.graph.setEdge(idStr, depId.toString(), depType);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
this.completed.push(idStr);
|
|
125
|
-
return allDependencies;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {
|
|
129
|
-
const components = await mapSeries(componentsIds, async (comp: BitId) => {
|
|
130
|
-
const idStr = comp.toString();
|
|
131
|
-
const fromGraph = this.graph.node(idStr);
|
|
132
|
-
if (fromGraph) return fromGraph;
|
|
133
|
-
try {
|
|
134
|
-
const component = await this.loadComponent(comp);
|
|
135
|
-
this.graph.setNode(idStr, component);
|
|
136
|
-
return component;
|
|
137
|
-
} catch (err: any) {
|
|
138
|
-
if (err instanceof ComponentNotFound) {
|
|
139
|
-
throw new BitError(
|
|
140
|
-
`error: component "${idStr}" was not found.\nthis component is a dependency of "${dependenciesOf}" and is needed as part of the graph generation`
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
this.logger.error(`failed loading dependencies of ${dependenciesOf}`);
|
|
144
|
-
throw err;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return components;
|
|
148
|
-
}
|
|
149
|
-
private async loadComponent(componentId: BitId): Promise<Component> {
|
|
150
|
-
const componentMap = this.consumer.bitMap.getComponentIfExist(componentId);
|
|
151
|
-
const isOnWorkspace = Boolean(componentMap);
|
|
152
|
-
if (isOnWorkspace) {
|
|
153
|
-
return this.consumer.loadComponentForCapsule(componentId);
|
|
154
|
-
}
|
|
155
|
-
// a dependency might have been installed as a package in the workspace, and as such doesn't
|
|
156
|
-
// have a componentMap.
|
|
157
|
-
const componentFromModel = await this.consumer.loadComponentFromModel(componentId);
|
|
158
|
-
return componentFromModel.clone();
|
|
159
|
-
}
|
|
160
|
-
}
|
package/capsule.cmd.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line max-classes-per-file
|
|
2
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
-
import { CapsuleList, IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
|
|
6
|
-
import { Workspace } from '.';
|
|
7
|
-
|
|
8
|
-
type CreateOpts = {
|
|
9
|
-
baseDir?: string;
|
|
10
|
-
rootBaseDir?: string;
|
|
11
|
-
alwaysNew?: boolean;
|
|
12
|
-
seedersOnly?: boolean;
|
|
13
|
-
id: string;
|
|
14
|
-
installPackages?: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export class CapsuleCreateCmd implements Command {
|
|
18
|
-
name = 'create [componentIds...]';
|
|
19
|
-
description = `create capsules`;
|
|
20
|
-
group = 'capsules';
|
|
21
|
-
alias = '';
|
|
22
|
-
options = [
|
|
23
|
-
[
|
|
24
|
-
'b',
|
|
25
|
-
'base-dir <name>',
|
|
26
|
-
'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)',
|
|
27
|
-
],
|
|
28
|
-
['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'],
|
|
29
|
-
['a', 'always-new', 'create new environment for capsule'],
|
|
30
|
-
['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'],
|
|
31
|
-
['i', 'id <name>', 'reuse capsule of certain name'],
|
|
32
|
-
['j', 'json', 'json format'],
|
|
33
|
-
['d', 'install-packages', 'install packages by the package-manager'],
|
|
34
|
-
['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm'],
|
|
35
|
-
] as CommandOptions;
|
|
36
|
-
|
|
37
|
-
constructor(private workspace: Workspace, private isolator: IsolatorMain) {}
|
|
38
|
-
|
|
39
|
-
async create(
|
|
40
|
-
[componentIds = []]: [string[]],
|
|
41
|
-
{ baseDir, rootBaseDir, alwaysNew = false, id, installPackages = false, seedersOnly = false }: CreateOpts
|
|
42
|
-
): Promise<CapsuleList> {
|
|
43
|
-
// @todo: why it is not an array?
|
|
44
|
-
if (componentIds && !Array.isArray(componentIds)) componentIds = [componentIds];
|
|
45
|
-
const capsuleOptions: IsolateComponentsOptions = {
|
|
46
|
-
baseDir,
|
|
47
|
-
rootBaseDir,
|
|
48
|
-
installOptions: { installPackages },
|
|
49
|
-
alwaysNew,
|
|
50
|
-
seedersOnly,
|
|
51
|
-
includeFromNestedHosts: true,
|
|
52
|
-
name: id,
|
|
53
|
-
};
|
|
54
|
-
const ids = await this.workspace.resolveMultipleComponentIds(componentIds);
|
|
55
|
-
const network = await this.isolator.isolateComponents(ids, capsuleOptions);
|
|
56
|
-
const capsules = network.graphCapsules;
|
|
57
|
-
return capsules;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async report([componentIds]: [string[]], opts: CreateOpts) {
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
const capsules = await this.create(componentIds, opts);
|
|
63
|
-
const capsuleOutput = capsules
|
|
64
|
-
.map((capsule) => `${chalk.bold(capsule.component.id.toString())} - ${capsule.path}`)
|
|
65
|
-
.join('\n');
|
|
66
|
-
const title = `${capsules.length} capsule(s) were created successfully`;
|
|
67
|
-
return `${chalk.green(title)}\n${capsuleOutput}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async json([componentIds]: [string[]], opts: CreateOpts) {
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
const capsules = await this.create(componentIds, opts);
|
|
73
|
-
return capsules.map((c) => ({
|
|
74
|
-
id: c.component.id.toString(),
|
|
75
|
-
path: c.path,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class CapsuleListCmd implements Command {
|
|
81
|
-
name = 'list';
|
|
82
|
-
description = `list all capsules`;
|
|
83
|
-
shortDescription = 'list all capsules';
|
|
84
|
-
group = 'capsules';
|
|
85
|
-
alias = '';
|
|
86
|
-
options = [['j', 'json', 'json format']] as CommandOptions;
|
|
87
|
-
|
|
88
|
-
constructor(private isolator: IsolatorMain, private workspace: Workspace) {}
|
|
89
|
-
|
|
90
|
-
async report() {
|
|
91
|
-
const list = await this.isolator.list(this.workspace.path);
|
|
92
|
-
const { workspaceCapsulesRootDir, scopeCapsulesRootDir, scopeAspectsCapsulesRootDir } = this.getCapsulesRootDirs();
|
|
93
|
-
// TODO: improve output
|
|
94
|
-
return chalk.green(`found ${chalk.cyan(list.capsules.length.toString())} capsule(s) for workspace: ${chalk.cyan(
|
|
95
|
-
list.workspace
|
|
96
|
-
)}
|
|
97
|
-
workspace capsules root-dir: ${chalk.cyan(workspaceCapsulesRootDir)}
|
|
98
|
-
scope capsules root-dir: ${chalk.cyan(scopeCapsulesRootDir)}
|
|
99
|
-
scope's aspects capsules root-dir: ${chalk.cyan(scopeAspectsCapsulesRootDir)}
|
|
100
|
-
use --json to get the list of all workspace capsules`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async json() {
|
|
104
|
-
const list = await this.isolator.list(this.workspace.path);
|
|
105
|
-
const rootDirs = this.getCapsulesRootDirs();
|
|
106
|
-
return { ...list, ...rootDirs };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private getCapsulesRootDirs() {
|
|
110
|
-
const workspaceCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.path);
|
|
111
|
-
const scopeCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.scope.path);
|
|
112
|
-
const scopeAspectsCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.scope.getAspectCapsulePath());
|
|
113
|
-
|
|
114
|
-
return { workspaceCapsulesRootDir, scopeCapsulesRootDir, scopeAspectsCapsulesRootDir };
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export class CapsuleCmd implements Command {
|
|
119
|
-
name = 'capsule <sub-command>';
|
|
120
|
-
shortDescription = 'manage capsules';
|
|
121
|
-
description = `manage capsules.
|
|
122
|
-
a capsule is a directory contains the component code, isolated from the workspace.
|
|
123
|
-
normally, capsules are created during the build process, the component files are copied and the packages are installed
|
|
124
|
-
via the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for
|
|
125
|
-
other users after publishing/exporting them.`;
|
|
126
|
-
alias = '';
|
|
127
|
-
group = 'capsules';
|
|
128
|
-
commands: Command[] = [];
|
|
129
|
-
options = [] as CommandOptions;
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
132
|
-
async report(args: [string]) {
|
|
133
|
-
// it should never be here. Yargs throws an error before reaching this method.
|
|
134
|
-
return `Please specify a sub-command`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { ComponentID, AspectList } from '@teambit/component';
|
|
2
|
-
import { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';
|
|
3
|
-
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
4
|
-
import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
|
|
5
|
-
import detectIndent from 'detect-indent';
|
|
6
|
-
import detectNewline from 'detect-newline';
|
|
7
|
-
import fs from 'fs-extra';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import stringifyPackage from 'stringify-package';
|
|
10
|
-
|
|
11
|
-
import { AlreadyExistsError } from './exceptions';
|
|
12
|
-
|
|
13
|
-
interface ComponentConfigFileOptions {
|
|
14
|
-
indent: number;
|
|
15
|
-
newLine: '\r\n' | '\n' | undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface WriteConfigFileOptions {
|
|
19
|
-
override?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ComponentConfigFileJson {
|
|
23
|
-
componentId: any;
|
|
24
|
-
// TODO: think if we want to change it to aspects
|
|
25
|
-
extensions: any;
|
|
26
|
-
propagate: boolean;
|
|
27
|
-
defaultScope?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const DEFAULT_INDENT = 2;
|
|
31
|
-
const DEFAULT_NEWLINE = '\n';
|
|
32
|
-
|
|
33
|
-
export class ComponentConfigFile {
|
|
34
|
-
constructor(
|
|
35
|
-
public componentId: ComponentID,
|
|
36
|
-
public aspects: AspectList,
|
|
37
|
-
public propagate: boolean = false,
|
|
38
|
-
private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },
|
|
39
|
-
public defaultScope?: string
|
|
40
|
-
) {}
|
|
41
|
-
|
|
42
|
-
// TODO: remove consumer from here
|
|
43
|
-
static async load(
|
|
44
|
-
componentDir: PathOsBasedAbsolute,
|
|
45
|
-
aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,
|
|
46
|
-
outsideDefaultScope?: string
|
|
47
|
-
): Promise<ComponentConfigFile | undefined> {
|
|
48
|
-
const filePath = ComponentConfigFile.composePath(componentDir);
|
|
49
|
-
const isExist = await fs.pathExists(filePath);
|
|
50
|
-
if (!isExist) {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
54
|
-
const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);
|
|
55
|
-
const indent = detectIndent(content).amount;
|
|
56
|
-
const newLine = detectNewline(content);
|
|
57
|
-
const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);
|
|
58
|
-
const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));
|
|
59
|
-
|
|
60
|
-
return new ComponentConfigFile(componentId, aspects, !!parsed.propagate, { indent, newLine }, parsed.defaultScope);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static composePath(componentRootFolder: string) {
|
|
64
|
-
return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async write(componentDir: string, options: WriteConfigFileOptions = {}): Promise<void> {
|
|
68
|
-
const json = this.toJson();
|
|
69
|
-
const filePath = ComponentConfigFile.composePath(componentDir);
|
|
70
|
-
const isExist = await fs.pathExists(filePath);
|
|
71
|
-
if (isExist && !options.override) {
|
|
72
|
-
throw new AlreadyExistsError(filePath);
|
|
73
|
-
}
|
|
74
|
-
return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
toJson(): ComponentConfigFileJson {
|
|
78
|
-
return {
|
|
79
|
-
componentId: this.componentId.toObject(),
|
|
80
|
-
propagate: this.propagate,
|
|
81
|
-
defaultScope: this.defaultScope,
|
|
82
|
-
extensions: this.aspects.toConfigObject(),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
toString(): string {
|
|
87
|
-
const json = this.toJson();
|
|
88
|
-
return stringifyPackage(json, this.options.indent, this.options.newLine);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function parseComponentJsonContent(str: string, dir: string) {
|
|
93
|
-
try {
|
|
94
|
-
return JSON.parse(str);
|
|
95
|
-
} catch (err: any) {
|
|
96
|
-
throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AlreadyExistsError } from './already-exists';
|