@aklinker1/check 2.1.2 → 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-CKPF6CV1.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.1.2";
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-CKPF6CV1.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 }) => {
@@ -227,9 +345,16 @@ const typescript = async ({ root, packageJson }) => {
227
345
  cmd: "vue-tsc --noEmit --pretty false",
228
346
  packageName: "vue-tsc"
229
347
  };
230
- const isVueTsc = packageJson.devDependencies?.["vue-tsc"] !== void 0;
348
+ const tsgo = {
349
+ name: "TypeScript (Go)",
350
+ cmd: "tsgo --noEmit --pretty false",
351
+ packageName: "@typescript/native-preview"
352
+ };
353
+ const isVueTsc = packageJson.devDependencies?.[vueTsc.packageName] !== void 0;
354
+ const isTsgo = packageJson.devDependencies?.[tsgo.packageName] !== void 0;
231
355
  debug("TypeScript: Is vue-tsc installed? " + isVueTsc);
232
- const mod = isVueTsc ? vueTsc : tsc;
356
+ debug("TypeScript: Is tsgo installed? " + isTsgo);
357
+ const mod = isVueTsc ? vueTsc : isTsgo ? tsgo : tsc;
233
358
  return {
234
359
  name: mod.name,
235
360
  packageName: mod.packageName,
@@ -256,6 +381,7 @@ const parseOutput = ({ stdout }) => {
256
381
  //#endregion
257
382
  //#region src/tools/index.ts
258
383
  const ALL_TOOLS = [
384
+ oxfmt,
259
385
  eslint,
260
386
  markdownlint,
261
387
  oxlint,
@@ -264,88 +390,6 @@ const ALL_TOOLS = [
264
390
  typescript
265
391
  ];
266
392
 
267
- //#endregion
268
- //#region src/tasklist/index.ts
269
- async function createTaskList(inputs, run) {
270
- const states = inputs.map((item) => ({
271
- title: item.name,
272
- state: "pending"
273
- }));
274
- const isTty = process.stderr.isTTY;
275
- let tick = 0;
276
- const render = (opts) => {
277
- if (isTty && !opts?.firstRender) readline.moveCursor(process.stderr, 0, -1 * states.length);
278
- if (isTty || opts?.firstRender || opts?.lastRender) states.forEach(({ state, title }) => {
279
- readline.clearLine(process.stderr, 0);
280
- const frames = SPINNER_FRAMES[state];
281
- process.stderr.write(`${frames[tick % frames.length]} ${title}\n`);
282
- });
283
- tick++;
284
- };
285
- render({ firstRender: true });
286
- const renderInterval = setInterval(render, SPINNER_INTERVAL_MS);
287
- try {
288
- const result = await Promise.all(inputs.map(async (input, i) => {
289
- const succeed = (title) => {
290
- if (title != null) states[i].title = title;
291
- states[i].state = "success";
292
- render();
293
- };
294
- const warn = (title) => {
295
- if (title != null) states[i].title = title;
296
- states[i].state = "warning";
297
- render();
298
- };
299
- const fail = (title) => {
300
- if (title != null) states[i].title = title;
301
- states[i].state = "error";
302
- render();
303
- };
304
- try {
305
- states[i].state = "in-progress";
306
- render();
307
- const res = await run({
308
- input,
309
- succeed,
310
- warn,
311
- fail
312
- });
313
- if (states[i].state === "in-progress") states[i].state = "success";
314
- render();
315
- return res;
316
- } catch (err) {
317
- if (err instanceof Error) fail(err.message);
318
- else fail(String(err));
319
- render();
320
- throw err;
321
- }
322
- }));
323
- render({ lastRender: true });
324
- return result;
325
- } finally {
326
- clearInterval(renderInterval);
327
- }
328
- }
329
- const SPINNER_INTERVAL_MS = 80;
330
- const SPINNER_FRAMES = {
331
- pending: [dim("□")],
332
- "in-progress": [
333
- "⠋",
334
- "⠙",
335
- "⠹",
336
- "⠸",
337
- "⠼",
338
- "⠴",
339
- "⠦",
340
- "⠧",
341
- "⠇",
342
- "⠏"
343
- ].map(cyan),
344
- success: [green("✔")],
345
- warning: [yellow("⚠")],
346
- error: [red("✗")]
347
- };
348
-
349
393
  //#endregion
350
394
  //#region src/index.ts
351
395
  async function check(options = {}) {
package/package.json CHANGED
@@ -1,8 +1,41 @@
1
1
  {
2
2
  "name": "@aklinker1/check",
3
- "version": "2.1.2",
4
- "packageManager": "bun@1.3.0",
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",
@@ -14,42 +47,12 @@
14
47
  },
15
48
  "devDependencies": {
16
49
  "@types/bun": "latest",
50
+ "@typescript/native-preview": "^7.0.0-dev.20251114.1",
51
+ "oxfmt": "^0.40.0",
17
52
  "oxlint": "^1.22.0",
18
53
  "publint": "^0.3.14",
19
54
  "tsdown": "^0.15.9",
20
55
  "typescript": "^5.9.3"
21
56
  },
22
- "repository": {
23
- "url": "https://github.com/aklinker1/check"
24
- },
25
- "license": "MIT",
26
- "homepage": "https://github.com/aklinker1/check",
27
- "author": {
28
- "name": "Aaron Klinker",
29
- "email": "aaronklinker1+npm@gmail.com"
30
- },
31
- "keywords": [
32
- "lint",
33
- "format",
34
- "check",
35
- "eslint",
36
- "publint",
37
- "prettier",
38
- "typescript"
39
- ],
40
- "exports": {
41
- ".": {
42
- "types": "./dist/index.d.ts",
43
- "import": "./dist/index.js"
44
- }
45
- },
46
- "module": "./dist/index.js",
47
- "types": "./dist/index.d.ts",
48
- "files": [
49
- "bin",
50
- "dist"
51
- ],
52
- "bin": {
53
- "check": "bin/check.mjs"
54
- }
57
+ "packageManager": "bun@1.3.2"
55
58
  }