@contentstack/cli-config 1.18.0 → 1.20.0-beta.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
@@ -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.18.0 linux-x64 node-v22.22.0
21
+ @contentstack/cli-config/1.20.0-beta.0 linux-x64 node-v22.22.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -34,3 +34,6 @@ export interface SetRateLimitConfig {
34
34
  default?: boolean;
35
35
  host?: string;
36
36
  }
37
+ export interface RegionsMap {
38
+ [key: string]: Region;
39
+ }
@@ -1,105 +1,5 @@
1
- declare const regions: {
2
- NA: {
3
- name: string;
4
- cma: string;
5
- cda: string;
6
- uiHost: string;
7
- developerHubUrl: string;
8
- launchHubUrl: string;
9
- personalizeUrl: string;
10
- composableStudioUrl: string;
11
- };
12
- 'AWS-NA': {
13
- name: string;
14
- cma: string;
15
- cda: string;
16
- uiHost: string;
17
- developerHubUrl: string;
18
- launchHubUrl: string;
19
- personalizeUrl: string;
20
- composableStudioUrl: string;
21
- };
22
- EU: {
23
- name: string;
24
- cma: string;
25
- cda: string;
26
- uiHost: string;
27
- developerHubUrl: string;
28
- launchHubUrl: string;
29
- personalizeUrl: string;
30
- composableStudioUrl: string;
31
- };
32
- 'AWS-EU': {
33
- name: string;
34
- cma: string;
35
- cda: string;
36
- uiHost: string;
37
- developerHubUrl: string;
38
- launchHubUrl: string;
39
- personalizeUrl: string;
40
- composableStudioUrl: string;
41
- };
42
- AU: {
43
- name: string;
44
- cma: string;
45
- cda: string;
46
- uiHost: string;
47
- developerHubUrl: string;
48
- launchHubUrl: string;
49
- personalizeUrl: string;
50
- composableStudioUrl: string;
51
- };
52
- 'AWS-AU': {
53
- name: string;
54
- cma: string;
55
- cda: string;
56
- uiHost: string;
57
- developerHubUrl: string;
58
- launchHubUrl: string;
59
- personalizeUrl: string;
60
- composableStudioUrl: string;
61
- };
62
- 'AZURE-NA': {
63
- name: string;
64
- cma: string;
65
- cda: string;
66
- uiHost: string;
67
- developerHubUrl: string;
68
- launchHubUrl: string;
69
- personalizeUrl: string;
70
- composableStudioUrl: string;
71
- };
72
- 'AZURE-EU': {
73
- name: string;
74
- cma: string;
75
- cda: string;
76
- uiHost: string;
77
- developerHubUrl: string;
78
- launchHubUrl: string;
79
- personalizeUrl: string;
80
- composableStudioUrl: string;
81
- };
82
- 'GCP-NA': {
83
- name: string;
84
- cma: string;
85
- cda: string;
86
- uiHost: string;
87
- developerHubUrl: string;
88
- launchHubUrl: string;
89
- personalizeUrl: string;
90
- composableStudioUrl: string;
91
- };
92
- 'GCP-EU': {
93
- name: string;
94
- cma: string;
95
- cda: string;
96
- uiHost: string;
97
- developerHubUrl: string;
98
- launchHubUrl: string;
99
- personalizeUrl: string;
100
- composableStudioUrl: string;
101
- };
102
- };
1
+ import { Region, RegionsMap } from '../interfaces';
2
+ declare const regions: RegionsMap;
103
3
  declare class UserConfig {
104
4
  /**
105
5
  *
@@ -107,7 +7,7 @@ declare class UserConfig {
107
7
  * @param {string} region It Can be AWS-NA, AWS-EU, AWS-AU, AZURE-NA, AZURE-EU, GCP-NA, GCP-EU
108
8
  * @returns {object} region object with cma, cda, region property
109
9
  */
110
- setRegion(region: any): any;
10
+ setRegion(region: any): Region;
111
11
  /**
112
12
  *
113
13
  * Get current host set for CLI
@@ -2,6 +2,7 @@
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");
5
6
  function validURL(str) {
6
7
  const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol (http or https)
7
8
  '([a-zA-Z0-9.-]+|' + // domain name
@@ -13,109 +14,61 @@ function validURL(str) {
13
14
  'i');
14
15
  return pattern.test(str);
15
16
  }
16
- // Available region list
17
- const regions = {
18
- NA: {
19
- name: 'NA',
20
- cma: 'https://api.contentstack.io',
21
- cda: 'https://cdn.contentstack.io',
22
- uiHost: 'https://app.contentstack.com',
23
- developerHubUrl: 'https://developerhub-api.contentstack.com',
24
- launchHubUrl: 'https://launch-api.contentstack.com',
25
- personalizeUrl: 'https://personalize-api.contentstack.com',
26
- composableStudioUrl: 'https://composable-studio-api.contentstack.com',
27
- },
28
- 'AWS-NA': {
29
- name: 'AWS-NA',
30
- cma: 'https://api.contentstack.io',
31
- cda: 'https://cdn.contentstack.io',
32
- uiHost: 'https://app.contentstack.com',
33
- developerHubUrl: 'https://developerhub-api.contentstack.com',
34
- launchHubUrl: 'https://launch-api.contentstack.com',
35
- personalizeUrl: 'https://personalize-api.contentstack.com',
36
- composableStudioUrl: 'https://composable-studio-api.contentstack.com',
37
- },
38
- EU: {
39
- name: 'EU',
40
- cma: 'https://eu-api.contentstack.com',
41
- cda: 'https://eu-cdn.contentstack.com',
42
- uiHost: 'https://eu-app.contentstack.com',
43
- developerHubUrl: 'https://eu-developerhub-api.contentstack.com',
44
- launchHubUrl: 'https://eu-launch-api.contentstack.com',
45
- personalizeUrl: 'https://eu-personalize-api.contentstack.com',
46
- composableStudioUrl: 'https://eu-composable-studio-api.contentstack.com',
47
- },
48
- 'AWS-EU': {
49
- name: 'AWS-EU',
50
- cma: 'https://eu-api.contentstack.com',
51
- cda: 'https://eu-cdn.contentstack.com',
52
- uiHost: 'https://eu-app.contentstack.com',
53
- developerHubUrl: 'https://eu-developerhub-api.contentstack.com',
54
- launchHubUrl: 'https://eu-launch-api.contentstack.com',
55
- personalizeUrl: 'https://eu-personalize-api.contentstack.com',
56
- composableStudioUrl: 'https://eu-composable-studio-api.contentstack.com',
57
- },
58
- AU: {
59
- name: 'AU',
60
- cma: 'https://au-api.contentstack.com',
61
- cda: 'https://au-cdn.contentstack.com',
62
- uiHost: 'https://au-app.contentstack.com',
63
- developerHubUrl: 'https://au-developerhub-api.contentstack.com',
64
- launchHubUrl: 'https://au-launch-api.contentstack.com',
65
- personalizeUrl: 'https://au-personalize-api.contentstack.com',
66
- composableStudioUrl: 'https://au-composable-studio-api.contentstack.com',
67
- },
68
- 'AWS-AU': {
69
- name: 'AWS-AU',
70
- cma: 'https://au-api.contentstack.com',
71
- cda: 'https://au-cdn.contentstack.com',
72
- uiHost: 'https://au-app.contentstack.com',
73
- developerHubUrl: 'https://au-developerhub-api.contentstack.com',
74
- launchHubUrl: 'https://au-launch-api.contentstack.com',
75
- personalizeUrl: 'https://au-personalize-api.contentstack.com',
76
- composableStudioUrl: 'https://au-composable-studio-api.contentstack.com',
77
- },
78
- 'AZURE-NA': {
79
- name: 'AZURE-NA',
80
- cma: 'https://azure-na-api.contentstack.com',
81
- cda: 'https://azure-na-cdn.contentstack.com',
82
- uiHost: 'https://azure-na-app.contentstack.com',
83
- developerHubUrl: 'https://azure-na-developerhub-api.contentstack.com',
84
- launchHubUrl: 'https://azure-na-launch-api.contentstack.com',
85
- personalizeUrl: 'https://azure-na-personalize-api.contentstack.com',
86
- composableStudioUrl: 'https://azure-na-composable-studio-api.contentstack.com',
87
- },
88
- 'AZURE-EU': {
89
- name: 'AZURE-EU',
90
- cma: 'https://azure-eu-api.contentstack.com',
91
- cda: 'https://azure-eu-cdn.contentstack.com',
92
- uiHost: 'https://azure-eu-app.contentstack.com',
93
- developerHubUrl: 'https://azure-eu-developerhub-api.contentstack.com',
94
- launchHubUrl: 'https://azure-eu-launch-api.contentstack.com',
95
- personalizeUrl: 'https://azure-eu-personalize-api.contentstack.com',
96
- composableStudioUrl: 'https://azure-eu-composable-studio-api.contentstack.com',
97
- },
98
- 'GCP-NA': {
99
- name: 'GCP-NA',
100
- cma: 'https://gcp-na-api.contentstack.com',
101
- cda: 'https://gcp-na-cdn.contentstack.com',
102
- uiHost: 'https://gcp-na-app.contentstack.com',
103
- developerHubUrl: 'https://gcp-na-developerhub-api.contentstack.com',
104
- launchHubUrl: 'https://gcp-na-launch-api.contentstack.com',
105
- personalizeUrl: 'https://gcp-na-personalize-api.contentstack.com',
106
- composableStudioUrl: 'https://gcp-na-composable-studio-api.contentstack.com',
107
- },
108
- 'GCP-EU': {
109
- name: 'GCP-EU',
110
- cma: 'https://gcp-eu-api.contentstack.com',
111
- cda: 'https://gcp-eu-cdn.contentstack.com',
112
- uiHost: 'https://gcp-eu-app.contentstack.com',
113
- developerHubUrl: 'https://gcp-eu-developerhub-api.contentstack.com',
114
- launchHubUrl: 'https://gcp-eu-launch-api.contentstack.com',
115
- personalizeUrl: 'https://gcp-eu-personalize-api.contentstack.com',
116
- composableStudioUrl: 'https://gcp-eu-composable-studio-api.contentstack.com',
117
- },
118
- };
17
+ /**
18
+ * Helper function to build region object from @contentstack/utils
19
+ * @param {string} regionKey - Region identifier
20
+ * @returns {object} Region object with all necessary URLs
21
+ */
22
+ 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
+ };
39
+ }
40
+ catch (error) {
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Get all available regions dynamically
46
+ * This creates a regions object similar to the old hardcoded one but using @contentstack/utils
47
+ */
48
+ function getAvailableRegions() {
49
+ const regionKeys = [
50
+ 'NA',
51
+ 'AWS-NA',
52
+ 'EU',
53
+ 'AWS-EU',
54
+ 'AU',
55
+ 'AWS-AU',
56
+ 'AZURE-NA',
57
+ 'AZURE-EU',
58
+ 'GCP-NA',
59
+ 'GCP-EU',
60
+ ];
61
+ const regions = {};
62
+ for (const key of regionKeys) {
63
+ const regionObj = getRegionObject(key);
64
+ if (regionObj) {
65
+ regions[key] = regionObj;
66
+ }
67
+ }
68
+ return regions;
69
+ }
70
+ // Available region list - now dynamically generated
71
+ const regions = getAvailableRegions();
119
72
  exports.regions = regions;
120
73
  class UserConfig {
121
74
  /**
@@ -146,145 +146,6 @@
146
146
  "region.js"
147
147
  ]
148
148
  },
149
- "config:remove:base-branch": {
150
- "aliases": [],
151
- "args": {},
152
- "description": "Remove branch config for CLI",
153
- "examples": [
154
- "$ csdx config:remove:base-branch",
155
- "$ csdx config:remove:base-branch --stack-api-key <value>"
156
- ],
157
- "flags": {
158
- "stack-api-key": {
159
- "char": "k",
160
- "description": "Stack API key.",
161
- "name": "stack-api-key",
162
- "hasDynamicHelp": false,
163
- "multiple": false,
164
- "type": "option"
165
- },
166
- "yes": {
167
- "char": "y",
168
- "description": "Force remove.",
169
- "name": "yes",
170
- "allowNo": false,
171
- "type": "boolean"
172
- }
173
- },
174
- "hasDynamicHelp": false,
175
- "hiddenAliases": [],
176
- "id": "config:remove:base-branch",
177
- "pluginAlias": "@contentstack/cli-config",
178
- "pluginName": "@contentstack/cli-config",
179
- "pluginType": "core",
180
- "strict": true,
181
- "isESM": false,
182
- "relativePath": [
183
- "lib",
184
- "commands",
185
- "config",
186
- "remove",
187
- "base-branch.js"
188
- ]
189
- },
190
- "config:remove:early-access-header": {
191
- "aliases": [
192
- "config:remove:ea-header"
193
- ],
194
- "args": {},
195
- "description": "Remove Early Access header",
196
- "examples": [
197
- "$ <%= config.bin %> <%= command.id %>",
198
- "$ <%= config.bin %> <%= command.id %> --header-alias <value>"
199
- ],
200
- "flags": {
201
- "header-alias": {
202
- "description": "(optional) Provide the Early Access header alias name.",
203
- "name": "header-alias",
204
- "hasDynamicHelp": false,
205
- "multiple": false,
206
- "type": "option"
207
- },
208
- "yes": {
209
- "char": "y",
210
- "description": "(optional) Force the removal of Early Access header configuration by skipping the confirmation.",
211
- "name": "yes",
212
- "allowNo": false,
213
- "type": "boolean"
214
- }
215
- },
216
- "hasDynamicHelp": false,
217
- "hiddenAliases": [],
218
- "id": "config:remove:early-access-header",
219
- "pluginAlias": "@contentstack/cli-config",
220
- "pluginName": "@contentstack/cli-config",
221
- "pluginType": "core",
222
- "strict": true,
223
- "isESM": false,
224
- "relativePath": [
225
- "lib",
226
- "commands",
227
- "config",
228
- "remove",
229
- "early-access-header.js"
230
- ]
231
- },
232
- "config:remove:proxy": {
233
- "aliases": [],
234
- "args": {},
235
- "description": "Remove proxy configuration from global config",
236
- "examples": [
237
- "csdx config:remove:proxy"
238
- ],
239
- "flags": {},
240
- "hasDynamicHelp": false,
241
- "hiddenAliases": [],
242
- "id": "config:remove:proxy",
243
- "pluginAlias": "@contentstack/cli-config",
244
- "pluginName": "@contentstack/cli-config",
245
- "pluginType": "core",
246
- "strict": true,
247
- "isESM": false,
248
- "relativePath": [
249
- "lib",
250
- "commands",
251
- "config",
252
- "remove",
253
- "proxy.js"
254
- ]
255
- },
256
- "config:remove:rate-limit": {
257
- "aliases": [],
258
- "args": {},
259
- "description": "Remove rate-limit of the organization",
260
- "examples": [
261
- "$ csdx config:remove:rate-limit --org <<org_uid>>"
262
- ],
263
- "flags": {
264
- "org": {
265
- "description": "Provide the organization UID",
266
- "name": "org",
267
- "hasDynamicHelp": false,
268
- "multiple": false,
269
- "type": "option"
270
- }
271
- },
272
- "hasDynamicHelp": false,
273
- "hiddenAliases": [],
274
- "id": "config:remove:rate-limit",
275
- "pluginAlias": "@contentstack/cli-config",
276
- "pluginName": "@contentstack/cli-config",
277
- "pluginType": "core",
278
- "strict": true,
279
- "isESM": false,
280
- "relativePath": [
281
- "lib",
282
- "commands",
283
- "config",
284
- "remove",
285
- "rate-limit.js"
286
- ]
287
- },
288
149
  "config:set:base-branch": {
289
150
  "aliases": [],
290
151
  "args": {},
@@ -665,7 +526,146 @@
665
526
  "set",
666
527
  "region.js"
667
528
  ]
529
+ },
530
+ "config:remove:base-branch": {
531
+ "aliases": [],
532
+ "args": {},
533
+ "description": "Remove branch config for CLI",
534
+ "examples": [
535
+ "$ csdx config:remove:base-branch",
536
+ "$ csdx config:remove:base-branch --stack-api-key <value>"
537
+ ],
538
+ "flags": {
539
+ "stack-api-key": {
540
+ "char": "k",
541
+ "description": "Stack API key.",
542
+ "name": "stack-api-key",
543
+ "hasDynamicHelp": false,
544
+ "multiple": false,
545
+ "type": "option"
546
+ },
547
+ "yes": {
548
+ "char": "y",
549
+ "description": "Force remove.",
550
+ "name": "yes",
551
+ "allowNo": false,
552
+ "type": "boolean"
553
+ }
554
+ },
555
+ "hasDynamicHelp": false,
556
+ "hiddenAliases": [],
557
+ "id": "config:remove:base-branch",
558
+ "pluginAlias": "@contentstack/cli-config",
559
+ "pluginName": "@contentstack/cli-config",
560
+ "pluginType": "core",
561
+ "strict": true,
562
+ "isESM": false,
563
+ "relativePath": [
564
+ "lib",
565
+ "commands",
566
+ "config",
567
+ "remove",
568
+ "base-branch.js"
569
+ ]
570
+ },
571
+ "config:remove:early-access-header": {
572
+ "aliases": [
573
+ "config:remove:ea-header"
574
+ ],
575
+ "args": {},
576
+ "description": "Remove Early Access header",
577
+ "examples": [
578
+ "$ <%= config.bin %> <%= command.id %>",
579
+ "$ <%= config.bin %> <%= command.id %> --header-alias <value>"
580
+ ],
581
+ "flags": {
582
+ "header-alias": {
583
+ "description": "(optional) Provide the Early Access header alias name.",
584
+ "name": "header-alias",
585
+ "hasDynamicHelp": false,
586
+ "multiple": false,
587
+ "type": "option"
588
+ },
589
+ "yes": {
590
+ "char": "y",
591
+ "description": "(optional) Force the removal of Early Access header configuration by skipping the confirmation.",
592
+ "name": "yes",
593
+ "allowNo": false,
594
+ "type": "boolean"
595
+ }
596
+ },
597
+ "hasDynamicHelp": false,
598
+ "hiddenAliases": [],
599
+ "id": "config:remove:early-access-header",
600
+ "pluginAlias": "@contentstack/cli-config",
601
+ "pluginName": "@contentstack/cli-config",
602
+ "pluginType": "core",
603
+ "strict": true,
604
+ "isESM": false,
605
+ "relativePath": [
606
+ "lib",
607
+ "commands",
608
+ "config",
609
+ "remove",
610
+ "early-access-header.js"
611
+ ]
612
+ },
613
+ "config:remove:proxy": {
614
+ "aliases": [],
615
+ "args": {},
616
+ "description": "Remove proxy configuration from global config",
617
+ "examples": [
618
+ "csdx config:remove:proxy"
619
+ ],
620
+ "flags": {},
621
+ "hasDynamicHelp": false,
622
+ "hiddenAliases": [],
623
+ "id": "config:remove:proxy",
624
+ "pluginAlias": "@contentstack/cli-config",
625
+ "pluginName": "@contentstack/cli-config",
626
+ "pluginType": "core",
627
+ "strict": true,
628
+ "isESM": false,
629
+ "relativePath": [
630
+ "lib",
631
+ "commands",
632
+ "config",
633
+ "remove",
634
+ "proxy.js"
635
+ ]
636
+ },
637
+ "config:remove:rate-limit": {
638
+ "aliases": [],
639
+ "args": {},
640
+ "description": "Remove rate-limit of the organization",
641
+ "examples": [
642
+ "$ csdx config:remove:rate-limit --org <<org_uid>>"
643
+ ],
644
+ "flags": {
645
+ "org": {
646
+ "description": "Provide the organization UID",
647
+ "name": "org",
648
+ "hasDynamicHelp": false,
649
+ "multiple": false,
650
+ "type": "option"
651
+ }
652
+ },
653
+ "hasDynamicHelp": false,
654
+ "hiddenAliases": [],
655
+ "id": "config:remove:rate-limit",
656
+ "pluginAlias": "@contentstack/cli-config",
657
+ "pluginName": "@contentstack/cli-config",
658
+ "pluginType": "core",
659
+ "strict": true,
660
+ "isESM": false,
661
+ "relativePath": [
662
+ "lib",
663
+ "commands",
664
+ "config",
665
+ "remove",
666
+ "rate-limit.js"
667
+ ]
668
668
  }
669
669
  },
670
- "version": "1.18.0"
670
+ "version": "1.20.0-beta.0"
671
671
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@contentstack/cli-config",
3
3
  "description": "Contentstack CLI plugin for configuration",
4
- "version": "1.18.0",
4
+ "version": "1.20.0-beta.0",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
- "build": "npm run clean && npm run compile",
8
- "clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
7
+ "build": "pnpm compile && oclif manifest && oclif readme",
8
+ "clean": "rm -rf ./lib ./node_modules tsconfig.tsbuildinfo",
9
9
  "compile": "tsc -b tsconfig.json",
10
10
  "postpack": "rm -f oclif.manifest.json",
11
11
  "prepack": "pnpm compile && oclif manifest && oclif readme",
@@ -21,11 +21,12 @@
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.7.2",
25
- "@contentstack/cli-utilities": "~1.17.0",
24
+ "@contentstack/cli-command": "~1.8.0-beta.0",
25
+ "@contentstack/cli-utilities": "~1.18.0-beta.0",
26
+ "@contentstack/utils": "~1.7.0",
26
27
  "@oclif/core": "^4.3.0",
27
28
  "@oclif/plugin-help": "^6.2.28",
28
- "lodash": "^4.17.21"
29
+ "lodash": "^4.17.23"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@oclif/test": "^4.1.13",