@stacksjs/cli 0.44.12 → 0.45.1
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/run.d.ts +4 -4
- package/dist/actions/run.mjs +17 -8
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.mjs +8 -4
- package/package.json +7 -7
package/dist/actions/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliOptions, CommandResult, Result } from '@stacksjs/types';
|
|
2
|
-
import {
|
|
2
|
+
import type { Err } from '@stacksjs/error-handling';
|
|
3
3
|
/**
|
|
4
4
|
* Execute a command.
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@ import { ResultAsync } from '@stacksjs/error-handling';
|
|
|
8
8
|
* @param errorMsg The name of the error to throw if the command fails.
|
|
9
9
|
* @returns The result of the command.
|
|
10
10
|
*/
|
|
11
|
-
export declare function exec(command: string, options?: CliOptions):
|
|
11
|
+
export declare function exec(command: string, options?: CliOptions): any;
|
|
12
12
|
/**
|
|
13
13
|
* Run a command the Stacks way.
|
|
14
14
|
*
|
|
@@ -16,7 +16,7 @@ export declare function exec(command: string, options?: CliOptions): ResultAsync
|
|
|
16
16
|
* @param options The options to pass to the command.
|
|
17
17
|
* @returns The result of the command.
|
|
18
18
|
*/
|
|
19
|
-
export declare function runCommand(command: string, options?: CliOptions): Promise<
|
|
19
|
+
export declare function runCommand(command: string, options?: CliOptions): Promise<any>;
|
|
20
20
|
/**
|
|
21
21
|
* Run many commands—the Stacks way.
|
|
22
22
|
*
|
|
@@ -24,4 +24,4 @@ export declare function runCommand(command: string, options?: CliOptions): Promi
|
|
|
24
24
|
* @param options The options to pass to the command.
|
|
25
25
|
* @returns The result of the command.
|
|
26
26
|
*/
|
|
27
|
-
export declare function runCommands(commands: string[], options?: CliOptions): Promise<Result<CommandResult<string>, Error>[]
|
|
27
|
+
export declare function runCommands(commands: string[], options?: CliOptions): Promise<Result<CommandResult<string>, Error>[] | Result<CommandResult<string>, Error> | Err<CommandResult<string>, string>>;
|
package/dist/actions/run.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { determineDebugMode } from "@stacksjs/config";
|
|
2
|
-
import { ResultAsync } from "@stacksjs/error-handling";
|
|
2
|
+
import { ResultAsync, err } from "@stacksjs/error-handling";
|
|
3
3
|
import { projectPath } from "@stacksjs/path";
|
|
4
4
|
import { italic } from "@stacksjs/cli";
|
|
5
5
|
import { spawn } from "../command.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { startSpinner } from "../helpers.mjs";
|
|
7
7
|
export function exec(command, options) {
|
|
8
8
|
const cwd = options?.cwd || projectPath();
|
|
9
9
|
const stdio = determineDebugMode(options) ? "inherit" : "ignore";
|
|
10
|
+
const shell = options?.shell || false;
|
|
10
11
|
return ResultAsync.fromPromise(
|
|
11
|
-
spawn(command, { stdio, cwd }),
|
|
12
|
+
spawn(command, { stdio, cwd, shell }),
|
|
12
13
|
() => new Error(`Failed to run command: ${italic(command)}`)
|
|
13
14
|
);
|
|
14
15
|
}
|
|
@@ -16,15 +17,16 @@ export async function runCommand(command, options) {
|
|
|
16
17
|
return await exec(command, options);
|
|
17
18
|
}
|
|
18
19
|
export async function runCommands(commands, options) {
|
|
19
|
-
let spinner;
|
|
20
|
-
if (!determineDebugMode(options))
|
|
21
|
-
spinner = startAnimation();
|
|
22
20
|
const results = [];
|
|
21
|
+
const numberOfCommands = commands.length;
|
|
22
|
+
if (!numberOfCommands)
|
|
23
|
+
return err("No commands were specified");
|
|
24
|
+
const spinner = determineSpinner(options);
|
|
23
25
|
for (const command of commands) {
|
|
24
26
|
const result = await runCommand(command, options);
|
|
25
|
-
if (result
|
|
27
|
+
if (result?.isOk())
|
|
26
28
|
results.push(result);
|
|
27
|
-
if (result
|
|
29
|
+
if (result?.isErr()) {
|
|
28
30
|
if (spinner)
|
|
29
31
|
spinner.fail("Failed to run command.");
|
|
30
32
|
results.push(result);
|
|
@@ -33,5 +35,12 @@ export async function runCommands(commands, options) {
|
|
|
33
35
|
}
|
|
34
36
|
if (spinner)
|
|
35
37
|
spinner.stop();
|
|
38
|
+
if (numberOfCommands === 1)
|
|
39
|
+
return results[0];
|
|
36
40
|
return results;
|
|
37
41
|
}
|
|
42
|
+
function determineSpinner(options) {
|
|
43
|
+
if (!determineDebugMode(options))
|
|
44
|
+
return startSpinner(options?.spinnerText);
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function intro(command: string, options?: IntroOptions): number |
|
|
|
7
7
|
* Prints the outro message.
|
|
8
8
|
*/
|
|
9
9
|
export declare function outro(text: string, options: OutroOptions, error?: Error | string): void;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function startSpinner(text?: string): import("ora").Ora;
|
package/dist/helpers.mjs
CHANGED
|
@@ -30,11 +30,15 @@ export function outro(text, options, error) {
|
|
|
30
30
|
log.success(green(`Done in ${time}${options.useSeconds ? "s" : "ms"}`));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
export function
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
export function startSpinner(text) {
|
|
34
|
+
if (!text)
|
|
35
|
+
text = "Executing...";
|
|
36
|
+
const spin = spinner({
|
|
37
|
+
text
|
|
38
|
+
}).start();
|
|
36
39
|
setTimeout(() => {
|
|
37
|
-
spin.text = italic(
|
|
40
|
+
spin.text = italic("This may take a little while...");
|
|
41
|
+
spin.spinner = "clock";
|
|
38
42
|
}, 5e3);
|
|
39
43
|
return spin;
|
|
40
44
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.45.1",
|
|
5
5
|
"packageManager": "pnpm@7.18.2",
|
|
6
6
|
"description": "The simple way to create beautiful CLIs.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"execa": "^6.1.0",
|
|
50
50
|
"ora": "^6.1.2",
|
|
51
51
|
"prompts": "^2.4.2",
|
|
52
|
-
"@stacksjs/config": "0.
|
|
53
|
-
"@stacksjs/error-handling": "0.
|
|
54
|
-
"@stacksjs/logging": "0.
|
|
55
|
-
"@stacksjs/path": "0.
|
|
56
|
-
"@stacksjs/types": "0.
|
|
52
|
+
"@stacksjs/config": "0.45.1",
|
|
53
|
+
"@stacksjs/error-handling": "0.45.1",
|
|
54
|
+
"@stacksjs/logging": "0.45.1",
|
|
55
|
+
"@stacksjs/path": "0.45.1",
|
|
56
|
+
"@stacksjs/types": "0.45.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"esno": "^0.16.3",
|
|
60
60
|
"mkdist": "^1.0.0",
|
|
61
|
-
"@stacksjs/testing": "0.
|
|
61
|
+
"@stacksjs/testing": "0.45.1"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "mkdist -d",
|