UNPKG

@appium/support

Version:

Support libs used across Appium packages

63 lines 2.49 kB
import type { Color } from '@colors/colors'; import '@colors/colors'; import symbols from 'log-symbols'; import type { InspectOptions } from 'node:util'; import type { JsonValue } from 'type-fest'; /** Symbol keys from log-symbols used for decoration */ type SymbolKey = keyof typeof symbols; /** * Options for {@linkcode CliConsole}. * * @see https://npm.im/supports-color */ export interface ConsoleOpts { /** If _truthy_, suppress all output except JSON (use {@linkcode CliConsole#json}), which writes to `STDOUT`. */ jsonMode?: boolean; /** If _falsy_, do not use fancy symbols. */ useSymbols?: boolean; /** If _falsy_, do not use color output. If _truthy_, forces color output. By default, checks terminal/TTY for support via pkg `supports-color`. Ignored if `useSymbols` is `false`. */ useColor?: boolean; } /** * A particular console/logging class for Appium's CLI. * * - By default, uses some fancy symbols * - Writes to `STDERR`, generally. * - In "JSON mode", `STDERR` is squelched. Use {@linkcode CliConsole.json} to write the JSON. * * DO NOT extend this to do anything other than what it already does. Download a library or something. */ export declare class CliConsole { #private; static readonly symbolToColor: Record<SymbolKey, keyof Color>; constructor(opts?: ConsoleOpts); /** * Wraps a message string in breathtaking fanciness * * Returns `undefined` if `msg` is `undefined`. */ decorate(msg: string | undefined, symbol?: SymbolKey): string | undefined; /** * Writes to `STDOUT`. Must be stringifyable. * * You probably don't want to call this more than once before exiting (since that will output invalid JSON). */ json(value: JsonValue): void; /** General logging function. */ log(message?: string, ...args: unknown[]): void; /** A "success" message */ ok(message?: string, ...args: unknown[]): void; /** Alias for {@linkcode CliConsole.log} */ debug(message?: string, ...args: unknown[]): void; /** Wraps {@link console.dir} */ dump(item: unknown, opts?: InspectOptions): void; /** An "info" message */ info(message?: string, ...args: unknown[]): void; /** A "warning" message */ warn(message?: string, ...args: unknown[]): void; /** An "error" message */ error(message?: string, ...args: unknown[]): void; } export declare const console: CliConsole; export { symbols }; //# sourceMappingURL=console.d.ts.map