@contentstack/cli-config 1.16.1 → 1.17.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Contentstack
3
+ Copyright (c) 2026 Contentstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.16.1 linux-x64 node-v22.21.1
21
+ @contentstack/cli-config/1.17.0 linux-x64 node-v22.21.1
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -1,9 +1,18 @@
1
1
  import { Command } from '@contentstack/cli-command';
2
- import { ArgInput, Interfaces, LoggerService } from '@contentstack/cli-utilities';
2
+ import { ArgInput, Interfaces } from '@contentstack/cli-utilities';
3
3
  export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
4
4
  export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
5
5
  export declare abstract class BaseCommand<T extends typeof Command> extends Command {
6
- logger: LoggerService;
6
+ contextDetails: {
7
+ command: string;
8
+ module: string;
9
+ userId: string;
10
+ email: string;
11
+ sessionId: string;
12
+ apiKey: string;
13
+ orgId: string;
14
+ authenticationMethod: string;
15
+ };
7
16
  protected args: Args<T>;
8
17
  protected flags: Flags<T>;
9
18
  static args: ArgInput<{
@@ -9,9 +9,10 @@ class BaseCommand extends cli_command_1.Command {
9
9
  * plugins, registering the configuration, and initializing the logger.
10
10
  */
11
11
  async init() {
12
+ var _a, _b;
12
13
  await super.init();
13
- // Init logger
14
- this.logger = new cli_utilities_1.LoggerService(process.cwd(), 'cli-log');
14
+ // Init logger context
15
+ this.contextDetails = Object.assign({}, (0, cli_utilities_1.createLogContext)(((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'config', '', cli_utilities_1.configHandler.get('authenticationMethod')));
15
16
  }
16
17
  /**
17
18
  * The catch function is used to handle errors from a command, either by adding custom logic or
@@ -23,7 +23,7 @@ class BranchGetCommand extends cli_command_1.Command {
23
23
  }
24
24
  }
25
25
  catch (error) {
26
- cli_utilities_1.cliux.error('Error', error);
26
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-get-base-branch' });
27
27
  }
28
28
  }
29
29
  }
@@ -26,7 +26,7 @@ class GetEarlyAccessHeaderCommand extends cli_command_1.Command {
26
26
  }
27
27
  }
28
28
  catch (error) {
29
- this.log('Unable to retrieve the Early Access header config', error instanceof Error ? error.message : error);
29
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-get-early-access-header' });
30
30
  }
31
31
  }
32
32
  }
@@ -29,7 +29,7 @@ class LogGetCommand extends cli_command_1.Command {
29
29
  });
30
30
  }
31
31
  catch (error) {
32
- cli_utilities_1.cliux.error('Error', error);
32
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-get-log' });
33
33
  }
34
34
  }
35
35
  }
@@ -30,7 +30,7 @@ class RateLimitGetCommand extends cli_command_1.Command {
30
30
  cli_utilities_1.cliux.table(headers, tableData);
31
31
  }
32
32
  catch (error) {
33
- this.log('Unable to retrieve the rate limits configuration', error instanceof Error ? error.message : error);
33
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-get-rate-limit' });
34
34
  }
35
35
  }
36
36
  }
@@ -6,7 +6,7 @@ class RegionGetCommand extends base_command_1.BaseCommand {
6
6
  async run() {
7
7
  let currentRegion = this.region;
8
8
  if (!currentRegion) {
9
- this.logger.error('No region is set.');
9
+ cli_utilities_1.log.error('No region is set.', this.contextDetails);
10
10
  cli_utilities_1.cliux.error('CLI_CONFIG_GET_REGION_NOT_FOUND');
11
11
  this.exit();
12
12
  }
@@ -17,7 +17,7 @@ class RegionGetCommand extends base_command_1.BaseCommand {
17
17
  cli_utilities_1.cliux.print(`Developer Hub URL: ${currentRegion.developerHubUrl}`);
18
18
  cli_utilities_1.cliux.print(`Launch URL: ${currentRegion.launchHubUrl}`);
19
19
  cli_utilities_1.cliux.print(`Personalize URL: ${currentRegion.personalizeUrl}`);
20
- this.logger.error(`Currently using ${currentRegion.name} region`);
20
+ cli_utilities_1.log.info(`Currently using ${currentRegion.name} region`, this.contextDetails);
21
21
  }
22
22
  }
23
23
  exports.default = RegionGetCommand;
@@ -36,7 +36,7 @@ class RemoveBranchConfigCommand extends cli_command_1.Command {
36
36
  }
37
37
  }
38
38
  catch (error) {
39
- cli_utilities_1.cliux.error('error', error);
39
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-remove-base-branch' });
40
40
  }
41
41
  }
42
42
  }
@@ -24,7 +24,7 @@ class RemoveEarlyAccessHeader extends cli_command_1.Command {
24
24
  cli_utilities_1.cliux.success(`Early Access header has been successfully removed`);
25
25
  }
26
26
  catch (error) {
27
- this.log('Unable to remove the Early Access header config', error instanceof Error ? error.message : error);
27
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-remove-early-access-header' });
28
28
  }
29
29
  }
30
30
  }
@@ -33,7 +33,10 @@ RemoveEarlyAccessHeader.description = 'Remove Early Access header';
33
33
  RemoveEarlyAccessHeader.aliases = ['config:remove:ea-header'];
34
34
  RemoveEarlyAccessHeader.flags = {
35
35
  'header-alias': cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header alias name.' }),
36
- yes: cli_utilities_1.flags.boolean({ char: 'y', description: '(optional) Force the removal of Early Access header configuration by skipping the confirmation.' }),
36
+ yes: cli_utilities_1.flags.boolean({
37
+ char: 'y',
38
+ description: '(optional) Force the removal of Early Access header configuration by skipping the confirmation.',
39
+ }),
37
40
  };
38
41
  RemoveEarlyAccessHeader.examples = [
39
42
  '$ <%= config.bin %> <%= command.id %>',
@@ -20,7 +20,7 @@ class RateLimitRemoveCommand extends cli_command_1.Command {
20
20
  cli_utilities_1.cliux.print(`Rate limit entry for organization UID ${org} has been removed.`, { color: 'green' });
21
21
  }
22
22
  catch (error) {
23
- this.log('Unable to remove the rate limit entry', error instanceof Error ? error.message : error);
23
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-remove-rate-limit' });
24
24
  }
25
25
  }
26
26
  }
@@ -21,7 +21,7 @@ class BranchSetCommand extends cli_command_1.Command {
21
21
  cli_utilities_1.cliux.success(`Base branch configuration for stack-api-key: ${apiKey} and branch: ${baseBranch} set successfully`);
22
22
  }
23
23
  catch (error) {
24
- cli_utilities_1.cliux.error('error', error);
24
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-set-base-branch' });
25
25
  }
26
26
  }
27
27
  }
@@ -18,7 +18,7 @@ class SetEarlyAccessHeaderCommand extends cli_command_1.Command {
18
18
  cli_utilities_1.cliux.success(`Early Access header has been successfully set`);
19
19
  }
20
20
  catch (error) {
21
- this.log('Unable to set the Early Access header config', error instanceof Error ? error.message : error);
21
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-set-early-access-header' });
22
22
  }
23
23
  }
24
24
  }
@@ -36,7 +36,7 @@ class LogSetCommand extends cli_command_1.Command {
36
36
  }
37
37
  }
38
38
  catch (error) {
39
- cli_utilities_1.cliux.error('error', error);
39
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'config-set-log' });
40
40
  }
41
41
  }
42
42
  }
@@ -52,6 +52,7 @@ class SetRateLimitCommand extends base_command_1.BaseCommand {
52
52
  await limitHandler.setRateLimit(config);
53
53
  }
54
54
  catch (error) {
55
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-set-rate-limit' }));
55
56
  if (error === null || error === void 0 ? void 0 : error.message) {
56
57
  cli_utilities_1.cliux.error(error.message);
57
58
  }
@@ -65,8 +65,7 @@ class RegionSetCommand extends base_command_1.BaseCommand {
65
65
  cli_utilities_1.cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
66
66
  }
67
67
  catch (error) {
68
- this.logger.error('failed to set the region', error);
69
- cli_utilities_1.cliux.error(`Failed to set region due to: ${error.message}`);
68
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-set-region' }));
70
69
  }
71
70
  }
72
71
  else if (['NA', 'EU', 'AU', 'AWS-NA', 'AWS-EU', 'AWS-AU', 'AZURE-NA', 'AZURE-EU', 'GCP-NA', 'GCP-EU'].includes(selectedRegion)) {
@@ -556,5 +556,5 @@
556
556
  ]
557
557
  }
558
558
  },
559
- "version": "1.16.1"
559
+ "version": "1.17.0"
560
560
  }
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.16.1",
4
+ "version": "1.17.0",
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.7.0",
25
- "@contentstack/cli-utilities": "~1.15.0",
24
+ "@contentstack/cli-command": "~1.7.1",
25
+ "@contentstack/cli-utilities": "~1.16.0",
26
26
  "@oclif/core": "^4.3.0",
27
27
  "@oclif/plugin-help": "^6.2.28",
28
28
  "lodash": "^4.17.21"