@stacksjs/cli 0.70.88 → 0.70.91
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/actions/index.d.ts +1 -0
- package/dist/actions/install.d.ts +24 -0
- package/dist/cli.d.ts +14 -0
- package/dist/exec.d.ts +40 -0
- package/dist/helpers.d.ts +14 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1024 -0
- package/dist/parse.d.ts +20 -0
- package/dist/prompts.d.ts +48 -0
- package/dist/run.d.ts +63 -0
- package/dist/signals.d.ts +29 -0
- package/dist/spinner.d.ts +17 -0
- package/dist/utils.d.ts +137 -0
- package/package.json +9 -9
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function parseArgv(argv?: string[]): ParsedArgv;
|
|
2
|
+
export declare function parseArgs(argv?: string[]): string[];
|
|
3
|
+
export declare function parseOptions(options?: CliOptions): CliOptions;
|
|
4
|
+
// interface BuddyOptions {
|
|
5
|
+
// dryRun?: boolean
|
|
6
|
+
// verbose?: boolean
|
|
7
|
+
// }
|
|
8
|
+
export declare function buddyOptions(options?: string[] | Record<string, any>): string;
|
|
9
|
+
declare interface ParsedArgv {
|
|
10
|
+
args: string[]
|
|
11
|
+
options: {
|
|
12
|
+
[k: string]: string | boolean | number
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare interface CliOptions {
|
|
16
|
+
dryRun?: boolean
|
|
17
|
+
quiet?: boolean
|
|
18
|
+
verbose?: boolean
|
|
19
|
+
[k: string]: string | boolean | number | undefined
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple confirm prompt
|
|
3
|
+
*/
|
|
4
|
+
declare function confirm(options: ConfirmOptions | string): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Simple text prompt
|
|
7
|
+
*/
|
|
8
|
+
declare function text(options: TextOptions | string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Simple select prompt (basic implementation)
|
|
11
|
+
*/
|
|
12
|
+
declare function select(options: SelectOptions): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Multiselect prompt (basic implementation)
|
|
15
|
+
*/
|
|
16
|
+
declare function multiselect(options: SelectOptions): Promise<any[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Password prompt (hidden input)
|
|
19
|
+
*/
|
|
20
|
+
declare function password(options: PasswordOptions | string): Promise<string>;
|
|
21
|
+
export declare const prompts: {
|
|
22
|
+
text: typeof text;
|
|
23
|
+
confirm: typeof confirm;
|
|
24
|
+
select: typeof select;
|
|
25
|
+
multiselect: typeof multiselect;
|
|
26
|
+
password: typeof password
|
|
27
|
+
};
|
|
28
|
+
declare interface ConfirmOptions {
|
|
29
|
+
message: string
|
|
30
|
+
initial?: boolean
|
|
31
|
+
}
|
|
32
|
+
declare interface TextOptions {
|
|
33
|
+
message: string
|
|
34
|
+
initial?: string
|
|
35
|
+
placeholder?: string
|
|
36
|
+
validate?: (value: string) => boolean | string
|
|
37
|
+
}
|
|
38
|
+
declare interface PasswordOptions {
|
|
39
|
+
message: string
|
|
40
|
+
validate?: (value: string) => boolean | string
|
|
41
|
+
}
|
|
42
|
+
declare interface SelectOptions {
|
|
43
|
+
message: string
|
|
44
|
+
choices: Array<{ value: any, label: string }>
|
|
45
|
+
initial?: number
|
|
46
|
+
}
|
|
47
|
+
// Also export individual functions
|
|
48
|
+
export { confirm, text, select, multiselect, password };
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CliOptions, CommandError, Readable, Subprocess, Writable } from '@stacksjs/types';
|
|
2
|
+
import type { Ok, Result } from '@stacksjs/error-handling';
|
|
3
|
+
/**
|
|
4
|
+
* Run a command.
|
|
5
|
+
*
|
|
6
|
+
* @param command The command to run.
|
|
7
|
+
* @param options The options to pass to the command.
|
|
8
|
+
* @returns The result of the command.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const result = await runCommand('ls')
|
|
12
|
+
*
|
|
13
|
+
* if (result.isErr)
|
|
14
|
+
* console.error(result.error)
|
|
15
|
+
* else
|
|
16
|
+
* console.log(result)
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const result = await runCommand('ls', { cwd: '/home' })
|
|
21
|
+
*
|
|
22
|
+
* if (result.isErr)
|
|
23
|
+
* console.error(result.error)
|
|
24
|
+
* else
|
|
25
|
+
* console.log(result)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function runCommand(command: string, options?: CliOptions): Promise<Result<Subprocess, CommandError>>;
|
|
29
|
+
export declare function runProcess(command: string, options?: CliOptions): Promise<Result<Subprocess, CommandError>>;
|
|
30
|
+
/**
|
|
31
|
+
* Run a command.
|
|
32
|
+
*
|
|
33
|
+
* @param command The command to run.
|
|
34
|
+
* @param options The options to pass to the command.
|
|
35
|
+
* @returns The result of the command.
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const result = runCommandSync('ls')
|
|
39
|
+
*
|
|
40
|
+
* if (result.isErr)
|
|
41
|
+
* console.error(result.error)
|
|
42
|
+
* else
|
|
43
|
+
* console.log(result)
|
|
44
|
+
* ```
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const result = runCommandSync('ls', { cwd: '/home' })
|
|
48
|
+
*
|
|
49
|
+
* if (result.isErr)
|
|
50
|
+
* console.error(result.error)
|
|
51
|
+
* else
|
|
52
|
+
* console.log(result)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function runCommandSync(command: string, options?: CliOptions): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Run many commands.
|
|
58
|
+
*
|
|
59
|
+
* @param commands The command to run.
|
|
60
|
+
* @param options The options to pass to the command.
|
|
61
|
+
* @returns The result of the command.
|
|
62
|
+
*/
|
|
63
|
+
export declare function runCommands(commands: string[], options?: CliOptions): Promise<Ok<Subprocess<Writable, Readable, Readable>, Error>[]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register or replace the cleanup for `name`. Returns a disposer that
|
|
3
|
+
* un-registers this specific cleanup; useful in tests to avoid leaking
|
|
4
|
+
* across spec files.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { onSignal } from '@stacksjs/cli'
|
|
9
|
+
*
|
|
10
|
+
* const dispose = onSignal('queue-worker', async () => {
|
|
11
|
+
* await worker.drain()
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* // Later, if the worker stops on its own:
|
|
15
|
+
* dispose()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function onSignal(name: string, cleanup: () => void | Promise<void>): () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Drop a registered handler by name. Equivalent to invoking the disposer
|
|
21
|
+
* returned by `onSignal`, but useful when the disposer wasn't kept.
|
|
22
|
+
*/
|
|
23
|
+
export declare function offSignal(name: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Snapshot of currently-registered handler names — primarily for tests
|
|
26
|
+
* that want to assert cleanup wiring is in place.
|
|
27
|
+
*/
|
|
28
|
+
export declare function listSignalHandlers(): string[];
|
|
29
|
+
declare type Signal = 'SIGINT' | 'SIGTERM' | 'SIGHUP';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function spinner(message?: string): Spinner;
|
|
2
|
+
/**
|
|
3
|
+
* Run an async operation with a spinner
|
|
4
|
+
*/
|
|
5
|
+
export declare function withSpinner<T>(message: string, operation: () => Promise<T>, options?: { successMessage?: string; failMessage?: string }): Promise<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Spinner utilities for CLI with reactive terminal output
|
|
8
|
+
*/
|
|
9
|
+
export declare interface Spinner {
|
|
10
|
+
start: (message?: string) => void
|
|
11
|
+
stop: (message?: string) => void
|
|
12
|
+
succeed: (message?: string) => void
|
|
13
|
+
fail: (message?: string) => void
|
|
14
|
+
update: (message: string) => void
|
|
15
|
+
text: string
|
|
16
|
+
isSpinning: boolean
|
|
17
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export declare function stripAnsi(text: string): string;
|
|
2
|
+
export declare function ansi256(code: number): ColorFn;
|
|
3
|
+
export declare function ansi256Bg(code: number): ColorFn;
|
|
4
|
+
export declare function trueColor(r: number, g: number, b: number): ColorFn;
|
|
5
|
+
export declare function trueColorBg(r: number, g: number, b: number): ColorFn;
|
|
6
|
+
export declare function link(url: string): ColorFn;
|
|
7
|
+
export declare function link(text: ColorInput, url: string): string;
|
|
8
|
+
export declare function getColor(colorName: string): ColorFn;
|
|
9
|
+
export declare function colorize(text: ColorInput, colorOrFn: ColorLike): string;
|
|
10
|
+
declare function supportsColor(): boolean;
|
|
11
|
+
export declare function align(text: string, width?: number, alignMode?: Alignment): string;
|
|
12
|
+
export declare function align(text: string, options?: AlignOptions): string;
|
|
13
|
+
export declare function leftAlign(text: string, width?: number): string;
|
|
14
|
+
export declare function rightAlign(text: string, width?: number): string;
|
|
15
|
+
export declare function centerAlign(text: string, width?: number): string;
|
|
16
|
+
export declare function box(text: string, options?: BoxOptions): string;
|
|
17
|
+
export declare const stripColors: typeof stripAnsi;
|
|
18
|
+
export declare const black: ColorFn;
|
|
19
|
+
export declare const red: ColorFn;
|
|
20
|
+
export declare const green: ColorFn;
|
|
21
|
+
export declare const yellow: ColorFn;
|
|
22
|
+
export declare const blue: ColorFn;
|
|
23
|
+
export declare const magenta: ColorFn;
|
|
24
|
+
export declare const cyan: ColorFn;
|
|
25
|
+
export declare const white: ColorFn;
|
|
26
|
+
export declare const gray: ColorFn;
|
|
27
|
+
export declare const lightRed: ColorFn;
|
|
28
|
+
export declare const lightGreen: ColorFn;
|
|
29
|
+
export declare const lightYellow: ColorFn;
|
|
30
|
+
export declare const lightBlue: ColorFn;
|
|
31
|
+
export declare const lightMagenta: ColorFn;
|
|
32
|
+
export declare const lightCyan: ColorFn;
|
|
33
|
+
export declare const lightGray: ColorFn;
|
|
34
|
+
export declare const bgBlack: ColorFn;
|
|
35
|
+
export declare const bgRed: ColorFn;
|
|
36
|
+
export declare const bgGreen: ColorFn;
|
|
37
|
+
export declare const bgYellow: ColorFn;
|
|
38
|
+
export declare const bgBlue: ColorFn;
|
|
39
|
+
export declare const bgMagenta: ColorFn;
|
|
40
|
+
export declare const bgCyan: ColorFn;
|
|
41
|
+
export declare const bgWhite: ColorFn;
|
|
42
|
+
export declare const bgGray: ColorFn;
|
|
43
|
+
export declare const bgLightRed: ColorFn;
|
|
44
|
+
export declare const bgLightGreen: ColorFn;
|
|
45
|
+
export declare const bgLightYellow: ColorFn;
|
|
46
|
+
export declare const bgLightBlue: ColorFn;
|
|
47
|
+
export declare const bgLightMagenta: ColorFn;
|
|
48
|
+
export declare const bgLightCyan: ColorFn;
|
|
49
|
+
export declare const bgLightGray: ColorFn;
|
|
50
|
+
export declare const bold: ColorFn;
|
|
51
|
+
export declare const dim: ColorFn;
|
|
52
|
+
export declare const italic: ColorFn;
|
|
53
|
+
export declare const underline: ColorFn;
|
|
54
|
+
export declare const inverse: ColorFn;
|
|
55
|
+
export declare const hidden: ColorFn;
|
|
56
|
+
export declare const strikethrough: ColorFn;
|
|
57
|
+
export declare const reset: ColorFn;
|
|
58
|
+
export declare const colors: ColorsApi;
|
|
59
|
+
export declare const kolorist: KoloristApi;
|
|
60
|
+
export declare const quotes: any;
|
|
61
|
+
declare interface AlignOptions {
|
|
62
|
+
width?: number
|
|
63
|
+
align?: Alignment
|
|
64
|
+
padChar?: string
|
|
65
|
+
}
|
|
66
|
+
declare interface BoxOptions {
|
|
67
|
+
align?: Alignment
|
|
68
|
+
borderColor?: ColorLike
|
|
69
|
+
borderStyle?: 'single' | 'double' | 'round'
|
|
70
|
+
margin?: number
|
|
71
|
+
padding?: number
|
|
72
|
+
title?: string
|
|
73
|
+
}
|
|
74
|
+
declare type ColorInput = string | number;
|
|
75
|
+
declare type ColorFn = (_text: ColorInput) => string;
|
|
76
|
+
declare type ColorLike = ColorFn | string;
|
|
77
|
+
declare type Alignment = 'left' | 'center' | 'right';
|
|
78
|
+
declare type NamedColorMap = {
|
|
79
|
+
black: ColorFn
|
|
80
|
+
red: ColorFn
|
|
81
|
+
green: ColorFn
|
|
82
|
+
yellow: ColorFn
|
|
83
|
+
blue: ColorFn
|
|
84
|
+
magenta: ColorFn
|
|
85
|
+
cyan: ColorFn
|
|
86
|
+
white: ColorFn
|
|
87
|
+
gray: ColorFn
|
|
88
|
+
|
|
89
|
+
lightRed: ColorFn
|
|
90
|
+
lightGreen: ColorFn
|
|
91
|
+
lightYellow: ColorFn
|
|
92
|
+
lightBlue: ColorFn
|
|
93
|
+
lightMagenta: ColorFn
|
|
94
|
+
lightCyan: ColorFn
|
|
95
|
+
lightGray: ColorFn
|
|
96
|
+
|
|
97
|
+
bgBlack: ColorFn
|
|
98
|
+
bgRed: ColorFn
|
|
99
|
+
bgGreen: ColorFn
|
|
100
|
+
bgYellow: ColorFn
|
|
101
|
+
bgBlue: ColorFn
|
|
102
|
+
bgMagenta: ColorFn
|
|
103
|
+
bgCyan: ColorFn
|
|
104
|
+
bgWhite: ColorFn
|
|
105
|
+
bgGray: ColorFn
|
|
106
|
+
|
|
107
|
+
bgLightRed: ColorFn
|
|
108
|
+
bgLightGreen: ColorFn
|
|
109
|
+
bgLightYellow: ColorFn
|
|
110
|
+
bgLightBlue: ColorFn
|
|
111
|
+
bgLightMagenta: ColorFn
|
|
112
|
+
bgLightCyan: ColorFn
|
|
113
|
+
bgLightGray: ColorFn
|
|
114
|
+
|
|
115
|
+
bold: ColorFn
|
|
116
|
+
dim: ColorFn
|
|
117
|
+
italic: ColorFn
|
|
118
|
+
underline: ColorFn
|
|
119
|
+
inverse: ColorFn
|
|
120
|
+
hidden: ColorFn
|
|
121
|
+
strikethrough: ColorFn
|
|
122
|
+
reset: ColorFn
|
|
123
|
+
}
|
|
124
|
+
declare type ColorsApi = NamedColorMap & {
|
|
125
|
+
ansi256: typeof ansi256
|
|
126
|
+
ansi256Bg: typeof ansi256Bg
|
|
127
|
+
trueColor: typeof trueColor
|
|
128
|
+
trueColorBg: typeof trueColorBg
|
|
129
|
+
link: typeof link
|
|
130
|
+
stripColors: typeof stripColors
|
|
131
|
+
}
|
|
132
|
+
declare type KoloristApi = ColorsApi & {
|
|
133
|
+
grey: ColorFn
|
|
134
|
+
lightGrey: ColorFn
|
|
135
|
+
bgLightGrey: ColorFn
|
|
136
|
+
supportsColor: () => boolean
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.91",
|
|
6
6
|
"description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"@stacksjs/clapp": "^0.2.8"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@stacksjs/collections": "0.70.
|
|
70
|
-
"@stacksjs/config": "0.70.
|
|
69
|
+
"@stacksjs/collections": "0.70.91",
|
|
70
|
+
"@stacksjs/config": "0.70.91",
|
|
71
71
|
"better-dx": "^0.2.16",
|
|
72
|
-
"@stacksjs/error-handling": "0.70.
|
|
73
|
-
"@stacksjs/logging": "0.70.
|
|
74
|
-
"@stacksjs/path": "0.70.
|
|
75
|
-
"@stacksjs/types": "0.70.
|
|
76
|
-
"@stacksjs/utils": "0.70.
|
|
77
|
-
"@stacksjs/validation": "0.70.
|
|
72
|
+
"@stacksjs/error-handling": "0.70.91",
|
|
73
|
+
"@stacksjs/logging": "0.70.91",
|
|
74
|
+
"@stacksjs/path": "0.70.91",
|
|
75
|
+
"@stacksjs/types": "0.70.91",
|
|
76
|
+
"@stacksjs/utils": "0.70.91",
|
|
77
|
+
"@stacksjs/validation": "0.70.91"
|
|
78
78
|
}
|
|
79
79
|
}
|