UNPKG

@elgato/cli

Version:

Stream Deck CLI tool for building with Stream Deck.

335 lines (327 loc) 10.3 kB
/** * An object that references a location. */ type LocationRef<T extends JsonLocation | Location = Location> = { /** * The location this instance references. */ location?: T; }; /** * Location of an item within a file. */ type Location = { /** * Column number. */ column?: number; /** * Identifies the location within the file, for example the property reference for a JSON error. */ key: string | undefined; /** * Line number. */ line?: number; }; /** * Location of a JSON value within a file. */ type JsonLocation = Location & { /** * JSON pointer to the value. */ instancePath: string; }; /** * Provides information about a validation entry. */ declare class ValidationEntry { readonly level: ValidationLevel; readonly message: string; readonly details?: ValidationEntryDetails | undefined; /** * Location of the validation entry, represented as a string in the format {line}:{column}. */ readonly location: string; /** * Initializes a new instance of the {@link ValidationEntry} class. * @param level Severity level of the entry. * @param message Validation message. * @param details Supporting optional details. */ constructor(level: ValidationLevel, message: string, details?: ValidationEntryDetails | undefined); /** * Converts the entry to a summary string. * @param padding Optional padding required to align the position of each entry. * @returns String that represents the entry. */ toSummary(padding?: number): string; } /** * Levels of validation. */ declare enum ValidationLevel { /** * Error. */ error = 0, /** * Warning. */ warning = 1 } /** * Optional details associated with the validation entry. */ type ValidationEntryDetails = LocationRef & { /** * Optional suggestion to fix the validation entry. */ suggestion?: string; }; /** * An ordered array; items pushed onto the array are inserted in the sort ordered as defined by the `compareOn` delegates provided in the constructor. */ declare class OrderedArray<T> extends Array<T> { #private; /** * Initializes a new instance of the {@link OrderedArray} class. * @param compareOn Delegates responsible for determining the sort order. */ constructor(...compareOn: ((value: T) => number | string)[]); /** * "Pushes" the specified {@link value} in a sorted order. * @param value Value to push. * @returns New length of the array. */ push(value: T): number; } /** * Options associated with a {@link ConsoleStdOut}. */ type ConsoleStdOutOptions = { /** * Determines whether the standard output stream is interactive. */ interactive: boolean; /** * The minimum {@link MessageLevel} to write. */ level: MessageLevel; /** * Determines whether the standard output stream should display non-essential motion, e.g. spinning bars. */ reduceMotion: boolean; }; /** * Provides interactive console writer that writes to the stdout, including a spinner and status results. */ type StdOut = ConsoleStdOut; /** * Provides interactive console writer that writes to the stdout, including a spinner and status results. */ declare class ConsoleStdOut { private readonly options; /** * Private backing field for {@link ConsoleStdOut.isLoading}. */ private _isLoading; /** * Current symbol index. */ private index; /** * The active message associated with the task denoted by the spinner. */ private message; /** * Identifies the timer responsible for displaying the spinning symbol. */ private timerId?; /** * Initializes a new instance of the {@link ConsoleStdOut} class. * @param options Options associated with this instance. */ constructor(options: ConsoleStdOutOptions); /** * Gets a value that determines whether there is active loading-feedback, e.g. spinning ({@link ConsoleStdOut.spin}) due to a task running. * @returns `true` when the feedback is spinning; otherwise `false`. */ get isLoading(): boolean; /** * Display the {@link message} as an error message, and stops any current interactive feedback (spinners). * @param message Optional text to display. * @returns An error reporter capable of outputting more detailed information. */ error(message?: string): ErrorReporter; /** * Exits the process. * @param code Optional exit code. */ exit(code?: number): never; /** * Display the {@link message} as an informational message, and stops any current interactive feedback (spinners). * @param message Optional text to display. * @returns This instance for chaining. */ info(message?: string): this; /** * Logs the specified {@link message} to the console. * @param message Message to write. * @returns This instance for chaining. */ log(message?: unknown): this; /** * Displays an interactive spinner and the {@link message}. * @param message Text to show next to the spinner. * @param task Task that the spinner represents. * @returns A promise fulfilled when the {@link task} completes. */ spin(message: string, task?: (writer: ConsoleStdOut, spin: Spinner) => Promise<number | void> | void): Promise<void>; /** * Display the {@link message} as a success message, and stops any current interactive feedback (spinners). * @param message Optional text to display. * @returns This instance for chaining. */ success(message?: string): this; /** * Display the {@link message} as a warning message, and stops any current interactive feedback (spinners). * @param message Optional text to display. * @returns This instance for chaining. */ warn(message?: string): this; /** * Gets the symbol associated with the {@link level}. * @param level Message level. * @returns Associated symbol that denotes the {@link level} as an icon. */ private getSymbol; /** * Starts the spinner. */ private startSpinner; /** * Writes the message; when there is an active spinner, it is stopped and the message is associated with the task that was running. * @param param0 Message to display. * @param param0.level The {@link MessageLevel} associated with the message. * @param param0.text Text to write. * @returns This instance for chaining. */ private stopAndWrite; } /** * Spinner that indicates a busy status. */ type Spinner = { setText(message: string): void; }; /** * Provides logging and exiting facilities as part of reporting an error. */ declare class ErrorReporter { /** * Determines whether a message has been logged; the first log is yellow. */ private hasMessageBeenLogged; /** * Exits the process. * @param code Optional exit code. */ exit(code?: number): never; /** * Logs a message to the console; if this is the first message as part of the reporter, the message will be highlighted in yellow. * @param message Message to log. * @returns This instance for chaining. */ log(message: unknown): this; } /** * Levels of logging used by {@link ConsoleStdOut}. */ declare enum MessageLevel { /** * Error message used to indicate an error was thrown, or something critically went wrong. */ ERROR = 0, /** * Warning message used to indicate something went wrong, but the application is able to recover. */ WARN = 1, /** * Success message that indicates the completion of a task or operation */ SUCCESS = 2, /** * Information message for general usage. */ INFO = 3, /** * Miscellaneous information that is not represented by a symbol. */ LOG = 4 } /** * Provides validation results for a specific file path. */ declare class FileValidationResult extends OrderedArray<ValidationEntry> { #private; readonly path: string; /** * Initializes a new instance of the {@link FileValidationResult} class. * @param path Path that groups the entries together. */ constructor(path: string); /** * Adds the specified {@link entry} to the collection. * @param entry Entry to add. * @returns New length of the validation results. */ push(entry: ValidationEntry): number; /** * Writes the entry collection to the {@link output}. * @param output Output to write to. */ writeTo(output: StdOut): void; } /** * Validation result containing a collection of {@link FileValidationResult} grouped by the directory or file path they're associated with. */ declare class ValidationResult extends Array<FileValidationResult> implements ReadonlyArray<FileValidationResult> { /** * Private backing field for {@link ValidationResult.errorCount}. */ private errorCount; /** * Private backing field for {@link ValidationResult.warningCount}. */ private warningCount; /** * Adds a new validation entry to the result. * @param path Directory or file path the entry is associated with. * @param entry Validation entry. */ add(path: string, entry: ValidationEntry): void; /** * Determines whether the result contains errors. * @returns `true` when the result has errors. */ hasErrors(): boolean; /** * Determines whether the result contains warnings. * @returns `true` when the result has warnings. */ hasWarnings(): boolean; /** * Writes the results to the specified {@link output}. * @param output Output to write to. */ writeTo(output: StdOut): void; } /** * Validates the Stream Deck plugin as the specified {@link path}. * @param path Path to the plugin. * @returns The validation result. */ declare function validatePlugin(path: string): Promise<ValidationResult>; export { FileValidationResult, ValidationEntry, type ValidationEntryDetails, ValidationLevel, ValidationResult, validatePlugin as validateStreamDeckPlugin };