@aklinker1/check 2.2.0 → 2.3.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/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 when no problems exist.
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,8 @@
1
- import { i as ALL_TOOLS, t as check } from "./src-DLILuPNJ.js";
1
+ import { i as ALL_TOOLS, t as check } from "./src-B6y5RIK9.js";
2
2
  import { isCI } from "ci-info";
3
3
 
4
4
  //#region package.json
5
- var version = "2.2.0";
5
+ var version = "2.3.0";
6
6
 
7
7
  //#endregion
8
8
  //#region src/cli.ts
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as renderProblem, r as renderProblemGroup, t as check } from "./src-DLILuPNJ.js";
1
+ import { n as renderProblem, r as renderProblemGroup, t as check } from "./src-B6y5RIK9.js";
2
2
 
3
3
  export { check, renderProblem, renderProblemGroup };
@@ -1,8 +1,8 @@
1
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
2
  import { readFile } from "node:fs/promises";
3
+ import { join, relative, resolve, sep } from "node:path";
4
+ import readline from "node:readline";
5
+ import { spawn } from "node:child_process";
6
6
 
7
7
  //#region src/utils.ts
8
8
  function exec(cmd, opts) {
@@ -63,6 +63,88 @@ function debug(message) {
63
63
  if (isDebug()) console.debug(dim("⚙ " + message));
64
64
  }
65
65
 
66
+ //#endregion
67
+ //#region src/tasklist/index.ts
68
+ async function createTaskList(inputs, run) {
69
+ const states = inputs.map((item) => ({
70
+ title: item.name,
71
+ state: "pending"
72
+ }));
73
+ const isTty = process.stderr.isTTY;
74
+ let tick = 0;
75
+ const render = (opts) => {
76
+ if (isTty && !opts?.firstRender) readline.moveCursor(process.stderr, 0, -1 * states.length);
77
+ if (isTty || opts?.firstRender || opts?.lastRender) states.forEach(({ state, title }) => {
78
+ readline.clearLine(process.stderr, 0);
79
+ const frames = SPINNER_FRAMES[state];
80
+ process.stderr.write(`${frames[tick % frames.length]} ${title}\n`);
81
+ });
82
+ tick++;
83
+ };
84
+ render({ firstRender: true });
85
+ const renderInterval = setInterval(render, SPINNER_INTERVAL_MS);
86
+ try {
87
+ const result = await Promise.all(inputs.map(async (input, i) => {
88
+ const succeed = (title) => {
89
+ if (title != null) states[i].title = title;
90
+ states[i].state = "success";
91
+ render();
92
+ };
93
+ const warn = (title) => {
94
+ if (title != null) states[i].title = title;
95
+ states[i].state = "warning";
96
+ render();
97
+ };
98
+ const fail = (title) => {
99
+ if (title != null) states[i].title = title;
100
+ states[i].state = "error";
101
+ render();
102
+ };
103
+ try {
104
+ states[i].state = "in-progress";
105
+ render();
106
+ const res = await run({
107
+ input,
108
+ succeed,
109
+ warn,
110
+ fail
111
+ });
112
+ if (states[i].state === "in-progress") states[i].state = "success";
113
+ render();
114
+ return res;
115
+ } catch (err) {
116
+ if (err instanceof Error) fail(err.message);
117
+ else fail(String(err));
118
+ render();
119
+ throw err;
120
+ }
121
+ }));
122
+ render({ lastRender: true });
123
+ return result;
124
+ } finally {
125
+ clearInterval(renderInterval);
126
+ }
127
+ }
128
+ const SPINNER_INTERVAL_MS = 80;
129
+ const SPINNER_FRAMES = {
130
+ pending: [dim("□")],
131
+ "in-progress": [
132
+ "⠋",
133
+ "⠙",
134
+ "⠹",
135
+ "⠸",
136
+ "⠼",
137
+ "⠴",
138
+ "⠦",
139
+ "⠧",
140
+ "⠇",
141
+ "⠏"
142
+ ].map(cyan),
143
+ success: [green("✔")],
144
+ warning: [yellow("⚠")],
145
+ error: [red("✗")]
146
+ };
147
+
66
148
  //#endregion
67
149
  //#region src/tools/eslint.ts
68
150
  const eslint = ({ root }) => {
@@ -71,11 +153,11 @@ const eslint = ({ root }) => {
71
153
  return {
72
154
  name: "ESLint",
73
155
  packageName: "eslint",
74
- check: () => execAndParse(checkCmd, root, parseOutput$5),
75
- fix: () => execAndParse(fixCmd, root, parseOutput$5)
156
+ check: () => execAndParse(checkCmd, root, parseOutput$6),
157
+ fix: () => execAndParse(fixCmd, root, parseOutput$6)
76
158
  };
77
159
  };
78
- const parseOutput$5 = ({ stdout, stderr }) => {
160
+ const parseOutput$6 = ({ stdout, stderr }) => {
79
161
  return `${stdout}\n${stderr}`.split(/\r?\n/).reduce((acc, line) => {
80
162
  const groups = /^(?<file>.*?): line (?<line>[0-9]+), col (?<column>[0-9]+), (?<kind>\S+) - (?<message>.*?) \((?<rule>\S*?)\)$/.exec(line)?.groups;
81
163
  if (groups) acc.push({
@@ -100,11 +182,11 @@ const markdownlint = ({ root }) => {
100
182
  return {
101
183
  name: "Markdownlint",
102
184
  packageName: "markdownlint-cli",
103
- check: () => execAndParse(checkCmd, root, parseOutput$4),
104
- fix: () => execAndParse(fixCmd, root, parseOutput$4)
185
+ check: () => execAndParse(checkCmd, root, parseOutput$5),
186
+ fix: () => execAndParse(fixCmd, root, parseOutput$5)
105
187
  };
106
188
  };
107
- const parseOutput$4 = ({ stderr: _stderr }) => {
189
+ const parseOutput$5 = ({ stderr: _stderr }) => {
108
190
  const stderr = _stderr.trim();
109
191
  if (!stderr) return [];
110
192
  return JSON.parse(stderr).map((warning) => ({
@@ -119,6 +201,42 @@ const parseOutput$4 = ({ stderr: _stderr }) => {
119
201
  }));
120
202
  };
121
203
 
204
+ //#endregion
205
+ //#region src/tools/oxfmt.ts
206
+ const oxfmt = ({ root }) => {
207
+ const checkCmd = "oxfmt . --list-different";
208
+ const fixCmd = "oxfmt .";
209
+ return {
210
+ name: "Oxfmt",
211
+ packageName: "oxfmt",
212
+ check: () => execAndParse(checkCmd, root, parseOutput$4),
213
+ fix: () => execAndParse(fixCmd, root, parseOutput$4)
214
+ };
215
+ };
216
+ const NEWLINE_REGEX = /\r?\n/;
217
+ const SYNTAX_ERROR_REGEX = /^\s*?[×✕]\s+(?<message>.+?)\r?\n\s+╭─\[(?<file>.+?):(?<line>[0-9]+):(?<column>[0-9]+)\]/;
218
+ const parseOutput$4 = ({ stdout, stderr }) => {
219
+ const problems = [];
220
+ for (const { groups } of stderr.trim().matchAll(new RegExp(SYNTAX_ERROR_REGEX, "g"))) problems.push({
221
+ file: groups.file,
222
+ kind: "error",
223
+ message: groups.message,
224
+ location: {
225
+ line: parseInt(groups.line, 10),
226
+ column: parseInt(groups.column, 10)
227
+ }
228
+ });
229
+ for (const line of stdout.trim().split(NEWLINE_REGEX)) {
230
+ if (!line || line.includes(" ")) continue;
231
+ problems.push({
232
+ file: line.trim(),
233
+ kind: "warning",
234
+ message: "Not formatted."
235
+ });
236
+ }
237
+ return problems;
238
+ };
239
+
122
240
  //#endregion
123
241
  //#region src/tools/oxlint.ts
124
242
  const oxlint = ({ root }) => {
@@ -263,6 +381,7 @@ const parseOutput = ({ stdout }) => {
263
381
  //#endregion
264
382
  //#region src/tools/index.ts
265
383
  const ALL_TOOLS = [
384
+ oxfmt,
266
385
  eslint,
267
386
  markdownlint,
268
387
  oxlint,
@@ -271,88 +390,6 @@ const ALL_TOOLS = [
271
390
  typescript
272
391
  ];
273
392
 
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
393
  //#endregion
357
394
  //#region src/index.ts
358
395
  async function check(options = {}) {
package/package.json CHANGED
@@ -1,8 +1,41 @@
1
1
  {
2
2
  "name": "@aklinker1/check",
3
- "version": "2.2.0",
4
- "packageManager": "bun@1.3.2",
3
+ "version": "2.3.0",
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",
@@ -15,42 +48,11 @@
15
48
  "devDependencies": {
16
49
  "@types/bun": "latest",
17
50
  "@typescript/native-preview": "^7.0.0-dev.20251114.1",
51
+ "oxfmt": "^0.40.0",
18
52
  "oxlint": "^1.22.0",
19
53
  "publint": "^0.3.14",
20
54
  "tsdown": "^0.15.9",
21
55
  "typescript": "^5.9.3"
22
56
  },
23
- "repository": {
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
- }
57
+ "packageManager": "bun@1.3.2"
56
58
  }