@reliverse/relinka 1.3.7 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -70
- package/bin/{relinka-impl/deprecated → deprecated}/components/levels/levels.d.ts +13 -13
- package/bin/{relinka-impl/deprecated → deprecated}/components/modes/basic.d.ts +19 -19
- package/bin/{relinka-impl/deprecated → deprecated}/components/modes/browser.d.ts +19 -19
- package/bin/deprecated/components/modes/shared.d.ts +2 -0
- package/bin/deprecated/components/modes/shared.js +1 -0
- package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/logger.d.ts +5 -5
- package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/mod.d.ts +20 -20
- package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.d.ts +140 -141
- package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/basic.d.ts +11 -11
- package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/browser.d.ts +10 -10
- package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/fancy.d.ts +10 -10
- package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/fancy.js +1 -3
- package/bin/deprecated/impl-old.js +0 -0
- package/bin/{relinka-types.d.ts → deprecated/types.d.ts} +161 -194
- package/bin/deprecated/types.js +0 -0
- package/bin/{relinka-impl/deprecated → deprecated}/utils/box.d.ts +114 -114
- package/bin/{relinka-impl/deprecated → deprecated}/utils/deprecatedColors.d.ts +69 -69
- package/bin/{relinka-impl/deprecated → deprecated}/utils/error.d.ts +6 -6
- package/bin/{relinka-impl/deprecated → deprecated}/utils/format.d.ts +14 -14
- package/bin/{relinka-impl/deprecated → deprecated}/utils/log.d.ts +13 -13
- package/bin/{relinka-impl/deprecated → deprecated}/utils/stream.d.ts +14 -15
- package/bin/{relinka-impl/deprecated → deprecated}/utils/string.d.ts +50 -50
- package/bin/{relinka-impl/deprecated → deprecated}/utils/tree.d.ts +41 -41
- package/bin/impl.d.ts +149 -0
- package/bin/impl.js +606 -0
- package/bin/main.d.ts +24 -22
- package/bin/main.js +24 -21
- package/bin/types.d.ts +0 -0
- package/bin/types.js +0 -0
- package/package.json +43 -8
- package/bin/relinka-impl/deprecated/components/modes/shared.d.ts +0 -2
- package/bin/relinka-impl/deprecated/components/modes/shared.js +0 -4
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +0 -1
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.js +0 -57
- package/bin/relinka-impl/impl-mod.d.ts +0 -19
- package/bin/relinka-impl/impl-mod.js +0 -317
- /package/bin/{relinka-impl/deprecated → deprecated}/components/levels/levels.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/modes/basic.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/modes/browser.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/logger.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/mod.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/basic.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/browser.js +0 -0
- /package/bin/{relinka-types.js → deprecated/impl-old.d.ts} +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/box.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/deprecatedColors.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/error.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/format.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/log.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/stream.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/string.js +0 -0
- /package/bin/{relinka-impl/deprecated → deprecated}/utils/tree.js +0 -0
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on https://github.com/jorgebucaran/colorette
|
|
3
|
-
* Read LICENSE file for more information
|
|
4
|
-
* https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index.js
|
|
5
|
-
*/
|
|
6
|
-
declare const colorDefs: {
|
|
7
|
-
reset: (string: string) => string;
|
|
8
|
-
bold: (string: string) => string;
|
|
9
|
-
dim: (string: string) => string;
|
|
10
|
-
italic: (string: string) => string;
|
|
11
|
-
underline: (string: string) => string;
|
|
12
|
-
inverse: (string: string) => string;
|
|
13
|
-
hidden: (string: string) => string;
|
|
14
|
-
strikethrough: (string: string) => string;
|
|
15
|
-
black: (string: string) => string;
|
|
16
|
-
red: (string: string) => string;
|
|
17
|
-
green: (string: string) => string;
|
|
18
|
-
yellow: (string: string) => string;
|
|
19
|
-
blue: (string: string) => string;
|
|
20
|
-
magenta: (string: string) => string;
|
|
21
|
-
cyan: (string: string) => string;
|
|
22
|
-
white: (string: string) => string;
|
|
23
|
-
gray: (string: string) => string;
|
|
24
|
-
bgBlack: (string: string) => string;
|
|
25
|
-
bgRed: (string: string) => string;
|
|
26
|
-
bgGreen: (string: string) => string;
|
|
27
|
-
bgYellow: (string: string) => string;
|
|
28
|
-
bgBlue: (string: string) => string;
|
|
29
|
-
bgMagenta: (string: string) => string;
|
|
30
|
-
bgCyan: (string: string) => string;
|
|
31
|
-
bgWhite: (string: string) => string;
|
|
32
|
-
blackBright: (string: string) => string;
|
|
33
|
-
redBright: (string: string) => string;
|
|
34
|
-
greenBright: (string: string) => string;
|
|
35
|
-
yellowBright: (string: string) => string;
|
|
36
|
-
blueBright: (string: string) => string;
|
|
37
|
-
magentaBright: (string: string) => string;
|
|
38
|
-
cyanBright: (string: string) => string;
|
|
39
|
-
whiteBright: (string: string) => string;
|
|
40
|
-
bgBlackBright: (string: string) => string;
|
|
41
|
-
bgRedBright: (string: string) => string;
|
|
42
|
-
bgGreenBright: (string: string) => string;
|
|
43
|
-
bgYellowBright: (string: string) => string;
|
|
44
|
-
bgBlueBright: (string: string) => string;
|
|
45
|
-
bgMagentaBright: (string: string) => string;
|
|
46
|
-
bgCyanBright: (string: string) => string;
|
|
47
|
-
bgWhiteBright: (string: string) => string;
|
|
48
|
-
};
|
|
49
|
-
export type ColorName = keyof typeof colorDefs;
|
|
50
|
-
export type ColorFunction = (text: string | number) => string;
|
|
51
|
-
/**
|
|
52
|
-
* An object containing functions for coloring text. Each function corresponds to a terminal color. See {@link ColorName} for available colors.
|
|
53
|
-
*/
|
|
54
|
-
export declare const colors: Record<
|
|
55
|
-
/**
|
|
56
|
-
* Gets a color function by name, with an option for a fallback color if the requested color is not found.
|
|
57
|
-
* @param {ColorName} color - The name of the color function to get. See {@link ColorName}.
|
|
58
|
-
* @param {ColorName} [fallback="reset"] - The name of the fallback color function if the requested color is not found. See {@link ColorName}.
|
|
59
|
-
* @returns {ColorFunction} The color function that corresponds to the requested color, or the fallback color function. See {@link ColorFunction}.
|
|
60
|
-
*/
|
|
61
|
-
export declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
|
|
62
|
-
/**
|
|
63
|
-
* Applies a specified color to a given text string or number.
|
|
64
|
-
* @param {ColorName} color - The color to apply. See {@link ColorName}.
|
|
65
|
-
* @param {string | number} text - The text to color.
|
|
66
|
-
* @returns {string} The colored text.
|
|
67
|
-
*/
|
|
68
|
-
export declare function colorize(color: ColorName, text: string | number): string;
|
|
69
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Based on https://github.com/jorgebucaran/colorette
|
|
3
|
+
* Read LICENSE file for more information
|
|
4
|
+
* https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index.js
|
|
5
|
+
*/
|
|
6
|
+
declare const colorDefs: {
|
|
7
|
+
reset: (string: string) => string;
|
|
8
|
+
bold: (string: string) => string;
|
|
9
|
+
dim: (string: string) => string;
|
|
10
|
+
italic: (string: string) => string;
|
|
11
|
+
underline: (string: string) => string;
|
|
12
|
+
inverse: (string: string) => string;
|
|
13
|
+
hidden: (string: string) => string;
|
|
14
|
+
strikethrough: (string: string) => string;
|
|
15
|
+
black: (string: string) => string;
|
|
16
|
+
red: (string: string) => string;
|
|
17
|
+
green: (string: string) => string;
|
|
18
|
+
yellow: (string: string) => string;
|
|
19
|
+
blue: (string: string) => string;
|
|
20
|
+
magenta: (string: string) => string;
|
|
21
|
+
cyan: (string: string) => string;
|
|
22
|
+
white: (string: string) => string;
|
|
23
|
+
gray: (string: string) => string;
|
|
24
|
+
bgBlack: (string: string) => string;
|
|
25
|
+
bgRed: (string: string) => string;
|
|
26
|
+
bgGreen: (string: string) => string;
|
|
27
|
+
bgYellow: (string: string) => string;
|
|
28
|
+
bgBlue: (string: string) => string;
|
|
29
|
+
bgMagenta: (string: string) => string;
|
|
30
|
+
bgCyan: (string: string) => string;
|
|
31
|
+
bgWhite: (string: string) => string;
|
|
32
|
+
blackBright: (string: string) => string;
|
|
33
|
+
redBright: (string: string) => string;
|
|
34
|
+
greenBright: (string: string) => string;
|
|
35
|
+
yellowBright: (string: string) => string;
|
|
36
|
+
blueBright: (string: string) => string;
|
|
37
|
+
magentaBright: (string: string) => string;
|
|
38
|
+
cyanBright: (string: string) => string;
|
|
39
|
+
whiteBright: (string: string) => string;
|
|
40
|
+
bgBlackBright: (string: string) => string;
|
|
41
|
+
bgRedBright: (string: string) => string;
|
|
42
|
+
bgGreenBright: (string: string) => string;
|
|
43
|
+
bgYellowBright: (string: string) => string;
|
|
44
|
+
bgBlueBright: (string: string) => string;
|
|
45
|
+
bgMagentaBright: (string: string) => string;
|
|
46
|
+
bgCyanBright: (string: string) => string;
|
|
47
|
+
bgWhiteBright: (string: string) => string;
|
|
48
|
+
};
|
|
49
|
+
export type ColorName = keyof typeof colorDefs;
|
|
50
|
+
export type ColorFunction = (text: string | number) => string;
|
|
51
|
+
/**
|
|
52
|
+
* An object containing functions for coloring text. Each function corresponds to a terminal color. See {@link ColorName} for available colors.
|
|
53
|
+
*/
|
|
54
|
+
export declare const colors: Record<ColorName, ColorFunction>;
|
|
55
|
+
/**
|
|
56
|
+
* Gets a color function by name, with an option for a fallback color if the requested color is not found.
|
|
57
|
+
* @param {ColorName} color - The name of the color function to get. See {@link ColorName}.
|
|
58
|
+
* @param {ColorName} [fallback="reset"] - The name of the fallback color function if the requested color is not found. See {@link ColorName}.
|
|
59
|
+
* @returns {ColorFunction} The color function that corresponds to the requested color, or the fallback color function. See {@link ColorFunction}.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
|
|
62
|
+
/**
|
|
63
|
+
* Applies a specified color to a given text string or number.
|
|
64
|
+
* @param {ColorName} color - The color to apply. See {@link ColorName}.
|
|
65
|
+
* @param {string | number} text - The text to color.
|
|
66
|
+
* @returns {string} The colored text.
|
|
67
|
+
*/
|
|
68
|
+
export declare function colorize(color: ColorName, text: string | number): string;
|
|
69
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a stack trace string and normalizes its paths by removing the current working directory and the "file://" protocol.
|
|
3
|
-
* @param {string} stack - The stack trace string.
|
|
4
|
-
* @returns {string[]} An array of stack trace lines with normalized paths.
|
|
5
|
-
*/
|
|
6
|
-
export declare function parseStack(stack: string): string[];
|
|
1
|
+
/**
|
|
2
|
+
* Parses a stack trace string and normalizes its paths by removing the current working directory and the "file://" protocol.
|
|
3
|
+
* @param {string} stack - The stack trace string.
|
|
4
|
+
* @returns {string[]} An array of stack trace lines with normalized paths.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseStack(stack: string): string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compiles a format string by replacing placeholders with appropriate position indices.
|
|
3
|
-
* Caches compiled formats for efficiency.
|
|
4
|
-
* @param {string} format - The format string containing the placeholders to replace.
|
|
5
|
-
* @returns {string} The compiled format string with placeholders replaced by positional indices.
|
|
6
|
-
*/
|
|
7
|
-
export declare function compileFormat(format: string): any;
|
|
8
|
-
/**
|
|
9
|
-
* Formats a string according to a custom format, using vsprintf for string formatting.
|
|
10
|
-
* @param {string} format - The custom format string.
|
|
11
|
-
* @param {any[]} argv - The arguments to format into the string.
|
|
12
|
-
* @returns {string} The formatted string.
|
|
13
|
-
*/
|
|
14
|
-
export declare function formatString(format: string, argv: any): string;
|
|
1
|
+
/**
|
|
2
|
+
* Compiles a format string by replacing placeholders with appropriate position indices.
|
|
3
|
+
* Caches compiled formats for efficiency.
|
|
4
|
+
* @param {string} format - The format string containing the placeholders to replace.
|
|
5
|
+
* @returns {string} The compiled format string with placeholders replaced by positional indices.
|
|
6
|
+
*/
|
|
7
|
+
export declare function compileFormat(format: string): any;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a string according to a custom format, using vsprintf for string formatting.
|
|
10
|
+
* @param {string} format - The custom format string.
|
|
11
|
+
* @param {any[]} argv - The arguments to format into the string.
|
|
12
|
+
* @returns {string} The formatted string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatString(format: string, argv: any): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the given argument is a simple JavaScript object.
|
|
3
|
-
* @param {any} obj - The object to test.
|
|
4
|
-
* @returns {boolean} `true` if the argument is a plain object, otherwise `false`.
|
|
5
|
-
*/
|
|
6
|
-
export declare function isPlainObject(obj: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Determines whether the given argument is a protocol object. A log object must be a simple object and
|
|
9
|
-
* must contain either a 'message' or 'args' field, but not a 'stack' field.
|
|
10
|
-
* @param {any} arg - The argument to check.
|
|
11
|
-
* @returns {boolean} `true` if the argument is a log object according to the specified criteria, otherwise `false`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function isLogObj(arg: any): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given argument is a simple JavaScript object.
|
|
3
|
+
* @param {any} obj - The object to test.
|
|
4
|
+
* @returns {boolean} `true` if the argument is a plain object, otherwise `false`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPlainObject(obj: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Determines whether the given argument is a protocol object. A log object must be a simple object and
|
|
9
|
+
* must contain either a 'message' or 'args' field, but not a 'stack' field.
|
|
10
|
+
* @param {any} arg - The argument to check.
|
|
11
|
+
* @returns {boolean} `true` if the argument is a log object according to the specified criteria, otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isLogObj(arg: any): boolean;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare function writeStream(data: any, stream: NodeJS.WriteStream): any;
|
|
1
|
+
/**
|
|
2
|
+
* Writes data to a specified NodeJS writable stream. This function supports streams that have a custom
|
|
3
|
+
* `__write' method, and will fall back to the default `write' method if `__write' is not present.
|
|
4
|
+
*
|
|
5
|
+
* @param {any} data - The data to write to the stream. This can be a string, a buffer, or any data type
|
|
6
|
+
* supported by the stream's `write' or `__write' method.
|
|
7
|
+
* @param {NodeJS.WriteStream} stream - The writable stream to write the data to. This stream
|
|
8
|
+
* must implement the `write' method, and can optionally implement a custom `__write' method.
|
|
9
|
+
* @returns {boolean} `true` if the data has been completely processed by the write operation,
|
|
10
|
+
* indicating that further writes can be performed immediately. Returns `false` if the data is
|
|
11
|
+
* buffered by the stream, indicating that the `drain` event should be waited for before writing
|
|
12
|
+
* more data.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeStream(data: any, stream: NodeJS.WriteStream): any;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes ANSI escape codes from a given string. This is particularly useful for
|
|
3
|
-
* processing text that contains formatting codes, such as colors or styles, so that the
|
|
4
|
-
* the raw text without any visual formatting.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} text - The text string from which to strip the ANSI escape codes.
|
|
7
|
-
* @returns {string} The text without ANSI escape codes.
|
|
8
|
-
*/
|
|
9
|
-
export declare function stripAnsi(text: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Centers a string within a specified total width, padding it with spaces or another specified character.
|
|
12
|
-
* If the string is longer than the total width, it is returned as is.
|
|
13
|
-
*
|
|
14
|
-
* @param {string} str - The string to centre.
|
|
15
|
-
* @param {number} len - The total width in which to centre the string.
|
|
16
|
-
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
17
|
-
* @returns {string} The centred string.
|
|
18
|
-
*/
|
|
19
|
-
export declare function centerAlign(str: string, len: number, space?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Right-justifies a string within a given total width, padding it with whitespace or another specified character.
|
|
22
|
-
* If the string is longer than the total width, it is returned as is.
|
|
23
|
-
*
|
|
24
|
-
* @param {string} str - The string to right-justify.
|
|
25
|
-
* @param {number} len - The total width to align the string.
|
|
26
|
-
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
27
|
-
* @returns {string} The right-justified string.
|
|
28
|
-
*/
|
|
29
|
-
export declare function rightAlign(str: string, len: number, space?: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
|
|
32
|
-
* If the string is longer than the total width, it is returned as is.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} str - The string to align left.
|
|
35
|
-
* @param {number} len - The total width to align the string.
|
|
36
|
-
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
37
|
-
* @returns {string} The left-justified string.
|
|
38
|
-
*/
|
|
39
|
-
export declare function leftAlign(str: string, len: number, space?: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
|
|
42
|
-
* If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
|
|
43
|
-
*
|
|
44
|
-
* @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
|
|
45
|
-
* @param {string} str - The string to align.
|
|
46
|
-
* @param {number} len - The total width in which to align the string.
|
|
47
|
-
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
48
|
-
* @returns {string} The aligned string, according to the given alignment.
|
|
49
|
-
*/
|
|
50
|
-
export declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* Removes ANSI escape codes from a given string. This is particularly useful for
|
|
3
|
+
* processing text that contains formatting codes, such as colors or styles, so that the
|
|
4
|
+
* the raw text without any visual formatting.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} text - The text string from which to strip the ANSI escape codes.
|
|
7
|
+
* @returns {string} The text without ANSI escape codes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function stripAnsi(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Centers a string within a specified total width, padding it with spaces or another specified character.
|
|
12
|
+
* If the string is longer than the total width, it is returned as is.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} str - The string to centre.
|
|
15
|
+
* @param {number} len - The total width in which to centre the string.
|
|
16
|
+
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
17
|
+
* @returns {string} The centred string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function centerAlign(str: string, len: number, space?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Right-justifies a string within a given total width, padding it with whitespace or another specified character.
|
|
22
|
+
* If the string is longer than the total width, it is returned as is.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} str - The string to right-justify.
|
|
25
|
+
* @param {number} len - The total width to align the string.
|
|
26
|
+
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
27
|
+
* @returns {string} The right-justified string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rightAlign(str: string, len: number, space?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
|
|
32
|
+
* If the string is longer than the total width, it is returned as is.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} str - The string to align left.
|
|
35
|
+
* @param {number} len - The total width to align the string.
|
|
36
|
+
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
37
|
+
* @returns {string} The left-justified string.
|
|
38
|
+
*/
|
|
39
|
+
export declare function leftAlign(str: string, len: number, space?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
|
|
42
|
+
* If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
|
|
43
|
+
*
|
|
44
|
+
* @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
|
|
45
|
+
* @param {string} str - The string to align.
|
|
46
|
+
* @param {number} len - The total width in which to align the string.
|
|
47
|
+
* @param {string} [space=" "] - The character to use for padding. Defaults to a space.
|
|
48
|
+
* @returns {string} The aligned string, according to the given alignment.
|
|
49
|
+
*/
|
|
50
|
+
export declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { type ColorName } from "./deprecatedColors.js";
|
|
2
|
-
export type TreeItemObject = {
|
|
3
|
-
/**
|
|
4
|
-
* Text of the item
|
|
5
|
-
*/
|
|
6
|
-
text: string;
|
|
7
|
-
/**
|
|
8
|
-
* Children of the item
|
|
9
|
-
*/
|
|
10
|
-
children?: TreeItem[];
|
|
11
|
-
/**
|
|
12
|
-
* Color of the item
|
|
13
|
-
*/
|
|
14
|
-
color?: ColorName;
|
|
15
|
-
};
|
|
16
|
-
export type TreeItem = string | TreeItemObject;
|
|
17
|
-
export type TreeOptions = {
|
|
18
|
-
/**
|
|
19
|
-
* Color of the tree
|
|
20
|
-
*/
|
|
21
|
-
color?: ColorName;
|
|
22
|
-
/**
|
|
23
|
-
* Prefix of the tree
|
|
24
|
-
*
|
|
25
|
-
* @default " "
|
|
26
|
-
*/
|
|
27
|
-
prefix?: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Formats a hierarchical list of items into a string representing a tree structure.
|
|
31
|
-
* Each item in the tree can be a simple string or an object defining the text of the item,
|
|
32
|
-
* optional children, and color. The tree structure can be customized with options
|
|
33
|
-
* Specify the overall color and the prefix used for indentation and tree lines.
|
|
34
|
-
*
|
|
35
|
-
* @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
|
|
36
|
-
* either a string or an object with `text', `children' and `color' properties.
|
|
37
|
-
* @param {TreeOptions} [options] - Optional settings to customize the appearance of the tree, including
|
|
38
|
-
* the color of the tree text and the prefix for branches. See {@link TreeOptions}.
|
|
39
|
-
* @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere.
|
|
40
|
-
*/
|
|
41
|
-
export declare function formatTree(items: TreeItem[], options?: TreeOptions): string;
|
|
1
|
+
import { type ColorName } from "./deprecatedColors.js";
|
|
2
|
+
export type TreeItemObject = {
|
|
3
|
+
/**
|
|
4
|
+
* Text of the item
|
|
5
|
+
*/
|
|
6
|
+
text: string;
|
|
7
|
+
/**
|
|
8
|
+
* Children of the item
|
|
9
|
+
*/
|
|
10
|
+
children?: TreeItem[];
|
|
11
|
+
/**
|
|
12
|
+
* Color of the item
|
|
13
|
+
*/
|
|
14
|
+
color?: ColorName;
|
|
15
|
+
};
|
|
16
|
+
export type TreeItem = string | TreeItemObject;
|
|
17
|
+
export type TreeOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Color of the tree
|
|
20
|
+
*/
|
|
21
|
+
color?: ColorName;
|
|
22
|
+
/**
|
|
23
|
+
* Prefix of the tree
|
|
24
|
+
*
|
|
25
|
+
* @default " "
|
|
26
|
+
*/
|
|
27
|
+
prefix?: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Formats a hierarchical list of items into a string representing a tree structure.
|
|
31
|
+
* Each item in the tree can be a simple string or an object defining the text of the item,
|
|
32
|
+
* optional children, and color. The tree structure can be customized with options
|
|
33
|
+
* Specify the overall color and the prefix used for indentation and tree lines.
|
|
34
|
+
*
|
|
35
|
+
* @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
|
|
36
|
+
* either a string or an object with `text', `children' and `color' properties.
|
|
37
|
+
* @param {TreeOptions} [options] - Optional settings to customize the appearance of the tree, including
|
|
38
|
+
* the color of the tree text and the prefix for branches. See {@link TreeOptions}.
|
|
39
|
+
* @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere.
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatTree(items: TreeItem[], options?: TreeOptions): string;
|
package/bin/impl.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { DefaultColorKeys } from "@reliverse/relico";
|
|
2
|
+
/** Configuration for special directory handling. */
|
|
3
|
+
export type RelinkaSpecialDirsConfig = {
|
|
4
|
+
distDirNames?: string[];
|
|
5
|
+
useParentConfigInDist?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** Configuration for directory-related settings. */
|
|
8
|
+
export type RelinkaDirsConfig = {
|
|
9
|
+
dailyLogs?: boolean;
|
|
10
|
+
logDir?: string;
|
|
11
|
+
maxLogFiles?: number;
|
|
12
|
+
specialDirs?: RelinkaSpecialDirsConfig;
|
|
13
|
+
};
|
|
14
|
+
/** Configuration for a single log level. */
|
|
15
|
+
export type LogLevelConfig = {
|
|
16
|
+
/**
|
|
17
|
+
* Symbol to display for this log level.
|
|
18
|
+
* @see https://symbl.cc
|
|
19
|
+
*/
|
|
20
|
+
symbol: string;
|
|
21
|
+
/**
|
|
22
|
+
* Fallback symbol to use if Unicode is not supported.
|
|
23
|
+
*/
|
|
24
|
+
fallbackSymbol: string;
|
|
25
|
+
/**
|
|
26
|
+
* Color to use for this log level.
|
|
27
|
+
*/
|
|
28
|
+
color: DefaultColorKeys;
|
|
29
|
+
/**
|
|
30
|
+
* Number of spaces after the symbol/fallback
|
|
31
|
+
*/
|
|
32
|
+
spacing?: number;
|
|
33
|
+
};
|
|
34
|
+
/** Configuration for all log levels. */
|
|
35
|
+
export type LogLevelsConfig = Partial<Record<LogLevel, LogLevelConfig>>;
|
|
36
|
+
/** Log level types used by the logger. */
|
|
37
|
+
export type LogLevel = "error" | "fatal" | "info" | "success" | "verbose" | "warn" | "log";
|
|
38
|
+
/**
|
|
39
|
+
* Configuration options for the Relinka logger.
|
|
40
|
+
* All properties are optional to allow for partial configuration.
|
|
41
|
+
* Defaults will be applied during initialization.
|
|
42
|
+
*/
|
|
43
|
+
export type RelinkaConfig = {
|
|
44
|
+
/**
|
|
45
|
+
* Enables verbose (aka debug) mode for detailed logging.
|
|
46
|
+
*
|
|
47
|
+
* `true` here works only for end-users of CLIs/libs when theirs developers
|
|
48
|
+
* has been awaited for user's config via `@reliverse/relinka`'s `await relinkaConfig;`
|
|
49
|
+
*/
|
|
50
|
+
verbose?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for directory-related settings.
|
|
53
|
+
* - `dailyLogs`: If true, logs will be stored in a daily subdirectory.
|
|
54
|
+
* - `logDir`: The base directory for logs.
|
|
55
|
+
* - `maxLogFiles`: The maximum number of log files to keep before cleanup.
|
|
56
|
+
* - `specialDirs`: Configuration for special directory handling.
|
|
57
|
+
* - `distDirNames`: An array of directory names to check for special handling.
|
|
58
|
+
* - `useParentConfigInDist`: If true, use the parent config in dist directories.
|
|
59
|
+
*/
|
|
60
|
+
dirs?: RelinkaDirsConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Disables color output in the console.
|
|
63
|
+
*/
|
|
64
|
+
disableColors?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Path to the log file.
|
|
67
|
+
*/
|
|
68
|
+
logFilePath?: string;
|
|
69
|
+
/**
|
|
70
|
+
* If true, logs will be saved to a file.
|
|
71
|
+
*/
|
|
72
|
+
saveLogsToFile?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Configuration for timestamp in log messages.
|
|
75
|
+
*/
|
|
76
|
+
timestamp?: {
|
|
77
|
+
/**
|
|
78
|
+
* If true, timestamps will be added to log messages.
|
|
79
|
+
*/
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The format for timestamps. Default is YYYY-MM-DD HH:mm:ss.SSS
|
|
83
|
+
*/
|
|
84
|
+
format?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Allows to customize the log levels.
|
|
88
|
+
*/
|
|
89
|
+
levels?: LogLevelsConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Controls how often the log cleanup runs (in milliseconds)
|
|
92
|
+
* Default: 10000 (10 seconds)
|
|
93
|
+
*/
|
|
94
|
+
cleanupInterval?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Maximum size of the log write buffer before flushing to disk (in bytes)
|
|
97
|
+
* Default: 4096 (4KB)
|
|
98
|
+
*/
|
|
99
|
+
bufferSize?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Maximum time to hold logs in buffer before flushing to disk (in milliseconds)
|
|
102
|
+
* Default: 5000 (5 seconds)
|
|
103
|
+
*/
|
|
104
|
+
maxBufferAge?: number;
|
|
105
|
+
};
|
|
106
|
+
/** Represents information about a log file for cleanup purposes. */
|
|
107
|
+
export type LogFileInfo = {
|
|
108
|
+
path: string;
|
|
109
|
+
mtime: number;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Promise that resolves once `reconf` loads and merges the config.
|
|
113
|
+
*/
|
|
114
|
+
export declare const relinkaConfig: Promise<RelinkaConfig>;
|
|
115
|
+
/**
|
|
116
|
+
* Shuts down the logger, flushing all buffers and clearing timers.
|
|
117
|
+
* As Relinka user - call this at the end of your program to prevent hanging.
|
|
118
|
+
*/
|
|
119
|
+
export declare function relinkaShutdown(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Flushes all log buffers to disk. Used before process exit or on demand.
|
|
122
|
+
*/
|
|
123
|
+
export declare function flushAllLogBuffers(): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* If something truly impossible happened, log + throw.
|
|
126
|
+
*/
|
|
127
|
+
export declare function shouldNeverHappen(message: string, ...args: unknown[]): never;
|
|
128
|
+
/**
|
|
129
|
+
* Truncates a string to a specified length, adding "…" if truncated.
|
|
130
|
+
*/
|
|
131
|
+
export declare function truncateString(msg: string, maxLength?: number): string;
|
|
132
|
+
/**
|
|
133
|
+
* Exhaustiveness check. If we land here, we missed a union case.
|
|
134
|
+
*/
|
|
135
|
+
export declare function casesHandled(unexpectedCase: never): never;
|
|
136
|
+
/**
|
|
137
|
+
* Logs a message synchronously using the current config.
|
|
138
|
+
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
139
|
+
*/
|
|
140
|
+
export declare function relinka(type: LogLevel | "clear", message: string, ...args: unknown[]): undefined | never;
|
|
141
|
+
/**
|
|
142
|
+
* Logs a message asynchronously, waiting for the config to be fully loaded.
|
|
143
|
+
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
144
|
+
*/
|
|
145
|
+
export declare function relinkaAsync(type: LogLevel, message: string, ...args: unknown[]): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Type helper for user config files.
|
|
148
|
+
*/
|
|
149
|
+
export declare function defineConfig(config: Partial<RelinkaConfig>): Partial<RelinkaConfig>;
|