esa-cli 1.0.3-beta.2 → 1.0.3-beta.4
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.js +9 -0
- package/dist/libs/logger.js +3 -0
- package/dist/utils/command.js +20 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import chalk from 'chalk';
|
|
11
11
|
import yargs from 'yargs';
|
|
12
12
|
import { hideBin } from 'yargs/helpers';
|
|
13
|
+
import logger from './libs/logger.js';
|
|
13
14
|
import commit from './commands/commit/index.js';
|
|
14
15
|
import config from './commands/config.js';
|
|
15
16
|
import deploy from './commands/deploy/index.js';
|
|
@@ -40,6 +41,9 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
40
41
|
.wrap(null)
|
|
41
42
|
.help()
|
|
42
43
|
.middleware((argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
if (argv.debug) {
|
|
45
|
+
logger.setLogLevel('debug');
|
|
46
|
+
}
|
|
43
47
|
try {
|
|
44
48
|
// Pass current command (first positional) so version check can decide prompting behavior
|
|
45
49
|
yield checkCLIVersion((argv._ && argv._[0] ? String(argv._[0]) : ''));
|
|
@@ -57,6 +61,11 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
57
61
|
.options('help', {
|
|
58
62
|
describe: t('main_help_describe').d('Show help'),
|
|
59
63
|
alias: 'h'
|
|
64
|
+
})
|
|
65
|
+
.options('debug', {
|
|
66
|
+
describe: t('dev_option_debugger').d('Output debug logs'),
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
default: false
|
|
60
69
|
});
|
|
61
70
|
esa.command('*', false, () => { }, (args) => {
|
|
62
71
|
if (args._.length > 0) {
|
package/dist/libs/logger.js
CHANGED
package/dist/utils/command.js
CHANGED
|
@@ -7,14 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { spawn } from 'child_process';
|
|
11
10
|
import { cancel, spinner } from '@clack/prompts';
|
|
12
11
|
import chalk from 'chalk';
|
|
12
|
+
import spawn from 'cross-spawn';
|
|
13
|
+
import logger from '../libs/logger.js';
|
|
13
14
|
/**
|
|
14
15
|
* Execute a shell command with rich options (spinner, capture, env, cwd).
|
|
15
16
|
*/
|
|
16
17
|
export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_1, ...args_1], void 0, function* (command, options = {}) {
|
|
17
|
-
const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage } = options;
|
|
18
|
+
const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage, debug = logger.isDebug } = options;
|
|
18
19
|
// Determine stdio mode based on options
|
|
19
20
|
// If realtimeOutput is true, we need to pipe to capture and display output in real-time
|
|
20
21
|
// If spinner is used without realtimeOutput, pipe to avoid TTY contention
|
|
@@ -140,6 +141,23 @@ export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_
|
|
|
140
141
|
if (stderr)
|
|
141
142
|
process.stderr.write(stderr);
|
|
142
143
|
}
|
|
144
|
+
if (debug) {
|
|
145
|
+
console.error(chalk.red('\n--- DEBUG INFO ---'));
|
|
146
|
+
console.error(chalk.red(`Command: ${command.join(' ')}`));
|
|
147
|
+
if (cwd)
|
|
148
|
+
console.error(chalk.red(`CWD: ${cwd}`));
|
|
149
|
+
if (stdout)
|
|
150
|
+
console.error(chalk.red(`Stdout:\n${stdout}`));
|
|
151
|
+
if (stderr)
|
|
152
|
+
console.error(chalk.red(`Stderr:\n${stderr}`));
|
|
153
|
+
if (e instanceof Error && e.stack) {
|
|
154
|
+
console.error(chalk.red(`Stack:\n${e.stack}`));
|
|
155
|
+
}
|
|
156
|
+
else if (e && typeof e === 'object') {
|
|
157
|
+
console.error(chalk.red(`Error Object:\n${JSON.stringify(e, null, 2)}`));
|
|
158
|
+
}
|
|
159
|
+
console.error(chalk.red('------------------\n'));
|
|
160
|
+
}
|
|
143
161
|
if (errorMessage) {
|
|
144
162
|
cancel(errorMessage);
|
|
145
163
|
}
|