@contentstack/cli-config 2.0.0-beta.9 → 2.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @contentstack/cli-config
2
2
 
3
- The config namespace contains all the commands that you will need to configure the CLI as per your requirements. Contentstack currently supports four regions: North America, Europe, Azure North America and Azure Europe. [Configure the CLI documentation](https://www.contentstack.com/docs/developers/cli/configure-the-cli)
3
+ The config namespace contains all the commands that you will need to configure the CLI as per your requirements. Contentstack supports multiple regions. [Configure the CLI documentation](https://www.contentstack.com/docs/headless-cms/configure-the-cli)
4
4
 
5
5
  [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)
6
6
 
@@ -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/2.0.0-beta.9 linux-x64 node-v22.22.2
21
+ @contentstack/cli-config/2.0.0 linux-x64 node-v22.23.1
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -316,8 +316,8 @@ USAGE
316
316
  $ csdx config:set:ea-header [--header-alias <value>] [--header <value>]
317
317
 
318
318
  FLAGS
319
- --header=<value> (optional) Provide the Early Access header alias name.
320
- --header-alias=<value> (optional) Provide the Early Access header value.
319
+ --header=<value> (optional) Provide the Early Access header value.
320
+ --header-alias=<value> (optional) Provide a name (alias) for this Early Access header.
321
321
 
322
322
  DESCRIPTION
323
323
  Set Early Access header
@@ -340,8 +340,8 @@ USAGE
340
340
  $ csdx config:set:early-access-header [--header-alias <value>] [--header <value>]
341
341
 
342
342
  FLAGS
343
- --header=<value> (optional) Provide the Early Access header alias name.
344
- --header-alias=<value> (optional) Provide the Early Access header value.
343
+ --header=<value> (optional) Provide the Early Access header value.
344
+ --header-alias=<value> (optional) Provide a name (alias) for this Early Access header.
345
345
 
346
346
  DESCRIPTION
347
347
  Set Early Access header
@@ -456,25 +456,26 @@ Set region for CLI
456
456
 
457
457
  ```
458
458
  USAGE
459
- $ csdx config:set:region [REGION] [--cda <value> --cma <value> --ui-host <value> -n <value>] [--developer-hub
460
- <value>] [--personalize <value>] [--launch <value>] [--studio <value>] [--cs-assets <value>]
459
+ $ csdx config:set:region [REGION] [--cda <value> --cma <value> --ui-host <value> --name <value>] [--developer-hub
460
+ <value>] [--personalize <value>] [--launch <value>] [--studio <value>] [--cs-assets <value>] [--auth-api <value>]
461
461
 
462
462
  ARGUMENTS
463
463
  [REGION] Name for the region
464
464
 
465
465
  FLAGS
466
- -n, --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are required
467
- --cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host and
468
- name flags are required
469
- --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host
470
- and name flags are required
471
- --cs-assets=<value> Custom host to set for Contentstack Assets API
472
- --developer-hub=<value> Custom host to set for Developer hub API
473
- --launch=<value> Custom host to set for Launch API
474
- --personalize=<value> Custom host to set for Personalize API
475
- --studio=<value> Custom host to set for Studio API
476
- --ui-host=<value> Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are
477
- required
466
+ --auth-api=<value> Custom host to set for Auth API
467
+ --cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host and name
468
+ flags are required
469
+ --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host and
470
+ name flags are required
471
+ --cs-assets=<value> Custom host to set for Contentstack Assets API
472
+ --developer-hub=<value> Custom host to set for Developer hub API
473
+ --launch=<value> Custom host to set for Launch API
474
+ --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are required
475
+ --personalize=<value> Custom host to set for Personalize API
476
+ --studio=<value> Custom host to set for Studio API
477
+ --ui-host=<value> Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are
478
+ required
478
479
 
479
480
  DESCRIPTION
480
481
  Set region for CLI
@@ -508,7 +509,7 @@ EXAMPLES
508
509
 
509
510
  $ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --cs-assets <cs_assets_url>
510
511
 
511
- $ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name "India" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url>
512
+ $ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name "India" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url> --cs-assets <cs_assets_url>
512
513
  ```
513
514
 
514
515
  _See code: [src/commands/config/set/region.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/region.ts)_
@@ -17,6 +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
+ cli_utilities_1.cliux.print(`Contentstack Assets URL: ${currentRegion.csAssetsUrl}`);
20
21
  cli_utilities_1.log.info(`Currently using ${currentRegion.name} region`, this.contextDetails);
21
22
  }
22
23
  }
@@ -26,8 +26,8 @@ exports.default = SetEarlyAccessHeaderCommand;
26
26
  SetEarlyAccessHeaderCommand.description = 'Set Early Access header';
27
27
  SetEarlyAccessHeaderCommand.aliases = ['config:set:ea-header'];
28
28
  SetEarlyAccessHeaderCommand.flags = {
29
- 'header-alias': cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header value.' }),
30
- header: cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header alias name.' }),
29
+ 'header-alias': cli_utilities_1.flags.string({ description: '(optional) Provide a name (alias) for this Early Access header.' }),
30
+ header: cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header value.' }),
31
31
  };
32
32
  SetEarlyAccessHeaderCommand.examples = [
33
33
  '$ <%= config.bin %> <%= command.id %>',
@@ -5,6 +5,7 @@ const utils_1 = require("../../../utils");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  class RegionSetCommand extends base_command_1.BaseCommand {
7
7
  async run() {
8
+ var _a;
8
9
  const { args, flags: regionSetFlags } = await this.parse(RegionSetCommand);
9
10
  let cda = regionSetFlags.cda;
10
11
  let cma = regionSetFlags.cma;
@@ -15,6 +16,7 @@ class RegionSetCommand extends base_command_1.BaseCommand {
15
16
  let launchHubUrl = regionSetFlags['launch'];
16
17
  let composableStudioUrl = regionSetFlags['studio'];
17
18
  let csAssetsUrl = regionSetFlags['cs-assets'];
19
+ let authUrl = regionSetFlags['auth-api'];
18
20
  let selectedRegion = args.region;
19
21
  if (!(cda && cma && uiHost && name) && !selectedRegion) {
20
22
  selectedRegion = await utils_1.interactive.askRegions();
@@ -47,6 +49,9 @@ class RegionSetCommand extends base_command_1.BaseCommand {
47
49
  if (!csAssetsUrl) {
48
50
  csAssetsUrl = this.transformUrl(cma, 'am-api');
49
51
  }
52
+ if (!authUrl) {
53
+ authUrl = this.transformUrl(cma, 'auth-api');
54
+ }
50
55
  let customRegion = {
51
56
  cda,
52
57
  cma,
@@ -57,6 +62,17 @@ class RegionSetCommand extends base_command_1.BaseCommand {
57
62
  launchHubUrl,
58
63
  composableStudioUrl,
59
64
  csAssetsUrl,
65
+ endpoints: {
66
+ contentManagement: cma,
67
+ contentDelivery: cda,
68
+ application: uiHost,
69
+ developerHub: developerHubUrl,
70
+ launch: launchHubUrl,
71
+ personalizeManagement: personalizeUrl,
72
+ composableStudio: composableStudioUrl,
73
+ assetManagement: csAssetsUrl,
74
+ auth: authUrl,
75
+ },
60
76
  };
61
77
  customRegion = utils_1.regionHandler.setCustomRegion(customRegion);
62
78
  await cli_utilities_1.authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
@@ -69,6 +85,7 @@ class RegionSetCommand extends base_command_1.BaseCommand {
69
85
  cli_utilities_1.cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
70
86
  cli_utilities_1.cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
71
87
  cli_utilities_1.cliux.success(`Contentstack Assets URL: ${customRegion.csAssetsUrl}`);
88
+ cli_utilities_1.cliux.success(`Auth API URL: ${(_a = customRegion.endpoints) === null || _a === void 0 ? void 0 : _a.auth}`);
72
89
  }
73
90
  catch (error) {
74
91
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-set-region' }));
@@ -117,7 +134,6 @@ RegionSetCommand.flags = {
117
134
  dependsOn: ['cda', 'cma', 'name'],
118
135
  }),
119
136
  name: cli_utilities_1.flags.string({
120
- char: 'n',
121
137
  description: 'Name for the region, if this flag is added then cda, cma and ui-host flags are required',
122
138
  dependsOn: ['cda', 'cma', 'ui-host'],
123
139
  }),
@@ -136,6 +152,9 @@ RegionSetCommand.flags = {
136
152
  'cs-assets': cli_utilities_1.flags.string({
137
153
  description: 'Custom host to set for Contentstack Assets API',
138
154
  }),
155
+ 'auth-api': cli_utilities_1.flags.string({
156
+ description: 'Custom host to set for Auth API',
157
+ }),
139
158
  };
140
159
  RegionSetCommand.examples = [
141
160
  '$ csdx config:set:region',
@@ -152,7 +171,7 @@ RegionSetCommand.examples = [
152
171
  '$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --launch <custom_launch_url>',
153
172
  '$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --studio <custom_studio_url>',
154
173
  '$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --cs-assets <cs_assets_url>',
155
- '$ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name "India" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url>',
174
+ '$ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name "India" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url> --cs-assets <cs_assets_url>',
156
175
  ];
157
176
  RegionSetCommand.args = {
158
177
  region: cli_utilities_1.args.string({ description: 'Name for the region' }),
@@ -18,6 +18,7 @@ export interface Region {
18
18
  launchHubUrl: string;
19
19
  composableStudioUrl: string;
20
20
  csAssetsUrl?: string;
21
+ endpoints?: Record<string, string>;
21
22
  }
22
23
  export interface Limit {
23
24
  value: number;
@@ -38,17 +38,7 @@ declare class UserConfig {
38
38
  * @param { object } regionObject JSON object needs to be sanitized
39
39
  * @returns { object } JSON object with only valid keys for region
40
40
  */
41
- sanitizeRegionObject(regionObject: any): {
42
- cma: any;
43
- cda: any;
44
- uiHost: any;
45
- name: any;
46
- developerHubUrl: any;
47
- personalizeUrl: any;
48
- launchHubUrl: any;
49
- composableStudioUrl: any;
50
- csAssetsUrl: any;
51
- };
41
+ sanitizeRegionObject(regionObject: any): import("@contentstack/cli-utilities").CanonicalRegion;
52
42
  }
53
43
  export { regions };
54
44
  declare const _default: UserConfig;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.regions = void 0;
4
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
- const utils_1 = require("@contentstack/utils");
6
5
  function validURL(str) {
7
6
  const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol (http or https)
8
7
  '([a-zA-Z0-9.-]+|' + // domain name
@@ -20,27 +19,11 @@ function validURL(str) {
20
19
  * @returns {object} Region object with all necessary URLs
21
20
  */
22
21
  function getRegionObject(regionKey) {
23
- try {
24
- // getContentstackEndpoint handles all aliases defined in regions.json
25
- const endpoints = (0, utils_1.getContentstackEndpoint)(regionKey);
26
- if (typeof endpoints === 'string') {
27
- throw new Error('Invalid endpoint response');
28
- }
29
- return {
30
- name: regionKey,
31
- cma: endpoints.contentManagement,
32
- cda: endpoints.contentDelivery,
33
- uiHost: endpoints.application,
34
- developerHubUrl: endpoints.developerHub,
35
- launchHubUrl: endpoints.launch,
36
- personalizeUrl: endpoints.personalizeManagement,
37
- composableStudioUrl: endpoints.composableStudio,
38
- csAssetsUrl: endpoints.assetManagement,
39
- };
40
- }
41
- catch (_a) {
22
+ // resolveCanonicalEndpoints handles all aliases defined in regions.json
23
+ const endpoints = (0, cli_utilities_1.resolveCanonicalEndpoints)(regionKey);
24
+ if (!endpoints)
42
25
  return null;
43
- }
26
+ return (0, cli_utilities_1.buildRegionFromEndpoints)(regionKey, endpoints);
44
27
  }
45
28
  /**
46
29
  * Get all available regions dynamically
@@ -132,18 +115,23 @@ class UserConfig {
132
115
  * @returns { object } JSON object with only valid keys for region
133
116
  */
134
117
  sanitizeRegionObject(regionObject) {
135
- const sanitizedRegion = {
136
- cma: regionObject.cma,
137
- cda: regionObject.cda,
138
- uiHost: regionObject.uiHost,
139
- name: regionObject.name,
140
- developerHubUrl: regionObject['developerHubUrl'],
141
- personalizeUrl: regionObject['personalizeUrl'],
142
- launchHubUrl: regionObject['launchHubUrl'],
143
- composableStudioUrl: regionObject['composableStudioUrl'],
144
- csAssetsUrl: regionObject['csAssetsUrl'],
118
+ var _a;
119
+ // endpoints is the single source of truth — every friendly field (cma, cda, ...,
120
+ // auth, csAssetsUrl) is derived from it below via buildRegionFromEndpoints, same
121
+ // as named regions. Falls back to synthesizing endpoints from the individual raw
122
+ // fields when the caller didn't supply one directly.
123
+ const endpoints = (_a = regionObject['endpoints']) !== null && _a !== void 0 ? _a : {
124
+ contentManagement: regionObject.cma,
125
+ contentDelivery: regionObject.cda,
126
+ application: regionObject.uiHost,
127
+ developerHub: regionObject['developerHubUrl'],
128
+ launch: regionObject['launchHubUrl'],
129
+ personalizeManagement: regionObject['personalizeUrl'],
130
+ composableStudio: regionObject['composableStudioUrl'],
131
+ assetManagement: regionObject['csAssetsUrl'],
132
+ auth: regionObject['authUrl'],
145
133
  };
146
- return sanitizedRegion;
134
+ return (0, cli_utilities_1.buildRegionFromEndpoints)(regionObject.name, endpoints);
147
135
  }
148
136
  }
149
137
  exports.default = new UserConfig();
@@ -338,14 +338,14 @@
338
338
  ],
339
339
  "flags": {
340
340
  "header-alias": {
341
- "description": "(optional) Provide the Early Access header value.",
341
+ "description": "(optional) Provide a name (alias) for this Early Access header.",
342
342
  "name": "header-alias",
343
343
  "hasDynamicHelp": false,
344
344
  "multiple": false,
345
345
  "type": "option"
346
346
  },
347
347
  "header": {
348
- "description": "(optional) Provide the Early Access header alias name.",
348
+ "description": "(optional) Provide the Early Access header value.",
349
349
  "name": "header",
350
350
  "hasDynamicHelp": false,
351
351
  "multiple": false,
@@ -568,7 +568,7 @@
568
568
  "$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name \"India\" --launch <custom_launch_url>",
569
569
  "$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name \"India\" --studio <custom_studio_url>",
570
570
  "$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name \"India\" --cs-assets <cs_assets_url>",
571
- "$ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name \"India\" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url>"
571
+ "$ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name \"India\" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url> --cs-assets <cs_assets_url>"
572
572
  ],
573
573
  "flags": {
574
574
  "cda": {
@@ -608,7 +608,6 @@
608
608
  "type": "option"
609
609
  },
610
610
  "name": {
611
- "char": "n",
612
611
  "dependsOn": [
613
612
  "cda",
614
613
  "cma",
@@ -654,6 +653,13 @@
654
653
  "hasDynamicHelp": false,
655
654
  "multiple": false,
656
655
  "type": "option"
656
+ },
657
+ "auth-api": {
658
+ "description": "Custom host to set for Auth API",
659
+ "name": "auth-api",
660
+ "hasDynamicHelp": false,
661
+ "multiple": false,
662
+ "type": "option"
657
663
  }
658
664
  },
659
665
  "hasDynamicHelp": false,
@@ -673,5 +679,5 @@
673
679
  ]
674
680
  }
675
681
  },
676
- "version": "2.0.0-beta.9"
682
+ "version": "2.0.0"
677
683
  }
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": "2.0.0-beta.9",
4
+ "version": "2.0.0",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "pnpm compile && oclif manifest && oclif readme",
@@ -14,10 +14,10 @@
14
14
  "lint": "eslint src/**/*.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@contentstack/cli-command": "~2.0.0-beta.7",
18
- "@contentstack/cli-utilities": "~2.0.0-beta.8",
17
+ "@contentstack/cli-command": "~2.0.0",
18
+ "@contentstack/cli-utilities": "~2.0.0",
19
19
  "@contentstack/utils": "~1.9.1",
20
- "@oclif/core": "^4.8.3"
20
+ "@oclif/core": "^4.11.14"
21
21
  },
22
22
  "overrides": {
23
23
  "@oclif/core": {
@@ -25,24 +25,24 @@
25
25
  }
26
26
  },
27
27
  "devDependencies": {
28
- "@oclif/test": "^4.1.18",
28
+ "@oclif/test": "^4.1.20",
29
29
  "@types/chai": "^4.3.20",
30
30
  "@types/mocha": "^8.2.3",
31
31
  "@types/node": "^14.18.63",
32
32
  "@types/sinon": "^21.0.1",
33
33
  "chai": "^4.5.0",
34
- "eslint": "^9.26.0",
35
- "eslint-config-oclif": "^6.0.62",
34
+ "eslint": "^10.6.0",
35
+ "eslint-config-oclif": "^6.0.175",
36
36
  "eslint-config-oclif-typescript": "^3.1.14",
37
37
  "mocha": "10.8.2",
38
38
  "nyc": "^15.1.0",
39
- "oclif": "^4.23.0",
39
+ "oclif": "^4.23.27",
40
40
  "sinon": "^21.1.2",
41
41
  "ts-node": "^10.9.2",
42
42
  "typescript": "^4.9.5"
43
43
  },
44
44
  "engines": {
45
- "node": ">=14.0.0"
45
+ "node": ">=22.0.0"
46
46
  },
47
47
  "files": [
48
48
  "/lib",
@@ -90,5 +90,9 @@
90
90
  "config:remove:rate-limit": "RLRM"
91
91
  }
92
92
  },
93
- "repository": "contentstack/cli"
93
+ "repository": {
94
+ "type": "git",
95
+ "url": "git+https://github.com/contentstack/cli.git",
96
+ "directory": "packages/contentstack-config"
97
+ }
94
98
  }