Skip to content

Commit

Permalink
chore: apply automated updates
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jun 8, 2024
1 parent e638643 commit df0e555
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createConsola(
/**
* Creates and exports a standard instance of Consola with the default configuration.
* This instance can be used directly for logging throughout the application.
*
*
* @type {ConsolaInstance} consola - The default instance of Consola.
*/
export const consola = createConsola();
Expand Down
2 changes: 1 addition & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createConsola(options: Partial<ConsolaOptions> = {}) {
/**
* A standard Consola instance created with browser-specific configurations.
* This instance can be used throughout a browser-based project.
*
*
* @type {ConsolaInstance} consola - The default browser-configured Consola instance.
*/
export const consola = createConsola();
Expand Down
24 changes: 12 additions & 12 deletions src/consola.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Consola {

/**
* Creates an instance of Consola with specified options or defaults.
*
*
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
*/
constructor(options: Partial<ConsolaOptions> = {}) {
Expand Down Expand Up @@ -86,7 +86,7 @@ export class Consola {

/**
* Gets the current log level of the Consola instance.
*
*
* @returns {number} The current log level.
*/
get level() {
Expand All @@ -95,7 +95,7 @@ export class Consola {

/**
* Sets the minimum log level that will be output by the instance.
*
*
* @param {number} level - The new log level to set.
*/
set level(level) {
Expand All @@ -109,7 +109,7 @@ export class Consola {
/**
* Displays a prompt to the user and returns the response.
* Throw an error if `prompt` is not supported by the current configuration.
*
*
* @template T
* @param {string} message - The message to display in the prompt.
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
Expand All @@ -124,7 +124,7 @@ export class Consola {

/**
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
*
*
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
*/
Expand All @@ -143,7 +143,7 @@ export class Consola {

/**
* Creates a new Consola instance with the specified default log object properties.
*
*
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
*/
Expand All @@ -159,7 +159,7 @@ export class Consola {

/**
* Creates a new Consola instance with a specified tag, which will be included in every log.
*
*
* @param {string} tag - The tag to include in each log of the new instance.
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
*/
Expand All @@ -174,7 +174,7 @@ export class Consola {
/**
* Adds a custom reporter to the Consola instance.
* Reporters will be called for each log message, depending on their implementation and log level.
*
*
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
* @returns {Consola} The current Consola instance.
*/
Expand All @@ -186,7 +186,7 @@ export class Consola {
/**
* Removes a custom reporter from the Consola instance.
* If no reporter is specified, all reporters will be removed.
*
*
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
* @returns {Consola} The current Consola instance.
*/
Expand All @@ -204,7 +204,7 @@ export class Consola {

/**
* Replaces all reporters of the Consola instance with the specified array of reporters.
*
*
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
* @returns {Consola} The current Consola instance.
*/
Expand Down Expand Up @@ -317,7 +317,7 @@ export class Consola {

/**
* Replaces logging methods with mocks if a mock function is provided.
*
*
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
*/
mockTypes(mockFn?: ConsolaOptions["mockFn"]) {
Expand Down Expand Up @@ -498,7 +498,7 @@ Consola.prototype.resume = Consola.prototype.resumeLogs;

/**
* Utility for creating a new Consola instance with optional configuration.
*
*
* @param {Partial<ConsolaOptions>} [options={}] - Optional configuration options for the new Consola instance. See {@link ConsolaOptions}.
* @returns {ConsolaInstance} A new instance of Consola. See {@link ConsolaInstance}.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LogObject } from "./types";

/**
* Defines the level of logs as specific numbers or special number types.
*
*
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevel - Represents the log level.
* @default 0 - Represents the default log level.
*/
Expand All @@ -11,7 +11,7 @@ export type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});

/**
* A mapping of `LogType` to its corresponding numeric log level.
*
*
* @type {Record<LogType, number>} LogLevels - key-value pairs of log types to their numeric levels. See {@link LogType}.
*/
export const LogLevels: Record<LogType, number> = {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const LogLevels: Record<LogType, number> = {

/**
* Lists the types of log messages supported by the system.
*
*
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogType - Represents the specific type of log message.
*/
export type LogType =
Expand All @@ -66,7 +66,7 @@ export type LogType =

/**
* Maps `LogType` to a `Partial<LogObject>`, primarily defining the log level.
*
*
* @type {Record<LogType, Partial<LogObject>>} LogTypes - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogType} and {@link LogObject}.
*/
export const LogTypes: Record<LogType, Partial<LogObject>> = {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function _getDefaultLogLevel() {
/**
* A default instance of Consola, created and configured for immediate use.
* This instance is configured based on the execution environment and the options provided.
*
*
* @type {ConsolaInstance} consola - The default Consola instance, ready to use.
*/
export const consola = createConsola();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export type ColorName = keyof typeof colorDefs;
export type ColorFunction = (text: string | number) => string;

/**
* Creates an object that maps colour names to their respective colour functions,
* Creates an object that maps colour names to their respective colour functions,
* based on whether or not colour support is enabled.
* @param {boolean} [useColor=isColorSupported] - Specifies whether to use colour functions or fallback to plain strings.
* @returns {Record<ColorName, ColorFunction>} An object where keys are colour names and values are functions to apply those colours. See {@link ColorFunction}.
Expand Down
30 changes: 16 additions & 14 deletions src/utils/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ export interface PasswordOptions {
mask?: string;

/**
* A function to validate the input. Returns an error message if the input fails validation.
* @param {string} value - The current value of the input field.
* @returns {string | void} An error message if the input fails validation, or `void` if the input is valid.
* @optional
*/
* A function to validate the input. Returns an error message if the input fails validation.
* @param {string} value - The current value of the input field.
* @returns {string | void} An error message if the input fails validation, or `void` if the input is valid.
* @optional
*/
validate?: (value: string) => string | void;
}
/**
Expand Down Expand Up @@ -278,7 +278,8 @@ export const confirm = (opts: ConfirmOptions) => {
this.value
? `${color.green(S_RADIO_ACTIVE)} ${active}`
: `${color.dim(S_RADIO_INACTIVE)} ${color.dim(active)}`
} ${color.dim("/")} ${this.value
} ${color.dim("/")} ${
this.value
? `${color.dim(S_RADIO_INACTIVE)} ${color.dim(inactive)}`
: `${color.green(S_RADIO_ACTIVE)} ${inactive}`
}\n${color.cyan(S_BAR_END)}\n`;
Expand Down Expand Up @@ -386,7 +387,7 @@ export const select = <Options extends Option<Value>[], Value>(
};

/**
* Provides a prompt that allows the user to select an option by pressing a key.
* Provides a prompt that allows the user to select an option by pressing a key.
* This is useful for scenarios where each option is associated with a specific key.
* @param {SelectOptions<Options, Value>} opts - Configuration options for the select key prompt. See {@link SelectOptions}.
* @returns {Promise<Value | Symbol>} A promise that resolves to the value of the selected option, or a symbol for special cases such as abort. See {@link Value}.
Expand Down Expand Up @@ -425,8 +426,9 @@ export const selectKey = <
options: opts.options,
initialValue: opts.initialValue,
render() {
const title = `${color.gray(S_BAR)}\n${symbol(this.state)} ${opts.message
}\n`;
const title = `${color.gray(S_BAR)}\n${symbol(this.state)} ${
opts.message
}\n`;

switch (this.state) {
case "submit": {
Expand Down Expand Up @@ -455,8 +457,8 @@ export const selectKey = <

export interface MultiSelectOptions<Options extends Option<Value>[], Value> {
/**
* The primary message to be displayed above the multi-select list.
*/
* The primary message to be displayed above the multi-select list.
*/
message: string;

/**
Expand Down Expand Up @@ -865,7 +867,7 @@ export const note = (message = "", title = "") => {
* Prints an abort message to the console. This is typically used to indicate
* that a process or operation has been cancelled. The message is coloured for
* for emphasis and visual differentiation.
*
*
* @param {string} [message=""] - The cancellation message to display. This parameter
* is optional; if omitted, the default styling will be used without a specific message.
*/
Expand All @@ -877,7 +879,7 @@ export const cancel = (message = "") => {
* Prints an introductory message to the console. This function is used to
* Display a title or short message at the beginning of a script or application.
* framed by a specified bar character for visual distinction.
*
*
* @param {string} [title=""] - The title or message to display. This parameter is optional; if omitted, only the framing bar will be printed.
*/
export const intro = (title = "") => {
Expand All @@ -888,7 +890,7 @@ export const intro = (title = "") => {
* Prints a closing message to the console. Similar to the `intro` function,
* `outro' is designed to indicate the end of a script or application execution
* with a framed message for clear visual separation from the rest of the console output.
*
*
* @param {string} [message=""] - The final message to display. This parameter is optional; if omitted, only the border will be printed.
*/
export const outro = (message = "") => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/stream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Writes data to a specified NodeJS writable stream. This function supports streams that have a custom
* `__write' method, and will fall back to the default `write' method if `__write' is not present.
*
*
* @param {any} data - The data to write to the stream. This can be a string, a buffer, or any data type
* supported by the stream's `write' or `__write' method.
* @param {NodeJS.WriteStream} stream - The writable stream to write the data to. This stream
Expand Down
10 changes: 5 additions & 5 deletions src/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ansiRegex = [
* Removes ANSI escape codes from a given string. This is particularly useful for
* processing text that contains formatting codes, such as colours or styles, so that the
* the raw text without any visual formatting.
*
*
* @param {string} text - The text string from which to strip the ANSI escape codes.
* @returns {string} The text without ANSI escape codes.
*/
Expand All @@ -18,7 +18,7 @@ export function stripAnsi(text: string) {
/**
* Centers a string within a specified total width, padding it with spaces or another specified character.
* If the string is longer than the total width, it is returned as is.
*
*
* @param {string} str - The string to centre.
* @param {number} len - The total width in which to centre the string.
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
Expand All @@ -41,7 +41,7 @@ export function centerAlign(str: string, len: number, space = " ") {
/**
* Right-justifies a string within a given total width, padding it with whitespace or another specified character.
* If the string is longer than the total width, it is returned as is.
*
*
* @param {string} str - The string to right-justify.
* @param {number} len - The total width to align the string.
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
Expand All @@ -62,7 +62,7 @@ export function rightAlign(str: string, len: number, space = " ") {
/**
* Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
* If the string is longer than the total width, it is returned as is.
*
*
* @param {string} str - The string to align left.
* @param {number} len - The total width to align the string.
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
Expand All @@ -79,7 +79,7 @@ export function leftAlign(str: string, len: number, space = " ") {
/**
* Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
* If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
*
*
* @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
* @param {string} str - The string to align.
* @param {number} len - The total width in which to align the string.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type TreeOptions = {
* Each item in the tree can be a simple string or an object defining the text of the item,
* optional children, and colour. The tree structure can be customised with options
* Specify the overall colour and the prefix used for indentation and tree lines.
*
*
* @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
* either a string or an object with `text', `children' and `colour' properties.
* @param {TreeOptions} [options] - Optional settings to customise the appearance of the tree, including
Expand Down

0 comments on commit df0e555

Please sign in to comment.