@valbuild/cli 0.63.5 → 0.65.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.d.ts +2 -2
- package/cli/dist/valbuild-cli-cli.cjs.dev.js +1 -2
- package/cli/dist/valbuild-cli-cli.cjs.prod.js +1 -2
- package/cli/dist/valbuild-cli-cli.esm.js +1 -2
- package/package.json +4 -4
- package/src/cli.ts +4 -4
- package/src/files.ts +3 -3
- package/src/logger.ts +2 -2
- package/src/validate.ts +21 -22
- package/cli/dist/valbuild-cli-cli.cjs.d.ts.map +0 -1
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from "../../dist/declarations/src/cli";
|
2
|
-
//# sourceMappingURL=
|
1
|
+
export * from "../../dist/declarations/src/cli.js";
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsYnVpbGQtY2xpLWNsaS5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy9jbGkuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
@@ -30,8 +30,7 @@ async function validate({
|
|
30
30
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
31
31
|
const eslint$1 = new eslint.ESLint({
|
32
32
|
cwd: projectRoot,
|
33
|
-
ignore: false
|
34
|
-
useEslintrc: true
|
33
|
+
ignore: false
|
35
34
|
});
|
36
35
|
const service = await server.createService(projectRoot, {});
|
37
36
|
const valFiles = await fastGlob.glob("**/*.val.{js,ts}", {
|
@@ -30,8 +30,7 @@ async function validate({
|
|
30
30
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
31
31
|
const eslint$1 = new eslint.ESLint({
|
32
32
|
cwd: projectRoot,
|
33
|
-
ignore: false
|
34
|
-
useEslintrc: true
|
33
|
+
ignore: false
|
35
34
|
});
|
36
35
|
const service = await server.createService(projectRoot, {});
|
37
36
|
const valFiles = await fastGlob.glob("**/*.val.{js,ts}", {
|
@@ -20,8 +20,7 @@ async function validate({
|
|
20
20
|
const projectRoot = root ? path.resolve(root) : process.cwd();
|
21
21
|
const eslint = new ESLint({
|
22
22
|
cwd: projectRoot,
|
23
|
-
ignore: false
|
24
|
-
useEslintrc: true
|
23
|
+
ignore: false
|
25
24
|
});
|
26
25
|
const service = await createService(projectRoot, {});
|
27
26
|
const valFiles = await glob("**/*.val.{js,ts}", {
|
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.65.0",
|
5
5
|
"description": "Val CLI tools",
|
6
6
|
"bin": {
|
7
7
|
"val": "./bin.js"
|
@@ -18,9 +18,9 @@
|
|
18
18
|
"typecheck": "tsc --noEmit"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@valbuild/core": "~0.
|
22
|
-
"@valbuild/server": "~0.
|
23
|
-
"@valbuild/eslint-plugin": "~0.
|
21
|
+
"@valbuild/core": "~0.65.0",
|
22
|
+
"@valbuild/server": "~0.65.0",
|
23
|
+
"@valbuild/eslint-plugin": "~0.65.0",
|
24
24
|
"eslint": "^8.31.0",
|
25
25
|
"@inquirer/confirm": "^2.0.15",
|
26
26
|
"@inquirer/prompts": "^3.0.2",
|
package/src/cli.ts
CHANGED
@@ -61,7 +61,7 @@ async function main(): Promise<void> {
|
|
61
61
|
},
|
62
62
|
},
|
63
63
|
hardRejection: false,
|
64
|
-
}
|
64
|
+
},
|
65
65
|
);
|
66
66
|
|
67
67
|
if (input.length === 0) {
|
@@ -77,7 +77,7 @@ async function main(): Promise<void> {
|
|
77
77
|
case "files":
|
78
78
|
if (flags.fix || flags.noEslint) {
|
79
79
|
return error(
|
80
|
-
`Command "files" does not support --fix or --noEslint flags
|
80
|
+
`Command "files" does not support --fix or --noEslint flags`,
|
81
81
|
);
|
82
82
|
}
|
83
83
|
return files({
|
@@ -106,8 +106,8 @@ void main().catch((err) => {
|
|
106
106
|
err instanceof Error
|
107
107
|
? err.message + "\n" + err.stack
|
108
108
|
: typeof err === "object"
|
109
|
-
|
110
|
-
|
109
|
+
? JSON.stringify(err, null, 2)
|
110
|
+
: err,
|
111
111
|
);
|
112
112
|
process.exitCode = 1;
|
113
113
|
});
|
package/src/files.ts
CHANGED
@@ -30,7 +30,7 @@ export async function files({
|
|
30
30
|
async function printOrGetFileRefs(file: string) {
|
31
31
|
const moduleId = `/${file}`.replace(
|
32
32
|
/(\.val\.(ts|js))$/,
|
33
|
-
""
|
33
|
+
"",
|
34
34
|
) as ModuleFilePath; // TODO: check if this always works? (Windows?)
|
35
35
|
const valModule = await service.get(moduleId, "" as ModulePath, {
|
36
36
|
validate: true,
|
@@ -48,7 +48,7 @@ export async function files({
|
|
48
48
|
if (isFileRef(value)) {
|
49
49
|
const absoluteFilePathUsedByVal = path.join(
|
50
50
|
projectRoot,
|
51
|
-
...value[FILE_REF_PROP].split("/")
|
51
|
+
...value[FILE_REF_PROP].split("/"),
|
52
52
|
);
|
53
53
|
if (printFilesUsedByVal) {
|
54
54
|
console.log(absoluteFilePathUsedByVal);
|
@@ -86,7 +86,7 @@ export async function files({
|
|
86
86
|
}
|
87
87
|
|
88
88
|
function isFileRef(
|
89
|
-
value: unknown
|
89
|
+
value: unknown,
|
90
90
|
): value is { [FILE_REF_PROP]: string; [VAL_EXTENSION]: "file" } {
|
91
91
|
if (!value) return false;
|
92
92
|
if (typeof value !== "object") return false;
|
package/src/logger.ts
CHANGED
@@ -6,7 +6,7 @@ export function error(message: string) {
|
|
6
6
|
|
7
7
|
export function info(
|
8
8
|
message: string,
|
9
|
-
opts: { isCodeSnippet?: true; isGood?: true } = {}
|
9
|
+
opts: { isCodeSnippet?: true; isGood?: true } = {},
|
10
10
|
) {
|
11
11
|
if (opts.isCodeSnippet) {
|
12
12
|
console.log(chalk.cyanBright("$ > ") + chalk.cyan(message));
|
@@ -29,6 +29,6 @@ export function debugPrint(str: string) {
|
|
29
29
|
|
30
30
|
export function printDebuggingHelp() {
|
31
31
|
info(
|
32
|
-
`If you're having trouble, please follow the debugging steps\n🌐: https://val.build/docs/troubleshooting
|
32
|
+
`If you're having trouble, please follow the debugging steps\n🌐: https://val.build/docs/troubleshooting`,
|
33
33
|
);
|
34
34
|
}
|
package/src/validate.ts
CHANGED
@@ -19,7 +19,6 @@ export async function validate({
|
|
19
19
|
const eslint = new ESLint({
|
20
20
|
cwd: projectRoot,
|
21
21
|
ignore: false,
|
22
|
-
useEslintrc: true,
|
23
22
|
});
|
24
23
|
const service = await createService(projectRoot, {});
|
25
24
|
|
@@ -44,7 +43,7 @@ export async function validate({
|
|
44
43
|
...acc,
|
45
44
|
[result.filePath.replaceAll(`${projectRoot}/`, "")]: result,
|
46
45
|
}),
|
47
|
-
{} as Record<string, ESLint.LintResult
|
46
|
+
{} as Record<string, ESLint.LintResult>,
|
48
47
|
);
|
49
48
|
eslintResults.forEach((result) => {
|
50
49
|
result.messages.forEach(async (m) => {
|
@@ -53,7 +52,7 @@ export async function validate({
|
|
53
52
|
logEslintMessage(
|
54
53
|
await fs.readFile(result.filePath, "utf-8"),
|
55
54
|
result.filePath,
|
56
|
-
m
|
55
|
+
m,
|
57
56
|
);
|
58
57
|
}
|
59
58
|
});
|
@@ -62,7 +61,7 @@ export async function validate({
|
|
62
61
|
errors === 0 ? picocolors.green("✔") : picocolors.red("✘"),
|
63
62
|
"ESlint complete",
|
64
63
|
lintFiles.length,
|
65
|
-
"files"
|
64
|
+
"files",
|
66
65
|
);
|
67
66
|
}
|
68
67
|
console.log("Validating...", valFiles.length, "files");
|
@@ -77,7 +76,7 @@ export async function validate({
|
|
77
76
|
});
|
78
77
|
const fileContent = await fs.readFile(
|
79
78
|
path.join(projectRoot, file),
|
80
|
-
"utf-8"
|
79
|
+
"utf-8",
|
81
80
|
);
|
82
81
|
const eslintResult = eslintResultsByFile?.[file];
|
83
82
|
eslintResult?.messages.forEach((m) => {
|
@@ -88,19 +87,19 @@ export async function validate({
|
|
88
87
|
console.log(
|
89
88
|
picocolors.green("✔"),
|
90
89
|
moduleFilePath,
|
91
|
-
"is valid (" + (Date.now() - start) + "ms)"
|
90
|
+
"is valid (" + (Date.now() - start) + "ms)",
|
92
91
|
);
|
93
92
|
return 0;
|
94
93
|
} else {
|
95
94
|
let errors =
|
96
95
|
eslintResultsByFile?.[file]?.messages.reduce(
|
97
96
|
(prev, m) => (m.severity >= 2 ? prev + 1 : prev),
|
98
|
-
0
|
97
|
+
0,
|
99
98
|
) || 0;
|
100
99
|
if (valModule.errors) {
|
101
100
|
if (valModule.errors.validation) {
|
102
101
|
for (const [sourcePath, validationErrors] of Object.entries(
|
103
|
-
valModule.errors.validation
|
102
|
+
valModule.errors.validation,
|
104
103
|
)) {
|
105
104
|
for (const v of validationErrors) {
|
106
105
|
if (v.fixes && v.fixes.length > 0) {
|
@@ -108,14 +107,14 @@ export async function validate({
|
|
108
107
|
{ projectRoot },
|
109
108
|
!!fix,
|
110
109
|
sourcePath as SourcePath,
|
111
|
-
v
|
110
|
+
v,
|
112
111
|
);
|
113
112
|
if (fix && fixPatch?.patch && fixPatch?.patch.length > 0) {
|
114
113
|
await service.patch(moduleFilePath, fixPatch.patch);
|
115
114
|
console.log(
|
116
115
|
picocolors.yellow("⚠"),
|
117
116
|
"Applied fix for",
|
118
|
-
sourcePath
|
117
|
+
sourcePath,
|
119
118
|
);
|
120
119
|
}
|
121
120
|
fixPatch?.remainingErrors?.forEach((e) => {
|
@@ -124,7 +123,7 @@ export async function validate({
|
|
124
123
|
v.fixes ? picocolors.yellow("⚠") : picocolors.red("✘"),
|
125
124
|
`Found ${v.fixes ? "fixable " : ""}error in`,
|
126
125
|
`${sourcePath}:`,
|
127
|
-
e.message
|
126
|
+
e.message,
|
128
127
|
);
|
129
128
|
});
|
130
129
|
} else {
|
@@ -133,7 +132,7 @@ export async function validate({
|
|
133
132
|
picocolors.red("✘"),
|
134
133
|
"Found error in",
|
135
134
|
`${sourcePath}:`,
|
136
|
-
v.message
|
135
|
+
v.message,
|
137
136
|
);
|
138
137
|
}
|
139
138
|
}
|
@@ -145,14 +144,14 @@ export async function validate({
|
|
145
144
|
picocolors.red("✘"),
|
146
145
|
moduleFilePath,
|
147
146
|
"is invalid:",
|
148
|
-
fatalError.message
|
147
|
+
fatalError.message,
|
149
148
|
);
|
150
149
|
}
|
151
150
|
} else {
|
152
151
|
console.log(
|
153
152
|
picocolors.green("✔"),
|
154
153
|
moduleFilePath,
|
155
|
-
"is valid (" + (Date.now() - start) + "ms)"
|
154
|
+
"is valid (" + (Date.now() - start) + "ms)",
|
156
155
|
);
|
157
156
|
}
|
158
157
|
return errors;
|
@@ -166,7 +165,7 @@ export async function validate({
|
|
166
165
|
picocolors.red("✘"),
|
167
166
|
"Found",
|
168
167
|
errors,
|
169
|
-
"validation error" + (errors > 1 ? "s" : "")
|
168
|
+
"validation error" + (errors > 1 ? "s" : ""),
|
170
169
|
);
|
171
170
|
process.exit(1);
|
172
171
|
} else {
|
@@ -180,7 +179,7 @@ export async function validate({
|
|
180
179
|
function logEslintMessage(
|
181
180
|
fileContent: string,
|
182
181
|
filePath: string,
|
183
|
-
eslintMessage: ESLint.LintResult["messages"][number]
|
182
|
+
eslintMessage: ESLint.LintResult["messages"][number],
|
184
183
|
) {
|
185
184
|
const lines = fileContent.split("\n");
|
186
185
|
const line = lines[eslintMessage.line - 1];
|
@@ -191,12 +190,12 @@ function logEslintMessage(
|
|
191
190
|
isError ? picocolors.red("✘") : picocolors.yellow("⚠"),
|
192
191
|
isError ? "Found eslint error:" : "Found eslint warning:",
|
193
192
|
`${filePath}:${eslintMessage.line}:${eslintMessage.column}\n`,
|
194
|
-
eslintMessage.message
|
193
|
+
eslintMessage.message,
|
195
194
|
);
|
196
195
|
lineBefore &&
|
197
196
|
console.log(
|
198
197
|
picocolors.gray(" " + (eslintMessage.line - 1) + " |"),
|
199
|
-
lineBefore
|
198
|
+
lineBefore,
|
200
199
|
);
|
201
200
|
line && console.log(picocolors.gray(" " + eslintMessage.line + " |"), line);
|
202
201
|
// adds ^ below the relevant line:
|
@@ -209,18 +208,18 @@ function logEslintMessage(
|
|
209
208
|
line &&
|
210
209
|
console.log(
|
211
210
|
picocolors.gray(
|
212
|
-
" " + " ".repeat(eslintMessage.line.toString().length) + " |"
|
211
|
+
" " + " ".repeat(eslintMessage.line.toString().length) + " |",
|
213
212
|
),
|
214
213
|
" ".repeat(eslintMessage.column - 1) +
|
215
214
|
(eslintMessage.endColumn
|
216
215
|
? (isError ? picocolors.red("^") : picocolors.yellow("^")).repeat(
|
217
|
-
amountOfColumns
|
216
|
+
amountOfColumns,
|
218
217
|
)
|
219
|
-
: "")
|
218
|
+
: ""),
|
220
219
|
);
|
221
220
|
lineAfter &&
|
222
221
|
console.log(
|
223
222
|
picocolors.gray(" " + (eslintMessage.line + 1) + " |"),
|
224
|
-
lineAfter
|
223
|
+
lineAfter,
|
225
224
|
);
|
226
225
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"valbuild-cli-cli.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/cli.d.ts"],"names":[],"mappings":"AAAA"}
|