1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import { Logger } from '@salesforce/core';
|
16 | import { Optional } from '@salesforce/ts-types';
|
17 | import { cli, IPromptOptions } from 'cli-ux';
|
18 | import { TableOptions as OclifTableOptions } from 'cli-ux/lib/styled/table';
|
19 |
|
20 |
|
21 |
|
22 | export declare class UX {
|
23 | private logger;
|
24 | |
25 |
|
26 |
|
27 |
|
28 | static warnings: Set<string>;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | static formatDeprecationWarning(def: DeprecationDefinition): string;
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | static create(): Promise<UX>;
|
42 | cli: typeof cli;
|
43 | private isOutputEnabled;
|
44 | |
45 |
|
46 |
|
47 | constructor(logger: Logger, isOutputEnabled?: boolean, ux?: typeof cli);
|
48 | /**
|
49 | * Logs at `INFO` level and conditionally writes to `stdout` if stream output is enabled.
|
50 | *
|
51 | * @param {...any[]} args The messages or objects to log.
|
52 | * @returns {UX}
|
53 | */
|
54 | log(...args: string[]): UX;
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | logJson(obj: object): UX;
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | prompt(name: string, options?: IPromptOptions): Promise<string>;
|
70 | |
71 |
|
72 |
|
73 |
|
74 |
|
75 | confirm(message: string): Promise<boolean>;
|
76 | |
77 |
|
78 |
|
79 |
|
80 | startSpinner(message: string): void;
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | pauseSpinner<T>(fn: () => T, icon?: string): Optional<T>;
|
88 | /**
|
89 | * Update the spinner status.
|
90 | * @param {string} status The message displayed to the user.
|
91 | */
|
92 | setSpinnerStatus(status?: string): void;
|
93 | /**
|
94 | * Get the spinner status.
|
95 | * @returns {Optional<string>}
|
96 | */
|
97 | getSpinnerStatus(): Optional<string>;
|
98 | /**
|
99 | * Stop the spinner action.
|
100 | * @param {string} message The message displayed to the user.
|
101 | */
|
102 | stopSpinner(message?: string): void;
|
103 | /**
|
104 | * Logs a warning as `WARN` level and conditionally writes to `stderr` if the log
|
105 | * level is `WARN` or above and stream output is enabled. The message is added
|
106 | * to the static {@link UX.warnings} set if stream output is _not_ enabled, for later
|
107 | * consumption and manipulation.
|
108 | *
|
109 | * @param {string} message The warning message to output.
|
110 | * @returns {UX}
|
111 | * @see UX.warnings
|
112 | */
|
113 | warn(message: string): UX;
|
114 | /**
|
115 | * Logs an error at `ERROR` level and conditionally writes to `stderr` if stream
|
116 | * output is enabled.
|
117 | *
|
118 | * @param {...any[]} args The errors to log.
|
119 | * @returns {UX}
|
120 | */
|
121 | error(...args: unknown[]): UX;
|
122 | /**
|
123 | * Logs an object as JSON at `ERROR` level and to `stderr`.
|
124 | *
|
125 | * @param {object} obj The error object to log -- must be serializable as JSON.
|
126 | * @returns {UX}
|
127 | * @throws {TypeError} If the object is not JSON-serializable.
|
128 | */
|
129 | errorJson(obj: object): UX;
|
130 | /**
|
131 | * Logs at `INFO` level and conditionally writes to `stdout` in a table format if
|
132 | * stream output is enabled.
|
133 | *
|
134 | * @param {object[]} rows The rows of data to be output in table format.
|
135 | * @param {SfdxTableOptions} options The {@link SfdxTableOptions} to use for formatting.
|
136 | * @returns {UX}
|
137 | */
|
138 | table(rows: any[], options?: TableOptions): UX;
|
139 | /**
|
140 | * Logs at `INFO` level and conditionally writes to `stdout` in a styled object format if
|
141 | * stream output is enabled.
|
142 | *
|
143 | * @param {object} obj The object to be styled for stdout.
|
144 | * @param {string[]} [keys] The object keys to be written to stdout.
|
145 | * @returns {UX}
|
146 | */
|
147 | styledObject(obj: object, keys?: string[]): UX;
|
148 | /**
|
149 | * Log at `INFO` level and conditionally write to `stdout` in styled JSON format if
|
150 | * stream output is enabled.
|
151 | *
|
152 | * @param {object} obj The object to be styled for stdout.
|
153 | * @returns {UX}
|
154 | */
|
155 | styledJSON(obj: object): UX;
|
156 | /**
|
157 | * Logs at `INFO` level and conditionally writes to `stdout` in a styled header format if
|
158 | * stream output is enabled.
|
159 | *
|
160 | * @param {string} header The header to be styled.
|
161 | * @returns {UX}
|
162 | */
|
163 | styledHeader(header: string): UX;
|
164 | }
|
165 | /**
|
166 | * A table option configuration type. May be a detailed configuration, or
|
167 | * more simply just a string array in the simple cases where table header values
|
168 | * are the only desired config option.
|
169 | */
|
170 | export declare type TableOptions = Partial<OclifTableOptions> | string[];
|
171 | /**
|
172 | * A deprecation configuration type. A typical instance can pass `name`,
|
173 | * `type`, and `version` for a standard message. Alternatively, the `messageOverride` can
|
174 | * be used as a special case deprecated message. Used when defining a deprecation on a
|
175 | * command or flag.
|
176 | */
|
177 | export declare type Deprecation = {
|
178 | to?: string;
|
179 | message?: string;
|
180 | } & ({
|
181 | version: number | string;
|
182 | } | {
|
183 | messageOverride: string;
|
184 | });
|
185 | /**
|
186 | * A deprecation warning message configuration type. A typical instance can pass `name`,
|
187 | * `type`, and `version` for a standard message. Alternatively, the `messageOverride` can
|
188 | * be used as a special case deprecated message. Used when formating a deprecation message.
|
189 | */
|
190 | export declare type DeprecationDefinition = {
|
191 | to?: string;
|
192 | message?: string;
|
193 | } & ({
|
194 | version: number | string;
|
195 | name: string;
|
196 | type: string;
|
197 | } | {
|
198 | messageOverride: string;
|
199 | });
|
200 |
|
\ | No newline at end of file |