@teambit/insights 0.0.726 → 0.0.729
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/all-insights/{find-cycles.ts → find-circulars.ts} +3 -3
- package/dist/all-insights/{find-cycles.d.ts → find-circulars.d.ts} +1 -1
- package/dist/all-insights/{find-cycles.js → find-circulars.js} +6 -6
- package/dist/all-insights/find-circulars.js.map +1 -0
- package/dist/core-insights-getter.d.ts +1 -1
- package/dist/core-insights-getter.js +4 -4
- package/dist/core-insights-getter.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/insights.docs.mdx +1 -1
- package/insights.docs.mdx +1 -1
- package/package-tar/teambit-insights-0.0.729.tgz +0 -0
- package/package.json +8 -8
- package/{preview-1651721125153.js → preview-1652239597845.js} +1 -1
- package/dist/all-insights/find-cycles.js.map +0 -1
- package/package-tar/teambit-insights-0.0.726.tgz +0 -0
|
@@ -4,11 +4,11 @@ import { GraphBuilder } from '@teambit/graph';
|
|
|
4
4
|
import { uniq } from 'lodash';
|
|
5
5
|
import { Insight, InsightResult, RawResult } from '../insight';
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const INSIGHT_CIRCULAR_DEPS_NAME = 'circular dependencies';
|
|
8
8
|
|
|
9
9
|
export default class FindCycles implements Insight {
|
|
10
|
-
name =
|
|
11
|
-
description = 'Get all
|
|
10
|
+
name = INSIGHT_CIRCULAR_DEPS_NAME;
|
|
11
|
+
description = 'Get all circular dependencies in component graph';
|
|
12
12
|
graphBuilder: GraphBuilder;
|
|
13
13
|
constructor(graphBuilder: GraphBuilder) {
|
|
14
14
|
this.graphBuilder = graphBuilder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component } from '@teambit/component';
|
|
2
2
|
import { GraphBuilder } from '@teambit/graph';
|
|
3
3
|
import { Insight, InsightResult } from '../insight';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const INSIGHT_CIRCULAR_DEPS_NAME = "circular dependencies";
|
|
5
5
|
export default class FindCycles implements Insight {
|
|
6
6
|
name: string;
|
|
7
7
|
description: string;
|
|
@@ -13,7 +13,7 @@ require("core-js/modules/es.promise.js");
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
|
15
15
|
});
|
|
16
|
-
exports.default = exports.
|
|
16
|
+
exports.default = exports.INSIGHT_CIRCULAR_DEPS_NAME = void 0;
|
|
17
17
|
|
|
18
18
|
function _defineProperty2() {
|
|
19
19
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -45,13 +45,13 @@ function _lodash() {
|
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const
|
|
49
|
-
exports.
|
|
48
|
+
const INSIGHT_CIRCULAR_DEPS_NAME = 'circular dependencies';
|
|
49
|
+
exports.INSIGHT_CIRCULAR_DEPS_NAME = INSIGHT_CIRCULAR_DEPS_NAME;
|
|
50
50
|
|
|
51
51
|
class FindCycles {
|
|
52
52
|
constructor(graphBuilder) {
|
|
53
|
-
(0, _defineProperty2().default)(this, "name",
|
|
54
|
-
(0, _defineProperty2().default)(this, "description", 'Get all
|
|
53
|
+
(0, _defineProperty2().default)(this, "name", INSIGHT_CIRCULAR_DEPS_NAME);
|
|
54
|
+
(0, _defineProperty2().default)(this, "description", 'Get all circular dependencies in component graph');
|
|
55
55
|
(0, _defineProperty2().default)(this, "graphBuilder", void 0);
|
|
56
56
|
this.graphBuilder = graphBuilder;
|
|
57
57
|
}
|
|
@@ -132,4 +132,4 @@ class FindCycles {
|
|
|
132
132
|
|
|
133
133
|
exports.default = FindCycles;
|
|
134
134
|
|
|
135
|
-
//# sourceMappingURL=find-
|
|
135
|
+
//# sourceMappingURL=find-circulars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["find-circulars.ts"],"names":["INSIGHT_CIRCULAR_DEPS_NAME","FindCycles","constructor","graphBuilder","runInsight","graph","getGraph","message","data","undefined","cycles","findCycles","length","renderData","string","map","cycle","join","run","bareResult","renderedData","result","metaData","name","description","addAsComponentIssue","components","allIds","flat","componentsWithCircular","filter","component","includes","id","toString","forEach","state","issues","getOrCreate","IssuesClasses","CircularDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,0BAA0B,GAAG,uBAAnC;;;AAEQ,MAAMC,UAAN,CAAoC;AAIjDC,EAAAA,WAAW,CAACC,YAAD,EAA6B;AAAA,kDAHjCH,0BAGiC;AAAA,yDAF1B,kDAE0B;AAAA;AACtC,SAAKG,YAAL,GAAoBA,YAApB;AACD;;AACuB,QAAVC,UAAU,GAAuB;AAC7C,UAAMC,KAAK,GAAG,MAAM,KAAKF,YAAL,CAAkBG,QAAlB,EAApB;;AACA,QAAI,CAACD,KAAL,EAAY;AACV,aAAO;AACLE,QAAAA,OAAO,EAAE,EADJ;AAELC,QAAAA,IAAI,EAAEC;AAFD,OAAP;AAID;;AACD,UAAMC,MAAM,GAAGL,KAAK,CAACM,UAAN,EAAf;;AACA,QAAID,MAAM,CAACE,MAAP,KAAkB,CAAtB,EAAyB;AACvB,aAAO;AACLL,QAAAA,OAAO,EAAG,SAAQG,MAAM,CAACE,MAAO,SAD3B;AAELJ,QAAAA,IAAI,EAAEE;AAFD,OAAP;AAID;;AACD,WAAO;AACLH,MAAAA,OAAO,EAAG,SAAQG,MAAM,CAACE,MAAO,UAD3B;AAELJ,MAAAA,IAAI,EAAEE;AAFD,KAAP;AAID;;AAEOG,EAAAA,UAAU,CAACL,IAAD,EAAkB;AAClC,QAAIA,IAAI,CAACA,IAAL,CAAUI,MAAV,KAAqB,CAAzB,EAA4B;AAC1B,aAAO,wBAAP;AACD;;AACD,UAAME,MAAM,GAAGN,IAAI,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B,CAAmCC,iCAAcC,oBAAjD,EAAuEhC,IAAvE,GAA8E,IAA9E;AACD,KAFD;AAGD;;AAvEgD","sourcesContent":["import { Component } from '@teambit/component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GraphBuilder } from '@teambit/graph';\nimport { uniq } from 'lodash';\nimport { Insight, InsightResult, RawResult } from '../insight';\n\nexport const INSIGHT_CIRCULAR_DEPS_NAME = 'circular dependencies';\n\nexport default class FindCycles implements Insight {\n name = INSIGHT_CIRCULAR_DEPS_NAME;\n description = 'Get all circular dependencies in component graph';\n graphBuilder: GraphBuilder;\n constructor(graphBuilder: GraphBuilder) {\n this.graphBuilder = graphBuilder;\n }\n private async runInsight(): Promise<RawResult> {\n const graph = await this.graphBuilder.getGraph();\n if (!graph) {\n return {\n message: '',\n data: undefined,\n };\n }\n const cycles = graph.findCycles();\n if (cycles.length === 1) {\n return {\n message: `Found ${cycles.length} cycle.`,\n data: cycles,\n };\n }\n return {\n message: `Found ${cycles.length} cycles.`,\n data: cycles,\n };\n }\n\n private renderData(data: RawResult) {\n if (data.data.length === 0) {\n return 'No cyclic dependencies';\n }\n const string = data.data\n .map((cycle) => {\n return `\\nCyclic dependency\n-----------------\n- ${cycle.join('\\n- ')}`;\n })\n .join('\\n');\n return string;\n }\n\n async run(): Promise<InsightResult> {\n const bareResult = await this.runInsight();\n const renderedData = this.renderData(bareResult);\n const result: InsightResult = {\n metaData: {\n name: this.name,\n description: this.description,\n },\n data: bareResult.data,\n message: bareResult.message,\n renderedData,\n };\n\n if (bareResult.message) {\n result.message = bareResult.message;\n }\n return result;\n }\n\n async addAsComponentIssue(components: Component[]) {\n const result = await this.runInsight();\n if (!result.data.length) {\n return; // no circulars\n }\n const allIds = uniq(result.data.flat());\n const componentsWithCircular = components.filter((component) => allIds.includes(component.id.toString()));\n componentsWithCircular.forEach((component) => {\n component.state.issues.getOrCreate(IssuesClasses.CircularDependencies).data = true;\n });\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GraphBuilder } from '@teambit/graph';
|
|
2
2
|
import DuplicateDependencies from './all-insights/duplicate-dependencies';
|
|
3
|
-
import FindCycles from './all-insights/find-
|
|
3
|
+
import FindCycles from './all-insights/find-circulars';
|
|
4
4
|
export default function getCoreInsights(graphBuilder: GraphBuilder): (FindCycles | DuplicateDependencies)[];
|
|
@@ -17,10 +17,10 @@ function _duplicateDependencies() {
|
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
21
|
-
const data = _interopRequireDefault(require("./all-insights/find-
|
|
20
|
+
function _findCirculars() {
|
|
21
|
+
const data = _interopRequireDefault(require("./all-insights/find-circulars"));
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
_findCirculars = function () {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ function _findCycles() {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function getCoreInsights(graphBuilder) {
|
|
31
|
-
const coreInsights = [new (
|
|
31
|
+
const coreInsights = [new (_findCirculars().default)(graphBuilder), new (_duplicateDependencies().default)(graphBuilder)];
|
|
32
32
|
return coreInsights;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["core-insights-getter.ts"],"names":["getCoreInsights","graphBuilder","coreInsights","FindCycles","DuplicateDependencies"],"mappings":";;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEe,SAASA,eAAT,CAAyBC,YAAzB,EAAqD;AAClE,QAAMC,YAAY,GAAG,CAAC,KAAIC,
|
|
1
|
+
{"version":3,"sources":["core-insights-getter.ts"],"names":["getCoreInsights","graphBuilder","coreInsights","FindCycles","DuplicateDependencies"],"mappings":";;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEe,SAASA,eAAT,CAAyBC,YAAzB,EAAqD;AAClE,QAAMC,YAAY,GAAG,CAAC,KAAIC,wBAAJ,EAAeF,YAAf,CAAD,EAA+B,KAAIG,gCAAJ,EAA0BH,YAA1B,CAA/B,CAArB;AACA,SAAOC,YAAP;AACD","sourcesContent":["import { GraphBuilder } from '@teambit/graph';\n\nimport DuplicateDependencies from './all-insights/duplicate-dependencies';\nimport FindCycles from './all-insights/find-circulars';\n\nexport default function getCoreInsights(graphBuilder: GraphBuilder) {\n const coreInsights = [new FindCycles(graphBuilder), new DuplicateDependencies(graphBuilder)];\n return coreInsights;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { InsightManager } from './insight-manager';
|
|
|
2
2
|
export { Insight } from './insight';
|
|
3
3
|
export type { InsightsMain } from './insights.main.runtime';
|
|
4
4
|
export { InsightsAspect } from './insights.aspect';
|
|
5
|
+
export { INSIGHT_CIRCULAR_DEPS_NAME } from './all-insights/find-circulars';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "INSIGHT_CIRCULAR_DEPS_NAME", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _findCirculars().INSIGHT_CIRCULAR_DEPS_NAME;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "Insight", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -52,4 +58,14 @@ function _insights() {
|
|
|
52
58
|
return data;
|
|
53
59
|
}
|
|
54
60
|
|
|
61
|
+
function _findCirculars() {
|
|
62
|
+
const data = require("./all-insights/find-circulars");
|
|
63
|
+
|
|
64
|
+
_findCirculars = function () {
|
|
65
|
+
return data;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { InsightManager } from './insight-manager';\nexport { Insight } from './insight';\nexport type { InsightsMain } from './insights.main.runtime';\nexport { InsightsAspect } from './insights.aspect';\nexport { INSIGHT_CIRCULAR_DEPS_NAME } from './all-insights/find-circulars';\n"]}
|
package/dist/insights.docs.mdx
CHANGED
package/insights.docs.mdx
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/insights",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.729",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/explorer/insights",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.explorer",
|
|
8
8
|
"name": "insights",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.729"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"p-map-series": "2.1.0",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"@babel/runtime": "7.12.18",
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
18
|
"@teambit/harmony": "0.3.3",
|
|
19
|
-
"@teambit/graph": "0.0.
|
|
20
|
-
"@teambit/component": "0.0.
|
|
21
|
-
"@teambit/cli": "0.0.
|
|
22
|
-
"@teambit/component-issues": "0.0.
|
|
19
|
+
"@teambit/graph": "0.0.729",
|
|
20
|
+
"@teambit/component": "0.0.729",
|
|
21
|
+
"@teambit/cli": "0.0.486",
|
|
22
|
+
"@teambit/component-issues": "0.0.52",
|
|
23
23
|
"@teambit/bit-error": "0.0.394"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/node": "12.20.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@teambit/legacy": "1.0.
|
|
36
|
+
"@teambit/legacy": "1.0.265",
|
|
37
37
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
38
38
|
"react": "^16.8.0 || ^17.0.0"
|
|
39
39
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"react": "-"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@teambit/legacy": "1.0.
|
|
64
|
+
"@teambit/legacy": "1.0.265",
|
|
65
65
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
66
66
|
"react": "^16.8.0 || ^17.0.0"
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.
|
|
1
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.729/dist/insights.docs.mdx')]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["find-cycles.ts"],"names":["INSIGHT_NAME","FindCycles","constructor","graphBuilder","runInsight","graph","getGraph","message","data","undefined","cycles","findCycles","length","renderData","string","map","cycle","join","run","bareResult","renderedData","result","metaData","name","description","addAsComponentIssue","components","allIds","flat","componentsWithCircular","filter","component","includes","id","toString","forEach","state","iss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AACD;;AAEQ,QAAHI,GAAG,GAA2B;AAClC,UAAMC,UAAU,GAAG,MAAM,KAAKf,UAAL,EAAzB;AACA,UAAMgB,YAAY,GAAG,KAAKP,UAAL,CAAgBM,UAAhB,CAArB;AACA,UAAME,MAAqB,GAAG;AAC5BC,MAAAA,QAAQ,EAAE;AACRC,QAAAA,IAAI,EAAE,KAAKA,IADH;AAERC,QAAAA,WAAW,EAAE,KAAKA;AAFV,OADkB;AAK5BhB,MAAAA,IAAI,EAAEW,UAAU,CAACX,IALW;AAM5BD,MAAAA,OAAO,EAAEY,UAAU,CAACZ,OANQ;AAO5Ba,MAAAA;AAP4B,KAA9B;;AAUA,QAAID,UAAU,CAACZ,OAAf,EAAwB;AACtBc,MAAAA,MAAM,CAACd,OAAP,GAAiBY,UAAU,CAACZ,OAA5B;AACD;;AACD,WAAOc,MAAP;AACD;;AAEwB,QAAnBI,mBAAmB,CAACC,UAAD,EAA0B;AACjD,UAAML,MAAM,GAAG,MAAM,KAAKjB,UAAL,EAArB;;AACA,QAAI,CAACiB,MAAM,CAACb,IAAP,CAAYI,MAAjB,EAAyB;AACvB,aADuB,CACf;AACT;;AACD,UAAMe,MAAM,GAAG,oBAAKN,MAAM,CAACb,IAAP,CAAYoB,IAAZ,EAAL,CAAf;AACA,UAAMC,sBAAsB,GAAGH,UAAU,CAACI,MAAX,CAAmBC,SAAD,IAAeJ,MAAM,CAACK,QAAP,CAAgBD,SAAS,CAACE,EAAV,CAAaC,QAAb,EAAhB,CAAjC,CAA/B;AACAL,IAAAA,sBAAsB,CAACM,OAAvB,CAAgCJ,SAAD,IAAe;AAC5CA,MAAAA,SAAS,CAACK,KAAV,CAAgBC,MAAhB,CAAuBC,WAAvB,CAAmCC,iCAAcC,oBAAjD,EAAuEhC,IAAvE,GAA8E,IAA9E;AACD,KAFD;AAGD;;AAvEgD","sourcesContent":["import { Component } from '@teambit/component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GraphBuilder } from '@teambit/graph';\nimport { uniq } from 'lodash';\nimport { Insight, InsightResult, RawResult } from '../insight';\n\nexport const INSIGHT_NAME = 'cyclic dependencies';\n\nexport default class FindCycles implements Insight {\n name = INSIGHT_NAME;\n description = 'Get all cyclic dependencies in component graph';\n graphBuilder: GraphBuilder;\n constructor(graphBuilder: GraphBuilder) {\n this.graphBuilder = graphBuilder;\n }\n private async runInsight(): Promise<RawResult> {\n const graph = await this.graphBuilder.getGraph();\n if (!graph) {\n return {\n message: '',\n data: undefined,\n };\n }\n const cycles = graph.findCycles();\n if (cycles.length === 1) {\n return {\n message: `Found ${cycles.length} cycle.`,\n data: cycles,\n };\n }\n return {\n message: `Found ${cycles.length} cycles.`,\n data: cycles,\n };\n }\n\n private renderData(data: RawResult) {\n if (data.data.length === 0) {\n return 'No cyclic dependencies';\n }\n const string = data.data\n .map((cycle) => {\n return `\\nCyclic dependency\n-----------------\n- ${cycle.join('\\n- ')}`;\n })\n .join('\\n');\n return string;\n }\n\n async run(): Promise<InsightResult> {\n const bareResult = await this.runInsight();\n const renderedData = this.renderData(bareResult);\n const result: InsightResult = {\n metaData: {\n name: this.name,\n description: this.description,\n },\n data: bareResult.data,\n message: bareResult.message,\n renderedData,\n };\n\n if (bareResult.message) {\n result.message = bareResult.message;\n }\n return result;\n }\n\n async addAsComponentIssue(components: Component[]) {\n const result = await this.runInsight();\n if (!result.data.length) {\n return; // no circulars\n }\n const allIds = uniq(result.data.flat());\n const componentsWithCircular = components.filter((component) => allIds.includes(component.id.toString()));\n componentsWithCircular.forEach((component) => {\n component.state.issues.getOrCreate(IssuesClasses.CircularDependencies).data = true;\n });\n }\n}\n"]}
|
|
Binary file
|