@contentstack/cli-config 1.2.0 → 1.3.1

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
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-config
16
16
  $ csdx COMMAND
17
17
  running command...
18
18
  $ csdx (--version)
19
- @contentstack/cli-config/1.2.0 linux-x64 node-v16.19.1
19
+ @contentstack/cli-config/1.3.1 linux-x64 node-v16.20.0
20
20
  $ csdx --help [COMMAND]
21
21
  USAGE
22
22
  $ csdx COMMAND
@@ -51,17 +51,18 @@ Set region for CLI
51
51
 
52
52
  ```
53
53
  USAGE
54
- $ csdx config:set:region [REGION] [-d <value> -m <value> -n <value>]
54
+ $ csdx config:set:region [REGION] [-d <value> -m <value> --ui-host <value> -n <value>]
55
55
 
56
56
  ARGUMENTS
57
57
  REGION Name for the region
58
58
 
59
59
  FLAGS
60
- -d, --cda=<value> Custom host to set for content delivery API, if this flag is added then cma and name flags are
61
- required
62
- -m, --cma=<value> Custom host to set for content management API, , if this flag is added then cda and name flags are
63
- required
64
- -n, --name=<value> Name for the region, if this flag is added then cda and cma flags are required
60
+ -d, --cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host and name
61
+ flags are required
62
+ -m, --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host and name
63
+ flags are required
64
+ -n, --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are required
65
+ --ui-host=<value> Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are required
65
66
 
66
67
  DESCRIPTION
67
68
  Set region for CLI
@@ -71,9 +72,9 @@ EXAMPLES
71
72
 
72
73
  $ csdx config:set:region NA
73
74
 
74
- $ csdx config:set:region NA
75
+ $ csdx config:set:region EU
75
76
 
76
- $ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --name "India"
77
+ $ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India"
77
78
  ```
78
79
 
79
80
  _See code: [src/commands/config/set/region.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/region.ts)_
@@ -13,6 +13,7 @@ class RegionGetCommand extends cli_command_1.Command {
13
13
  cli_utilities_1.cliux.print(`Currently using ${currentRegion.name} region`);
14
14
  cli_utilities_1.cliux.print(`CDA HOST: ${currentRegion.cda}`);
15
15
  cli_utilities_1.cliux.print(`CMA HOST: ${currentRegion.cma}`);
16
+ cli_utilities_1.cliux.print(`UI HOST: ${currentRegion.uiHost}`);
16
17
  }
17
18
  }
18
19
  exports.default = RegionGetCommand;
@@ -9,8 +9,9 @@ class RegionSetCommand extends cli_command_1.Command {
9
9
  let cda = regionSetFlags.cda;
10
10
  let cma = regionSetFlags.cma;
11
11
  let name = regionSetFlags.name;
12
+ let uiHost = regionSetFlags['ui-host'];
12
13
  let selectedRegion = args.region;
13
- if (!(cda && cma && name) && !selectedRegion) {
14
+ if (!(cda && cma && uiHost && name) && !selectedRegion) {
14
15
  selectedRegion = await utils_1.interactive.askRegions();
15
16
  }
16
17
  if (selectedRegion === 'custom') {
@@ -18,18 +19,21 @@ class RegionSetCommand extends cli_command_1.Command {
18
19
  name = selectedCustomRegion.name;
19
20
  cda = selectedCustomRegion.cda;
20
21
  cma = selectedCustomRegion.cma;
22
+ uiHost = selectedCustomRegion.uiHost;
21
23
  }
22
24
  else if (selectedRegion === 'exit') {
23
25
  this.exit();
24
26
  }
25
27
  // Custom flag will get first priority over region argument
26
- if (cda && cma && name) {
28
+ if (cda && cma && uiHost && name) {
27
29
  try {
28
- let customRegion = { cda, cma, name };
30
+ let customRegion = { cda, cma, uiHost, name };
29
31
  customRegion = utils_1.regionHandler.setCustomRegion(customRegion);
32
+ await cli_utilities_1.authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
30
33
  cli_utilities_1.cliux.success(`Custom region has been set to ${customRegion.name}`);
31
34
  cli_utilities_1.cliux.success(`CMA HOST: ${customRegion.cma}`);
32
35
  cli_utilities_1.cliux.success(`CDA HOST: ${customRegion.cda}`);
36
+ cli_utilities_1.cliux.success(`UI HOST: ${customRegion.uiHost}`);
33
37
  }
34
38
  catch (error) {
35
39
  cli_utilities_1.logger.error('failed to set the region', error);
@@ -38,9 +42,11 @@ class RegionSetCommand extends cli_command_1.Command {
38
42
  }
39
43
  else if (['NA', 'EU', 'AZURE-NA'].includes(selectedRegion)) {
40
44
  const regionDetails = utils_1.regionHandler.setRegion(selectedRegion);
45
+ await cli_utilities_1.authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
41
46
  cli_utilities_1.cliux.success(`Region has been set to ${regionDetails.name}`);
42
47
  cli_utilities_1.cliux.success(`CDA HOST: ${regionDetails.cda}`);
43
48
  cli_utilities_1.cliux.success(`CMA HOST: ${regionDetails.cma}`);
49
+ cli_utilities_1.cliux.success(`UI HOST: ${regionDetails.uiHost}`);
44
50
  }
45
51
  else {
46
52
  cli_utilities_1.cliux.error(`Invalid region is given`);
@@ -52,28 +58,32 @@ RegionSetCommand.description = 'Set region for CLI';
52
58
  RegionSetCommand.flags = {
53
59
  cda: cli_utilities_1.flags.string({
54
60
  char: 'd',
55
- description: 'Custom host to set for content delivery API, if this flag is added then cma and name flags are required',
56
- dependsOn: ['cma', 'name'],
61
+ description: 'Custom host to set for content delivery API, if this flag is added then cma, ui-host and name flags are required',
62
+ dependsOn: ['cma', 'ui-host', 'name'],
57
63
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-d'], ['--cda']),
58
64
  }),
59
65
  cma: cli_utilities_1.flags.string({
60
66
  char: 'm',
61
- description: 'Custom host to set for content management API, , if this flag is added then cda and name flags are required',
62
- dependsOn: ['cda', 'name'],
67
+ description: 'Custom host to set for content management API, , if this flag is added then cda, ui-host and name flags are required',
68
+ dependsOn: ['cda', 'ui-host', 'name'],
63
69
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--cma']),
64
70
  }),
71
+ 'ui-host': cli_utilities_1.flags.string({
72
+ description: 'Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are required',
73
+ dependsOn: ['cda', 'cma', 'name'],
74
+ }),
65
75
  name: cli_utilities_1.flags.string({
66
76
  char: 'n',
67
- description: 'Name for the region, if this flag is added then cda and cma flags are required',
68
- dependsOn: ['cda', 'cma'],
77
+ description: 'Name for the region, if this flag is added then cda, cma and ui-host flags are required',
78
+ dependsOn: ['cda', 'cma', 'ui-host'],
69
79
  }),
70
80
  };
71
81
  RegionSetCommand.examples = [
72
82
  '$ csdx config:set:region',
73
83
  '$ csdx config:set:region NA',
74
- '$ csdx config:set:region NA',
75
- '$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --name "India"',
84
+ '$ csdx config:set:region EU',
85
+ '$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India"',
76
86
  ];
77
87
  RegionSetCommand.args = {
78
- region: cli_utilities_1.args.string({ description: 'Name for the region' })
88
+ region: cli_utilities_1.args.string({ description: 'Name for the region' }),
79
89
  };
@@ -33,6 +33,11 @@ const askCustomRegion = async () => {
33
33
  name: 'cda',
34
34
  message: 'CLI_CONFIG_INQUIRE_REGION_CDA',
35
35
  });
36
- return { name, cma, cda };
36
+ const uiHost = await cli_utilities_1.cliux.inquire({
37
+ type: 'input',
38
+ name: 'ui-host',
39
+ message: 'CLI_CONFIG_INQUIRE_REGION_UI_HOST',
40
+ });
41
+ return { name, cma, cda, uiHost };
37
42
  };
38
43
  exports.askCustomRegion = askCustomRegion;
@@ -12,11 +12,22 @@ function validURL(str) {
12
12
  }
13
13
  // Available region list
14
14
  const regions = {
15
- NA: { cma: 'https://api.contentstack.io', cda: 'https://cdn.contentstack.io', name: 'NA' },
16
- EU: { cma: 'https://eu-api.contentstack.com', cda: 'https://eu-cdn.contentstack.com', name: 'EU' },
15
+ NA: {
16
+ cma: 'https://api.contentstack.io',
17
+ cda: 'https://cdn.contentstack.io',
18
+ uiHost: 'https://app.contentstack.com',
19
+ name: 'NA',
20
+ },
21
+ EU: {
22
+ cma: 'https://eu-api.contentstack.com',
23
+ cda: 'https://eu-cdn.contentstack.com',
24
+ uiHost: 'https://eu-app.contentstack.com',
25
+ name: 'EU',
26
+ },
17
27
  'AZURE-NA': {
18
28
  cma: 'https://azure-na-api.contentstack.com',
19
29
  cda: 'https://azure-na-cdn.contentstack.com',
30
+ uiHost: 'https://azure-na-app.contentstack.com',
20
31
  name: 'AZURE-NA',
21
32
  },
22
33
  };
@@ -80,7 +91,7 @@ class UserConfig {
80
91
  * @returns {boolean} True if contains cma, cda and region property otherwise false
81
92
  */
82
93
  validateRegion(regionObject) {
83
- if (regionObject.cma && regionObject.cda && regionObject.name) {
94
+ if (regionObject.cma && regionObject.cda && regionObject.uiHost && regionObject.name) {
84
95
  if (validURL(regionObject.cma) && validURL(regionObject.cda))
85
96
  return true;
86
97
  }
@@ -96,6 +107,7 @@ class UserConfig {
96
107
  sanitizedRegion = {
97
108
  cma: regionObject.cma,
98
109
  cda: regionObject.cda,
110
+ uiHost: regionObject.uiHost,
99
111
  name: regionObject.name,
100
112
  };
101
113
  return sanitizedRegion;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.0",
2
+ "version": "1.3.1",
3
3
  "commands": {
4
4
  "config:get:region": {
5
5
  "id": "config:get:region",
@@ -26,18 +26,19 @@
26
26
  "examples": [
27
27
  "$ csdx config:set:region",
28
28
  "$ csdx config:set:region NA",
29
- "$ csdx config:set:region NA",
30
- "$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --name \"India\""
29
+ "$ csdx config:set:region EU",
30
+ "$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\""
31
31
  ],
32
32
  "flags": {
33
33
  "cda": {
34
34
  "name": "cda",
35
35
  "type": "option",
36
36
  "char": "d",
37
- "description": "Custom host to set for content delivery API, if this flag is added then cma and name flags are required",
37
+ "description": "Custom host to set for content delivery API, if this flag is added then cma, ui-host and name flags are required",
38
38
  "multiple": false,
39
39
  "dependsOn": [
40
40
  "cma",
41
+ "ui-host",
41
42
  "name"
42
43
  ]
43
44
  },
@@ -45,10 +46,22 @@
45
46
  "name": "cma",
46
47
  "type": "option",
47
48
  "char": "m",
48
- "description": "Custom host to set for content management API, , if this flag is added then cda and name flags are required",
49
+ "description": "Custom host to set for content management API, , if this flag is added then cda, ui-host and name flags are required",
50
+ "multiple": false,
51
+ "dependsOn": [
52
+ "cda",
53
+ "ui-host",
54
+ "name"
55
+ ]
56
+ },
57
+ "ui-host": {
58
+ "name": "ui-host",
59
+ "type": "option",
60
+ "description": "Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are required",
49
61
  "multiple": false,
50
62
  "dependsOn": [
51
63
  "cda",
64
+ "cma",
52
65
  "name"
53
66
  ]
54
67
  },
@@ -56,11 +69,12 @@
56
69
  "name": "name",
57
70
  "type": "option",
58
71
  "char": "n",
59
- "description": "Name for the region, if this flag is added then cda and cma flags are required",
72
+ "description": "Name for the region, if this flag is added then cda, cma and ui-host flags are required",
60
73
  "multiple": false,
61
74
  "dependsOn": [
62
75
  "cda",
63
- "cma"
76
+ "cma",
77
+ "ui-host"
64
78
  ]
65
79
  }
66
80
  },
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.2.0",
4
+ "version": "1.3.1",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "npm run clean && npm run compile",
@@ -20,8 +20,8 @@
20
20
  "test:unit": "mocha --forbid-only \"test/unit/*.test.ts\" --unit-test"
21
21
  },
22
22
  "dependencies": {
23
- "@contentstack/cli-command": "^1.2.0",
24
- "@contentstack/cli-utilities": "^1.2.0",
23
+ "@contentstack/cli-command": "^1.2.2",
24
+ "@contentstack/cli-utilities": "^1.3.1",
25
25
  "chalk": "^4.0.0",
26
26
  "debug": "^4.1.1",
27
27
  "inquirer": "8.2.4",
@@ -72,9 +72,10 @@
72
72
  ],
73
73
  "repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-config/<%- commandPath %>"
74
74
  },
75
- "husky": {
76
- "hooks": {
77
- "pre-commit": "npm run lint"
75
+ "csdxConfig": {
76
+ "shortCommandName": {
77
+ "config:get:region": "RGT",
78
+ "config:set:region": "RST"
78
79
  }
79
80
  },
80
81
  "repository": "contentstack/cli"