@stacksjs/cli 0.52.10 → 0.56.3
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/index.d.ts +16 -35
- package/dist/index.mjs +61 -12
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -33,40 +33,21 @@ declare function installPackage(pkg: string, options?: InstallPackageOptions): P
|
|
|
33
33
|
*/
|
|
34
34
|
declare function installStack(name: string, options?: InstallPackageOptions): Promise<CommandReturnValue>;
|
|
35
35
|
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
options:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})[];
|
|
52
|
-
} | {
|
|
53
|
-
type: "multiselect";
|
|
54
|
-
initial?: string | undefined;
|
|
55
|
-
options: string[] | {
|
|
56
|
-
label: string;
|
|
57
|
-
value: string;
|
|
58
|
-
hint?: string | undefined;
|
|
59
|
-
}[];
|
|
60
|
-
required?: boolean | undefined;
|
|
61
|
-
}>(message: string, opts?: T | undefined) => Promise<T extends {
|
|
62
|
-
type?: "text" | undefined;
|
|
63
|
-
default?: string | undefined;
|
|
64
|
-
placeholder?: string | undefined;
|
|
65
|
-
initial?: string | undefined;
|
|
66
|
-
} ? string : T extends {
|
|
67
|
-
type: "confirm";
|
|
68
|
-
initial?: boolean | undefined;
|
|
69
|
-
} ? boolean : string[]>;
|
|
36
|
+
declare class Prompt {
|
|
37
|
+
private required;
|
|
38
|
+
constructor();
|
|
39
|
+
require(): this;
|
|
40
|
+
isRequired(): boolean;
|
|
41
|
+
select(message: string, options: any): Promise<string | boolean | string[]>;
|
|
42
|
+
checkbox(message: string, options: any): Promise<string | boolean | string[]>;
|
|
43
|
+
confirm(message: string, options: any): Promise<string | boolean | string[]>;
|
|
44
|
+
input(message: string, options: any): Promise<string | boolean | string[]>;
|
|
45
|
+
password(message: string, options: any): Promise<string | boolean | string[]>;
|
|
46
|
+
number(message: string, options: any): Promise<string | boolean | string[]>;
|
|
47
|
+
multiselect(message: string, options: any): Promise<string | boolean | string[]>;
|
|
48
|
+
autocomplete(message: string, options: any): Promise<string | boolean | string[]>;
|
|
49
|
+
}
|
|
50
|
+
declare const prompt: Prompt;
|
|
70
51
|
|
|
71
52
|
/**
|
|
72
53
|
* Prints the intro message.
|
|
@@ -125,4 +106,4 @@ declare function runCommands(commands: string[], options?: CliOptions): Promise<
|
|
|
125
106
|
|
|
126
107
|
declare const spinner: typeof ora;
|
|
127
108
|
|
|
128
|
-
export { exec, execSync, installPackage, installStack, intro, outro, parseArgs, parseArgv, parseOptions, prompt, runCommand, runCommands, spinner, startSpinner };
|
|
109
|
+
export { Prompt, exec, execSync, installPackage, installStack, intro, outro, parseArgs, parseArgv, parseOptions, prompt, runCommand, runCommands, spinner, startSpinner };
|
package/dist/index.mjs
CHANGED
|
@@ -25,7 +25,59 @@ async function installStack(name, options) {
|
|
|
25
25
|
return await installPackage$1(`@stacksjs/${name}`, { silent: true });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
class Prompt {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.required = false;
|
|
31
|
+
}
|
|
32
|
+
require() {
|
|
33
|
+
this.required = true;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
isRequired() {
|
|
37
|
+
return this.required;
|
|
38
|
+
}
|
|
39
|
+
async select(message, options) {
|
|
40
|
+
if (this.isRequired())
|
|
41
|
+
return log.prompt(message, { ...options, type: "select", required: true });
|
|
42
|
+
return log.prompt(message, { ...options, type: "select" });
|
|
43
|
+
}
|
|
44
|
+
async checkbox(message, options) {
|
|
45
|
+
if (this.isRequired())
|
|
46
|
+
return log.prompt(message, { ...options, type: "multiselect", required: true });
|
|
47
|
+
return log.prompt(message, { ...options, type: "multiselect" });
|
|
48
|
+
}
|
|
49
|
+
async confirm(message, options) {
|
|
50
|
+
if (this.isRequired())
|
|
51
|
+
return log.prompt(message, { ...options, type: "confirm", required: true });
|
|
52
|
+
return log.prompt(message, { ...options, type: "confirm" });
|
|
53
|
+
}
|
|
54
|
+
async input(message, options) {
|
|
55
|
+
if (this.isRequired())
|
|
56
|
+
return log.prompt(message, { ...options, type: "text", required: true });
|
|
57
|
+
return log.prompt(message, { ...options, type: "text" });
|
|
58
|
+
}
|
|
59
|
+
async password(message, options) {
|
|
60
|
+
if (this.isRequired())
|
|
61
|
+
return log.prompt(message, { ...options, type: "password", required: true });
|
|
62
|
+
return log.prompt(message, { ...options, type: "password" });
|
|
63
|
+
}
|
|
64
|
+
async number(message, options) {
|
|
65
|
+
if (this.isRequired())
|
|
66
|
+
return log.prompt(message, { ...options, type: "numeral", required: true });
|
|
67
|
+
return log.prompt(message, { ...options, type: "numeral" });
|
|
68
|
+
}
|
|
69
|
+
async multiselect(message, options) {
|
|
70
|
+
if (this.isRequired())
|
|
71
|
+
return log.prompt(message, { ...options, type: "multiselect", required: true });
|
|
72
|
+
return log.prompt(message, { ...options, type: "multiselect" });
|
|
73
|
+
}
|
|
74
|
+
async autocomplete(message, options) {
|
|
75
|
+
if (this.isRequired())
|
|
76
|
+
return log.prompt(message, { ...options, type: "autocomplete", required: true });
|
|
77
|
+
return log.prompt(message, { ...options, type: "autocomplete" });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const prompt = new Prompt();
|
|
29
81
|
|
|
30
82
|
const spinner = ora;
|
|
31
83
|
|
|
@@ -44,7 +96,7 @@ async function intro(command, options) {
|
|
|
44
96
|
function outro(text, options, error) {
|
|
45
97
|
if (options.isError) {
|
|
46
98
|
if (error)
|
|
47
|
-
log.error(error);
|
|
99
|
+
log.error(isString(error) ? new Error(error) : error);
|
|
48
100
|
} else {
|
|
49
101
|
if (options?.type === "info")
|
|
50
102
|
log.info(text);
|
|
@@ -88,8 +140,8 @@ function parseValue(value) {
|
|
|
88
140
|
return true;
|
|
89
141
|
if (value === "false")
|
|
90
142
|
return false;
|
|
91
|
-
const numberValue = parseFloat(value);
|
|
92
|
-
if (!isNaN(numberValue))
|
|
143
|
+
const numberValue = Number.parseFloat(value);
|
|
144
|
+
if (!Number.isNaN(numberValue))
|
|
93
145
|
return numberValue;
|
|
94
146
|
return value.replace(/"/g, "");
|
|
95
147
|
}
|
|
@@ -162,14 +214,14 @@ function execSync(command) {
|
|
|
162
214
|
return execSync$1(command, { encoding: "utf-8" });
|
|
163
215
|
}
|
|
164
216
|
async function runCommand(command, options) {
|
|
165
|
-
return
|
|
217
|
+
return exec(command, options);
|
|
166
218
|
}
|
|
167
219
|
async function runCommands(commands, options) {
|
|
168
220
|
const results = [];
|
|
169
221
|
const numberOfCommands = commands.length;
|
|
170
222
|
if (!numberOfCommands) {
|
|
171
223
|
log.error(new Error("No commands were specified"));
|
|
172
|
-
process.exit();
|
|
224
|
+
process.exit(ExitCode.FatalError);
|
|
173
225
|
}
|
|
174
226
|
const spinner = determineSpinner(options);
|
|
175
227
|
for (const command of commands) {
|
|
@@ -177,11 +229,8 @@ async function runCommands(commands, options) {
|
|
|
177
229
|
if (result.isOk()) {
|
|
178
230
|
results.push(result);
|
|
179
231
|
} else if (result.isErr()) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
process.exit(ExitCode.FatalError);
|
|
183
|
-
}
|
|
184
|
-
results.push(result);
|
|
232
|
+
log.error(new Error(`Failed to run command ${italic(command)}`));
|
|
233
|
+
process.exit(ExitCode.FatalError);
|
|
185
234
|
break;
|
|
186
235
|
}
|
|
187
236
|
}
|
|
@@ -197,4 +246,4 @@ function determineSpinner(options) {
|
|
|
197
246
|
return void 0;
|
|
198
247
|
}
|
|
199
248
|
|
|
200
|
-
export { exec, execSync, installPackage, installStack, intro, outro, parseArgs, parseArgv, parseOptions, prompt, runCommand, runCommands, spinner, startSpinner };
|
|
249
|
+
export { Prompt, exec, execSync, installPackage, installStack, intro, outro, parseArgs, parseArgv, parseOptions, prompt, runCommand, runCommands, spinner, startSpinner };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.5
|
|
4
|
+
"version": "0.56.3",
|
|
5
|
+
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "The simple way to create beautiful CLIs.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"cac": "^6.7.14",
|
|
51
51
|
"execa": "^7.1.1",
|
|
52
52
|
"ora": "^6.3.1",
|
|
53
|
-
"@stacksjs/config": "0.
|
|
54
|
-
"@stacksjs/error-handling": "0.
|
|
55
|
-
"@stacksjs/
|
|
56
|
-
"@stacksjs/
|
|
57
|
-
"@stacksjs/
|
|
58
|
-
"@stacksjs/
|
|
53
|
+
"@stacksjs/config": "0.56.3",
|
|
54
|
+
"@stacksjs/error-handling": "0.56.3",
|
|
55
|
+
"@stacksjs/path": "0.56.3",
|
|
56
|
+
"@stacksjs/types": "0.56.3",
|
|
57
|
+
"@stacksjs/utils": "0.56.3",
|
|
58
|
+
"@stacksjs/logging": "0.56.3"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"kolorist": "1.8.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@stacksjs/development": "0.
|
|
64
|
+
"@stacksjs/development": "0.56.3"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "unbuild",
|