@jakubmazanec/cli 0.5.1-unstable.4bad639f → 0.5.2-next.ee433a8c
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { ParsingError, ValidationError } from "@jakubmazanec/args";
|
|
3
|
-
import {
|
|
4
|
-
import { ZodError } from "zod";
|
|
3
|
+
import { prettifyError, ZodError } from "zod";
|
|
5
4
|
export function getErrorDetail(error) {
|
|
6
5
|
if (error instanceof ParsingError) {
|
|
7
6
|
switch (error.code) {
|
|
@@ -36,7 +35,7 @@ export function getErrorDetail(error) {
|
|
|
36
35
|
if (error instanceof ZodError) {
|
|
37
36
|
let errorDetail = {
|
|
38
37
|
label: "Error",
|
|
39
|
-
description:
|
|
38
|
+
description: prettifyError(error)
|
|
40
39
|
};
|
|
41
40
|
return errorDetail;
|
|
42
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/ui/getErrorDetail.ts"],
|
|
4
|
-
"sourcesContent": ["import {ParsingError, ValidationError} from '@jakubmazanec/args';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAQ,cAAc,uBAAsB;AAC5C,SAAQ,
|
|
4
|
+
"sourcesContent": ["import {ParsingError, ValidationError} from '@jakubmazanec/args';\nimport {prettifyError, ZodError} from 'zod';\n\nimport {type ErrorDetail} from './ErrorDetail.js';\n\n/**\n * Creates detailed information about an error.\n */\nexport function getErrorDetail(error: unknown): ErrorDetail {\n // TODO: add all codes\n if (error instanceof ParsingError) {\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- remove this when the TODO comment above is resolved\n switch (error.code) {\n default: {\n return {\n label: 'Parsing error',\n description: error.message,\n };\n }\n }\n }\n\n // TODO: add all codes\n if (error instanceof ValidationError) {\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- remove this when the TODO comment above is resolved\n switch (error.code) {\n default: {\n return {\n label: 'Validation error',\n description: error.message,\n };\n }\n }\n }\n\n // TODO: add all built-in errors\n if (error instanceof ReferenceError) {\n let errorDetail: ErrorDetail = {\n label: 'Error',\n description: error.message,\n };\n\n if (error.stack) {\n errorDetail.stack = error.stack;\n }\n\n return errorDetail;\n }\n\n if (error instanceof ZodError) {\n let errorDetail: ErrorDetail = {\n label: 'Error',\n description: prettifyError(error),\n };\n\n return errorDetail;\n }\n\n if (error instanceof Error) {\n let errorDetail: ErrorDetail = {\n label: 'Error',\n description: error.message,\n };\n\n if (error.stack) {\n errorDetail.stack = error.stack;\n }\n\n if (error.cause instanceof Error) {\n errorDetail.cause = {\n description: error.cause.message,\n };\n\n if (error.cause.stack) {\n errorDetail.cause.stack = error.cause.stack;\n }\n }\n\n return errorDetail;\n }\n\n return {\n label: 'Error',\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAQ,cAAc,uBAAsB;AAC5C,SAAQ,eAAe,gBAAe;AAO/B,gBAAS,eAAe,OAA6B;AAE1D,MAAI,iBAAiB,cAAc;AAEjC,YAAQ,MAAM,MAAM;AAAA,MAClB,SAAS;AACP,eAAO;AAAA,UACL,OAAO;AAAA,UACP,aAAa,MAAM;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,iBAAiB,iBAAiB;AAEpC,YAAQ,MAAM,MAAM;AAAA,MAClB,SAAS;AACP,eAAO;AAAA,UACL,OAAO;AAAA,UACP,aAAa,MAAM;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,iBAAiB,gBAAgB;AACnC,QAAI,cAA2B;AAAA,MAC7B,OAAO;AAAA,MACP,aAAa,MAAM;AAAA,IACrB;AAEA,QAAI,MAAM,OAAO;AACf,kBAAY,QAAQ,MAAM;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,UAAU;AAC7B,QAAI,cAA2B;AAAA,MAC7B,OAAO;AAAA,MACP,aAAa,cAAc,KAAK;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,OAAO;AAC1B,QAAI,cAA2B;AAAA,MAC7B,OAAO;AAAA,MACP,aAAa,MAAM;AAAA,IACrB;AAEA,QAAI,MAAM,OAAO;AACf,kBAAY,QAAQ,MAAM;AAAA,IAC5B;AAEA,QAAI,MAAM,iBAAiB,OAAO;AAChC,kBAAY,QAAQ;AAAA,QAClB,aAAa,MAAM,MAAM;AAAA,MAC3B;AAEA,UAAI,MAAM,MAAM,OAAO;AACrB,oBAAY,MAAM,QAAQ,MAAM,MAAM;AAAA,MACxC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2-next.ee433a8c",
|
|
4
4
|
"description": "TypeScript-first library for building CLIs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"typecheck": "tsc --project tsconfig.typecheck.json"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jakubmazanec/args": "2.0.
|
|
31
|
-
"@jakubmazanec/error": "3.0.
|
|
32
|
-
"@jakubmazanec/ts-utils": "3.0.
|
|
33
|
-
"@jakubmazanec/zod-utils": "
|
|
30
|
+
"@jakubmazanec/args": "^2.0.0",
|
|
31
|
+
"@jakubmazanec/error": "3.0.14-next.ee433a8c",
|
|
32
|
+
"@jakubmazanec/ts-utils": "^3.0.0",
|
|
33
|
+
"@jakubmazanec/zod-utils": "3.0.0-next.ee433a8c",
|
|
34
34
|
"chalk": "^5.4.1",
|
|
35
35
|
"fs-extra": "^11.3.0",
|
|
36
36
|
"latest-version": "^9.0.0",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"react-error-boundary": "^6.0.0",
|
|
39
|
-
"zod": "^
|
|
39
|
+
"zod": "^4.0.17"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@jakubmazanec/eslint-config": "4.1.
|
|
42
|
+
"@jakubmazanec/eslint-config": "^4.1.0",
|
|
43
43
|
"@types/fs-extra": "^11.0.4",
|
|
44
44
|
"@types/lodash": "^4.17.18",
|
|
45
45
|
"@types/node": "^24.0.4",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"packageManager": "npm@11.3.0",
|
|
68
68
|
"engines": {
|
|
69
|
-
"node": "^24.3.0"
|
|
69
|
+
"node": "^24.3.0",
|
|
70
|
+
"npm": "^11.3.0"
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {ParsingError, ValidationError} from '@jakubmazanec/args';
|
|
2
|
-
import {
|
|
3
|
-
import {ZodError} from 'zod';
|
|
2
|
+
import {prettifyError, ZodError} from 'zod';
|
|
4
3
|
|
|
5
4
|
import {type ErrorDetail} from './ErrorDetail.js';
|
|
6
5
|
|
|
@@ -51,7 +50,7 @@ export function getErrorDetail(error: unknown): ErrorDetail {
|
|
|
51
50
|
if (error instanceof ZodError) {
|
|
52
51
|
let errorDetail: ErrorDetail = {
|
|
53
52
|
label: 'Error',
|
|
54
|
-
description:
|
|
53
|
+
description: prettifyError(error),
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
return errorDetail;
|