@griffin-app/griffin-cli 1.0.26 → 1.0.28
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 +122 -367
- package/dist/cli.js +48 -29
- package/dist/commands/env.d.ts +14 -3
- package/dist/commands/env.js +24 -22
- package/dist/commands/generate-key.d.ts +5 -6
- package/dist/commands/generate-key.js +20 -26
- package/dist/commands/hub/apply.d.ts +1 -0
- package/dist/commands/hub/apply.js +44 -29
- package/dist/commands/hub/connect.d.ts +2 -1
- package/dist/commands/hub/connect.js +18 -22
- package/dist/commands/hub/destroy.d.ts +2 -1
- package/dist/commands/hub/destroy.js +123 -119
- package/dist/commands/hub/integrations.d.ts +4 -1
- package/dist/commands/hub/integrations.js +160 -141
- package/dist/commands/hub/login.d.ts +13 -1
- package/dist/commands/hub/login.js +81 -15
- package/dist/commands/hub/logout.d.ts +2 -1
- package/dist/commands/hub/logout.js +7 -12
- package/dist/commands/hub/metrics.js +29 -27
- package/dist/commands/hub/monitor.js +16 -16
- package/dist/commands/hub/notifications.d.ts +3 -6
- package/dist/commands/hub/notifications.js +52 -38
- package/dist/commands/hub/run.d.ts +1 -0
- package/dist/commands/hub/run.js +114 -87
- package/dist/commands/hub/runs.d.ts +2 -0
- package/dist/commands/hub/runs.js +47 -45
- package/dist/commands/hub/secrets.d.ts +5 -5
- package/dist/commands/hub/secrets.js +80 -72
- package/dist/commands/hub/status.d.ts +4 -1
- package/dist/commands/hub/status.js +15 -9
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +31 -25
- package/dist/commands/local/run.d.ts +1 -0
- package/dist/commands/local/run.js +34 -26
- package/dist/commands/validate.d.ts +4 -1
- package/dist/commands/validate.js +23 -14
- package/dist/commands/variables.d.ts +17 -3
- package/dist/commands/variables.js +29 -28
- package/dist/core/credentials.d.ts +15 -0
- package/dist/core/credentials.js +37 -0
- package/dist/core/variables.js +4 -0
- package/dist/monitor-runner.js +0 -12
- package/dist/utils/command-wrapper.d.ts +9 -0
- package/dist/utils/command-wrapper.js +23 -0
- package/dist/utils/output.d.ts +66 -0
- package/dist/utils/output.js +202 -0
- package/dist/utils/sdk-error.d.ts +6 -1
- package/dist/utils/sdk-error.js +107 -77
- package/package.json +2 -2
package/dist/utils/sdk-error.js
CHANGED
|
@@ -1,106 +1,136 @@
|
|
|
1
1
|
import { terminal } from "./terminal.js";
|
|
2
|
-
|
|
3
|
-
* Handle SDK errors with user-friendly messaging
|
|
4
|
-
*/
|
|
5
|
-
export function handleSDKError(error, context) {
|
|
6
|
-
const sdkError = error;
|
|
2
|
+
function getSDKErrorCodeAndMessage(sdkError, context) {
|
|
7
3
|
const contextMsg = context ? `${context}: ` : "";
|
|
8
|
-
terminal.blank();
|
|
9
|
-
// Handle network/connection errors
|
|
10
4
|
if (sdkError.message?.includes("ECONNREFUSED")) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
return {
|
|
6
|
+
code: "CONNECTION_REFUSED",
|
|
7
|
+
message: `${contextMsg}Unable to connect to Griffin Hub`,
|
|
8
|
+
hint: "Make sure the hub is running and the URL is correct.",
|
|
9
|
+
};
|
|
14
10
|
}
|
|
15
11
|
if (sdkError.message?.includes("ENOTFOUND")) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
return {
|
|
13
|
+
code: "HOST_NOT_FOUND",
|
|
14
|
+
message: `${contextMsg}Hub host not found`,
|
|
15
|
+
hint: "Check your hub URL configuration.",
|
|
16
|
+
};
|
|
19
17
|
}
|
|
20
18
|
if (sdkError.message?.includes("ETIMEDOUT")) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
return {
|
|
20
|
+
code: "TIMEOUT",
|
|
21
|
+
message: `${contextMsg}Connection to hub timed out`,
|
|
22
|
+
hint: "The hub may be unresponsive or the network is slow.",
|
|
23
|
+
};
|
|
24
24
|
}
|
|
25
|
-
// Handle HTTP status codes
|
|
26
25
|
if (sdkError.status) {
|
|
27
26
|
switch (sdkError.status) {
|
|
28
27
|
case 401:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return {
|
|
29
|
+
code: "AUTH_FAILED",
|
|
30
|
+
message: `${contextMsg}Authentication failed`,
|
|
31
|
+
hint: "Your API token may be invalid or expired. Run 'griffin auth login' to authenticate again.",
|
|
32
|
+
};
|
|
33
33
|
case 403:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
return {
|
|
35
|
+
code: "ACCESS_DENIED",
|
|
36
|
+
message: `${contextMsg}Access denied`,
|
|
37
|
+
hint: "You don't have permission to perform this action.",
|
|
38
|
+
};
|
|
37
39
|
case 404:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
return {
|
|
41
|
+
code: "NOT_FOUND",
|
|
42
|
+
message: `${contextMsg}Resource not found`,
|
|
43
|
+
details: sdkError.url ? { url: sdkError.url } : undefined,
|
|
44
|
+
hint: "The requested resource may not exist on the hub.",
|
|
45
|
+
};
|
|
44
46
|
case 409:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return terminal.exit(1);
|
|
47
|
+
return {
|
|
48
|
+
code: "CONFLICT",
|
|
49
|
+
message: `${contextMsg}Conflict`,
|
|
50
|
+
details: sdkError.body?.message ? { message: sdkError.body.message } : undefined,
|
|
51
|
+
hint: "The operation conflicts with the current state.",
|
|
52
|
+
};
|
|
53
53
|
case 422:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
terminal.dim("The request data is invalid.");
|
|
66
|
-
}
|
|
67
|
-
return terminal.exit(1);
|
|
54
|
+
return {
|
|
55
|
+
code: "VALIDATION_ERROR",
|
|
56
|
+
message: `${contextMsg}Validation error`,
|
|
57
|
+
details: sdkError.body?.message
|
|
58
|
+
? { message: sdkError.body.message }
|
|
59
|
+
: sdkError.body?.errors
|
|
60
|
+
? { errors: sdkError.body.errors }
|
|
61
|
+
: undefined,
|
|
62
|
+
hint: "The request data is invalid.",
|
|
63
|
+
};
|
|
68
64
|
case 429:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
return {
|
|
66
|
+
code: "RATE_LIMITED",
|
|
67
|
+
message: `${contextMsg}Rate limit exceeded`,
|
|
68
|
+
hint: "Too many requests. Please wait and try again.",
|
|
69
|
+
};
|
|
72
70
|
case 500:
|
|
73
71
|
case 502:
|
|
74
72
|
case 503:
|
|
75
73
|
case 504:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
return {
|
|
75
|
+
code: "SERVER_ERROR",
|
|
76
|
+
message: `${contextMsg}Hub server error`,
|
|
77
|
+
details: {
|
|
78
|
+
status: sdkError.status,
|
|
79
|
+
statusText: sdkError.statusText,
|
|
80
|
+
...(sdkError.body?.message && { bodyMessage: sdkError.body.message }),
|
|
81
|
+
},
|
|
82
|
+
hint: "The hub encountered an internal error.",
|
|
83
|
+
};
|
|
85
84
|
default:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
return {
|
|
86
|
+
code: "UNKNOWN_ERROR",
|
|
87
|
+
message: `${contextMsg}Request failed`,
|
|
88
|
+
details: {
|
|
89
|
+
status: sdkError.status,
|
|
90
|
+
statusText: sdkError.statusText,
|
|
91
|
+
...(sdkError.body?.message && { bodyMessage: sdkError.body.message }),
|
|
92
|
+
...(sdkError.message && { message: sdkError.message }),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
return {
|
|
98
|
+
code: "UNKNOWN_ERROR",
|
|
99
|
+
message: `${contextMsg}${sdkError.message || "An unexpected error occurred"}`,
|
|
100
|
+
hint: sdkError.stack ? "Run with DEBUG=* for more details." : undefined,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle SDK errors with user-friendly messaging (terminal output)
|
|
105
|
+
*/
|
|
106
|
+
export function handleSDKError(error, context) {
|
|
107
|
+
const sdkError = error;
|
|
108
|
+
const { message, details, hint } = getSDKErrorCodeAndMessage(sdkError, context);
|
|
109
|
+
terminal.blank();
|
|
110
|
+
terminal.error(message);
|
|
111
|
+
if (hint)
|
|
112
|
+
terminal.dim(hint);
|
|
113
|
+
if (details !== undefined && details !== null) {
|
|
114
|
+
if (typeof details === "object" && "message" in details) {
|
|
115
|
+
terminal.dim(String(details.message));
|
|
116
|
+
}
|
|
117
|
+
else if (typeof details === "object" && "errors" in details) {
|
|
118
|
+
terminal.dim("Validation failed:");
|
|
119
|
+
for (const err of details.errors) {
|
|
120
|
+
terminal.dim(` - ${err.message || err}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
101
123
|
}
|
|
102
124
|
return terminal.exit(1);
|
|
103
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Handle SDK errors using OutputContext (JSON or human output)
|
|
128
|
+
*/
|
|
129
|
+
export function handleSDKErrorWithOutput(error, output, context) {
|
|
130
|
+
const sdkError = error;
|
|
131
|
+
const { code, message, details, hint } = getSDKErrorCodeAndMessage(sdkError, context);
|
|
132
|
+
output.flushError(code, message, details, hint);
|
|
133
|
+
}
|
|
104
134
|
/**
|
|
105
135
|
* Wrap an SDK call with error handling
|
|
106
136
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffin-app/griffin-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "CLI tool for running and managing griffin API tests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@griffin-app/griffin-hub-sdk": "1.0.25",
|
|
28
28
|
"@griffin-app/griffin-executor": "0.1.1",
|
|
29
|
-
"@griffin-app/griffin-core": "0.2.
|
|
29
|
+
"@griffin-app/griffin-core": "0.2.2",
|
|
30
30
|
"better-auth": "^1.4.17",
|
|
31
31
|
"cli-table3": "^0.6.5",
|
|
32
32
|
"commander": "^12.1.0",
|