@contentstack/cli-config 1.15.0 → 1.15.2

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 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.0 linux-x64 node-v22.17.1
21
+ @contentstack/cli-config/1.15.2 linux-x64 node-v22.19.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 file path where logs should be saved.
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 --path ./logs/app.log --show-console-logs
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 logLevel = currentLoggingConfig === null || currentLoggingConfig === void 0 ? void 0 : currentLoggingConfig.level;
10
- const logPath = currentLoggingConfig === null || currentLoggingConfig === void 0 ? void 0 : currentLoggingConfig.path;
11
- if (logLevel || logPath) {
12
- const logConfigList = [
13
- {
14
- 'Log Level': logLevel || 'Not set',
15
- 'Log Path': logPath || 'Not set',
16
- },
17
- ];
18
- const headers = [
19
- { value: 'Log Level' },
20
- { value: 'Log Path' },
21
- ];
22
- cli_utilities_1.cliux.table(headers, logConfigList);
23
- }
24
- else {
25
- cli_utilities_1.cliux.print(`error: ${cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_NO_CONFIG')}`, { color: 'red' });
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,38 @@
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 utils_1 = require("../../../utils");
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
- let logLevel = flags['level'];
11
- let logPath = flags['path'];
12
- const showConsoleLogs = flags['show-console-logs'];
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 (!logPath) {
18
- logPath = await utils_1.interactive.askLogPath();
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['show-console-logs'] = 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
- cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_LEVEL_SET', logLevel));
28
- cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_PATH_SET', logPath));
29
- cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_CONSOLE_SET', String(showConsoleLogs)));
30
- cli_utilities_1.cliux.print(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_SET_SUCCESS'), { color: 'green' });
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['show-console-logs'])));
36
+ }
31
37
  }
32
38
  catch (error) {
33
39
  cli_utilities_1.cliux.error('error', error);
@@ -37,21 +43,26 @@ class LogSetCommand extends cli_command_1.Command {
37
43
  exports.default = LogSetCommand;
38
44
  LogSetCommand.description = 'Set logging configuration for CLI';
39
45
  LogSetCommand.flags = {
40
- 'level': cli_utilities_1.flags.string({
41
- description: 'Set the log level for the CLI.',
46
+ level: cli_utilities_1.flags.string({
47
+ description: 'Set the log level for the CLI. Defaults to "info" if not specified.',
42
48
  options: ['debug', 'info', 'warn', 'error'],
43
49
  }),
44
- 'path': cli_utilities_1.flags.string({
45
- description: 'Specify the file path where logs should be saved.',
50
+ path: cli_utilities_1.flags.string({
51
+ description: 'Specify the directory path where logs should be saved. Supports both relative and absolute paths. Defaults to ~/.contentstack/logs if not specified.',
46
52
  }),
47
53
  'show-console-logs': cli_utilities_1.flags.boolean({
48
54
  description: 'Enable console logging.',
49
55
  allowNo: true,
50
56
  default: false,
51
- })
57
+ }),
52
58
  };
53
59
  LogSetCommand.examples = [
54
60
  'csdx config:set:log',
55
- 'csdx config:set:log --level debug --path ./logs/app.log --show-console-logs',
61
+ 'csdx config:set:log --level debug',
62
+ 'csdx config:set:log --path ./logs',
63
+ 'csdx config:set:log --level debug --path ./logs --show-console-logs',
56
64
  'csdx config:set:log --no-show-console-logs',
65
+ 'csdx config:set:log --level warn --show-console-logs',
66
+ 'csdx config:set:log --path ~/custom/logs',
67
+ 'csdx config:set:log --path /var/log/contentstack',
57
68
  ];
@@ -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['show-console-logs']) !== 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;
@@ -1,3 +1,95 @@
1
+ declare const regions: {
2
+ NA: {
3
+ name: string;
4
+ cma: string;
5
+ cda: string;
6
+ uiHost: string;
7
+ developerHubUrl: string;
8
+ launchHubUrl: string;
9
+ personalizeUrl: string;
10
+ };
11
+ 'AWS-NA': {
12
+ name: string;
13
+ cma: string;
14
+ cda: string;
15
+ uiHost: string;
16
+ developerHubUrl: string;
17
+ launchHubUrl: string;
18
+ personalizeUrl: string;
19
+ };
20
+ EU: {
21
+ name: string;
22
+ cma: string;
23
+ cda: string;
24
+ uiHost: string;
25
+ developerHubUrl: string;
26
+ launchHubUrl: string;
27
+ personalizeUrl: string;
28
+ };
29
+ 'AWS-EU': {
30
+ name: string;
31
+ cma: string;
32
+ cda: string;
33
+ uiHost: string;
34
+ developerHubUrl: string;
35
+ launchHubUrl: string;
36
+ personalizeUrl: string;
37
+ };
38
+ AU: {
39
+ name: string;
40
+ cma: string;
41
+ cda: string;
42
+ uiHost: string;
43
+ developerHubUrl: string;
44
+ launchHubUrl: string;
45
+ personalizeUrl: string;
46
+ };
47
+ 'AWS-AU': {
48
+ name: string;
49
+ cma: string;
50
+ cda: string;
51
+ uiHost: string;
52
+ developerHubUrl: string;
53
+ launchHubUrl: string;
54
+ personalizeUrl: string;
55
+ };
56
+ 'AZURE-NA': {
57
+ name: string;
58
+ cma: string;
59
+ cda: string;
60
+ uiHost: string;
61
+ developerHubUrl: string;
62
+ launchHubUrl: string;
63
+ personalizeUrl: string;
64
+ };
65
+ 'AZURE-EU': {
66
+ name: string;
67
+ cma: string;
68
+ cda: string;
69
+ uiHost: string;
70
+ developerHubUrl: string;
71
+ launchHubUrl: string;
72
+ personalizeUrl: string;
73
+ };
74
+ 'GCP-NA': {
75
+ name: string;
76
+ cma: string;
77
+ cda: string;
78
+ uiHost: string;
79
+ developerHubUrl: string;
80
+ launchHubUrl: string;
81
+ personalizeUrl: string;
82
+ };
83
+ 'GCP-EU': {
84
+ name: string;
85
+ cma: string;
86
+ cda: string;
87
+ uiHost: string;
88
+ developerHubUrl: string;
89
+ launchHubUrl: string;
90
+ personalizeUrl: string;
91
+ };
92
+ };
1
93
  declare class UserConfig {
2
94
  /**
3
95
  *
@@ -46,5 +138,6 @@ declare class UserConfig {
46
138
  launchHubUrl: any;
47
139
  };
48
140
  }
141
+ export { regions };
49
142
  declare const _default: UserConfig;
50
143
  export default _default;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.regions = void 0;
3
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
4
5
  function validURL(str) {
5
6
  const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol (http or https)
@@ -105,6 +106,7 @@ const regions = {
105
106
  personalizeUrl: 'https://gcp-eu-personalize-api.contentstack.com',
106
107
  },
107
108
  };
109
+ exports.regions = regions;
108
110
  class UserConfig {
109
111
  /**
110
112
  *
@@ -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 --path ./logs/app.log --show-console-logs",
330
- "csdx config:set:log --no-show-console-logs"
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 file path where logs should be saved.",
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.0"
551
+ "version": "1.15.2"
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.0",
4
+ "version": "1.15.2",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "npm run clean && npm run compile",
@@ -21,8 +21,8 @@
21
21
  "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
22
22
  },
23
23
  "dependencies": {
24
- "@contentstack/cli-command": "~1.6.0",
25
- "@contentstack/cli-utilities": "~1.13.1",
24
+ "@contentstack/cli-command": "~1.6.1",
25
+ "@contentstack/cli-utilities": "~1.14.1",
26
26
  "@oclif/core": "^4.3.0",
27
27
  "@oclif/plugin-help": "^6.2.28",
28
28
  "lodash": "^4.17.21"