Skip to content

Commit 5e5f3fa

Browse files
Merge pull request #2387 from contentstack/enhancement/DX-4443
feat: AM2.0 suppport in config module
2 parents 3b3556e + 107e67c commit 5e5f3fa

12 files changed

Lines changed: 1462 additions & 1499 deletions

File tree

.talismanrc

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
21
fileignoreconfig:
3-
- filename: packages/contentstack-import/src/import/modules/environments.ts
4-
checksum: f61c635eaec8026e0cfa80a5ab8272f7946531f6d89505dc0d247b4c7ab0eab7
5-
- filename: pnpm-lock.yaml
6-
checksum: 33b0a88264d099a2594bf8f18b8b025b0e15443dce340cd2ab5021ccc9aa84b0
7-
- filename: package-lock.json
8-
checksum: 38142d4c1159342957985368de6d5caf77ab3198a926fe55cdfd95c7c7343100
9-
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
10-
checksum: 5ab20e057fa9c4c300f7a882d30e1c68bbc91ed19de520488107e8c37239682a
11-
- filename: packages/contentstack-migration/README.md
12-
checksum: 0deea9c8e43a89a4f20fb25ffe1a38cccd19020fe4fedae80f1ca24d34307f2b
13-
- filename: packages/contentstack-import/src/import/modules/taxonomies.ts
14-
checksum: f4f44b6031d2936ec2da98b39bb5f5c1bd0f3be34dbe498c75e64a35b7d25a33
15-
- filename: packages/contentstack/README.md
16-
checksum: 3a0fab964797476a71d2149ce261d265f410bd756eb9cde9400be9e5250fdc35
17-
- filename: packages/contentstack-audit/src/modules/entries.ts
18-
checksum: 8ad10d72522433bc5ce66079248aa2dabae1758ee63335024efd8526d76dd885
2+
- filename: pnpm-lock.yaml
3+
checksum: 0d38bb12f29f0e69d78484a321bd17ca1ef0528f9e6294aac47fde45ab213a0b
4+
- filename: package-lock.json
5+
checksum: 3f5620c23bcc7df713fcf017382e8ccbf102d06387898ae1f328594f09924fbf
6+
- filename: packages/contentstack-audit/src/modules/entries.ts
7+
checksum: 8ad10d72522433bc5ce66079248aa2dabae1758ee63335024efd8526d76dd885
198
version: '1.0'

package-lock.json

Lines changed: 758 additions & 782 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-bootstrap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@contentstack/cli-cm-seed": "~2.0.0-beta.8",
2020
"@contentstack/cli-command": "~2.0.0-beta",
2121
"@contentstack/cli-utilities": "~2.0.0-beta",
22-
"@contentstack/cli-config": "~2.0.0-beta.1",
22+
"@contentstack/cli-config": "~2.0.0-beta.2",
2323
"@oclif/core": "^4.3.0",
2424
"@oclif/plugin-help": "^6.2.37",
2525
"inquirer": "8.2.7",

packages/contentstack-config/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
1818
$ csdx COMMAND
1919
running command...
2020
$ csdx (--version)
21-
@contentstack/cli-config/2.0.0-beta darwin-arm64 node-v24.12.0
21+
@contentstack/cli-config/2.0.0-beta.2 darwin-arm64 node-v24.12.0
2222
$ csdx --help [COMMAND]
2323
USAGE
2424
$ csdx COMMAND
@@ -457,23 +457,25 @@ Set region for CLI
457457
```
458458
USAGE
459459
$ csdx config:set:region [REGION] [--cda <value> --cma <value> --ui-host <value> -n <value>] [--developer-hub
460-
<value>] [--personalize <value>] [--launch <value>] [--studio <value>]
460+
<value>] [--personalize <value>] [--launch <value>] [--studio <value>] [--asset-management <value>]
461461
462462
ARGUMENTS
463463
[REGION] Name for the region
464464
465465
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-
--developer-hub=<value> Custom host to set for Developer hub API
472-
--launch=<value> Custom host to set for Launch API
473-
--personalize=<value> Custom host to set for Personalize API
474-
--studio=<value> Custom host to set for Studio API
475-
--ui-host=<value> Custom UI host to set for CLI, if this flag is added then cda, cma and name flags are
476-
required
466+
-n, --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are
467+
required
468+
--asset-management=<value> Custom host to set for Asset Management API
469+
--cda=<value> Custom host to set for content delivery API, if this flag is added then cma, ui-host
470+
and name flags are required
471+
--cma=<value> Custom host to set for content management API, , if this flag is added then cda,
472+
ui-host and name flags are required
473+
--developer-hub=<value> Custom host to set for Developer hub API
474+
--launch=<value> Custom host to set for Launch API
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
477479
478480
DESCRIPTION
479481
Set region for CLI
@@ -505,6 +507,8 @@ EXAMPLES
505507
506508
$ 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>
507509
510+
$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --asset-management <asset_management_url>
511+
508512
$ 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>
509513
```
510514

packages/contentstack-config/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-config",
33
"description": "Contentstack CLI plugin for configuration",
4-
"version": "2.0.0-beta.1",
4+
"version": "2.0.0-beta.2",
55
"author": "Contentstack",
66
"scripts": {
77
"build": "npm run clean && npm run compile",
@@ -24,7 +24,7 @@
2424
"@contentstack/cli-command": "~2.0.0-beta",
2525
"@contentstack/cli-utilities": "~2.0.0-beta",
2626
"@contentstack/utils": "~1.7.0",
27-
"@oclif/core": "^4.3.0",
27+
"@oclif/core": "^4.8.1",
2828
"@oclif/plugin-help": "^6.2.28",
2929
"lodash": "^4.17.23"
3030
},
@@ -81,4 +81,4 @@
8181
}
8282
},
8383
"repository": "contentstack/cli"
84-
}
84+
}

packages/contentstack-config/src/commands/config/set/region.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
4646
studio: _flags.string({
4747
description: 'Custom host to set for Studio API',
4848
}),
49+
'asset-management': _flags.string({
50+
description: 'Custom host to set for Asset Management API',
51+
}),
4952
};
5053
static examples = [
5154
'$ csdx config:set:region',
@@ -61,6 +64,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
6164
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --personalize <custom_personalize_url>',
6265
'$ 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>',
6366
'$ 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>',
67+
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --asset-management <asset_management_url>',
6468
'$ 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>',
6569
];
6670

@@ -78,6 +82,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
7882
let personalizeUrl = regionSetFlags['personalize'];
7983
let launchHubUrl = regionSetFlags['launch'];
8084
let composableStudioUrl = regionSetFlags['studio'];
85+
let assetManagementUrl = regionSetFlags['asset-management'];
8186
let selectedRegion = args.region;
8287
if (!(cda && cma && uiHost && name) && !selectedRegion) {
8388
selectedRegion = await interactive.askRegions();
@@ -108,6 +113,9 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
108113
if (!composableStudioUrl) {
109114
composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
110115
}
116+
if (!assetManagementUrl) {
117+
assetManagementUrl = this.transformUrl(cma, 'am-api');
118+
}
111119
let customRegion: Region = {
112120
cda,
113121
cma,
@@ -117,6 +125,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
117125
personalizeUrl,
118126
launchHubUrl,
119127
composableStudioUrl,
128+
assetManagementUrl,
120129
};
121130
customRegion = regionHandler.setCustomRegion(customRegion);
122131
await authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
@@ -128,6 +137,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
128137
cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
129138
cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
130139
cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
140+
cliux.success(`Asset Management URL: ${customRegion.assetManagementUrl}`);
131141
} catch (error) {
132142
handleAndLogError(error, { ...this.contextDetails, module: 'config-set-region' });
133143
}
@@ -146,6 +156,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
146156
cliux.success(`Personalize URL: ${regionDetails.personalizeUrl}`);
147157
cliux.success(`Launch URL: ${regionDetails.launchHubUrl}`);
148158
cliux.success(`Studio URL: ${regionDetails.composableStudioUrl}`);
159+
cliux.success(`Asset Management URL: ${regionDetails.assetManagementUrl}`);
149160
} else {
150161
cliux.error(`Invalid region specified.`);
151162
}

packages/contentstack-config/src/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface Region {
1919
personalizeUrl: string;
2020
launchHubUrl: string;
2121
composableStudioUrl: string;
22+
assetManagementUrl?: string;
2223
}
2324

2425
export interface Limit {

packages/contentstack-config/src/utils/region-handler.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getRegionObject(regionKey: string): Region {
2626
try {
2727
// getContentstackEndpoint handles all aliases defined in regions.json
2828
const endpoints = getContentstackEndpoint(regionKey) as any;
29-
29+
3030
if (typeof endpoints === 'string') {
3131
throw new Error('Invalid endpoint response');
3232
}
@@ -40,6 +40,7 @@ function getRegionObject(regionKey: string): Region {
4040
launchHubUrl: endpoints.launch,
4141
personalizeUrl: endpoints.personalizeManagement,
4242
composableStudioUrl: endpoints.composableStudio,
43+
assetManagementUrl: endpoints.assetManagement,
4344
};
4445
} catch (error) {
4546
return null;
@@ -51,21 +52,10 @@ function getRegionObject(regionKey: string): Region {
5152
* This creates a regions object similar to the old hardcoded one but using @contentstack/utils
5253
*/
5354
function getAvailableRegions() {
54-
const regionKeys = [
55-
'NA',
56-
'AWS-NA',
57-
'EU',
58-
'AWS-EU',
59-
'AU',
60-
'AWS-AU',
61-
'AZURE-NA',
62-
'AZURE-EU',
63-
'GCP-NA',
64-
'GCP-EU',
65-
];
55+
const regionKeys = ['NA', 'AWS-NA', 'EU', 'AWS-EU', 'AU', 'AWS-AU', 'AZURE-NA', 'AZURE-EU', 'GCP-NA', 'GCP-EU'];
6656

6757
const regions: RegionsMap = {};
68-
58+
6959
for (const key of regionKeys) {
7060
const regionObj = getRegionObject(key);
7161
if (regionObj) {
@@ -166,6 +156,7 @@ class UserConfig {
166156
personalizeUrl: regionObject['personalizeUrl'],
167157
launchHubUrl: regionObject['launchHubUrl'],
168158
composableStudioUrl: regionObject['composableStudioUrl'],
159+
assetManagementUrl: regionObject['assetManagementUrl'],
169160
};
170161

171162
return sanitizedRegion;

packages/contentstack-config/test/unit/commands/region.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('Region command', function () {
1717
launchHubUrl: 'https://launch-api.contentstack.com',
1818
personalizeUrl: 'https://personalization-api.contentstack.com',
1919
composableStudioUrl: 'https://composable-studio-api.contentstack.com',
20+
assetManagementUrl: 'https://am-api.contentstack.com',
2021
};
2122
let cliuxPrintStub: sinon.SinonStub;
2223
let configGetStub: sinon.SinonStub;
@@ -43,32 +44,32 @@ describe('Region command', function () {
4344
});
4445
it('should log an error and exit when the region is not set', async function () {
4546
const command = new GetRegionCommand([], {} as any);
46-
47+
4748
// Stub the region property to return undefined
4849
sinon.stub(command, 'region').get(() => undefined);
49-
50+
5051
// Stub the exit method to throw to stop execution
5152
const exitStub = sinon.stub(command, 'exit').throws(new Error('EXIT_CALLED'));
52-
53+
5354
// Stub cliux.error to capture error calls
5455
const errorStub = sinon.stub(cliux, 'error');
55-
56+
5657
// Reset cliuxPrintStub to capture new calls
5758
cliuxPrintStub.reset();
58-
59+
5960
// Call the run method directly, expect it to throw
6061
try {
6162
await command.run();
6263
} catch (error) {
6364
// Expected to throw due to exit stub
6465
}
65-
66+
6667
// Verify that cliux.error was called with the correct message
6768
expect(errorStub.calledWith('CLI_CONFIG_GET_REGION_NOT_FOUND')).to.be.true;
68-
69+
6970
// Verify exit was called
7071
expect(exitStub.called).to.be.true;
71-
72+
7273
errorStub.restore();
7374
});
7475

@@ -309,6 +310,7 @@ describe('Region command', function () {
309310
personalizeUrl: 'https://custom-personalize.com',
310311
launchHubUrl: 'https://custom-launch.com',
311312
composableStudioUrl: 'https://custom-composable-studio.com',
313+
assetManagementUrl: 'https://custom-asset-management.com',
312314
};
313315
const result = UserConfig.setCustomRegion(customRegion);
314316
expect(result).to.deep.equal(customRegion);

packages/contentstack-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@contentstack/cli-auth": "~2.0.0-beta.5",
25-
"@contentstack/cli-config": "~2.0.0-beta.1",
25+
"@contentstack/cli-config": "~2.0.0-beta.2",
2626
"@contentstack/cli-dev-dependencies": "~1.3.1",
2727
"@oclif/plugin-help": "^6.2.28",
2828
"@oclif/test": "^4.1.13",

0 commit comments

Comments
 (0)