@contentstack/cli-config 2.0.0-beta.13 → 2.0.0-beta.15

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.13 linux-x64 node-v22.23.1
21
+ @contentstack/cli-config/2.0.0-beta.15 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
@@ -457,12 +457,13 @@ Set region for CLI
457
457
  ```
458
458
  USAGE
459
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>]
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
+ --auth-api=<value> Custom host to set for Auth API
466
467
  --cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host and name
467
468
  flags are required
468
469
  --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host and
@@ -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' }));
@@ -135,6 +152,9 @@ RegionSetCommand.flags = {
135
152
  'cs-assets': cli_utilities_1.flags.string({
136
153
  description: 'Custom host to set for Contentstack Assets API',
137
154
  }),
155
+ 'auth-api': cli_utilities_1.flags.string({
156
+ description: 'Custom host to set for Auth API',
157
+ }),
138
158
  };
139
159
  RegionSetCommand.examples = [
140
160
  '$ csdx config:set: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,
@@ -653,6 +653,13 @@
653
653
  "hasDynamicHelp": false,
654
654
  "multiple": false,
655
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"
656
663
  }
657
664
  },
658
665
  "hasDynamicHelp": false,
@@ -672,5 +679,5 @@
672
679
  ]
673
680
  }
674
681
  },
675
- "version": "2.0.0-beta.13"
682
+ "version": "2.0.0-beta.15"
676
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.13",
4
+ "version": "2.0.0-beta.15",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "pnpm compile && oclif manifest && oclif readme",
@@ -14,8 +14,8 @@
14
14
  "lint": "eslint src/**/*.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@contentstack/cli-command": "~2.0.0-beta.9",
18
- "@contentstack/cli-utilities": "~2.0.0-beta.10",
17
+ "@contentstack/cli-command": "~2.0.0-beta.11",
18
+ "@contentstack/cli-utilities": "~2.0.0-beta.12",
19
19
  "@contentstack/utils": "~1.9.1",
20
20
  "@oclif/core": "^4.11.4"
21
21
  },
@@ -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
  }