@teambit/insights 0.0.1133 → 0.0.1135

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.
@@ -15,7 +15,7 @@ export default class FindCycles implements Insight {
15
15
  this.graphBuilder = graphBuilder;
16
16
  }
17
17
  private async runInsight(opts?: RunInsightOptions): Promise<RawResult> {
18
- const graph = await this.graphBuilder.getGraphIds();
18
+ const graph = await this.graphBuilder.getGraphIds(opts?.ids);
19
19
  if (!graph) {
20
20
  return {
21
21
  message: '',
@@ -69,7 +69,7 @@ export default class FindCycles implements Insight {
69
69
  }
70
70
 
71
71
  async addAsComponentIssue(components: Component[]) {
72
- const result = await this.runInsight();
72
+ const result = await this.runInsight({ ids: components.map((c) => c.id) });
73
73
  if (!result.data.length) {
74
74
  return; // no circulars
75
75
  }
@@ -40,7 +40,7 @@ class FindCycles {
40
40
  this.graphBuilder = graphBuilder;
41
41
  }
42
42
  async runInsight(opts) {
43
- const graph = await this.graphBuilder.getGraphIds();
43
+ const graph = await this.graphBuilder.getGraphIds(opts === null || opts === void 0 ? void 0 : opts.ids);
44
44
  if (!graph) {
45
45
  return {
46
46
  message: '',
@@ -88,7 +88,9 @@ class FindCycles {
88
88
  return result;
89
89
  }
90
90
  async addAsComponentIssue(components) {
91
- const result = await this.runInsight();
91
+ const result = await this.runInsight({
92
+ ids: components.map(c => c.id)
93
+ });
92
94
  if (!result.data.length) {
93
95
  return; // no circulars
94
96
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_componentIssues","data","require","_lodash","INSIGHT_CIRCULAR_DEPS_NAME","exports","FindCycles","constructor","graphBuilder","_defineProperty2","default","runInsight","opts","graph","getGraphIds","message","undefined","cycles","findCycles","includeDeps","length","renderData","string","map","cycle","join","run","bareResult","renderedData","result","metaData","name","description","addAsComponentIssue","components","allIds","uniq","flat","componentsWithCircular","filter","component","includes","id","toString","forEach","state","issues","getOrCreate","IssuesClasses","CircularDependencies"],"sources":["find-circulars.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GraphMain } from '@teambit/graph';\nimport { uniq } from 'lodash';\nimport { Insight, InsightResult, RawResult } from '../insight';\nimport { RunInsightOptions } from '../insight-manager';\n\nexport const INSIGHT_CIRCULAR_DEPS_NAME = 'circular';\n\nexport default class FindCycles implements Insight {\n name = INSIGHT_CIRCULAR_DEPS_NAME;\n description = 'Get all circular dependencies in component graph';\n graphBuilder: GraphMain;\n constructor(graphBuilder: GraphMain) {\n this.graphBuilder = graphBuilder;\n }\n private async runInsight(opts?: RunInsightOptions): Promise<RawResult> {\n const graph = await this.graphBuilder.getGraphIds();\n if (!graph) {\n return {\n message: '',\n data: undefined,\n };\n }\n const cycles = graph.findCycles(undefined, opts?.includeDeps);\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(opts?: RunInsightOptions): Promise<InsightResult> {\n const bareResult = await this.runInsight(opts);\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"],"mappings":";;;;;;;;;;;;;;;;;;AACA,SAAAA,iBAAA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,SAAS,IAAK;MAC5CA,SAAS,CAACK,KAAK,CAACC,MAAM,CAACC,WAAW,CAACC,gCAAa,CAACC,oBAAoB,CAAC,CAAChD,IAAI,GAAG,IAAI;IACpF,CAAC,CAAC;EACJ;AACF;AAACI,OAAA,CAAAK,OAAA,GAAAJ,UAAA"}
1
+ {"version":3,"names":["_componentIssues","data","require","_lodash","INSIGHT_CIRCULAR_DEPS_NAME","exports","FindCycles","constructor","graphBuilder","_defineProperty2","default","runInsight","opts","graph","getGraphIds","ids","message","undefined","cycles","findCycles","includeDeps","length","renderData","string","map","cycle","join","run","bareResult","renderedData","result","metaData","name","description","addAsComponentIssue","components","c","id","allIds","uniq","flat","componentsWithCircular","filter","component","includes","toString","forEach","state","issues","getOrCreate","IssuesClasses","CircularDependencies"],"sources":["find-circulars.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GraphMain } from '@teambit/graph';\nimport { uniq } from 'lodash';\nimport { Insight, InsightResult, RawResult } from '../insight';\nimport { RunInsightOptions } from '../insight-manager';\n\nexport const INSIGHT_CIRCULAR_DEPS_NAME = 'circular';\n\nexport default class FindCycles implements Insight {\n name = INSIGHT_CIRCULAR_DEPS_NAME;\n description = 'Get all circular dependencies in component graph';\n graphBuilder: GraphMain;\n constructor(graphBuilder: GraphMain) {\n this.graphBuilder = graphBuilder;\n }\n private async runInsight(opts?: RunInsightOptions): Promise<RawResult> {\n const graph = await this.graphBuilder.getGraphIds(opts?.ids);\n if (!graph) {\n return {\n message: '',\n data: undefined,\n };\n }\n const cycles = graph.findCycles(undefined, opts?.includeDeps);\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(opts?: RunInsightOptions): Promise<InsightResult> {\n const bareResult = await this.runInsight(opts);\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({ ids: components.map((c) => c.id) });\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"],"mappings":";;;;;;;;;;;;;;;;;;AACA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIO,MAAMG,0BAA0B,GAAG,UAAU;AAACC,OAAA,CAAAD,0BAAA,GAAAA,0BAAA;AAEtC,MAAME,UAAU,CAAoB;EAIjDC,WAAWA,CAACC,YAAuB,EAAE;IAAA,IAAAC,gBAAA,GAAAC,OAAA,gBAH9BN,0BAA0B;IAAA,IAAAK,gBAAA,GAAAC,OAAA,uBACnB,kDAAkD;IAAA,IAAAD,gBAAA,GAAAC,OAAA;IAG9D,IAAI,CAACF,YAAY,GAAGA,YAAY;EAClC;EACA,MAAcG,UAAUA,CAACC,IAAwB,EAAsB;IACrE,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACL,YAAY,CAACM,WAAW,CAACF,IAAI,aAAJA,IAAI,uBAAJA,IAAI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AAC;IAED,IAAID,UAAU,CAACZ,OAAO,EAAE;MACtBc,MAAM,CAACd,OAAO,GAAGY,UAAU,CAACZ,OAAO;IACrC;IACA,OAAOc,MAAM;EACf;EAEA,MAAMI,mBAAmBA,CAACC,UAAuB,EAAE;IACjD,MAAML,MAAM,GAAG,MAAM,IAAI,CAACnB,UAAU,CAAC;MAAEI,GAAG,EAAEoB,UAAU,CAACX,GAAG,CAAEY,CAAC,IAAKA,CAAC,CAACC,EAAE;IAAE,CAAC,CAAC;IAC1E,IAAI,CAACP,MAAM,CAAC7B,IAAI,CAACoB,MAAM,EAAE;MACvB,OAAO,CAAC;IACV;;IACA,MAAMiB,MAAM,GAAG,IAAAC,cAAI,EAACT,MAAM,CAAC7B,IAAI,CAACuC,IAAI,CAAC,CAAC,CAAC;IACvC,MAAMC,sBAAsB,GAAGN,UAAU,CAACO,MAAM,CAAEC,SAAS,IAAKL,MAAM,CAACM,QAAQ,CAACD,SAAS,CAACN,EAAE,CAACQ,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzGJ,sBAAsB,CAACK,OAAO,CAAEH,SAAS,IAAK;MAC5CA,SAAS,CAACI,KAAK,CAACC,MAAM,CAACC,WAAW,CAACC,gCAAa,CAACC,oBAAoB,CAAC,CAAClD,IAAI,GAAG,IAAI;IACpF,CAAC,CAAC;EACJ;AACF;AAACI,OAAA,CAAAK,OAAA,GAAAJ,UAAA"}
@@ -1,7 +1,9 @@
1
+ import { ComponentID } from '@teambit/component-id';
1
2
  import { Insight, InsightResult } from './insight';
2
3
  export declare type RunInsightOptions = {
3
4
  renderData?: boolean;
4
5
  includeDeps?: boolean;
6
+ ids?: ComponentID[];
5
7
  };
6
8
  export declare class InsightManager {
7
9
  /** insights is an insight registry */
@@ -1 +1 @@
1
- {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_insightAlreadyExists","_insightNotFound","InsightManager","constructor","insights","_defineProperty2","default","Map","forEach","insight","register","name","has","InsightAlreadyExists","set","listInsights","keys","getByName","insightName","get","delete","InsightNotFound","run","insightNames","opts","res","pMapSeries","insightRes","renderData","renderedData","push","runAll","allInsightNames","exports"],"sources":["insight-manager.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport InsightAlreadyExists from './exceptions/insight-already-exists';\nimport InsightNotFound from './exceptions/insight-not-found';\nimport { Insight, InsightResult } from './insight';\n\nexport type RunInsightOptions = {\n renderData?: boolean;\n includeDeps?: boolean;\n};\nexport class InsightManager {\n /** insights is an insight registry */\n readonly insights: Map<string, Insight> = new Map();\n constructor(\n /**\n * array of registered insights\n */\n insights: Insight[]\n ) {\n insights.forEach((insight) => {\n this.register(insight);\n });\n }\n\n /**\n * registers a new insight and returns the updated insight registry map\n */\n register(insight: Insight) {\n const name = insight.name;\n if (this.insights.has(name)) {\n throw new InsightAlreadyExists(name);\n }\n this.insights.set(name, insight);\n }\n /**\n * list of all registered insights\n */\n listInsights(): string[] {\n return [...this.insights.keys()];\n }\n\n /**\n * gets a specific insight by its name or undefined if doesn't exist\n */\n getByName(insightName: string): Insight | undefined {\n return this.insights.get(insightName);\n }\n\n /**\n * deletes a specific insight by its name if exists\n */\n delete(insightName: string) {\n if (!this.insights.has(insightName)) {\n throw new InsightNotFound(insightName);\n }\n this.insights.delete(insightName);\n }\n\n /**\n * execute an array of insights\n *\n */\n async run(insightNames: string[], opts: RunInsightOptions): Promise<InsightResult[]> {\n const res: InsightResult[] = [];\n // the reason for not using Promise.all here is that the current both insights building the graph.\n // if it happens at the same time, some props are not populated in one of the instances. it obviously\n // should be fixed in the GraphBuilder class. see \"todo\" there.\n await pMapSeries(insightNames, async (insightName) => {\n const insight = this.getByName(insightName);\n if (insight) {\n const insightRes: InsightResult = await insight.run(opts);\n if (!opts.renderData) {\n delete insightRes.renderedData;\n }\n res.push(insightRes);\n }\n });\n return res;\n }\n\n /**\n * execute all insights in the registry\n *\n */\n async runAll(opts: RunInsightOptions): Promise<InsightResult[]> {\n const allInsightNames = this.listInsights();\n return this.run(allInsightNames, op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GAAG,CAACD,WAAW,CAAC;EACvC;;EAEA;AACF;AACA;EACEE,MAAMA,CAACF,WAAmB,EAAE;IAC1B,IAAI,CAAC,IAAI,CAACd,QAAQ,CAACQ,GAAG,CAACM,WAAW,CAAC,EAAE;MACnC,MAAM,KAAIG,0BAAe,EAACH,WAAW,CAAC;IACxC;IACA,IAAI,CAACd,QAAQ,CAACgB,MAAM,CAACF,WAAW,CAAC;EACnC;;EAEA;AACF;AACA;AACA;EACE,MAAMI,GAAGA,CAACC,YAAsB,EAAEC,IAAuB,EAA4B;IACnF,MAAMC,GAAoB,GAAG,EAAE;IAC/B;IACA;IACA;IACA,MAAM,IAAAC,qBAAU,EAACH,YAAY,EAAE,MAAOL,WAAW,IAAK;MACpD,MAAMT,OAAO,GAAG,IAAI,CAACQ,SAAS,CAACC,WAAW,CAAC;MAC3C,IAAIT,OAAO,EAAE;QACX,MAAMkB,UAAyB,GAAG,MAAMlB,OAAO,CAACa,GAAG,CAACE,IAAI,CAAC;QACzD,IAAI,CAACA,IAAI,CAACI,UAAU,EAAE;UACpB,OAAOD,UAAU,CAACE,YAAY;QAChC;QACAJ,GAAG,CAACK,IAAI,CAACH,UAAU,CAAC;MACtB;IACF,CAAC,CAAC;IACF,OAAOF,GAAG;EACZ;;EAEA;AACF;AACA;AACA;EACE,MAAMM,MAAMA,CAACP,IAAuB,EAA4B;IAC9D,MAAMQ,eAAe,GAAG,IAAI,CAACjB,YAAY,CAAC,CAAC;IAC3C,OAAO,IAAI,CAACO,GAAG,CAACU,eAAe,EAAER,IAAI,CAAC;EACxC;AACF;AAACS,OAAA,CAAA/B,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_insightAlreadyExists","_insightNotFound","InsightManager","constructor","insights","_defineProperty2","default","Map","forEach","insight","register","name","has","InsightAlreadyExists","set","listInsights","keys","getByName","insightName","get","delete","InsightNotFound","run","insightNames","opts","res","pMapSeries","insightRes","renderData","renderedData","push","runAll","allInsightNames","exports"],"sources":["insight-manager.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { ComponentID } from '@teambit/component-id';\nimport InsightAlreadyExists from './exceptions/insight-already-exists';\nimport InsightNotFound from './exceptions/insight-not-found';\nimport { Insight, InsightResult } from './insight';\n\nexport type RunInsightOptions = {\n renderData?: boolean;\n includeDeps?: boolean;\n ids?: ComponentID[];\n};\nexport class InsightManager {\n /** insights is an insight registry */\n readonly insights: Map<string, Insight> = new Map();\n constructor(\n /**\n * array of registered insights\n */\n insights: Insight[]\n ) {\n insights.forEach((insight) => {\n this.register(insight);\n });\n }\n\n /**\n * registers a new insight and returns the updated insight registry map\n */\n register(insight: Insight) {\n const name = insight.name;\n if (this.insights.has(name)) {\n throw new InsightAlreadyExists(name);\n }\n this.insights.set(name, insight);\n }\n /**\n * list of all registered insights\n */\n listInsights(): string[] {\n return [...this.insights.keys()];\n }\n\n /**\n * gets a specific insight by its name or undefined if doesn't exist\n */\n getByName(insightName: string): Insight | undefined {\n return this.insights.get(insightName);\n }\n\n /**\n * deletes a specific insight by its name if exists\n */\n delete(insightName: string) {\n if (!this.insights.has(insightName)) {\n throw new InsightNotFound(insightName);\n }\n this.insights.delete(insightName);\n }\n\n /**\n * execute an array of insights\n *\n */\n async run(insightNames: string[], opts: RunInsightOptions): Promise<InsightResult[]> {\n const res: InsightResult[] = [];\n // the reason for not using Promise.all here is that the current both insights building the graph.\n // if it happens at the same time, some props are not populated in one of the instances. it obviously\n // should be fixed in the GraphBuilder class. see \"todo\" there.\n await pMapSeries(insightNames, async (insightName) => {\n const insight = this.getByName(insightName);\n if (insight) {\n const insightRes: InsightResult = await insight.run(opts);\n if (!opts.renderData) {\n delete insightRes.renderedData;\n }\n res.push(insightRes);\n }\n });\n return res;\n }\n\n /**\n * execute all insights in the registry\n *\n */\n async runAll(opts: RunInsightOptions): Promise<InsightResult[]> {\n const allInsightNames = this.listInsights();\n return this.run(allInsightNames, opts);\n }\n}\n"],"mappings":";;;;;;;;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;;EAEA;AACF;AACA;EACEE,MAAMA,CAACF,WAAmB,EAAE;IAC1B,IAAI,CAAC,IAAI,CAACd,QAAQ,CAACQ,GAAG,CAACM,WAAW,CAAC,EAAE;MACnC,MAAM,KAAIG,0BAAe,EAACH,WAAW,CAAC;IACxC;IACA,IAAI,CAACd,QAAQ,CAACgB,MAAM,CAACF,WAAW,CAAC;EACnC;;EAEA;AACF;AACA;AACA;EACE,MAAMI,GAAGA,CAACC,YAAsB,EAAEC,IAAuB,EAA4B;IACnF,MAAMC,GAAoB,GAAG,EAAE;IAC/B;IACA;IACA;IACA,MAAM,IAAAC,qBAAU,EAACH,YAAY,EAAE,MAAOL,WAAW,IAAK;MACpD,MAAMT,OAAO,GAAG,IAAI,CAACQ,SAAS,CAACC,WAAW,CAAC;MAC3C,IAAIT,OAAO,EAAE;QACX,MAAMkB,UAAyB,GAAG,MAAMlB,OAAO,CAACa,GAAG,CAACE,IAAI,CAAC;QACzD,IAAI,CAACA,IAAI,CAACI,UAAU,EAAE;UACpB,OAAOD,UAAU,CAACE,YAAY;QAChC;QACAJ,GAAG,CAACK,IAAI,CAACH,UAAU,CAAC;MACtB;IACF,CAAC,CAAC;IACF,OAAOF,GAAG;EACZ;;EAEA;AACF;AACA;AACA;EACE,MAAMM,MAAMA,CAACP,IAAuB,EAA4B;IAC9D,MAAMQ,eAAe,GAAG,IAAI,CAACjB,YAAY,CAAC,CAAC;IAC3C,OAAO,IAAI,CAACO,GAAG,CAACU,eAAe,EAAER,IAAI,CAAC;EACxC;AACF;AAACS,OAAA,CAAA/B,cAAA,GAAAA,cAAA"}
@@ -1,5 +1,5 @@
1
1
  ;
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.1133/dist/insights.docs.mdx';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.1135/dist/insights.docs.mdx';
3
3
 
4
4
  export const compositions = [];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/insights",
3
- "version": "0.0.1133",
3
+ "version": "0.0.1135",
4
4
  "homepage": "https://bit.cloud/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.1133"
9
+ "version": "0.0.1135"
10
10
  },
11
11
  "dependencies": {
12
12
  "p-map-series": "2.1.0",
@@ -15,12 +15,13 @@
15
15
  "lodash": "4.17.21",
16
16
  "core-js": "^3.0.0",
17
17
  "@babel/runtime": "7.20.0",
18
+ "@teambit/component-id": "0.0.427",
18
19
  "@teambit/harmony": "0.4.6",
19
- "@teambit/graph": "0.0.1133",
20
- "@teambit/component": "0.0.1133",
21
- "@teambit/cli": "0.0.759",
20
+ "@teambit/graph": "0.0.1135",
21
+ "@teambit/component": "0.0.1135",
22
+ "@teambit/cli": "0.0.761",
22
23
  "@teambit/component-issues": "0.0.95",
23
- "@teambit/issues": "0.0.441",
24
+ "@teambit/issues": "0.0.443",
24
25
  "@teambit/bit-error": "0.0.402"
25
26
  },
26
27
  "devDependencies": {
@@ -34,7 +35,7 @@
34
35
  "@types/testing-library__jest-dom": "5.9.5"
35
36
  },
36
37
  "peerDependencies": {
37
- "@teambit/legacy": "1.0.542",
38
+ "@teambit/legacy": "1.0.545",
38
39
  "react": "^16.8.0 || ^17.0.0",
39
40
  "react-dom": "^16.8.0 || ^17.0.0"
40
41
  },