@contentstack/cli-config 1.15.1 → 1.15.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/README.md +15 -4
- package/lib/commands/config/get/log.js +21 -18
- package/lib/commands/config/set/log.js +37 -25
- package/lib/utils/log-config-defaults.d.ts +21 -0
- package/lib/utils/log-config-defaults.js +38 -0
- package/oclif.manifest.json +10 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
|
|
|
18
18
|
$ csdx COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ csdx (--version)
|
|
21
|
-
@contentstack/cli-config/1.15.
|
|
21
|
+
@contentstack/cli-config/1.15.3 linux-x64 node-v22.20.0
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -329,9 +329,10 @@ USAGE
|
|
|
329
329
|
$ csdx config:set:log [--level debug|info|warn|error] [--path <value>] [--show-console-logs]
|
|
330
330
|
|
|
331
331
|
FLAGS
|
|
332
|
-
--level=<option> Set the log level for the CLI.
|
|
332
|
+
--level=<option> Set the log level for the CLI. Defaults to "info" if not specified.
|
|
333
333
|
<options: debug|info|warn|error>
|
|
334
|
-
--path=<value> Specify the
|
|
334
|
+
--path=<value> Specify the directory path where logs should be saved. Supports both relative and absolute
|
|
335
|
+
paths. Defaults to ~/.contentstack/logs if not specified.
|
|
335
336
|
--[no-]show-console-logs Enable console logging.
|
|
336
337
|
|
|
337
338
|
DESCRIPTION
|
|
@@ -340,9 +341,19 @@ DESCRIPTION
|
|
|
340
341
|
EXAMPLES
|
|
341
342
|
$ csdx config:set:log
|
|
342
343
|
|
|
343
|
-
$ csdx config:set:log --level debug
|
|
344
|
+
$ csdx config:set:log --level debug
|
|
345
|
+
|
|
346
|
+
$ csdx config:set:log --path ./logs
|
|
347
|
+
|
|
348
|
+
$ csdx config:set:log --level debug --path ./logs --show-console-logs
|
|
344
349
|
|
|
345
350
|
$ csdx config:set:log --no-show-console-logs
|
|
351
|
+
|
|
352
|
+
$ csdx config:set:log --level warn --show-console-logs
|
|
353
|
+
|
|
354
|
+
$ csdx config:set:log --path ~/custom/logs
|
|
355
|
+
|
|
356
|
+
$ csdx config:set:log --path /var/log/contentstack
|
|
346
357
|
```
|
|
347
358
|
|
|
348
359
|
_See code: [src/commands/config/set/log.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/log.ts)_
|
|
@@ -2,28 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const cli_command_1 = require("@contentstack/cli-command");
|
|
4
4
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
const log_config_defaults_1 = require("../../../utils/log-config-defaults");
|
|
5
6
|
class LogGetCommand extends cli_command_1.Command {
|
|
6
7
|
async run() {
|
|
7
8
|
try {
|
|
8
9
|
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
const effectiveConfig = (0, log_config_defaults_1.getEffectiveLogConfig)(currentLoggingConfig);
|
|
11
|
+
const logConfigList = [
|
|
12
|
+
{
|
|
13
|
+
Setting: 'Log Level',
|
|
14
|
+
Value: effectiveConfig.level,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
Setting: 'Log Path',
|
|
18
|
+
Value: effectiveConfig.path,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
Setting: 'Show Console Logs',
|
|
22
|
+
Value: effectiveConfig.showConsoleLogs.toString(),
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
const headers = [{ value: 'Setting' }, { value: 'Value' }];
|
|
26
|
+
cli_utilities_1.cliux.table(headers, logConfigList);
|
|
27
|
+
cli_utilities_1.cliux.print('\nNote: Absolute paths are displayed. Relative paths are resolved from current working directory.', {
|
|
28
|
+
color: 'dim',
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
catch (error) {
|
|
29
32
|
cli_utilities_1.cliux.error('error', error);
|
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const cli_command_1 = require("@contentstack/cli-command");
|
|
4
4
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
-
const
|
|
5
|
+
const log_config_defaults_1 = require("../../../utils/log-config-defaults");
|
|
6
|
+
const path = require("path");
|
|
6
7
|
class LogSetCommand extends cli_command_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
try {
|
|
9
10
|
const { flags } = await this.parse(LogSetCommand);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Interactive prompts if not passed via flags
|
|
14
|
-
if (!logLevel) {
|
|
15
|
-
logLevel = await utils_1.interactive.askLogLevel();
|
|
11
|
+
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
12
|
+
if (flags['level'] !== undefined) {
|
|
13
|
+
currentLoggingConfig.level = flags['level'];
|
|
16
14
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
15
|
+
if (flags['path'] !== undefined) {
|
|
16
|
+
// Convert to absolute path and ensure it's a directory
|
|
17
|
+
let resolvedPath = (0, log_config_defaults_1.resolveLogPath)(flags['path']);
|
|
18
|
+
const pathExt = path.extname(resolvedPath);
|
|
19
|
+
if (pathExt && pathExt.length > 0) {
|
|
20
|
+
resolvedPath = path.dirname(resolvedPath);
|
|
21
|
+
}
|
|
22
|
+
currentLoggingConfig.path = resolvedPath;
|
|
23
|
+
}
|
|
24
|
+
if (flags['show-console-logs'] !== undefined) {
|
|
25
|
+
currentLoggingConfig['showConsoleLogs'] = flags['show-console-logs'];
|
|
19
26
|
}
|
|
20
|
-
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
21
|
-
if (logLevel)
|
|
22
|
-
currentLoggingConfig.level = logLevel;
|
|
23
|
-
if (logPath)
|
|
24
|
-
currentLoggingConfig.path = logPath;
|
|
25
|
-
currentLoggingConfig['show-console-logs'] = showConsoleLogs;
|
|
26
27
|
cli_utilities_1.configHandler.set('log', currentLoggingConfig);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (flags['level'] !== undefined) {
|
|
29
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_LEVEL_SET', currentLoggingConfig.level));
|
|
30
|
+
}
|
|
31
|
+
if (flags['path'] !== undefined) {
|
|
32
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_PATH_SET', currentLoggingConfig.path));
|
|
33
|
+
}
|
|
34
|
+
if (flags['show-console-logs'] !== undefined) {
|
|
35
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_CONSOLE_SET', String(currentLoggingConfig['showConsoleLogs'])));
|
|
36
|
+
}
|
|
37
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_SET_SUCCESS'));
|
|
31
38
|
}
|
|
32
39
|
catch (error) {
|
|
33
40
|
cli_utilities_1.cliux.error('error', error);
|
|
@@ -37,21 +44,26 @@ class LogSetCommand extends cli_command_1.Command {
|
|
|
37
44
|
exports.default = LogSetCommand;
|
|
38
45
|
LogSetCommand.description = 'Set logging configuration for CLI';
|
|
39
46
|
LogSetCommand.flags = {
|
|
40
|
-
|
|
41
|
-
description: 'Set the log level for the CLI.',
|
|
47
|
+
level: cli_utilities_1.flags.string({
|
|
48
|
+
description: 'Set the log level for the CLI. Defaults to "info" if not specified.',
|
|
42
49
|
options: ['debug', 'info', 'warn', 'error'],
|
|
43
50
|
}),
|
|
44
|
-
|
|
45
|
-
description: 'Specify the
|
|
51
|
+
path: cli_utilities_1.flags.string({
|
|
52
|
+
description: 'Specify the directory path where logs should be saved. Supports both relative and absolute paths. Defaults to ~/.contentstack/logs if not specified.',
|
|
46
53
|
}),
|
|
47
54
|
'show-console-logs': cli_utilities_1.flags.boolean({
|
|
48
55
|
description: 'Enable console logging.',
|
|
49
56
|
allowNo: true,
|
|
50
57
|
default: false,
|
|
51
|
-
})
|
|
58
|
+
}),
|
|
52
59
|
};
|
|
53
60
|
LogSetCommand.examples = [
|
|
54
61
|
'csdx config:set:log',
|
|
55
|
-
'csdx config:set:log --level debug
|
|
62
|
+
'csdx config:set:log --level debug',
|
|
63
|
+
'csdx config:set:log --path ./logs',
|
|
64
|
+
'csdx config:set:log --level debug --path ./logs --show-console-logs',
|
|
56
65
|
'csdx config:set:log --no-show-console-logs',
|
|
66
|
+
'csdx config:set:log --level warn --show-console-logs',
|
|
67
|
+
'csdx config:set:log --path ~/custom/logs',
|
|
68
|
+
'csdx config:set:log --path /var/log/contentstack',
|
|
57
69
|
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const LOG_CONFIG_DEFAULTS: {
|
|
2
|
+
readonly LEVEL: "info";
|
|
3
|
+
readonly PATH: string;
|
|
4
|
+
readonly SHOW_CONSOLE_LOGS: false;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a log path to an absolute path
|
|
8
|
+
* @param logPath - The path to resolve
|
|
9
|
+
* @returns Absolute path
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveLogPath(logPath: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Gets the effective log configuration with defaults applied
|
|
14
|
+
* @param currentConfig - Current configuration from config handler
|
|
15
|
+
* @returns Configuration with defaults applied
|
|
16
|
+
*/
|
|
17
|
+
export declare function getEffectiveLogConfig(currentConfig?: any): {
|
|
18
|
+
level: any;
|
|
19
|
+
path: string;
|
|
20
|
+
showConsoleLogs: any;
|
|
21
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEffectiveLogConfig = exports.resolveLogPath = exports.LOG_CONFIG_DEFAULTS = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
exports.LOG_CONFIG_DEFAULTS = {
|
|
7
|
+
LEVEL: 'info',
|
|
8
|
+
PATH: path.join(os.homedir(), '.contentstack', 'logs'),
|
|
9
|
+
SHOW_CONSOLE_LOGS: false,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a log path to an absolute path
|
|
13
|
+
* @param logPath - The path to resolve
|
|
14
|
+
* @returns Absolute path
|
|
15
|
+
*/
|
|
16
|
+
function resolveLogPath(logPath) {
|
|
17
|
+
if (!logPath)
|
|
18
|
+
return exports.LOG_CONFIG_DEFAULTS.PATH;
|
|
19
|
+
return path.isAbsolute(logPath) ? logPath : path.resolve(process.cwd(), logPath);
|
|
20
|
+
}
|
|
21
|
+
exports.resolveLogPath = resolveLogPath;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the effective log configuration with defaults applied
|
|
24
|
+
* @param currentConfig - Current configuration from config handler
|
|
25
|
+
* @returns Configuration with defaults applied
|
|
26
|
+
*/
|
|
27
|
+
function getEffectiveLogConfig(currentConfig = {}) {
|
|
28
|
+
var _a;
|
|
29
|
+
const logLevel = (currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.level) || exports.LOG_CONFIG_DEFAULTS.LEVEL;
|
|
30
|
+
const logPath = resolveLogPath((currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.path) || exports.LOG_CONFIG_DEFAULTS.PATH);
|
|
31
|
+
const showConsoleLogs = (_a = currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig['showConsoleLogs']) !== null && _a !== void 0 ? _a : exports.LOG_CONFIG_DEFAULTS.SHOW_CONSOLE_LOGS;
|
|
32
|
+
return {
|
|
33
|
+
level: logLevel,
|
|
34
|
+
path: logPath,
|
|
35
|
+
showConsoleLogs,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.getEffectiveLogConfig = getEffectiveLogConfig;
|
package/oclif.manifest.json
CHANGED
|
@@ -326,12 +326,17 @@
|
|
|
326
326
|
"description": "Set logging configuration for CLI",
|
|
327
327
|
"examples": [
|
|
328
328
|
"csdx config:set:log",
|
|
329
|
-
"csdx config:set:log --level debug
|
|
330
|
-
"csdx config:set:log --
|
|
329
|
+
"csdx config:set:log --level debug",
|
|
330
|
+
"csdx config:set:log --path ./logs",
|
|
331
|
+
"csdx config:set:log --level debug --path ./logs --show-console-logs",
|
|
332
|
+
"csdx config:set:log --no-show-console-logs",
|
|
333
|
+
"csdx config:set:log --level warn --show-console-logs",
|
|
334
|
+
"csdx config:set:log --path ~/custom/logs",
|
|
335
|
+
"csdx config:set:log --path /var/log/contentstack"
|
|
331
336
|
],
|
|
332
337
|
"flags": {
|
|
333
338
|
"level": {
|
|
334
|
-
"description": "Set the log level for the CLI.",
|
|
339
|
+
"description": "Set the log level for the CLI. Defaults to \"info\" if not specified.",
|
|
335
340
|
"name": "level",
|
|
336
341
|
"hasDynamicHelp": false,
|
|
337
342
|
"multiple": false,
|
|
@@ -344,7 +349,7 @@
|
|
|
344
349
|
"type": "option"
|
|
345
350
|
},
|
|
346
351
|
"path": {
|
|
347
|
-
"description": "Specify the
|
|
352
|
+
"description": "Specify the directory path where logs should be saved. Supports both relative and absolute paths. Defaults to ~/.contentstack/logs if not specified.",
|
|
348
353
|
"name": "path",
|
|
349
354
|
"hasDynamicHelp": false,
|
|
350
355
|
"multiple": false,
|
|
@@ -543,5 +548,5 @@
|
|
|
543
548
|
]
|
|
544
549
|
}
|
|
545
550
|
},
|
|
546
|
-
"version": "1.15.
|
|
551
|
+
"version": "1.15.3"
|
|
547
552
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-config",
|
|
3
3
|
"description": "Contentstack CLI plugin for configuration",
|
|
4
|
-
"version": "1.15.
|
|
4
|
+
"version": "1.15.3",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "npm run clean && npm run compile",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@contentstack/cli-command": "~1.6.1",
|
|
25
|
-
"@contentstack/cli-utilities": "~1.
|
|
25
|
+
"@contentstack/cli-utilities": "~1.15.0",
|
|
26
26
|
"@oclif/core": "^4.3.0",
|
|
27
27
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
28
|
"lodash": "^4.17.21"
|