@teambit/graph 0.0.881 → 0.0.883
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/component-graph/component-graph.js +4 -46
- package/dist/component-graph/component-graph.js.map +1 -1
- package/dist/component-graph/index.js +0 -3
- package/dist/component-graph/index.js.map +1 -1
- package/dist/duplicate-dependency.js +1 -7
- package/dist/duplicate-dependency.js.map +1 -1
- package/dist/edge-type.js +0 -1
- package/dist/edge-type.js.map +1 -1
- package/dist/graph-builder.js +0 -17
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-cmd.js +4 -65
- package/dist/graph-cmd.js.map +1 -1
- package/dist/graph.aspect.js +0 -5
- package/dist/graph.aspect.js.map +1 -1
- package/dist/graph.compare.section.js +0 -13
- package/dist/graph.compare.section.js.map +1 -1
- package/dist/graph.composition.js +0 -6
- package/dist/graph.composition.js.map +1 -1
- package/dist/graph.graphql.js +0 -14
- package/dist/graph.graphql.js.map +1 -1
- package/dist/graph.main.runtime.js +0 -36
- package/dist/graph.main.runtime.js.map +1 -1
- package/dist/graph.ui.runtime.js +1 -38
- package/dist/graph.ui.runtime.js.map +1 -1
- package/dist/index.js +0 -33
- package/dist/index.js.map +1 -1
- package/dist/model/dependency/dependency.js +0 -8
- package/dist/model/dependency/dependency.js.map +1 -1
- package/dist/model/dependency/index.js +0 -3
- package/dist/model/dependency/index.js.map +1 -1
- package/dist/object-list-to-graph.js +0 -23
- package/dist/object-list-to-graph.js.map +1 -1
- package/dist/ui/component-node/component-node.js +9 -56
- package/dist/ui/component-node/component-node.js.map +1 -1
- package/dist/ui/component-node/index.js +0 -12
- package/dist/ui/component-node/index.js.map +1 -1
- package/dist/ui/component-node/variants.js +0 -6
- package/dist/ui/component-node/variants.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-graph-model.js +0 -6
- package/dist/ui/dependencies-compare/compare-graph-model.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-node-model.js +0 -11
- package/dist/ui/dependencies-compare/compare-node-model.js.map +1 -1
- package/dist/ui/dependencies-compare/dependencies-compare.js +0 -41
- package/dist/ui/dependencies-compare/dependencies-compare.js.map +1 -1
- package/dist/ui/dependencies-compare/dependency-compare-node.js +4 -66
- package/dist/ui/dependencies-compare/dependency-compare-node.js.map +1 -1
- package/dist/ui/dependencies-compare/diff-graph.js +2 -23
- package/dist/ui/dependencies-compare/diff-graph.js.map +1 -1
- package/dist/ui/dependencies-compare/index.js +0 -3
- package/dist/ui/dependencies-compare/index.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-elements.js +0 -14
- package/dist/ui/dependencies-graph/calc-elements.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-layout.js +5 -11
- package/dist/ui/dependencies-graph/calc-layout.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js +0 -15
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/index.js +0 -3
- package/dist/ui/dependencies-graph/dep-edge/index.js.map +1 -1
- package/dist/ui/dependencies-graph/dependencies-graph.js +12 -47
- package/dist/ui/dependencies-graph/dependencies-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/graph-context.js +0 -4
- package/dist/ui/dependencies-graph/graph-context.js.map +1 -1
- package/dist/ui/dependencies-graph/index.js +0 -24
- package/dist/ui/dependencies-graph/index.js.map +1 -1
- package/dist/ui/dependencies-graph/minimap.js +0 -8
- package/dist/ui/dependencies-graph/minimap.js.map +1 -1
- package/dist/ui/graph-page/graph-filters.js +5 -19
- package/dist/ui/graph-page/graph-filters.js.map +1 -1
- package/dist/ui/graph-page/graph-page.js +0 -37
- package/dist/ui/graph-page/graph-page.js.map +1 -1
- package/dist/ui/graph-page/index.js +0 -12
- package/dist/ui/graph-page/index.js.map +1 -1
- package/dist/ui/graph.section.js +0 -13
- package/dist/ui/graph.section.js.map +1 -1
- package/dist/ui/query/edge-model.js +0 -8
- package/dist/ui/query/edge-model.js.map +1 -1
- package/dist/ui/query/get-graph.query.js +1 -4
- package/dist/ui/query/get-graph.query.js.map +1 -1
- package/dist/ui/query/graph-model.js +0 -10
- package/dist/ui/query/graph-model.js.map +1 -1
- package/dist/ui/query/index.js +0 -18
- package/dist/ui/query/index.js.map +1 -1
- package/dist/ui/query/node-model.js +2 -13
- package/dist/ui/query/node-model.js.map +1 -1
- package/dist/ui/query/use-graph-query.js +0 -16
- package/dist/ui/query/use-graph-query.js.map +1 -1
- package/dist/ui/query/use-graph.js +0 -7
- package/dist/ui/query/use-graph.js.map +1 -1
- package/package-tar/teambit-graph-0.0.883.tgz +0 -0
- package/package.json +6 -6
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-graph-0.0.881.tgz +0 -0
package/dist/graph-cmd.js
CHANGED
@@ -1,140 +1,98 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.promise.js");
|
8
|
-
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
10
7
|
value: true
|
11
8
|
});
|
12
9
|
exports.GraphCmd = void 0;
|
13
|
-
|
14
10
|
function _defineProperty2() {
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
-
|
17
12
|
_defineProperty2 = function () {
|
18
13
|
return data;
|
19
14
|
};
|
20
|
-
|
21
15
|
return data;
|
22
16
|
}
|
23
|
-
|
24
17
|
function _chalk() {
|
25
18
|
const data = _interopRequireDefault(require("chalk"));
|
26
|
-
|
27
19
|
_chalk = function () {
|
28
20
|
return data;
|
29
21
|
};
|
30
|
-
|
31
22
|
return data;
|
32
23
|
}
|
33
|
-
|
34
24
|
function _os() {
|
35
25
|
const data = _interopRequireDefault(require("os"));
|
36
|
-
|
37
26
|
_os = function () {
|
38
27
|
return data;
|
39
28
|
};
|
40
|
-
|
41
29
|
return data;
|
42
30
|
}
|
43
|
-
|
44
31
|
function path() {
|
45
32
|
const data = _interopRequireWildcard(require("path"));
|
46
|
-
|
47
33
|
path = function () {
|
48
34
|
return data;
|
49
35
|
};
|
50
|
-
|
51
36
|
return data;
|
52
37
|
}
|
53
|
-
|
54
38
|
function _graphlib() {
|
55
39
|
const data = _interopRequireDefault(require("graphlib"));
|
56
|
-
|
57
40
|
_graphlib = function () {
|
58
41
|
return data;
|
59
42
|
};
|
60
|
-
|
61
43
|
return data;
|
62
44
|
}
|
63
|
-
|
64
45
|
function _legacyBitId() {
|
65
46
|
const data = require("@teambit/legacy-bit-id");
|
66
|
-
|
67
47
|
_legacyBitId = function () {
|
68
48
|
return data;
|
69
49
|
};
|
70
|
-
|
71
50
|
return data;
|
72
51
|
}
|
73
|
-
|
74
52
|
function _utils() {
|
75
53
|
const data = require("@teambit/legacy/dist/utils");
|
76
|
-
|
77
54
|
_utils = function () {
|
78
55
|
return data;
|
79
56
|
};
|
80
|
-
|
81
57
|
return data;
|
82
58
|
}
|
83
|
-
|
84
59
|
function _vizgraph() {
|
85
60
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/graph/vizgraph"));
|
86
|
-
|
87
61
|
_vizgraph = function () {
|
88
62
|
return data;
|
89
63
|
};
|
90
|
-
|
91
64
|
return data;
|
92
65
|
}
|
93
|
-
|
94
66
|
function _consumer() {
|
95
67
|
const data = require("@teambit/legacy/dist/consumer");
|
96
|
-
|
97
68
|
_consumer = function () {
|
98
69
|
return data;
|
99
70
|
};
|
100
|
-
|
101
71
|
return data;
|
102
72
|
}
|
103
|
-
|
104
73
|
function _scopeGraph() {
|
105
74
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/graph/scope-graph"));
|
106
|
-
|
107
75
|
_scopeGraph = function () {
|
108
76
|
return data;
|
109
77
|
};
|
110
|
-
|
111
78
|
return data;
|
112
79
|
}
|
113
|
-
|
114
80
|
function _exceptions() {
|
115
81
|
const data = require("@teambit/legacy/dist/consumer/exceptions");
|
116
|
-
|
117
82
|
_exceptions = function () {
|
118
83
|
return data;
|
119
84
|
};
|
120
|
-
|
121
85
|
return data;
|
122
86
|
}
|
123
|
-
|
124
87
|
function _getRemoteByName() {
|
125
88
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/remotes/get-remote-by-name"));
|
126
|
-
|
127
89
|
_getRemoteByName = function () {
|
128
90
|
return data;
|
129
91
|
};
|
130
|
-
|
131
92
|
return data;
|
132
93
|
}
|
133
|
-
|
134
94
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
135
|
-
|
136
95
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
137
|
-
|
138
96
|
class GraphCmd {
|
139
97
|
constructor() {
|
140
98
|
(0, _defineProperty2().default)(this, "name", 'graph [id]');
|
@@ -144,7 +102,6 @@ class GraphCmd {
|
|
144
102
|
(0, _defineProperty2().default)(this, "options", [['i', 'image <image>', 'image path. use one of the following extensions: [gif, png, svg, pdf]'], ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'], ['', 'all-versions', 'enter all components versions into the graph, not only latest'], ['', 'layout <name>', 'GraphVis layout. default to "dot". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]'], ['j', 'json', 'json format']]);
|
145
103
|
(0, _defineProperty2().default)(this, "remoteOp", true);
|
146
104
|
}
|
147
|
-
|
148
105
|
async report([id], {
|
149
106
|
remote,
|
150
107
|
allVersions,
|
@@ -154,42 +111,32 @@ class GraphCmd {
|
|
154
111
|
const consumer = await (0, _consumer().loadConsumerIfExist)();
|
155
112
|
if (!consumer && !remote) throw new (_exceptions().ConsumerNotFound)();
|
156
113
|
const graph = await this.generateGraph(consumer, id, remote, allVersions);
|
157
|
-
const config = {};
|
158
|
-
|
114
|
+
const config = {};
|
115
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
159
116
|
if (layout) config.layout = layout;
|
160
117
|
const visualDependencyGraph = await _vizgraph().default.loadFromGraphlib(graph, config);
|
161
|
-
|
162
118
|
const getBitId = () => {
|
163
119
|
if (!id) return undefined;
|
164
120
|
if (remote) return _legacyBitId().BitId.parse(id, true); // user used --remote so we know it has a scope
|
165
|
-
|
166
121
|
return consumer === null || consumer === void 0 ? void 0 : consumer.getParsedId(id);
|
167
122
|
};
|
168
|
-
|
169
123
|
const bitId = getBitId();
|
170
|
-
|
171
124
|
if (bitId) {
|
172
125
|
visualDependencyGraph.highlightId(bitId);
|
173
126
|
}
|
174
|
-
|
175
127
|
image = image || path().join(_os().default.tmpdir(), `${(0, _utils().generateRandomStr)()}.png`);
|
176
128
|
const result = await visualDependencyGraph.image(image);
|
177
129
|
return _chalk().default.green(`image created at ${result}`);
|
178
130
|
}
|
179
|
-
|
180
131
|
async generateGraph(consumer, id, remote, allVersions) {
|
181
132
|
if (!consumer && !remote) throw new (_exceptions().ConsumerNotFound)();
|
182
|
-
|
183
133
|
const getBitId = () => {
|
184
134
|
if (!id) return undefined;
|
185
135
|
if (remote) return _legacyBitId().BitId.parse(id, true); // user used --remote so we know it has a scope
|
186
136
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
187
|
-
|
188
137
|
return consumer.getParsedId(id);
|
189
138
|
};
|
190
|
-
|
191
139
|
const bitId = getBitId();
|
192
|
-
|
193
140
|
if (remote) {
|
194
141
|
if (id) {
|
195
142
|
// @ts-ignore scope must be set as it came from a remote
|
@@ -198,31 +145,25 @@ class GraphCmd {
|
|
198
145
|
const componentDepGraph = await remoteScope.graph(bitId);
|
199
146
|
return componentDepGraph.graph;
|
200
147
|
}
|
201
|
-
|
202
148
|
if (typeof remote !== 'string') {
|
203
149
|
throw new Error('please specify remote scope name or enter an id');
|
204
150
|
}
|
205
|
-
|
206
151
|
const remoteScope = await (0, _getRemoteByName().default)(remote, consumer);
|
207
152
|
const componentDepGraph = await remoteScope.graph();
|
208
153
|
return componentDepGraph.graph;
|
209
154
|
}
|
210
|
-
|
211
|
-
|
212
|
-
|
155
|
+
const onlyLatest = !allVersions;
|
156
|
+
// @ts-ignore consumer must be set here
|
213
157
|
const workspaceGraph = await _scopeGraph().default.buildGraphFromWorkspace(consumer, onlyLatest);
|
214
158
|
const dependencyGraph = new (_scopeGraph().default)(workspaceGraph);
|
215
|
-
|
216
159
|
if (id) {
|
217
160
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
218
161
|
const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);
|
219
162
|
const componentDepGraph = new (_scopeGraph().default)(componentGraph);
|
220
163
|
return componentDepGraph.graph;
|
221
164
|
}
|
222
|
-
|
223
165
|
return dependencyGraph.graph;
|
224
166
|
}
|
225
|
-
|
226
167
|
async json([id], {
|
227
168
|
remote,
|
228
169
|
allVersions
|
@@ -232,9 +173,7 @@ class GraphCmd {
|
|
232
173
|
const graph = await this.generateGraph(consumer, id, remote, allVersions);
|
233
174
|
return _graphlib().default.json.write(graph);
|
234
175
|
}
|
235
|
-
|
236
176
|
}
|
237
|
-
|
238
177
|
exports.GraphCmd = GraphCmd;
|
239
178
|
|
240
179
|
//# sourceMappingURL=graph-cmd.js.map
|
package/dist/graph-cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphCmd","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","getBitId","undefined","BitId","parse","getParsedId","bitId","highlightId","path","join","os","tmpdir","generateRandomStr","result","chalk","green","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\nimport * as path from 'path';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { generateRandomStr } from '@teambit/legacy/dist/utils';\nimport VisualDependencyGraph from '@teambit/legacy/dist/scope/graph/vizgraph';\nimport { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\n\ntype GraphOpt = {\n image?: string;\n remote?: string;\n allVersions?: boolean;\n layout?: string;\n json?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = 'EXPERIMENTAL. generate an image file with the dependencies graph';\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path. use one of the following extensions: [gif, png, svg, pdf]'],\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n ['', 'all-versions', 'enter all components versions into the graph, not only latest'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n async report([id]: [string], { remote, allVersions, layout, image }: GraphOpt): Promise<string> {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n\n const config = {};\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (layout) config.layout = layout;\n const visualDependencyGraph = await VisualDependencyGraph.loadFromGraphlib(graph, config);\n\n const getBitId = (): BitId | undefined => {\n if (!id) return undefined;\n if (remote) return BitId.parse(id, true); // user used --remote so we know it has a scope\n return consumer?.getParsedId(id);\n };\n const bitId = getBitId();\n\n if (bitId) {\n visualDependencyGraph.highlightId(bitId);\n }\n image = image || path.join(os.tmpdir(), `${generateRandomStr()}.png`);\n const result = await visualDependencyGraph.image(image);\n\n return chalk.green(`image created at ${result}`);\n }\n\n private async generateGraph(\n consumer?: Consumer,\n id?: string,\n remote?: string,\n allVersions?: boolean\n ): Promise<GraphLib.Graph> {\n if (!consumer && !remote) throw new ConsumerNotFound();\n const getBitId = (): BitId | undefined => {\n if (!id) return undefined;\n if (remote) return BitId.parse(id, true); // user used --remote so we know it has a scope\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return consumer.getParsedId(id);\n };\n const bitId = getBitId();\n if (remote) {\n if (id) {\n // @ts-ignore scope must be set as it came from a remote\n const scopeName: string = typeof remote === 'string' ? remote : bitId.scope;\n const remoteScope = await getRemoteByName(scopeName, consumer);\n const componentDepGraph = await remoteScope.graph(bitId);\n return componentDepGraph.graph;\n }\n if (typeof remote !== 'string') {\n throw new Error('please specify remote scope name or enter an id');\n }\n const remoteScope = await getRemoteByName(remote, consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n\n const onlyLatest = !allVersions;\n // @ts-ignore consumer must be set here\n const workspaceGraph = await DependencyGraph.buildGraphFromWorkspace(consumer, onlyLatest);\n const dependencyGraph = new DependencyGraph(workspaceGraph);\n if (id) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);\n const componentDepGraph = new DependencyGraph(componentGraph);\n return componentDepGraph.graph;\n }\n return dependencyGraph.graph;\n }\n\n async json([id]: [string], { remote, allVersions }: GraphOpt) {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n return GraphLib.json.write(graph);\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["GraphCmd","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","getBitId","undefined","BitId","parse","getParsedId","bitId","highlightId","path","join","os","tmpdir","generateRandomStr","result","chalk","green","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\nimport * as path from 'path';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { generateRandomStr } from '@teambit/legacy/dist/utils';\nimport VisualDependencyGraph from '@teambit/legacy/dist/scope/graph/vizgraph';\nimport { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\n\ntype GraphOpt = {\n image?: string;\n remote?: string;\n allVersions?: boolean;\n layout?: string;\n json?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = 'EXPERIMENTAL. generate an image file with the dependencies graph';\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path. use one of the following extensions: [gif, png, svg, pdf]'],\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n ['', 'all-versions', 'enter all components versions into the graph, not only latest'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n async report([id]: [string], { remote, allVersions, layout, image }: GraphOpt): Promise<string> {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n\n const config = {};\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (layout) config.layout = layout;\n const visualDependencyGraph = await VisualDependencyGraph.loadFromGraphlib(graph, config);\n\n const getBitId = (): BitId | undefined => {\n if (!id) return undefined;\n if (remote) return BitId.parse(id, true); // user used --remote so we know it has a scope\n return consumer?.getParsedId(id);\n };\n const bitId = getBitId();\n\n if (bitId) {\n visualDependencyGraph.highlightId(bitId);\n }\n image = image || path.join(os.tmpdir(), `${generateRandomStr()}.png`);\n const result = await visualDependencyGraph.image(image);\n\n return chalk.green(`image created at ${result}`);\n }\n\n private async generateGraph(\n consumer?: Consumer,\n id?: string,\n remote?: string,\n allVersions?: boolean\n ): Promise<GraphLib.Graph> {\n if (!consumer && !remote) throw new ConsumerNotFound();\n const getBitId = (): BitId | undefined => {\n if (!id) return undefined;\n if (remote) return BitId.parse(id, true); // user used --remote so we know it has a scope\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return consumer.getParsedId(id);\n };\n const bitId = getBitId();\n if (remote) {\n if (id) {\n // @ts-ignore scope must be set as it came from a remote\n const scopeName: string = typeof remote === 'string' ? remote : bitId.scope;\n const remoteScope = await getRemoteByName(scopeName, consumer);\n const componentDepGraph = await remoteScope.graph(bitId);\n return componentDepGraph.graph;\n }\n if (typeof remote !== 'string') {\n throw new Error('please specify remote scope name or enter an id');\n }\n const remoteScope = await getRemoteByName(remote, consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n\n const onlyLatest = !allVersions;\n // @ts-ignore consumer must be set here\n const workspaceGraph = await DependencyGraph.buildGraphFromWorkspace(consumer, onlyLatest);\n const dependencyGraph = new DependencyGraph(workspaceGraph);\n if (id) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);\n const componentDepGraph = new DependencyGraph(componentGraph);\n return componentDepGraph.graph;\n }\n return dependencyGraph.graph;\n }\n\n async json([id]: [string], { remote, allVersions }: GraphOpt) {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n return GraphLib.json.write(graph);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8E;AAAA;AAUvE,MAAMA,QAAQ,CAAoB;EAAA;IAAA,8CAChC,YAAY;IAAA,q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C,0BAAe,EAAC/B,MAAM,EAAEI,QAAQ,CAAC;MAC3D,MAAM4B,iBAAiB,GAAG,MAAMF,WAAW,CAACvB,KAAK,EAAE;MACnD,OAAOyB,iBAAiB,CAACzB,KAAK;IAChC;IAEA,MAAM2B,UAAU,GAAG,CAACjC,WAAW;IAC/B;IACA,MAAMkC,cAAc,GAAG,MAAMC,qBAAe,CAACC,uBAAuB,CAACjC,QAAQ,EAAE8B,UAAU,CAAC;IAC1F,MAAMI,eAAe,GAAG,KAAIF,qBAAe,EAACD,cAAc,CAAC;IAC3D,IAAIpC,EAAE,EAAE;MACN;MACA,MAAMwC,cAAc,GAAGD,eAAe,CAACE,gCAAgC,CAACtB,KAAK,CAAC;MAC9E,MAAMc,iBAAiB,GAAG,KAAII,qBAAe,EAACG,cAAc,CAAC;MAC7D,OAAOP,iBAAiB,CAACzB,KAAK;IAChC;IACA,OAAO+B,eAAe,CAAC/B,KAAK;EAC9B;EAEA,MAAMkC,IAAI,CAAC,CAAC1C,EAAE,CAAW,EAAE;IAAEC,MAAM;IAAEC;EAAsB,CAAC,EAAE;IAC5D,MAAMG,QAAQ,GAAG,MAAM,IAAAC,+BAAmB,GAAE;IAC5C,IAAI,CAACD,QAAQ,IAAI,CAACJ,MAAM,EAAE,MAAM,KAAIM,8BAAgB,GAAE;IAEtD,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,aAAa,CAACJ,QAAQ,EAAEL,EAAE,EAAEC,MAAM,EAAEC,WAAW,CAAC;IACzE,OAAOyC,mBAAQ,CAACD,IAAI,CAACE,KAAK,CAACpC,KAAK,CAAC;EACnC;AACF;AAAC"}
|
package/dist/graph.aspect.js
CHANGED
@@ -4,23 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.GraphAspect = void 0;
|
7
|
-
|
8
7
|
function _harmony() {
|
9
8
|
const data = require("@teambit/harmony");
|
10
|
-
|
11
9
|
_harmony = function () {
|
12
10
|
return data;
|
13
11
|
};
|
14
|
-
|
15
12
|
return data;
|
16
13
|
}
|
17
|
-
|
18
14
|
const GraphAspect = _harmony().Aspect.create({
|
19
15
|
id: 'teambit.component/graph',
|
20
16
|
dependencies: [],
|
21
17
|
defaultConfig: {}
|
22
18
|
});
|
23
|
-
|
24
19
|
exports.GraphAspect = GraphAspect;
|
25
20
|
|
26
21
|
//# sourceMappingURL=graph.aspect.js.map
|
package/dist/graph.aspect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphAspect","Aspect","create","id","dependencies","defaultConfig"],"sources":["graph.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const GraphAspect = Aspect.create({\n id: 'teambit.component/graph',\n dependencies: [],\n defaultConfig: {},\n});\n"],"mappings":"
|
1
|
+
{"version":3,"names":["GraphAspect","Aspect","create","id","dependencies","defaultConfig"],"sources":["graph.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const GraphAspect = Aspect.create({\n id: 'teambit.component/graph',\n dependencies: [],\n defaultConfig: {},\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,WAAW,GAAGC,iBAAM,CAACC,MAAM,CAAC;EACvCC,EAAE,EAAE,yBAAyB;EAC7BC,YAAY,EAAE,EAAE;EAChBC,aAAa,EAAE,CAAC;AAClB,CAAC,CAAC;AAAC"}
|
@@ -1,42 +1,31 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.GraphCompareSection = void 0;
|
9
|
-
|
10
8
|
function _defineProperty2() {
|
11
9
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
12
|
-
|
13
10
|
_defineProperty2 = function () {
|
14
11
|
return data;
|
15
12
|
};
|
16
|
-
|
17
13
|
return data;
|
18
14
|
}
|
19
|
-
|
20
15
|
function _react() {
|
21
16
|
const data = _interopRequireDefault(require("react"));
|
22
|
-
|
23
17
|
_react = function () {
|
24
18
|
return data;
|
25
19
|
};
|
26
|
-
|
27
20
|
return data;
|
28
21
|
}
|
29
|
-
|
30
22
|
function _graph() {
|
31
23
|
const data = require("@teambit/graph");
|
32
|
-
|
33
24
|
_graph = function () {
|
34
25
|
return data;
|
35
26
|
};
|
36
|
-
|
37
27
|
return data;
|
38
28
|
}
|
39
|
-
|
40
29
|
class GraphCompareSection {
|
41
30
|
constructor() {
|
42
31
|
(0, _defineProperty2().default)(this, "navigationLink", {
|
@@ -49,9 +38,7 @@ class GraphCompareSection {
|
|
49
38
|
element: /*#__PURE__*/_react().default.createElement(_graph().DependenciesCompare, null)
|
50
39
|
});
|
51
40
|
}
|
52
|
-
|
53
41
|
}
|
54
|
-
|
55
42
|
exports.GraphCompareSection = GraphCompareSection;
|
56
43
|
|
57
44
|
//# sourceMappingURL=graph.compare.section.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphCompareSection","href","children","order","path","element"],"sources":["graph.compare.section.tsx"],"sourcesContent":["import React from 'react';\nimport { Section } from '@teambit/component';\nimport { DependenciesCompare } from '@teambit/graph';\n\nexport class GraphCompareSection implements Section {\n navigationLink = {\n href: 'dependencies',\n children: 'Dependencies',\n order: 2,\n };\n\n route = {\n path: 'dependencies/*',\n element: <DependenciesCompare />,\n };\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["GraphCompareSection","href","children","order","path","element"],"sources":["graph.compare.section.tsx"],"sourcesContent":["import React from 'react';\nimport { Section } from '@teambit/component';\nimport { DependenciesCompare } from '@teambit/graph';\n\nexport class GraphCompareSection implements Section {\n navigationLink = {\n href: 'dependencies',\n children: 'Dependencies',\n order: 2,\n };\n\n route = {\n path: 'dependencies/*',\n element: <DependenciesCompare />,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,mBAAmB,CAAoB;EAAA;IAAA,wDACjC;MACfC,IAAI,EAAE,cAAc;MACpBC,QAAQ,EAAE,cAAc;MACxBC,KAAK,EAAE;IACT,CAAC;IAAA,+CAEO;MACNC,IAAI,EAAE,gBAAgB;MACtBC,OAAO,eAAE,+BAAC,4BAAmB;IAC/B,CAAC;EAAA;AACH;AAAC"}
|
@@ -1,22 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.Logo = void 0;
|
9
|
-
|
10
8
|
function _react() {
|
11
9
|
const data = _interopRequireDefault(require("react"));
|
12
|
-
|
13
10
|
_react = function () {
|
14
11
|
return data;
|
15
12
|
};
|
16
|
-
|
17
13
|
return data;
|
18
14
|
}
|
19
|
-
|
20
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
21
16
|
style: {
|
22
17
|
height: '100%',
|
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
29
24
|
},
|
30
25
|
src: "https://static.bit.dev/extensions-icons/graph.svg"
|
31
26
|
}));
|
32
|
-
|
33
27
|
exports.Logo = Logo;
|
34
28
|
|
35
29
|
//# sourceMappingURL=graph.composition.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["graph.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/graph.svg\" />\n </div>\n);\n"],"mappings":"
|
1
|
+
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["graph.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/graph.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAAmD,EAAG,CAExF;AAAC"}
|
package/dist/graph.graphql.js
CHANGED
@@ -1,38 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.sort.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.promise.js");
|
8
|
-
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
10
7
|
value: true
|
11
8
|
});
|
12
9
|
exports.graphSchema = graphSchema;
|
13
|
-
|
14
10
|
function _graphqlTag() {
|
15
11
|
const data = _interopRequireDefault(require("graphql-tag"));
|
16
|
-
|
17
12
|
_graphqlTag = function () {
|
18
13
|
return data;
|
19
14
|
};
|
20
|
-
|
21
15
|
return data;
|
22
16
|
}
|
23
|
-
|
24
17
|
function _edgeType() {
|
25
18
|
const data = require("./edge-type");
|
26
|
-
|
27
19
|
_edgeType = function () {
|
28
20
|
return data;
|
29
21
|
};
|
30
|
-
|
31
22
|
return data;
|
32
23
|
}
|
33
|
-
|
34
24
|
const textCmp = new Intl.Collator().compare;
|
35
|
-
|
36
25
|
function graphSchema(graphBuilder, componentAspect) {
|
37
26
|
return {
|
38
27
|
typeDefs: (0, _graphqlTag().default)`
|
@@ -89,19 +78,16 @@ function graphSchema(graphBuilder, componentAspect) {
|
|
89
78
|
const resolvedIds = ids ? await componentsHost.resolveMultipleComponentIds(ids) : (await componentsHost.list()).map(x => x.id);
|
90
79
|
const graph = await graphBuilder.getGraph(resolvedIds);
|
91
80
|
if (!graph) return undefined;
|
92
|
-
|
93
81
|
if (filter === 'runtimeOnly') {
|
94
82
|
const runtimeGraph = graph.runtimeOnly(resolvedIds.map(x => x.toString()));
|
95
83
|
return runtimeGraph;
|
96
84
|
}
|
97
|
-
|
98
85
|
return graph;
|
99
86
|
}
|
100
87
|
}
|
101
88
|
}
|
102
89
|
};
|
103
90
|
}
|
104
|
-
|
105
91
|
function getDependencyLifecycleType(edgeRawData) {
|
106
92
|
if (edgeRawData === 'dev') return _edgeType().EdgeType.dev;
|
107
93
|
if (edgeRawData === 'runtime') return _edgeType().EdgeType.runtime;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["textCmp","Intl","Collator","compare","graphSchema","graphBuilder","componentAspect","typeDefs","gql","resolvers","ComponentGraph","nodes","graph","map","node","id","component","attr","sort","a","b","edges","edge","sourceId","targetId","dependencyLifecycleType","getDependencyLifecycleType","type","Query","_parent","ids","filter","componentsHost","getHost","resolvedIds","resolveMultipleComponentIds","list","x","getGraph","undefined","runtimeGraph","runtimeOnly","toString","edgeRawData","EdgeType","dev","runtime","peer"],"sources":["graph.graphql.ts"],"sourcesContent":["import { ComponentMain } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\n\nimport { GraphBuilder } from './graph-builder';\nimport { ComponentGraph } from './component-graph';\nimport { GraphFilter } from './model/graph-filters';\nimport { DependencyType } from './model/dependency';\nimport { EdgeType } from './edge-type';\n\nconst textCmp = new Intl.Collator().compare;\n\nexport function graphSchema(graphBuilder: GraphBuilder, componentAspect: ComponentMain): Schema {\n return {\n typeDefs: gql`\n type ComponentGraph {\n nodes: [ComponentGraphNode]\n edges: [ComponentGraphEdge]\n }\n\n type ComponentGraphNode {\n id: String\n component: Component\n }\n\n enum DependencyLifecycleType {\n PEER\n RUNTIME\n DEV\n }\n\n type ComponentGraphEdge {\n sourceId: String\n targetId: String\n dependencyLifecycleType: DependencyLifecycleType\n }\n\n extend type Query {\n graph(ids: [String], filter: String): ComponentGraph\n }\n `,\n resolvers: {\n ComponentGraph: {\n nodes: (graph: ComponentGraph) => {\n return graph.nodes\n .map((node) => {\n return {\n id: node.id,\n component: node.attr,\n };\n })\n .sort((a, b) => textCmp(a.id, b.id));\n },\n edges: (graph: ComponentGraph) => {\n return graph.edges\n .map(\n (edge) =>\n ({\n sourceId: edge.sourceId,\n targetId: edge.targetId,\n dependencyLifecycleType: getDependencyLifecycleType(edge.attr.type),\n } as { sourceId: string; targetId: string; dependencyLifecycleType: EdgeType })\n )\n .sort((a, b) => textCmp(a.sourceId, b.sourceId))\n .sort((a, b) => textCmp(a.targetId, b.targetId));\n },\n },\n Query: {\n graph: async (_parent, { ids, filter }: { ids?: string[]; filter?: GraphFilter }) => {\n const componentsHost = componentAspect.getHost();\n const resolvedIds = ids\n ? await componentsHost.resolveMultipleComponentIds(ids)\n : (await componentsHost.list()).map((x) => x.id);\n\n const graph = await graphBuilder.getGraph(resolvedIds);\n if (!graph) return undefined;\n\n if (filter === 'runtimeOnly') {\n const runtimeGraph = graph.runtimeOnly(resolvedIds.map((x) => x.toString()));\n return runtimeGraph;\n }\n\n return graph;\n },\n },\n },\n };\n}\n\nfunction getDependencyLifecycleType(edgeRawData: DependencyType): EdgeType {\n if (edgeRawData === 'dev') return EdgeType.dev;\n if (edgeRawData === 'runtime') return EdgeType.runtime;\n return EdgeType.peer;\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["textCmp","Intl","Collator","compare","graphSchema","graphBuilder","componentAspect","typeDefs","gql","resolvers","ComponentGraph","nodes","graph","map","node","id","component","attr","sort","a","b","edges","edge","sourceId","targetId","dependencyLifecycleType","getDependencyLifecycleType","type","Query","_parent","ids","filter","componentsHost","getHost","resolvedIds","resolveMultipleComponentIds","list","x","getGraph","undefined","runtimeGraph","runtimeOnly","toString","edgeRawData","EdgeType","dev","runtime","peer"],"sources":["graph.graphql.ts"],"sourcesContent":["import { ComponentMain } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\n\nimport { GraphBuilder } from './graph-builder';\nimport { ComponentGraph } from './component-graph';\nimport { GraphFilter } from './model/graph-filters';\nimport { DependencyType } from './model/dependency';\nimport { EdgeType } from './edge-type';\n\nconst textCmp = new Intl.Collator().compare;\n\nexport function graphSchema(graphBuilder: GraphBuilder, componentAspect: ComponentMain): Schema {\n return {\n typeDefs: gql`\n type ComponentGraph {\n nodes: [ComponentGraphNode]\n edges: [ComponentGraphEdge]\n }\n\n type ComponentGraphNode {\n id: String\n component: Component\n }\n\n enum DependencyLifecycleType {\n PEER\n RUNTIME\n DEV\n }\n\n type ComponentGraphEdge {\n sourceId: String\n targetId: String\n dependencyLifecycleType: DependencyLifecycleType\n }\n\n extend type Query {\n graph(ids: [String], filter: String): ComponentGraph\n }\n `,\n resolvers: {\n ComponentGraph: {\n nodes: (graph: ComponentGraph) => {\n return graph.nodes\n .map((node) => {\n return {\n id: node.id,\n component: node.attr,\n };\n })\n .sort((a, b) => textCmp(a.id, b.id));\n },\n edges: (graph: ComponentGraph) => {\n return graph.edges\n .map(\n (edge) =>\n ({\n sourceId: edge.sourceId,\n targetId: edge.targetId,\n dependencyLifecycleType: getDependencyLifecycleType(edge.attr.type),\n } as { sourceId: string; targetId: string; dependencyLifecycleType: EdgeType })\n )\n .sort((a, b) => textCmp(a.sourceId, b.sourceId))\n .sort((a, b) => textCmp(a.targetId, b.targetId));\n },\n },\n Query: {\n graph: async (_parent, { ids, filter }: { ids?: string[]; filter?: GraphFilter }) => {\n const componentsHost = componentAspect.getHost();\n const resolvedIds = ids\n ? await componentsHost.resolveMultipleComponentIds(ids)\n : (await componentsHost.list()).map((x) => x.id);\n\n const graph = await graphBuilder.getGraph(resolvedIds);\n if (!graph) return undefined;\n\n if (filter === 'runtimeOnly') {\n const runtimeGraph = graph.runtimeOnly(resolvedIds.map((x) => x.toString()));\n return runtimeGraph;\n }\n\n return graph;\n },\n },\n },\n };\n}\n\nfunction getDependencyLifecycleType(edgeRawData: DependencyType): EdgeType {\n if (edgeRawData === 'dev') return EdgeType.dev;\n if (edgeRawData === 'runtime') return EdgeType.runtime;\n return EdgeType.peer;\n}\n"],"mappings":";;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA,MAAMA,OAAO,GAAG,IAAIC,IAAI,CAACC,QAAQ,EAAE,CAACC,OAAO;AAEpC,SAASC,WAAW,CAACC,YAA0B,EAAEC,eAA8B,EAAU;EAC9F,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAG,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,cAAc,EAAE;QACdC,KAAK,EAAGC,KAAqB,IAAK;UAChC,OAAOA,KAAK,CAACD,KAAK,CACfE,GAAG,CAAEC,IAAI,IAAK;YACb,OAAO;cACLC,EAAE,EAAED,IAAI,CAACC,EAAE;cACXC,SAAS,EAAEF,IAAI,CAACG;YAClB,CAAC;UACH,CAAC,CAAC,CACDC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKpB,OAAO,CAACmB,CAAC,CAACJ,EAAE,EAAEK,CAAC,CAACL,EAAE,CAAC,CAAC;QACxC,CAAC;QACDM,KAAK,EAAGT,KAAqB,IAAK;UAChC,OAAOA,KAAK,CAACS,KAAK,CACfR,GAAG,CACDS,IAAI,KACF;YACCC,QAAQ,EAAED,IAAI,CAACC,QAAQ;YACvBC,QAAQ,EAAEF,IAAI,CAACE,QAAQ;YACvBC,uB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D,OAAOF,oBAAQ,CAACG,IAAI;AACtB"}
|
@@ -1,117 +1,84 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.promise.js");
|
8
|
-
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
10
7
|
value: true
|
11
8
|
});
|
12
9
|
exports.GraphMain = void 0;
|
13
|
-
|
14
10
|
function _defineProperty2() {
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
-
|
17
12
|
_defineProperty2 = function () {
|
18
13
|
return data;
|
19
14
|
};
|
20
|
-
|
21
15
|
return data;
|
22
16
|
}
|
23
|
-
|
24
17
|
function _cli() {
|
25
18
|
const data = require("@teambit/cli");
|
26
|
-
|
27
19
|
_cli = function () {
|
28
20
|
return data;
|
29
21
|
};
|
30
|
-
|
31
22
|
return data;
|
32
23
|
}
|
33
|
-
|
34
24
|
function _component() {
|
35
25
|
const data = require("@teambit/component");
|
36
|
-
|
37
26
|
_component = function () {
|
38
27
|
return data;
|
39
28
|
};
|
40
|
-
|
41
29
|
return data;
|
42
30
|
}
|
43
|
-
|
44
31
|
function _graphql() {
|
45
32
|
const data = require("@teambit/graphql");
|
46
|
-
|
47
33
|
_graphql = function () {
|
48
34
|
return data;
|
49
35
|
};
|
50
|
-
|
51
36
|
return data;
|
52
37
|
}
|
53
|
-
|
54
38
|
function _logger() {
|
55
39
|
const data = require("@teambit/logger");
|
56
|
-
|
57
40
|
_logger = function () {
|
58
41
|
return data;
|
59
42
|
};
|
60
|
-
|
61
43
|
return data;
|
62
44
|
}
|
63
|
-
|
64
45
|
function _graphBuilder() {
|
65
46
|
const data = require("./graph-builder");
|
66
|
-
|
67
47
|
_graphBuilder = function () {
|
68
48
|
return data;
|
69
49
|
};
|
70
|
-
|
71
50
|
return data;
|
72
51
|
}
|
73
|
-
|
74
52
|
function _graph() {
|
75
53
|
const data = require("./graph.graphql");
|
76
|
-
|
77
54
|
_graph = function () {
|
78
55
|
return data;
|
79
56
|
};
|
80
|
-
|
81
57
|
return data;
|
82
58
|
}
|
83
|
-
|
84
59
|
function _graph2() {
|
85
60
|
const data = require("./graph.aspect");
|
86
|
-
|
87
61
|
_graph2 = function () {
|
88
62
|
return data;
|
89
63
|
};
|
90
|
-
|
91
64
|
return data;
|
92
65
|
}
|
93
|
-
|
94
66
|
function _graphCmd() {
|
95
67
|
const data = require("./graph-cmd");
|
96
|
-
|
97
68
|
_graphCmd = function () {
|
98
69
|
return data;
|
99
70
|
};
|
100
|
-
|
101
71
|
return data;
|
102
72
|
}
|
103
|
-
|
104
73
|
class GraphMain {
|
105
74
|
constructor(componentAspect, logger) {
|
106
75
|
this.componentAspect = componentAspect;
|
107
76
|
this.logger = logger;
|
108
77
|
}
|
109
|
-
|
110
78
|
async getGraph(ids, opts = {}) {
|
111
79
|
const graphBuilder = new (_graphBuilder().GraphBuilder)(this.componentAspect);
|
112
80
|
return graphBuilder.getGraph(ids, opts);
|
113
81
|
}
|
114
|
-
|
115
82
|
static async provider([graphql, componentAspect, cli, loggerMain]) {
|
116
83
|
const logger = loggerMain.createLogger(_graph2().GraphAspect.id);
|
117
84
|
const graphBuilder = new (_graphBuilder().GraphBuilder)(componentAspect);
|
@@ -120,14 +87,11 @@ class GraphMain {
|
|
120
87
|
cli.register(new (_graphCmd().GraphCmd)());
|
121
88
|
return graphMain;
|
122
89
|
}
|
123
|
-
|
124
90
|
}
|
125
|
-
|
126
91
|
exports.GraphMain = GraphMain;
|
127
92
|
(0, _defineProperty2().default)(GraphMain, "slots", []);
|
128
93
|
(0, _defineProperty2().default)(GraphMain, "dependencies", [_graphql().GraphqlAspect, _component().ComponentAspect, _cli().CLIAspect, _logger().LoggerAspect]);
|
129
94
|
(0, _defineProperty2().default)(GraphMain, "runtime", _cli().MainRuntime);
|
130
|
-
|
131
95
|
_graph2().GraphAspect.addRuntime(GraphMain);
|
132
96
|
|
133
97
|
//# sourceMappingURL=graph.main.runtime.js.map
|