@teambit/graph 1.0.636 → 1.0.637
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/graph-cmd.d.ts
CHANGED
@@ -8,6 +8,7 @@ export type GraphOpt = {
|
|
8
8
|
png?: boolean;
|
9
9
|
json?: boolean;
|
10
10
|
includeLocalOnly?: boolean;
|
11
|
+
includeDependencies?: boolean;
|
11
12
|
};
|
12
13
|
export declare class GraphCmd implements Command {
|
13
14
|
private componentAspect;
|
@@ -21,7 +22,7 @@ export declare class GraphCmd implements Command {
|
|
21
22
|
remoteOp: boolean;
|
22
23
|
constructor(componentAspect: ComponentMain, graph: GraphMain);
|
23
24
|
report([id]: [string], graphOpts: GraphOpt): Promise<string>;
|
24
|
-
json([id]: [string],
|
25
|
+
json([id]: [string], graphOpts: GraphOpt): Promise<any>;
|
25
26
|
private getWorkspaceIfExist;
|
26
27
|
private generateGraphFromRemote;
|
27
28
|
}
|
package/dist/graph-cmd.js
CHANGED
@@ -40,6 +40,8 @@ function _scope() {
|
|
40
40
|
return data;
|
41
41
|
}
|
42
42
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
43
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
44
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
43
45
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
44
46
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
45
47
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
@@ -52,14 +54,16 @@ class GraphCmd {
|
|
52
54
|
_defineProperty(this, "extendedDescription", void 0);
|
53
55
|
_defineProperty(this, "group", 'info-analysis');
|
54
56
|
_defineProperty(this, "alias", '');
|
55
|
-
_defineProperty(this, "options", [['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'], ['', 'layout <name>', 'GraphVis layout. default to "dot". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]'], ['', 'png', 'save the graph as a png file instead of svg. requires "graphviz" to be installed'], ['', 'cycles', 'generate a graph of cycles only'], ['', 'include-local-only', 'include only the components in the workspace (or local scope)'], ['j', 'json', 'json format']]);
|
57
|
+
_defineProperty(this, "options", [['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'], ['', 'layout <name>', 'GraphVis layout. default to "dot". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]'], ['', 'png', 'save the graph as a png file instead of svg. requires "graphviz" to be installed'], ['', 'cycles', 'generate a graph of cycles only'], ['', 'include-local-only', 'DEPRECATED: include only the components in the workspace (or local scope). This is now the default behavior.'], ['', 'include-dependencies', 'include all dependencies recursively, not just workspace (or local scope) components'], ['j', 'json', 'json format']]);
|
56
58
|
_defineProperty(this, "remoteOp", true);
|
57
59
|
}
|
58
60
|
async report([id], graphOpts) {
|
59
61
|
const {
|
60
62
|
remote,
|
61
63
|
layout,
|
62
|
-
png
|
64
|
+
png,
|
65
|
+
includeLocalOnly,
|
66
|
+
includeDependencies
|
63
67
|
} = graphOpts;
|
64
68
|
const host = this.componentAspect.getHost();
|
65
69
|
const getVisualGraph = async () => {
|
@@ -71,19 +75,41 @@ class GraphCmd {
|
|
71
75
|
}
|
72
76
|
const compId = id ? await host.resolveComponentId(id) : undefined;
|
73
77
|
const compIds = compId ? [compId] : undefined;
|
74
|
-
|
78
|
+
|
79
|
+
// New logic: local-only is now the default behavior
|
80
|
+
// includeDependencies flag overrides this to show all dependencies
|
81
|
+
const modifiedOpts = _objectSpread(_objectSpread({}, graphOpts), {}, {
|
82
|
+
includeLocalOnly: includeDependencies ? false : includeLocalOnly !== false // true by default unless includeDependencies is used
|
83
|
+
});
|
84
|
+
return this.graph.getVisualGraphIds(compIds, modifiedOpts);
|
75
85
|
};
|
76
86
|
const visualDependencyGraph = await getVisualGraph();
|
77
87
|
const result = await visualDependencyGraph.render(png ? 'png' : 'svg');
|
78
88
|
return _chalk().default.green(`image created at ${result}`);
|
79
89
|
}
|
80
|
-
async json([id], {
|
81
|
-
|
82
|
-
|
90
|
+
async json([id], graphOpts) {
|
91
|
+
const {
|
92
|
+
remote,
|
93
|
+
includeLocalOnly,
|
94
|
+
includeDependencies
|
95
|
+
} = graphOpts;
|
83
96
|
const host = this.componentAspect.getHost();
|
84
97
|
if (!remote) {
|
98
|
+
// For JSON output, we need to manually filter if needed
|
99
|
+
// Since getGraphIds doesn't accept the same options as getVisualGraphIds
|
100
|
+
const shouldIncludeLocalOnly = includeDependencies ? false : includeLocalOnly !== false;
|
85
101
|
const graph = await this.graph.getGraphIds(id ? [await host.resolveComponentId(id)] : undefined);
|
86
|
-
|
102
|
+
let filteredGraph = graph;
|
103
|
+
if (shouldIncludeLocalOnly) {
|
104
|
+
// Filter to only include local components
|
105
|
+
const list = await host.listIds();
|
106
|
+
const listStr = list.map(compId => compId.toString());
|
107
|
+
filteredGraph = graph.successorsSubgraph(listStr, {
|
108
|
+
nodeFilter: node => listStr.includes(node.id),
|
109
|
+
edgeFilter: edge => listStr.includes(edge.targetId) && listStr.includes(edge.sourceId)
|
110
|
+
});
|
111
|
+
}
|
112
|
+
const jsonGraph = filteredGraph.toJson();
|
87
113
|
if (jsonGraph.nodes) {
|
88
114
|
jsonGraph.nodes = jsonGraph.nodes.map(node => node.id);
|
89
115
|
}
|
package/dist/graph-cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_graphlib","_componentId","_legacy","_scope","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphCmd","constructor","componentAspect","graph","report","id","graphOpts","remote","layout","png","host","getHost","getVisualGraph","config","generateGraphFromRemote","VisualDependencyGraph","loadFromGraphlib","compId","resolveComponentId","undefined","compIds","getVisualGraphIds","visualDependencyGraph","result","render","chalk","green","json","getGraphIds","jsonGraph","toJson","nodes","map","node","GraphLib","write","getWorkspaceIfExist","workspace","ComponentID","fromString","scopeName","scope","remoteScope","getRemoteByName","consumer","componentDepGraph","Error","exports"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { GraphConfig, VisualDependencyGraph } from '@teambit/legacy.dependency-graph';\nimport { getRemoteByName } from '@teambit/scope.remotes';\nimport { ComponentMain } from '@teambit/component';\nimport type { Workspace } from '@teambit/workspace';\nimport { GraphMain } from './graph.main.runtime';\n\nexport type GraphOpt = {\n remote?: string;\n layout?: string;\n cycles?: boolean;\n png?: boolean;\n json?: boolean;\n includeLocalOnly?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = \"generate an SVG image file with the components' dependencies graph\";\n extendedDescription: 'black arrow is a runtime dependency. red arrow is either dev or peer';\n group = 'info-analysis';\n alias = '';\n options = [\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['', 'png', 'save the graph as a png file instead of svg. requires \"graphviz\" to be installed'],\n ['', 'cycles', 'generate a graph of cycles only'],\n ['', 'include-local-only', 'include only the components in the workspace (or local scope)'],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n constructor(\n private componentAspect: ComponentMain,\n private graph: GraphMain\n ) {}\n\n async report([id]: [string], graphOpts: GraphOpt): Promise<string> {\n const { remote, layout, png } = graphOpts;\n const host = this.componentAspect.getHost();\n\n const getVisualGraph = async (): Promise<VisualDependencyGraph> => {\n if (remote) {\n const config: GraphConfig = {};\n if (layout) config.layout = layout;\n const graph = await this.generateGraphFromRemote(remote, id);\n return VisualDependencyGraph.loadFromGraphlib(graph, config);\n }\n const compId = id ? await host.resolveComponentId(id) : undefined;\n const compIds = compId ? [compId] : undefined;\n return this.graph.getVisualGraphIds(compIds, graphOpts);\n };\n\n const visualDependencyGraph = await getVisualGraph();\n const result = await visualDependencyGraph.render(png ? 'png' : 'svg');\n\n return chalk.green(`image created at ${result}`);\n }\n\n async json([id]: [string], { remote }: GraphOpt) {\n const host = this.componentAspect.getHost();\n if (!remote) {\n const graph = await this.graph.getGraphIds(id ? [await host.resolveComponentId(id)] : undefined);\n const jsonGraph = graph.toJson();\n if (jsonGraph.nodes) {\n jsonGraph.nodes = jsonGraph.nodes.map((node) => node.id);\n }\n return jsonGraph;\n }\n const graph = await this.generateGraphFromRemote(remote!, id);\n return GraphLib.json.write(graph);\n }\n\n private getWorkspaceIfExist(): Workspace | undefined {\n try {\n return this.componentAspect.getHost('teambit.workspace/workspace') as Workspace | undefined;\n } catch {\n return undefined;\n }\n }\n\n private async generateGraphFromRemote(remote: string | boolean, id?: string): Promise<GraphLib.Graph> {\n const workspace = this.getWorkspaceIfExist();\n const compId = id ? ComponentID.fromString(id) : undefined;\n if (compId) {\n const scopeName: string = typeof remote === 'string' ? remote : compId.scope;\n const remoteScope = await getRemoteByName(scopeName, workspace?.consumer);\n const componentDepGraph = await remoteScope.graph(compId);\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, workspace?.consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyD,SAAAC,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAA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AMJ,WAAW,GAAG,MAAM,IAAAC,wBAAe,EAACpC,MAAM,EAAE8B,SAAS,EAAEO,QAAQ,CAAC;IACtE,MAAMC,iBAAiB,GAAG,MAAMH,WAAW,CAACvC,KAAK,CAAC,CAAC;IACnD,OAAO0C,iBAAiB,CAAC1C,KAAK;EAChC;AACF;AAAC4C,OAAA,CAAA/C,QAAA,GAAAA,QAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_graphlib","_componentId","_legacy","_scope","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphCmd","constructor","componentAspect","graph","report","id","graphOpts","remote","layout","png","includeLocalOnly","includeDependencies","host","getHost","getVisualGraph","config","generateGraphFromRemote","VisualDependencyGraph","loadFromGraphlib","compId","resolveComponentId","undefined","compIds","modifiedOpts","getVisualGraphIds","visualDependencyGraph","result","render","chalk","green","json","shouldIncludeLocalOnly","getGraphIds","filteredGraph","list","listIds","listStr","map","toString","successorsSubgraph","nodeFilter","node","includes","edgeFilter","edge","targetId","sourceId","jsonGraph","toJson","nodes","GraphLib","write","getWorkspaceIfExist","workspace","ComponentID","fromString","scopeName","scope","remoteScope","getRemoteByName","consumer","componentDepGraph","Error","exports"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { GraphConfig, VisualDependencyGraph } from '@teambit/legacy.dependency-graph';\nimport { getRemoteByName } from '@teambit/scope.remotes';\nimport { ComponentMain } from '@teambit/component';\nimport type { Workspace } from '@teambit/workspace';\nimport { GraphMain } from './graph.main.runtime';\n\nexport type GraphOpt = {\n remote?: string;\n layout?: string;\n cycles?: boolean;\n png?: boolean;\n json?: boolean;\n includeLocalOnly?: boolean;\n includeDependencies?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = \"generate an SVG image file with the components' dependencies graph\";\n extendedDescription: 'black arrow is a runtime dependency. red arrow is either dev or peer';\n group = 'info-analysis';\n alias = '';\n options = [\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['', 'png', 'save the graph as a png file instead of svg. requires \"graphviz\" to be installed'],\n ['', 'cycles', 'generate a graph of cycles only'],\n [\n '',\n 'include-local-only',\n 'DEPRECATED: include only the components in the workspace (or local scope). This is now the default behavior.',\n ],\n [\n '',\n 'include-dependencies',\n 'include all dependencies recursively, not just workspace (or local scope) components',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n constructor(\n private componentAspect: ComponentMain,\n private graph: GraphMain\n ) {}\n\n async report([id]: [string], graphOpts: GraphOpt): Promise<string> {\n const { remote, layout, png, includeLocalOnly, includeDependencies } = graphOpts;\n const host = this.componentAspect.getHost();\n\n const getVisualGraph = async (): Promise<VisualDependencyGraph> => {\n if (remote) {\n const config: GraphConfig = {};\n if (layout) config.layout = layout;\n const graph = await this.generateGraphFromRemote(remote, id);\n return VisualDependencyGraph.loadFromGraphlib(graph, config);\n }\n const compId = id ? await host.resolveComponentId(id) : undefined;\n const compIds = compId ? [compId] : undefined;\n\n // New logic: local-only is now the default behavior\n // includeDependencies flag overrides this to show all dependencies\n const modifiedOpts = {\n ...graphOpts,\n includeLocalOnly: includeDependencies ? false : includeLocalOnly !== false, // true by default unless includeDependencies is used\n };\n\n return this.graph.getVisualGraphIds(compIds, modifiedOpts);\n };\n\n const visualDependencyGraph = await getVisualGraph();\n const result = await visualDependencyGraph.render(png ? 'png' : 'svg');\n\n return chalk.green(`image created at ${result}`);\n }\n\n async json([id]: [string], graphOpts: GraphOpt) {\n const { remote, includeLocalOnly, includeDependencies } = graphOpts;\n const host = this.componentAspect.getHost();\n if (!remote) {\n // For JSON output, we need to manually filter if needed\n // Since getGraphIds doesn't accept the same options as getVisualGraphIds\n const shouldIncludeLocalOnly = includeDependencies ? false : includeLocalOnly !== false;\n\n const graph = await this.graph.getGraphIds(id ? [await host.resolveComponentId(id)] : undefined);\n\n let filteredGraph = graph;\n if (shouldIncludeLocalOnly) {\n // Filter to only include local components\n const list = await host.listIds();\n const listStr = list.map((compId) => compId.toString());\n filteredGraph = graph.successorsSubgraph(listStr, {\n nodeFilter: (node) => listStr.includes(node.id),\n edgeFilter: (edge) => listStr.includes(edge.targetId) && listStr.includes(edge.sourceId),\n });\n }\n\n const jsonGraph = filteredGraph.toJson();\n if (jsonGraph.nodes) {\n jsonGraph.nodes = jsonGraph.nodes.map((node) => node.id);\n }\n return jsonGraph;\n }\n const graph = await this.generateGraphFromRemote(remote!, id);\n return GraphLib.json.write(graph);\n }\n\n private getWorkspaceIfExist(): Workspace | undefined {\n try {\n return this.componentAspect.getHost('teambit.workspace/workspace') as Workspace | undefined;\n } catch {\n return undefined;\n }\n }\n\n private async generateGraphFromRemote(remote: string | boolean, id?: string): Promise<GraphLib.Graph> {\n const workspace = this.getWorkspaceIfExist();\n const compId = id ? ComponentID.fromString(id) : undefined;\n if (compId) {\n const scopeName: string = typeof remote === 'string' ? remote : compId.scope;\n const remoteScope = await getRemoteByName(scopeName, workspace?.consumer);\n const componentDepGraph = await remoteScope.graph(compId);\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, workspace?.consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,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qC,SAAiB,GAAG,OAAOjD,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGY,MAAM,CAACsC,KAAK;MAC5E,MAAMC,WAAW,GAAG,MAAM,IAAAC,wBAAe,EAACH,SAAS,EAAEH,SAAS,EAAEO,QAAQ,CAAC;MACzE,MAAMC,iBAAiB,GAAG,MAAMH,WAAW,CAACvD,KAAK,CAACgB,MAAM,CAAC;MACzD,OAAO0C,iBAAiB,CAAC1D,KAAK;IAChC;IACA,IAAI,OAAOI,MAAM,KAAK,QAAQ,EAAE;MAC9B,MAAM,IAAIuD,KAAK,CAAC,iDAAiD,CAAC;IACpE;IACA,MAAMJ,WAAW,GAAG,MAAM,IAAAC,wBAAe,EAACpD,MAAM,EAAE8C,SAAS,EAAEO,QAAQ,CAAC;IACtE,MAAMC,iBAAiB,GAAG,MAAMH,WAAW,CAACvD,KAAK,CAAC,CAAC;IACnD,OAAO0D,iBAAiB,CAAC1D,KAAK;EAChC;AACF;AAAC4D,OAAA,CAAA/D,QAAA,GAAAA,QAAA","ignoreList":[]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.637/dist/graph.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.637/dist/graph.docs.md';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/graph",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.637",
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/graph",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.component",
|
8
8
|
"name": "graph",
|
9
|
-
"version": "1.0.
|
9
|
+
"version": "1.0.637"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"graphlib": "2.1.8",
|
@@ -26,23 +26,23 @@
|
|
26
26
|
"@teambit/component.ui.deprecation-icon": "0.0.509",
|
27
27
|
"@teambit/design.ui.styles.ellipsis": "0.0.357",
|
28
28
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
29
|
-
"@teambit/design.ui.round-loader": "0.0.355",
|
30
|
-
"@teambit/component.ui.component-compare.status-resolver": "0.0.9",
|
31
29
|
"@teambit/evangelist.input.checkbox.label": "1.1.0",
|
32
30
|
"@teambit/design.skeletons.base-skeleton": "0.0.2",
|
33
31
|
"@teambit/design.ui.pages.not-found": "0.0.371",
|
34
32
|
"@teambit/design.ui.pages.server-error": "0.0.368",
|
35
33
|
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.505",
|
34
|
+
"@teambit/design.ui.round-loader": "0.0.355",
|
35
|
+
"@teambit/component.ui.component-compare.status-resolver": "0.0.9",
|
36
36
|
"@teambit/legacy.dependency-graph": "0.0.55",
|
37
|
-
"@teambit/component": "1.0.
|
38
|
-
"@teambit/cli": "0.0.
|
37
|
+
"@teambit/component": "1.0.637",
|
38
|
+
"@teambit/cli": "0.0.1214",
|
39
39
|
"@teambit/scope.remotes": "0.0.52",
|
40
|
-
"@teambit/workspace": "1.0.
|
40
|
+
"@teambit/workspace": "1.0.637",
|
41
41
|
"@teambit/component.ui.component-compare.models.component-compare-props": "0.0.119",
|
42
|
-
"@teambit/graphql": "1.0.
|
43
|
-
"@teambit/logger": "0.0.
|
44
|
-
"@teambit/component-compare": "1.0.
|
45
|
-
"@teambit/ui": "1.0.
|
42
|
+
"@teambit/graphql": "1.0.637",
|
43
|
+
"@teambit/logger": "0.0.1307",
|
44
|
+
"@teambit/component-compare": "1.0.637",
|
45
|
+
"@teambit/ui": "1.0.637",
|
46
46
|
"@teambit/component.modules.component-url": "0.0.176",
|
47
47
|
"@teambit/envs.ui.env-icon": "0.0.506",
|
48
48
|
"@teambit/component.ui.component-compare.context": "0.0.122"
|