@stacksjs/cli 0.51.0 → 0.52.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/README.md +2 -2
- package/dist/index.d.ts +127 -7
- package/dist/index.mjs +197 -8
- package/package.json +22 -20
- package/dist/actions/index.d.ts +0 -1
- package/dist/actions/index.mjs +0 -1
- package/dist/actions/install.d.ts +0 -15
- package/dist/actions/install.mjs +0 -7
- package/dist/command.d.ts +0 -4
- package/dist/command.mjs +0 -5
- package/dist/console.d.ts +0 -3
- package/dist/console.mjs +0 -4
- package/dist/helpers.d.ts +0 -10
- package/dist/helpers.mjs +0 -45
- package/dist/run.d.ts +0 -28
- package/dist/run.mjs +0 -49
- package/dist/spinner.d.ts +0 -2
- package/dist/spinner.mjs +0 -2
- package/dist/utilities.d.ts +0 -1
- package/dist/utilities.mjs +0 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ command.parse() // parse the command
|
|
|
68
68
|
You may now run the command via:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
|
|
71
|
+
tsx command.ts
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
To view a more detailed example, check out [Buddy](../../buddy/).
|
|
@@ -98,7 +98,7 @@ pnpm test
|
|
|
98
98
|
|
|
99
99
|
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
|
|
100
100
|
|
|
101
|
-
##
|
|
101
|
+
## 🚜 Contributing
|
|
102
102
|
|
|
103
103
|
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
|
|
104
104
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from './console';
|
|
4
|
-
export * from './helpers';
|
|
5
|
-
export * from './run';
|
|
6
|
-
export * from './spinner';
|
|
7
|
-
export * from './utilities';
|
|
1
|
+
import * as _stacksjs_types from '@stacksjs/types';
|
|
2
|
+
import { CommandReturnValue, IntroOptions, OutroOptions, CliOptions, ResultAsync, CommandResult } from '@stacksjs/types';
|
|
8
3
|
export { ExitCode } from '@stacksjs/types';
|
|
4
|
+
export { cac as command } from 'cac';
|
|
5
|
+
export { execaCommand as spawn } from 'execa';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
export { ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, red, reset, strikethrough, underline, white, yellow } from 'kolorist';
|
|
8
|
+
export { log } from '@stacksjs/logging';
|
|
9
|
+
|
|
10
|
+
interface InstallPackageOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
dev?: boolean;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
packageManager?: string;
|
|
15
|
+
packageManagerVersion?: string;
|
|
16
|
+
preferOffline?: boolean;
|
|
17
|
+
additionalArgs?: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Install an npm package.
|
|
21
|
+
*
|
|
22
|
+
* @param pkg - The package name to install.
|
|
23
|
+
* @param pkg - The options to pass to the install.The options to pass to the install.
|
|
24
|
+
* @returns The result of the install.
|
|
25
|
+
*/
|
|
26
|
+
declare function installPackage(pkg: string, options?: InstallPackageOptions): Promise<CommandReturnValue>;
|
|
27
|
+
/**
|
|
28
|
+
* Install a Stack into your project.
|
|
29
|
+
*
|
|
30
|
+
* @param pkg - The Stack name to install.
|
|
31
|
+
* @param options - The options to pass to the install.
|
|
32
|
+
* @returns The result of the install.
|
|
33
|
+
*/
|
|
34
|
+
declare function installStack(name: string, options?: InstallPackageOptions): Promise<CommandReturnValue>;
|
|
35
|
+
|
|
36
|
+
declare const prompt: <T extends {
|
|
37
|
+
type?: "text" | undefined;
|
|
38
|
+
default?: string | undefined;
|
|
39
|
+
placeholder?: string | undefined;
|
|
40
|
+
initial?: string | undefined;
|
|
41
|
+
} | {
|
|
42
|
+
type: "confirm";
|
|
43
|
+
initial?: boolean | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
type: "select";
|
|
46
|
+
initial?: string | undefined;
|
|
47
|
+
options: (string | {
|
|
48
|
+
label: string;
|
|
49
|
+
value: string;
|
|
50
|
+
hint?: string | undefined;
|
|
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[]>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Prints the intro message.
|
|
73
|
+
*/
|
|
74
|
+
declare function intro(command: string, options?: IntroOptions): Promise<number | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* Prints the outro message.
|
|
77
|
+
*/
|
|
78
|
+
declare function outro(text: string, options: OutroOptions, error?: Error | string): void;
|
|
79
|
+
declare function startSpinner(text?: string): _stacksjs_types.SpinnerOptions;
|
|
80
|
+
|
|
81
|
+
interface ParsedArgv {
|
|
82
|
+
args: ReadonlyArray<string>;
|
|
83
|
+
options: {
|
|
84
|
+
[k: string]: string | boolean | number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
declare function parseArgv(argv?: ReadonlyArray<string>): ParsedArgv;
|
|
88
|
+
declare function parseOptions(argv?: ReadonlyArray<string>): {
|
|
89
|
+
[k: string]: string | boolean | number;
|
|
90
|
+
};
|
|
91
|
+
declare function parseArgs(argv?: ReadonlyArray<string>): ReadonlyArray<string>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Execute a command.
|
|
95
|
+
*
|
|
96
|
+
* @param command The command to execute.
|
|
97
|
+
* @param options The options to pass to the command.
|
|
98
|
+
* @param errorMsg The name of the error to throw if the command fails.
|
|
99
|
+
* @returns The result of the command.
|
|
100
|
+
*/
|
|
101
|
+
declare function exec(command: string, options?: CliOptions): ResultAsync<CommandReturnValue, Error>;
|
|
102
|
+
/**
|
|
103
|
+
* Execute a command and return result.
|
|
104
|
+
*
|
|
105
|
+
* @param command The command to execute.
|
|
106
|
+
* @returns The result of the command.
|
|
107
|
+
*/
|
|
108
|
+
declare function execSync(command: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Run a command the Stacks way.
|
|
111
|
+
*
|
|
112
|
+
* @param command The command to run.
|
|
113
|
+
* @param options The options to pass to the command.
|
|
114
|
+
* @returns The result of the command.
|
|
115
|
+
*/
|
|
116
|
+
declare function runCommand(command: string, options?: CliOptions): Promise<ResultAsync<CommandReturnValue, Error>>;
|
|
117
|
+
/**
|
|
118
|
+
* Run many commands—the Stacks way.
|
|
119
|
+
*
|
|
120
|
+
* @param commands The command to run.
|
|
121
|
+
* @param options The options to pass to the command.
|
|
122
|
+
* @returns The result of the command.
|
|
123
|
+
*/
|
|
124
|
+
declare function runCommands(commands: string[], options?: CliOptions): Promise<CommandResult | CommandResult[]>;
|
|
125
|
+
|
|
126
|
+
declare const spinner: typeof ora;
|
|
127
|
+
|
|
128
|
+
export { exec, execSync, installPackage, installStack, intro, outro, parseArgs, parseArgv, parseOptions, prompt, runCommand, runCommands, spinner, startSpinner };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,197 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { installPackage as installPackage$1 } from '@antfu/install-pkg';
|
|
2
|
+
export { cac as command } from 'cac';
|
|
3
|
+
import { execaCommand } from 'execa';
|
|
4
|
+
export { execaCommand as spawn } from 'execa';
|
|
5
|
+
import { log } from '@stacksjs/logging';
|
|
6
|
+
export { log } from '@stacksjs/logging';
|
|
7
|
+
import { frameworkVersion, determineDebugLevel } from '@stacksjs/utils';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import { cyan, bold, dim, bgCyan, italic, red, green } from 'kolorist';
|
|
10
|
+
export { ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, red, reset, strikethrough, underline, white, yellow } from 'kolorist';
|
|
11
|
+
import { execSync as execSync$1 } from 'node:child_process';
|
|
12
|
+
import { ExitCode } from '@stacksjs/types';
|
|
13
|
+
export { ExitCode } from '@stacksjs/types';
|
|
14
|
+
import { projectPath } from '@stacksjs/path';
|
|
15
|
+
import { ResultAsync } from '@stacksjs/error-handling';
|
|
16
|
+
|
|
17
|
+
async function installPackage(pkg, options) {
|
|
18
|
+
if (options)
|
|
19
|
+
return await installPackage$1(pkg, options);
|
|
20
|
+
return await installPackage$1(pkg, { silent: true });
|
|
21
|
+
}
|
|
22
|
+
async function installStack(name, options) {
|
|
23
|
+
if (options)
|
|
24
|
+
return await installPackage$1(`@stacksjs/${name}`, options);
|
|
25
|
+
return await installPackage$1(`@stacksjs/${name}`, { silent: true });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const prompt = log.prompt;
|
|
29
|
+
|
|
30
|
+
const spinner = ora;
|
|
31
|
+
|
|
32
|
+
async function intro(command, options) {
|
|
33
|
+
const version = await frameworkVersion();
|
|
34
|
+
console.log();
|
|
35
|
+
console.log(cyan(bold("Stacks CLI")) + dim(` v${version}`));
|
|
36
|
+
console.log();
|
|
37
|
+
log.info(`Preparing to run the ${bgCyan(italic(bold(` ${command} `)))} command.`);
|
|
38
|
+
if (options?.showPerformance === false)
|
|
39
|
+
return;
|
|
40
|
+
return performance.now();
|
|
41
|
+
}
|
|
42
|
+
function outro(text, options, error) {
|
|
43
|
+
if (options.isError) {
|
|
44
|
+
if (error)
|
|
45
|
+
log.error(error);
|
|
46
|
+
} else {
|
|
47
|
+
if (options?.type === "info")
|
|
48
|
+
log.info(text);
|
|
49
|
+
log.success(text);
|
|
50
|
+
}
|
|
51
|
+
if (options.startTime) {
|
|
52
|
+
let time = performance.now() - options.startTime;
|
|
53
|
+
if (options.useSeconds) {
|
|
54
|
+
time = time / 1e3;
|
|
55
|
+
time = Math.round(time * 100) / 100;
|
|
56
|
+
}
|
|
57
|
+
if (options.isError)
|
|
58
|
+
log.error(red(`in ${time}${options.useSeconds ? "s" : "ms"}`));
|
|
59
|
+
else
|
|
60
|
+
log.success(green(`Done in ${time}${options.useSeconds ? "s" : "ms"}`));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function startSpinner(text) {
|
|
64
|
+
if (!text)
|
|
65
|
+
text = "Executing...";
|
|
66
|
+
const spin = spinner({
|
|
67
|
+
text
|
|
68
|
+
}).start();
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
spin.text = italic("This may take a few moments...");
|
|
71
|
+
spin.spinner = "clock";
|
|
72
|
+
}, 7500);
|
|
73
|
+
return spin;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isLongOption(arg) {
|
|
77
|
+
return arg.startsWith("--");
|
|
78
|
+
}
|
|
79
|
+
function isShortOption(arg) {
|
|
80
|
+
return arg.startsWith("-") && !isLongOption(arg);
|
|
81
|
+
}
|
|
82
|
+
function parseValue(value) {
|
|
83
|
+
if (value === "true")
|
|
84
|
+
return true;
|
|
85
|
+
if (value === "false")
|
|
86
|
+
return false;
|
|
87
|
+
const numberValue = parseFloat(value);
|
|
88
|
+
if (!isNaN(numberValue))
|
|
89
|
+
return numberValue;
|
|
90
|
+
return value.replace(/"/g, "");
|
|
91
|
+
}
|
|
92
|
+
function parseLongOption(arg, argv, index, options) {
|
|
93
|
+
const [key, value] = arg.slice(2).split("=");
|
|
94
|
+
if (value !== void 0) {
|
|
95
|
+
options[key] = parseValue(value);
|
|
96
|
+
} else if (index + 1 < argv.length && !argv[index + 1].startsWith("-")) {
|
|
97
|
+
options[key] = argv[index + 1];
|
|
98
|
+
index++;
|
|
99
|
+
} else {
|
|
100
|
+
options[key] = true;
|
|
101
|
+
}
|
|
102
|
+
return index;
|
|
103
|
+
}
|
|
104
|
+
function parseShortOption(arg, argv, index, options) {
|
|
105
|
+
const [key, value] = arg.slice(1).split("=");
|
|
106
|
+
if (value !== void 0) {
|
|
107
|
+
for (let j = 0; j < key.length; j++)
|
|
108
|
+
options[key[j]] = parseValue(value);
|
|
109
|
+
} else {
|
|
110
|
+
for (let j = 0; j < key.length; j++) {
|
|
111
|
+
if (index + 1 < argv.length && j === key.length - 1 && !argv[index + 1].startsWith("-")) {
|
|
112
|
+
options[key[j]] = parseValue(argv[index + 1]);
|
|
113
|
+
index++;
|
|
114
|
+
} else {
|
|
115
|
+
options[key[j]] = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return index;
|
|
120
|
+
}
|
|
121
|
+
function parseArgv(argv) {
|
|
122
|
+
if (argv === void 0)
|
|
123
|
+
argv = process.argv.slice(2);
|
|
124
|
+
const args = [];
|
|
125
|
+
const options = {};
|
|
126
|
+
for (let i = 0; i < argv.length; i++) {
|
|
127
|
+
const arg = argv[i];
|
|
128
|
+
if (isLongOption(arg))
|
|
129
|
+
i = parseLongOption(arg, argv, i, options);
|
|
130
|
+
else if (isShortOption(arg))
|
|
131
|
+
i = parseShortOption(arg, argv, i, options);
|
|
132
|
+
else
|
|
133
|
+
args.push(arg);
|
|
134
|
+
}
|
|
135
|
+
return { args, options };
|
|
136
|
+
}
|
|
137
|
+
function parseOptions(argv) {
|
|
138
|
+
if (argv === void 0)
|
|
139
|
+
argv = process.argv.slice(2);
|
|
140
|
+
return parseArgv(argv).options;
|
|
141
|
+
}
|
|
142
|
+
function parseArgs(argv) {
|
|
143
|
+
if (argv === void 0)
|
|
144
|
+
argv = process.argv.slice(2);
|
|
145
|
+
return parseArgv(argv).args;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function exec(command, options) {
|
|
149
|
+
const cwd = options?.cwd || projectPath();
|
|
150
|
+
const stdio = determineDebugLevel(options) ? "inherit" : "ignore";
|
|
151
|
+
const shell = options?.shell || false;
|
|
152
|
+
return ResultAsync.fromPromise(
|
|
153
|
+
execaCommand(command, { stdio, cwd, shell }),
|
|
154
|
+
() => new Error(`Failed to run command: ${italic(command)}`)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function execSync(command) {
|
|
158
|
+
return execSync$1(command, { encoding: "utf-8" });
|
|
159
|
+
}
|
|
160
|
+
async function runCommand(command, options) {
|
|
161
|
+
return await exec(command, options);
|
|
162
|
+
}
|
|
163
|
+
async function runCommands(commands, options) {
|
|
164
|
+
console.log("runCommands", commands, options);
|
|
165
|
+
const results = [];
|
|
166
|
+
const numberOfCommands = commands.length;
|
|
167
|
+
if (!numberOfCommands) {
|
|
168
|
+
log.error(new Error("No commands were specified"));
|
|
169
|
+
process.exit();
|
|
170
|
+
}
|
|
171
|
+
const spinner = determineSpinner(options);
|
|
172
|
+
for (const command of commands) {
|
|
173
|
+
const result = await runCommand(command, options);
|
|
174
|
+
if (result.isOk()) {
|
|
175
|
+
results.push(result);
|
|
176
|
+
} else if (result.isErr()) {
|
|
177
|
+
if (spinner) {
|
|
178
|
+
log.error(new Error("Failed to run command"));
|
|
179
|
+
process.exit(ExitCode.FatalError);
|
|
180
|
+
}
|
|
181
|
+
results.push(result);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (spinner)
|
|
186
|
+
spinner.stop();
|
|
187
|
+
if (numberOfCommands === 1)
|
|
188
|
+
return results[0];
|
|
189
|
+
return results;
|
|
190
|
+
}
|
|
191
|
+
function determineSpinner(options) {
|
|
192
|
+
if (!determineDebugLevel(options))
|
|
193
|
+
return startSpinner(options?.spinnerText);
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { 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@
|
|
4
|
+
"version": "0.52.1",
|
|
5
|
+
"packageManager": "pnpm@8.5.1",
|
|
6
6
|
"description": "The simple way to create beautiful CLIs.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"ez-spawn",
|
|
30
30
|
"stacks"
|
|
31
31
|
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
32
38
|
"main": "dist/index.mjs",
|
|
33
39
|
"module": "dist/index.mjs",
|
|
34
40
|
"types": "dist/index.d.ts",
|
|
@@ -39,31 +45,27 @@
|
|
|
39
45
|
"dist",
|
|
40
46
|
"README.md"
|
|
41
47
|
],
|
|
42
|
-
"engines": {
|
|
43
|
-
"node": ">=v18.14.0",
|
|
44
|
-
"pnpm": ">=7.26.3"
|
|
45
|
-
},
|
|
46
48
|
"peerDependencies": {
|
|
47
49
|
"@antfu/install-pkg": "^0.1.1",
|
|
48
50
|
"cac": "^6.7.14",
|
|
49
|
-
"execa": "^
|
|
50
|
-
"ora": "^6.1
|
|
51
|
-
"
|
|
52
|
-
"@stacksjs/
|
|
53
|
-
"@stacksjs/
|
|
54
|
-
"@stacksjs/
|
|
55
|
-
"@stacksjs/
|
|
56
|
-
"@stacksjs/
|
|
57
|
-
|
|
51
|
+
"execa": "^7.1.1",
|
|
52
|
+
"ora": "^6.3.1",
|
|
53
|
+
"@stacksjs/config": "0.52.1",
|
|
54
|
+
"@stacksjs/error-handling": "0.52.1",
|
|
55
|
+
"@stacksjs/path": "0.52.1",
|
|
56
|
+
"@stacksjs/types": "0.52.1",
|
|
57
|
+
"@stacksjs/logging": "0.52.1",
|
|
58
|
+
"@stacksjs/utils": "0.52.1"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"kolorist": "1.8.0"
|
|
58
62
|
},
|
|
59
63
|
"devDependencies": {
|
|
60
|
-
"
|
|
61
|
-
"mkdist": "^1.1.0",
|
|
62
|
-
"@stacksjs/testing": "0.51.0"
|
|
64
|
+
"@stacksjs/development": "0.52.1"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
|
-
"build": "
|
|
66
|
-
"dev": "
|
|
67
|
+
"build": "unbuild",
|
|
68
|
+
"dev": "unbuild --stub",
|
|
67
69
|
"typecheck": "tsc --noEmit"
|
|
68
70
|
}
|
|
69
71
|
}
|
package/dist/actions/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './install';
|
package/dist/actions/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./install.mjs";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CommandResult } from '@stacksjs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Install an npm package.
|
|
4
|
-
*
|
|
5
|
-
* @param pkg - The package name to install.
|
|
6
|
-
* @returns The result of the install.
|
|
7
|
-
*/
|
|
8
|
-
export declare function installPackage(pkg: string): Promise<CommandResult<string>>;
|
|
9
|
-
/**
|
|
10
|
-
* Install a Stack into your project.
|
|
11
|
-
*
|
|
12
|
-
* @param pkg - The Stack name to install.
|
|
13
|
-
* @returns The result of the install.
|
|
14
|
-
*/
|
|
15
|
-
export declare function installStack(name: string): Promise<CommandResult<string>>;
|
package/dist/actions/install.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { installPackage as installPkg } from "@antfu/install-pkg";
|
|
2
|
-
export async function installPackage(pkg) {
|
|
3
|
-
return await installPkg(pkg, { silent: true });
|
|
4
|
-
}
|
|
5
|
-
export async function installStack(name) {
|
|
6
|
-
return await installPkg(`@stacksjs/${name}`, { silent: true });
|
|
7
|
-
}
|
package/dist/command.d.ts
DELETED
package/dist/command.mjs
DELETED
package/dist/console.d.ts
DELETED
package/dist/console.mjs
DELETED
package/dist/helpers.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IntroOptions, OutroOptions } from '@stacksjs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Prints the intro message.
|
|
4
|
-
*/
|
|
5
|
-
export declare function intro(command: string, options?: IntroOptions): Promise<number | undefined>;
|
|
6
|
-
/**
|
|
7
|
-
* Prints the outro message.
|
|
8
|
-
*/
|
|
9
|
-
export declare function outro(text: string, options: OutroOptions, error?: Error | string): void;
|
|
10
|
-
export declare function startSpinner(text?: string): import("ora").Ora;
|
package/dist/helpers.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { frameworkVersion } from "@stacksjs/utils";
|
|
2
|
-
import { log } from "./console.mjs";
|
|
3
|
-
import { spinner } from "./spinner.mjs";
|
|
4
|
-
import { bgCyan, bold, cyan, dim, green, italic, red } from "./utilities.mjs";
|
|
5
|
-
export async function intro(command, options) {
|
|
6
|
-
const version = await frameworkVersion();
|
|
7
|
-
console.log();
|
|
8
|
-
console.log(cyan(bold("Stacks CLI")) + dim(` v${version}`));
|
|
9
|
-
console.log();
|
|
10
|
-
log.info(`Preparing to run the ${bgCyan(italic(bold(` ${command} `)))} command.`);
|
|
11
|
-
if (options?.showPerformance === false)
|
|
12
|
-
return;
|
|
13
|
-
return performance.now();
|
|
14
|
-
}
|
|
15
|
-
export function outro(text, options, error) {
|
|
16
|
-
if (options.isError) {
|
|
17
|
-
if (error)
|
|
18
|
-
log.error(error);
|
|
19
|
-
} else {
|
|
20
|
-
log.success(text);
|
|
21
|
-
}
|
|
22
|
-
if (options.startTime) {
|
|
23
|
-
let time = performance.now() - options.startTime;
|
|
24
|
-
if (options.useSeconds) {
|
|
25
|
-
time = time / 1e3;
|
|
26
|
-
time = Math.round(time * 100) / 100;
|
|
27
|
-
}
|
|
28
|
-
if (options.isError)
|
|
29
|
-
log.error(red(`in ${time}${options.useSeconds ? "s" : "ms"}`));
|
|
30
|
-
else
|
|
31
|
-
log.success(green(`Done in ${time}${options.useSeconds ? "s" : "ms"}`));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function startSpinner(text) {
|
|
35
|
-
if (!text)
|
|
36
|
-
text = "Executing...";
|
|
37
|
-
const spin = spinner({
|
|
38
|
-
text
|
|
39
|
-
}).start();
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
spin.text = italic("This may take a few moments...");
|
|
42
|
-
spin.spinner = "clock";
|
|
43
|
-
}, 7500);
|
|
44
|
-
return spin;
|
|
45
|
-
}
|
package/dist/run.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { CliOptions, CommandResult, Result } from '@stacksjs/types';
|
|
2
|
-
import type { Err } from '@stacksjs/error-handling';
|
|
3
|
-
import { ResultAsync } from '@stacksjs/error-handling';
|
|
4
|
-
/**
|
|
5
|
-
* Execute a command.
|
|
6
|
-
*
|
|
7
|
-
* @param command The command to execute.
|
|
8
|
-
* @param options The options to pass to the command.
|
|
9
|
-
* @param errorMsg The name of the error to throw if the command fails.
|
|
10
|
-
* @returns The result of the command.
|
|
11
|
-
*/
|
|
12
|
-
export declare function exec(command: string, options?: CliOptions): ResultAsync<CommandResult<string>, Error>;
|
|
13
|
-
/**
|
|
14
|
-
* Run a command the Stacks way.
|
|
15
|
-
*
|
|
16
|
-
* @param command The command to run.
|
|
17
|
-
* @param options The options to pass to the command.
|
|
18
|
-
* @returns The result of the command.
|
|
19
|
-
*/
|
|
20
|
-
export declare function runCommand(command: string, options?: CliOptions): Promise<Result<CommandResult<string>, Error>>;
|
|
21
|
-
/**
|
|
22
|
-
* Run many commands—the Stacks way.
|
|
23
|
-
*
|
|
24
|
-
* @param commands The command to run.
|
|
25
|
-
* @param options The options to pass to the command.
|
|
26
|
-
* @returns The result of the command.
|
|
27
|
-
*/
|
|
28
|
-
export declare function runCommands(commands: string[], options?: CliOptions): Promise<Result<CommandResult<string>, Error>[] | Result<CommandResult<string>, Error> | Err<CommandResult<string>, string>>;
|
package/dist/run.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { determineDebugMode } from "@stacksjs/config";
|
|
2
|
-
import { ResultAsync, err } from "@stacksjs/error-handling";
|
|
3
|
-
import { projectPath } from "@stacksjs/path";
|
|
4
|
-
import { spawn } from "./command.mjs";
|
|
5
|
-
import { startSpinner } from "./helpers.mjs";
|
|
6
|
-
import { italic } from "./index.mjs";
|
|
7
|
-
export function exec(command, options) {
|
|
8
|
-
const cwd = options?.cwd || projectPath();
|
|
9
|
-
const stdio = determineDebugMode(options) ? "inherit" : "ignore";
|
|
10
|
-
const shell = options?.shell || false;
|
|
11
|
-
return ResultAsync.fromPromise(
|
|
12
|
-
spawn(command, { stdio, cwd, shell }),
|
|
13
|
-
() => new Error(`Failed to run command: ${italic(command)}`)
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
export async function runCommand(command, options) {
|
|
17
|
-
return await exec(command, options);
|
|
18
|
-
}
|
|
19
|
-
export async function runCommands(commands, options) {
|
|
20
|
-
const results = [];
|
|
21
|
-
const numberOfCommands = commands.length;
|
|
22
|
-
if (!numberOfCommands)
|
|
23
|
-
return err("No commands were specified");
|
|
24
|
-
const spinner = determineSpinner(options);
|
|
25
|
-
for (const command of commands) {
|
|
26
|
-
const result = await runCommand(command, options);
|
|
27
|
-
if (result?.isOk())
|
|
28
|
-
results.push(result);
|
|
29
|
-
if (result?.isErr()) {
|
|
30
|
-
if (spinner) {
|
|
31
|
-
spinner.fail("Failed to run command.");
|
|
32
|
-
err(result.error);
|
|
33
|
-
process.exit();
|
|
34
|
-
}
|
|
35
|
-
results.push(result);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (spinner)
|
|
40
|
-
spinner.stop();
|
|
41
|
-
if (numberOfCommands === 1)
|
|
42
|
-
return results[0];
|
|
43
|
-
return results;
|
|
44
|
-
}
|
|
45
|
-
function determineSpinner(options) {
|
|
46
|
-
if (!determineDebugMode(options))
|
|
47
|
-
return startSpinner(options?.spinnerText);
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
package/dist/spinner.d.ts
DELETED
package/dist/spinner.mjs
DELETED
package/dist/utilities.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, red, reset, strikethrough, underline, white, yellow } from 'kolorist';
|
package/dist/utilities.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, red, reset, strikethrough, underline, white, yellow } from "kolorist";
|