bob-core 3.0.0-beta.10 → 3.0.0-beta.11
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/dist/cjs/args/index.d.ts +30 -23
- package/dist/cjs/flags/boolean.d.ts +4 -4
- package/dist/cjs/flags/custom.d.ts +1 -1
- package/dist/cjs/flags/directory.d.ts +7 -5
- package/dist/cjs/flags/file.d.ts +7 -5
- package/dist/cjs/flags/index.d.ts +34 -27
- package/dist/cjs/flags/number.d.ts +8 -5
- package/dist/cjs/flags/string.d.ts +4 -4
- package/dist/cjs/flags/url.d.ts +4 -4
- package/dist/cjs/index.js +1 -1
- package/dist/esm/args/index.d.ts +30 -23
- package/dist/esm/flags/boolean.d.ts +4 -4
- package/dist/esm/flags/custom.d.ts +1 -1
- package/dist/esm/flags/directory.d.ts +7 -5
- package/dist/esm/flags/file.d.ts +7 -5
- package/dist/esm/flags/index.d.ts +34 -27
- package/dist/esm/flags/number.d.ts +8 -5
- package/dist/esm/flags/string.d.ts +4 -4
- package/dist/esm/flags/url.d.ts +4 -4
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
package/dist/cjs/args/index.d.ts
CHANGED
|
@@ -7,38 +7,41 @@ import { optionFlag } from '../flags/option.js';
|
|
|
7
7
|
* positional inputs and the `ArgsSchema` type rejects them at compile time.
|
|
8
8
|
*/
|
|
9
9
|
export declare const Args: {
|
|
10
|
-
string: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
10
|
+
string: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
11
11
|
[x: string]: unknown;
|
|
12
12
|
} & {
|
|
13
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
13
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
14
14
|
type?: import('../index.js').FlagKind;
|
|
15
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
15
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
16
16
|
description?: string;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
19
19
|
multiple?: boolean;
|
|
20
20
|
help?: string;
|
|
21
21
|
alias?: string | readonly string[];
|
|
22
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
22
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
23
23
|
shouldStop: boolean;
|
|
24
24
|
} | void) | undefined;
|
|
25
25
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
|
26
|
-
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
26
|
+
number: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
27
27
|
min?: number;
|
|
28
28
|
max?: number;
|
|
29
|
-
},
|
|
29
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
30
33
|
min?: number | undefined;
|
|
31
34
|
max?: number | undefined;
|
|
32
35
|
} & {
|
|
33
36
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
34
37
|
min?: number;
|
|
35
38
|
max?: number;
|
|
36
|
-
},
|
|
39
|
+
}, Ctx>) => number;
|
|
37
40
|
type?: import('../index.js').FlagKind;
|
|
38
41
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
39
42
|
min?: number;
|
|
40
43
|
max?: number;
|
|
41
|
-
},
|
|
44
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
42
45
|
description?: string;
|
|
43
46
|
required?: boolean;
|
|
44
47
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -48,7 +51,7 @@ export declare const Args: {
|
|
|
48
51
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
49
52
|
min?: number;
|
|
50
53
|
max?: number;
|
|
51
|
-
},
|
|
54
|
+
}, Ctx>) => {
|
|
52
55
|
shouldStop: boolean;
|
|
53
56
|
} | void) | undefined;
|
|
54
57
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
@@ -56,18 +59,20 @@ export declare const Args: {
|
|
|
56
59
|
max?: number;
|
|
57
60
|
}, any>> & O;
|
|
58
61
|
option: typeof optionFlag;
|
|
59
|
-
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
62
|
+
file: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
60
63
|
exists?: boolean;
|
|
61
|
-
},
|
|
64
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
65
|
+
exists?: boolean;
|
|
66
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
62
67
|
exists?: boolean | undefined;
|
|
63
68
|
} & {
|
|
64
69
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
65
70
|
exists?: boolean;
|
|
66
|
-
},
|
|
71
|
+
}, Ctx>) => string;
|
|
67
72
|
type?: import('../index.js').FlagKind;
|
|
68
73
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
69
74
|
exists?: boolean;
|
|
70
|
-
},
|
|
75
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
71
76
|
description?: string;
|
|
72
77
|
required?: boolean;
|
|
73
78
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -76,24 +81,26 @@ export declare const Args: {
|
|
|
76
81
|
alias?: string | readonly string[];
|
|
77
82
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
78
83
|
exists?: boolean;
|
|
79
|
-
},
|
|
84
|
+
}, Ctx>) => {
|
|
80
85
|
shouldStop: boolean;
|
|
81
86
|
} | void) | undefined;
|
|
82
87
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
83
88
|
exists?: boolean;
|
|
84
89
|
}, any>> & O;
|
|
85
|
-
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
90
|
+
directory: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
91
|
+
exists?: boolean;
|
|
92
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
86
93
|
exists?: boolean;
|
|
87
|
-
},
|
|
94
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
88
95
|
exists?: boolean | undefined;
|
|
89
96
|
} & {
|
|
90
97
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
91
98
|
exists?: boolean;
|
|
92
|
-
},
|
|
99
|
+
}, Ctx>) => string;
|
|
93
100
|
type?: import('../index.js').FlagKind;
|
|
94
101
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
95
102
|
exists?: boolean;
|
|
96
|
-
},
|
|
103
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
97
104
|
description?: string;
|
|
98
105
|
required?: boolean;
|
|
99
106
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -102,25 +109,25 @@ export declare const Args: {
|
|
|
102
109
|
alias?: string | readonly string[];
|
|
103
110
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
104
111
|
exists?: boolean;
|
|
105
|
-
},
|
|
112
|
+
}, Ctx>) => {
|
|
106
113
|
shouldStop: boolean;
|
|
107
114
|
} | void) | undefined;
|
|
108
115
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
109
116
|
exists?: boolean;
|
|
110
117
|
}, any>> & O;
|
|
111
|
-
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
118
|
+
url: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
112
119
|
[x: string]: unknown;
|
|
113
120
|
} & {
|
|
114
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
121
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
115
122
|
type?: import('../index.js').FlagKind;
|
|
116
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
123
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
117
124
|
description?: string;
|
|
118
125
|
required?: boolean;
|
|
119
126
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
120
127
|
multiple?: boolean;
|
|
121
128
|
help?: string;
|
|
122
129
|
alias?: string | readonly string[];
|
|
123
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
130
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
124
131
|
shouldStop: boolean;
|
|
125
132
|
} | void) | undefined;
|
|
126
133
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { FlagOpts } from '../lib/types.js';
|
|
2
2
|
/** Boolean flag (`--debug` / `--no-debug`). Defaults to `false` when omitted. */
|
|
3
|
-
export declare const booleanFlag: <const O extends Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions,
|
|
3
|
+
export declare const booleanFlag: <Ctx extends unknown = any, const O extends Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, Ctx>> = Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
4
4
|
[x: string]: unknown;
|
|
5
5
|
} & {
|
|
6
|
-
parse: (input: any, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
6
|
+
parse: (input: any, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => boolean;
|
|
7
7
|
type?: import('../lib/types.js').FlagKind;
|
|
8
|
-
ask?: ((opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
8
|
+
ask?: ((opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
9
9
|
description?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
12
12
|
multiple?: boolean;
|
|
13
13
|
help?: string;
|
|
14
14
|
alias?: string | readonly string[];
|
|
15
|
-
handler?: ((value: boolean, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
15
|
+
handler?: ((value: boolean, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => {
|
|
16
16
|
shouldStop: boolean;
|
|
17
17
|
} | void) | undefined;
|
|
18
18
|
} & Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, any>> & O;
|
|
@@ -9,4 +9,4 @@ import { ContextDefinition, CustomOptions, FlagDefinition, InitFlagDefinition }
|
|
|
9
9
|
* The `type` literal supplied in `defaults` is preserved in the returned shape
|
|
10
10
|
* so downstream consumers can rely on it (e.g. for help rendering).
|
|
11
11
|
*/
|
|
12
|
-
export declare function custom<T, C extends CustomOptions = CustomOptions, Ctx extends ContextDefinition = ContextDefinition, const D extends InitFlagDefinition<T, C, Ctx> = InitFlagDefinition<T, C, Ctx>>(defaults?: D): <const O extends InitFlagDefinition<T, C,
|
|
12
|
+
export declare function custom<T, C extends CustomOptions = CustomOptions, Ctx extends ContextDefinition = ContextDefinition, const D extends InitFlagDefinition<T, C, Ctx> = InitFlagDefinition<T, C, Ctx>>(defaults?: D): <Ctx_1 extends ContextDefinition = ContextDefinition, const O extends InitFlagDefinition<T, C, Ctx_1> = InitFlagDefinition<T, C, Ctx_1>>(overrides?: O) => FlagDefinition<T, C, Ctx_1> & D & O;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/** Filesystem directory flag. Pass `exists: true` to require the directory to exist at parse time. */
|
|
2
|
-
export declare const directoryFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
2
|
+
export declare const directoryFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
3
3
|
exists?: boolean;
|
|
4
|
-
},
|
|
4
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
5
7
|
exists?: boolean | undefined;
|
|
6
8
|
} & {
|
|
7
9
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
8
10
|
exists?: boolean;
|
|
9
|
-
},
|
|
11
|
+
}, Ctx>) => string;
|
|
10
12
|
type?: import('../index.js').FlagKind;
|
|
11
13
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
12
14
|
exists?: boolean;
|
|
13
|
-
},
|
|
15
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
14
16
|
description?: string;
|
|
15
17
|
required?: boolean;
|
|
16
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -19,7 +21,7 @@ export declare const directoryFlag: <const O extends Partial<import('../index.js
|
|
|
19
21
|
alias?: string | readonly string[];
|
|
20
22
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
21
23
|
exists?: boolean;
|
|
22
|
-
},
|
|
24
|
+
}, Ctx>) => {
|
|
23
25
|
shouldStop: boolean;
|
|
24
26
|
} | void) | undefined;
|
|
25
27
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
package/dist/cjs/flags/file.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/** Filesystem file flag. Pass `exists: true` to require the path to exist at parse time. */
|
|
2
|
-
export declare const fileFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
2
|
+
export declare const fileFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
3
3
|
exists?: boolean;
|
|
4
|
-
},
|
|
4
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
5
7
|
exists?: boolean | undefined;
|
|
6
8
|
} & {
|
|
7
9
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
8
10
|
exists?: boolean;
|
|
9
|
-
},
|
|
11
|
+
}, Ctx>) => string;
|
|
10
12
|
type?: import('../index.js').FlagKind;
|
|
11
13
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
12
14
|
exists?: boolean;
|
|
13
|
-
},
|
|
15
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
14
16
|
description?: string;
|
|
15
17
|
required?: boolean;
|
|
16
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -19,7 +21,7 @@ export declare const fileFlag: <const O extends Partial<import('../index.js').Fl
|
|
|
19
21
|
alias?: string | readonly string[];
|
|
20
22
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
21
23
|
exists?: boolean;
|
|
22
|
-
},
|
|
24
|
+
}, Ctx>) => {
|
|
23
25
|
shouldStop: boolean;
|
|
24
26
|
} | void) | undefined;
|
|
25
27
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
@@ -17,38 +17,41 @@ import { optionFlag } from './option.js';
|
|
|
17
17
|
* default, multiple, ask, handler, help) plus its builder-specific extras.
|
|
18
18
|
*/
|
|
19
19
|
export declare const Flags: {
|
|
20
|
-
string: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
20
|
+
string: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
21
21
|
[x: string]: unknown;
|
|
22
22
|
} & {
|
|
23
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
23
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
24
24
|
type?: import('../index.js').FlagKind;
|
|
25
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
25
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
26
26
|
description?: string;
|
|
27
27
|
required?: boolean;
|
|
28
28
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
help?: string;
|
|
31
31
|
alias?: string | readonly string[];
|
|
32
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
32
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
33
33
|
shouldStop: boolean;
|
|
34
34
|
} | void) | undefined;
|
|
35
35
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
|
36
|
-
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
36
|
+
number: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
37
37
|
min?: number;
|
|
38
38
|
max?: number;
|
|
39
|
-
},
|
|
39
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
40
|
+
min?: number;
|
|
41
|
+
max?: number;
|
|
42
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
40
43
|
min?: number | undefined;
|
|
41
44
|
max?: number | undefined;
|
|
42
45
|
} & {
|
|
43
46
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
44
47
|
min?: number;
|
|
45
48
|
max?: number;
|
|
46
|
-
},
|
|
49
|
+
}, Ctx>) => number;
|
|
47
50
|
type?: import('../index.js').FlagKind;
|
|
48
51
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
49
52
|
min?: number;
|
|
50
53
|
max?: number;
|
|
51
|
-
},
|
|
54
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
52
55
|
description?: string;
|
|
53
56
|
required?: boolean;
|
|
54
57
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -58,42 +61,44 @@ export declare const Flags: {
|
|
|
58
61
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
59
62
|
min?: number;
|
|
60
63
|
max?: number;
|
|
61
|
-
},
|
|
64
|
+
}, Ctx>) => {
|
|
62
65
|
shouldStop: boolean;
|
|
63
66
|
} | void) | undefined;
|
|
64
67
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
65
68
|
min?: number;
|
|
66
69
|
max?: number;
|
|
67
70
|
}, any>> & O;
|
|
68
|
-
boolean: <const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions,
|
|
71
|
+
boolean: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
69
72
|
[x: string]: unknown;
|
|
70
73
|
} & {
|
|
71
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
74
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => boolean;
|
|
72
75
|
type?: import('../index.js').FlagKind;
|
|
73
|
-
ask?: ((opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
76
|
+
ask?: ((opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
74
77
|
description?: string;
|
|
75
78
|
required?: boolean;
|
|
76
79
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
77
80
|
multiple?: boolean;
|
|
78
81
|
help?: string;
|
|
79
82
|
alias?: string | readonly string[];
|
|
80
|
-
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
83
|
+
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => {
|
|
81
84
|
shouldStop: boolean;
|
|
82
85
|
} | void) | undefined;
|
|
83
86
|
} & Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, any>> & O;
|
|
84
87
|
option: typeof optionFlag;
|
|
85
|
-
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
88
|
+
file: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
86
89
|
exists?: boolean;
|
|
87
|
-
},
|
|
90
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
91
|
+
exists?: boolean;
|
|
92
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
88
93
|
exists?: boolean | undefined;
|
|
89
94
|
} & {
|
|
90
95
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
91
96
|
exists?: boolean;
|
|
92
|
-
},
|
|
97
|
+
}, Ctx>) => string;
|
|
93
98
|
type?: import('../index.js').FlagKind;
|
|
94
99
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
95
100
|
exists?: boolean;
|
|
96
|
-
},
|
|
101
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
97
102
|
description?: string;
|
|
98
103
|
required?: boolean;
|
|
99
104
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -102,24 +107,26 @@ export declare const Flags: {
|
|
|
102
107
|
alias?: string | readonly string[];
|
|
103
108
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
104
109
|
exists?: boolean;
|
|
105
|
-
},
|
|
110
|
+
}, Ctx>) => {
|
|
106
111
|
shouldStop: boolean;
|
|
107
112
|
} | void) | undefined;
|
|
108
113
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
109
114
|
exists?: boolean;
|
|
110
115
|
}, any>> & O;
|
|
111
|
-
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
116
|
+
directory: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
117
|
+
exists?: boolean;
|
|
118
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
112
119
|
exists?: boolean;
|
|
113
|
-
},
|
|
120
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
114
121
|
exists?: boolean | undefined;
|
|
115
122
|
} & {
|
|
116
123
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
117
124
|
exists?: boolean;
|
|
118
|
-
},
|
|
125
|
+
}, Ctx>) => string;
|
|
119
126
|
type?: import('../index.js').FlagKind;
|
|
120
127
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
121
128
|
exists?: boolean;
|
|
122
|
-
},
|
|
129
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
123
130
|
description?: string;
|
|
124
131
|
required?: boolean;
|
|
125
132
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -128,25 +135,25 @@ export declare const Flags: {
|
|
|
128
135
|
alias?: string | readonly string[];
|
|
129
136
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
130
137
|
exists?: boolean;
|
|
131
|
-
},
|
|
138
|
+
}, Ctx>) => {
|
|
132
139
|
shouldStop: boolean;
|
|
133
140
|
} | void) | undefined;
|
|
134
141
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
135
142
|
exists?: boolean;
|
|
136
143
|
}, any>> & O;
|
|
137
|
-
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
144
|
+
url: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
138
145
|
[x: string]: unknown;
|
|
139
146
|
} & {
|
|
140
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
147
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
141
148
|
type?: import('../index.js').FlagKind;
|
|
142
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
149
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
143
150
|
description?: string;
|
|
144
151
|
required?: boolean;
|
|
145
152
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
146
153
|
multiple?: boolean;
|
|
147
154
|
help?: string;
|
|
148
155
|
alias?: string | readonly string[];
|
|
149
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
156
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
150
157
|
shouldStop: boolean;
|
|
151
158
|
} | void) | undefined;
|
|
152
159
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/** Numeric flag. Optional `min`/`max` clamp the accepted range and surface as `BadCommandFlag`. */
|
|
2
|
-
export declare const numberFlag: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
2
|
+
export declare const numberFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
3
3
|
min?: number;
|
|
4
4
|
max?: number;
|
|
5
|
-
},
|
|
5
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
6
9
|
min?: number | undefined;
|
|
7
10
|
max?: number | undefined;
|
|
8
11
|
} & {
|
|
9
12
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
10
13
|
min?: number;
|
|
11
14
|
max?: number;
|
|
12
|
-
},
|
|
15
|
+
}, Ctx>) => number;
|
|
13
16
|
type?: import('../index.js').FlagKind;
|
|
14
17
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
15
18
|
min?: number;
|
|
16
19
|
max?: number;
|
|
17
|
-
},
|
|
20
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
18
21
|
description?: string;
|
|
19
22
|
required?: boolean;
|
|
20
23
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -24,7 +27,7 @@ export declare const numberFlag: <const O extends Partial<import('../index.js').
|
|
|
24
27
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
25
28
|
min?: number;
|
|
26
29
|
max?: number;
|
|
27
|
-
},
|
|
30
|
+
}, Ctx>) => {
|
|
28
31
|
shouldStop: boolean;
|
|
29
32
|
} | void) | undefined;
|
|
30
33
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** Text input flag. Pass `secret: true` to mask the prompt as a password. */
|
|
2
|
-
export declare const stringFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
2
|
+
export declare const stringFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
14
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
package/dist/cjs/flags/url.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** URL flag — parses the input with `new URL()` and returns the resulting `URL` object. */
|
|
2
|
-
export declare const urlFlag: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
2
|
+
export declare const urlFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
14
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`chalk`);l=c(l,1);let u=require(`node:fs`);u=c(u,1);let d=require(`node:path`);d=c(d,1);let f=require(`minimist`);f=c(f,1);let p=require(`@inquirer/prompts`),ee=require(`inquirer-file-selector`);var m=class{level;constructor(e={}){this.level=e.level??`info`}shouldLog(e){let t=[`debug`,`info`,`warn`,`error`],n=t.indexOf(this.level);return t.indexOf(e)>=n}setLevel(e){this.level=e}getLevel(){return this.level}log(...e){console.log(...e)}info(...e){this.shouldLog(`info`)&&console.log(...e)}warn(...e){this.shouldLog(`warn`)&&console.warn(...e)}error(...e){this.shouldLog(`error`)&&console.error(...e)}debug(...e){this.shouldLog(`debug`)&&console.log(...e)}},te=.1,ne=4,h=.5,g=class{calculateSimilarity(e,t){if(e===t)return 1;let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 1;if(n.length===0||r.length===0)return 0;let i=this.jaro(n,r);if(i===0)return 0;let a=0,o=Math.min(ne,n.length,r.length);for(;a<o&&n[a]===r[a];)a++;let s=i+a*te*(1-i),c=Math.min(n.length,r.length)/Math.max(n.length,r.length);return s*(c<h?c/h:1)}jaro(e,t){let n=Math.max(0,Math.floor(Math.max(e.length,t.length)/2)-1),r=Array(e.length).fill(!1),i=Array(t.length).fill(!1),a=0;for(let o=0;o<e.length;o++){let s=Math.max(0,o-n),c=Math.min(o+n+1,t.length);for(let n=s;n<c;n++)if(!i[n]&&e[o]===t[n]){r[o]=!0,i[n]=!0,a++;break}}if(a===0)return 0;let o=0,s=0;for(let n=0;n<e.length;n++)if(r[n]){for(;!i[s];)s++;e[n]!==t[s]&&o++,s++}return o/=2,(a/e.length+a/t.length+(a-o)/a)/3}findBestMatch(e,t){let n=t.map(t=>({target:t,rating:this.calculateSimilarity(e,t)})),r=0,i=n[0]?.rating??0;for(let e=1;e<n.length;e++)n[e].rating>i&&(i=n[e].rating,r=e);return{ratings:n,bestMatch:n[r],bestMatchIndex:r}}},_=class extends Error{};function v(e){return l.default.bold.yellow(`'${e}'`)}var re=/\x1b\[[0-9;]*m/g;function ie(e){return e.replace(re,``).length}function y(e,t){let{title:n,details:r,hint:i}=t,a=r&&r.length>0||i!=null,o=l.default.dim(`│`),s=l.default.dim(`└─`);if(e.log(``),e.log(` ${l.default.red(`error:`)} ${n}`),a){if(e.log(` ${o}`),r&&r.length>0){let t=r.map(([e])=>ie(e)),n=Math.max(...t);for(let i=0;i<r.length;i++){let[a,s]=r[i],c=` `.repeat(n-t[i]);e.log(` ${o} ${a}${c} ${s}`)}}i==null?e.log(` ${o}`):(e.log(` ${o}`),e.log(` ${s} try: ${i}`))}e.log(``)}var ae=class extends _{$type=`CommandNotFoundError`;constructor(e){super(`Command "${e}" not found.`),this.command=e}pretty(e){y(e,{title:`command ${v(this.command)} not found`})}};function b(e,t){let n=t.multiple===!0,r=t.required?`${l.default.yellow.bold(e)} is required`:`Enter ${l.default.yellow.bold(e)}`;return t.description&&(r+=`: ${l.default.gray(`(${t.description})`)}`),r+=` ${l.default.green(`(${t.type}${n?`[]`:``})`)}\n`,r}function x(e){return e==null?[]:typeof e==`string`?[e]:e}function S(e){return e.length===1?`-${e}`:`--${e}`}function C(e){return e.type===`option`&&`options`in e}var w=class extends _{$type=`InvalidFlag`;constructor(e,t={}){super(`Flag ${e} is not recognized`),this.flag=e,this.flagsSchema=t}pretty(e){let t=Object.entries(this.flagsSchema).map(([e,t])=>{let n=x(t.alias),r=`--${e}${n.length>0?n.map(e=>`, ${S(e)}`).join(``):``}`,i=C(t)?t.options.join(` | `):t.type,a=t.description??``,o=a?`${a} ${l.default.dim(`(${i})`)}`:l.default.dim(`(${i})`);return[l.default.cyan(r),o]});y(e,{title:`flag ${v(this.flag)} is not recognized`,details:t})}},T=class extends _{$type=`MissingRequiredArgumentValue`;constructor(e){super(`Argument "${e}" is required.`),this.argument=e}pretty(e){y(e,{title:`argument ${v(this.argument)} is required`})}},E=class extends _{$type=`MissingRequiredFlagValue`;constructor(e){super(`Flag "${e}" is required.`),this.flag=e}pretty(e){y(e,{title:`flag ${v(this.flag)} is required`})}},D=class extends Error{constructor(e){super(e)}},O=class extends _{$type=`BadCommandArgument`;constructor(e,t){let n=`Argument "${e.arg}" value is invalid.`;e.reason?n+=` Reason: ${e.reason}`:n+=` Value: "${e.value}"`,super(n),this.detail=e,this.argDefinition=t}pretty(e){let t=[];this.detail.value!=null&&t.push([l.default.dim(`value`),l.default.yellow(`"${this.detail.value}"`)]),this.detail.reason!=null&&t.push([l.default.dim(`reason`),this.detail.reason]),this.argDefinition?.help!=null&&t.push([l.default.dim(`help`),l.default.green(this.argDefinition.help)]),y(e,{title:`argument ${v(this.detail.arg)} is invalid`,details:t})}},k=class extends _{$type=`BadCommandFlag`;constructor(e,t){let n=`Flag "${e.flag}" value is invalid.`;e.reason?n+=` Reason: ${e.reason}`:n+=` Value: "${e.value}"`,super(n),this.param=e,this.flagDefinition=t}pretty(e){let t=[];this.param.value!=null&&t.push([l.default.dim(`value`),l.default.yellow(`"${this.param.value}"`)]),this.param.reason!=null&&t.push([l.default.dim(`reason`),this.param.reason]),this.flagDefinition?.help!=null&&t.push([l.default.dim(`help`),l.default.green(this.flagDefinition.help)]),y(e,{title:`flag ${v(this.param.flag)} is invalid`,details:t})}},oe=class extends _{$type=`TooManyArguments`;constructor(e,t){super(`Too many arguments provided. Expected ${e}, got ${t}.`),this.expected=e,this.received=t}pretty(e){y(e,{title:`too many arguments`,details:[[l.default.dim(`expected`),l.default.green(String(this.expected))],[l.default.dim(`received`),l.default.bold.yellow(String(this.received))]]})}},se=class{flags;parsedFlags=null;args;parsedArgs=null;ux;shouldPromptForMissingFlags=!0;shouldValidateUnknownFlags=!0;shouldRejectExtraArguments=!1;constructor(e){this.opts=e,this.ux=e.ux,this.flags=e.flags,this.args=e.args}async init(e){let{_:t,...n}=(0,f.default)(e);return this.shouldValidateUnknownFlags&&this.validateUnknownFlags(n),this.parsedFlags=await this.handleOptions(n),this.parsedArgs=await this.handleArguments(t),{flags:this.parsedFlags,args:this.parsedArgs}}async validate(){await this.validateSchema(this.flags,this.parsedFlags,`flag`),await this.validateSchema(this.args,this.parsedArgs,`arg`)}flag(e,t){if(!this.parsedFlags)throw Error(`Flags have not been parsed yet. Call init() first.`);return this.isEmptyValue(this.parsedFlags[e])&&t!==void 0?t:this.parsedFlags[e]}async setFlag(e,t){if(!this.parsedFlags)throw Error(`Flags have not been parsed yet. Call init() first.`);if(!(e in this.flags))throw new w(e,this.flags);this.parsedFlags[e]=t}argument(e,t){if(!this.parsedArgs)throw Error(`Arguments have not been parsed yet. Call init() first.`);return this.isEmptyValue(this.parsedArgs[e])&&t!==void 0?t:this.parsedArgs[e]}async setArgument(e,t){if(!this.parsedArgs)throw Error(`Arguments have not been parsed yet. Call init() first.`);if(!(e in this.args))throw new O({arg:e,reason:`Argument "${e}" is not recognized`});this.parsedArgs[e]=t}isEmptyValue(e){return e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0}isMissing(e){return e==null||Array.isArray(e)&&e.length===0}validateUnknownFlags(e){let t=new Set;for(let e in this.flags){t.add(e);let n=this.flags[e],r=Array.isArray(n.alias)?n.alias:n.alias?[n.alias]:[];for(let e of r)t.add(e)}for(let n in e)if(!t.has(n))throw new w(n,this.flags)}async handleOptions(e){let t={};for(let n in this.flags)t[n]=await this.resolveFlagValue(n,this.flags[n],e);return t}async handleArguments(e){let t={},n=[...e],r=Object.keys(this.args).length;for(let e in this.args){let r=this.args[e];if(r.multiple){t[e]=await this.parseValue(n,r,`arg`,{name:e}),n.length=0;continue}t[e]=await this.parseValue(n.shift(),r,`arg`,{name:e})}if(this.shouldRejectExtraArguments&&n.length>0)throw new oe(r,r+n.length);return t}async resolveFlagValue(e,t,n){let r,i=[e];t.alias&&i.push(...Array.isArray(t.alias)?t.alias:[t.alias]);for(let e of i)if(e in n){r=n[e];break}return this.parseValue(r,t,`flag`,{name:e})}async parseValue(e,t,n,r){if(this.isMissing(e))return typeof t.default==`function`?await t.default():t.default;if(t.multiple){Array.isArray(e)||(e=[e]);let i=[];for(let a of e)i.push(await this.safeParse(a,t,n,r));return i}return this.safeParse(e,t,n,r)}buildOpts(e,t){return{name:e,ux:this.ux,ctx:this.opts.ctx,definition:t,cmd:this.opts.cmd??Q}}async safeParse(e,t,n,r){try{return t.parse(e,this.buildOpts(r?.name??``,t))}catch(t){if(t instanceof k||t instanceof O||!(t instanceof D)||!r)throw t;let i=t.message;throw n===`flag`?new k({flag:r.name,value:e,reason:i}):new O({arg:r.name,value:e,reason:i})}}async validateSchema(e,t,n){for(let r in e){let i=e[r],a=t?.[r],o=this.isEmptyValue(a);if(i.required&&o){if(!this.shouldPromptForMissingFlags)throw n===`flag`?new E(r):new T(r);let e=await this.promptFor(r,i);if(e!=null&&t)a=await this.parseValue(e,i,n,{name:r}),t[r]=a;else throw n===`flag`?new E(r):new T(r)}}}disablePrompting(){return this.shouldPromptForMissingFlags=!1,this}allowUnknownFlags(){return this.shouldValidateUnknownFlags=!1,this}strictMode(){return this.shouldRejectExtraArguments=!0,this}async promptFor(e,t){return t.ask?t.ask(this.buildOpts(e,t)):null}};function A(e={}){return function(t){return{type:`custom`,default:e.multiple||t?.multiple?[]:null,parse:e=>e,...e,...t}}}function ce(e){if(typeof e==`boolean`)throw new D(`Expected a string, got boolean "${e}"`);return String(e)}function le(e,t){let n=typeof e==`number`?e:Number(e);if(isNaN(n))throw new D(`must be a valid number`);if(t?.min!==void 0&&n<t.min)throw new D(`is below minimum ${t.min}`);if(t?.max!==void 0&&n>t.max)throw new D(`exceeds maximum ${t.max}`);return n}function ue(e){if(typeof e==`boolean`)return e;let t=String(e).toLowerCase();if(t===`true`||t===`1`)return!0;if(t===`false`||t===`0`)return!1;throw new D(`Invalid boolean value: "${e}". Expected true, false, 1, or 0.`)}function de(e,t){let n=String(e);if(!t.includes(n))throw new D(`must be one of: ${t.map(e=>`"${e}"`).join(`, `)}`);return n}function fe(e,t){let n=String(e);if(t?.exists)try{u.default.accessSync(n,u.default.constants.F_OK)}catch(e){let t=e.code;throw t===`ENOENT`?new D(`file does not exist`):t===`EACCES`?new D(`file is not accessible (permission denied)`):new D(`file is not accessible (${t??e.message})`)}return n}function pe(e,t){let n=String(e);if(t?.exists){let e;try{e=u.default.lstatSync(n)}catch(e){let t=e.code;throw t===`ENOENT`?new D(`directory does not exist`):t===`EACCES`?new D(`directory is not accessible (permission denied)`):t===`ELOOP`?new D(`symlink loop detected`):new D(`directory is not accessible (${t??e.message})`)}if(!e.isDirectory())throw new D(`path is not a directory`)}return n}function me(e){try{return new URL(String(e))}catch(t){throw new D(`Invalid URL "${e}": ${t instanceof Error?t.message:String(t)}`)}}var he=A({default:!1,parse:e=>ue(e),ask:async e=>{let t=b(e.name,e.definition);return await e.ux.askForToggle(t)},type:`boolean`});function j(e,t){return n=>{if((n==null||typeof n==`string`&&n.trim()===``)&&e.required)return`This value is required`;try{e.parse(n,t)}catch(e){if(e instanceof D)return e.message;throw e}return!0}}function M(e,t){return n=>{if((n==null||n.trim()===``)&&e.required)return`Please enter at least one value`;for(let r of n.split(`,`)){let n=r.trim();if(n!==``)try{e.parse(n,t)}catch(e){if(e instanceof D)return`"${n}": ${e.message}`;throw e}}return!0}}async function ge(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);return n?await e.ux.askForList(r+`Please provide one or more values, separated by commas:
|
|
2
2
|
`,{separator:`,`,validate:M(t,e)}):t.secret?e.ux.askForPassword(r,{validate:j(t,e)}):await e.ux.askForInput(r,{validate:j(t,e)})}async function _e(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);return n?await e.ux.askForList(r+`Please provide one or more values, separated by commas:
|
|
3
3
|
`,{separator:`,`,validate:M(t,e)}):await e.ux.askForNumber(r,{validate:n=>{if(n===void 0&&t.required)return`This value is required`;if(n!==void 0)try{t.parse(String(n),e)}catch(e){if(e instanceof D)return e.message;throw e}return!0}})}async function ve(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);if(!C(t))return null;let i=t.options.map(e=>({name:e,value:e}));return n?await e.ux.askForCheckbox(r,i):await e.ux.askForSelect(r,i)}async function ye(e){let t=b(e.name,e.definition);return e.ux.askForFile(t,{basePath:process.cwd()})}async function be(e){let t=b(e.name,e.definition);return e.ux.askForDirectory(t,{basePath:process.cwd()})}async function xe(e){let t=b(e.name,e.definition);return await e.ux.askForInput(t,{validate:j(e.definition,e)})}var N=A({parse:(e,t)=>pe(e,{exists:t.definition.exists}),ask:be,type:`directory`}),P=A({parse:(e,t)=>fe(e,{exists:t.definition.exists}),ask:ye,type:`file`}),F=A({parse:(e,t)=>le(e,{min:t.definition.min,max:t.definition.max}),ask:_e,type:`number`});function I(e){let{options:t,...n}=e;return A({type:`option`,ask:ve,parse:e=>de(e,t??[]),...e})(n)}var L=A({parse:e=>ce(e),ask:ge,type:`string`}),R=A({parse:e=>me(e),ask:xe,type:`url`}),z={string:L,number:F,option:I,file:P,directory:N,url:R,custom:A},B={string:L,number:F,boolean:he,option:I,file:P,directory:N,url:R,custom:A};function V(e){return Array(e+5).join(` `)}function Se(e){let t=e.type;return C(e)?`enum: ${e.options.join(`|`)}`:t??`custom`}var Ce=B.boolean({alias:[`h`],description:`Displays help information about the command`,handler:(e,t)=>{if(!e)return{shouldStop:!1};let n=t.cmd,r=n.args,i={...n.baseFlags,...n.flags},a=Object.entries(r),o=Object.entries(i),s=o.map(([e,t])=>{let n=x(t.alias);return{name:e,...t,flagWithAlias:`--${e}${n.map(e=>`, ${S(e)}`).join(``)}`}}),c=a.filter(([,e])=>e.required);console.log(l.default.yellow(`Description:`)),console.log(` ${n.description}\n`),n.aliases.length>0&&(console.log(l.default.yellow(`Aliases:`)),console.log(` ${n.aliases.join(`, `)}\n`)),console.log(l.default.yellow(`Usage:`)),console.log(` ${n.command} ${c.length>0?c.map(([e])=>`<${e}>`).join(` `):`\b`} [options]`);let u=Math.max(...s.map(e=>e.flagWithAlias.length),0),d=Math.max(...a.map(([e])=>e.length),0),f=d>u?d:u;if(a.length>0){console.log(`\n${l.default.yellow(`Arguments`)}:`);for(let[e,t]of a){let n=V(f-e.length),r=` ${l.default.green(e)} ${n} ${t.description??`\b`}`;if(t.default!==void 0&&!t.required){let e=typeof t.default==`function`?`[function]`:t.multiple?JSON.stringify(t.default):t.default;r+=` ${l.default.yellow(`[default: ${e}]`)}`}t.multiple&&(r+=` ${l.default.white(`(multiple)`)}`),console.log(r)}}if(o.length>0){console.log(`\n${l.default.yellow(`Options`)}:`);for(let e of s){let t=V(f-e.flagWithAlias.length),n=` ${l.default.green(e.flagWithAlias)} ${t} ${e.description??`\b`}`;if(e.type&&(n+=` ${l.default.white(`(${Se(e)})`)}`),e.default!==void 0&&!e.required){let t=typeof e.default==`function`?`(function)`:e.default;n+=` ${l.default.yellow(`[default: ${t}]`)}`}console.log(n)}}let p=n.examples??[];if(p.length>0){console.log(`\n${l.default.yellow(`Examples`)}:`);let e=process.argv[0].split(`/`).pop();e===`node`&&(e+=` `+process.argv[1].split(`/`).pop());for(let[t,n]of p.entries())t>0&&console.log(``),console.log(` ${n.description}\n`),console.log(` ${l.default.green(`${e} ${n.command}`)}`)}return{shouldStop:!0}}}),we=class extends Error{name=`ExitPromptError`},Te=o(((e,t)=>{t.exports={}}));async function H(e,t){try{return await e()}catch(e){if(e instanceof we||e instanceof Error&&e.name===`ExitPromptError`)return t;throw e}}async function U(e,t,n){if(t.length===0)throw Error(`No options provided`);let r=t.map(e=>typeof e==`string`?{name:e,value:e}:{name:e.name,value:e.value,disabled:e.disabled,checked:e.checked,description:e.description});return H(()=>(0,p.checkbox)({message:e,choices:r,required:n?.required,pageSize:n?.pageSize,loop:n?.loop,validate:n?.validate,shortcuts:n?.shortcuts}),null)}async function W(e=`Do you want to continue?`,t){return H(()=>(0,p.confirm)({message:e,default:t?.default??!1,transformer:t?.transformer}),null)}async function G(e,t){return H(()=>(0,p.editor)({message:e,default:t?.default,postfix:t?.postfix,waitForUserInput:t?.waitForUserInput,validate:t?.validate}),null)}async function K(e,t,n){return H(()=>(0,p.expand)({message:e,choices:t,default:n?.default}),null)}async function q(e,t){return H(async()=>{let n=await(0,ee.fileSelector)({message:e,basePath:t?.basePath,type:t?.type===`file+directory`?void 0:t?.type,filter:t?.filter,allowCancel:!0,pageSize:t?.pageSize,loop:t?.loop});return n===null?null:n.path},null)}async function J(e,t){return H(()=>(0,p.input)({message:e,default:t?.default,required:t?.required,validate:t?.validate,transformer:t?.transformer}),null)}async function Y(e,t){let n=t?.separator??`,`;return H(async()=>(await(0,p.input)({message:e,default:t?.default,validate:t?.validate})).split(n).map(e=>e.trim()).filter(e=>e.length>0),null)}async function X(e,t){return H(async()=>await(0,p.number)({message:e,default:t?.default,required:t?.required,min:t?.min,max:t?.max,step:t?.step,validate:t?.validate})??null,null)}async function Ee(e,t){return H(()=>(0,p.password)({message:e,mask:t?.mask,validate:t?.validate}),null)}async function De(e,t,n){return H(()=>(0,p.rawlist)({message:e,choices:t,loop:n?.loop}),null)}async function Oe(e,t,n){return H(()=>(0,p.search)({message:e,source:t,pageSize:n?.pageSize,validate:n?.validate}),null)}async function ke(e,t,n){if(t.length===0)throw Error(`No options provided`);let r=t.map(e=>typeof e==`string`?{name:e,value:e}:e);return H(()=>(0,p.select)({message:e,choices:r,default:n?.default,pageSize:n?.pageSize,loop:n?.loop}),null)}async function Ae(e,t){let n=t?.active??`Yes`,r=t?.inactive??`No`;return H(()=>(0,p.confirm)({message:e,default:t?.default??!1,transformer:e=>e?n:r}),null)}function je(e,t){let n=t?.separator??`: `,r=t?.keyStyle??l.default.bold,i=Array.isArray(e)?e:Object.entries(e);if(i.length===0)return;let a=Math.max(...i.map(([e])=>e.length));for(let[e,t]of i)console.log(r(e.padEnd(a))+n+String(t??``))}function Me(e=``,t=[`⠙`,`⠘`,`⠰`,`⠴`,`⠤`,`⠦`,`⠆`,`⠃`,`⠋`,`⠉`],n=100){let r=e,i=null,a=e.length,o=0,s=e=>{let t=process.stdout.columns||80,n=e+2,r=Math.max(1,Math.ceil(n/t));if(process.stdout.isTTY&&process.stdout.clearLine&&process.stdout.moveCursor&&process.stdout.cursorTo){r>1&&process.stdout.moveCursor(0,-(r-1));for(let e=0;e<r;e++)process.stdout.cursorTo(0),process.stdout.clearLine(1),e<r-1&&process.stdout.moveCursor(0,1);r>1&&process.stdout.moveCursor(0,-(r-1)),process.stdout.cursorTo(0)}else process.stdout.write(`\r`+` `.repeat(e+5)+`\r`)},c=setInterval(function(){i!==null&&(s(Math.max(i.length,r.length)),i=null),process.stdout.write(`\r`+t[o++]+` `+r),o%=t.length},n),l=()=>{clearInterval(c),s(a)};return{[Symbol.dispose]:l,[Symbol.asyncDispose]:l,updateText:e=>{i=r,r=e,a=Math.max(a,e.length)},stop:l}}function Ne(e,t){let n=t?.width??30,r=t?.completeChar??`█`,i=t?.incompleteChar??`░`,a=0,o=!1,s=()=>{if(o)return;let t=e<=0?1:Math.min(a/e,1),s=Math.round(t*n),l=`${r.repeat(s)+i.repeat(n-s)} ${Math.round(t*100)}% ${a}/${e}`;process.stdout.write(`\r`+l),(e<=0||a>=e)&&c()},c=()=>{o||(o=!0,process.stdout.write(`
|
|
4
|
-
`))};return s(),{increment:(t=1)=>{o||(a=Math.min(a+t,e),s())},update:t=>{o||(a=Math.max(0,Math.min(t,e)),s())},stop:c,[Symbol.dispose]:c,[Symbol.asyncDispose]:c}}function Pe(e,t){if(e.length===0)return;let n=t??Object.keys(e[0]).map(e=>({key:e})),r=n.map(e=>e.header??e.key.toUpperCase()),i=n.map((t,n)=>{let i=Math.max(r[n].length,...e.map(e=>(t.format?t.format(e[t.key]):String(e[t.key]??``)).length));return t.width?Math.min(i,t.width):i}),a=(e,t,n=`left`)=>{if(e.length>t)return e.slice(0,t-1)+`…`;switch(n){case`right`:return e.padStart(t);case`center`:{let n=Math.floor((t-e.length)/2);return` `.repeat(n)+e+` `.repeat(t-e.length-n)}default:return e.padEnd(t)}},o=n.map((e,t)=>a(r[t],i[t],e.alignment)).join(` `);console.log(l.default.bold(o));let s=i.map(e=>`-`.repeat(e)).join(` `);console.log(l.default.dim(s));for(let t of e){let e=n.map((e,n)=>a(e.format?e.format(t[e.key]):String(t[e.key]??``),i[n],e.alignment)).join(` `);console.log(e)}}var Z=class{askForConfirmation(e,t){return W(e,t)}askForInput(e,t){return J(e,t)}askForPassword(e,t){return Ee(e,t)}askForNumber(e,t){return X(e,t)}askForSelect(e,t,n){return ke(e,t,n)}askForCheckbox(e,t,n){return U(e,t,n)}askForSearch(e,t,n){return Oe(e,t,n)}askForList(e,t){return Y(e,t)}askForToggle(e,t){return Ae(e,t)}askForEditor(e,t){return G(e,t)}askForRawList(e,t,n){return De(e,t,n)}askForExpand(e,t,n){return K(e,t,n)}askForFile(e,t){return q(e,{...t,type:`file`})}askForDirectory(e,t){return q(e,{...t,type:`directory`})}askForFileSelector(e,t){return q(e,t)}keyValue(e,t){return je(e,t)}table(e,t){return Pe(e,t)}newProgressBar(e,t){return Ne(e,t)}newLoader(e,t,n){return Me(e,t,n)}},Q=class{static $type=`BobCommand`;static command=``;static description=``;static group;static args={};static flags={};static examples=[];static hidden=!1;static aliases=[];static disableDefaultOptions=!1;static disablePrompting=!1;static allowUnknownFlags=!1;static strictMode=!1;ctx;logger;ux;parser;static baseFlags={help:Ce};newCommandParser(e){return new se({ux:e.ux,ctx:e.ctx,flags:e.flags,args:e.args,cmd:e.cmd})}newUX(){return new Z}async run(e){let t=this.constructor;this.ctx=e.ctx,this.logger=e.logger,this.ux=this.newUX();let n;if(`flags`in e)n={flags:e.flags,args:e.args};else{this.parser=this.newCommandParser({ctx:this.ctx,ux:this.ux,flags:t.disableDefaultOptions?t.flags:{...t.baseFlags,...t.flags},args:t.args,cmd:t}),t.allowUnknownFlags&&this.parser.allowUnknownFlags(),t.strictMode&&this.parser.strictMode(),t.disablePrompting&&this.parser.disablePrompting();let r=await this.parser.init(e.args);for(let n in r.flags){let i=r.flags[n],a=t.flags[n]||t.baseFlags[n];if(a&&a.handler){let r={name:n,ux:this.ux,ctx:e.ctx,definition:a,cmd:t},o=a.handler(i,r);if(o&&o.shouldStop)return 0}}await this.parser.validate(),n={flags:r.flags,args:r.args}}if(this.preHandle){let e=await this.preHandle();if(e&&e!==0)return e}return await this.handle(this.ctx,n)??0}};function Fe(e){return e instanceof _}function $(e){return typeof e==`function`?e.prototype instanceof Q||e.$type===`BobCommand`:!1}var Ie=.75,Le=.55,Re=.05,ze=class{commands={};aliases={};ux;logger;stringSimilarity;constructor(e){this.logger=e?.logger??new m,this.ux=e?.ux??new Z,this.stringSimilarity=e?.stringSimilarity??new g}getAvailableCommands(){return[...Object.keys(this.commands),...Object.keys(this.aliases)]}getCommands(){return Object.values(this.commands)}importFile=async e=>(await import(e)).default;commandResolver=async e=>{let t=await this.importFile(e);return t?(t&&typeof t==`object`&&`default`in t&&(t=t.default),typeof t==`function`&&$(t)?t:null):null};withCommandResolver(e){return this.commandResolver=e,this}withFileImporter(e){return this.importFile=e,this}registerCommand(e,t=!1){if(!$(e))throw Error(`Invalid command, it must extend the Command class.`);let n=e.command;if(!n)throw Error(`Cannot register a command with no name. ${e.name} `);if(!t&&this.commands[n])throw Error(`Command ${n} already registered.`);if(!t&&this.aliases[n])throw Error(`Command name ${n} conflicts with an existing alias.`);this.commands[n]=e;for(let r of e.aliases){if(!t&&this.commands[r])throw Error(`Alias ${r} conflicts with an existing command name.`);if(!t&&this.aliases[r])throw Error(`Alias ${r} already registered.`);this.aliases[r]=n}}async loadCommandsPath(e){for await(let t of this.listCommandsFiles(e))try{let e=await this.commandResolver(t);$(e)&&this.registerCommand(e)}catch(e){throw Error(`Command ${t} failed to load. ${e}`,{cause:e})}}async runCommand(e,t,...n){let r;if(typeof t==`string`){let i=this.commands[t]??this.commands[this.aliases[t]];if(!i){let r=await this.suggestCommand(t);if(r)return await this.runCommand(e,r,...n);throw new ae(t)}r=new i}else r=$(t)?new t:t;return await r.run({ctx:e,logger:this.logger,args:n})??0}async suggestCommand(e){let t=this.getAvailableCommands();if(t.length===0)return null;let{bestMatch:n,bestMatchIndex:r,ratings:i}=this.stringSimilarity.findBestMatch(e,t),a=[...i].sort((e,t)=>t.rating-e.rating),o=a[1]?.rating??0,s=a.filter(e=>e.rating>=Le).map(e=>e.target);if(n&&n.rating>=Ie&&n.rating-o>Re){let n=t[r],i=await this.askRunSimilarCommand(e,n);return i===!0?n:(i===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length===1){let t=s[0],n=await this.askRunSimilarCommand(e,t);return n===!0?t:(n===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length>1){let t=await this.ux.askForSelect(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean one of these?`,s);return t||(t===null&&this.logger.debug(`suggestion selection cancelled for "${e}"`),null)}return null}async askRunSimilarCommand(e,t){return this.ux.askForConfirmation(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean ${l.default.bold.green(`'${t}'`)}?`)}async*listCommandsFiles(e){let t;try{t=await u.default.promises.readdir(e,{withFileTypes:!0})}catch(t){throw Error(`Failed to read commands directory "${e}": ${t.message}`,{cause:t})}for(let n of t){let t=d.default.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(d.default.resolve(e,n.name));else{if(!t.endsWith(`.ts`)&&!t.endsWith(`.js`)&&!t.endsWith(`.mjs`)&&!t.endsWith(`.cjs`))continue;yield t}}}},Be=class{logger;constructor(e){this.logger=e}handle(e){if(Fe(e))return e.pretty(this.logger),-1;throw e}},Ve=c(Te(),1);function He(){try{let e=(0,u.readFileSync)((0,Ve.fileURLToPath)(new URL(`data:application/json;base64,
|
|
4
|
+
`))};return s(),{increment:(t=1)=>{o||(a=Math.min(a+t,e),s())},update:t=>{o||(a=Math.max(0,Math.min(t,e)),s())},stop:c,[Symbol.dispose]:c,[Symbol.asyncDispose]:c}}function Pe(e,t){if(e.length===0)return;let n=t??Object.keys(e[0]).map(e=>({key:e})),r=n.map(e=>e.header??e.key.toUpperCase()),i=n.map((t,n)=>{let i=Math.max(r[n].length,...e.map(e=>(t.format?t.format(e[t.key]):String(e[t.key]??``)).length));return t.width?Math.min(i,t.width):i}),a=(e,t,n=`left`)=>{if(e.length>t)return e.slice(0,t-1)+`…`;switch(n){case`right`:return e.padStart(t);case`center`:{let n=Math.floor((t-e.length)/2);return` `.repeat(n)+e+` `.repeat(t-e.length-n)}default:return e.padEnd(t)}},o=n.map((e,t)=>a(r[t],i[t],e.alignment)).join(` `);console.log(l.default.bold(o));let s=i.map(e=>`-`.repeat(e)).join(` `);console.log(l.default.dim(s));for(let t of e){let e=n.map((e,n)=>a(e.format?e.format(t[e.key]):String(t[e.key]??``),i[n],e.alignment)).join(` `);console.log(e)}}var Z=class{askForConfirmation(e,t){return W(e,t)}askForInput(e,t){return J(e,t)}askForPassword(e,t){return Ee(e,t)}askForNumber(e,t){return X(e,t)}askForSelect(e,t,n){return ke(e,t,n)}askForCheckbox(e,t,n){return U(e,t,n)}askForSearch(e,t,n){return Oe(e,t,n)}askForList(e,t){return Y(e,t)}askForToggle(e,t){return Ae(e,t)}askForEditor(e,t){return G(e,t)}askForRawList(e,t,n){return De(e,t,n)}askForExpand(e,t,n){return K(e,t,n)}askForFile(e,t){return q(e,{...t,type:`file`})}askForDirectory(e,t){return q(e,{...t,type:`directory`})}askForFileSelector(e,t){return q(e,t)}keyValue(e,t){return je(e,t)}table(e,t){return Pe(e,t)}newProgressBar(e,t){return Ne(e,t)}newLoader(e,t,n){return Me(e,t,n)}},Q=class{static $type=`BobCommand`;static command=``;static description=``;static group;static args={};static flags={};static examples=[];static hidden=!1;static aliases=[];static disableDefaultOptions=!1;static disablePrompting=!1;static allowUnknownFlags=!1;static strictMode=!1;ctx;logger;ux;parser;static baseFlags={help:Ce};newCommandParser(e){return new se({ux:e.ux,ctx:e.ctx,flags:e.flags,args:e.args,cmd:e.cmd})}newUX(){return new Z}async run(e){let t=this.constructor;this.ctx=e.ctx,this.logger=e.logger,this.ux=this.newUX();let n;if(`flags`in e)n={flags:e.flags,args:e.args};else{this.parser=this.newCommandParser({ctx:this.ctx,ux:this.ux,flags:t.disableDefaultOptions?t.flags:{...t.baseFlags,...t.flags},args:t.args,cmd:t}),t.allowUnknownFlags&&this.parser.allowUnknownFlags(),t.strictMode&&this.parser.strictMode(),t.disablePrompting&&this.parser.disablePrompting();let r=await this.parser.init(e.args);for(let n in r.flags){let i=r.flags[n],a=t.flags[n]||t.baseFlags[n];if(a&&a.handler){let r={name:n,ux:this.ux,ctx:e.ctx,definition:a,cmd:t},o=a.handler(i,r);if(o&&o.shouldStop)return 0}}await this.parser.validate(),n={flags:r.flags,args:r.args}}if(this.preHandle){let e=await this.preHandle();if(e&&e!==0)return e}return await this.handle(this.ctx,n)??0}};function Fe(e){return e instanceof _}function $(e){return typeof e==`function`?e.prototype instanceof Q||e.$type===`BobCommand`:!1}var Ie=.75,Le=.55,Re=.05,ze=class{commands={};aliases={};ux;logger;stringSimilarity;constructor(e){this.logger=e?.logger??new m,this.ux=e?.ux??new Z,this.stringSimilarity=e?.stringSimilarity??new g}getAvailableCommands(){return[...Object.keys(this.commands),...Object.keys(this.aliases)]}getCommands(){return Object.values(this.commands)}importFile=async e=>(await import(e)).default;commandResolver=async e=>{let t=await this.importFile(e);return t?(t&&typeof t==`object`&&`default`in t&&(t=t.default),typeof t==`function`&&$(t)?t:null):null};withCommandResolver(e){return this.commandResolver=e,this}withFileImporter(e){return this.importFile=e,this}registerCommand(e,t=!1){if(!$(e))throw Error(`Invalid command, it must extend the Command class.`);let n=e.command;if(!n)throw Error(`Cannot register a command with no name. ${e.name} `);if(!t&&this.commands[n])throw Error(`Command ${n} already registered.`);if(!t&&this.aliases[n])throw Error(`Command name ${n} conflicts with an existing alias.`);this.commands[n]=e;for(let r of e.aliases){if(!t&&this.commands[r])throw Error(`Alias ${r} conflicts with an existing command name.`);if(!t&&this.aliases[r])throw Error(`Alias ${r} already registered.`);this.aliases[r]=n}}async loadCommandsPath(e){for await(let t of this.listCommandsFiles(e))try{let e=await this.commandResolver(t);$(e)&&this.registerCommand(e)}catch(e){throw Error(`Command ${t} failed to load. ${e}`,{cause:e})}}async runCommand(e,t,...n){let r;if(typeof t==`string`){let i=this.commands[t]??this.commands[this.aliases[t]];if(!i){let r=await this.suggestCommand(t);if(r)return await this.runCommand(e,r,...n);throw new ae(t)}r=new i}else r=$(t)?new t:t;return await r.run({ctx:e,logger:this.logger,args:n})??0}async suggestCommand(e){let t=this.getAvailableCommands();if(t.length===0)return null;let{bestMatch:n,bestMatchIndex:r,ratings:i}=this.stringSimilarity.findBestMatch(e,t),a=[...i].sort((e,t)=>t.rating-e.rating),o=a[1]?.rating??0,s=a.filter(e=>e.rating>=Le).map(e=>e.target);if(n&&n.rating>=Ie&&n.rating-o>Re){let n=t[r],i=await this.askRunSimilarCommand(e,n);return i===!0?n:(i===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length===1){let t=s[0],n=await this.askRunSimilarCommand(e,t);return n===!0?t:(n===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length>1){let t=await this.ux.askForSelect(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean one of these?`,s);return t||(t===null&&this.logger.debug(`suggestion selection cancelled for "${e}"`),null)}return null}async askRunSimilarCommand(e,t){return this.ux.askForConfirmation(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean ${l.default.bold.green(`'${t}'`)}?`)}async*listCommandsFiles(e){let t;try{t=await u.default.promises.readdir(e,{withFileTypes:!0})}catch(t){throw Error(`Failed to read commands directory "${e}": ${t.message}`,{cause:t})}for(let n of t){let t=d.default.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(d.default.resolve(e,n.name));else{if(!t.endsWith(`.ts`)&&!t.endsWith(`.js`)&&!t.endsWith(`.mjs`)&&!t.endsWith(`.cjs`))continue;yield t}}}},Be=class{logger;constructor(e){this.logger=e}handle(e){if(Fe(e))return e.pretty(this.logger),-1;throw e}},Ve=c(Te(),1);function He(){try{let e=(0,u.readFileSync)((0,Ve.fileURLToPath)(new URL(`data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMC1iZXRhLjExIiwKICAiZGVzY3JpcHRpb24iOiAiQk9CIENvcmUiLAogICJ0eXBlIjogIm1vZHVsZSIsCiAgIm1haW4iOiAiLi9kaXN0L2Nqcy9pbmRleC5qcyIsCiAgIm1vZHVsZSI6ICIuL2Rpc3QvZXNtL2luZGV4LmpzIiwKICAidHlwZXMiOiAiLi9kaXN0L2VzbS9pbmRleC5kLnRzIiwKICAiZmlsZXMiOiBbCiAgICAiZGlzdCIKICBdLAogICJleHBvcnRzIjogewogICAgIi4iOiB7CiAgICAgICJpbXBvcnQiOiB7CiAgICAgICAgInR5cGVzIjogIi4vZGlzdC9lc20vaW5kZXguZC50cyIsCiAgICAgICAgImRlZmF1bHQiOiAiLi9kaXN0L2VzbS9pbmRleC5qcyIKICAgICAgfSwKICAgICAgInJlcXVpcmUiOiB7CiAgICAgICAgInR5cGVzIjogIi4vZGlzdC9janMvaW5kZXguZC50cyIsCiAgICAgICAgImRlZmF1bHQiOiAiLi9kaXN0L2Nqcy9pbmRleC5qcyIKICAgICAgfQogICAgfQogIH0sCiAgInNjcmlwdHMiOiB7CiAgICAic3RhcnQiOiAibm9kZSAtciBAc3djLW5vZGUvcmVnaXN0ZXIgZGVidWcvbWFpbi50cyIsCiAgICAiYnVpbGQiOiAicm0gLXJmIC4vZGlzdCAmJiB2aXRlIGJ1aWxkIiwKICAgICJ0eXBlY2hlY2siOiAidHNjIC0tbm9FbWl0IiwKICAgICJwcmVwYWNrIjogIm5wbSBydW4gYnVpbGQiLAogICAgInRlc3QiOiAidml0ZXN0IHJ1biIsCiAgICAibGludCI6ICJlc2xpbnQgLiIsCiAgICAibGludDpmaXgiOiAiZXNsaW50IC4gLS1maXgiCiAgfSwKICAiYXV0aG9yIjogIkzDqW8gSHViZXJ0IiwKICAibGljZW5zZSI6ICJJU0MiLAogICJkZXZEZXBlbmRlbmNpZXMiOiB7CiAgICAiQGVzbGludC9qcyI6ICJeOS4zOS40IiwKICAgICJAZmFrZXItanMvZmFrZXIiOiAiXjEwLjMuMCIsCiAgICAiQHN3Yy1ub2RlL3JlZ2lzdGVyIjogIl4xLjExLjEiLAogICAgIkB0cml2YWdvL3ByZXR0aWVyLXBsdWdpbi1zb3J0LWltcG9ydHMiOiAiXjUuMi4yIiwKICAgICJAdHlwZXMvbWluaW1pc3QiOiAiXjEuMi41IiwKICAgICJAdHlwZXMvbm9kZSI6ICJeMjAuMTQuNSIsCiAgICAiQHR5cGVzL3N0cmluZy1zaW1pbGFyaXR5IjogIl40LjAuMiIsCiAgICAiQHZpdGVzdC9jb3ZlcmFnZS12OCI6ICJeNC4xLjAiLAogICAgImVzbGludCI6ICJeOS4zOS40IiwKICAgICJlc2xpbnQtY29uZmlnLXByZXR0aWVyIjogIl4xMC4xLjgiLAogICAgImVzbGludC1wbHVnaW4tcHJldHRpZXIiOiAiXjUuNS41IiwKICAgICJwcmV0dGllciI6ICJeMy42LjIiLAogICAgInRzeCI6ICJeNC4yMS4wIiwKICAgICJ0eXBlc2NyaXB0IjogIl41LjkuMyIsCiAgICAidHlwZXNjcmlwdC1lc2xpbnQiOiAiXjguNTcuMCIsCiAgICAidml0ZSI6ICJeOC4wLjAiLAogICAgInZpdGUtcGx1Z2luLWR0cyI6ICJeNC41LjQiLAogICAgInZpdGVzdCI6ICJeNC4xLjAiCiAgfSwKICAiZGVwZW5kZW5jaWVzIjogewogICAgIkBpbnF1aXJlci9jb3JlIjogIl4xMS4xLjgiLAogICAgIkBpbnF1aXJlci9wcm9tcHRzIjogIl44LjQuMSIsCiAgICAiY2hhbGsiOiAiXjUuNi4yIiwKICAgICJpbnF1aXJlci1maWxlLXNlbGVjdG9yIjogIl4xLjAuMSIsCiAgICAibWluaW1pc3QiOiAiXjEuMi44IgogIH0KfQo=`,``+{}.url)),`utf8`);return JSON.parse(e).version??`0.0.0`}catch{return`0.0.0`}}var Ue=class extends Q{static command=`help`;static description=l.default.bold(`Show help information about the CLI and its commands`);constructor(e){super(),this.opts=e}async handle(){let e=this.opts.commandRegistry.getCommands().filter(e=>!e.hidden),t=this.opts.cliName??`Bob CLI`,n=this.opts.cliVersion??`0.0.0`,r=He();this.logger.log(`${t} ${l.default.green(n)} (core: ${l.default.yellow(r)})
|
|
5
5
|
|
|
6
6
|
${l.default.yellow(`Usage`)}:
|
|
7
7
|
command [options] [arguments]
|
package/dist/esm/args/index.d.ts
CHANGED
|
@@ -7,38 +7,41 @@ import { optionFlag } from '../flags/option.js';
|
|
|
7
7
|
* positional inputs and the `ArgsSchema` type rejects them at compile time.
|
|
8
8
|
*/
|
|
9
9
|
export declare const Args: {
|
|
10
|
-
string: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
10
|
+
string: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
11
11
|
[x: string]: unknown;
|
|
12
12
|
} & {
|
|
13
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
13
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
14
14
|
type?: import('../index.js').FlagKind;
|
|
15
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
15
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
16
16
|
description?: string;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
19
19
|
multiple?: boolean;
|
|
20
20
|
help?: string;
|
|
21
21
|
alias?: string | readonly string[];
|
|
22
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
22
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
23
23
|
shouldStop: boolean;
|
|
24
24
|
} | void) | undefined;
|
|
25
25
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
|
26
|
-
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
26
|
+
number: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
27
27
|
min?: number;
|
|
28
28
|
max?: number;
|
|
29
|
-
},
|
|
29
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
30
33
|
min?: number | undefined;
|
|
31
34
|
max?: number | undefined;
|
|
32
35
|
} & {
|
|
33
36
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
34
37
|
min?: number;
|
|
35
38
|
max?: number;
|
|
36
|
-
},
|
|
39
|
+
}, Ctx>) => number;
|
|
37
40
|
type?: import('../index.js').FlagKind;
|
|
38
41
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
39
42
|
min?: number;
|
|
40
43
|
max?: number;
|
|
41
|
-
},
|
|
44
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
42
45
|
description?: string;
|
|
43
46
|
required?: boolean;
|
|
44
47
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -48,7 +51,7 @@ export declare const Args: {
|
|
|
48
51
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
49
52
|
min?: number;
|
|
50
53
|
max?: number;
|
|
51
|
-
},
|
|
54
|
+
}, Ctx>) => {
|
|
52
55
|
shouldStop: boolean;
|
|
53
56
|
} | void) | undefined;
|
|
54
57
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
@@ -56,18 +59,20 @@ export declare const Args: {
|
|
|
56
59
|
max?: number;
|
|
57
60
|
}, any>> & O;
|
|
58
61
|
option: typeof optionFlag;
|
|
59
|
-
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
62
|
+
file: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
60
63
|
exists?: boolean;
|
|
61
|
-
},
|
|
64
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
65
|
+
exists?: boolean;
|
|
66
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
62
67
|
exists?: boolean | undefined;
|
|
63
68
|
} & {
|
|
64
69
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
65
70
|
exists?: boolean;
|
|
66
|
-
},
|
|
71
|
+
}, Ctx>) => string;
|
|
67
72
|
type?: import('../index.js').FlagKind;
|
|
68
73
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
69
74
|
exists?: boolean;
|
|
70
|
-
},
|
|
75
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
71
76
|
description?: string;
|
|
72
77
|
required?: boolean;
|
|
73
78
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -76,24 +81,26 @@ export declare const Args: {
|
|
|
76
81
|
alias?: string | readonly string[];
|
|
77
82
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
78
83
|
exists?: boolean;
|
|
79
|
-
},
|
|
84
|
+
}, Ctx>) => {
|
|
80
85
|
shouldStop: boolean;
|
|
81
86
|
} | void) | undefined;
|
|
82
87
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
83
88
|
exists?: boolean;
|
|
84
89
|
}, any>> & O;
|
|
85
|
-
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
90
|
+
directory: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
91
|
+
exists?: boolean;
|
|
92
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
86
93
|
exists?: boolean;
|
|
87
|
-
},
|
|
94
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
88
95
|
exists?: boolean | undefined;
|
|
89
96
|
} & {
|
|
90
97
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
91
98
|
exists?: boolean;
|
|
92
|
-
},
|
|
99
|
+
}, Ctx>) => string;
|
|
93
100
|
type?: import('../index.js').FlagKind;
|
|
94
101
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
95
102
|
exists?: boolean;
|
|
96
|
-
},
|
|
103
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
97
104
|
description?: string;
|
|
98
105
|
required?: boolean;
|
|
99
106
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -102,25 +109,25 @@ export declare const Args: {
|
|
|
102
109
|
alias?: string | readonly string[];
|
|
103
110
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
104
111
|
exists?: boolean;
|
|
105
|
-
},
|
|
112
|
+
}, Ctx>) => {
|
|
106
113
|
shouldStop: boolean;
|
|
107
114
|
} | void) | undefined;
|
|
108
115
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
109
116
|
exists?: boolean;
|
|
110
117
|
}, any>> & O;
|
|
111
|
-
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
118
|
+
url: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
112
119
|
[x: string]: unknown;
|
|
113
120
|
} & {
|
|
114
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
121
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
115
122
|
type?: import('../index.js').FlagKind;
|
|
116
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
123
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
117
124
|
description?: string;
|
|
118
125
|
required?: boolean;
|
|
119
126
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
120
127
|
multiple?: boolean;
|
|
121
128
|
help?: string;
|
|
122
129
|
alias?: string | readonly string[];
|
|
123
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
130
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
124
131
|
shouldStop: boolean;
|
|
125
132
|
} | void) | undefined;
|
|
126
133
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { FlagOpts } from '../lib/types.js';
|
|
2
2
|
/** Boolean flag (`--debug` / `--no-debug`). Defaults to `false` when omitted. */
|
|
3
|
-
export declare const booleanFlag: <const O extends Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions,
|
|
3
|
+
export declare const booleanFlag: <Ctx extends unknown = any, const O extends Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, Ctx>> = Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
4
4
|
[x: string]: unknown;
|
|
5
5
|
} & {
|
|
6
|
-
parse: (input: any, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
6
|
+
parse: (input: any, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => boolean;
|
|
7
7
|
type?: import('../lib/types.js').FlagKind;
|
|
8
|
-
ask?: ((opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
8
|
+
ask?: ((opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
9
9
|
description?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
12
12
|
multiple?: boolean;
|
|
13
13
|
help?: string;
|
|
14
14
|
alias?: string | readonly string[];
|
|
15
|
-
handler?: ((value: boolean, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions,
|
|
15
|
+
handler?: ((value: boolean, opts: FlagOpts<boolean, import('../lib/types.js').CustomOptions, Ctx>) => {
|
|
16
16
|
shouldStop: boolean;
|
|
17
17
|
} | void) | undefined;
|
|
18
18
|
} & Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions, any>> & O;
|
|
@@ -9,4 +9,4 @@ import { ContextDefinition, CustomOptions, FlagDefinition, InitFlagDefinition }
|
|
|
9
9
|
* The `type` literal supplied in `defaults` is preserved in the returned shape
|
|
10
10
|
* so downstream consumers can rely on it (e.g. for help rendering).
|
|
11
11
|
*/
|
|
12
|
-
export declare function custom<T, C extends CustomOptions = CustomOptions, Ctx extends ContextDefinition = ContextDefinition, const D extends InitFlagDefinition<T, C, Ctx> = InitFlagDefinition<T, C, Ctx>>(defaults?: D): <const O extends InitFlagDefinition<T, C,
|
|
12
|
+
export declare function custom<T, C extends CustomOptions = CustomOptions, Ctx extends ContextDefinition = ContextDefinition, const D extends InitFlagDefinition<T, C, Ctx> = InitFlagDefinition<T, C, Ctx>>(defaults?: D): <Ctx_1 extends ContextDefinition = ContextDefinition, const O extends InitFlagDefinition<T, C, Ctx_1> = InitFlagDefinition<T, C, Ctx_1>>(overrides?: O) => FlagDefinition<T, C, Ctx_1> & D & O;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/** Filesystem directory flag. Pass `exists: true` to require the directory to exist at parse time. */
|
|
2
|
-
export declare const directoryFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
2
|
+
export declare const directoryFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
3
3
|
exists?: boolean;
|
|
4
|
-
},
|
|
4
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
5
7
|
exists?: boolean | undefined;
|
|
6
8
|
} & {
|
|
7
9
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
8
10
|
exists?: boolean;
|
|
9
|
-
},
|
|
11
|
+
}, Ctx>) => string;
|
|
10
12
|
type?: import('../index.js').FlagKind;
|
|
11
13
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
12
14
|
exists?: boolean;
|
|
13
|
-
},
|
|
15
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
14
16
|
description?: string;
|
|
15
17
|
required?: boolean;
|
|
16
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -19,7 +21,7 @@ export declare const directoryFlag: <const O extends Partial<import('../index.js
|
|
|
19
21
|
alias?: string | readonly string[];
|
|
20
22
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
21
23
|
exists?: boolean;
|
|
22
|
-
},
|
|
24
|
+
}, Ctx>) => {
|
|
23
25
|
shouldStop: boolean;
|
|
24
26
|
} | void) | undefined;
|
|
25
27
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
package/dist/esm/flags/file.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/** Filesystem file flag. Pass `exists: true` to require the path to exist at parse time. */
|
|
2
|
-
export declare const fileFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
2
|
+
export declare const fileFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
3
3
|
exists?: boolean;
|
|
4
|
-
},
|
|
4
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
5
7
|
exists?: boolean | undefined;
|
|
6
8
|
} & {
|
|
7
9
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
8
10
|
exists?: boolean;
|
|
9
|
-
},
|
|
11
|
+
}, Ctx>) => string;
|
|
10
12
|
type?: import('../index.js').FlagKind;
|
|
11
13
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
12
14
|
exists?: boolean;
|
|
13
|
-
},
|
|
15
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
14
16
|
description?: string;
|
|
15
17
|
required?: boolean;
|
|
16
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -19,7 +21,7 @@ export declare const fileFlag: <const O extends Partial<import('../index.js').Fl
|
|
|
19
21
|
alias?: string | readonly string[];
|
|
20
22
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
21
23
|
exists?: boolean;
|
|
22
|
-
},
|
|
24
|
+
}, Ctx>) => {
|
|
23
25
|
shouldStop: boolean;
|
|
24
26
|
} | void) | undefined;
|
|
25
27
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
@@ -17,38 +17,41 @@ import { optionFlag } from './option.js';
|
|
|
17
17
|
* default, multiple, ask, handler, help) plus its builder-specific extras.
|
|
18
18
|
*/
|
|
19
19
|
export declare const Flags: {
|
|
20
|
-
string: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
20
|
+
string: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
21
21
|
[x: string]: unknown;
|
|
22
22
|
} & {
|
|
23
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
23
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
24
24
|
type?: import('../index.js').FlagKind;
|
|
25
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
25
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
26
26
|
description?: string;
|
|
27
27
|
required?: boolean;
|
|
28
28
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
help?: string;
|
|
31
31
|
alias?: string | readonly string[];
|
|
32
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
32
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
33
33
|
shouldStop: boolean;
|
|
34
34
|
} | void) | undefined;
|
|
35
35
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
|
36
|
-
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
36
|
+
number: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
37
37
|
min?: number;
|
|
38
38
|
max?: number;
|
|
39
|
-
},
|
|
39
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
40
|
+
min?: number;
|
|
41
|
+
max?: number;
|
|
42
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
40
43
|
min?: number | undefined;
|
|
41
44
|
max?: number | undefined;
|
|
42
45
|
} & {
|
|
43
46
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
44
47
|
min?: number;
|
|
45
48
|
max?: number;
|
|
46
|
-
},
|
|
49
|
+
}, Ctx>) => number;
|
|
47
50
|
type?: import('../index.js').FlagKind;
|
|
48
51
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
49
52
|
min?: number;
|
|
50
53
|
max?: number;
|
|
51
|
-
},
|
|
54
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
52
55
|
description?: string;
|
|
53
56
|
required?: boolean;
|
|
54
57
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -58,42 +61,44 @@ export declare const Flags: {
|
|
|
58
61
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
59
62
|
min?: number;
|
|
60
63
|
max?: number;
|
|
61
|
-
},
|
|
64
|
+
}, Ctx>) => {
|
|
62
65
|
shouldStop: boolean;
|
|
63
66
|
} | void) | undefined;
|
|
64
67
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
65
68
|
min?: number;
|
|
66
69
|
max?: number;
|
|
67
70
|
}, any>> & O;
|
|
68
|
-
boolean: <const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions,
|
|
71
|
+
boolean: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
69
72
|
[x: string]: unknown;
|
|
70
73
|
} & {
|
|
71
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
74
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => boolean;
|
|
72
75
|
type?: import('../index.js').FlagKind;
|
|
73
|
-
ask?: ((opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
76
|
+
ask?: ((opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
74
77
|
description?: string;
|
|
75
78
|
required?: boolean;
|
|
76
79
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
77
80
|
multiple?: boolean;
|
|
78
81
|
help?: string;
|
|
79
82
|
alias?: string | readonly string[];
|
|
80
|
-
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions,
|
|
83
|
+
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<boolean, import('../index.js').CustomOptions, Ctx>) => {
|
|
81
84
|
shouldStop: boolean;
|
|
82
85
|
} | void) | undefined;
|
|
83
86
|
} & Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions, any>> & O;
|
|
84
87
|
option: typeof optionFlag;
|
|
85
|
-
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
88
|
+
file: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
86
89
|
exists?: boolean;
|
|
87
|
-
},
|
|
90
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
91
|
+
exists?: boolean;
|
|
92
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
88
93
|
exists?: boolean | undefined;
|
|
89
94
|
} & {
|
|
90
95
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
91
96
|
exists?: boolean;
|
|
92
|
-
},
|
|
97
|
+
}, Ctx>) => string;
|
|
93
98
|
type?: import('../index.js').FlagKind;
|
|
94
99
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
95
100
|
exists?: boolean;
|
|
96
|
-
},
|
|
101
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
97
102
|
description?: string;
|
|
98
103
|
required?: boolean;
|
|
99
104
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -102,24 +107,26 @@ export declare const Flags: {
|
|
|
102
107
|
alias?: string | readonly string[];
|
|
103
108
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
104
109
|
exists?: boolean;
|
|
105
|
-
},
|
|
110
|
+
}, Ctx>) => {
|
|
106
111
|
shouldStop: boolean;
|
|
107
112
|
} | void) | undefined;
|
|
108
113
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
109
114
|
exists?: boolean;
|
|
110
115
|
}, any>> & O;
|
|
111
|
-
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
116
|
+
directory: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
117
|
+
exists?: boolean;
|
|
118
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<string, {
|
|
112
119
|
exists?: boolean;
|
|
113
|
-
},
|
|
120
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
114
121
|
exists?: boolean | undefined;
|
|
115
122
|
} & {
|
|
116
123
|
parse: (input: any, opts: import('../index.js').FlagOpts<string, {
|
|
117
124
|
exists?: boolean;
|
|
118
|
-
},
|
|
125
|
+
}, Ctx>) => string;
|
|
119
126
|
type?: import('../index.js').FlagKind;
|
|
120
127
|
ask?: ((opts: import('../index.js').FlagOpts<string, {
|
|
121
128
|
exists?: boolean;
|
|
122
|
-
},
|
|
129
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
123
130
|
description?: string;
|
|
124
131
|
required?: boolean;
|
|
125
132
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
@@ -128,25 +135,25 @@ export declare const Flags: {
|
|
|
128
135
|
alias?: string | readonly string[];
|
|
129
136
|
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, {
|
|
130
137
|
exists?: boolean;
|
|
131
|
-
},
|
|
138
|
+
}, Ctx>) => {
|
|
132
139
|
shouldStop: boolean;
|
|
133
140
|
} | void) | undefined;
|
|
134
141
|
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
135
142
|
exists?: boolean;
|
|
136
143
|
}, any>> & O;
|
|
137
|
-
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
144
|
+
url: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
138
145
|
[x: string]: unknown;
|
|
139
146
|
} & {
|
|
140
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
147
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
141
148
|
type?: import('../index.js').FlagKind;
|
|
142
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
149
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
143
150
|
description?: string;
|
|
144
151
|
required?: boolean;
|
|
145
152
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
146
153
|
multiple?: boolean;
|
|
147
154
|
help?: string;
|
|
148
155
|
alias?: string | readonly string[];
|
|
149
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
156
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
150
157
|
shouldStop: boolean;
|
|
151
158
|
} | void) | undefined;
|
|
152
159
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/** Numeric flag. Optional `min`/`max` clamp the accepted range and surface as `BadCommandFlag`. */
|
|
2
|
-
export declare const numberFlag: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
2
|
+
export declare const numberFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
3
3
|
min?: number;
|
|
4
4
|
max?: number;
|
|
5
|
-
},
|
|
5
|
+
}, Ctx>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
}, Ctx>>>(overrides?: O | undefined) => {
|
|
6
9
|
min?: number | undefined;
|
|
7
10
|
max?: number | undefined;
|
|
8
11
|
} & {
|
|
9
12
|
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
10
13
|
min?: number;
|
|
11
14
|
max?: number;
|
|
12
|
-
},
|
|
15
|
+
}, Ctx>) => number;
|
|
13
16
|
type?: import('../index.js').FlagKind;
|
|
14
17
|
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
15
18
|
min?: number;
|
|
16
19
|
max?: number;
|
|
17
|
-
},
|
|
20
|
+
}, Ctx>) => Promise<any>) | undefined;
|
|
18
21
|
description?: string;
|
|
19
22
|
required?: boolean;
|
|
20
23
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
@@ -24,7 +27,7 @@ export declare const numberFlag: <const O extends Partial<import('../index.js').
|
|
|
24
27
|
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
25
28
|
min?: number;
|
|
26
29
|
max?: number;
|
|
27
|
-
},
|
|
30
|
+
}, Ctx>) => {
|
|
28
31
|
shouldStop: boolean;
|
|
29
32
|
} | void) | undefined;
|
|
30
33
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** Text input flag. Pass `secret: true` to mask the prompt as a password. */
|
|
2
|
-
export declare const stringFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions,
|
|
2
|
+
export declare const stringFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => string;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions,
|
|
14
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions, Ctx>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions, any>> & O;
|
package/dist/esm/flags/url.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** URL flag — parses the input with `new URL()` and returns the resulting `URL` object. */
|
|
2
|
-
export declare const urlFlag: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions,
|
|
2
|
+
export declare const urlFlag: <Ctx extends unknown = any, const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, Ctx>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => URL;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions,
|
|
14
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions, Ctx>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions, any>> & O;
|
package/dist/esm/index.js
CHANGED
|
@@ -1160,7 +1160,7 @@ var Ke = .75, qe = .55, Je = .05, Ye = class {
|
|
|
1160
1160
|
}, Ze = /* @__PURE__ */ ue(Ne(), 1);
|
|
1161
1161
|
function Qe() {
|
|
1162
1162
|
try {
|
|
1163
|
-
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,
|
|
1163
|
+
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMC1iZXRhLjExIiwKICAiZGVzY3JpcHRpb24iOiAiQk9CIENvcmUiLAogICJ0eXBlIjogIm1vZHVsZSIsCiAgIm1haW4iOiAiLi9kaXN0L2Nqcy9pbmRleC5qcyIsCiAgIm1vZHVsZSI6ICIuL2Rpc3QvZXNtL2luZGV4LmpzIiwKICAidHlwZXMiOiAiLi9kaXN0L2VzbS9pbmRleC5kLnRzIiwKICAiZmlsZXMiOiBbCiAgICAiZGlzdCIKICBdLAogICJleHBvcnRzIjogewogICAgIi4iOiB7CiAgICAgICJpbXBvcnQiOiB7CiAgICAgICAgInR5cGVzIjogIi4vZGlzdC9lc20vaW5kZXguZC50cyIsCiAgICAgICAgImRlZmF1bHQiOiAiLi9kaXN0L2VzbS9pbmRleC5qcyIKICAgICAgfSwKICAgICAgInJlcXVpcmUiOiB7CiAgICAgICAgInR5cGVzIjogIi4vZGlzdC9janMvaW5kZXguZC50cyIsCiAgICAgICAgImRlZmF1bHQiOiAiLi9kaXN0L2Nqcy9pbmRleC5qcyIKICAgICAgfQogICAgfQogIH0sCiAgInNjcmlwdHMiOiB7CiAgICAic3RhcnQiOiAibm9kZSAtciBAc3djLW5vZGUvcmVnaXN0ZXIgZGVidWcvbWFpbi50cyIsCiAgICAiYnVpbGQiOiAicm0gLXJmIC4vZGlzdCAmJiB2aXRlIGJ1aWxkIiwKICAgICJ0eXBlY2hlY2siOiAidHNjIC0tbm9FbWl0IiwKICAgICJwcmVwYWNrIjogIm5wbSBydW4gYnVpbGQiLAogICAgInRlc3QiOiAidml0ZXN0IHJ1biIsCiAgICAibGludCI6ICJlc2xpbnQgLiIsCiAgICAibGludDpmaXgiOiAiZXNsaW50IC4gLS1maXgiCiAgfSwKICAiYXV0aG9yIjogIkzDqW8gSHViZXJ0IiwKICAibGljZW5zZSI6ICJJU0MiLAogICJkZXZEZXBlbmRlbmNpZXMiOiB7CiAgICAiQGVzbGludC9qcyI6ICJeOS4zOS40IiwKICAgICJAZmFrZXItanMvZmFrZXIiOiAiXjEwLjMuMCIsCiAgICAiQHN3Yy1ub2RlL3JlZ2lzdGVyIjogIl4xLjExLjEiLAogICAgIkB0cml2YWdvL3ByZXR0aWVyLXBsdWdpbi1zb3J0LWltcG9ydHMiOiAiXjUuMi4yIiwKICAgICJAdHlwZXMvbWluaW1pc3QiOiAiXjEuMi41IiwKICAgICJAdHlwZXMvbm9kZSI6ICJeMjAuMTQuNSIsCiAgICAiQHR5cGVzL3N0cmluZy1zaW1pbGFyaXR5IjogIl40LjAuMiIsCiAgICAiQHZpdGVzdC9jb3ZlcmFnZS12OCI6ICJeNC4xLjAiLAogICAgImVzbGludCI6ICJeOS4zOS40IiwKICAgICJlc2xpbnQtY29uZmlnLXByZXR0aWVyIjogIl4xMC4xLjgiLAogICAgImVzbGludC1wbHVnaW4tcHJldHRpZXIiOiAiXjUuNS41IiwKICAgICJwcmV0dGllciI6ICJeMy42LjIiLAogICAgInRzeCI6ICJeNC4yMS4wIiwKICAgICJ0eXBlc2NyaXB0IjogIl41LjkuMyIsCiAgICAidHlwZXNjcmlwdC1lc2xpbnQiOiAiXjguNTcuMCIsCiAgICAidml0ZSI6ICJeOC4wLjAiLAogICAgInZpdGUtcGx1Z2luLWR0cyI6ICJeNC41LjQiLAogICAgInZpdGVzdCI6ICJeNC4xLjAiCiAgfSwKICAiZGVwZW5kZW5jaWVzIjogewogICAgIkBpbnF1aXJlci9jb3JlIjogIl4xMS4xLjgiLAogICAgIkBpbnF1aXJlci9wcm9tcHRzIjogIl44LjQuMSIsCiAgICAiY2hhbGsiOiAiXjUuNi4yIiwKICAgICJpbnF1aXJlci1maWxlLXNlbGVjdG9yIjogIl4xLjAuMSIsCiAgICAibWluaW1pc3QiOiAiXjEuMi44IgogIH0KfQo=", "" + import.meta.url)), "utf8");
|
|
1164
1164
|
return JSON.parse(e).version ?? "0.0.0";
|
|
1165
1165
|
} catch {
|
|
1166
1166
|
return "0.0.0";
|