@teambit/component-issues 0.0.41 → 0.0.45

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.
Files changed (61) hide show
  1. package/component-issue.ts +63 -0
  2. package/custom-module-resolution-used.ts +7 -0
  3. package/dist/component-issue.js +53 -102
  4. package/dist/component-issue.js.map +1 -1
  5. package/dist/custom-module-resolution-used.js +9 -39
  6. package/dist/custom-module-resolution-used.js.map +1 -1
  7. package/dist/import-non-main-files.js +10 -40
  8. package/dist/import-non-main-files.js.map +1 -1
  9. package/dist/index.js +9 -87
  10. package/dist/index.js.map +1 -1
  11. package/dist/issues-list.js +100 -295
  12. package/dist/issues-list.js.map +1 -1
  13. package/dist/legacy-inside-harmony.js +12 -44
  14. package/dist/legacy-inside-harmony.js.map +1 -1
  15. package/dist/missing-components.js +12 -43
  16. package/dist/missing-components.js.map +1 -1
  17. package/dist/missing-custom-module-resolution-links.js +9 -39
  18. package/dist/missing-custom-module-resolution-links.js.map +1 -1
  19. package/dist/missing-dependencies-on-fs.js +9 -39
  20. package/dist/missing-dependencies-on-fs.js.map +1 -1
  21. package/dist/missing-dists.js +12 -44
  22. package/dist/missing-dists.js.map +1 -1
  23. package/dist/missing-links-from-nm-to-src.js +12 -44
  24. package/dist/missing-links-from-nm-to-src.js.map +1 -1
  25. package/dist/missing-links.js +12 -43
  26. package/dist/missing-links.js.map +1 -1
  27. package/dist/missing-packages-dependencies-on-fs.js +9 -39
  28. package/dist/missing-packages-dependencies-on-fs.js.map +1 -1
  29. package/dist/multiple-envs.js +12 -44
  30. package/dist/multiple-envs.js.map +1 -1
  31. package/dist/parse-errors.js +9 -39
  32. package/dist/parse-errors.js.map +1 -1
  33. package/dist/relative-components-authored.js +25 -67
  34. package/dist/relative-components-authored.js.map +1 -1
  35. package/dist/relative-components.js +13 -44
  36. package/dist/relative-components.js.map +1 -1
  37. package/dist/resolve-errors.js +9 -39
  38. package/dist/resolve-errors.js.map +1 -1
  39. package/dist/untracked-dependencies.js +32 -73
  40. package/dist/untracked-dependencies.js.map +1 -1
  41. package/import-non-main-files.ts +8 -0
  42. package/index.ts +4 -0
  43. package/issues-list.ts +124 -0
  44. package/legacy-inside-harmony.ts +11 -0
  45. package/missing-components.ts +11 -0
  46. package/missing-custom-module-resolution-links.ts +7 -0
  47. package/missing-dependencies-on-fs.ts +7 -0
  48. package/missing-dists.ts +11 -0
  49. package/missing-links-from-nm-to-src.ts +11 -0
  50. package/missing-links.ts +11 -0
  51. package/missing-packages-dependencies-on-fs.ts +7 -0
  52. package/multiple-envs.ts +12 -0
  53. package/package-tar/teambit-component-issues-0.0.45.tgz +0 -0
  54. package/package.json +9 -36
  55. package/parse-errors.ts +7 -0
  56. package/relative-components-authored.ts +37 -0
  57. package/relative-components.ts +12 -0
  58. package/resolve-errors.ts +7 -0
  59. package/tsconfig.json +5 -13
  60. package/untracked-dependencies.ts +41 -0
  61. package/package-tar/teambit-component-issues-0.0.41.tgz +0 -0
@@ -1,44 +1,14 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- require("core-js/modules/es.array.iterator.js");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
10
3
  exports.ResolveErrors = void 0;
11
-
12
- function _defineProperty2() {
13
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
- _defineProperty2 = function () {
16
- return data;
17
- };
18
-
19
- return data;
4
+ const component_issue_1 = require("./component-issue");
5
+ class ResolveErrors extends component_issue_1.ComponentIssue {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.description = 'error found while resolving the file dependencies';
9
+ this.solution = 'see the log for the full error';
10
+ this.data = {};
11
+ }
20
12
  }
21
-
22
- function _componentIssue() {
23
- const data = require("./component-issue");
24
-
25
- _componentIssue = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- class ResolveErrors extends _componentIssue().ComponentIssue {
33
- constructor(...args) {
34
- super(...args);
35
- (0, _defineProperty2().default)(this, "description", 'error found while resolving the file dependencies');
36
- (0, _defineProperty2().default)(this, "solution", 'see the log for the full error');
37
- (0, _defineProperty2().default)(this, "data", {});
38
- }
39
-
40
- }
41
-
42
13
  exports.ResolveErrors = ResolveErrors;
43
-
44
14
  //# sourceMappingURL=resolve-errors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["resolve-errors.ts"],"names":["ResolveErrors","ComponentIssue"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,aAAN,SAA4BC,gCAA5B,CAA2C;AAAA;AAAA;AAAA,yDAClC,mDADkC;AAAA,sDAErC,gCAFqC;AAAA,kDAGT,EAHS;AAAA;;AAAA","sourcesContent":["import { ComponentIssue } from './component-issue';\n\nexport class ResolveErrors extends ComponentIssue {\n description = 'error found while resolving the file dependencies';\n solution = 'see the log for the full error';\n data: { [filePath: string]: string } = {};\n}\n"]}
1
+ {"version":3,"file":"resolve-errors.js","sourceRoot":"","sources":["../resolve-errors.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAEnD,MAAa,aAAc,SAAQ,gCAAc;IAAjD;;QACE,gBAAW,GAAG,mDAAmD,CAAC;QAClE,aAAQ,GAAG,gCAAgC,CAAC;QAC5C,SAAI,GAAmC,EAAE,CAAC;IAC5C,CAAC;CAAA;AAJD,sCAIC"}
@@ -1,80 +1,39 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- require("core-js/modules/es.array.iterator.js");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
10
6
  exports.UntrackedDependencies = exports.MISSING_NESTED_DEPS_SPACE = void 0;
11
-
12
- function _defineProperty2() {
13
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
- _defineProperty2 = function () {
16
- return data;
17
- };
18
-
19
- return data;
20
- }
21
-
22
- function _chalk() {
23
- const data = _interopRequireDefault(require("chalk"));
24
-
25
- _chalk = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- function _componentIssue() {
33
- const data = require("./component-issue");
34
-
35
- _componentIssue = function () {
36
- return data;
37
- };
38
-
39
- return data;
40
- }
41
-
42
- const MISSING_NESTED_DEPS_SPACE = ' '.repeat(_componentIssue().ISSUE_FORMAT_SPACE_COUNT + 2);
43
- exports.MISSING_NESTED_DEPS_SPACE = MISSING_NESTED_DEPS_SPACE;
44
-
45
- class UntrackedDependencies extends _componentIssue().ComponentIssue {
46
- constructor(...args) {
47
- super(...args);
48
- (0, _defineProperty2().default)(this, "description", 'untracked file dependencies');
49
- (0, _defineProperty2().default)(this, "solution", 'use "bit add <file>" to track untracked files as components');
50
- (0, _defineProperty2().default)(this, "data", {});
51
- }
52
-
53
- dataToString() {
54
- return Object.keys(this.data).map(k => {
55
- let space = _componentIssue().ISSUE_FORMAT_SPACE;
56
-
57
- if (this.data[k].nested) {
58
- space = MISSING_NESTED_DEPS_SPACE;
59
- }
60
-
61
- return `${space}${k} -> ${untrackedFilesComponentIssueToString(this.data[k])}`;
62
- }).join('\n');
63
- }
64
-
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const component_issue_1 = require("./component-issue");
9
+ exports.MISSING_NESTED_DEPS_SPACE = ' '.repeat(component_issue_1.ISSUE_FORMAT_SPACE_COUNT + 2);
10
+ class UntrackedDependencies extends component_issue_1.ComponentIssue {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.description = 'untracked file dependencies';
14
+ this.solution = 'use "bit add <file>" to track untracked files as components';
15
+ this.data = {};
16
+ }
17
+ dataToString() {
18
+ return Object.keys(this.data)
19
+ .map((k) => {
20
+ let space = component_issue_1.ISSUE_FORMAT_SPACE;
21
+ if (this.data[k].nested) {
22
+ space = exports.MISSING_NESTED_DEPS_SPACE;
23
+ }
24
+ return `${space}${k} -> ${untrackedFilesComponentIssueToString(this.data[k])}`;
25
+ })
26
+ .join('\n');
27
+ }
65
28
  }
66
-
67
29
  exports.UntrackedDependencies = UntrackedDependencies;
68
-
69
30
  function untrackedFilesComponentIssueToString(value) {
70
- const colorizedMap = value.untrackedFiles.map(curr => {
71
- if (curr.existing) {
72
- return `${_chalk().default.yellow(curr.relativePath)}`;
73
- }
74
-
75
- return curr.relativePath;
76
- });
77
- return colorizedMap.join(', ');
31
+ const colorizedMap = value.untrackedFiles.map((curr) => {
32
+ if (curr.existing) {
33
+ return `${chalk_1.default.yellow(curr.relativePath)}`;
34
+ }
35
+ return curr.relativePath;
36
+ });
37
+ return colorizedMap.join(', ');
78
38
  }
79
-
80
39
  //# sourceMappingURL=untracked-dependencies.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["untracked-dependencies.ts"],"names":["MISSING_NESTED_DEPS_SPACE","repeat","ISSUE_FORMAT_SPACE_COUNT","UntrackedDependencies","ComponentIssue","dataToString","Object","keys","data","map","k","space","ISSUE_FORMAT_SPACE","nested","untrackedFilesComponentIssueToString","join","value","colorizedMap","untrackedFiles","curr","existing","chalk","yellow","relativePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,yBAAyB,GAAG,IAAIC,MAAJ,CAAWC,6CAA2B,CAAtC,CAAlC;;;AAYA,MAAMC,qBAAN,SAAoCC,gCAApC,CAAmD;AAAA;AAAA;AAAA,yDAC1C,6BAD0C;AAAA,sDAE7C,6DAF6C;AAAA,kDAGK,EAHL;AAAA;;AAIxDC,EAAAA,YAAY,GAAG;AACb,WAAOC,MAAM,CAACC,IAAP,CAAY,KAAKC,IAAjB,EACJC,GADI,CACCC,CAAD,IAAO;AACV,UAAIC,KAAK,GAAGC,oCAAZ;;AACA,UAAI,KAAKJ,IAAL,CAAUE,CAAV,EAAaG,MAAjB,EAAyB;AACvBF,QAAAA,KAAK,GAAGX,yBAAR;AACD;;AACD,aAAQ,GAAEW,KAAM,GAAED,CAAE,OAAMI,oCAAoC,CAAC,KAAKN,IAAL,CAAUE,CAAV,CAAD,CAAe,EAA7E;AACD,KAPI,EAQJK,IARI,CAQC,IARD,CAAP;AASD;;AAduD;;;;AAiB1D,SAASD,oCAAT,CAA8CE,KAA9C,EAAmF;AACjF,QAAMC,YAAY,GAAGD,KAAK,CAACE,cAAN,CAAqBT,GAArB,CAA0BU,IAAD,IAAU;AACtD,QAAIA,IAAI,CAACC,QAAT,EAAmB;AACjB,aAAQ,GAAEC,iBAAMC,MAAN,CAAaH,IAAI,CAACI,YAAlB,CAAgC,EAA1C;AACD;;AACD,WAAOJ,IAAI,CAACI,YAAZ;AACD,GALoB,CAArB;AAMA,SAAON,YAAY,CAACF,IAAb,CAAkB,IAAlB,CAAP;AACD","sourcesContent":["import chalk from 'chalk';\nimport { ComponentIssue, ISSUE_FORMAT_SPACE, ISSUE_FORMAT_SPACE_COUNT } from './component-issue';\n\nexport const MISSING_NESTED_DEPS_SPACE = ' '.repeat(ISSUE_FORMAT_SPACE_COUNT + 2);\n\ninterface UntrackedFileEntry {\n relativePath: string;\n existing: boolean;\n}\n\nexport interface UntrackedFileDependencyEntry {\n nested: boolean;\n untrackedFiles: Array<UntrackedFileEntry>;\n}\n\nexport class UntrackedDependencies extends ComponentIssue {\n description = 'untracked file dependencies';\n solution = 'use \"bit add <file>\" to track untracked files as components';\n data: { [filePath: string]: UntrackedFileDependencyEntry } = {};\n dataToString() {\n return Object.keys(this.data)\n .map((k) => {\n let space = ISSUE_FORMAT_SPACE;\n if (this.data[k].nested) {\n space = MISSING_NESTED_DEPS_SPACE;\n }\n return `${space}${k} -> ${untrackedFilesComponentIssueToString(this.data[k])}`;\n })\n .join('\\n');\n }\n}\n\nfunction untrackedFilesComponentIssueToString(value: UntrackedFileDependencyEntry) {\n const colorizedMap = value.untrackedFiles.map((curr) => {\n if (curr.existing) {\n return `${chalk.yellow(curr.relativePath)}`;\n }\n return curr.relativePath;\n });\n return colorizedMap.join(', ');\n}\n"]}
1
+ {"version":3,"file":"untracked-dependencies.js","sourceRoot":"","sources":["../untracked-dependencies.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,uDAAiG;AAEpF,QAAA,yBAAyB,GAAG,GAAG,CAAC,MAAM,CAAC,0CAAwB,GAAG,CAAC,CAAC,CAAC;AAYlF,MAAa,qBAAsB,SAAQ,gCAAc;IAAzD;;QACE,gBAAW,GAAG,6BAA6B,CAAC;QAC5C,aAAQ,GAAG,6DAA6D,CAAC;QACzE,SAAI,GAAyD,EAAE,CAAC;IAYlE,CAAC;IAXC,YAAY;QACV,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;aAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,IAAI,KAAK,GAAG,oCAAkB,CAAC;YAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;gBACvB,KAAK,GAAG,iCAAyB,CAAC;aACnC;YACD,OAAO,GAAG,KAAK,GAAG,CAAC,OAAO,oCAAoC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF;AAfD,sDAeC;AAED,SAAS,oCAAoC,CAAC,KAAmC;IAC/E,MAAM,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,GAAG,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;SAC7C;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ComponentIssue, StringsPerFilePath } from './component-issue';
2
+
3
+ export class ImportNonMainFiles extends ComponentIssue {
4
+ description = 'importing non-main files';
5
+ solution = 'the dependency should expose its API from the main file';
6
+ data: StringsPerFilePath = {};
7
+ isCacheBlocker = false;
8
+ }
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { IssuesList, IssuesClasses, IssuesNames } from './issues-list';
2
+ export { ISSUE_FORMAT_SPACE as MISSING_DEPS_SPACE } from './component-issue';
3
+ export { UntrackedFileDependencyEntry, MISSING_NESTED_DEPS_SPACE } from './untracked-dependencies';
4
+ export { RelativeComponentsAuthoredEntry } from './relative-components-authored';
package/issues-list.ts ADDED
@@ -0,0 +1,124 @@
1
+ import { ComponentIssue } from './component-issue';
2
+ import { CustomModuleResolutionUsed } from './custom-module-resolution-used';
3
+ import { ImportNonMainFiles } from './import-non-main-files';
4
+ import { MissingComponents } from './missing-components';
5
+ import { MissingCustomModuleResolutionLinks } from './missing-custom-module-resolution-links';
6
+ import { MissingDependenciesOnFs } from './missing-dependencies-on-fs';
7
+ import { MissingDists } from './missing-dists';
8
+ import { MissingLinks } from './missing-links';
9
+ import { MissingPackagesDependenciesOnFs } from './missing-packages-dependencies-on-fs';
10
+ import { ParseErrors } from './parse-errors';
11
+ import { relativeComponents } from './relative-components';
12
+ import { relativeComponentsAuthored } from './relative-components-authored';
13
+ import { ResolveErrors } from './resolve-errors';
14
+ import { UntrackedDependencies } from './untracked-dependencies';
15
+ import { LegacyInsideHarmony } from './legacy-inside-harmony';
16
+ import { MultipleEnvs } from './multiple-envs';
17
+ import { MissingLinksFromNodeModulesToSrc } from './missing-links-from-nm-to-src';
18
+
19
+ export const IssuesClasses = {
20
+ MissingPackagesDependenciesOnFs,
21
+ MissingComponents,
22
+ UntrackedDependencies,
23
+ ResolveErrors,
24
+ relativeComponents,
25
+ relativeComponentsAuthored,
26
+ ParseErrors,
27
+ MissingLinks,
28
+ MissingDists,
29
+ LegacyInsideHarmony,
30
+ MissingDependenciesOnFs,
31
+ MissingCustomModuleResolutionLinks,
32
+ ImportNonMainFiles,
33
+ CustomModuleResolutionUsed,
34
+ MultipleEnvs,
35
+ MissingLinksFromNodeModulesToSrc,
36
+ };
37
+ export type IssuesNames = keyof typeof IssuesClasses;
38
+
39
+ export class IssuesList {
40
+ constructor(private issues: ComponentIssue[] = []) {}
41
+
42
+ get count() {
43
+ return this.issues.length;
44
+ }
45
+
46
+ isEmpty() {
47
+ return this.issues.length === 0;
48
+ }
49
+
50
+ outputForCLI() {
51
+ return this.issues.map((issue) => issue.outputForCLI()).join('');
52
+ }
53
+
54
+ toObject(): { type: string; description: string; data: any }[] {
55
+ return this.issues.map((issue) => issue.toObject());
56
+ }
57
+
58
+ toObjectWithDataAsString(): { type: string; description: string; data: string }[] {
59
+ return this.issues.map((issue) => ({
60
+ ...issue.toObject(),
61
+ data: issue.dataToString().trim(),
62
+ }));
63
+ }
64
+
65
+ add(issue: ComponentIssue) {
66
+ this.issues.push(issue);
67
+ }
68
+
69
+ delete(IssueClass: typeof ComponentIssue) {
70
+ this.issues = this.issues.filter((issue) => !(issue instanceof IssueClass));
71
+ }
72
+
73
+ getIssue<T extends ComponentIssue>(IssueClass: { new (): T }): T | undefined {
74
+ return this.issues.find((issue) => issue instanceof IssueClass) as T | undefined;
75
+ }
76
+
77
+ getIssueByName<T extends ComponentIssue>(issueType: IssuesNames): T | undefined {
78
+ return this.issues.find((issue) => issue.constructor.name === issueType) as T | undefined;
79
+ }
80
+
81
+ getAllIssues(): ComponentIssue[] {
82
+ return this.issues;
83
+ }
84
+
85
+ createIssue<T extends ComponentIssue>(IssueClass: { new (): T }): T {
86
+ const newIssue = new IssueClass();
87
+ this.add(newIssue);
88
+ return newIssue;
89
+ }
90
+
91
+ getOrCreate<T extends ComponentIssue>(IssueClass: { new (): T }): T {
92
+ return this.getIssue(IssueClass) || this.createIssue(IssueClass);
93
+ }
94
+
95
+ shouldBlockSavingInCache(): boolean {
96
+ return this.issues.some((issue) => issue.isCacheBlocker);
97
+ }
98
+
99
+ shouldBlockTagging(): boolean {
100
+ return this.issues.some((issue) => issue.isTagBlocker);
101
+ }
102
+
103
+ serialize() {
104
+ return this.issues.map((issue) => ({ type: issue.constructor.name, data: issue.serialize() }));
105
+ }
106
+
107
+ static deserialize(data: Record<string, any>) {
108
+ if (!Array.isArray(data)) {
109
+ // probably old format, ignore it and return an empty IssuesList
110
+ return new IssuesList();
111
+ }
112
+ const issues = data.map((issue) => {
113
+ const ClassName = issue.type;
114
+ if (!Object.keys(IssuesClasses).includes(ClassName)) {
115
+ throw new Error(`issue type "${ClassName}" is not recognized.
116
+ the following are permitted ${Object.keys(IssuesClasses).join(', ')}`);
117
+ }
118
+ const issueInstance: ComponentIssue = new IssuesClasses[ClassName]();
119
+ issueInstance.data = issueInstance.deserialize(issue.data);
120
+ return issueInstance;
121
+ });
122
+ return new IssuesList(issues);
123
+ }
124
+ }
@@ -0,0 +1,11 @@
1
+ import { ComponentIssue, formatTitle } from './component-issue';
2
+
3
+ export class LegacyInsideHarmony extends ComponentIssue {
4
+ description = 'legacy component inside Harmony workspace';
5
+ solution = 'remove the component and re-create it via Harmony';
6
+ data: boolean;
7
+ isTagBlocker = true;
8
+ outputForCLI() {
9
+ return formatTitle(this.descriptionWithSolution, false);
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import { BitId } from '@teambit/legacy-bit-id';
2
+ import { ComponentIssue, deserializeWithBitId } from './component-issue';
3
+
4
+ export class MissingComponents extends ComponentIssue {
5
+ description = 'missing components';
6
+ solution = 'use "bit import" or `bit install` to make sure all components exist';
7
+ data: { [filePath: string]: BitId[] } = {};
8
+ deserialize(data: string) {
9
+ return deserializeWithBitId(data);
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ import { ComponentIssue, StringsPerFilePath } from './component-issue';
2
+
3
+ export class MissingCustomModuleResolutionLinks extends ComponentIssue {
4
+ description = 'missing links';
5
+ solution = 'use "bit link" to build missing component links';
6
+ data: StringsPerFilePath = {};
7
+ }
@@ -0,0 +1,7 @@
1
+ import { ComponentIssue, StringsPerFilePath } from './component-issue';
2
+
3
+ export class MissingDependenciesOnFs extends ComponentIssue {
4
+ description = 'non-existing dependency files';
5
+ solution = 'make sure all files exists on your workspace';
6
+ data: StringsPerFilePath = {};
7
+ }
@@ -0,0 +1,11 @@
1
+ import { ComponentIssue, formatTitle } from './component-issue';
2
+
3
+ export class MissingDists extends ComponentIssue {
4
+ description = 'missing dists';
5
+ solution = 'run "bit compile"';
6
+ data: boolean;
7
+ isTagBlocker = false;
8
+ outputForCLI() {
9
+ return formatTitle(this.descriptionWithSolution, false);
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import { ComponentIssue, formatTitle } from './component-issue';
2
+
3
+ export class MissingLinksFromNodeModulesToSrc extends ComponentIssue {
4
+ description = 'missing links from node_modules to source';
5
+ solution = 'run "bit link"';
6
+ data: boolean;
7
+ isTagBlocker = false;
8
+ outputForCLI() {
9
+ return formatTitle(this.descriptionWithSolution, false);
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import { BitId } from '@teambit/legacy-bit-id';
2
+ import { ComponentIssue, deserializeWithBitId } from './component-issue';
3
+
4
+ export class MissingLinks extends ComponentIssue {
5
+ description = 'missing links between components';
6
+ solution = 'use "bit link" to build missing component links';
7
+ data: { [filePath: string]: BitId[] } = {};
8
+ deserialize(data: string) {
9
+ return deserializeWithBitId(data);
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ import { ComponentIssue, StringsPerFilePath } from './component-issue';
2
+
3
+ export class MissingPackagesDependenciesOnFs extends ComponentIssue {
4
+ description = `missing packages or links from node_modules to the source`;
5
+ solution = `run "bit install" to fix both issues. if it's an external package, make sure it's added as a package dependency`;
6
+ data: StringsPerFilePath = {};
7
+ }
@@ -0,0 +1,12 @@
1
+ import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
2
+
3
+ export class MultipleEnvs extends ComponentIssue {
4
+ description = 'multiple envs';
5
+ solution =
6
+ 'remove the old envs by setting them with "-" sign in the variants. see https://harmony-docs.bit.dev/aspects/variants#removing-aspects ';
7
+ data: string[]; // env ids
8
+ isTagBlocker = true;
9
+ dataToString() {
10
+ return ISSUE_FORMAT_SPACE + this.data.join(', ');
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,59 +1,32 @@
1
1
  {
2
2
  "name": "@teambit/component-issues",
3
- "version": "0.0.41",
3
+ "version": "0.0.45",
4
4
  "homepage": "https://bit.dev/teambit/component/component-issues",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component-issues",
9
- "version": "0.0.41"
9
+ "version": "0.0.45"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
- "@babel/runtime": "7.12.18",
14
- "core-js": "^3.0.0",
15
- "@teambit/legacy-bit-id": "0.0.395"
13
+ "@teambit/legacy-bit-id": "0.0.397"
16
14
  },
17
15
  "devDependencies": {
18
- "@types/mocha": "5.2.7",
19
- "@types/testing-library__jest-dom": "5.9.5",
20
- "@types/jest": "^26.0.0",
21
- "@types/react-dom": "^17.0.5",
22
- "@types/react": "^17.0.8",
23
- "@types/node": "12.20.4"
24
- },
25
- "peerDependencies": {
26
- "@teambit/legacy": "1.0.192",
27
- "react-dom": "^16.8.0 || ^17.0.0",
28
- "react": "^16.8.0 || ^17.0.0"
16
+ "@babel/runtime": "7.12.18",
17
+ "@types/node": "12.20.4",
18
+ "@types/jest": "26.0.20"
29
19
  },
20
+ "peerDependencies": {},
30
21
  "license": "Apache-2.0",
31
22
  "bit": {
32
23
  "bindingPrefix": "@teambit",
33
24
  "env": {},
34
25
  "overrides": {
35
- "dependencies": {
36
- "@teambit/legacy": "-",
37
- "@babel/runtime": "7.12.18",
38
- "core-js": "^3.0.0",
39
- "react-dom": "-",
40
- "react": "-"
41
- },
42
26
  "devDependencies": {
43
- "@teambit/legacy": "-",
44
- "@types/mocha": "5.2.7",
45
- "@types/testing-library__jest-dom": "5.9.5",
46
- "@types/jest": "^26.0.0",
47
- "@types/react-dom": "^17.0.5",
48
- "@types/react": "^17.0.8",
27
+ "@babel/runtime": "7.12.18",
49
28
  "@types/node": "12.20.4",
50
- "react-dom": "-",
51
- "react": "-"
52
- },
53
- "peerDependencies": {
54
- "@teambit/legacy": "1.0.192",
55
- "react-dom": "^16.8.0 || ^17.0.0",
56
- "react": "^16.8.0 || ^17.0.0"
29
+ "@types/jest": "26.0.20"
57
30
  }
58
31
  }
59
32
  },
@@ -0,0 +1,7 @@
1
+ import { ComponentIssue } from './component-issue';
2
+
3
+ export class ParseErrors extends ComponentIssue {
4
+ description = 'error found while parsing the file';
5
+ solution = 'edit the file and fix the parsing error';
6
+ data: { [filePath: string]: string } = {};
7
+ }
@@ -0,0 +1,37 @@
1
+ import { BitId } from '@teambit/legacy-bit-id';
2
+ import { ComponentIssue } from './component-issue';
3
+
4
+ export type RelativeComponentsAuthoredEntry = {
5
+ importSource: string;
6
+ componentId: BitId;
7
+ relativePath: {
8
+ sourceRelativePath: string;
9
+ importSpecifiers?: any[];
10
+ };
11
+ };
12
+
13
+ export class relativeComponentsAuthored extends ComponentIssue {
14
+ description = 'components with relative import statements found';
15
+ solution = 'replace to module paths or use "bit link --rewire" to replace';
16
+ data: { [fileName: string]: RelativeComponentsAuthoredEntry[] } = {};
17
+ isCacheBlocker = false;
18
+ formatDataFunction = relativeComponentsAuthoredIssuesToString;
19
+
20
+ deserialize(dataStr: string) {
21
+ const data = JSON.parse(dataStr);
22
+ Object.keys(data).forEach((fileName) => {
23
+ data[fileName] = data[fileName].map((record) => ({
24
+ importSource: record.importSource,
25
+ componentId: new BitId(record.componentId),
26
+ relativePath: record.relativePath,
27
+ }));
28
+ });
29
+ return data;
30
+ }
31
+ }
32
+
33
+ function relativeComponentsAuthoredIssuesToString(relativeEntries: RelativeComponentsAuthoredEntry[]) {
34
+ const stringifyEntry = (entry: RelativeComponentsAuthoredEntry) =>
35
+ `"${entry.importSource}" (${entry.componentId.toString()})`;
36
+ return relativeEntries.map(stringifyEntry).join(', ');
37
+ }
@@ -0,0 +1,12 @@
1
+ import { BitId } from '@teambit/legacy-bit-id';
2
+ import { ComponentIssue, deserializeWithBitId } from './component-issue';
3
+
4
+ export class relativeComponents extends ComponentIssue {
5
+ description = 'components with relative import statements found';
6
+ solution = 'use module paths for imported components';
7
+ data: { [filePath: string]: BitId[] } = {};
8
+ isCacheBlocker = false;
9
+ deserialize(data: string) {
10
+ return deserializeWithBitId(data);
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ import { ComponentIssue } from './component-issue';
2
+
3
+ export class ResolveErrors extends ComponentIssue {
4
+ description = 'error found while resolving the file dependencies';
5
+ solution = 'see the log for the full error';
6
+ data: { [filePath: string]: string } = {};
7
+ }
package/tsconfig.json CHANGED
@@ -4,29 +4,21 @@
4
4
  "es2019",
5
5
  "DOM",
6
6
  "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
7
+ "DOM.Iterable"
9
8
  ],
10
9
  "target": "es2015",
11
10
  "module": "commonjs",
12
11
  "jsx": "react",
12
+ "allowJs": true,
13
+ "composite": true,
13
14
  "declaration": true,
14
15
  "sourceMap": true,
15
16
  "skipLibCheck": true,
17
+ "outDir": "dist",
16
18
  "moduleResolution": "node",
17
19
  "esModuleInterop": true,
18
- "resolveJsonModule": true,
19
- "composite": true,
20
- "emitDeclarationOnly": true,
21
- "outDir": "dist",
22
- "experimentalDecorators": true,
23
- "emitDecoratorMetadata": true,
24
- "allowSyntheticDefaultImports": true,
25
- "strictPropertyInitialization": false,
26
- "strict": true,
27
- "noImplicitAny": false,
28
20
  "rootDir": ".",
29
- "preserveConstEnums": true
21
+ "resolveJsonModule": true
30
22
  },
31
23
  "exclude": [
32
24
  "dist"
@@ -0,0 +1,41 @@
1
+ import chalk from 'chalk';
2
+ import { ComponentIssue, ISSUE_FORMAT_SPACE, ISSUE_FORMAT_SPACE_COUNT } from './component-issue';
3
+
4
+ export const MISSING_NESTED_DEPS_SPACE = ' '.repeat(ISSUE_FORMAT_SPACE_COUNT + 2);
5
+
6
+ interface UntrackedFileEntry {
7
+ relativePath: string;
8
+ existing: boolean;
9
+ }
10
+
11
+ export interface UntrackedFileDependencyEntry {
12
+ nested: boolean;
13
+ untrackedFiles: Array<UntrackedFileEntry>;
14
+ }
15
+
16
+ export class UntrackedDependencies extends ComponentIssue {
17
+ description = 'untracked file dependencies';
18
+ solution = 'use "bit add <file>" to track untracked files as components';
19
+ data: { [filePath: string]: UntrackedFileDependencyEntry } = {};
20
+ dataToString() {
21
+ return Object.keys(this.data)
22
+ .map((k) => {
23
+ let space = ISSUE_FORMAT_SPACE;
24
+ if (this.data[k].nested) {
25
+ space = MISSING_NESTED_DEPS_SPACE;
26
+ }
27
+ return `${space}${k} -> ${untrackedFilesComponentIssueToString(this.data[k])}`;
28
+ })
29
+ .join('\n');
30
+ }
31
+ }
32
+
33
+ function untrackedFilesComponentIssueToString(value: UntrackedFileDependencyEntry) {
34
+ const colorizedMap = value.untrackedFiles.map((curr) => {
35
+ if (curr.existing) {
36
+ return `${chalk.yellow(curr.relativePath)}`;
37
+ }
38
+ return curr.relativePath;
39
+ });
40
+ return colorizedMap.join(', ');
41
+ }