@mittwald/cli 1.0.0-alpha.41 → 1.0.0-alpha.43
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 +457 -42
- package/dist/commands/app/download.d.ts +2 -0
- package/dist/commands/app/download.js +9 -2
- package/dist/commands/app/list.js +2 -3
- package/dist/commands/app/ssh.d.ts +2 -0
- package/dist/commands/app/ssh.js +22 -10
- package/dist/commands/app/upload.d.ts +19 -0
- package/dist/commands/app/upload.js +76 -0
- package/dist/commands/database/mysql/dump.d.ts +3 -2
- package/dist/commands/database/mysql/dump.js +21 -56
- package/dist/commands/database/mysql/import.d.ts +21 -0
- package/dist/commands/database/mysql/import.js +72 -0
- package/dist/commands/database/mysql/port-forward.d.ts +2 -0
- package/dist/commands/database/mysql/port-forward.js +9 -11
- package/dist/commands/database/mysql/shell.d.ts +3 -0
- package/dist/commands/database/mysql/shell.js +14 -15
- package/dist/commands/database/redis/shell.d.ts +3 -0
- package/dist/commands/database/redis/shell.js +15 -4
- package/dist/commands/ddev/init.js +5 -3
- package/dist/commands/domain/dnszone/list.js +1 -1
- package/dist/commands/domain/dnszone/update.js +1 -1
- package/dist/commands/domain/virtualhost/create.js +1 -1
- package/dist/commands/mail/address/create.d.ts +1 -1
- package/dist/commands/mail/address/create.js +6 -6
- package/dist/commands/mail/address/get.js +1 -1
- package/dist/commands/mail/address/list.js +1 -1
- package/dist/commands/mail/address/update.d.ts +35 -0
- package/dist/commands/mail/address/update.js +169 -0
- package/dist/commands/mail/deliverybox/get.js +1 -1
- package/dist/commands/mail/deliverybox/list.js +1 -1
- package/dist/commands/project/ssh.d.ts +5 -0
- package/dist/commands/project/ssh.js +12 -12
- package/dist/lib/app/custom_installation.d.ts +7 -0
- package/dist/lib/app/custom_installation.js +16 -0
- package/dist/lib/app/flags.js +4 -0
- package/dist/lib/context.d.ts +1 -1
- package/dist/lib/context_flags.d.ts +4 -0
- package/dist/lib/context_flags.js +14 -1
- package/dist/lib/database/mysql/connect.d.ts +22 -14
- package/dist/lib/database/mysql/connect.js +15 -0
- package/dist/lib/database/mysql/flags.d.ts +4 -0
- package/dist/lib/database/mysql/flags.js +10 -0
- package/dist/lib/database/mysql/temp_user.d.ts +13 -0
- package/dist/lib/database/mysql/temp_user.js +52 -0
- package/dist/lib/database/redis/connect.d.ts +1 -1
- package/dist/lib/database/redis/connect.js +5 -6
- package/dist/lib/ddev/config_builder.js +5 -18
- package/dist/lib/ddev/flags.js +2 -0
- package/dist/lib/ddev/init_projecttype.d.ts +32 -0
- package/dist/lib/ddev/init_projecttype.js +102 -0
- package/dist/lib/error/UnexpectedShortIDPassedError.d.ts +5 -0
- package/dist/lib/error/UnexpectedShortIDPassedError.js +10 -0
- package/dist/lib/language.d.ts +10 -0
- package/dist/lib/language.js +12 -0
- package/dist/lib/mail/flags.d.ts +1 -0
- package/dist/lib/mail/flags.js +20 -0
- package/dist/lib/project/flags.js +9 -2
- package/dist/lib/ssh/connection.d.ts +22 -0
- package/dist/lib/ssh/connection.js +19 -0
- package/dist/lib/ssh/doc.d.ts +10 -0
- package/dist/lib/ssh/doc.js +14 -0
- package/dist/lib/ssh/exec.d.ts +6 -1
- package/dist/lib/ssh/exec.js +8 -5
- package/dist/lib/ssh/flags.d.ts +6 -1
- package/dist/lib/ssh/flags.js +11 -0
- package/dist/rendering/react/RenderBaseCommand.js +12 -5
- package/dist/rendering/react/components/AppInstallation/AppInstallationDetails.js +2 -4
- package/dist/rendering/react/components/Error/APIError.d.ts +13 -0
- package/dist/rendering/react/components/Error/APIError.js +29 -0
- package/dist/rendering/react/components/Error/ErrorBox.d.ts +4 -0
- package/dist/rendering/react/components/Error/ErrorBox.js +14 -0
- package/dist/rendering/react/components/Error/ErrorStack.d.ts +4 -0
- package/dist/rendering/react/components/Error/ErrorStack.js +7 -0
- package/dist/rendering/react/components/Error/ErrorText.d.ts +3 -0
- package/dist/rendering/react/components/Error/ErrorText.js +6 -0
- package/dist/rendering/react/components/Error/GenericError.d.ts +12 -0
- package/dist/rendering/react/components/Error/GenericError.js +13 -0
- package/dist/rendering/react/components/Error/InvalidArgsError.d.ts +5 -0
- package/dist/rendering/react/components/Error/InvalidArgsError.js +8 -0
- package/dist/rendering/react/components/Error/InvalidFlagsError.d.ts +5 -0
- package/dist/rendering/react/components/Error/InvalidFlagsError.js +8 -0
- package/dist/rendering/react/components/Error/UnexpectedShortIDPassedErrorBox.d.ts +4 -0
- package/dist/rendering/react/components/Error/UnexpectedShortIDPassedErrorBox.js +7 -0
- package/dist/rendering/react/components/ErrorBoundary.d.ts +20 -0
- package/dist/rendering/react/components/ErrorBoundary.js +32 -0
- package/dist/rendering/react/components/ErrorBox.d.ts +0 -1
- package/dist/rendering/react/components/ErrorBox.js +12 -48
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import ErrorText from "./ErrorText.js";
|
|
4
|
+
/** Render the stack trace of an error. */
|
|
5
|
+
export default function ErrorStack({ err }) {
|
|
6
|
+
return (_jsxs(Box, { marginX: 2, marginY: 1, flexDirection: "column", rowGap: 1, children: [_jsx(ErrorText, { dimColor: true, bold: true, children: "ERROR STACK TRACE" }), _jsx(ErrorText, { dimColor: true, children: "Please provide this when opening a bug report." }), _jsx(ErrorText, { dimColor: true, children: err.stack })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface GenericErrorProps {
|
|
2
|
+
err: Error;
|
|
3
|
+
withStack: boolean;
|
|
4
|
+
withIssue?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Render a generic error to the terminal. This is used for errors that don't
|
|
9
|
+
* have a specific rendering function.
|
|
10
|
+
*/
|
|
11
|
+
export default function GenericError({ err, withStack, withIssue, title, }: GenericErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import ErrorStack from "./ErrorStack.js";
|
|
4
|
+
import ErrorText from "./ErrorText.js";
|
|
5
|
+
import ErrorBox from "./ErrorBox.js";
|
|
6
|
+
const issueURL = "https://github.com/mittwald/cli/issues/new";
|
|
7
|
+
/**
|
|
8
|
+
* Render a generic error to the terminal. This is used for errors that don't
|
|
9
|
+
* have a specific rendering function.
|
|
10
|
+
*/
|
|
11
|
+
export default function GenericError({ err, withStack, withIssue = true, title = "Error", }) {
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ErrorBox, { children: [_jsx(ErrorText, { bold: true, underline: true, children: title.toUpperCase() }), _jsx(ErrorText, { children: "An error occurred while executing this command:" }), _jsx(Box, { marginX: 2, children: _jsx(ErrorText, { children: err.toString() }) }), withIssue ? (_jsxs(ErrorText, { children: ["If you believe this to be a bug, please open an issue at ", issueURL, "."] })) : undefined] }), withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import ErrorBox from "./ErrorBox.js";
|
|
4
|
+
/** Render an error for invalid command arguments. */
|
|
5
|
+
export default function InvalidArgsError({ err }) {
|
|
6
|
+
const color = "yellow";
|
|
7
|
+
return (_jsxs(ErrorBox, { borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "INVALID COMMAND ARGUMENTS" }), _jsxs(Text, { color: color, children: ["The arguments that you provided for this command were invalid.", " ", err.message] })] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import ErrorBox from "./ErrorBox.js";
|
|
4
|
+
/** Render an error for invalid command flags. */
|
|
5
|
+
export default function InvalidFlagsError({ err, }) {
|
|
6
|
+
const color = "yellow";
|
|
7
|
+
return (_jsxs(ErrorBox, { borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "INVALID COMMAND FLAGS" }), _jsxs(Text, { color: color, children: ["The flags that you provided for this command were invalid. ", err.message] })] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text, Newline } from "ink";
|
|
3
|
+
import ErrorBox from "./ErrorBox.js";
|
|
4
|
+
export default function UnexpectedShortIDPassedErrorBox({ err, }) {
|
|
5
|
+
const color = "yellow";
|
|
6
|
+
return (_jsxs(ErrorBox, { borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "UNEXPECTED RESOURCE TYPE" }), _jsxs(Text, { color: color, children: ["Whoops! It looks like you passed an ID for an unexpected resource type.", _jsx(Newline, {}), err.message] })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, PropsWithChildren } from "react";
|
|
2
|
+
interface ErrorBoundaryProps {
|
|
3
|
+
onError?: (error: Error) => void;
|
|
4
|
+
}
|
|
5
|
+
interface ErrorBoundaryState {
|
|
6
|
+
error?: Error;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* ErrorBoundary is a component that catches rendering errors in its children
|
|
10
|
+
* and displays an appropriately-styled error message.
|
|
11
|
+
*
|
|
12
|
+
* @see https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
|
|
13
|
+
*/
|
|
14
|
+
export default class ErrorBoundary extends Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
|
|
15
|
+
constructor(props: PropsWithChildren<ErrorBoundaryProps>);
|
|
16
|
+
static getDerivedStateFromError(error: unknown): ErrorBoundaryState;
|
|
17
|
+
componentDidCatch(error: Error): void;
|
|
18
|
+
render(): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { ErrorBox } from "./ErrorBox.js";
|
|
4
|
+
/**
|
|
5
|
+
* ErrorBoundary is a component that catches rendering errors in its children
|
|
6
|
+
* and displays an appropriately-styled error message.
|
|
7
|
+
*
|
|
8
|
+
* @see https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
|
|
9
|
+
*/
|
|
10
|
+
export default class ErrorBoundary extends Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.state = {};
|
|
14
|
+
}
|
|
15
|
+
static getDerivedStateFromError(error) {
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
return { error };
|
|
18
|
+
}
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
componentDidCatch(error) {
|
|
22
|
+
if (this.props.onError) {
|
|
23
|
+
this.props.onError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
if (this.state.error) {
|
|
28
|
+
return _jsx(ErrorBox, { err: this.state.error });
|
|
29
|
+
}
|
|
30
|
+
return this.props.children;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,55 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { Box, Text } from "ink";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { FailedFlagValidationError, RequiredArgsError, } from "@oclif/core/lib/parser/errors.js";
|
|
4
|
-
import { ApiClientError
|
|
3
|
+
import { ApiClientError } from "@mittwald/api-client-commons";
|
|
5
4
|
import InteractiveInputRequiredError from "../../../lib/error/InteractiveInputRequiredError.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
borderStyle: "round",
|
|
13
|
-
paddingX: 1,
|
|
14
|
-
rowGap: 1,
|
|
15
|
-
};
|
|
16
|
-
const ErrorStack = ({ err }) => {
|
|
17
|
-
return (_jsxs(Box, { marginX: 2, marginY: 1, flexDirection: "column", rowGap: 1, children: [_jsx(Text, { color: color, dimColor: true, bold: true, children: "ERROR STACK TRACE" }), _jsx(Text, { color: color, dimColor: true, children: "Please provide this when opening a bug report." }), _jsx(Text, { color: color, dimColor: true, children: err.stack })] }));
|
|
18
|
-
};
|
|
19
|
-
const GenericError = ({ err, withStack, withIssue = true, title = "Error" }) => {
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { ...boxProps, borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: title.toUpperCase() }), _jsx(Text, { color: color, children: "An error occurred while executing this command:" }), _jsx(Box, { marginX: 2, children: _jsx(Text, { color: color, children: err.toString() }) }), withIssue ? (_jsxs(Text, { color: color, children: ["If you believe this to be a bug, please open an issue at ", issueURL, "."] })) : undefined] }), withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
|
|
21
|
-
};
|
|
22
|
-
const InvalidFlagsError = ({ err }) => {
|
|
23
|
-
const color = "yellow";
|
|
24
|
-
return (_jsxs(Box, { ...boxProps, borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "INVALID COMMAND FLAGS" }), _jsxs(Text, { color: color, children: ["The flags that you provided for this command were invalid. ", err.message] })] }));
|
|
25
|
-
};
|
|
26
|
-
const InvalidArgsError = ({ err }) => {
|
|
27
|
-
const color = "yellow";
|
|
28
|
-
return (_jsxs(Box, { ...boxProps, borderColor: color, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "INVALID COMMAND ARGUMENTS" }), _jsxs(Text, { color: color, children: ["The arguments that you provided for this command were invalid.", " ", err.message] })] }));
|
|
29
|
-
};
|
|
30
|
-
const RequestHeaders = ({ headers }) => {
|
|
31
|
-
const lines = headers.trim().split("\r\n");
|
|
32
|
-
const requestLine = lines.shift();
|
|
33
|
-
const values = lines.map((line) => line.split(": ", 2));
|
|
34
|
-
const maxKeyLength = Math.max(...values.map(([key]) => key.length));
|
|
35
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, underline: true, children: requestLine }), values.map(([key, value]) => (_jsxs(Box, { flexDirection: "row", children: [_jsxs(Text, { dimColor: true, children: [key.toLowerCase().padEnd(maxKeyLength, " "), " "] }), _jsx(Text, { bold: true, children: key === "x-access-token" ? "[redacted]" : value })] }, key)))] }));
|
|
36
|
-
};
|
|
37
|
-
const Response = ({ status, statusText, body, headers }) => {
|
|
38
|
-
const keys = Object.keys(headers);
|
|
39
|
-
const maxKeyLength = Math.max(...keys.map((key) => key.length));
|
|
40
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { bold: true, underline: true, children: [status, " ", statusText] }, "status"), keys.map((key) => (_jsxs(Box, { flexDirection: "row", children: [_jsxs(Text, { dimColor: true, children: [key.toLowerCase().padEnd(maxKeyLength, " "), " "] }), _jsx(Text, { bold: true, children: key === "x-access-token" ? "[redacted]" : headers[key] })] }, key))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { children: JSON.stringify(body, undefined, 2) }) }, "body")] }));
|
|
41
|
-
};
|
|
42
|
-
const HttpMessages = ({ err }) => {
|
|
43
|
-
const response = err.response ? (_jsx(Response, { status: err.response.status, statusText: err.response.statusText, body: err.response.data, headers: err.response.headers })) : (_jsx(Text, { children: "no response received" }));
|
|
44
|
-
return (_jsxs(Box, { marginX: 2, marginY: 1, flexDirection: "column", rowGap: 1, children: [_jsx(RequestHeaders, { headers: err.request._header }), response] }));
|
|
45
|
-
};
|
|
46
|
-
const ApiError = ({ err, withStack, withHTTPMessages }) => {
|
|
47
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { ...boxProps, children: [_jsx(Text, { color: color, bold: true, underline: true, children: "API CLIENT ERROR" }), _jsxs(Text, { color: color, children: ["An error occurred while communicating with the API: ", err.message] }), _jsx(Text, { children: JSON.stringify(err.response?.data, undefined, 2) })] }), withHTTPMessages === "full" ? _jsx(HttpMessages, { err: err }) : undefined, withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
|
|
48
|
-
};
|
|
5
|
+
import UnexpectedShortIDPassedError from "../../../lib/error/UnexpectedShortIDPassedError.js";
|
|
6
|
+
import GenericError from "./Error/GenericError.js";
|
|
7
|
+
import InvalidFlagsError from "./Error/InvalidFlagsError.js";
|
|
8
|
+
import InvalidArgsError from "./Error/InvalidArgsError.js";
|
|
9
|
+
import APIError from "./Error/APIError.js";
|
|
10
|
+
import UnexpectedShortIDPassedErrorBox from "./Error/UnexpectedShortIDPassedErrorBox.js";
|
|
49
11
|
/**
|
|
50
12
|
* Render an error to the terminal.
|
|
51
13
|
*
|
|
52
|
-
* @class
|
|
53
14
|
* @param err The error to render. May be anything, although different errors
|
|
54
15
|
* will be rendered differently.
|
|
55
16
|
*/
|
|
@@ -61,11 +22,14 @@ export const ErrorBox = ({ err }) => {
|
|
|
61
22
|
return _jsx(InvalidArgsError, { err: err });
|
|
62
23
|
}
|
|
63
24
|
else if (err instanceof ApiClientError) {
|
|
64
|
-
return _jsx(
|
|
25
|
+
return _jsx(APIError, { err: err, withStack: true, withHTTPMessages: "body" });
|
|
65
26
|
}
|
|
66
27
|
else if (err instanceof InteractiveInputRequiredError) {
|
|
67
28
|
return (_jsx(GenericError, { err: err, withStack: false, withIssue: false, title: "Input required" }));
|
|
68
29
|
}
|
|
30
|
+
else if (err instanceof UnexpectedShortIDPassedError) {
|
|
31
|
+
return _jsx(UnexpectedShortIDPassedErrorBox, { err: err });
|
|
32
|
+
}
|
|
69
33
|
else if (err instanceof Error) {
|
|
70
34
|
return _jsx(GenericError, { err: err, withStack: true });
|
|
71
35
|
}
|