@contentstack/cli-config 1.6.5 → 1.7.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 +21 -8
- package/lib/commands/config/get/region.js +3 -0
- package/lib/commands/config/set/region.d.ts +1 -0
- package/lib/commands/config/set/region.js +41 -1
- package/lib/interfaces/index.d.ts +3 -0
- package/lib/utils/region-handler.js +18 -0
- package/oclif.manifest.json +24 -2
- package/package.json +4 -4
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.
|
|
21
|
+
@contentstack/cli-config/1.7.1 linux-x64 node-v18.20.4
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -265,18 +265,23 @@ Set region for CLI
|
|
|
265
265
|
|
|
266
266
|
```
|
|
267
267
|
USAGE
|
|
268
|
-
$ csdx config:set:region [REGION] [-d <value> -m <value> --ui-host <value> -n <value>]
|
|
268
|
+
$ csdx config:set:region [REGION] [-d <value> -m <value> --ui-host <value> -n <value>] [--developer-hub <value>]
|
|
269
|
+
[--personalize <value>] [--launch <value>]
|
|
269
270
|
|
|
270
271
|
ARGUMENTS
|
|
271
272
|
REGION Name for the region
|
|
272
273
|
|
|
273
274
|
FLAGS
|
|
274
|
-
-d, --cda=<value>
|
|
275
|
-
|
|
276
|
-
-m, --cma=<value>
|
|
277
|
-
|
|
278
|
-
-n, --name=<value>
|
|
279
|
-
--
|
|
275
|
+
-d, --cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host and name
|
|
276
|
+
flags are required
|
|
277
|
+
-m, --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host and
|
|
278
|
+
name flags are required
|
|
279
|
+
-n, --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are required
|
|
280
|
+
--developer-hub=<value> Custom host to set for Developer hub API
|
|
281
|
+
--launch=<value> Custom host to set for Launch API
|
|
282
|
+
--personalize=<value> Custom host to set for Personalize API
|
|
283
|
+
--ui-host=<value> Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are
|
|
284
|
+
required
|
|
280
285
|
|
|
281
286
|
DESCRIPTION
|
|
282
287
|
Set region for CLI
|
|
@@ -295,6 +300,14 @@ EXAMPLES
|
|
|
295
300
|
$ csdx config:set:region GCP-NA
|
|
296
301
|
|
|
297
302
|
$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India"
|
|
303
|
+
|
|
304
|
+
$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --developer-hub <developer_hub_url>
|
|
305
|
+
|
|
306
|
+
$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --personalize <personalize_url>
|
|
307
|
+
|
|
308
|
+
$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --launch <launch_url>
|
|
309
|
+
|
|
310
|
+
$ csdx config:set:region --cda <contentstack_cda_endpoint> --cma <contentstack_cma_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --developer-hub <developer_hub_url> --personalize <personalize_url> --launch <launch_url>
|
|
298
311
|
```
|
|
299
312
|
|
|
300
313
|
_See code: [src/commands/config/set/region.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/region.ts)_
|
|
@@ -14,6 +14,9 @@ class RegionGetCommand extends base_command_1.BaseCommand {
|
|
|
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
|
+
cli_utilities_1.cliux.print(`Developer Hub URL: ${currentRegion.developerHubUrl}`);
|
|
18
|
+
cli_utilities_1.cliux.print(`Launch URL: ${currentRegion.launchHubUrl}`);
|
|
19
|
+
cli_utilities_1.cliux.print(`Personalize URL: ${currentRegion.personalizeUrl}`);
|
|
17
20
|
this.logger.error(`Currently using ${currentRegion.name} region`);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -10,6 +10,9 @@ class RegionSetCommand extends base_command_1.BaseCommand {
|
|
|
10
10
|
let cma = regionSetFlags.cma;
|
|
11
11
|
let name = regionSetFlags.name;
|
|
12
12
|
let uiHost = regionSetFlags['ui-host'];
|
|
13
|
+
let developerHubUrl = regionSetFlags['developer-hub'];
|
|
14
|
+
let personalizeUrl = regionSetFlags['personalize'];
|
|
15
|
+
let launchHubUrl = regionSetFlags['launch'];
|
|
13
16
|
let selectedRegion = args.region;
|
|
14
17
|
if (!(cda && cma && uiHost && name) && !selectedRegion) {
|
|
15
18
|
selectedRegion = await utils_1.interactive.askRegions();
|
|
@@ -27,13 +30,25 @@ class RegionSetCommand extends base_command_1.BaseCommand {
|
|
|
27
30
|
// Custom flag will get first priority over region argument
|
|
28
31
|
if (cda && cma && uiHost && name) {
|
|
29
32
|
try {
|
|
30
|
-
|
|
33
|
+
if (!developerHubUrl) {
|
|
34
|
+
developerHubUrl = this.transformUrl(cma, 'developerhub-api');
|
|
35
|
+
}
|
|
36
|
+
if (!launchHubUrl) {
|
|
37
|
+
launchHubUrl = this.transformUrl(cma, 'launch-api');
|
|
38
|
+
}
|
|
39
|
+
if (!personalizeUrl) {
|
|
40
|
+
personalizeUrl = this.transformUrl(cma, 'personalize-api');
|
|
41
|
+
}
|
|
42
|
+
let customRegion = { cda, cma, uiHost, name, developerHubUrl, personalizeUrl, launchHubUrl };
|
|
31
43
|
customRegion = utils_1.regionHandler.setCustomRegion(customRegion);
|
|
32
44
|
await cli_utilities_1.authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
|
|
33
45
|
cli_utilities_1.cliux.success(`Custom region has been set to ${customRegion.name}`);
|
|
34
46
|
cli_utilities_1.cliux.success(`CMA HOST: ${customRegion.cma}`);
|
|
35
47
|
cli_utilities_1.cliux.success(`CDA HOST: ${customRegion.cda}`);
|
|
36
48
|
cli_utilities_1.cliux.success(`UI HOST: ${customRegion.uiHost}`);
|
|
49
|
+
cli_utilities_1.cliux.success(`Developer Hub URL: ${customRegion.developerHubUrl}`);
|
|
50
|
+
cli_utilities_1.cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
|
|
51
|
+
cli_utilities_1.cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
|
|
37
52
|
}
|
|
38
53
|
catch (error) {
|
|
39
54
|
this.logger.error('failed to set the region', error);
|
|
@@ -47,11 +62,23 @@ class RegionSetCommand extends base_command_1.BaseCommand {
|
|
|
47
62
|
cli_utilities_1.cliux.success(`CDA HOST: ${regionDetails.cda}`);
|
|
48
63
|
cli_utilities_1.cliux.success(`CMA HOST: ${regionDetails.cma}`);
|
|
49
64
|
cli_utilities_1.cliux.success(`UI HOST: ${regionDetails.uiHost}`);
|
|
65
|
+
cli_utilities_1.cliux.success(`Developer Hub URL: ${regionDetails.developerHubUrl}`);
|
|
66
|
+
cli_utilities_1.cliux.success(`Personalize URL: ${regionDetails.personalizeUrl}`);
|
|
67
|
+
cli_utilities_1.cliux.success(`Launch URL: ${regionDetails.launchHubUrl}`);
|
|
50
68
|
}
|
|
51
69
|
else {
|
|
52
70
|
cli_utilities_1.cliux.error(`Invalid region is given`);
|
|
53
71
|
}
|
|
54
72
|
}
|
|
73
|
+
transformUrl(url, replacement) {
|
|
74
|
+
let transformedUrl = url.replace('api', replacement);
|
|
75
|
+
if (transformedUrl.startsWith('http')) {
|
|
76
|
+
transformedUrl = transformedUrl.split('//')[1];
|
|
77
|
+
}
|
|
78
|
+
transformedUrl = transformedUrl.startsWith('dev11') ? transformedUrl.replace('dev11', 'dev') : transformedUrl;
|
|
79
|
+
transformedUrl = transformedUrl.endsWith('io') ? transformedUrl.replace('io', 'com') : transformedUrl;
|
|
80
|
+
return `https://${transformedUrl}`;
|
|
81
|
+
}
|
|
55
82
|
}
|
|
56
83
|
exports.default = RegionSetCommand;
|
|
57
84
|
RegionSetCommand.description = 'Set region for CLI';
|
|
@@ -77,6 +104,15 @@ RegionSetCommand.flags = {
|
|
|
77
104
|
description: 'Name for the region, if this flag is added then cda, cma and ui-host flags are required',
|
|
78
105
|
dependsOn: ['cda', 'cma', 'ui-host'],
|
|
79
106
|
}),
|
|
107
|
+
'developer-hub': cli_utilities_1.flags.string({
|
|
108
|
+
description: 'Custom host to set for Developer hub API',
|
|
109
|
+
}),
|
|
110
|
+
'personalize': cli_utilities_1.flags.string({
|
|
111
|
+
description: 'Custom host to set for Personalize API',
|
|
112
|
+
}),
|
|
113
|
+
'launch': cli_utilities_1.flags.string({
|
|
114
|
+
description: 'Custom host to set for Launch API',
|
|
115
|
+
}),
|
|
80
116
|
};
|
|
81
117
|
RegionSetCommand.examples = [
|
|
82
118
|
'$ csdx config:set:region',
|
|
@@ -86,6 +122,10 @@ RegionSetCommand.examples = [
|
|
|
86
122
|
'$ csdx config:set:region AZURE-EU',
|
|
87
123
|
'$ csdx config:set:region GCP-NA',
|
|
88
124
|
'$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India"',
|
|
125
|
+
'$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --developer-hub <developer_hub_url>',
|
|
126
|
+
'$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --personalize <personalize_url>',
|
|
127
|
+
'$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --launch <launch_url>',
|
|
128
|
+
'$ csdx config:set:region --cda <contentstack_cda_endpoint> --cma <contentstack_cma_endpoint> --ui-host <contentstack_ui_host_endpoint> --name "India" --developer-hub <developer_hub_url> --personalize <personalize_url> --launch <launch_url>',
|
|
89
129
|
];
|
|
90
130
|
RegionSetCommand.args = {
|
|
91
131
|
region: cli_utilities_1.args.string({ description: 'Name for the region' }),
|
|
@@ -19,30 +19,45 @@ const regions = {
|
|
|
19
19
|
cda: 'https://cdn.contentstack.io',
|
|
20
20
|
uiHost: 'https://app.contentstack.com',
|
|
21
21
|
name: 'NA',
|
|
22
|
+
'developerHubUrl': 'https://developerhub-api.contentstack.com',
|
|
23
|
+
'launchHubUrl': 'https://launch-api.contentstack.com',
|
|
24
|
+
'personalizeUrl': 'https://personalization-api.contentstack.com',
|
|
22
25
|
},
|
|
23
26
|
EU: {
|
|
24
27
|
cma: 'https://eu-api.contentstack.com',
|
|
25
28
|
cda: 'https://eu-cdn.contentstack.com',
|
|
26
29
|
uiHost: 'https://eu-app.contentstack.com',
|
|
27
30
|
name: 'EU',
|
|
31
|
+
'developerHubUrl': 'https://eu-developerhub-api.contentstack.com',
|
|
32
|
+
'launchHubUrl': 'https://eu-launch-api.contentstack.com',
|
|
33
|
+
'personalizeUrl': 'Not available',
|
|
28
34
|
},
|
|
29
35
|
'AZURE-NA': {
|
|
30
36
|
cma: 'https://azure-na-api.contentstack.com',
|
|
31
37
|
cda: 'https://azure-na-cdn.contentstack.com',
|
|
32
38
|
uiHost: 'https://azure-na-app.contentstack.com',
|
|
33
39
|
name: 'AZURE-NA',
|
|
40
|
+
'developerHubUrl': 'https://azure-na-developerhub-api.contentstack.com',
|
|
41
|
+
'launchHubUrl': 'https://azure-na-launch-api.contentstack.com',
|
|
42
|
+
'personalizeUrl': 'Not available',
|
|
34
43
|
},
|
|
35
44
|
'AZURE-EU': {
|
|
36
45
|
cma: 'https://azure-eu-api.contentstack.com',
|
|
37
46
|
cda: 'https://azure-eu-cdn.contentstack.com',
|
|
38
47
|
uiHost: 'https://azure-eu-app.contentstack.com',
|
|
39
48
|
name: 'AZURE-EU',
|
|
49
|
+
'developerHubUrl': 'https://azure-eu-developerhub-api.contentstack.com',
|
|
50
|
+
'launchHubUrl': 'https://azure-eu-launch-api.contentstack.com',
|
|
51
|
+
'personalizeUrl': 'Not available',
|
|
40
52
|
},
|
|
41
53
|
'GCP-NA': {
|
|
42
54
|
cma: 'https://gcp-na-api.contentstack.com',
|
|
43
55
|
cda: 'https://gcp-na-cdn.contentstack.com',
|
|
44
56
|
uiHost: 'https://gcp-na-app.contentstack.com',
|
|
45
57
|
name: 'GCP-NA',
|
|
58
|
+
'developerHubUrl': 'https://gcp-na-developerhub-api.contentstack.com',
|
|
59
|
+
'launchHubUrl': 'Not available',
|
|
60
|
+
'personalizeUrl': 'Not available',
|
|
46
61
|
},
|
|
47
62
|
};
|
|
48
63
|
class UserConfig {
|
|
@@ -123,6 +138,9 @@ class UserConfig {
|
|
|
123
138
|
cda: regionObject.cda,
|
|
124
139
|
uiHost: regionObject.uiHost,
|
|
125
140
|
name: regionObject.name,
|
|
141
|
+
developerHubUrl: regionObject['developerHubUrl'],
|
|
142
|
+
personalizeUrl: regionObject['personalizeUrl'],
|
|
143
|
+
launchHubUrl: regionObject['launchHubUrl'],
|
|
126
144
|
};
|
|
127
145
|
return sanitizedRegion;
|
|
128
146
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.1",
|
|
3
3
|
"commands": {
|
|
4
4
|
"config:get:base-branch": {
|
|
5
5
|
"id": "config:get:base-branch",
|
|
@@ -188,7 +188,11 @@
|
|
|
188
188
|
"$ csdx config:set:region AZURE-NA",
|
|
189
189
|
"$ csdx config:set:region AZURE-EU",
|
|
190
190
|
"$ csdx config:set:region GCP-NA",
|
|
191
|
-
"$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\""
|
|
191
|
+
"$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\"",
|
|
192
|
+
"$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\" --developer-hub <developer_hub_url>",
|
|
193
|
+
"$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\" --personalize <personalize_url>",
|
|
194
|
+
"$ csdx config:set:region --cma <contentstack_cma_endpoint> --cda <contentstack_cda_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\" --launch <launch_url>",
|
|
195
|
+
"$ csdx config:set:region --cda <contentstack_cda_endpoint> --cma <contentstack_cma_endpoint> --ui-host <contentstack_ui_host_endpoint> --name \"India\" --developer-hub <developer_hub_url> --personalize <personalize_url> --launch <launch_url>"
|
|
192
196
|
],
|
|
193
197
|
"flags": {
|
|
194
198
|
"cda": {
|
|
@@ -237,6 +241,24 @@
|
|
|
237
241
|
"cma",
|
|
238
242
|
"ui-host"
|
|
239
243
|
]
|
|
244
|
+
},
|
|
245
|
+
"developer-hub": {
|
|
246
|
+
"name": "developer-hub",
|
|
247
|
+
"type": "option",
|
|
248
|
+
"description": "Custom host to set for Developer hub API",
|
|
249
|
+
"multiple": false
|
|
250
|
+
},
|
|
251
|
+
"personalize": {
|
|
252
|
+
"name": "personalize",
|
|
253
|
+
"type": "option",
|
|
254
|
+
"description": "Custom host to set for Personalize API",
|
|
255
|
+
"multiple": false
|
|
256
|
+
},
|
|
257
|
+
"launch": {
|
|
258
|
+
"name": "launch",
|
|
259
|
+
"type": "option",
|
|
260
|
+
"description": "Custom host to set for Launch API",
|
|
261
|
+
"multiple": false
|
|
240
262
|
}
|
|
241
263
|
},
|
|
242
264
|
"args": {
|
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
|
+
"version": "1.7.1",
|
|
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.
|
|
25
|
-
"@contentstack/cli-utilities": "~1.7.
|
|
24
|
+
"@contentstack/cli-command": "~1.3.0",
|
|
25
|
+
"@contentstack/cli-utilities": "~1.7.2",
|
|
26
26
|
"chalk": "^4.0.0",
|
|
27
27
|
"debug": "^4.1.1",
|
|
28
28
|
"inquirer": "8.2.4",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"nyc": "^15.1.0",
|
|
48
48
|
"oclif": "^3.8.1",
|
|
49
49
|
"rimraf": "^2.7.1",
|
|
50
|
-
"sinon": "^
|
|
50
|
+
"sinon": "^19.0.0",
|
|
51
51
|
"tmp": "^0.2.2",
|
|
52
52
|
"ts-node": "^10.9.1",
|
|
53
53
|
"typescript": "^4.9.3"
|