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