@reliverse/relinka 1.1.2 → 1.1.4
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 +35 -28
- package/dist-npm/components/checkbox/index.js +8 -6
- package/dist-npm/components/confirm/index.js +7 -4
- package/dist-npm/components/core/Separator.d.ts +0 -4
- package/dist-npm/components/core/create-prompt.js +1 -1
- package/dist-npm/components/core/key.js +6 -6
- package/dist-npm/components/core/lines.d.ts +5 -17
- package/dist-npm/components/core/lines.js +6 -2
- package/dist-npm/components/core/make-theme.js +3 -1
- package/dist-npm/components/core/position.d.ts +0 -8
- package/dist-npm/components/core/position.js +9 -3
- package/dist-npm/components/core/promise-polyfill.js +2 -2
- package/dist-npm/components/core/screen-manager.js +2 -1
- package/dist-npm/components/core/theme.d.ts +12 -146
- package/dist-npm/components/core/theme.js +1 -1
- package/dist-npm/components/core/use-keypress.js +3 -1
- package/dist-npm/components/core/use-pagination.d.ts +4 -8
- package/dist-npm/components/core/use-prefix.js +1 -1
- package/dist-npm/components/core/useKeyPress.js +3 -1
- package/dist-npm/components/core/utils.d.ts +0 -11
- package/dist-npm/components/date/date.d.ts +1 -1
- package/dist-npm/components/date/date.js +74 -12
- package/dist-npm/components/expand/index.js +4 -2
- package/dist-npm/components/figures/index.js +5 -5
- package/dist-npm/components/instance/basic.d.ts +0 -12
- package/dist-npm/components/instance/basic.js +1 -1
- package/dist-npm/components/instance/browser.d.ts +0 -14
- package/dist-npm/components/instance/reporter/browser.js +5 -5
- package/dist-npm/components/instance/reporter/fancy.d.ts +1 -1
- package/dist-npm/components/instance/reporter/fancy.js +1 -1
- package/dist-npm/components/mono/mono.js +9 -9
- package/dist-npm/components/mono/monoTwo.d.ts +13 -76
- package/dist-npm/components/multiselect/multiselect-main.d.ts +4 -2
- package/dist-npm/components/multiselect/multiselect-main.js +12 -10
- package/dist-npm/components/password/password-main.js +1 -1
- package/dist-npm/components/progressbar/ProgressBar.d.ts +3 -14
- package/dist-npm/components/progressbar/ProgressBar.js +3 -14
- package/dist-npm/components/progressbar/helper.d.ts +2 -18
- package/dist-npm/components/prompts/create.d.ts +0 -13
- package/dist-npm/components/prompts/prompt.js +3 -3
- package/dist-npm/components/prompts/promptTwo.d.ts +34 -252
- package/dist-npm/components/prompts/promptTwo.js +6 -27
- package/dist-npm/components/prompts/relinka.d.ts +17 -114
- package/dist-npm/components/prompts/relinka.js +18 -103
- package/dist-npm/components/range/range.d.ts +12 -64
- package/dist-npm/components/range/range.js +36 -59
- package/dist-npm/components/rawlist/index.js +6 -4
- package/dist-npm/components/search/index.js +7 -5
- package/dist-npm/components/select/index.js +9 -3
- package/dist-npm/components/select/select-main.d.ts +1 -1
- package/dist-npm/components/select/select-main.js +4 -3
- package/dist-npm/components/select/select-two.js +3 -1
- package/dist-npm/components/toggle/index.js +3 -1
- package/dist-npm/testing/index.js +1 -1
- package/dist-npm/types/general.d.ts +30 -141
- package/dist-npm/types/keypress.d.ts +0 -3
- package/dist-npm/types/keypress.js +1 -1
- package/dist-npm/types/readline.d.ts +1 -9
- package/dist-npm/types/relinka.d.ts +1 -9
- package/dist-npm/types/utils.d.ts +0 -12
- package/dist-npm/utils/box.d.ts +14 -104
- package/dist-npm/utils/color.d.ts +0 -20
- package/dist-npm/utils/colorize.js +2 -1
- package/dist-npm/utils/component.d.ts +5 -26
- package/dist-npm/utils/component.js +1 -2
- package/dist-npm/utils/constants.d.ts +0 -21
- package/dist-npm/utils/constants.js +8 -8
- package/dist-npm/utils/decoder.d.ts +2 -17
- package/dist-npm/utils/decoder.js +54 -25
- package/dist-npm/utils/error.d.ts +0 -5
- package/dist-npm/utils/errors.d.ts +1 -1
- package/dist-npm/utils/errors.js +8 -4
- package/dist-npm/utils/format.d.ts +0 -12
- package/dist-npm/utils/keypress.d.ts +0 -6
- package/dist-npm/utils/keypress.js +12 -23
- package/dist-npm/utils/log.d.ts +0 -11
- package/dist-npm/utils/prompt-tmp.js +2 -2
- package/dist-npm/utils/prompt-two.js +2 -2
- package/dist-npm/utils/skeleton.d.ts +0 -3
- package/dist-npm/utils/skeleton.js +66 -22
- package/dist-npm/utils/stream.d.ts +0 -13
- package/dist-npm/utils/string.d.ts +0 -45
- package/dist-npm/utils/tree.d.ts +5 -34
- package/dist-npm/utils/variants.js +9 -9
- package/package.json +12 -5
|
@@ -90,155 +90,44 @@ export type ChoiceOptionalOptions = {
|
|
|
90
90
|
export type ChoiceOptions = ChoiceRequiredOptions & ChoiceOptionalOptions;
|
|
91
91
|
export type PromptType = "text" | "number" | "confirm" | "numSelect" | "select" | "multiselect" | "password" | "date" | "start" | "nextSteps" | "end";
|
|
92
92
|
export type RelinkaOptions = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
level: LogLevel;
|
|
106
|
-
/**
|
|
107
|
-
* Default properties applied to all log messages unless overridden. See {@link InputLogObject}.
|
|
108
|
-
*/
|
|
109
|
-
defaults: InputLogObject;
|
|
110
|
-
/**
|
|
111
|
-
* The maximum number of times a log message can be repeated within a given frame of time.
|
|
112
|
-
*/
|
|
113
|
-
throttle: number;
|
|
114
|
-
/**
|
|
115
|
-
* The minimum time in milliseconds that must elapse before a throttled log message can be logged again.
|
|
116
|
-
*/
|
|
117
|
-
throttleMin: number;
|
|
118
|
-
/**
|
|
119
|
-
* The Node writable stream for standard output. See {@link NodeJS.WriteStream}.
|
|
120
|
-
* @optional
|
|
121
|
-
*/
|
|
122
|
-
stdout?: NodeJS.WriteStream;
|
|
123
|
-
/**
|
|
124
|
-
* The Node writeable stream for standard error output. See {@link NodeJS.WriteStream}.
|
|
125
|
-
* @optional
|
|
126
|
-
*/
|
|
127
|
-
stderr?: NodeJS.WriteStream;
|
|
128
|
-
/**
|
|
129
|
-
* A function that allows you to mock log messages for testing purposes.
|
|
130
|
-
* @optional
|
|
131
|
-
*/
|
|
132
|
-
mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
|
|
133
|
-
/**
|
|
134
|
-
* Custom prompt function to use. It can be undefined.
|
|
135
|
-
* @optional
|
|
136
|
-
*/
|
|
137
|
-
prompt?: typeof import("../components/mono/monoTwo.js").prompt | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* Configuration options for formatting log messages. See {@link FormatOptions}.
|
|
140
|
-
*/
|
|
141
|
-
formatOptions: FormatOptions;
|
|
93
|
+
reporters: RelinkaReporter[];
|
|
94
|
+
types: Record<LogType, InputLogObject>;
|
|
95
|
+
level: LogLevel;
|
|
96
|
+
defaults: InputLogObject;
|
|
97
|
+
throttle: number;
|
|
98
|
+
throttleMin: number;
|
|
99
|
+
stdout?: NodeJS.WriteStream;
|
|
100
|
+
stderr?: NodeJS.WriteStream;
|
|
101
|
+
mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
|
|
102
|
+
prompt?: typeof import("../components/mono/monoTwo.js").prompt | undefined;
|
|
103
|
+
formatOptions: FormatOptions;
|
|
142
104
|
};
|
|
143
|
-
/**
|
|
144
|
-
* @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
|
|
145
|
-
*/
|
|
146
105
|
export type FormatOptions = {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Whether to include timestamp information in log messages.
|
|
154
|
-
* @optional
|
|
155
|
-
*/
|
|
156
|
-
date?: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Whether to use colors in the output.
|
|
159
|
-
* @optional
|
|
160
|
-
*/
|
|
161
|
-
colors?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Specifies whether or not the output should be compact. Accepts a boolean or numeric level of compactness.
|
|
164
|
-
* @optional
|
|
165
|
-
*/
|
|
166
|
-
compact?: boolean | number;
|
|
167
|
-
/**
|
|
168
|
-
* Allows additional custom formatting options.
|
|
169
|
-
*/
|
|
170
|
-
[key: string]: unknown;
|
|
106
|
+
columns?: number;
|
|
107
|
+
date?: boolean;
|
|
108
|
+
colors?: boolean;
|
|
109
|
+
compact?: boolean | number;
|
|
110
|
+
[key: string]: unknown;
|
|
171
111
|
};
|
|
172
112
|
export type InputLogObject = {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* @optional
|
|
181
|
-
*/
|
|
182
|
-
tag?: string;
|
|
183
|
-
/**
|
|
184
|
-
* The type of log message, which affects how it's processed and displayed. See {@link LogType}.
|
|
185
|
-
* @optional
|
|
186
|
-
*/
|
|
187
|
-
type?: LogType;
|
|
188
|
-
/**
|
|
189
|
-
* The main log message text.
|
|
190
|
-
* @optional
|
|
191
|
-
*/
|
|
192
|
-
message?: string;
|
|
193
|
-
/**
|
|
194
|
-
* Additional text or texts to be logged with the message.
|
|
195
|
-
* @optional
|
|
196
|
-
*/
|
|
197
|
-
additional?: string | string[];
|
|
198
|
-
/**
|
|
199
|
-
* Additional arguments to be logged with the message.
|
|
200
|
-
* @optional
|
|
201
|
-
*/
|
|
202
|
-
args?: any[];
|
|
203
|
-
/**
|
|
204
|
-
* The date and time when the log message was created.
|
|
205
|
-
* @optional
|
|
206
|
-
*/
|
|
207
|
-
date?: Date;
|
|
113
|
+
level?: LogLevel;
|
|
114
|
+
tag?: string;
|
|
115
|
+
type?: LogType;
|
|
116
|
+
message?: string;
|
|
117
|
+
additional?: string | string[];
|
|
118
|
+
args?: any[];
|
|
119
|
+
date?: Date;
|
|
208
120
|
};
|
|
209
121
|
export type LogObject = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
*/
|
|
217
|
-
type: LogType;
|
|
218
|
-
/**
|
|
219
|
-
* A string tag to categorize or identify the log message, overridden if necessary.
|
|
220
|
-
*/
|
|
221
|
-
tag: string;
|
|
222
|
-
/**
|
|
223
|
-
* Additional arguments to be logged with the message, overridden if necessary.
|
|
224
|
-
*/
|
|
225
|
-
args: any[];
|
|
226
|
-
/**
|
|
227
|
-
* The date and time the log message was created, overridden if necessary.
|
|
228
|
-
*/
|
|
229
|
-
date: Date;
|
|
230
|
-
/**
|
|
231
|
-
* Allows additional custom properties to be set on the log object.
|
|
232
|
-
*/
|
|
233
|
-
[key: string]: unknown;
|
|
122
|
+
level: LogLevel;
|
|
123
|
+
type: LogType;
|
|
124
|
+
tag: string;
|
|
125
|
+
args: any[];
|
|
126
|
+
date: Date;
|
|
127
|
+
[key: string]: unknown;
|
|
234
128
|
} & InputLogObject;
|
|
235
129
|
export type RelinkaReporter = {
|
|
236
|
-
|
|
237
|
-
* Defines how a log message is processed and displayed by this reporter.
|
|
238
|
-
* @param logObj The LogObject containing the log information to process. See {@link LogObject}.
|
|
239
|
-
* @param ctx An object containing context information such as options. See {@link RelinkaOptions}.
|
|
240
|
-
*/
|
|
241
|
-
log: (logObj: LogObject, ctx: {
|
|
130
|
+
log: (logObj: LogObject, ctx: {
|
|
242
131
|
options: RelinkaOptions;
|
|
243
132
|
}) => void;
|
|
244
133
|
};
|
|
@@ -44,9 +44,6 @@ export type Keypress = {
|
|
|
44
44
|
raw: string;
|
|
45
45
|
};
|
|
46
46
|
export type KeypressCallback = (key: Keypress) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Type definition for the listenForKeys function
|
|
49
|
-
*/
|
|
50
47
|
export type ListenForKeys = {
|
|
51
48
|
(stream: Readable, callback: KeypressCallback): () => void;
|
|
52
49
|
parse: (s: string | Buffer, enc?: string) => Keypress | Keypress[];
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type { Duplex } from "node:stream";
|
|
2
|
-
/**
|
|
3
|
-
* `RelinkaReadline` is a re-implementation of `readline.Interface` from Node.
|
|
4
|
-
* It is reimplemented because of 3 reasons:
|
|
5
|
-
* 1. The `readline.Interface` API is not complete; it's missing for example `clearLine`.
|
|
6
|
-
* 2. The input/output streams are not generics, meaning they're inexact.
|
|
7
|
-
* 3. Since ReadLine isn't built-in Typescript Global NodeJS type, it'd force us to ship `@types/node` as a dependency to all users.
|
|
8
|
-
*/
|
|
9
2
|
export type RelinkaReadline = {
|
|
10
3
|
output: Duplex & {
|
|
11
4
|
mute: () => void;
|
|
@@ -33,6 +26,5 @@ export type Context = {
|
|
|
33
26
|
signal?: AbortSignal;
|
|
34
27
|
};
|
|
35
28
|
export type Prompt<Value, Config> = (config: Config, context?: Context) => Promise<Value> & {
|
|
36
|
-
|
|
37
|
-
cancel: () => void;
|
|
29
|
+
cancel: () => void;
|
|
38
30
|
};
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type { Duplex } from "node:stream";
|
|
2
|
-
/**
|
|
3
|
-
* `RelinkaReadline` is a re-implementation of `readline.Interface` from Node.js.
|
|
4
|
-
* It's reimplemented because of 3 reasons:
|
|
5
|
-
* 1. The `readline.Interface` API is not complete; it's missing for example `clearLine`.
|
|
6
|
-
* 2. The input/output streams are not generics, meaning they're inexact.
|
|
7
|
-
* 3. Since ReadLine isn't built-in Typescript Global NodeJS type, it'd force us to ship `@types/node` as a dependency to all users.
|
|
8
|
-
*/
|
|
9
2
|
export type RelinkaReadline = {
|
|
10
3
|
output: Duplex & {
|
|
11
4
|
mute: () => void;
|
|
@@ -33,6 +26,5 @@ export type Context = {
|
|
|
33
26
|
signal?: AbortSignal;
|
|
34
27
|
};
|
|
35
28
|
export type Prompt<Value, Config> = (config: Config, context?: Context) => Promise<Value> & {
|
|
36
|
-
|
|
37
|
-
cancel: () => void;
|
|
29
|
+
cancel: () => void;
|
|
38
30
|
};
|
|
@@ -9,21 +9,9 @@ export type LiteralUnion<T extends F, F = string> = T | (F & {});
|
|
|
9
9
|
export type KeyUnion<T> = LiteralUnion<Extract<keyof T, string>>;
|
|
10
10
|
export type DistributiveMerge<A, B> = A extends any ? Prettify<Omit<A, keyof B> & B> : never;
|
|
11
11
|
export type UnionToIntersection<T> = (T extends any ? (input: T) => void : never) extends (input: infer Intersection) => void ? Intersection : never;
|
|
12
|
-
/**
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
12
|
type __Pick<O extends object, K extends keyof O> = {
|
|
16
13
|
[P in K]: O[P];
|
|
17
14
|
} & {};
|
|
18
|
-
/**
|
|
19
|
-
* @hidden
|
|
20
|
-
*/
|
|
21
15
|
export type _Pick<O extends object, K extends Key> = __Pick<O, keyof O & K>;
|
|
22
|
-
/**
|
|
23
|
-
* Extract out of `O` the fields of key `K`
|
|
24
|
-
* @param O to extract from
|
|
25
|
-
* @param K to chose fields
|
|
26
|
-
* @returns [[Object]]
|
|
27
|
-
*/
|
|
28
16
|
export type Pick<O extends object, K extends Key> = O extends unknown ? _Pick<O, K> : never;
|
|
29
17
|
export {};
|
package/dist-npm/utils/box.d.ts
CHANGED
|
@@ -1,114 +1,24 @@
|
|
|
1
1
|
export type BoxBorderStyle = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
tl: string;
|
|
9
|
-
/**
|
|
10
|
-
* Top right corner
|
|
11
|
-
* @example `┐`
|
|
12
|
-
* @example `╗`
|
|
13
|
-
* @example `╖`
|
|
14
|
-
*/
|
|
15
|
-
tr: string;
|
|
16
|
-
/**
|
|
17
|
-
* Bottom left corner
|
|
18
|
-
* @example `└`
|
|
19
|
-
* @example `╚`
|
|
20
|
-
* @example `╙`
|
|
21
|
-
*/
|
|
22
|
-
bl: string;
|
|
23
|
-
/**
|
|
24
|
-
* Bottom right corner
|
|
25
|
-
* @example `┘`
|
|
26
|
-
* @example `╝`
|
|
27
|
-
* @example `╜`
|
|
28
|
-
*/
|
|
29
|
-
br: string;
|
|
30
|
-
/**
|
|
31
|
-
* Horizontal line
|
|
32
|
-
* @example `─`
|
|
33
|
-
* @example `═`
|
|
34
|
-
* @example `─`
|
|
35
|
-
*/
|
|
36
|
-
h: string;
|
|
37
|
-
/**
|
|
38
|
-
* Vertical line
|
|
39
|
-
* @example `│`
|
|
40
|
-
* @example `║`
|
|
41
|
-
* @example `║`
|
|
42
|
-
*/
|
|
43
|
-
v: string;
|
|
2
|
+
tl: string;
|
|
3
|
+
tr: string;
|
|
4
|
+
bl: string;
|
|
5
|
+
br: string;
|
|
6
|
+
h: string;
|
|
7
|
+
v: string;
|
|
44
8
|
};
|
|
45
9
|
declare const boxStylePresets: Record<string, BoxBorderStyle>;
|
|
46
10
|
export type BoxStyle = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @default 'solid'
|
|
55
|
-
* @example 'single-double-rounded'
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* {
|
|
59
|
-
* tl: '┌',
|
|
60
|
-
* tr: '┐',
|
|
61
|
-
* bl: '└',
|
|
62
|
-
* br: '┘',
|
|
63
|
-
* h: '─',
|
|
64
|
-
* v: '│',
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
|
|
69
|
-
/**
|
|
70
|
-
* The vertical alignment of the text
|
|
71
|
-
* @default 'center'
|
|
72
|
-
*/
|
|
73
|
-
valign: "top" | "center" | "bottom";
|
|
74
|
-
/**
|
|
75
|
-
* The padding of the box
|
|
76
|
-
* @default 2
|
|
77
|
-
*/
|
|
78
|
-
padding: number;
|
|
79
|
-
/**
|
|
80
|
-
* The left margin of the box
|
|
81
|
-
* @default 1
|
|
82
|
-
*/
|
|
83
|
-
marginLeft: number;
|
|
84
|
-
/**
|
|
85
|
-
* The top margin of the box
|
|
86
|
-
* @default 1
|
|
87
|
-
*/
|
|
88
|
-
marginTop: number;
|
|
89
|
-
/**
|
|
90
|
-
* The top margin of the box
|
|
91
|
-
* @default 1
|
|
92
|
-
*/
|
|
93
|
-
marginBottom: number;
|
|
11
|
+
borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
|
|
12
|
+
borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
|
|
13
|
+
valign: "top" | "center" | "bottom";
|
|
14
|
+
padding: number;
|
|
15
|
+
marginLeft: number;
|
|
16
|
+
marginTop: number;
|
|
17
|
+
marginBottom: number;
|
|
94
18
|
};
|
|
95
|
-
/**
|
|
96
|
-
* The border options of the box
|
|
97
|
-
*/
|
|
98
19
|
export type BoxOpts = {
|
|
99
|
-
|
|
100
|
-
* Title that will be displayed on top of the box
|
|
101
|
-
* @example 'Hello World'
|
|
102
|
-
* @example 'Hello {name}'
|
|
103
|
-
*/
|
|
104
|
-
title?: string;
|
|
20
|
+
title?: string;
|
|
105
21
|
style?: Partial<BoxStyle>;
|
|
106
22
|
};
|
|
107
|
-
/**
|
|
108
|
-
* Creates a styled box with text content, customizable via options.
|
|
109
|
-
* @param {string} text - The text to display in the box.
|
|
110
|
-
* @param {BoxOpts} [_opts={}] - Optional settings for the appearance and behavior of the box. See {@link BoxOpts}.
|
|
111
|
-
* @returns {string} The formatted box as a string, ready for printing or logging.
|
|
112
|
-
*/
|
|
113
23
|
export declare function box(text: string, _opts?: BoxOpts): string;
|
|
114
24
|
export {};
|
|
@@ -1,8 +1,3 @@
|
|
|
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
|
|
5
|
-
*/
|
|
6
1
|
declare const colorDefs: {
|
|
7
2
|
reset: (string: string) => string;
|
|
8
3
|
bold: (string: string) => string;
|
|
@@ -48,22 +43,7 @@ declare const colorDefs: {
|
|
|
48
43
|
};
|
|
49
44
|
export type ColorName = keyof typeof colorDefs;
|
|
50
45
|
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
46
|
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
47
|
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
48
|
export declare function colorize(color: ColorName, text: string | number): string;
|
|
69
49
|
export {};
|
|
@@ -103,10 +103,11 @@ export function colorize(text, colorName, typography) {
|
|
|
103
103
|
"rainbowGradient",
|
|
104
104
|
"viceGradient"
|
|
105
105
|
];
|
|
106
|
-
if (gradientColors.includes(colorName ?? "") && typography)
|
|
106
|
+
if (gradientColors.includes(colorName ?? "") && typography) {
|
|
107
107
|
throw new Error(
|
|
108
108
|
"[colorize] Cannot apply typography to gradient color.\n\u2502 Use regular colorize()'s color or remove typography."
|
|
109
109
|
);
|
|
110
|
+
}
|
|
110
111
|
if (!gradientColors.includes(colorName ?? "") && typography) {
|
|
111
112
|
switch (typography) {
|
|
112
113
|
case "bold":
|
|
@@ -68,8 +68,7 @@ export declare const log: {
|
|
|
68
68
|
success: (message: string) => void;
|
|
69
69
|
step: (message: string) => void;
|
|
70
70
|
warn: (message: string) => void;
|
|
71
|
-
|
|
72
|
-
warning: (message: string) => void;
|
|
71
|
+
warning: (message: string) => void;
|
|
73
72
|
error: (message: string) => void;
|
|
74
73
|
};
|
|
75
74
|
export declare const spinner: () => {
|
|
@@ -81,11 +80,7 @@ export type PromptGroupAwaitedReturn<T> = {
|
|
|
81
80
|
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
|
82
81
|
};
|
|
83
82
|
export type PromptGroupOptions<T> = {
|
|
84
|
-
|
|
85
|
-
* Control how the group can be canceled
|
|
86
|
-
* if one of the prompts is canceled.
|
|
87
|
-
*/
|
|
88
|
-
onCancel?: (opts: {
|
|
83
|
+
onCancel?: (opts: {
|
|
89
84
|
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
|
90
85
|
}) => void;
|
|
91
86
|
};
|
|
@@ -97,26 +92,10 @@ export type PromptGroup<T> = {
|
|
|
97
92
|
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
|
98
93
|
}) => void | Promise<T[P] | void>;
|
|
99
94
|
};
|
|
100
|
-
/**
|
|
101
|
-
* Define a group of prompts to be displayed
|
|
102
|
-
* and return a results of objects within the group
|
|
103
|
-
*/
|
|
104
95
|
export declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T>) => Promise<Prettify<PromptGroupAwaitedReturn<T>>>;
|
|
105
96
|
export type Task = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
title: string;
|
|
110
|
-
/**
|
|
111
|
-
* Task function
|
|
112
|
-
*/
|
|
113
|
-
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* If enabled === false the task will be skipped
|
|
116
|
-
*/
|
|
117
|
-
enabled?: boolean;
|
|
97
|
+
title: string;
|
|
98
|
+
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
|
|
99
|
+
enabled?: boolean;
|
|
118
100
|
};
|
|
119
|
-
/**
|
|
120
|
-
* Define a group of tasks to be executed
|
|
121
|
-
*/
|
|
122
101
|
export declare const tasks: (tasks: Task[]) => Promise<void>;
|
|
@@ -517,8 +517,7 @@ export const log = {
|
|
|
517
517
|
warn: (message) => {
|
|
518
518
|
log.message(message, { symbol: color.yellow(S_WARN) });
|
|
519
519
|
},
|
|
520
|
-
|
|
521
|
-
warning: (message) => {
|
|
520
|
+
warning: (message) => {
|
|
522
521
|
log.warn(message);
|
|
523
522
|
},
|
|
524
523
|
error: (message) => {
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import type { LogObject } from "../types/general.js";
|
|
2
|
-
/**
|
|
3
|
-
* Defines the level of logs as specific numbers or special number types.
|
|
4
|
-
*
|
|
5
|
-
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevel - Represents the log level.
|
|
6
|
-
* @default 0 - Represents the default log level.
|
|
7
|
-
*/
|
|
8
2
|
export type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
9
|
-
/**
|
|
10
|
-
* A mapping of `LogType` to its corresponding numeric log level.
|
|
11
|
-
*
|
|
12
|
-
* @type {Record<LogType, number>} LogLevels - key-value pairs of log types to their numeric levels. See {@link LogType}.
|
|
13
|
-
*/
|
|
14
3
|
export declare const LogLevels: Record<LogType, number>;
|
|
15
|
-
/**
|
|
16
|
-
* Lists the types of log messages supported by the system.
|
|
17
|
-
*
|
|
18
|
-
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogType - Represents the specific type of log message.
|
|
19
|
-
*/
|
|
20
4
|
export type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
21
|
-
/**
|
|
22
|
-
* Maps `LogType` to a `Partial<LogObject>`, primarily defining the log level.
|
|
23
|
-
*
|
|
24
|
-
* @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}.
|
|
25
|
-
*/
|
|
26
5
|
export declare const LogTypes: Record<LogType, Partial<LogObject>>;
|
|
@@ -15,26 +15,26 @@ export const LogLevels = {
|
|
|
15
15
|
verbose: Number.POSITIVE_INFINITY
|
|
16
16
|
};
|
|
17
17
|
export const LogTypes = {
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
silent: {
|
|
20
20
|
level: -1
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
fatal: {
|
|
24
24
|
level: LogLevels.fatal
|
|
25
25
|
},
|
|
26
26
|
error: {
|
|
27
27
|
level: LogLevels.error
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
warn: {
|
|
31
31
|
level: LogLevels.warn
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
log: {
|
|
35
35
|
level: LogLevels.log
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
info: {
|
|
39
39
|
level: LogLevels.info
|
|
40
40
|
},
|
|
@@ -53,15 +53,15 @@ export const LogTypes = {
|
|
|
53
53
|
box: {
|
|
54
54
|
level: LogLevels.info
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
debug: {
|
|
58
58
|
level: LogLevels.debug
|
|
59
59
|
},
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
trace: {
|
|
62
62
|
level: LogLevels.trace
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
verbose: {
|
|
66
66
|
level: LogLevels.verbose
|
|
67
67
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Buffer } from "safe-buffer";
|
|
2
|
-
/**
|
|
3
|
-
* StringDecoder provides an interface for efficiently splitting a series of
|
|
4
|
-
* buffers into a series of JS strings without breaking apart multi-byte
|
|
5
|
-
* characters.
|
|
6
|
-
*/
|
|
7
2
|
export declare class StringDecoder {
|
|
8
3
|
encoding: BufferEncoding;
|
|
9
4
|
lastNeed: number;
|
|
@@ -14,16 +9,6 @@ export declare class StringDecoder {
|
|
|
14
9
|
endFn?: (buf?: Buffer) => string;
|
|
15
10
|
writeFn: (buf: Buffer) => string;
|
|
16
11
|
constructor(encoding?: BufferEncoding | string);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @param buf - The buffer to write.
|
|
20
|
-
* @returns The decoded string.
|
|
21
|
-
*/
|
|
22
|
-
write(buf: Buffer): string;
|
|
23
|
-
/**
|
|
24
|
-
* Ends the decoding and returns any remaining characters.
|
|
25
|
-
* @param buf - Optional buffer to write before ending.
|
|
26
|
-
* @returns The final decoded string.
|
|
27
|
-
*/
|
|
28
|
-
end(buf?: Buffer): string;
|
|
12
|
+
write(buf: Buffer): string;
|
|
13
|
+
end(buf?: Buffer): string;
|
|
29
14
|
}
|