@contentstack/cli-config 2.0.0-beta.14 → 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
|
@@ -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.
|
|
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
|
|
@@ -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
|
|
@@ -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',
|
|
@@ -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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
134
|
+
return (0, cli_utilities_1.buildRegionFromEndpoints)(regionObject.name, endpoints);
|
|
147
135
|
}
|
|
148
136
|
}
|
|
149
137
|
exports.default = new UserConfig();
|
package/oclif.manifest.json
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
18
|
-
"@contentstack/cli-utilities": "~2.0.0-beta.
|
|
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
|
},
|
|
@@ -95,4 +95,4 @@
|
|
|
95
95
|
"url": "git+https://github.com/contentstack/cli.git",
|
|
96
96
|
"directory": "packages/contentstack-config"
|
|
97
97
|
}
|
|
98
|
-
}
|
|
98
|
+
}
|