@contentstack/cli-config 1.4.11 → 1.4.13

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.4.11 linux-x64 node-v18.17.1
21
+ @contentstack/cli-config/1.4.13 linux-x64 node-v18.18.2
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -0,0 +1,36 @@
1
+ import { Command } from '@contentstack/cli-command';
2
+ import { ArgInput, Interfaces, LoggerService } from '@contentstack/cli-utilities';
3
+ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
4
+ export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
5
+ export declare abstract class BaseCommand<T extends typeof Command> extends Command {
6
+ logger: LoggerService;
7
+ protected args: Args<T>;
8
+ protected flags: Flags<T>;
9
+ static args: ArgInput<{
10
+ [arg: string]: any;
11
+ }>;
12
+ /**
13
+ * The `init` function initializes the command by parsing arguments and flags, registering search
14
+ * plugins, registering the configuration, and initializing the logger.
15
+ */
16
+ init(): Promise<void>;
17
+ /**
18
+ * The catch function is used to handle errors from a command, either by adding custom logic or
19
+ * returning the parent class error handling.
20
+ * @param err - The `err` parameter is of type `Error & { exitCode?: number }`. This means that it is
21
+ * an object that extends the `Error` class and may also have an optional property `exitCode` of type
22
+ * `number`.
23
+ * @returns The parent class error handling is being returned.
24
+ */
25
+ protected catch(err: Error & {
26
+ exitCode?: number;
27
+ }): Promise<any>;
28
+ /**
29
+ * The `finally` function is called after the `run` and `catch` functions, regardless of whether or not
30
+ * an error occurred.
31
+ * @param {Error | undefined} _ - The parameter "_" represents an error object or undefined.
32
+ * @returns The `finally` method is returning the result of calling the `finally` method of the
33
+ * superclass, which is a promise.
34
+ */
35
+ protected finally(_: Error | undefined): Promise<any>;
36
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseCommand = void 0;
4
+ const cli_command_1 = require("@contentstack/cli-command");
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
+ class BaseCommand extends cli_command_1.Command {
7
+ /**
8
+ * The `init` function initializes the command by parsing arguments and flags, registering search
9
+ * plugins, registering the configuration, and initializing the logger.
10
+ */
11
+ async init() {
12
+ await super.init();
13
+ // Init logger
14
+ this.logger = new cli_utilities_1.LoggerService(process.cwd(), 'cli-log');
15
+ }
16
+ /**
17
+ * The catch function is used to handle errors from a command, either by adding custom logic or
18
+ * returning the parent class error handling.
19
+ * @param err - The `err` parameter is of type `Error & { exitCode?: number }`. This means that it is
20
+ * an object that extends the `Error` class and may also have an optional property `exitCode` of type
21
+ * `number`.
22
+ * @returns The parent class error handling is being returned.
23
+ */
24
+ async catch(err) {
25
+ // add any custom logic to handle errors from the command
26
+ // or simply return the parent class error handling
27
+ return super.catch(err);
28
+ }
29
+ /**
30
+ * The `finally` function is called after the `run` and `catch` functions, regardless of whether or not
31
+ * an error occurred.
32
+ * @param {Error | undefined} _ - The parameter "_" represents an error object or undefined.
33
+ * @returns The `finally` method is returning the result of calling the `finally` method of the
34
+ * superclass, which is a promise.
35
+ */
36
+ async finally(_) {
37
+ // called after run and catch regardless of whether or not the command errored
38
+ return super.finally(_);
39
+ }
40
+ }
41
+ exports.BaseCommand = BaseCommand;
@@ -1,5 +1,5 @@
1
- import { Command } from '@contentstack/cli-command';
2
- export default class RegionGetCommand extends Command {
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class RegionGetCommand extends BaseCommand<typeof RegionGetCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  config: any;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_command_1 = require("@contentstack/cli-command");
4
3
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
- class RegionGetCommand extends cli_command_1.Command {
4
+ const base_command_1 = require("../../../base-command");
5
+ class RegionGetCommand extends base_command_1.BaseCommand {
6
6
  async run() {
7
7
  let currentRegion = this.region;
8
8
  if (!currentRegion) {
9
- cli_utilities_1.logger.error('No region set');
9
+ this.logger.error('No region set');
10
10
  cli_utilities_1.cliux.error('CLI_CONFIG_GET_REGION_NOT_FOUND');
11
11
  this.exit();
12
12
  }
@@ -14,6 +14,7 @@ class RegionGetCommand extends cli_command_1.Command {
14
14
  cli_utilities_1.cliux.print(`CDA HOST: ${currentRegion.cda}`);
15
15
  cli_utilities_1.cliux.print(`CMA HOST: ${currentRegion.cma}`);
16
16
  cli_utilities_1.cliux.print(`UI HOST: ${currentRegion.uiHost}`);
17
+ this.logger.error(`Currently using ${currentRegion.name} region`);
17
18
  }
18
19
  }
19
20
  exports.default = RegionGetCommand;
@@ -1,6 +1,6 @@
1
- import { Command } from '@contentstack/cli-command';
2
1
  import { FlagInput, ArgInput } from '@contentstack/cli-utilities';
3
- export default class RegionSetCommand extends Command {
2
+ import { BaseCommand } from '../../../base-command';
3
+ export default class RegionSetCommand extends BaseCommand<typeof RegionSetCommand> {
4
4
  config: any;
5
5
  static description: string;
6
6
  static flags: FlagInput;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_command_1 = require("@contentstack/cli-command");
4
3
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
4
  const utils_1 = require("../../../utils");
6
- class RegionSetCommand extends cli_command_1.Command {
5
+ const base_command_1 = require("../../../base-command");
6
+ class RegionSetCommand extends base_command_1.BaseCommand {
7
7
  async run() {
8
8
  const { args, flags: regionSetFlags } = await this.parse(RegionSetCommand);
9
9
  let cda = regionSetFlags.cda;
@@ -36,7 +36,7 @@ class RegionSetCommand extends cli_command_1.Command {
36
36
  cli_utilities_1.cliux.success(`UI HOST: ${customRegion.uiHost}`);
37
37
  }
38
38
  catch (error) {
39
- cli_utilities_1.logger.error('failed to set the region', error);
39
+ this.logger.error('failed to set the region', error);
40
40
  cli_utilities_1.cliux.error(`Failed to set region due to: ${error.message}`);
41
41
  }
42
42
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.11",
2
+ "version": "1.4.13",
3
3
  "commands": {
4
4
  "config:get:base-branch": {
5
5
  "id": "config:get:base-branch",
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.4.11",
4
+ "version": "1.4.13",
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.2.12",
25
- "@contentstack/cli-utilities": "~1.5.2",
24
+ "@contentstack/cli-command": "~1.2.14",
25
+ "@contentstack/cli-utilities": "~1.5.4",
26
26
  "chalk": "^4.0.0",
27
27
  "debug": "^4.1.1",
28
28
  "mkdirp": "^1.0.4",