@aklinker1/check 2.2.0 → 2.3.1
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/README.md +3 -2
- package/dist/cli.js +3 -4
- package/dist/index.js +1 -1
- package/dist/{src-DLILuPNJ.js → src-35ZaX6Fv.js} +165 -123
- package/package.json +38 -40
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Check
|
|
2
2
|
|
|
3
|
-
An opinionated CLI tool to run all your checks all at once. The command will only exit with code 0
|
|
3
|
+
An opinionated CLI tool to run all your checks all at once. The command will only exit with code 0
|
|
4
|
+
when no problems exist.
|
|
4
5
|
|
|
5
6
|
https://github.com/aklinker1/check/assets/10101283/c8089e5c-e25f-4f59-8897-d2a6f97a3139
|
|
6
7
|
|
|
@@ -13,7 +14,7 @@ pnpm check --fix
|
|
|
13
14
|
To enable checks for any of the following modules, just install them:
|
|
14
15
|
|
|
15
16
|
```sh
|
|
16
|
-
pnpm i -D typescript oxlint prettier publint eslint markdownlint-cli
|
|
17
|
+
pnpm i -D typescript oxlint prettier publint eslint markdownlint-cli @typescript/native-preview
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Contributing
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { i as ALL_TOOLS, t as check } from "./src-
|
|
2
|
-
import { isCI } from "ci-info";
|
|
1
|
+
import { a as isCi, i as ALL_TOOLS, t as check } from "./src-35ZaX6Fv.js";
|
|
3
2
|
|
|
4
3
|
//#region package.json
|
|
5
|
-
var version = "2.
|
|
4
|
+
var version = "2.3.1";
|
|
6
5
|
|
|
7
6
|
//#endregion
|
|
8
7
|
//#region src/cli.ts
|
|
@@ -28,7 +27,7 @@ if (boolArg("-h") || boolArg("--help")) {
|
|
|
28
27
|
process.exit(0);
|
|
29
28
|
}
|
|
30
29
|
await check({
|
|
31
|
-
fix: boolArg("-f") ?? boolArg("--fix") ?? !
|
|
30
|
+
fix: boolArg("-f") ?? boolArg("--fix") ?? !isCi,
|
|
32
31
|
debug: boolArg("-d") ?? boolArg("--debug") ?? false,
|
|
33
32
|
root: args.find((arg) => !arg.startsWith("-")) ?? "."
|
|
34
33
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { isCI } from "ci-info";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import readline from "node:readline";
|
|
4
|
-
import { join, relative, resolve, sep } from "node:path";
|
|
5
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import readline from "node:readline";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
6
5
|
|
|
7
6
|
//#region src/utils.ts
|
|
7
|
+
const env = process.env;
|
|
8
|
+
const isCi = Boolean(env.CI || env.JENKINS_URL);
|
|
9
|
+
const isDebug = env.DEBUG === "true" || env.DEBUG === "1";
|
|
8
10
|
function exec(cmd, opts) {
|
|
9
11
|
return new Promise((resolve$1, reject) => {
|
|
10
12
|
const child = spawn(cmd, {
|
|
@@ -31,12 +33,12 @@ function exec(cmd, opts) {
|
|
|
31
33
|
});
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
|
-
async function execAndParse(cmd, cwd, parser) {
|
|
35
|
-
const res = await exec(cmd, { cwd });
|
|
36
|
+
async function execAndParse(cmd, cwd$1, parser) {
|
|
37
|
+
const res = await exec(cmd, { cwd: cwd$1 });
|
|
36
38
|
if (res.exitCode == null) throw Error("Exit code was null");
|
|
37
|
-
if (isDebug
|
|
39
|
+
if (isDebug) console.debug({
|
|
38
40
|
cmd,
|
|
39
|
-
cwd,
|
|
41
|
+
cwd: cwd$1,
|
|
40
42
|
...res
|
|
41
43
|
});
|
|
42
44
|
return parser({
|
|
@@ -45,9 +47,6 @@ async function execAndParse(cmd, cwd, parser) {
|
|
|
45
47
|
stdout: res.stdout
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
function isDebug() {
|
|
49
|
-
return process.env.DEBUG === "true" || process.env.DEBUG === "1";
|
|
50
|
-
}
|
|
51
50
|
const bold = (str) => `\x1b[1m${str}\x1b[0m`;
|
|
52
51
|
const dim = (str) => `\x1b[2m${str}\x1b[0m`;
|
|
53
52
|
const red = (str) => `\x1b[31m${str}\x1b[0m`;
|
|
@@ -60,9 +59,91 @@ function humanMs(ms) {
|
|
|
60
59
|
return `${minutes > 0 ? `${minutes}m ` : ""}${seconds}s`;
|
|
61
60
|
}
|
|
62
61
|
function debug(message) {
|
|
63
|
-
if (isDebug
|
|
62
|
+
if (isDebug) console.debug(dim("⚙ " + message));
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/tasklist/index.ts
|
|
67
|
+
async function createTaskList(inputs, run) {
|
|
68
|
+
const states = inputs.map((item) => ({
|
|
69
|
+
title: item.name,
|
|
70
|
+
state: "pending"
|
|
71
|
+
}));
|
|
72
|
+
const isTty = process.stderr.isTTY;
|
|
73
|
+
let tick = 0;
|
|
74
|
+
const render = (opts) => {
|
|
75
|
+
if (isTty && !opts?.firstRender) readline.moveCursor(process.stderr, 0, -1 * states.length);
|
|
76
|
+
if (isTty || opts?.firstRender || opts?.lastRender) states.forEach(({ state, title }) => {
|
|
77
|
+
readline.clearLine(process.stderr, 0);
|
|
78
|
+
const frames = SPINNER_FRAMES[state];
|
|
79
|
+
process.stderr.write(`${frames[tick % frames.length]} ${title}\n`);
|
|
80
|
+
});
|
|
81
|
+
tick++;
|
|
82
|
+
};
|
|
83
|
+
render({ firstRender: true });
|
|
84
|
+
const renderInterval = setInterval(render, SPINNER_INTERVAL_MS);
|
|
85
|
+
try {
|
|
86
|
+
const result = await Promise.all(inputs.map(async (input, i) => {
|
|
87
|
+
const succeed = (title) => {
|
|
88
|
+
if (title != null) states[i].title = title;
|
|
89
|
+
states[i].state = "success";
|
|
90
|
+
render();
|
|
91
|
+
};
|
|
92
|
+
const warn = (title) => {
|
|
93
|
+
if (title != null) states[i].title = title;
|
|
94
|
+
states[i].state = "warning";
|
|
95
|
+
render();
|
|
96
|
+
};
|
|
97
|
+
const fail = (title) => {
|
|
98
|
+
if (title != null) states[i].title = title;
|
|
99
|
+
states[i].state = "error";
|
|
100
|
+
render();
|
|
101
|
+
};
|
|
102
|
+
try {
|
|
103
|
+
states[i].state = "in-progress";
|
|
104
|
+
render();
|
|
105
|
+
const res = await run({
|
|
106
|
+
input,
|
|
107
|
+
succeed,
|
|
108
|
+
warn,
|
|
109
|
+
fail
|
|
110
|
+
});
|
|
111
|
+
if (states[i].state === "in-progress") states[i].state = "success";
|
|
112
|
+
render();
|
|
113
|
+
return res;
|
|
114
|
+
} catch (err) {
|
|
115
|
+
if (err instanceof Error) fail(err.message);
|
|
116
|
+
else fail(String(err));
|
|
117
|
+
render();
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
render({ lastRender: true });
|
|
122
|
+
return result;
|
|
123
|
+
} finally {
|
|
124
|
+
clearInterval(renderInterval);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const SPINNER_INTERVAL_MS = 80;
|
|
128
|
+
const SPINNER_FRAMES = {
|
|
129
|
+
pending: [dim("□")],
|
|
130
|
+
"in-progress": [
|
|
131
|
+
"⠋",
|
|
132
|
+
"⠙",
|
|
133
|
+
"⠹",
|
|
134
|
+
"⠸",
|
|
135
|
+
"⠼",
|
|
136
|
+
"⠴",
|
|
137
|
+
"⠦",
|
|
138
|
+
"⠧",
|
|
139
|
+
"⠇",
|
|
140
|
+
"⠏"
|
|
141
|
+
].map(cyan),
|
|
142
|
+
success: [green("✔")],
|
|
143
|
+
warning: [yellow("⚠")],
|
|
144
|
+
error: [red("✗")]
|
|
145
|
+
};
|
|
146
|
+
|
|
66
147
|
//#endregion
|
|
67
148
|
//#region src/tools/eslint.ts
|
|
68
149
|
const eslint = ({ root }) => {
|
|
@@ -71,13 +152,15 @@ const eslint = ({ root }) => {
|
|
|
71
152
|
return {
|
|
72
153
|
name: "ESLint",
|
|
73
154
|
packageName: "eslint",
|
|
74
|
-
check: () => execAndParse(checkCmd, root, parseOutput$
|
|
75
|
-
fix: () => execAndParse(fixCmd, root, parseOutput$
|
|
155
|
+
check: () => execAndParse(checkCmd, root, parseOutput$6),
|
|
156
|
+
fix: () => execAndParse(fixCmd, root, parseOutput$6)
|
|
76
157
|
};
|
|
77
158
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
159
|
+
const NEWLINE_REGEX$5 = /\r?\n/;
|
|
160
|
+
const LINT_REGEX$1 = /^(?<file>.*?): line (?<line>[0-9]+), col (?<column>[0-9]+), (?<kind>\S+) - (?<message>.*?) \((?<rule>\S*?)\)$/;
|
|
161
|
+
const parseOutput$6 = ({ stdout, stderr }) => {
|
|
162
|
+
return `${stdout}\n${stderr}`.split(NEWLINE_REGEX$5).reduce((acc, line) => {
|
|
163
|
+
const groups = LINT_REGEX$1.exec(line)?.groups;
|
|
81
164
|
if (groups) acc.push({
|
|
82
165
|
file: groups.file,
|
|
83
166
|
kind: groups.kind === "Warning" ? "warning" : "error",
|
|
@@ -100,11 +183,11 @@ const markdownlint = ({ root }) => {
|
|
|
100
183
|
return {
|
|
101
184
|
name: "Markdownlint",
|
|
102
185
|
packageName: "markdownlint-cli",
|
|
103
|
-
check: () => execAndParse(checkCmd, root, parseOutput$
|
|
104
|
-
fix: () => execAndParse(fixCmd, root, parseOutput$
|
|
186
|
+
check: () => execAndParse(checkCmd, root, parseOutput$5),
|
|
187
|
+
fix: () => execAndParse(fixCmd, root, parseOutput$5)
|
|
105
188
|
};
|
|
106
189
|
};
|
|
107
|
-
const parseOutput$
|
|
190
|
+
const parseOutput$5 = ({ stderr: _stderr }) => {
|
|
108
191
|
const stderr = _stderr.trim();
|
|
109
192
|
if (!stderr) return [];
|
|
110
193
|
return JSON.parse(stderr).map((warning) => ({
|
|
@@ -119,6 +202,42 @@ const parseOutput$4 = ({ stderr: _stderr }) => {
|
|
|
119
202
|
}));
|
|
120
203
|
};
|
|
121
204
|
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/tools/oxfmt.ts
|
|
207
|
+
const oxfmt = ({ root }) => {
|
|
208
|
+
const checkCmd = "oxfmt . --list-different";
|
|
209
|
+
const fixCmd = "oxfmt .";
|
|
210
|
+
return {
|
|
211
|
+
name: "Oxfmt",
|
|
212
|
+
packageName: "oxfmt",
|
|
213
|
+
check: () => execAndParse(checkCmd, root, parseOutput$4),
|
|
214
|
+
fix: () => execAndParse(fixCmd, root, parseOutput$4)
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
const NEWLINE_REGEX$4 = /\r?\n/;
|
|
218
|
+
const SYNTAX_ERROR_REGEX = /^\s*?[×✕]\s+(?<message>.+?)\r?\n\s+╭─\[(?<file>.+?):(?<line>[0-9]+):(?<column>[0-9]+)\]/;
|
|
219
|
+
const parseOutput$4 = ({ stdout, stderr }) => {
|
|
220
|
+
const problems = [];
|
|
221
|
+
for (const { groups } of stderr.trim().matchAll(new RegExp(SYNTAX_ERROR_REGEX, "g"))) problems.push({
|
|
222
|
+
file: groups.file,
|
|
223
|
+
kind: "error",
|
|
224
|
+
message: groups.message,
|
|
225
|
+
location: {
|
|
226
|
+
line: parseInt(groups.line, 10),
|
|
227
|
+
column: parseInt(groups.column, 10)
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
for (const line of stdout.trim().split(NEWLINE_REGEX$4)) {
|
|
231
|
+
if (!line || line.includes(" ")) continue;
|
|
232
|
+
problems.push({
|
|
233
|
+
file: line.trim(),
|
|
234
|
+
kind: "warning",
|
|
235
|
+
message: "Not formatted."
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return problems;
|
|
239
|
+
};
|
|
240
|
+
|
|
122
241
|
//#endregion
|
|
123
242
|
//#region src/tools/oxlint.ts
|
|
124
243
|
const oxlint = ({ root }) => {
|
|
@@ -131,9 +250,11 @@ const oxlint = ({ root }) => {
|
|
|
131
250
|
fix: () => execAndParse(fixCmd, root, parseOutput$3)
|
|
132
251
|
};
|
|
133
252
|
};
|
|
253
|
+
const NEWLINE_REGEX$3 = /\r?\n/;
|
|
254
|
+
const LINT_REGEX = /^(?<file>.+?):(?<line>[0-9]+):(?<column>[0-9]+):\s?(?<message>.*?)\s?\[(?<kind>Warning|Error)\/?(?<rule>.*?)\]\s?$/;
|
|
134
255
|
const parseOutput$3 = ({ stdout }) => {
|
|
135
|
-
|
|
136
|
-
const groups =
|
|
256
|
+
return stdout.split(NEWLINE_REGEX$3).reduce((acc, line) => {
|
|
257
|
+
const groups = LINT_REGEX.exec(line)?.groups;
|
|
137
258
|
if (groups) acc.push({
|
|
138
259
|
file: groups.file,
|
|
139
260
|
kind: groups.kind === "Error" ? "error" : "warning",
|
|
@@ -146,11 +267,6 @@ const parseOutput$3 = ({ stdout }) => {
|
|
|
146
267
|
});
|
|
147
268
|
return acc;
|
|
148
269
|
}, []);
|
|
149
|
-
return stdout.trim().split(/\r?\n/).map((line) => line.trim()).filter((line) => !!line && !line.includes(" ")).map((line) => ({
|
|
150
|
-
file: line.trim(),
|
|
151
|
-
kind: "warning",
|
|
152
|
-
message: "Not formatted."
|
|
153
|
-
}));
|
|
154
270
|
};
|
|
155
271
|
|
|
156
272
|
//#endregion
|
|
@@ -165,9 +281,11 @@ const prettier = ({ root }) => {
|
|
|
165
281
|
fix: () => execAndParse(fixCmd, root, parseOutput$2)
|
|
166
282
|
};
|
|
167
283
|
};
|
|
284
|
+
const NEWLINE_REGEX$2 = /\r?\n/;
|
|
285
|
+
const ERROR_REGEX$2 = /^\[(?<kind>.+?)\]\s?(?<file>.+?):\s?(?<message>.*?)\s?\((?<line>[0-9]+):(?<column>[0-9]+)\)$/;
|
|
168
286
|
const parseOutput$2 = ({ stdout, stderr }) => {
|
|
169
|
-
if (stderr.trim()) return stderr.split(
|
|
170
|
-
const groups =
|
|
287
|
+
if (stderr.trim()) return stderr.split(NEWLINE_REGEX$2).reduce((acc, line) => {
|
|
288
|
+
const groups = ERROR_REGEX$2.exec(line)?.groups;
|
|
171
289
|
if (groups) acc.push({
|
|
172
290
|
file: groups.file,
|
|
173
291
|
kind: groups.kind === "error" ? "error" : "warning",
|
|
@@ -179,7 +297,7 @@ const parseOutput$2 = ({ stdout, stderr }) => {
|
|
|
179
297
|
});
|
|
180
298
|
return acc;
|
|
181
299
|
}, []);
|
|
182
|
-
return stdout.trim().split(
|
|
300
|
+
return stdout.trim().split(NEWLINE_REGEX$2).map((line) => line.trim()).filter((line) => !!line && !line.includes(" ")).map((line) => ({
|
|
183
301
|
file: line.trim(),
|
|
184
302
|
kind: "warning",
|
|
185
303
|
message: "Not formatted."
|
|
@@ -196,14 +314,16 @@ const publint = ({ root }) => {
|
|
|
196
314
|
check: () => execAndParse(cmd, root, parseOutput$1)
|
|
197
315
|
};
|
|
198
316
|
};
|
|
317
|
+
const NEWLINE_REGEX$1 = /\r?\n/;
|
|
318
|
+
const ERROR_REGEX$1 = /^[0-9]+\.\s?(?<message>.*)$/;
|
|
199
319
|
const parseOutput$1 = ({ stdout }) => {
|
|
200
320
|
let kind = "warning";
|
|
201
|
-
return stdout.split(
|
|
321
|
+
return stdout.split(NEWLINE_REGEX$1).reduce((acc, line) => {
|
|
202
322
|
if (line.includes("Errors:")) {
|
|
203
323
|
kind = "error";
|
|
204
324
|
return acc;
|
|
205
325
|
}
|
|
206
|
-
const groups =
|
|
326
|
+
const groups = ERROR_REGEX$1.exec(line)?.groups;
|
|
207
327
|
if (groups == null) return acc;
|
|
208
328
|
acc.push({
|
|
209
329
|
kind,
|
|
@@ -243,9 +363,11 @@ const typescript = async ({ root, packageJson }) => {
|
|
|
243
363
|
check: async () => execAndParse(mod.cmd, root, parseOutput)
|
|
244
364
|
};
|
|
245
365
|
};
|
|
366
|
+
const NEWLINE_REGEX = /\r?\n/;
|
|
367
|
+
const ERROR_REGEX = /^(?<file>\S+?)\((?<line>[0-9]+),(?<column>[0-9]+)\): \w+? (?<rule>TS[0-9]+): (?<message>.*)$/;
|
|
246
368
|
const parseOutput = ({ stdout }) => {
|
|
247
|
-
return stdout.split(
|
|
248
|
-
const groups =
|
|
369
|
+
return stdout.split(NEWLINE_REGEX).reduce((acc, line) => {
|
|
370
|
+
const groups = ERROR_REGEX.exec(line)?.groups;
|
|
249
371
|
if (groups) acc.push({
|
|
250
372
|
file: groups.file,
|
|
251
373
|
kind: "error",
|
|
@@ -263,6 +385,7 @@ const parseOutput = ({ stdout }) => {
|
|
|
263
385
|
//#endregion
|
|
264
386
|
//#region src/tools/index.ts
|
|
265
387
|
const ALL_TOOLS = [
|
|
388
|
+
oxfmt,
|
|
266
389
|
eslint,
|
|
267
390
|
markdownlint,
|
|
268
391
|
oxlint,
|
|
@@ -271,92 +394,11 @@ const ALL_TOOLS = [
|
|
|
271
394
|
typescript
|
|
272
395
|
];
|
|
273
396
|
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/tasklist/index.ts
|
|
276
|
-
async function createTaskList(inputs, run) {
|
|
277
|
-
const states = inputs.map((item) => ({
|
|
278
|
-
title: item.name,
|
|
279
|
-
state: "pending"
|
|
280
|
-
}));
|
|
281
|
-
const isTty = process.stderr.isTTY;
|
|
282
|
-
let tick = 0;
|
|
283
|
-
const render = (opts) => {
|
|
284
|
-
if (isTty && !opts?.firstRender) readline.moveCursor(process.stderr, 0, -1 * states.length);
|
|
285
|
-
if (isTty || opts?.firstRender || opts?.lastRender) states.forEach(({ state, title }) => {
|
|
286
|
-
readline.clearLine(process.stderr, 0);
|
|
287
|
-
const frames = SPINNER_FRAMES[state];
|
|
288
|
-
process.stderr.write(`${frames[tick % frames.length]} ${title}\n`);
|
|
289
|
-
});
|
|
290
|
-
tick++;
|
|
291
|
-
};
|
|
292
|
-
render({ firstRender: true });
|
|
293
|
-
const renderInterval = setInterval(render, SPINNER_INTERVAL_MS);
|
|
294
|
-
try {
|
|
295
|
-
const result = await Promise.all(inputs.map(async (input, i) => {
|
|
296
|
-
const succeed = (title) => {
|
|
297
|
-
if (title != null) states[i].title = title;
|
|
298
|
-
states[i].state = "success";
|
|
299
|
-
render();
|
|
300
|
-
};
|
|
301
|
-
const warn = (title) => {
|
|
302
|
-
if (title != null) states[i].title = title;
|
|
303
|
-
states[i].state = "warning";
|
|
304
|
-
render();
|
|
305
|
-
};
|
|
306
|
-
const fail = (title) => {
|
|
307
|
-
if (title != null) states[i].title = title;
|
|
308
|
-
states[i].state = "error";
|
|
309
|
-
render();
|
|
310
|
-
};
|
|
311
|
-
try {
|
|
312
|
-
states[i].state = "in-progress";
|
|
313
|
-
render();
|
|
314
|
-
const res = await run({
|
|
315
|
-
input,
|
|
316
|
-
succeed,
|
|
317
|
-
warn,
|
|
318
|
-
fail
|
|
319
|
-
});
|
|
320
|
-
if (states[i].state === "in-progress") states[i].state = "success";
|
|
321
|
-
render();
|
|
322
|
-
return res;
|
|
323
|
-
} catch (err) {
|
|
324
|
-
if (err instanceof Error) fail(err.message);
|
|
325
|
-
else fail(String(err));
|
|
326
|
-
render();
|
|
327
|
-
throw err;
|
|
328
|
-
}
|
|
329
|
-
}));
|
|
330
|
-
render({ lastRender: true });
|
|
331
|
-
return result;
|
|
332
|
-
} finally {
|
|
333
|
-
clearInterval(renderInterval);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const SPINNER_INTERVAL_MS = 80;
|
|
337
|
-
const SPINNER_FRAMES = {
|
|
338
|
-
pending: [dim("□")],
|
|
339
|
-
"in-progress": [
|
|
340
|
-
"⠋",
|
|
341
|
-
"⠙",
|
|
342
|
-
"⠹",
|
|
343
|
-
"⠸",
|
|
344
|
-
"⠼",
|
|
345
|
-
"⠴",
|
|
346
|
-
"⠦",
|
|
347
|
-
"⠧",
|
|
348
|
-
"⠇",
|
|
349
|
-
"⠏"
|
|
350
|
-
].map(cyan),
|
|
351
|
-
success: [green("✔")],
|
|
352
|
-
warning: [yellow("⚠")],
|
|
353
|
-
error: [red("✗")]
|
|
354
|
-
};
|
|
355
|
-
|
|
356
397
|
//#endregion
|
|
357
398
|
//#region src/index.ts
|
|
399
|
+
const cwd = process.cwd();
|
|
358
400
|
async function check(options = {}) {
|
|
359
|
-
const { debug: debug$1, fix = !
|
|
401
|
+
const { debug: debug$1, fix = !isCi, root = cwd } = options;
|
|
360
402
|
const packageJson = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
361
403
|
if (debug$1) process.env.DEBUG = "true";
|
|
362
404
|
console.log();
|
|
@@ -372,7 +414,7 @@ async function check(options = {}) {
|
|
|
372
414
|
packageJson
|
|
373
415
|
});
|
|
374
416
|
if (tools.length === 0) {
|
|
375
|
-
if (isDebug
|
|
417
|
+
if (isDebug) console.log("No tools detected!");
|
|
376
418
|
else console.log("No tools detected! Run with --debug for more info");
|
|
377
419
|
console.log();
|
|
378
420
|
process.exit(1);
|
|
@@ -381,7 +423,7 @@ async function check(options = {}) {
|
|
|
381
423
|
const startTime = performance.now();
|
|
382
424
|
const problems$1 = await (fix ? tool.fix ?? tool.check : tool.check)();
|
|
383
425
|
problems$1.forEach((problem) => {
|
|
384
|
-
problem.file = resolve(root
|
|
426
|
+
problem.file = resolve(root, problem.file);
|
|
385
427
|
});
|
|
386
428
|
const duration = humanMs(performance.now() - startTime);
|
|
387
429
|
const title = `${tool.name} ${dim(`(${duration})`)}`;
|
|
@@ -409,7 +451,7 @@ async function check(options = {}) {
|
|
|
409
451
|
}, /* @__PURE__ */ new Map());
|
|
410
452
|
console.log([...groupedProblems.values()].map(renderProblemGroup).join("\n"));
|
|
411
453
|
const files = Object.entries(problems.reduce((acc, problem) => {
|
|
412
|
-
const file = "." + sep + relative(
|
|
454
|
+
const file = "." + sep + relative(root, problem.file);
|
|
413
455
|
acc[file] ??= 0;
|
|
414
456
|
acc[file]++;
|
|
415
457
|
return acc;
|
|
@@ -431,7 +473,7 @@ async function findInstalledTools(opts) {
|
|
|
431
473
|
isInstalled: !!opts.packageJson.devDependencies?.[tool.packageName]
|
|
432
474
|
};
|
|
433
475
|
}));
|
|
434
|
-
if (isDebug
|
|
476
|
+
if (isDebug) {
|
|
435
477
|
const getTools = (isInstalled) => status.filter((item) => item.isInstalled === isInstalled).map((item) => item.tool.name).join(", ");
|
|
436
478
|
debug(`Installed: ${getTools(true) || "(none)"}`);
|
|
437
479
|
debug(`Skipping: ${getTools(false) || "(none)"} `);
|
|
@@ -444,7 +486,7 @@ function plural(count, singular, plural$1) {
|
|
|
444
486
|
function renderProblemGroup(problems) {
|
|
445
487
|
const renderedProblems = problems.map(renderProblem);
|
|
446
488
|
const problem = problems[0];
|
|
447
|
-
const path = relative(
|
|
489
|
+
const path = relative(cwd, problem.file);
|
|
448
490
|
const link = dim(`→ .${sep}${problem.location ? `${path}:${problem.location.line}:${problem.location.column}` : path}`);
|
|
449
491
|
return `${renderedProblems.join("\n")}\n ${link}`;
|
|
450
492
|
}
|
|
@@ -455,4 +497,4 @@ function renderProblem(problem) {
|
|
|
455
497
|
}
|
|
456
498
|
|
|
457
499
|
//#endregion
|
|
458
|
-
export { ALL_TOOLS as i, renderProblem as n, renderProblemGroup as r, check as t };
|
|
500
|
+
export { isCi as a, ALL_TOOLS as i, renderProblem as n, renderProblemGroup as r, check as t };
|
package/package.json
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aklinker1/check",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"check",
|
|
6
|
+
"eslint",
|
|
7
|
+
"format",
|
|
8
|
+
"lint",
|
|
9
|
+
"oxfmt",
|
|
10
|
+
"prettier",
|
|
11
|
+
"publint",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/aklinker1/check",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Aaron Klinker",
|
|
18
|
+
"email": "aaronklinker1+npm@gmail.com"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"url": "https://github.com/aklinker1/check"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"check": "bin/check.mjs"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin",
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
5
30
|
"type": "module",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
6
39
|
"scripts": {
|
|
7
40
|
"build": "tsdown src/index.ts src/cli.ts",
|
|
8
41
|
"check": "bun src/cli.ts",
|
|
9
|
-
"prepack": "bun run build"
|
|
10
|
-
"prepublish": "bun run build"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"ci-info": "*"
|
|
42
|
+
"prepack": "bun run build"
|
|
14
43
|
},
|
|
15
44
|
"devDependencies": {
|
|
16
45
|
"@types/bun": "latest",
|
|
17
46
|
"@typescript/native-preview": "^7.0.0-dev.20251114.1",
|
|
47
|
+
"oxfmt": "^0.40.0",
|
|
18
48
|
"oxlint": "^1.22.0",
|
|
19
49
|
"publint": "^0.3.14",
|
|
20
50
|
"tsdown": "^0.15.9",
|
|
21
51
|
"typescript": "^5.9.3"
|
|
22
52
|
},
|
|
23
|
-
"
|
|
24
|
-
"url": "https://github.com/aklinker1/check"
|
|
25
|
-
},
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"homepage": "https://github.com/aklinker1/check",
|
|
28
|
-
"author": {
|
|
29
|
-
"name": "Aaron Klinker",
|
|
30
|
-
"email": "aaronklinker1+npm@gmail.com"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"lint",
|
|
34
|
-
"format",
|
|
35
|
-
"check",
|
|
36
|
-
"eslint",
|
|
37
|
-
"publint",
|
|
38
|
-
"prettier",
|
|
39
|
-
"typescript"
|
|
40
|
-
],
|
|
41
|
-
"exports": {
|
|
42
|
-
".": {
|
|
43
|
-
"types": "./dist/index.d.ts",
|
|
44
|
-
"import": "./dist/index.js"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"module": "./dist/index.js",
|
|
48
|
-
"types": "./dist/index.d.ts",
|
|
49
|
-
"files": [
|
|
50
|
-
"bin",
|
|
51
|
-
"dist"
|
|
52
|
-
],
|
|
53
|
-
"bin": {
|
|
54
|
-
"check": "bin/check.mjs"
|
|
55
|
-
}
|
|
53
|
+
"packageManager": "bun@1.3.2"
|
|
56
54
|
}
|