@teambit/graph 0.0.1158 → 0.0.1159
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 -10
- package/dist/component-graph/component-graph.js.map +1 -1
- package/dist/component-id-graph.js +4 -12
- package/dist/component-id-graph.js.map +1 -1
- package/dist/duplicate-dependency.js +5 -10
- package/dist/duplicate-dependency.js.map +1 -1
- package/dist/graph-builder.js +0 -1
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-cmd.js +10 -16
- package/dist/graph-cmd.js.map +1 -1
- package/dist/graph.compare.section.js +10 -14
- package/dist/graph.compare.section.js.map +1 -1
- package/dist/graph.composition.js +1 -1
- package/dist/graph.composition.js.map +1 -1
- package/dist/graph.graphql.js +1 -3
- package/dist/graph.graphql.js.map +1 -1
- package/dist/graph.main.runtime.js +6 -13
- package/dist/graph.main.runtime.js.map +1 -1
- package/dist/graph.ui.runtime.js +7 -14
- package/dist/graph.ui.runtime.js.map +1 -1
- package/dist/model/dependency/dependency.js +4 -9
- package/dist/model/dependency/dependency.js.map +1 -1
- package/dist/object-list-to-graph.js +0 -2
- package/dist/object-list-to-graph.js.map +1 -1
- package/dist/{preview-1694575035715.js → preview-1694624356552.js} +2 -2
- package/dist/ui/component-node/component-node.js +10 -22
- package/dist/ui/component-node/component-node.js.map +1 -1
- package/dist/ui/component-node/index.js +1 -1
- package/dist/ui/component-node/index.js.map +1 -1
- package/dist/ui/component-node/variants.js +1 -1
- package/dist/ui/component-node/variants.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-node-model.js +7 -13
- package/dist/ui/dependencies-compare/compare-node-model.js.map +1 -1
- package/dist/ui/dependencies-compare/dependencies-compare.js +5 -6
- package/dist/ui/dependencies-compare/dependencies-compare.js.map +1 -1
- package/dist/ui/dependencies-compare/dependency-compare-node.js +7 -17
- package/dist/ui/dependencies-compare/dependency-compare-node.js.map +1 -1
- package/dist/ui/dependencies-compare/diff-graph.js +4 -11
- package/dist/ui/dependencies-compare/diff-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-elements.js +0 -1
- package/dist/ui/dependencies-graph/calc-elements.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-layout.js +0 -1
- package/dist/ui/dependencies-graph/calc-layout.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js.map +1 -1
- package/dist/ui/dependencies-graph/dependencies-graph.js +7 -17
- package/dist/ui/dependencies-graph/dependencies-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/index.js +1 -1
- package/dist/ui/dependencies-graph/index.js.map +1 -1
- package/dist/ui/graph-page/graph-filters.js +5 -9
- package/dist/ui/graph-page/graph-filters.js.map +1 -1
- package/dist/ui/graph-page/graph-page.js +1 -2
- package/dist/ui/graph-page/graph-page.js.map +1 -1
- package/dist/ui/graph-page/index.js +1 -1
- package/dist/ui/graph-page/index.js.map +1 -1
- package/dist/ui/graph.section.js +7 -11
- package/dist/ui/graph.section.js.map +1 -1
- package/dist/ui/query/edge-model.js +6 -11
- package/dist/ui/query/edge-model.js.map +1 -1
- package/dist/ui/query/node-model.js +5 -10
- package/dist/ui/query/node-model.js.map +1 -1
- package/package.json +18 -20
@@ -1,18 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
8
6
|
exports.DEPENDENCIES_TYPES = exports.ComponentGraph = void 0;
|
9
|
-
function _defineProperty2() {
|
10
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
_defineProperty2 = function () {
|
12
|
-
return data;
|
13
|
-
};
|
14
|
-
return data;
|
15
|
-
}
|
16
7
|
function _graph() {
|
17
8
|
const data = require("@teambit/graph.cleargraph");
|
18
9
|
_graph = function () {
|
@@ -27,13 +18,16 @@ function _duplicateDependency() {
|
|
27
18
|
};
|
28
19
|
return data;
|
29
20
|
}
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
30
24
|
const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];
|
31
25
|
exports.DEPENDENCIES_TYPES = DEPENDENCIES_TYPES;
|
32
26
|
class ComponentGraph extends _graph().Graph {
|
33
27
|
// component IDs that started the graph. (if from workspace, the .bitmap ids normally)
|
34
28
|
constructor(nodes = [], edges = []) {
|
35
29
|
super(nodes, edges);
|
36
|
-
(
|
30
|
+
_defineProperty(this, "seederIds", []);
|
37
31
|
}
|
38
32
|
create(nodes = [], edges = []) {
|
39
33
|
return new ComponentGraph(nodes, edges);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graph","data","require","_duplicateDependency","DEPENDENCIES_TYPES","exports","ComponentGraph","Graph","constructor","nodes","edges","_defineProperty2","default","create","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","map","id","toString","cyclesWithSeeders","filter","cycle","some","cycleIdStr","includes","findDuplicateDependencies","versionMap","calculateVersionMap","seederIdsNoVersions","toStringWithoutVersion","duplicateDependencies","Map","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","forEach","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","push","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","attr","type","node","comp","compKey","_legacy","has","value","get","_this$node","Object","prototype","hasOwnProperty","call","currentComp","latestComp","head","Date","timestamp"],"sources":["component-graph.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\n\nimport { Dependency } from '../model/dependency';\nimport { DuplicateDependency, VersionSubgraph } from '../duplicate-dependency';\n\nexport const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];\n\ntype ComponentNode = Node<Component>;\ntype DependencyEdge = Edge<Dependency>;\n\nexport class ComponentGraph extends Graph<Component, Dependency> {\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n protected create(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentGraph(nodes, edges) as this;\n }\n\n /**\n * @deprecate use graph.getGraphIds().findCycles()\n */\n findCycles(graph?: this): string[][] {\n const cycles = super.findCycles(graph);\n if (!this.shouldLimitToSeedersOnly()) {\n return cycles;\n }\n const seederIdsStr = this.seederIds.map((id) => id.toString());\n const cyclesWithSeeders = cycles.filter((cycle) => {\n return cycle.some((cycleIdStr) => seederIdsStr.includes(cycleIdStr));\n });\n return cyclesWithSeeders;\n }\n\n findDuplicateDependencies(): Map<string, DuplicateDependency> {\n const versionMap = this.calculateVersionMap();\n const seederIdsNoVersions = this.seederIds.map((id) => id.toStringWithoutVersion());\n const duplicateDependencies: Map<string, DuplicateDependency> = new Map();\n for (const [compFullName, versions] of versionMap) {\n if (versions.allVersionNodes.length > 1) {\n const versionSubgraphs: VersionSubgraph[] = [];\n const notLatestVersions = versions.allVersionNodes.filter((version) => version !== versions.latestVersionNode);\n notLatestVersions.forEach((version) => {\n const predecessors = this.predecessorsSubgraph(version);\n const immediatePredecessors = this.predecessors(version).map((predecessor) => predecessor.id);\n const subGraph = this.buildFromCleargraph(predecessors);\n const versionSubgraph: VersionSubgraph = {\n versionId: version,\n subGraph,\n // TODO: validate that this is working correctly\n immediateDependents: immediatePredecessors,\n };\n versionSubgraphs.push(versionSubgraph);\n });\n const isSeeder = seederIdsNoVersions.includes(compFullName);\n const shouldDisplayDueToBeingSeeder = !this.shouldLimitToSeedersOnly() || isSeeder;\n if (shouldDisplayDueToBeingSeeder && versionSubgraphs.length > 0) {\n const duplicateDep = new DuplicateDependency(versions.latestVersionNode, versionSubgraphs);\n duplicateDependencies.set(compFullName, duplicateDep);\n }\n }\n }\n return duplicateDependencies;\n }\n\n buildFromCleargraph(graph: Graph<Component, Dependency>): ComponentGraph {\n return this.create(graph.nodes, graph.edges);\n }\n\n runtimeOnly(componentIds: string[]) {\n return this.successorsSubgraph(componentIds, {\n edgeFilter: (edge: DependencyEdge) => edge.attr.type === 'runtime',\n });\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n\n private calculateVersionMap(): Map<string, { allVersionNodes: string[]; latestVersionNode: string }> {\n const versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }> = new Map();\n for (const node of this.nodes) {\n const comp = node.attr;\n const compKey = node.id;\n const compFullName = comp.id._legacy.toStringWithoutVersion();\n if (!versionMap.has(compFullName)) {\n versionMap.set(compFullName, {\n allVersionNodes: [compKey],\n latestVersionNode: compKey,\n });\n } else {\n const value = versionMap.get(compFullName);\n if (value) {\n if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {\n value.allVersionNodes.push(compKey);\n }\n const currentComp = comp;\n const latestComp = this.node(value.latestVersionNode)?.attr;\n // @todo: this check won't work when the component doesn't have head.\n // it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head\n // Version object, and as a result, the `Component.head` is empty.\n // for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only\n // checks the components on the workspace.\n if (\n currentComp.head &&\n latestComp?.head &&\n new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)\n ) {\n value.latestVersionNode = compKey;\n }\n }\n }\n }\n return versionMap;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMG,kBAAkB,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC;AAACC,OAAA,CAAAD,kBAAA,GAAAA,kBAAA;AAK/D,MAAME,cAAc,SAASC,cAAK,CAAwB;EAChC;EAC/BC,WAAWA,CAACC,KAAsB,GAAG,EAAE,EAAEC,KAAuB,GAAG,EAAE,EAAE;IACrE,KAAK,CAACD,KAAK,EAAEC,KAAK,CAAC;IAAC,IAAAC,gBAAA,GAAAC,OAAA,qBAFK,EAAE;EAG7B;EAEUC,MAAMA,CAACJ,KAAsB,GAAG,EAAE,EAAEC,KAAuB,GAAG,EAAE,EAAQ;IAChF,OAAO,IAAIJ,cAAc,CAACG,KAAK,EAAEC,KAAK,CAAC;EACzC;;EAEA;AACF;AACA;EACEI,UAAUA,CAACC,KAAY,EAAc;IACnC,MAAMC,MAAM,GAAG,KAAK,CAACF,UAAU,CAACC,KAAK,CAAC;IACtC,IAAI,CAAC,IAAI,CAACE,wBAAwB,CAAC,CAAC,EAAE;MACpC,OAAOD,MAAM;IACf;IACA,MAAME,YAAY,GAAG,IAAI,CAACC,SAAS,CAACC,GAAG,CAAEC,EAAE,IAAKA,EAAE,CAACC,QAAQ,CAAC,CAAC,CAAC;IAC9D,MAAMC,iBAAiB,GAAGP,MAAM,CAACQ,MAA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CAAC+B,OAAO,CAAC;UAC1B1B,iBAAiB,EAAE0B;QACrB,CAAC,CAAC;MACJ,CAAC,MAAM;QACL,MAAMG,KAAK,GAAG1C,UAAU,CAAC2C,GAAG,CAACrC,YAAY,CAAC;QAC1C,IAAIoC,KAAK,EAAE;UAAA,IAAAE,UAAA;UACT,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACN,KAAK,EAAE,iBAAiB,CAAC,EAAE;YAClEA,KAAK,CAAClC,eAAe,CAACgB,IAAI,CAACe,OAAO,CAAC;UACrC;UACA,MAAMU,WAAW,GAAGX,IAAI;UACxB,MAAMY,UAAU,IAAAN,UAAA,GAAG,IAAI,CAACP,IAAI,CAACK,KAAK,CAAC7B,iBAAiB,CAAC,cAAA+B,UAAA,uBAAlCA,UAAA,CAAoCT,IAAI;UAC3D;UACA;UACA;UACA;UACA;UACA,IACEc,WAAW,CAACE,IAAI,IAChBD,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEC,IAAI,IAChB,IAAIC,IAAI,CAACH,WAAW,CAACE,IAAI,CAACE,SAAS,CAAC,GAAG,IAAID,IAAI,CAACF,UAAU,CAACC,IAAI,CAACE,SAAS,CAAC,EAC1E;YACAX,KAAK,CAAC7B,iBAAiB,GAAG0B,OAAO;UACnC;QACF;MACF;IACF;IACA,OAAOvC,UAAU;EACnB;AACF;AAACzB,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
|
1
|
+
{"version":3,"names":["_graph","data","require","_duplicateDependency","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","DEPENDENCIES_TYPES","exports","ComponentGraph","Graph","constructor","nodes","edges","create","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","map","id","toString","cyclesWithSeeders","filter","cycle","some","cycleIdStr","includes","findDuplicateDependencies","versionMap","calculateVersionMap","seederIdsNoVersions","toStringWithoutVersion","duplicateDependencies","Map","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","forEach","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","push","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","attr","type","node","comp","compKey","_legacy","has","get","_this$node","prototype","hasOwnProperty","currentComp","latestComp","head","Date","timestamp"],"sources":["component-graph.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\n\nimport { Dependency } from '../model/dependency';\nimport { DuplicateDependency, VersionSubgraph } from '../duplicate-dependency';\n\nexport const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];\n\ntype ComponentNode = Node<Component>;\ntype DependencyEdge = Edge<Dependency>;\n\nexport class ComponentGraph extends Graph<Component, Dependency> {\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n protected create(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentGraph(nodes, edges) as this;\n }\n\n /**\n * @deprecate use graph.getGraphIds().findCycles()\n */\n findCycles(graph?: this): string[][] {\n const cycles = super.findCycles(graph);\n if (!this.shouldLimitToSeedersOnly()) {\n return cycles;\n }\n const seederIdsStr = this.seederIds.map((id) => id.toString());\n const cyclesWithSeeders = cycles.filter((cycle) => {\n return cycle.some((cycleIdStr) => seederIdsStr.includes(cycleIdStr));\n });\n return cyclesWithSeeders;\n }\n\n findDuplicateDependencies(): Map<string, DuplicateDependency> {\n const versionMap = this.calculateVersionMap();\n const seederIdsNoVersions = this.seederIds.map((id) => id.toStringWithoutVersion());\n const duplicateDependencies: Map<string, DuplicateDependency> = new Map();\n for (const [compFullName, versions] of versionMap) {\n if (versions.allVersionNodes.length > 1) {\n const versionSubgraphs: VersionSubgraph[] = [];\n const notLatestVersions = versions.allVersionNodes.filter((version) => version !== versions.latestVersionNode);\n notLatestVersions.forEach((version) => {\n const predecessors = this.predecessorsSubgraph(version);\n const immediatePredecessors = this.predecessors(version).map((predecessor) => predecessor.id);\n const subGraph = this.buildFromCleargraph(predecessors);\n const versionSubgraph: VersionSubgraph = {\n versionId: version,\n subGraph,\n // TODO: validate that this is working correctly\n immediateDependents: immediatePredecessors,\n };\n versionSubgraphs.push(versionSubgraph);\n });\n const isSeeder = seederIdsNoVersions.includes(compFullName);\n const shouldDisplayDueToBeingSeeder = !this.shouldLimitToSeedersOnly() || isSeeder;\n if (shouldDisplayDueToBeingSeeder && versionSubgraphs.length > 0) {\n const duplicateDep = new DuplicateDependency(versions.latestVersionNode, versionSubgraphs);\n duplicateDependencies.set(compFullName, duplicateDep);\n }\n }\n }\n return duplicateDependencies;\n }\n\n buildFromCleargraph(graph: Graph<Component, Dependency>): ComponentGraph {\n return this.create(graph.nodes, graph.edges);\n }\n\n runtimeOnly(componentIds: string[]) {\n return this.successorsSubgraph(componentIds, {\n edgeFilter: (edge: DependencyEdge) => edge.attr.type === 'runtime',\n });\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n\n private calculateVersionMap(): Map<string, { allVersionNodes: string[]; latestVersionNode: string }> {\n const versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }> = new Map();\n for (const node of this.nodes) {\n const comp = node.attr;\n const compKey = node.id;\n const compFullName = comp.id._legacy.toStringWithoutVersion();\n if (!versionMap.has(compFullName)) {\n versionMap.set(compFullName, {\n allVersionNodes: [compKey],\n latestVersionNode: compKey,\n });\n } else {\n const value = versionMap.get(compFullName);\n if (value) {\n if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {\n value.allVersionNodes.push(compKey);\n }\n const currentComp = comp;\n const latestComp = this.node(value.latestVersionNode)?.attr;\n // @todo: this check won't work when the component doesn't have head.\n // it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head\n // Version object, and as a result, the `Component.head` is empty.\n // for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only\n // checks the components on the workspace.\n if (\n currentComp.head &&\n latestComp?.head &&\n new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)\n ) {\n value.latestVersionNode = compKey;\n }\n }\n }\n }\n return versionMap;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+E,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,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AI;UACxB,MAAMS,UAAU,IAAAJ,UAAA,GAAG,IAAI,CAACN,IAAI,CAACjF,KAAK,CAACyD,iBAAiB,CAAC,cAAA8B,UAAA,uBAAlCA,UAAA,CAAoCR,IAAI;UAC3D;UACA;UACA;UACA;UACA;UACA,IACEW,WAAW,CAACE,IAAI,IAChBD,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEC,IAAI,IAChB,IAAIC,IAAI,CAACH,WAAW,CAACE,IAAI,CAACE,SAAS,CAAC,GAAG,IAAID,IAAI,CAACF,UAAU,CAACC,IAAI,CAACE,SAAS,CAAC,EAC1E;YACA9F,KAAK,CAACyD,iBAAiB,GAAG0B,OAAO;UACnC;QACF;MACF;IACF;IACA,OAAOvC,UAAU;EACnB;AACF;AAACvB,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
|
@@ -1,20 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
require("core-js/modules/es.array.flat.js");
|
5
|
-
require("core-js/modules/es.array.unscopables.flat.js");
|
6
|
-
require("core-js/modules/es.regexp.exec.js");
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
8
4
|
value: true
|
9
5
|
});
|
10
6
|
exports.ComponentIdGraph = void 0;
|
11
|
-
function _defineProperty2() {
|
12
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
_defineProperty2 = function () {
|
14
|
-
return data;
|
15
|
-
};
|
16
|
-
return data;
|
17
|
-
}
|
18
7
|
function _graph() {
|
19
8
|
const data = require("@teambit/graph.cleargraph");
|
20
9
|
_graph = function () {
|
@@ -29,11 +18,14 @@ function _lodash() {
|
|
29
18
|
};
|
30
19
|
return data;
|
31
20
|
}
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
32
24
|
class ComponentIdGraph extends _graph().Graph {
|
33
25
|
// component IDs that started the graph. (if from workspace, the .bitmap ids normally)
|
34
26
|
constructor(nodes = [], edges = []) {
|
35
27
|
super(nodes, edges);
|
36
|
-
(
|
28
|
+
_defineProperty(this, "seederIds", []);
|
37
29
|
}
|
38
30
|
create(nodes = [], edges = []) {
|
39
31
|
return new ComponentIdGraph(nodes, edges);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graph","data","require","_lodash","
|
1
|
+
{"version":3,"names":["_graph","data","require","_lodash","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ComponentIdGraph","Graph","constructor","nodes","edges","create","findIdsFromSourcesToTargets","sources","targets","removeVerFromIdStr","idStr","split","sourcesStr","map","s","toStringWithoutVersion","targetsStr","t","allFlattened","source","successors","toString","flat","allFlattenedIds","uniq","f","id","results","forEach","idWithNoVer","includes","allSuccessors","allSuccessorsWithNoVersion","find","push","componentIds","getNodes","n","attr","findCycles","graph","includeDeps","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","cyclesWithSeeders","filter","cycle","some","cycleIdStr","buildFromCleargraph","runtimeOnly","successorsSubgraph","edgeFilter","edge","length","exports"],"sources":["component-id-graph.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { uniq } from 'lodash';\n\nexport type DepEdgeType = 'prod' | 'dev' | 'ext';\n\ntype ComponentIdNode = Node<ComponentID>;\ntype DependencyEdge = Edge<DepEdgeType>;\nexport type CompIdGraph = Graph<ComponentID, DepEdgeType>;\n\nexport class ComponentIdGraph extends Graph<ComponentID, DepEdgeType> {\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n protected create(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentIdGraph(nodes, edges) as this;\n }\n\n /**\n * check all the routes from the sources to targets and return the components found during this traversal.\n * e.g.\n * A -> B -> C -> N.\n * A -> E -> N.\n * B -> F -> G.\n * given source: A, targets: N. The results will be: B, C, E\n */\n findIdsFromSourcesToTargets(sources: ComponentID[], targets: ComponentID[]): ComponentID[] {\n const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0];\n const sourcesStr = sources.map((s) => s.toStringWithoutVersion());\n const targetsStr = targets.map((t) => t.toStringWithoutVersion());\n const allFlattened = sources.map((source) => this.successors(source.toString())).flat();\n const allFlattenedIds = uniq(allFlattened.map((f) => f.id));\n const results: string[] = [];\n allFlattenedIds.forEach((id) => {\n const idWithNoVer = removeVerFromIdStr(id);\n if (sourcesStr.includes(idWithNoVer) || targetsStr.includes(idWithNoVer)) return;\n const allSuccessors = this.successors(id);\n const allSuccessorsWithNoVersion = allSuccessors.map((s) => removeVerFromIdStr(s.id));\n if (allSuccessorsWithNoVersion.find((s) => targetsStr.includes(s))) results.push(id);\n });\n const componentIds = this.getNodes(results).map((n) => n.attr);\n\n return componentIds;\n }\n\n /**\n * overrides the super class to eliminate non-seeders components\n */\n findCycles(graph?: this, includeDeps = false): string[][] {\n const cycles = super.findCycles(graph);\n if (!this.shouldLimitToSeedersOnly() || includeDeps) {\n return cycles;\n }\n const seederIdsStr = this.seederIds.map((id) => id.toString());\n const cyclesWithSeeders = cycles.filter((cycle) => {\n return cycle.some((cycleIdStr) => seederIdsStr.includes(cycleIdStr));\n });\n return cyclesWithSeeders;\n }\n\n buildFromCleargraph(graph: Graph<ComponentID, DepEdgeType>): ComponentIdGraph {\n return this.create(graph.nodes, graph.edges);\n }\n\n runtimeOnly(componentIds: string[]) {\n return this.successorsSubgraph(componentIds, {\n edgeFilter: (edge: DependencyEdge) => edge.attr === 'prod',\n });\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,g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WAAWA,CAACjB,YAAsB,EAAE;IAClC,OAAO,IAAI,CAACkB,kBAAkB,CAAClB,YAAY,EAAE;MAC3CmB,UAAU,EAAGC,IAAoB,IAAKA,IAAI,CAACjB,IAAI,KAAK;IACtD,CAAC,CAAC;EACJ;EAEQK,wBAAwBA,CAAA,EAAG;IACjC,OAAO,IAAI,CAACE,SAAS,CAACW,MAAM;EAC9B;AACF;AAACC,OAAA,CAAAzD,gBAAA,GAAAA,gBAAA"}
|
@@ -1,23 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.DuplicateDependency = void 0;
|
8
|
-
function
|
9
|
-
|
10
|
-
|
11
|
-
return data;
|
12
|
-
};
|
13
|
-
return data;
|
14
|
-
}
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
9
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
15
10
|
// eslint-disable-next-line import/no-cycle
|
16
11
|
|
17
12
|
class DuplicateDependency {
|
18
13
|
constructor(latestVersionId, priorVersions) {
|
19
|
-
(
|
20
|
-
(
|
14
|
+
_defineProperty(this, "latestVersionId", void 0);
|
15
|
+
_defineProperty(this, "priorVersions", void 0);
|
21
16
|
this.latestVersionId = latestVersionId;
|
22
17
|
this.priorVersions = priorVersions;
|
23
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DuplicateDependency","constructor","latestVersionId","priorVersions","
|
1
|
+
{"version":3,"names":["DuplicateDependency","constructor","latestVersionId","priorVersions","_defineProperty","exports"],"sources":["duplicate-dependency.ts"],"sourcesContent":["// eslint-disable-next-line import/no-cycle\nimport type { ComponentGraph } from './component-graph';\n\nexport class DuplicateDependency {\n latestVersionId: string;\n priorVersions: VersionSubgraph[];\n\n constructor(latestVersionId: string, priorVersions: VersionSubgraph[]) {\n this.latestVersionId = latestVersionId;\n this.priorVersions = priorVersions;\n }\n}\n\nexport type VersionSubgraph = {\n versionId: string;\n subGraph: ComponentGraph;\n immediateDependents: string[];\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGO,MAAMA,mBAAmB,CAAC;EAI/BC,WAAWA,CAACC,eAAuB,EAAEC,aAAgC,EAAE;IAAAC,eAAA;IAAAA,eAAA;IACrE,IAAI,CAACF,eAAe,GAAGA,eAAe;IACtC,IAAI,CAACC,aAAa,GAAGA,aAAa;EACpC;AACF;AAACE,OAAA,CAAAL,mBAAA,GAAAA,mBAAA"}
|
package/dist/graph-builder.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graph","data","require","_componentGraph","_componentIdGraph","_dependency","GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","graph","componentGraph","toComponentGraph","seederIds","listIds","getGraphIds","componentIdGraph","ComponentIdGraph","nodes","edges","newGraph","ComponentGraph","forEach","node","setNode","edge","edgeObj","attr","Dependency","setEdge","Edge","sourceId","targetId","exports"],"sources":["graph-builder.ts"],"sourcesContent":["import { Component, ComponentFactory, ComponentID, ComponentMain } from '@teambit/component';\nimport { Edge, Graph } from '@teambit/graph.cleargraph';\nimport { ComponentGraph } from './component-graph';\nimport { ComponentIdGraph } from './component-id-graph';\nimport { Dependency } from './model/dependency';\n\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\n constructor(private componentAspect: ComponentMain) {}\n\n /**\n * important - prefer using `getGraphIds()` it's way better in terms of performance.\n */\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const graph = await componentHost.getGraph(ids, false);\n const componentGraph = await this.toComponentGraph(graph);\n componentGraph.seederIds = ids || (await componentHost.listIds());\n return componentGraph;\n }\n\n async getGraphIds(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentIdGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const graph = await componentHost.getGraphIds(ids, false);\n const componentIdGraph = new ComponentIdGraph(graph.nodes, graph.edges);\n componentIdGraph.seederIds = ids || (await componentHost.listIds());\n return componentIdGraph;\n }\n\n private async toComponentGraph(graph: Graph<Component, string>): Promise<ComponentGraph> {\n const newGraph = new ComponentGraph();\n graph.nodes.forEach((node) => {\n newGraph.setNode(node);\n });\n graph.edges.forEach((edge) => {\n const edgeObj =\n edge.attr === 'dependencies' || edge.attr === 'runtime' ? new Dependency('runtime') : new Dependency('dev');\n newGraph.setEdge(new Edge(edge.sourceId, edge.targetId, edgeObj));\n });\n return newGraph;\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["_graph","data","require","_componentGraph","_componentIdGraph","_dependency","GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","graph","componentGraph","toComponentGraph","seederIds","listIds","getGraphIds","componentIdGraph","ComponentIdGraph","nodes","edges","newGraph","ComponentGraph","forEach","node","setNode","edge","edgeObj","attr","Dependency","setEdge","Edge","sourceId","targetId","exports"],"sources":["graph-builder.ts"],"sourcesContent":["import { Component, ComponentFactory, ComponentID, ComponentMain } from '@teambit/component';\nimport { Edge, Graph } from '@teambit/graph.cleargraph';\nimport { ComponentGraph } from './component-graph';\nimport { ComponentIdGraph } from './component-id-graph';\nimport { Dependency } from './model/dependency';\n\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\n constructor(private componentAspect: ComponentMain) {}\n\n /**\n * important - prefer using `getGraphIds()` it's way better in terms of performance.\n */\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const graph = await componentHost.getGraph(ids, false);\n const componentGraph = await this.toComponentGraph(graph);\n componentGraph.seederIds = ids || (await componentHost.listIds());\n return componentGraph;\n }\n\n async getGraphIds(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentIdGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const graph = await componentHost.getGraphIds(ids, false);\n const componentIdGraph = new ComponentIdGraph(graph.nodes, graph.edges);\n componentIdGraph.seederIds = ids || (await componentHost.listIds());\n return componentIdGraph;\n }\n\n private async toComponentGraph(graph: Graph<Component, string>): Promise<ComponentGraph> {\n const newGraph = new ComponentGraph();\n graph.nodes.forEach((node) => {\n newGraph.setNode(node);\n });\n graph.edges.forEach((edge) => {\n const edgeObj =\n edge.attr === 'dependencies' || edge.attr === 'runtime' ? new Dependency('runtime') : new Dependency('dev');\n newGraph.setEdge(new Edge(edge.sourceId, edge.targetId, edgeObj));\n });\n return newGraph;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,gBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,eAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,kBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,iBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EA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AAI,CAAC;IACxB,CAAC,CAAC;IACFb,KAAK,CAACS,KAAK,CAACG,OAAO,CAAEG,IAAI,IAAK;MAC5B,MAAMC,OAAO,GACXD,IAAI,CAACE,IAAI,KAAK,cAAc,IAAIF,IAAI,CAACE,IAAI,KAAK,SAAS,GAAG,KAAIC,wBAAU,EAAC,SAAS,CAAC,GAAG,KAAIA,wBAAU,EAAC,KAAK,CAAC;MAC7GR,QAAQ,CAACS,OAAO,CAAC,KAAIC,aAAI,EAACL,IAAI,CAACM,QAAQ,EAAEN,IAAI,CAACO,QAAQ,EAAEN,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IACF,OAAON,QAAQ;EACjB;AACF;AAACa,OAAA,CAAAhC,YAAA,GAAAA,YAAA"}
|
package/dist/graph-cmd.js
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
5
|
-
require("core-js/modules/es.promise.js");
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
7
4
|
value: true
|
8
5
|
});
|
9
6
|
exports.GraphCmd = void 0;
|
10
|
-
function _defineProperty2() {
|
11
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
12
|
-
_defineProperty2 = function () {
|
13
|
-
return data;
|
14
|
-
};
|
15
|
-
return data;
|
16
|
-
}
|
17
7
|
function _chalk() {
|
18
8
|
const data = _interopRequireDefault(require("chalk"));
|
19
9
|
_chalk = function () {
|
@@ -93,14 +83,18 @@ function _getRemoteByName() {
|
|
93
83
|
}
|
94
84
|
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); }
|
95
85
|
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; }
|
86
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
87
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
88
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
89
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
96
90
|
class GraphCmd {
|
97
91
|
constructor() {
|
98
|
-
(
|
99
|
-
(
|
100
|
-
(
|
101
|
-
(
|
102
|
-
(
|
103
|
-
(
|
92
|
+
_defineProperty(this, "name", 'graph [id]');
|
93
|
+
_defineProperty(this, "description", "generate an image file with the workspace components' dependencies graph");
|
94
|
+
_defineProperty(this, "group", 'discover');
|
95
|
+
_defineProperty(this, "alias", '');
|
96
|
+
_defineProperty(this, "options", [['i', 'image <image>', 'image path and format. 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']]);
|
97
|
+
_defineProperty(this, "remoteOp", true);
|
104
98
|
}
|
105
99
|
async report([id], {
|
106
100
|
remote,
|
package/dist/graph-cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_os","path","_interopRequireWildcard","_graphlib","_legacyBitId","_utils","_vizgraph","_consumer","_scopeGraph","_exceptions","_getRemoteByName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","GraphCmd","constructor","_defineProperty2","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","getBitId","undefined","BitId","parse","getParsedId","bitId","highlightId","join","os","tmpdir","generateRandomStr","result","chalk","green","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write","exports"],"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 = \"generate an image file with the workspace components' dependencies graph\";\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path and format. 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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAK,uBAAA,CAAAH,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA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D,CAAC;MACpE;MACA,MAAMH,WAAW,GAAG,MAAM,IAAAC,0BAAe,EAAC9B,MAAM,EAAEI,QAAQ,CAAC;MAC3D,MAAM2B,iBAAiB,GAAG,MAAMF,WAAW,CAACtB,KAAK,CAAC,CAAC;MACnD,OAAOwB,iBAAiB,CAACxB,KAAK;IAChC;IAEA,MAAM0B,UAAU,GAAG,CAAChC,WAAW;IAC/B;IACA,MAAMiC,cAAc,GAAG,MAAMC,qBAAe,CAACC,uBAAuB,CAAChC,QAAQ,EAAE6B,UAAU,CAAC;IAC1F,MAAMI,eAAe,GAAG,KAAIF,qBAAe,EAACD,cAAc,CAAC;IAC3D,IAAInC,EAAE,EAAE;MACN;MACA,MAAMuC,cAAc,GAAGD,eAAe,CAACE,gCAAgC,CAACrB,KAAK,CAAC;MAC9E,MAAMa,iBAAiB,GAAG,KAAII,qBAAe,EAACG,cAAc,CAAC;MAC7D,OAAOP,iBAAiB,CAACxB,KAAK;IAChC;IACA,OAAO8B,eAAe,CAAC9B,KAAK;EAC9B;EAEA,MAAMiC,IAAIA,CAAC,CAACzC,EAAE,CAAW,EAAE;IAAEC,MAAM;IAAEC;EAAsB,CAAC,EAAE;IAC5D,MAAMG,QAAQ,GAAG,MAAM,IAAAC,+BAAmB,EAAC,CAAC;IAC5C,IAAI,CAACD,QAAQ,IAAI,CAACJ,MAAM,EAAE,MAAM,KAAIM,8BAAgB,EAAC,CAAC;IAEtD,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,aAAa,CAACJ,QAAQ,EAAEL,EAAE,EAAEC,MAAM,EAAEC,WAAW,CAAC;IACzE,OAAOwC,mBAAQ,CAACD,IAAI,CAACE,KAAK,CAACnC,KAAK,CAAC;EACnC;AACF;AAACoC,OAAA,CAAAhD,QAAA,GAAAA,QAAA"}
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_os","path","_interopRequireWildcard","_graphlib","_legacyBitId","_utils","_vizgraph","_consumer","_scopeGraph","_exceptions","_getRemoteByName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_defineProperty","value","_toPropertyKey","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","TypeError","Number","GraphCmd","constructor","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","getBitId","BitId","parse","getParsedId","bitId","highlightId","join","os","tmpdir","generateRandomStr","result","chalk","green","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write","exports"],"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 = \"generate an image file with the workspace components' dependencies graph\";\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path and format. 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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAK,uBAAA,CAAAH,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,SAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,aAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAA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CAAC;IAC5C,IAAI,CAACD,QAAQ,IAAI,CAACJ,MAAM,EAAE,MAAM,KAAIM,8BAAgB,EAAC,CAAC;IAEtD,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,aAAa,CAACJ,QAAQ,EAAEL,EAAE,EAAEC,MAAM,EAAEC,WAAW,CAAC;IACzE,OAAOuC,mBAAQ,CAACD,IAAI,CAACE,KAAK,CAAClC,KAAK,CAAC;EACnC;AACF;AAACmC,OAAA,CAAA9C,QAAA,GAAAA,QAAA"}
|
@@ -1,17 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.GraphCompareSection = void 0;
|
8
|
-
function _defineProperty2() {
|
9
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
|
-
_defineProperty2 = function () {
|
11
|
-
return data;
|
12
|
-
};
|
13
|
-
return data;
|
14
|
-
}
|
15
7
|
function _react() {
|
16
8
|
const data = _interopRequireDefault(require("react"));
|
17
9
|
_react = function () {
|
@@ -33,20 +25,24 @@ function _graph() {
|
|
33
25
|
};
|
34
26
|
return data;
|
35
27
|
}
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
30
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
31
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
36
32
|
class GraphCompareSection {
|
37
33
|
constructor() {
|
38
|
-
(
|
34
|
+
_defineProperty(this, "navigationLink", {
|
39
35
|
href: 'dependencies',
|
40
36
|
children: 'Dependencies'
|
41
37
|
});
|
42
|
-
(
|
43
|
-
(
|
38
|
+
_defineProperty(this, "props", this.navigationLink);
|
39
|
+
_defineProperty(this, "route", {
|
44
40
|
path: 'dependencies/*',
|
45
41
|
element: /*#__PURE__*/_react().default.createElement(_graph().DependenciesCompare, null)
|
46
42
|
});
|
47
|
-
(
|
48
|
-
(
|
49
|
-
(
|
43
|
+
_defineProperty(this, "order", 25);
|
44
|
+
_defineProperty(this, "changeType", _componentUiComponentCompareModels().ChangeType.DEPENDENCY);
|
45
|
+
_defineProperty(this, "id", 'dependencies');
|
50
46
|
}
|
51
47
|
}
|
52
48
|
exports.GraphCompareSection = GraphCompareSection;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUiComponentCompareModels","_graph","
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUiComponentCompareModels","_graph","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","GraphCompareSection","constructor","href","children","navigationLink","path","element","createElement","DependenciesCompare","ChangeType","DEPENDENCY","exports"],"sources":["graph.compare.section.tsx"],"sourcesContent":["import React from 'react';\nimport { Section } from '@teambit/component';\nimport { ChangeType } from '@teambit/component.ui.component-compare.models.component-compare-change-type';\nimport { TabItem } from '@teambit/component.ui.component-compare.models.component-compare-props';\nimport { DependenciesCompare } from '@teambit/graph';\n\nexport class GraphCompareSection implements Section, TabItem {\n navigationLink = {\n href: 'dependencies',\n children: 'Dependencies',\n };\n\n props = this.navigationLink;\n\n route = {\n path: 'dependencies/*',\n element: <DependenciesCompare />,\n };\n\n order = 25;\n changeType = ChangeType.DEPENDENCY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AAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAE9C,MAAMU,mBAAmB,CAA6B;EAAAC,YAAA;IAAAvB,eAAA,yBAC1C;MACfwB,IAAI,EAAE,cAAc;MACpBC,QAAQ,EAAE;IACZ,CAAC;IAAAzB,eAAA,gBAEO,IAAI,CAAC0B,cAAc;IAAA1B,eAAA,gBAEnB;MACN2B,IAAI,EAAE,gBAAgB;MACtBC,OAAO,eAAErC,MAAA,GAAAQ,OAAA,CAAA8B,aAAA,CAACjC,MAAA,GAAAkC,mBAAmB,MAAE;IACjC,CAAC;IAAA9B,eAAA,gBAEO,EAAE;IAAAA,eAAA,qBACG+B,+CAAU,CAACC,UAAU;IAAAhC,eAAA,aAC7B,cAAc;EAAA;AACrB;AAACiC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
@@ -12,6 +11,7 @@ function _react() {
|
|
12
11
|
};
|
13
12
|
return data;
|
14
13
|
}
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
16
16
|
style: {
|
17
17
|
height: '100%',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","obj","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAmD,CAAE,CACjF,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA"}
|
package/dist/graph.graphql.js
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
require("core-js/modules/es.array.sort.js");
|
5
|
-
require("core-js/modules/es.promise.js");
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
7
4
|
value: true
|
8
5
|
});
|
@@ -21,6 +18,7 @@ function _edgeType() {
|
|
21
18
|
};
|
22
19
|
return data;
|
23
20
|
}
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24
22
|
const textCmp = new Intl.Collator().compare;
|
25
23
|
function graphSchema(graphBuilder, componentAspect) {
|
26
24
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","_edgeType","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":["_graphqlTag","data","_interopRequireDefault","require","_edgeType","obj","__esModule","default","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,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuC,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAA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pD;MACF,CAAC;MACDI,KAAK,EAAE;QACLhB,KAAK,EAAE,MAAAA,CAAOiB,OAAO,EAAE;UAAEC,GAAG;UAAEC;QAAiD,CAAC,KAAK;UACnF,MAAMC,cAAc,GAAG1B,eAAe,CAAC2B,OAAO,CAAC,CAAC;UAChD,MAAMC,WAAW,GAAGJ,GAAG,GACnB,MAAME,cAAc,CAACG,2BAA2B,CAACL,GAAG,CAAC,GACrD,CAAC,MAAME,cAAc,CAACI,IAAI,CAAC,CAAC,EAAEvB,GAAG,CAAEwB,CAAC,IAAKA,CAAC,CAACtB,EAAE,CAAC;UAElD,MAAMH,KAAK,GAAG,MAAMP,YAAY,CAACiC,QAAQ,CAACJ,WAAW,CAAC;UACtD,IAAI,CAACtB,KAAK,EAAE,OAAO2B,SAAS;UAE5B,IAAIR,MAAM,KAAK,aAAa,EAAE;YAC5B,MAAMS,YAAY,GAAG5B,KAAK,CAAC6B,WAAW,CAACP,WAAW,CAACrB,GAAG,CAAEwB,CAAC,IAAKA,CAAC,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5E,OAAOF,YAAY;UACrB;UAEA,OAAO5B,KAAK;QACd;MACF;IACF;EACF,CAAC;AACH;AAEA,SAASc,0BAA0BA,CAACiB,WAA2B,EAAY;EACzE,IAAIA,WAAW,KAAK,KAAK,EAAE,OAAOC,oBAAQ,CAACC,GAAG;EAC9C,IAAIF,WAAW,KAAK,SAAS,EAAE,OAAOC,oBAAQ,CAACE,OAAO;EACtD,OAAOF,oBAAQ,CAACG,IAAI;AACtB"}
|
@@ -1,19 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
5
|
-
require("core-js/modules/es.promise.js");
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
7
4
|
value: true
|
8
5
|
});
|
9
6
|
exports.GraphMain = void 0;
|
10
|
-
function _defineProperty2() {
|
11
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
12
|
-
_defineProperty2 = function () {
|
13
|
-
return data;
|
14
|
-
};
|
15
|
-
return data;
|
16
|
-
}
|
17
7
|
function _cli() {
|
18
8
|
const data = require("@teambit/cli");
|
19
9
|
_cli = function () {
|
@@ -70,6 +60,9 @@ function _graphCmd() {
|
|
70
60
|
};
|
71
61
|
return data;
|
72
62
|
}
|
63
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
64
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
65
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
73
66
|
class GraphMain {
|
74
67
|
constructor(componentAspect, logger) {
|
75
68
|
this.componentAspect = componentAspect;
|
@@ -97,9 +90,9 @@ class GraphMain {
|
|
97
90
|
}
|
98
91
|
}
|
99
92
|
exports.GraphMain = GraphMain;
|
100
|
-
(
|
101
|
-
(
|
102
|
-
(
|
93
|
+
_defineProperty(GraphMain, "slots", []);
|
94
|
+
_defineProperty(GraphMain, "dependencies", [_graphql().GraphqlAspect, _component().ComponentAspect, _cli().CLIAspect, _logger().LoggerAspect]);
|
95
|
+
_defineProperty(GraphMain, "runtime", _cli().MainRuntime);
|
103
96
|
_graph2().GraphAspect.addRuntime(GraphMain);
|
104
97
|
|
105
98
|
//# sourceMappingURL=graph.main.runtime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_component","_graphql","_logger","_graphBuilder","_graph","_graph2","_graphCmd","GraphMain","constructor","componentAspect","logger","getGraph","ids","opts","graphBuilder","GraphBuilder","getGraphIds","provider","graphql","cli","loggerMain","createLogger","GraphAspect","id","register","graphSchema","graphMain","GraphCmd","exports","
|
1
|
+
{"version":3,"names":["_cli","data","require","_component","_graphql","_logger","_graphBuilder","_graph","_graph2","_graphCmd","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","GraphMain","constructor","componentAspect","logger","getGraph","ids","opts","graphBuilder","GraphBuilder","getGraphIds","provider","graphql","cli","loggerMain","createLogger","GraphAspect","id","register","graphSchema","graphMain","GraphCmd","exports","GraphqlAspect","ComponentAspect","CLIAspect","LoggerAspect","MainRuntime","addRuntime"],"sources":["graph.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentMain, ComponentAspect, ComponentID } from '@teambit/component';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { GetGraphOpts, GraphBuilder } from './graph-builder';\nimport { graphSchema } from './graph.graphql';\nimport { GraphAspect } from './graph.aspect';\nimport { GraphCmd } from './graph-cmd';\nimport { ComponentGraph } from './component-graph';\nimport { ComponentIdGraph } from './component-id-graph';\n\nexport class GraphMain {\n constructor(private componentAspect: ComponentMain, private logger: Logger) {}\n\n /**\n * important - prefer using `getGraphIds()` it's way better in terms of performance.\n */\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const graphBuilder = new GraphBuilder(this.componentAspect);\n return graphBuilder.getGraph(ids, opts);\n }\n\n async getGraphIds(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentIdGraph> {\n const graphBuilder = new GraphBuilder(this.componentAspect);\n return graphBuilder.getGraphIds(ids, opts);\n }\n\n static slots = [];\n static dependencies = [GraphqlAspect, ComponentAspect, CLIAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([graphql, componentAspect, cli, loggerMain]: [\n GraphqlMain,\n ComponentMain,\n CLIMain,\n LoggerMain\n ]) {\n const logger = loggerMain.createLogger(GraphAspect.id);\n\n const graphBuilder = new GraphBuilder(componentAspect);\n graphql.register(graphSchema(graphBuilder, componentAspect));\n\n const graphMain = new GraphMain(componentAspect, logger);\n cli.register(new GraphCmd());\n\n return graphMain;\n }\n}\n\nGraphAspect.addRuntime(GraphMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,aAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,UAAA;EAAA,MAAAR,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