@valbuild/cli 0.48.1 → 0.49.0
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/cli/dist/valbuild-cli-cli.cjs.dev.js +35 -24
- package/cli/dist/valbuild-cli-cli.cjs.prod.js +35 -24
- package/cli/dist/valbuild-cli-cli.esm.js +35 -24
- package/package.json +3 -3
- package/src/cli.ts +5 -0
- package/src/validate.ts +38 -32
@@ -24,7 +24,8 @@ function error(...message) {
|
|
24
24
|
async function validate({
|
25
25
|
root,
|
26
26
|
cfg,
|
27
|
-
fix
|
27
|
+
fix,
|
28
|
+
noEslint
|
28
29
|
}) {
|
29
30
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
30
31
|
const eslint$1 = new eslint.ESLint({
|
@@ -39,33 +40,38 @@ async function validate({
|
|
39
40
|
ignore: ["node_modules/**"],
|
40
41
|
cwd: projectRoot
|
41
42
|
});
|
42
|
-
const lintFiles = await fastGlob.glob("**/*.{js,ts}", {
|
43
|
-
ignore: ["node_modules/**"],
|
44
|
-
cwd: projectRoot
|
45
|
-
});
|
46
|
-
console.log("Running eslint...");
|
47
|
-
const eslintResults = await eslint$1.lintFiles(lintFiles);
|
48
|
-
const eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
49
|
-
...acc,
|
50
|
-
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
51
|
-
}), {});
|
52
43
|
let errors = 0;
|
53
|
-
eslintResults
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
let eslintResults = [];
|
45
|
+
let eslintResultsByFile = {};
|
46
|
+
if (!noEslint) {
|
47
|
+
const lintFiles = await fastGlob.glob("**/*.{js,ts}", {
|
48
|
+
ignore: ["node_modules/**"],
|
49
|
+
cwd: projectRoot
|
59
50
|
});
|
60
|
-
|
61
|
-
|
51
|
+
console.log("Running eslint...");
|
52
|
+
eslintResults = await eslint$1.lintFiles(lintFiles);
|
53
|
+
eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
54
|
+
...acc,
|
55
|
+
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
56
|
+
}), {});
|
57
|
+
eslintResults.forEach(result => {
|
58
|
+
result.messages.forEach(async m => {
|
59
|
+
if (m.messageId === "val/export-content-must-be-valid") {
|
60
|
+
errors += 1;
|
61
|
+
logEslintMessage(await fs__default["default"].readFile(result.filePath, "utf-8"), result.filePath, m);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
console.log(errors === 0 ? picocolors__default["default"].green("✔") : picocolors__default["default"].red("✘"), "ESlint complete", lintFiles.length, "files");
|
66
|
+
}
|
62
67
|
console.log("Validating...", valFiles.length, "files");
|
63
68
|
async function validateFile(file) {
|
69
|
+
var _eslintResultsByFile;
|
64
70
|
const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
|
65
71
|
const start = Date.now();
|
66
72
|
const valModule = await service.get(moduleId, "");
|
67
73
|
const fileContent = await fs__default["default"].readFile(path__default["default"].join(projectRoot, file), "utf-8");
|
68
|
-
const eslintResult = eslintResultsByFile === null ||
|
74
|
+
const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
|
69
75
|
eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
|
70
76
|
// display surrounding code
|
71
77
|
logEslintMessage(fileContent, moduleId, m);
|
@@ -74,8 +80,8 @@ async function validate({
|
|
74
80
|
console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
|
75
81
|
return 0;
|
76
82
|
} else {
|
77
|
-
var
|
78
|
-
let errors = (eslintResultsByFile === null ||
|
83
|
+
var _eslintResultsByFile2;
|
84
|
+
let errors = ((_eslintResultsByFile2 = eslintResultsByFile) === null || _eslintResultsByFile2 === void 0 || (_eslintResultsByFile2 = _eslintResultsByFile2[file]) === null || _eslintResultsByFile2 === void 0 ? void 0 : _eslintResultsByFile2.messages.reduce((prev, m) => m.severity >= 2 ? prev + 1 : prev, 0)) || 0;
|
79
85
|
if (valModule.errors) {
|
80
86
|
if (valModule.errors.validation) {
|
81
87
|
for (const [sourcePath, validationErrors] of Object.entries(valModule.errors.validation)) {
|
@@ -87,7 +93,7 @@ async function validate({
|
|
87
93
|
}, !!fix, sourcePath, v);
|
88
94
|
if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
|
89
95
|
await service.patch(moduleId, fixPatch.patch);
|
90
|
-
console.log(picocolors__default["default"].
|
96
|
+
console.log(picocolors__default["default"].yellow("⚠"), "Applied fix for", sourcePath);
|
91
97
|
}
|
92
98
|
fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
|
93
99
|
errors += 1;
|
@@ -155,6 +161,7 @@ async function main() {
|
|
155
161
|
--root [root], -r [root] Set project root directory (default process.cwd())
|
156
162
|
--cfg [cfg], -c [cfg] Set path to config relative to root (default ./val.config)
|
157
163
|
--fix [fix] Attempt to fix validation errors
|
164
|
+
--noEslint [noEslint] Disable eslint validation
|
158
165
|
`, {
|
159
166
|
flags: {
|
160
167
|
port: {
|
@@ -172,6 +179,9 @@ async function main() {
|
|
172
179
|
},
|
173
180
|
fix: {
|
174
181
|
type: "boolean"
|
182
|
+
},
|
183
|
+
noEslint: {
|
184
|
+
type: "boolean"
|
175
185
|
}
|
176
186
|
},
|
177
187
|
hardRejection: false
|
@@ -189,7 +199,8 @@ async function main() {
|
|
189
199
|
return validate({
|
190
200
|
root: flags.root,
|
191
201
|
cfg: flags.cfg,
|
192
|
-
fix: flags.fix
|
202
|
+
fix: flags.fix,
|
203
|
+
noEslint: flags.noEslint
|
193
204
|
});
|
194
205
|
default:
|
195
206
|
return error(`Unknown command "${input.join(" ")}"`);
|
@@ -24,7 +24,8 @@ function error(...message) {
|
|
24
24
|
async function validate({
|
25
25
|
root,
|
26
26
|
cfg,
|
27
|
-
fix
|
27
|
+
fix,
|
28
|
+
noEslint
|
28
29
|
}) {
|
29
30
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
30
31
|
const eslint$1 = new eslint.ESLint({
|
@@ -39,33 +40,38 @@ async function validate({
|
|
39
40
|
ignore: ["node_modules/**"],
|
40
41
|
cwd: projectRoot
|
41
42
|
});
|
42
|
-
const lintFiles = await fastGlob.glob("**/*.{js,ts}", {
|
43
|
-
ignore: ["node_modules/**"],
|
44
|
-
cwd: projectRoot
|
45
|
-
});
|
46
|
-
console.log("Running eslint...");
|
47
|
-
const eslintResults = await eslint$1.lintFiles(lintFiles);
|
48
|
-
const eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
49
|
-
...acc,
|
50
|
-
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
51
|
-
}), {});
|
52
43
|
let errors = 0;
|
53
|
-
eslintResults
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
let eslintResults = [];
|
45
|
+
let eslintResultsByFile = {};
|
46
|
+
if (!noEslint) {
|
47
|
+
const lintFiles = await fastGlob.glob("**/*.{js,ts}", {
|
48
|
+
ignore: ["node_modules/**"],
|
49
|
+
cwd: projectRoot
|
59
50
|
});
|
60
|
-
|
61
|
-
|
51
|
+
console.log("Running eslint...");
|
52
|
+
eslintResults = await eslint$1.lintFiles(lintFiles);
|
53
|
+
eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
54
|
+
...acc,
|
55
|
+
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
56
|
+
}), {});
|
57
|
+
eslintResults.forEach(result => {
|
58
|
+
result.messages.forEach(async m => {
|
59
|
+
if (m.messageId === "val/export-content-must-be-valid") {
|
60
|
+
errors += 1;
|
61
|
+
logEslintMessage(await fs__default["default"].readFile(result.filePath, "utf-8"), result.filePath, m);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
console.log(errors === 0 ? picocolors__default["default"].green("✔") : picocolors__default["default"].red("✘"), "ESlint complete", lintFiles.length, "files");
|
66
|
+
}
|
62
67
|
console.log("Validating...", valFiles.length, "files");
|
63
68
|
async function validateFile(file) {
|
69
|
+
var _eslintResultsByFile;
|
64
70
|
const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
|
65
71
|
const start = Date.now();
|
66
72
|
const valModule = await service.get(moduleId, "");
|
67
73
|
const fileContent = await fs__default["default"].readFile(path__default["default"].join(projectRoot, file), "utf-8");
|
68
|
-
const eslintResult = eslintResultsByFile === null ||
|
74
|
+
const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
|
69
75
|
eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
|
70
76
|
// display surrounding code
|
71
77
|
logEslintMessage(fileContent, moduleId, m);
|
@@ -74,8 +80,8 @@ async function validate({
|
|
74
80
|
console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
|
75
81
|
return 0;
|
76
82
|
} else {
|
77
|
-
var
|
78
|
-
let errors = (eslintResultsByFile === null ||
|
83
|
+
var _eslintResultsByFile2;
|
84
|
+
let errors = ((_eslintResultsByFile2 = eslintResultsByFile) === null || _eslintResultsByFile2 === void 0 || (_eslintResultsByFile2 = _eslintResultsByFile2[file]) === null || _eslintResultsByFile2 === void 0 ? void 0 : _eslintResultsByFile2.messages.reduce((prev, m) => m.severity >= 2 ? prev + 1 : prev, 0)) || 0;
|
79
85
|
if (valModule.errors) {
|
80
86
|
if (valModule.errors.validation) {
|
81
87
|
for (const [sourcePath, validationErrors] of Object.entries(valModule.errors.validation)) {
|
@@ -87,7 +93,7 @@ async function validate({
|
|
87
93
|
}, !!fix, sourcePath, v);
|
88
94
|
if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
|
89
95
|
await service.patch(moduleId, fixPatch.patch);
|
90
|
-
console.log(picocolors__default["default"].
|
96
|
+
console.log(picocolors__default["default"].yellow("⚠"), "Applied fix for", sourcePath);
|
91
97
|
}
|
92
98
|
fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
|
93
99
|
errors += 1;
|
@@ -155,6 +161,7 @@ async function main() {
|
|
155
161
|
--root [root], -r [root] Set project root directory (default process.cwd())
|
156
162
|
--cfg [cfg], -c [cfg] Set path to config relative to root (default ./val.config)
|
157
163
|
--fix [fix] Attempt to fix validation errors
|
164
|
+
--noEslint [noEslint] Disable eslint validation
|
158
165
|
`, {
|
159
166
|
flags: {
|
160
167
|
port: {
|
@@ -172,6 +179,9 @@ async function main() {
|
|
172
179
|
},
|
173
180
|
fix: {
|
174
181
|
type: "boolean"
|
182
|
+
},
|
183
|
+
noEslint: {
|
184
|
+
type: "boolean"
|
175
185
|
}
|
176
186
|
},
|
177
187
|
hardRejection: false
|
@@ -189,7 +199,8 @@ async function main() {
|
|
189
199
|
return validate({
|
190
200
|
root: flags.root,
|
191
201
|
cfg: flags.cfg,
|
192
|
-
fix: flags.fix
|
202
|
+
fix: flags.fix,
|
203
|
+
noEslint: flags.noEslint
|
193
204
|
});
|
194
205
|
default:
|
195
206
|
return error(`Unknown command "${input.join(" ")}"`);
|
@@ -14,7 +14,8 @@ function error(...message) {
|
|
14
14
|
async function validate({
|
15
15
|
root,
|
16
16
|
cfg,
|
17
|
-
fix
|
17
|
+
fix,
|
18
|
+
noEslint
|
18
19
|
}) {
|
19
20
|
const projectRoot = root ? path.resolve(root) : process.cwd();
|
20
21
|
const eslint = new ESLint({
|
@@ -29,33 +30,38 @@ async function validate({
|
|
29
30
|
ignore: ["node_modules/**"],
|
30
31
|
cwd: projectRoot
|
31
32
|
});
|
32
|
-
const lintFiles = await glob("**/*.{js,ts}", {
|
33
|
-
ignore: ["node_modules/**"],
|
34
|
-
cwd: projectRoot
|
35
|
-
});
|
36
|
-
console.log("Running eslint...");
|
37
|
-
const eslintResults = await eslint.lintFiles(lintFiles);
|
38
|
-
const eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
39
|
-
...acc,
|
40
|
-
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
41
|
-
}), {});
|
42
33
|
let errors = 0;
|
43
|
-
eslintResults
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
34
|
+
let eslintResults = [];
|
35
|
+
let eslintResultsByFile = {};
|
36
|
+
if (!noEslint) {
|
37
|
+
const lintFiles = await glob("**/*.{js,ts}", {
|
38
|
+
ignore: ["node_modules/**"],
|
39
|
+
cwd: projectRoot
|
49
40
|
});
|
50
|
-
|
51
|
-
|
41
|
+
console.log("Running eslint...");
|
42
|
+
eslintResults = await eslint.lintFiles(lintFiles);
|
43
|
+
eslintResultsByFile = eslintResults.reduce((acc, result) => ({
|
44
|
+
...acc,
|
45
|
+
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result
|
46
|
+
}), {});
|
47
|
+
eslintResults.forEach(result => {
|
48
|
+
result.messages.forEach(async m => {
|
49
|
+
if (m.messageId === "val/export-content-must-be-valid") {
|
50
|
+
errors += 1;
|
51
|
+
logEslintMessage(await fs.readFile(result.filePath, "utf-8"), result.filePath, m);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
});
|
55
|
+
console.log(errors === 0 ? picocolors.green("✔") : picocolors.red("✘"), "ESlint complete", lintFiles.length, "files");
|
56
|
+
}
|
52
57
|
console.log("Validating...", valFiles.length, "files");
|
53
58
|
async function validateFile(file) {
|
59
|
+
var _eslintResultsByFile;
|
54
60
|
const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
|
55
61
|
const start = Date.now();
|
56
62
|
const valModule = await service.get(moduleId, "");
|
57
63
|
const fileContent = await fs.readFile(path.join(projectRoot, file), "utf-8");
|
58
|
-
const eslintResult = eslintResultsByFile === null ||
|
64
|
+
const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
|
59
65
|
eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
|
60
66
|
// display surrounding code
|
61
67
|
logEslintMessage(fileContent, moduleId, m);
|
@@ -64,8 +70,8 @@ async function validate({
|
|
64
70
|
console.log(picocolors.green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
|
65
71
|
return 0;
|
66
72
|
} else {
|
67
|
-
var
|
68
|
-
let errors = (eslintResultsByFile === null ||
|
73
|
+
var _eslintResultsByFile2;
|
74
|
+
let errors = ((_eslintResultsByFile2 = eslintResultsByFile) === null || _eslintResultsByFile2 === void 0 || (_eslintResultsByFile2 = _eslintResultsByFile2[file]) === null || _eslintResultsByFile2 === void 0 ? void 0 : _eslintResultsByFile2.messages.reduce((prev, m) => m.severity >= 2 ? prev + 1 : prev, 0)) || 0;
|
69
75
|
if (valModule.errors) {
|
70
76
|
if (valModule.errors.validation) {
|
71
77
|
for (const [sourcePath, validationErrors] of Object.entries(valModule.errors.validation)) {
|
@@ -77,7 +83,7 @@ async function validate({
|
|
77
83
|
}, !!fix, sourcePath, v);
|
78
84
|
if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
|
79
85
|
await service.patch(moduleId, fixPatch.patch);
|
80
|
-
console.log(picocolors.
|
86
|
+
console.log(picocolors.yellow("⚠"), "Applied fix for", sourcePath);
|
81
87
|
}
|
82
88
|
fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
|
83
89
|
errors += 1;
|
@@ -145,6 +151,7 @@ async function main() {
|
|
145
151
|
--root [root], -r [root] Set project root directory (default process.cwd())
|
146
152
|
--cfg [cfg], -c [cfg] Set path to config relative to root (default ./val.config)
|
147
153
|
--fix [fix] Attempt to fix validation errors
|
154
|
+
--noEslint [noEslint] Disable eslint validation
|
148
155
|
`, {
|
149
156
|
flags: {
|
150
157
|
port: {
|
@@ -162,6 +169,9 @@ async function main() {
|
|
162
169
|
},
|
163
170
|
fix: {
|
164
171
|
type: "boolean"
|
172
|
+
},
|
173
|
+
noEslint: {
|
174
|
+
type: "boolean"
|
165
175
|
}
|
166
176
|
},
|
167
177
|
hardRejection: false
|
@@ -179,7 +189,8 @@ async function main() {
|
|
179
189
|
return validate({
|
180
190
|
root: flags.root,
|
181
191
|
cfg: flags.cfg,
|
182
|
-
fix: flags.fix
|
192
|
+
fix: flags.fix,
|
193
|
+
noEslint: flags.noEslint
|
183
194
|
});
|
184
195
|
default:
|
185
196
|
return error(`Unknown command "${input.join(" ")}"`);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/cli",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.49.0",
|
5
5
|
"description": "Val CLI tools",
|
6
6
|
"bin": {
|
7
7
|
"val": "./bin.js"
|
@@ -17,8 +17,8 @@
|
|
17
17
|
"typecheck": "tsc --noEmit"
|
18
18
|
},
|
19
19
|
"dependencies": {
|
20
|
-
"@valbuild/server": "~0.
|
21
|
-
"@valbuild/eslint-plugin": "~0.
|
20
|
+
"@valbuild/server": "~0.49.0",
|
21
|
+
"@valbuild/eslint-plugin": "~0.49.0",
|
22
22
|
"eslint": "^8.31.0",
|
23
23
|
"chalk": "^4.1.2",
|
24
24
|
"cors": "^2.8.5",
|
package/src/cli.ts
CHANGED
@@ -17,6 +17,7 @@ async function main(): Promise<void> {
|
|
17
17
|
--root [root], -r [root] Set project root directory (default process.cwd())
|
18
18
|
--cfg [cfg], -c [cfg] Set path to config relative to root (default ./val.config)
|
19
19
|
--fix [fix] Attempt to fix validation errors
|
20
|
+
--noEslint [noEslint] Disable eslint validation
|
20
21
|
`,
|
21
22
|
{
|
22
23
|
flags: {
|
@@ -36,6 +37,9 @@ async function main(): Promise<void> {
|
|
36
37
|
fix: {
|
37
38
|
type: "boolean",
|
38
39
|
},
|
40
|
+
noEslint: {
|
41
|
+
type: "boolean",
|
42
|
+
},
|
39
43
|
},
|
40
44
|
hardRejection: false,
|
41
45
|
}
|
@@ -57,6 +61,7 @@ async function main(): Promise<void> {
|
|
57
61
|
root: flags.root,
|
58
62
|
cfg: flags.cfg,
|
59
63
|
fix: flags.fix,
|
64
|
+
noEslint: flags.noEslint,
|
60
65
|
});
|
61
66
|
default:
|
62
67
|
return error(`Unknown command "${input.join(" ")}"`);
|
package/src/validate.ts
CHANGED
@@ -10,10 +10,12 @@ export async function validate({
|
|
10
10
|
root,
|
11
11
|
cfg,
|
12
12
|
fix,
|
13
|
+
noEslint,
|
13
14
|
}: {
|
14
15
|
root?: string;
|
15
16
|
cfg?: string;
|
16
17
|
fix?: boolean;
|
18
|
+
noEslint?: boolean;
|
17
19
|
}) {
|
18
20
|
const projectRoot = root ? path.resolve(root) : process.cwd();
|
19
21
|
const eslint = new ESLint({
|
@@ -30,39 +32,43 @@ export async function validate({
|
|
30
32
|
cwd: projectRoot,
|
31
33
|
});
|
32
34
|
|
33
|
-
const lintFiles = await glob("**/*.{js,ts}", {
|
34
|
-
ignore: ["node_modules/**"],
|
35
|
-
cwd: projectRoot,
|
36
|
-
});
|
37
|
-
console.log("Running eslint...");
|
38
|
-
const eslintResults = await eslint.lintFiles(lintFiles);
|
39
|
-
const eslintResultsByFile = eslintResults.reduce(
|
40
|
-
(acc, result) => ({
|
41
|
-
...acc,
|
42
|
-
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result,
|
43
|
-
}),
|
44
|
-
{} as Record<string, ESLint.LintResult>
|
45
|
-
);
|
46
|
-
|
47
35
|
let errors = 0;
|
48
|
-
eslintResults.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
result.filePath,
|
55
|
-
m
|
56
|
-
);
|
57
|
-
}
|
36
|
+
let eslintResults: ESLint.LintResult[] = [];
|
37
|
+
let eslintResultsByFile: Record<string, ESLint.LintResult> = {};
|
38
|
+
if (!noEslint) {
|
39
|
+
const lintFiles = await glob("**/*.{js,ts}", {
|
40
|
+
ignore: ["node_modules/**"],
|
41
|
+
cwd: projectRoot,
|
58
42
|
});
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
43
|
+
console.log("Running eslint...");
|
44
|
+
eslintResults = await eslint.lintFiles(lintFiles);
|
45
|
+
|
46
|
+
eslintResultsByFile = eslintResults.reduce(
|
47
|
+
(acc, result) => ({
|
48
|
+
...acc,
|
49
|
+
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result,
|
50
|
+
}),
|
51
|
+
{} as Record<string, ESLint.LintResult>
|
52
|
+
);
|
53
|
+
eslintResults.forEach((result) => {
|
54
|
+
result.messages.forEach(async (m) => {
|
55
|
+
if (m.messageId === "val/export-content-must-be-valid") {
|
56
|
+
errors += 1;
|
57
|
+
logEslintMessage(
|
58
|
+
await fs.readFile(result.filePath, "utf-8"),
|
59
|
+
result.filePath,
|
60
|
+
m
|
61
|
+
);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
console.log(
|
66
|
+
errors === 0 ? picocolors.green("✔") : picocolors.red("✘"),
|
67
|
+
"ESlint complete",
|
68
|
+
lintFiles.length,
|
69
|
+
"files"
|
70
|
+
);
|
71
|
+
}
|
66
72
|
console.log("Validating...", valFiles.length, "files");
|
67
73
|
|
68
74
|
async function validateFile(file: string): Promise<number> {
|
@@ -107,7 +113,7 @@ export async function validate({
|
|
107
113
|
if (fix && fixPatch?.patch && fixPatch?.patch.length > 0) {
|
108
114
|
await service.patch(moduleId, fixPatch.patch);
|
109
115
|
console.log(
|
110
|
-
picocolors.
|
116
|
+
picocolors.yellow("⚠"),
|
111
117
|
"Applied fix for",
|
112
118
|
sourcePath
|
113
119
|
);
|