@intuned/runtime-dev 1.2.0-cli.1 → 1.2.0-cli.2
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,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
|
|
3
|
+
import { AutomationError } from "../../../common/runApi";
|
|
3
4
|
export declare class CLIError extends Error {
|
|
4
5
|
autoColor: boolean;
|
|
5
6
|
constructor(message: string, options?: {
|
|
@@ -14,6 +15,7 @@ export declare class CLIAssertionError extends CLIError {
|
|
|
14
15
|
export declare function logInvalidInput(result: z.SafeParseError<unknown>): void;
|
|
15
16
|
export declare function assertAuthEnabled(): Promise<void>;
|
|
16
17
|
export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
|
|
18
|
+
export declare function logAutomationError(error: AutomationError): void;
|
|
17
19
|
export declare function withErrorLogging<T extends any[]>(fn: (...args: T) => Promise<unknown>): (...args: T) => Promise<never>;
|
|
18
20
|
export declare function parseUrlProxy(proxyUrl: string): {
|
|
19
21
|
password: string;
|
|
@@ -7,6 +7,7 @@ exports.CLIError = exports.CLIAssertionError = void 0;
|
|
|
7
7
|
exports.assertApiFileExists = assertApiFileExists;
|
|
8
8
|
exports.assertAuthConsistent = assertAuthConsistent;
|
|
9
9
|
exports.assertAuthEnabled = assertAuthEnabled;
|
|
10
|
+
exports.logAutomationError = logAutomationError;
|
|
10
11
|
exports.logInvalidInput = logInvalidInput;
|
|
11
12
|
exports.parseUrlProxy = parseUrlProxy;
|
|
12
13
|
exports.withCLIContext = withCLIContext;
|
|
@@ -55,6 +56,15 @@ async function assertAuthConsistent(authSession) {
|
|
|
55
56
|
throw new CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
function logAutomationError(error) {
|
|
60
|
+
(0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
|
|
61
|
+
(0, _terminal.terminal)(`^r${error.error.message}^:\n`);
|
|
62
|
+
if (error.error.stack) {
|
|
63
|
+
(0, _terminal.terminal)(`^r^+Stack trace:^:\n`);
|
|
64
|
+
const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime"));
|
|
65
|
+
(0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
function withErrorLogging(fn) {
|
|
59
69
|
return async (...args) => {
|
|
60
70
|
try {
|
|
@@ -68,12 +78,7 @@ function withErrorLogging(fn) {
|
|
|
68
78
|
(0, _terminal.terminal)(`${error.message}\n`);
|
|
69
79
|
}
|
|
70
80
|
} else if (error instanceof _runApi.AutomationError) {
|
|
71
|
-
(
|
|
72
|
-
(0, _terminal.terminal)(`^r${error.error.message}^:\n`);
|
|
73
|
-
if (error.error.stack) {
|
|
74
|
-
(0, _terminal.terminal)(`^r^+Stack trace:^:\n`);
|
|
75
|
-
(0, _terminal.terminal)(`^r${error.error.stack}^:\n`);
|
|
76
|
-
}
|
|
81
|
+
logAutomationError(error);
|
|
77
82
|
} else {
|
|
78
83
|
(0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
|
|
79
84
|
}
|
|
@@ -51,7 +51,8 @@ async function executeRunApiCLI({
|
|
|
51
51
|
});
|
|
52
52
|
} catch (error) {
|
|
53
53
|
if (error instanceof _runApi.AutomationError) {
|
|
54
|
-
(0,
|
|
54
|
+
(0, _helpers.logAutomationError)(error);
|
|
55
|
+
(0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed^:\n`);
|
|
55
56
|
continue;
|
|
56
57
|
}
|
|
57
58
|
throw error;
|