@teambit/insights 0.0.692 → 0.0.695

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.
@@ -1,4 +1,7 @@
1
+ import { Component } from '@teambit/component';
2
+ import { IssuesClasses } from '@teambit/component-issues';
1
3
  import { GraphBuilder } from '@teambit/graph';
4
+ import { uniq } from 'lodash';
2
5
  import { Insight, InsightResult, RawResult } from '../insight';
3
6
 
4
7
  export const INSIGHT_NAME = 'cyclic dependencies';
@@ -63,4 +66,16 @@ export default class FindCycles implements Insight {
63
66
  }
64
67
  return result;
65
68
  }
69
+
70
+ async addAsComponentIssue(components: Component[]) {
71
+ const result = await this.runInsight();
72
+ if (!result.data.length) {
73
+ return; // no circulars
74
+ }
75
+ const allIds = uniq(result.data.flat());
76
+ const componentsWithCircular = components.filter((component) => allIds.includes(component.id.toString()));
77
+ componentsWithCircular.forEach((component) => {
78
+ component.state.issues.getOrCreate(IssuesClasses.CircularDependencies).data = true;
79
+ });
80
+ }
66
81
  }
@@ -1,3 +1,4 @@
1
+ import { Component } from '@teambit/component';
1
2
  import { GraphBuilder } from '@teambit/graph';
2
3
  import { Insight, InsightResult } from '../insight';
3
4
  export declare const INSIGHT_NAME = "cyclic dependencies";
@@ -9,4 +10,5 @@ export default class FindCycles implements Insight {
9
10
  private runInsight;
10
11
  private renderData;
11
12
  run(): Promise<InsightResult>;
13
+ addAsComponentIssue(components: Component[]): Promise<void>;
12
14
  }
@@ -4,6 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  require("core-js/modules/es.symbol.description.js");
6
6
 
7
+ require("core-js/modules/es.array.flat.js");
8
+
9
+ require("core-js/modules/es.array.unscopables.flat.js");
10
+
7
11
  require("core-js/modules/es.promise.js");
8
12
 
9
13
  Object.defineProperty(exports, "__esModule", {
@@ -21,6 +25,26 @@ function _defineProperty2() {
21
25
  return data;
22
26
  }
23
27
 
28
+ function _componentIssues() {
29
+ const data = require("@teambit/component-issues");
30
+
31
+ _componentIssues = function () {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _lodash() {
39
+ const data = require("lodash");
40
+
41
+ _lodash = function () {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
24
48
  const INSIGHT_NAME = 'cyclic dependencies';
25
49
  exports.INSIGHT_NAME = INSIGHT_NAME;
26
50
 
@@ -90,6 +114,20 @@ class FindCycles {
90
114
  return result;
91
115
  }
92
116
 
117
+ async addAsComponentIssue(components) {
118
+ const result = await this.runInsight();
119
+
120
+ if (!result.data.length) {
121
+ return; // no circulars
122
+ }
123
+
124
+ const allIds = (0, _lodash().uniq)(result.data.flat());
125
+ const componentsWithCircular = components.filter(component => allIds.includes(component.id.toString()));
126
+ componentsWithCircular.forEach(component => {
127
+ component.state.issues.getOrCreate(_componentIssues().IssuesClasses.CircularDependencies).data = true;
128
+ });
129
+ }
130
+
93
131
  }
94
132
 
95
133
  exports.default = FindCycles;
@@ -1 +1 @@
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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,YAAY,GAAG,qBAArB;;;AAEQ,MAAMC,UAAN,CAAoC;AAIjDC,EAAAA,WAAW,CAACC,YAAD,EAA6B;AAAA,kDAHjCH,YAGiC;AAAA,yDAF1B,gDAE0B;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,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@teambit/graph';\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"]}
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","issues","getOrCreate","IssuesClasses","CircularDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,YAAY,GAAG,qBAArB;;;AAEQ,MAAMC,UAAN,CAAoC;AAIjDC,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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"]}
package/dist/insight.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Component } from '@teambit/component';
1
2
  export declare type InsightMetaData = {
2
3
  name: string;
3
4
  description: string;
@@ -19,4 +20,9 @@ export interface Insight {
19
20
  * runs a specific insight using _runInsight, gets a RawResult, and uses _formatData to transform the output to InsightResult.
20
21
  */
21
22
  run(...args: any[]): Promise<InsightResult>;
23
+ /**
24
+ * add the results from the insights as a component-issue so then bit-status could show them and bit-tag could block
25
+ * them.
26
+ */
27
+ addAsComponentIssue?(components: Component[]): Promise<void>;
22
28
  }
@@ -1,19 +1,18 @@
1
1
  import { Command, CommandOptions } from '@teambit/cli';
2
2
  import { InsightResult } from './insight';
3
- import { InsightManager } from './insight-manager';
3
+ import { InsightsMain } from './insights.main.runtime';
4
4
  export default class InsightsCmd implements Command {
5
+ private insights;
5
6
  name: string;
6
7
  description: string;
7
8
  group: string;
8
9
  private: boolean;
9
10
  options: CommandOptions;
10
- insightManager: InsightManager;
11
- constructor(insightManager: InsightManager);
12
- report(names: [string[]], options: {
11
+ constructor(insights: InsightsMain);
12
+ report([names]: [string[]], options: {
13
13
  list: boolean;
14
14
  }): Promise<string>;
15
- json(names: [string[]], { list }: {
15
+ json([names]: [string[]], { list }: {
16
16
  list: boolean;
17
17
  }): Promise<string[] | InsightResult[]>;
18
- private runInsights;
19
18
  }
@@ -32,53 +32,40 @@ function _chalk() {
32
32
  }
33
33
 
34
34
  class InsightsCmd {
35
- constructor(insightManager) {
36
- (0, _defineProperty2().default)(this, "name", 'insights [...names]');
35
+ constructor(insights) {
36
+ this.insights = insights;
37
+ (0, _defineProperty2().default)(this, "name", 'insights [names...]');
37
38
  (0, _defineProperty2().default)(this, "description", 'Insights on component graph');
38
39
  (0, _defineProperty2().default)(this, "group", 'development');
39
40
  (0, _defineProperty2().default)(this, "private", true);
40
41
  (0, _defineProperty2().default)(this, "options", [['l', 'list', 'list all insights'], ['j', 'json', 'return the insights in json format']]);
41
- (0, _defineProperty2().default)(this, "insightManager", void 0);
42
- this.insightManager = insightManager;
43
42
  }
44
43
 
45
- async report(names, options) {
44
+ async report([names], options) {
46
45
  if (options.list) {
47
- const results = await this.json(names, options);
46
+ const results = await this.json([names], options);
48
47
  return JSON.stringify(results, null, 2);
49
48
  }
50
49
 
51
- const results = await this.runInsights(names, {
50
+ const results = await this.insights.runInsights(names, {
52
51
  renderData: true
53
52
  });
54
53
  return template(results);
55
54
  }
56
55
 
57
- async json(names, {
56
+ async json([names], {
58
57
  list
59
58
  }) {
60
59
  if (list) {
61
- const results = this.insightManager.listInsights();
60
+ const results = this.insights.listInsights();
62
61
  return results;
63
62
  }
64
63
 
65
- return this.runInsights(names, {
64
+ return this.insights.runInsights(names, {
66
65
  renderData: false
67
66
  });
68
67
  }
69
68
 
70
- async runInsights([names], opts) {
71
- if (names) {
72
- let results = [];
73
- const namesArr = typeof names === 'string' ? [names] : names;
74
- results = await this.insightManager.run(namesArr, opts);
75
- return results;
76
- }
77
-
78
- const results = await this.insightManager.runAll(opts);
79
- return results;
80
- }
81
-
82
69
  }
83
70
 
84
71
  exports.default = InsightsCmd;
@@ -1 +1 @@
1
- {"version":3,"sources":["insights.cmd.ts"],"names":["InsightsCmd","constructor","insightManager","report","names","options","list","results","json","JSON","stringify","runInsights","renderData","template","listInsights","opts","namesArr","run","runAll","elements","map","result","chalk","cyan","bold","message","renderedData","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKe,MAAMA,WAAN,CAAqC;AAUlDC,EAAAA,WAAW,CAACC,cAAD,EAAiC;AAAA,kDATrC,qBASqC;AAAA,yDAR9B,6BAQ8B;AAAA,mDAPpC,aAOoC;AAAA,qDANlC,IAMkC;AAAA,qDALlC,CACR,CAAC,GAAD,EAAM,MAAN,EAAc,mBAAd,CADQ,EAER,CAAC,GAAD,EAAM,MAAN,EAAc,oCAAd,CAFQ,CAKkC;AAAA;AAC1C,SAAKA,cAAL,GAAsBA,cAAtB;AACD;;AAEW,QAANC,MAAM,CAACC,KAAD,EAAoBC,OAApB,EAAiE;AAC3E,QAAIA,OAAO,CAACC,IAAZ,EAAkB;AAChB,YAAMC,OAAO,GAAG,MAAM,KAAKC,IAAL,CAAUJ,KAAV,EAAiBC,OAAjB,CAAtB;AACA,aAAOI,IAAI,CAACC,SAAL,CAAeH,OAAf,EAAwB,IAAxB,EAA8B,CAA9B,CAAP;AACD;;AACD,UAAMA,OAAO,GAAG,MAAM,KAAKI,WAAL,CAAiBP,KAAjB,EAAwB;AAAEQ,MAAAA,UAAU,EAAE;AAAd,KAAxB,CAAtB;AACA,WAAOC,QAAQ,CAACN,OAAD,CAAf;AACD;;AAES,QAAJC,IAAI,CAACJ,KAAD,EAAoB;AAAEE,IAAAA;AAAF,GAApB,EAAiD;AACzD,QAAIA,IAAJ,EAAU;AACR,YAAMC,OAAO,GAAG,KAAKL,cAAL,CAAoBY,YAApB,EAAhB;AACA,aAAOP,OAAP;AACD;;AACD,WAAO,KAAKI,WAAL,CAAiBP,KAAjB,EAAwB;AAAEQ,MAAAA,UAAU,EAAE;AAAd,KAAxB,CAAP;AACD;;AAEwB,QAAXD,WAAW,CAAC,CAACP,KAAD,CAAD,EAAsBW,IAAtB,EAA+C;AACtE,QAAIX,KAAJ,EAAW;AACT,UAAIG,OAAwB,GAAG,EAA/B;AACA,YAAMS,QAAQ,GAAG,OAAOZ,KAAP,KAAiB,QAAjB,GAA4B,CAACA,KAAD,CAA5B,GAAsCA,KAAvD;AACAG,MAAAA,OAAO,GAAG,MAAM,KAAKL,cAAL,CAAoBe,GAApB,CAAwBD,QAAxB,EAAkCD,IAAlC,CAAhB;AACA,aAAOR,OAAP;AACD;;AACD,UAAMA,OAAO,GAAG,MAAM,KAAKL,cAAL,CAAoBgB,MAApB,CAA2BH,IAA3B,CAAtB;AACA,WAAOR,OAAP;AACD;;AAxCiD;;;;AA2CpD,SAASM,QAAT,CAAkBN,OAAlB,EAAoD;AAClD,QAAMY,QAAQ,GAAGZ,OAAO,CACrBa,GADc,CACTC,MAAD,IAAY;AACf,WAAQ,KAAIC,iBAAMC,IAAN,CAAWC,IAAX,CAAgBH,MAAM,CAACI,OAAvB,CAAgC;AAClD,IAAIJ,MAAM,CAACK,YAAa,EADlB;AAED,GAJc,EAKdC,IALc,CAKT,IALS,CAAjB;AAMA,SAAOR,QAAP;AACD","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { InsightResult } from './insight';\nimport { InsightManager, RunInsightOptions } from './insight-manager';\n\nexport default class InsightsCmd implements Command {\n name = 'insights [...names]';\n description = 'Insights on component graph';\n group = 'development';\n private = true;\n options = [\n ['l', 'list', 'list all insights'],\n ['j', 'json', 'return the insights in json format'],\n ] as CommandOptions;\n insightManager: InsightManager;\n constructor(insightManager: InsightManager) {\n this.insightManager = insightManager;\n }\n\n async report(names: [string[]], options: { list: boolean }): Promise<string> {\n if (options.list) {\n const results = await this.json(names, options);\n return JSON.stringify(results, null, 2);\n }\n const results = await this.runInsights(names, { renderData: true });\n return template(results);\n }\n\n async json(names: [string[]], { list }: { list: boolean }) {\n if (list) {\n const results = this.insightManager.listInsights();\n return results;\n }\n return this.runInsights(names, { renderData: false });\n }\n\n private async runInsights([names]: [string[]], opts: RunInsightOptions) {\n if (names) {\n let results: InsightResult[] = [];\n const namesArr = typeof names === 'string' ? [names] : names;\n results = await this.insightManager.run(namesArr, opts);\n return results;\n }\n const results = await this.insightManager.runAll(opts);\n return results;\n }\n}\n\nfunction template(results: InsightResult[]): string {\n const elements = results\n .map((result) => {\n return `\\n${chalk.cyan.bold(result.message)}\n ${result.renderedData}`;\n })\n .join('\\n');\n return elements;\n}\n"]}
1
+ {"version":3,"sources":["insights.cmd.ts"],"names":["InsightsCmd","constructor","insights","report","names","options","list","results","json","JSON","stringify","runInsights","renderData","template","listInsights","elements","map","result","chalk","cyan","bold","message","renderedData","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKe,MAAMA,WAAN,CAAqC;AASlDC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,kDARrC,qBAQqC;AAAA,yDAP9B,6BAO8B;AAAA,mDANpC,aAMoC;AAAA,qDALlC,IAKkC;AAAA,qDAJlC,CACR,CAAC,GAAD,EAAM,MAAN,EAAc,mBAAd,CADQ,EAER,CAAC,GAAD,EAAM,MAAN,EAAc,oCAAd,CAFQ,CAIkC;AAAE;;AAElC,QAANC,MAAM,CAAC,CAACC,KAAD,CAAD,EAAsBC,OAAtB,EAAmE;AAC7E,QAAIA,OAAO,CAACC,IAAZ,EAAkB;AAChB,YAAMC,OAAO,GAAG,MAAM,KAAKC,IAAL,CAAU,CAACJ,KAAD,CAAV,EAAmBC,OAAnB,CAAtB;AACA,aAAOI,IAAI,CAACC,SAAL,CAAeH,OAAf,EAAwB,IAAxB,EAA8B,CAA9B,CAAP;AACD;;AACD,UAAMA,OAAO,GAAG,MAAM,KAAKL,QAAL,CAAcS,WAAd,CAA0BP,KAA1B,EAAiC;AAAEQ,MAAAA,UAAU,EAAE;AAAd,KAAjC,CAAtB;AACA,WAAOC,QAAQ,CAACN,OAAD,CAAf;AACD;;AAES,QAAJC,IAAI,CAAC,CAACJ,KAAD,CAAD,EAAsB;AAAEE,IAAAA;AAAF,GAAtB,EAAmD;AAC3D,QAAIA,IAAJ,EAAU;AACR,YAAMC,OAAO,GAAG,KAAKL,QAAL,CAAcY,YAAd,EAAhB;AACA,aAAOP,OAAP;AACD;;AACD,WAAO,KAAKL,QAAL,CAAcS,WAAd,CAA0BP,KAA1B,EAAiC;AAAEQ,MAAAA,UAAU,EAAE;AAAd,KAAjC,CAAP;AACD;;AA1BiD;;;;AA6BpD,SAASC,QAAT,CAAkBN,OAAlB,EAAoD;AAClD,QAAMQ,QAAQ,GAAGR,OAAO,CACrBS,GADc,CACTC,MAAD,IAAY;AACf,WAAQ,KAAIC,iBAAMC,IAAN,CAAWC,IAAX,CAAgBH,MAAM,CAACI,OAAvB,CAAgC;AAClD,IAAIJ,MAAM,CAACK,YAAa,EADlB;AAED,GAJc,EAKdC,IALc,CAKT,IALS,CAAjB;AAMA,SAAOR,QAAP;AACD","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { InsightResult } from './insight';\nimport { InsightsMain } from './insights.main.runtime';\n\nexport default class InsightsCmd implements Command {\n name = 'insights [names...]';\n description = 'Insights on component graph';\n group = 'development';\n private = true;\n options = [\n ['l', 'list', 'list all insights'],\n ['j', 'json', 'return the insights in json format'],\n ] as CommandOptions;\n constructor(private insights: InsightsMain) {}\n\n async report([names]: [string[]], options: { list: boolean }): Promise<string> {\n if (options.list) {\n const results = await this.json([names], options);\n return JSON.stringify(results, null, 2);\n }\n const results = await this.insights.runInsights(names, { renderData: true });\n return template(results);\n }\n\n async json([names]: [string[]], { list }: { list: boolean }) {\n if (list) {\n const results = this.insights.listInsights();\n return results;\n }\n return this.insights.runInsights(names, { renderData: false });\n }\n}\n\nfunction template(results: InsightResult[]): string {\n const elements = results\n .map((result) => {\n return `\\n${chalk.cyan.bold(result.message)}\n ${result.renderedData}`;\n })\n .join('\\n');\n return elements;\n}\n"]}
@@ -1,10 +1,20 @@
1
- import { provide } from './insight.provider';
2
- export declare const InsightsMain: {
3
- runtime: import("@teambit/harmony").RuntimeDefinition;
4
- name: string;
5
- dependencies: import("@teambit/harmony").Aspect[];
6
- config: {
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { GraphBuilder } from '@teambit/graph';
3
+ import { Component } from '@teambit/component';
4
+ import { InsightResult } from './insight';
5
+ import { InsightManager, RunInsightOptions } from './insight-manager';
6
+ export declare type InsightDeps = [GraphBuilder, CLIMain];
7
+ export declare class InsightsMain {
8
+ private insightManager;
9
+ constructor(insightManager: InsightManager);
10
+ runInsights(names: string[], opts: RunInsightOptions): Promise<InsightResult[]>;
11
+ listInsights(): string[];
12
+ addInsightsAsComponentIssues(components: Component[], insightNames?: string[]): Promise<void>;
13
+ static slots: never[];
14
+ static dependencies: import("@teambit/harmony").Aspect[];
15
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
16
+ static config: {
7
17
  silence: boolean;
8
18
  };
9
- provider: typeof provide;
10
- };
19
+ static provider([graphBuilder, cli]: InsightDeps): Promise<InsightsMain>;
20
+ }
@@ -1,10 +1,26 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ require("core-js/modules/es.array.iterator.js");
6
+
7
+ require("core-js/modules/es.promise.js");
8
+
3
9
  Object.defineProperty(exports, "__esModule", {
4
10
  value: true
5
11
  });
6
12
  exports.InsightsMain = void 0;
7
13
 
14
+ function _defineProperty2() {
15
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+
17
+ _defineProperty2 = function () {
18
+ return data;
19
+ };
20
+
21
+ return data;
22
+ }
23
+
8
24
  function _cli() {
9
25
  const data = require("@teambit/cli");
10
26
 
@@ -25,10 +41,10 @@ function _graph() {
25
41
  return data;
26
42
  }
27
43
 
28
- function _insight() {
29
- const data = require("./insight.provider");
44
+ function _pMapSeries() {
45
+ const data = _interopRequireDefault(require("p-map-series"));
30
46
 
31
- _insight = function () {
47
+ _pMapSeries = function () {
32
48
  return data;
33
49
  };
34
50
 
@@ -45,16 +61,87 @@ function _insights() {
45
61
  return data;
46
62
  }
47
63
 
48
- const InsightsMain = {
49
- runtime: _cli().MainRuntime,
50
- name: 'insights',
51
- dependencies: [_graph().GraphAspect, _cli().CLIAspect],
52
- config: {
53
- silence: false
54
- },
55
- provider: _insight().provide
56
- };
64
+ function _coreInsightsGetter() {
65
+ const data = _interopRequireDefault(require("./core-insights-getter"));
66
+
67
+ _coreInsightsGetter = function () {
68
+ return data;
69
+ };
70
+
71
+ return data;
72
+ }
73
+
74
+ function _insightManager() {
75
+ const data = require("./insight-manager");
76
+
77
+ _insightManager = function () {
78
+ return data;
79
+ };
80
+
81
+ return data;
82
+ }
83
+
84
+ function _insights2() {
85
+ const data = _interopRequireDefault(require("./insights.cmd"));
86
+
87
+ _insights2 = function () {
88
+ return data;
89
+ };
90
+
91
+ return data;
92
+ }
93
+
94
+ class InsightsMain {
95
+ constructor(insightManager) {
96
+ this.insightManager = insightManager;
97
+ }
98
+
99
+ async runInsights(names, opts) {
100
+ if (names) {
101
+ let results = [];
102
+ const namesArr = typeof names === 'string' ? [names] : names;
103
+ results = await this.insightManager.run(namesArr, opts);
104
+ return results;
105
+ }
106
+
107
+ const results = await this.insightManager.runAll(opts);
108
+ return results;
109
+ }
110
+
111
+ listInsights() {
112
+ return this.insightManager.listInsights();
113
+ }
114
+
115
+ async addInsightsAsComponentIssues(components, insightNames = this.listInsights()) {
116
+ const insights = insightNames.map(name => this.insightManager.getByName(name));
117
+ await (0, _pMapSeries().default)(insights, async insight => {
118
+ if (insight && insight.addAsComponentIssue) {
119
+ await insight.addAsComponentIssue(components);
120
+ }
121
+ });
122
+ }
123
+
124
+ static async provider([graphBuilder, cli]) {
125
+ // get all insights from registry
126
+ const initialInsights = (0, _coreInsightsGetter().default)(graphBuilder); // register all insights in cli
127
+ // TODO - get user-defined insights as well, and use them when instantiating InsightManager and InsightsCmd
128
+
129
+ const insightManager = new (_insightManager().InsightManager)(initialInsights);
130
+ const insightsMain = new InsightsMain(insightManager);
131
+ const insightsCmd = new (_insights2().default)(insightsMain);
132
+ cli.register(insightsCmd);
133
+ return insightsMain;
134
+ }
135
+
136
+ }
137
+
57
138
  exports.InsightsMain = InsightsMain;
139
+ (0, _defineProperty2().default)(InsightsMain, "slots", []);
140
+ (0, _defineProperty2().default)(InsightsMain, "dependencies", [_graph().GraphAspect, _cli().CLIAspect]);
141
+ (0, _defineProperty2().default)(InsightsMain, "runtime", _cli().MainRuntime);
142
+ (0, _defineProperty2().default)(InsightsMain, "config", {
143
+ silence: false
144
+ });
58
145
 
59
146
  _insights().InsightsAspect.addRuntime(InsightsMain);
60
147
 
@@ -1 +1 @@
1
- {"version":3,"sources":["insights.main.runtime.ts"],"names":["InsightsMain","runtime","MainRuntime","name","dependencies","GraphAspect","CLIAspect","config","silence","provider","provide","InsightsAspect","addRuntime"],"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;;AAEO,MAAMA,YAAY,GAAG;AAC1BC,EAAAA,OAAO,EAAEC,kBADiB;AAE1BC,EAAAA,IAAI,EAAE,UAFoB;AAG1BC,EAAAA,YAAY,EAAE,CAACC,oBAAD,EAAcC,gBAAd,CAHY;AAI1BC,EAAAA,MAAM,EAAE;AACNC,IAAAA,OAAO,EAAE;AADH,GAJkB;AAO1BC,EAAAA,QAAQ,EAAEC;AAPgB,CAArB;;;AAUPC,2BAAeC,UAAf,CAA0BZ,YAA1B","sourcesContent":["import { CLIAspect, MainRuntime } from '@teambit/cli';\nimport { GraphAspect } from '@teambit/graph';\n\nimport { provide } from './insight.provider';\nimport { InsightsAspect } from './insights.aspect';\n\nexport const InsightsMain = {\n runtime: MainRuntime,\n name: 'insights',\n dependencies: [GraphAspect, CLIAspect],\n config: {\n silence: false,\n },\n provider: provide,\n};\n\nInsightsAspect.addRuntime(InsightsMain);\n"]}
1
+ {"version":3,"sources":["insights.main.runtime.ts"],"names":["InsightsMain","constructor","insightManager","runInsights","names","opts","results","namesArr","run","runAll","listInsights","addInsightsAsComponentIssues","components","insightNames","insights","map","name","getByName","insight","addAsComponentIssue","provider","graphBuilder","cli","initialInsights","InsightManager","insightsMain","insightsCmd","InsightsCmd","register","GraphAspect","CLIAspect","MainRuntime","silence","InsightsAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;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;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,YAAN,CAAmB;AACxBC,EAAAA,WAAW,CAASC,cAAT,EAAyC;AAAA,SAAhCA,cAAgC,GAAhCA,cAAgC;AAAE;;AAErC,QAAXC,WAAW,CAACC,KAAD,EAAkBC,IAAlB,EAA2C;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,WAAb;AACA,WAAOD,YAAP;AACD;;AA3CuB;;;gCAAbzB,Y,WA2BI,E;gCA3BJA,Y,kBA4BW,CAAC6B,oBAAD,EAAcC,gBAAd,C;gCA5BX9B,Y,aA6BM+B,kB;gCA7BN/B,Y,YA8BK;AACdgC,EAAAA,OAAO,EAAE;AADK,C;;AAgBlBC,2BAAeC,UAAf,CAA0BlC,YAA1B","sourcesContent":["import { CLIAspect, MainRuntime, CLIMain } from '@teambit/cli';\nimport { GraphAspect, GraphBuilder } from '@teambit/graph';\nimport pMapSeries from 'p-map-series';\nimport { Component } from '@teambit/component';\nimport { InsightsAspect } from './insights.aspect';\nimport getCoreInsights from './core-insights-getter';\nimport { Insight, InsightResult } from './insight';\nimport { InsightManager, RunInsightOptions } from './insight-manager';\nimport InsightsCmd from './insights.cmd';\n\nexport type InsightDeps = [GraphBuilder, CLIMain];\n\nexport class InsightsMain {\n constructor(private insightManager: InsightManager) {}\n\n async runInsights(names: string[], opts: RunInsightOptions) {\n if (names) {\n let results: InsightResult[] = [];\n const namesArr = typeof names === 'string' ? [names] : names;\n results = await this.insightManager.run(namesArr, opts);\n return results;\n }\n const results = await this.insightManager.runAll(opts);\n return results;\n }\n\n listInsights() {\n return this.insightManager.listInsights();\n }\n\n async addInsightsAsComponentIssues(components: Component[], insightNames: string[] = this.listInsights()) {\n const insights = insightNames.map((name) => this.insightManager.getByName(name));\n await pMapSeries(insights, async (insight) => {\n if (insight && insight.addAsComponentIssue) {\n await insight.addAsComponentIssue(components);\n }\n });\n }\n\n static slots = [];\n static dependencies = [GraphAspect, CLIAspect];\n static runtime = MainRuntime;\n static config = {\n silence: false,\n };\n static async provider([graphBuilder, cli]: InsightDeps) {\n // get all insights from registry\n const initialInsights: Insight[] = getCoreInsights(graphBuilder);\n // register all insights in cli\n // TODO - get user-defined insights as well, and use them when instantiating InsightManager and InsightsCmd\n const insightManager = new InsightManager(initialInsights);\n const insightsMain = new InsightsMain(insightManager);\n const insightsCmd = new InsightsCmd(insightsMain);\n cli.register(insightsCmd);\n return insightsMain;\n }\n}\n\nInsightsAspect.addRuntime(InsightsMain);\n"]}
package/package.json CHANGED
@@ -1,28 +1,31 @@
1
1
  {
2
2
  "name": "@teambit/insights",
3
- "version": "0.0.692",
3
+ "version": "0.0.695",
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.692"
9
+ "version": "0.0.695"
10
10
  },
11
11
  "dependencies": {
12
12
  "p-map-series": "2.1.0",
13
13
  "@teambit/harmony": "0.2.11",
14
14
  "chalk": "2.4.2",
15
15
  "semver": "7.3.4",
16
+ "lodash": "4.17.21",
16
17
  "@babel/runtime": "7.12.18",
17
18
  "core-js": "^3.0.0",
18
- "@teambit/graph": "0.0.692",
19
- "@teambit/cli": "0.0.463",
20
- "@teambit/component": "0.0.692",
19
+ "@teambit/graph": "0.0.695",
20
+ "@teambit/component": "0.0.695",
21
+ "@teambit/cli": "0.0.464",
22
+ "@teambit/component-issues": "0.0.49",
21
23
  "@teambit/bit-error": "0.0.394"
22
24
  },
23
25
  "devDependencies": {
24
26
  "@types/react": "^17.0.8",
25
27
  "@types/semver": "7.3.4",
28
+ "@types/lodash": "4.14.165",
26
29
  "@types/mocha": "9.1.0",
27
30
  "@types/testing-library__jest-dom": "5.9.5",
28
31
  "@types/jest": "^26.0.0",
@@ -30,7 +33,7 @@
30
33
  "@types/node": "12.20.4"
31
34
  },
32
35
  "peerDependencies": {
33
- "@teambit/legacy": "1.0.241",
36
+ "@teambit/legacy": "1.0.242",
34
37
  "react-dom": "^16.8.0 || ^17.0.0",
35
38
  "react": "^16.8.0 || ^17.0.0"
36
39
  },
@@ -58,7 +61,7 @@
58
61
  "react": "-"
59
62
  },
60
63
  "peerDependencies": {
61
- "@teambit/legacy": "1.0.241",
64
+ "@teambit/legacy": "1.0.242",
62
65
  "react-dom": "^16.8.0 || ^17.0.0",
63
66
  "react": "^16.8.0 || ^17.0.0"
64
67
  }
@@ -1 +1 @@
1
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.692/dist/insights.docs.mdx')]
1
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_insights@0.0.695/dist/insights.docs.mdx')]
@@ -1,4 +0,0 @@
1
- import { CLIMain } from '@teambit/cli';
2
- import { GraphBuilder } from '@teambit/graph';
3
- export declare type InsightDeps = [GraphBuilder, CLIMain];
4
- export declare function provide([graphBuilder, cli]: InsightDeps): Promise<void>;
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- require("core-js/modules/es.array.iterator.js");
6
-
7
- require("core-js/modules/es.promise.js");
8
-
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- exports.provide = provide;
13
-
14
- function _coreInsightsGetter() {
15
- const data = _interopRequireDefault(require("./core-insights-getter"));
16
-
17
- _coreInsightsGetter = function () {
18
- return data;
19
- };
20
-
21
- return data;
22
- }
23
-
24
- function _insightManager() {
25
- const data = require("./insight-manager");
26
-
27
- _insightManager = function () {
28
- return data;
29
- };
30
-
31
- return data;
32
- }
33
-
34
- function _insights() {
35
- const data = _interopRequireDefault(require("./insights.cmd"));
36
-
37
- _insights = function () {
38
- return data;
39
- };
40
-
41
- return data;
42
- }
43
-
44
- async function provide([graphBuilder, cli]) {
45
- // get all insights from registry
46
- const initialInsights = (0, _coreInsightsGetter().default)(graphBuilder); // register all insights in cli
47
- // TODO - get user-defined insights as well, and use them when instantiating InsightManager and InsightsCmd
48
-
49
- const insightManager = new (_insightManager().InsightManager)(initialInsights);
50
- const insightsCmd = new (_insights().default)(insightManager);
51
- cli.register(insightsCmd);
52
- }
53
-
54
- //# sourceMappingURL=insight.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["insight.provider.ts"],"names":["provide","graphBuilder","cli","initialInsights","insightManager","InsightManager","insightsCmd","InsightsCmd","register"],"mappings":";;;;;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,eAAeA,OAAf,CAAuB,CAACC,YAAD,EAAeC,GAAf,CAAvB,EAAyD;AAC9D;AACA,QAAMC,eAA0B,GAAG,mCAAgBF,YAAhB,CAAnC,CAF8D,CAG9D;AACA;;AACA,QAAMG,cAAc,GAAG,KAAIC,gCAAJ,EAAmBF,eAAnB,CAAvB;AACA,QAAMG,WAAW,GAAG,KAAIC,mBAAJ,EAAgBH,cAAhB,CAApB;AACAF,EAAAA,GAAG,CAACM,QAAJ,CAAaF,WAAb;AACD","sourcesContent":["import { CLIMain } from '@teambit/cli';\nimport { GraphBuilder } from '@teambit/graph';\n\nimport getCoreInsights from './core-insights-getter';\nimport { Insight } from './insight';\nimport { InsightManager } from './insight-manager';\nimport InsightsCmd from './insights.cmd';\n\nexport type InsightDeps = [GraphBuilder, CLIMain];\n\nexport async function provide([graphBuilder, cli]: InsightDeps) {\n // get all insights from registry\n const initialInsights: Insight[] = getCoreInsights(graphBuilder);\n // register all insights in cli\n // TODO - get user-defined insights as well, and use them when instantiating InsightManager and InsightsCmd\n const insightManager = new InsightManager(initialInsights);\n const insightsCmd = new InsightsCmd(insightManager);\n cli.register(insightsCmd);\n}\n"]}