@stacksjs/cli 0.44.11 → 0.45.0
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 +2 -1
- package/dist/actions/run.mjs +18 -9
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.mjs +5 -3
- package/package.json +7 -7
package/dist/actions/run.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CliOptions, CommandResult, Result } from '@stacksjs/types';
|
|
2
|
+
import type { Err } from '@stacksjs/error-handling';
|
|
2
3
|
/**
|
|
3
4
|
* Execute a command.
|
|
4
5
|
*
|
|
@@ -23,4 +24,4 @@ export declare function runCommand(command: string, options?: CliOptions): Promi
|
|
|
23
24
|
* @param options The options to pass to the command.
|
|
24
25
|
* @returns The result of the command.
|
|
25
26
|
*/
|
|
26
|
-
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,30 +1,32 @@
|
|
|
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
|
-
import { italic } from "
|
|
4
|
+
import { italic } from "@stacksjs/cli";
|
|
5
5
|
import { spawn } from "../command.mjs";
|
|
6
6
|
import { startAnimation } 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
|
-
() => new Error(`Failed to
|
|
12
|
+
spawn(command, { stdio, cwd, shell }),
|
|
13
|
+
() => new Error(`Failed to run command: ${italic(command)}`)
|
|
13
14
|
);
|
|
14
15
|
}
|
|
15
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 startAnimation();
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare function intro(command: string, options?: IntroOptions): number |
|
|
|
6
6
|
/**
|
|
7
7
|
* Prints the outro message.
|
|
8
8
|
*/
|
|
9
|
-
export declare function outro(text: string, options: OutroOptions, error?: Error): void;
|
|
9
|
+
export declare function outro(text: string, options: OutroOptions, error?: Error | string): void;
|
|
10
10
|
export declare function startAnimation(): import("ora").Ora;
|
package/dist/helpers.mjs
CHANGED
|
@@ -31,10 +31,12 @@ export function outro(text, options, error) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
export function startAnimation() {
|
|
34
|
-
const spin = spinner(
|
|
35
|
-
|
|
34
|
+
const spin = spinner({
|
|
35
|
+
text: "Executing..."
|
|
36
|
+
}).start();
|
|
36
37
|
setTimeout(() => {
|
|
37
|
-
spin.text = italic(
|
|
38
|
+
spin.text = italic("This may take a little while...");
|
|
39
|
+
spin.spinner = "clock";
|
|
38
40
|
}, 5e3);
|
|
39
41
|
return spin;
|
|
40
42
|
}
|
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.0",
|
|
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.0",
|
|
53
|
+
"@stacksjs/error-handling": "0.45.0",
|
|
54
|
+
"@stacksjs/logging": "0.45.0",
|
|
55
|
+
"@stacksjs/path": "0.45.0",
|
|
56
|
+
"@stacksjs/types": "0.45.0"
|
|
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.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "mkdist -d",
|