@aklinker1/check 1.1.0 → 1.2.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/dist/index.mjs CHANGED
@@ -81,10 +81,13 @@ export async function check(options = {}) {
81
81
  process.exit(problems.length);
82
82
  }
83
83
  async function findInstalledTools(root) {
84
- const status = await p(ALL_TOOLS).map(async (tool) => ({
85
- tool,
86
- isInstalled: await tool.isInstalled(root)
87
- })).promise;
84
+ const status = await p(ALL_TOOLS).map(async (tool) => {
85
+ const t = typeof tool === "function" ? await tool(root) : tool;
86
+ return {
87
+ tool: t,
88
+ isInstalled: await t.isInstalled(root)
89
+ };
90
+ }).promise;
88
91
  if (isDebug()) {
89
92
  const getTools = (isInstalled) => status.filter((item) => item.isInstalled === isInstalled).map((item) => item.tool.name).join(", ");
90
93
  const installed = getTools(true);
@@ -1,2 +1 @@
1
- import type { Tool } from "../types";
2
- export declare const ALL_TOOLS: Tool[];
1
+ export declare const ALL_TOOLS: (import("..").Tool | ((root: string | undefined) => Promise<import("..").Tool>))[];
@@ -1,3 +1,3 @@
1
1
  import type { Tool, OutputParser } from "../types";
2
- export declare const typescript: Tool;
2
+ export declare const typescript: (root: string | undefined) => Promise<Tool>;
3
3
  export declare const parseOuptut: OutputParser;
@@ -1,10 +1,24 @@
1
- import { execAndParse, isBinInstalled } from "../utils.mjs";
2
- const bin = "node_modules/.bin/tsc";
3
- const checkArgs = ["--noEmit", "--pretty", "false"];
4
- export const typescript = {
5
- name: "TypeScript",
6
- isInstalled: (root) => isBinInstalled(bin, root),
7
- check: (root) => execAndParse(root, bin, checkArgs, parseOuptut)
1
+ import { debug, execAndParse, isBinInstalled } from "../utils.mjs";
2
+ const tsc = {
3
+ bin: "node_modules/.bin/tsc",
4
+ args: ["--noEmit", "--pretty", "false"]
5
+ };
6
+ const vueTsc = {
7
+ bin: "node_modules/.bin/vue-tsc",
8
+ args: ["--noEmit", "--pretty", "false"]
9
+ };
10
+ export const typescript = async (root) => {
11
+ const isVueTsc = await isBinInstalled(vueTsc.bin, root);
12
+ debug("TypeScript: Is vue-tsc installed? " + isVueTsc);
13
+ const cmd = isVueTsc ? vueTsc : tsc;
14
+ const name = isVueTsc ? "TypeScript (Vue)" : "Typescript";
15
+ return {
16
+ name,
17
+ // Always check if tsc is installed
18
+ isInstalled: (root2) => isBinInstalled(tsc.bin, root2),
19
+ // Execute the other TSC binary if necessary
20
+ check: async (root2) => execAndParse(root2, cmd.bin, cmd.args, parseOuptut)
21
+ };
8
22
  };
9
23
  export const parseOuptut = ({ stdout }) => {
10
24
  return stdout.split(/\r?\n/).reduce((acc, line) => {
@@ -30,4 +30,22 @@ test.ts(5,24): error TS7006: Parameter 'a' implicitly has an 'any' type.
30
30
  }
31
31
  ]);
32
32
  });
33
+ it("should parse vue-tsc output", () => {
34
+ const stdout = `src/components/CustomListsPref.vue(46,6): error TS2345: Argument of type '{ vale: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never> & Record<...>'.
35
+ Property 'value' is missing in type '{ vale: string; }' but required in type 'Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never>'.`;
36
+ const stderr = "";
37
+ const code = 1;
38
+ expect(parseOuptut({ code, stdout, stderr })).toEqual([
39
+ {
40
+ file: "src/components/CustomListsPref.vue",
41
+ message: `Argument of type '{ vale: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never> & Record<...>'.`,
42
+ kind: "error",
43
+ location: {
44
+ line: 46,
45
+ column: 6
46
+ },
47
+ rule: "TS2345"
48
+ }
49
+ ]);
50
+ });
33
51
  });
package/dist/utils.mjs CHANGED
@@ -17,7 +17,7 @@ export async function isBinInstalled(bin, root) {
17
17
  }
18
18
  function exec(cmd, args, opts) {
19
19
  return new Promise((resolve2, reject) => {
20
- const child = spawn(cmd, args, opts);
20
+ const child = spawn(cmd, args, { ...opts, shell: true });
21
21
  let stderr = "";
22
22
  let stdout = "";
23
23
  child.stdout.on("data", (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aklinker1/check",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/aklinker1/check"