@teambit/component-issues 0.0.0-de14d08f36c2ec7aca9f216f61bc447c5aeb9859
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/circular-dependencies.ts +11 -0
- package/component-issue.ts +75 -0
- package/deprecated-dependencies.ts +11 -0
- package/dist/circular-dependencies.d.ts +8 -0
- package/dist/circular-dependencies.js +24 -0
- package/dist/circular-dependencies.js.map +1 -0
- package/dist/component-issue.d.ts +32 -0
- package/dist/component-issue.js +81 -0
- package/dist/component-issue.js.map +1 -0
- package/dist/deprecated-dependencies.d.ts +8 -0
- package/dist/deprecated-dependencies.js +25 -0
- package/dist/deprecated-dependencies.js.map +1 -0
- package/dist/duplicate-component-and-package.d.ts +8 -0
- package/dist/duplicate-component-and-package.js +24 -0
- package/dist/duplicate-component-and-package.js.map +1 -0
- package/dist/external-env-without-version.d.ts +14 -0
- package/dist/external-env-without-version.js +27 -0
- package/dist/external-env-without-version.js.map +1 -0
- package/dist/import-from-directory.d.ts +8 -0
- package/dist/import-from-directory.js +23 -0
- package/dist/import-from-directory.js.map +1 -0
- package/dist/import-non-main-files.d.ts +7 -0
- package/dist/import-non-main-files.js +22 -0
- package/dist/import-non-main-files.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/issues-list.d.ts +109 -0
- package/dist/issues-list.js +300 -0
- package/dist/issues-list.js.map +1 -0
- package/dist/legacy-inside-harmony.d.ts +8 -0
- package/dist/legacy-inside-harmony.js +24 -0
- package/dist/legacy-inside-harmony.js.map +1 -0
- package/dist/merge-config-has-conflict.d.ts +8 -0
- package/dist/merge-config-has-conflict.js +24 -0
- package/dist/merge-config-has-conflict.js.map +1 -0
- package/dist/missing-dependencies-on-fs.d.ts +6 -0
- package/dist/missing-dependencies-on-fs.js +21 -0
- package/dist/missing-dependencies-on-fs.js.map +1 -0
- package/dist/missing-dists.d.ts +8 -0
- package/dist/missing-dists.js +24 -0
- package/dist/missing-dists.js.map +1 -0
- package/dist/missing-links-from-nm-to-src.d.ts +8 -0
- package/dist/missing-links-from-nm-to-src.js +24 -0
- package/dist/missing-links-from-nm-to-src.js.map +1 -0
- package/dist/missing-manually-configured-packages.d.ts +7 -0
- package/dist/missing-manually-configured-packages.js +24 -0
- package/dist/missing-manually-configured-packages.js.map +1 -0
- package/dist/missing-packages-dependencies-on-fs.d.ts +12 -0
- package/dist/missing-packages-dependencies-on-fs.js +24 -0
- package/dist/missing-packages-dependencies-on-fs.js.map +1 -0
- package/dist/multiple-envs.d.ts +8 -0
- package/dist/multiple-envs.js +25 -0
- package/dist/multiple-envs.js.map +1 -0
- package/dist/non-loaded-env.d.ts +8 -0
- package/dist/non-loaded-env.js +24 -0
- package/dist/non-loaded-env.js.map +1 -0
- package/dist/parse-errors.d.ts +8 -0
- package/dist/parse-errors.js +21 -0
- package/dist/parse-errors.js.map +1 -0
- package/dist/relative-components-authored.d.ts +23 -0
- package/dist/relative-components-authored.js +56 -0
- package/dist/relative-components-authored.js.map +1 -0
- package/dist/relative-components.d.ts +11 -0
- package/dist/relative-components.js +25 -0
- package/dist/relative-components.js.map +1 -0
- package/dist/removed-dependencies.d.ts +8 -0
- package/dist/removed-dependencies.js +25 -0
- package/dist/removed-dependencies.js.map +1 -0
- package/dist/removed-env.d.ts +8 -0
- package/dist/removed-env.js +25 -0
- package/dist/removed-env.js.map +1 -0
- package/dist/resolve-errors.d.ts +8 -0
- package/dist/resolve-errors.js +21 -0
- package/dist/resolve-errors.js.map +1 -0
- package/dist/self-reference.d.ts +9 -0
- package/dist/self-reference.js +22 -0
- package/dist/self-reference.js.map +1 -0
- package/dist/untracked-dependencies.d.ts +19 -0
- package/dist/untracked-dependencies.js +48 -0
- package/dist/untracked-dependencies.js.map +1 -0
- package/duplicate-component-and-package.ts +11 -0
- package/external-env-without-version.ts +19 -0
- package/import-from-directory.ts +9 -0
- package/import-non-main-files.ts +8 -0
- package/index.ts +5 -0
- package/issues-list.ts +172 -0
- package/legacy-inside-harmony.ts +11 -0
- package/merge-config-has-conflict.ts +11 -0
- package/missing-dependencies-on-fs.ts +7 -0
- package/missing-dists.ts +11 -0
- package/missing-links-from-nm-to-src.ts +11 -0
- package/missing-manually-configured-packages.ts +10 -0
- package/missing-packages-dependencies-on-fs.ts +18 -0
- package/multiple-envs.ts +12 -0
- package/non-loaded-env.ts +11 -0
- package/package.json +38 -0
- package/parse-errors.ts +7 -0
- package/relative-components-authored.ts +49 -0
- package/relative-components.ts +12 -0
- package/removed-dependencies.ts +12 -0
- package/removed-env.ts +12 -0
- package/resolve-errors.ts +7 -0
- package/self-reference.ts +8 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
- package/untracked-dependencies.ts +41 -0
package/issues-list.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ComponentIssue, IssueObject } from './component-issue';
|
|
2
|
+
import { ImportNonMainFiles } from './import-non-main-files';
|
|
3
|
+
import { MissingDependenciesOnFs } from './missing-dependencies-on-fs';
|
|
4
|
+
import { MissingDists } from './missing-dists';
|
|
5
|
+
import { MissingPackagesDependenciesOnFs } from './missing-packages-dependencies-on-fs';
|
|
6
|
+
import { MissingManuallyConfiguredPackages } from './missing-manually-configured-packages';
|
|
7
|
+
import { ParseErrors } from './parse-errors';
|
|
8
|
+
import { RelativeComponents } from './relative-components';
|
|
9
|
+
import { RelativeComponentsAuthored } from './relative-components-authored';
|
|
10
|
+
import { ResolveErrors } from './resolve-errors';
|
|
11
|
+
import { UntrackedDependencies } from './untracked-dependencies';
|
|
12
|
+
import { LegacyInsideHarmony } from './legacy-inside-harmony';
|
|
13
|
+
import { MultipleEnvs } from './multiple-envs';
|
|
14
|
+
import { MissingLinksFromNodeModulesToSrc } from './missing-links-from-nm-to-src';
|
|
15
|
+
import { CircularDependencies } from './circular-dependencies';
|
|
16
|
+
import { DuplicateComponentAndPackage } from './duplicate-component-and-package';
|
|
17
|
+
import { MergeConfigHasConflict } from './merge-config-has-conflict';
|
|
18
|
+
import { NonLoadedEnv } from './non-loaded-env';
|
|
19
|
+
import { ExternalEnvWithoutVersion } from './external-env-without-version';
|
|
20
|
+
import { RemovedDependencies } from './removed-dependencies';
|
|
21
|
+
import { SelfReference } from './self-reference';
|
|
22
|
+
import { ImportFromDirectory } from './import-from-directory';
|
|
23
|
+
import { DeprecatedDependencies } from './deprecated-dependencies';
|
|
24
|
+
import { RemovedEnv } from './removed-env';
|
|
25
|
+
|
|
26
|
+
export const IssuesClasses = {
|
|
27
|
+
MissingPackagesDependenciesOnFs,
|
|
28
|
+
MissingManuallyConfiguredPackages,
|
|
29
|
+
UntrackedDependencies,
|
|
30
|
+
ResolveErrors,
|
|
31
|
+
RelativeComponents,
|
|
32
|
+
RelativeComponentsAuthored,
|
|
33
|
+
ParseErrors,
|
|
34
|
+
MissingDists,
|
|
35
|
+
LegacyInsideHarmony,
|
|
36
|
+
MissingDependenciesOnFs,
|
|
37
|
+
ImportNonMainFiles,
|
|
38
|
+
MultipleEnvs,
|
|
39
|
+
MissingLinksFromNodeModulesToSrc,
|
|
40
|
+
CircularDependencies,
|
|
41
|
+
DuplicateComponentAndPackage,
|
|
42
|
+
MergeConfigHasConflict,
|
|
43
|
+
NonLoadedEnv,
|
|
44
|
+
ExternalEnvWithoutVersion,
|
|
45
|
+
RemovedDependencies,
|
|
46
|
+
RemovedEnv,
|
|
47
|
+
DeprecatedDependencies,
|
|
48
|
+
SelfReference,
|
|
49
|
+
ImportFromDirectory,
|
|
50
|
+
};
|
|
51
|
+
export type IssuesNames = keyof typeof IssuesClasses;
|
|
52
|
+
|
|
53
|
+
export class IssuesList {
|
|
54
|
+
constructor(
|
|
55
|
+
/**
|
|
56
|
+
* only reason to have "issues" as public is to avoid the error "Types have separate declarations of a private property"
|
|
57
|
+
* because it is used in the legacy as well. it's possible to remove it from bit-repo and install as a package, but it's not
|
|
58
|
+
* convenient for now.
|
|
59
|
+
*/
|
|
60
|
+
public _issues: ComponentIssue[] = []
|
|
61
|
+
) {}
|
|
62
|
+
|
|
63
|
+
get count() {
|
|
64
|
+
return this._issues.length;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
isEmpty() {
|
|
68
|
+
return this._issues.length === 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
outputForCLI() {
|
|
72
|
+
return this._issues.map((issue) => issue.outputForCLI()).join('');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
toObject(): { type: string; description: string; data: any }[] {
|
|
76
|
+
return this._issues.map((issue) => issue.toObject());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated use toObjectIncludeDataAsString instead
|
|
81
|
+
* this method changes the "data" prop to string, which can be unexpected, and at times both are needed, the raw and the string.
|
|
82
|
+
* if you change to use `toObjectIncludeDataAsString`, make sure to call "dataAsString" instead of "data" when needed.
|
|
83
|
+
*/
|
|
84
|
+
toObjectWithDataAsString(): { type: string; description: string; data: string }[] {
|
|
85
|
+
return this._issues.map((issue) => ({
|
|
86
|
+
...issue.toObject(),
|
|
87
|
+
data: issue.dataToString().trim(),
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
add(issue: ComponentIssue) {
|
|
92
|
+
this._issues.push(issue);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
delete(IssueClass: typeof ComponentIssue) {
|
|
96
|
+
this._issues = this._issues.filter((issue) => issue.constructor.name !== IssueClass.name);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
hasTagBlockerIssues(): boolean {
|
|
100
|
+
return this._issues.some((issue) => issue.isTagBlocker);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getIssue<T extends ComponentIssue>(IssueClass: { new (): T }): T | undefined {
|
|
104
|
+
// don't use instanceof, e.g. `this._issues.find((issue) => issue instanceof IssueClass)`
|
|
105
|
+
// the "component-issues" package can come from different sources, so the "instanceof" won't work.
|
|
106
|
+
// use only getIssueByName for this.
|
|
107
|
+
return this.getIssueByName(IssueClass.name as IssuesNames);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getIssueByName<T extends ComponentIssue>(issueType: IssuesNames): T | undefined {
|
|
111
|
+
return this._issues.find((issue) => issue.constructor.name === issueType) as T | undefined;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getAllIssues(): ComponentIssue[] {
|
|
115
|
+
return this._issues;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getAllIssueNames(): string[] {
|
|
119
|
+
return this._issues.map((issue) => issue.constructor.name);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
createIssue<T extends ComponentIssue>(IssueClass: { new (): T }): T {
|
|
123
|
+
const newIssue = new IssueClass();
|
|
124
|
+
this.add(newIssue);
|
|
125
|
+
return newIssue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getOrCreate<T extends ComponentIssue>(IssueClass: { new (): T }): T {
|
|
129
|
+
return this.getIssue(IssueClass) || this.createIssue(IssueClass);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
shouldBlockSavingInCache(): boolean {
|
|
133
|
+
return this._issues.some((issue) => issue.isCacheBlocker);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
shouldBlockTagging(): boolean {
|
|
137
|
+
return this._issues.some((issue) => issue.isTagBlocker);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
filterNonTagBlocking(): IssuesList {
|
|
141
|
+
return new IssuesList(this._issues.filter((issue) => issue.isTagBlocker));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toObjectIncludeDataAsString(): Array<IssueObject & { dataAsString: string }> {
|
|
145
|
+
return this._issues.map((issue) => ({
|
|
146
|
+
...issue.toObject(),
|
|
147
|
+
dataAsString: issue.dataToString(),
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
serialize() {
|
|
152
|
+
return this._issues.map((issue) => ({ type: issue.constructor.name, data: issue.serialize() }));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static deserialize(data: Record<string, any>) {
|
|
156
|
+
if (!Array.isArray(data)) {
|
|
157
|
+
// probably old format, ignore it and return an empty IssuesList
|
|
158
|
+
return new IssuesList();
|
|
159
|
+
}
|
|
160
|
+
const issues = data.map((issue) => {
|
|
161
|
+
const ClassName = issue.type;
|
|
162
|
+
if (!Object.keys(IssuesClasses).includes(ClassName)) {
|
|
163
|
+
throw new Error(`issue type "${ClassName}" is not recognized.
|
|
164
|
+
the following are permitted ${Object.keys(IssuesClasses).join(', ')}`);
|
|
165
|
+
}
|
|
166
|
+
const issueInstance: ComponentIssue = new IssuesClasses[ClassName]();
|
|
167
|
+
issueInstance.data = issueInstance.deserialize(issue.data);
|
|
168
|
+
return issueInstance;
|
|
169
|
+
});
|
|
170
|
+
return new IssuesList(issues);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -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 { ComponentIssue, formatTitle } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class MergeConfigHasConflict extends ComponentIssue {
|
|
4
|
+
description = 'merge-conflict file has unresolved conflicts';
|
|
5
|
+
solution = `edit the merge-conflict file in the workspace root and resolve the conflicts`;
|
|
6
|
+
data: boolean;
|
|
7
|
+
isTagBlocker = true;
|
|
8
|
+
outputForCLI() {
|
|
9
|
+
return formatTitle(this.descriptionWithSolution, false);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -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
|
+
}
|
package/missing-dists.ts
ADDED
|
@@ -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,10 @@
|
|
|
1
|
+
import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class MissingManuallyConfiguredPackages extends ComponentIssue {
|
|
4
|
+
description = `missing packages that were manually set`;
|
|
5
|
+
solution = `run "bit install"`;
|
|
6
|
+
data: string[] = []; // package names
|
|
7
|
+
dataToString() {
|
|
8
|
+
return ISSUE_FORMAT_SPACE + this.data.join(', ');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export type MissingPackagesData = {
|
|
4
|
+
filePath: string;
|
|
5
|
+
isDevFile: boolean;
|
|
6
|
+
missingPackages: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export class MissingPackagesDependenciesOnFs extends ComponentIssue {
|
|
10
|
+
description = `missing packages or links from node_modules to the source`;
|
|
11
|
+
solution = `run "bit install --add-missing-deps" to fix both issues`;
|
|
12
|
+
data: MissingPackagesData[] = [];
|
|
13
|
+
dataToString(): string {
|
|
14
|
+
return this.data
|
|
15
|
+
.map((d) => `${ISSUE_FORMAT_SPACE}${d.filePath} -> ${this.formatDataFunction(d.missingPackages)}`)
|
|
16
|
+
.join('\n');
|
|
17
|
+
}
|
|
18
|
+
}
|
package/multiple-envs.ts
ADDED
|
@@ -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
|
+
'set the desired env by running "bit env set <component> <env>", if it doesn\'t work, run "bit aspect unset <component> <unwanted-env-id>". to keep troubleshooting run "bit aspect list <component-id>"';
|
|
7
|
+
data: string[]; // env ids
|
|
8
|
+
isTagBlocker = true;
|
|
9
|
+
dataToString() {
|
|
10
|
+
return ISSUE_FORMAT_SPACE + this.data.join(', ');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class NonLoadedEnv extends ComponentIssue {
|
|
4
|
+
description = 'failed loading env';
|
|
5
|
+
solution = `run "bit install"`;
|
|
6
|
+
data: string;
|
|
7
|
+
isTagBlocker = true;
|
|
8
|
+
dataToString() {
|
|
9
|
+
return ISSUE_FORMAT_SPACE + this.data;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/component-issues",
|
|
3
|
+
"version": "0.0.0-de14d08f36c2ec7aca9f216f61bc447c5aeb9859",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/component/component-issues",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.component",
|
|
8
|
+
"name": "component-issues",
|
|
9
|
+
"version": "de14d08f36c2ec7aca9f216f61bc447c5aeb9859"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"chalk": "4.1.2",
|
|
13
|
+
"@teambit/component-id": "1.2.4"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/mocha": "9.1.0",
|
|
17
|
+
"chai": "4.3.0",
|
|
18
|
+
"@teambit/node.envs.node-babel-mocha": "0.1.18"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"optionalDependencies": {},
|
|
23
|
+
"peerDependenciesMeta": {},
|
|
24
|
+
"private": false,
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=16.0.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/teambit/bit"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"bit",
|
|
34
|
+
"components",
|
|
35
|
+
"collaboration",
|
|
36
|
+
"web"
|
|
37
|
+
]
|
|
38
|
+
}
|
package/parse-errors.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import { ComponentIssue } from './component-issue';
|
|
3
|
+
|
|
4
|
+
export type RelativeComponentsAuthoredEntry = {
|
|
5
|
+
importSource: string;
|
|
6
|
+
componentId: ComponentID;
|
|
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
|
+
serialize(): string {
|
|
21
|
+
const obj = Object.keys(this.data).reduce((acc, fileName) => {
|
|
22
|
+
acc[fileName] = this.data[fileName].map((record) => ({
|
|
23
|
+
importSource: record.importSource,
|
|
24
|
+
componentId: record.componentId.serialize(),
|
|
25
|
+
relativePath: record.relativePath,
|
|
26
|
+
}));
|
|
27
|
+
return acc;
|
|
28
|
+
}, {});
|
|
29
|
+
return JSON.stringify(obj);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
deserialize(dataStr: string) {
|
|
33
|
+
const data = JSON.parse(dataStr);
|
|
34
|
+
Object.keys(data).forEach((fileName) => {
|
|
35
|
+
data[fileName] = data[fileName].map((record) => ({
|
|
36
|
+
importSource: record.importSource,
|
|
37
|
+
componentId: ComponentID.deserialize(record.componentId),
|
|
38
|
+
relativePath: record.relativePath,
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function relativeComponentsAuthoredIssuesToString(relativeEntries: RelativeComponentsAuthoredEntry[]) {
|
|
46
|
+
const stringifyEntry = (entry: RelativeComponentsAuthoredEntry) =>
|
|
47
|
+
`"${entry.importSource}" (${entry.componentId.toString()})`;
|
|
48
|
+
return relativeEntries.map(stringifyEntry).join(', ');
|
|
49
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-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]: ComponentID[] } = {};
|
|
8
|
+
isCacheBlocker = false;
|
|
9
|
+
deserialize(data: string) {
|
|
10
|
+
return deserializeWithBitId(data);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class RemovedDependencies extends ComponentIssue {
|
|
4
|
+
description = 'dependencies used in the code were deleted';
|
|
5
|
+
solution =
|
|
6
|
+
'if the dependencies are no longer needed, remove them from the code. otherwise, to get it installed from main run "bit install <missing dep>". to undo the delete, run "bit recover"';
|
|
7
|
+
data: string[]; // deps ids
|
|
8
|
+
isTagBlocker = true;
|
|
9
|
+
dataToString() {
|
|
10
|
+
return ISSUE_FORMAT_SPACE + this.data.join(', ');
|
|
11
|
+
}
|
|
12
|
+
}
|
package/removed-env.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class RemovedEnv extends ComponentIssue {
|
|
4
|
+
description = 'the env of this component is deleted';
|
|
5
|
+
solution =
|
|
6
|
+
'use "bit env set/replace" to set a new env or a different version of this env. to undo the delete, run "bit recover"';
|
|
7
|
+
data: string; // env id
|
|
8
|
+
isTagBlocker = true;
|
|
9
|
+
dataToString() {
|
|
10
|
+
return ISSUE_FORMAT_SPACE + this.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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentIssue } from './component-issue';
|
|
2
|
+
|
|
3
|
+
export class SelfReference extends ComponentIssue {
|
|
4
|
+
description = 'a component has an import statement that points to itself';
|
|
5
|
+
solution = 'edit the file and change the import statement to a relative path';
|
|
6
|
+
data: { [filePath: string]: string } = {};
|
|
7
|
+
isTagBlocker = true;
|
|
8
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
@@ -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
|
+
}
|