Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/contentstack-config/src/commands/config/set/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
studio: _flags.string({
description: 'Custom host to set for Studio API',
}),
'asset-management': _flags.string({
description: 'Custom host to set for Asset Management API',
'cs-assets': _flags.string({
description: 'Custom host to set for Contentstack Assets API',
}),
};
static examples = [
Expand All @@ -64,7 +64,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
'$ 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>',
'$ 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>',
'$ 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>',
'$ 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>',
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --cs-assets <cs_assets_url>',
'$ 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>',
];

Expand All @@ -82,7 +82,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
let personalizeUrl = regionSetFlags['personalize'];
let launchHubUrl = regionSetFlags['launch'];
let composableStudioUrl = regionSetFlags['studio'];
let assetManagementUrl = regionSetFlags['asset-management'];
let csAssetsUrl = regionSetFlags['cs-assets'];
let selectedRegion = args.region;
if (!(cda && cma && uiHost && name) && !selectedRegion) {
selectedRegion = await interactive.askRegions();
Expand Down Expand Up @@ -113,8 +113,8 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
if (!composableStudioUrl) {
composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
}
if (!assetManagementUrl) {
assetManagementUrl = this.transformUrl(cma, 'am-api');
if (!csAssetsUrl) {
csAssetsUrl = this.transformUrl(cma, 'am-api');
}
let customRegion: Region = {
cda,
Expand All @@ -125,7 +125,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
personalizeUrl,
launchHubUrl,
composableStudioUrl,
assetManagementUrl,
csAssetsUrl,
};
customRegion = regionHandler.setCustomRegion(customRegion);
await authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
Expand All @@ -137,7 +137,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
cliux.success(`Asset Management URL: ${customRegion.assetManagementUrl}`);
cliux.success(`Contentstack Assets URL: ${customRegion.csAssetsUrl}`);
} catch (error) {
handleAndLogError(error, { ...this.contextDetails, module: 'config-set-region' });
}
Expand All @@ -156,7 +156,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
cliux.success(`Personalize URL: ${regionDetails.personalizeUrl}`);
cliux.success(`Launch URL: ${regionDetails.launchHubUrl}`);
cliux.success(`Studio URL: ${regionDetails.composableStudioUrl}`);
cliux.success(`Asset Management URL: ${regionDetails.assetManagementUrl}`);
cliux.success(`Contentstack Assets URL: ${regionDetails.csAssetsUrl}`);
} else {
cliux.error(`Invalid region specified.`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Region {
personalizeUrl: string;
launchHubUrl: string;
composableStudioUrl: string;
assetManagementUrl?: string;
csAssetsUrl?: string;
}

export interface Limit {
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-config/src/utils/region-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function getRegionObject(regionKey: string): Region {
launchHubUrl: endpoints.launch,
personalizeUrl: endpoints.personalizeManagement,
composableStudioUrl: endpoints.composableStudio,
assetManagementUrl: endpoints.assetManagement,
csAssetsUrl: endpoints.assetManagement,
};
} catch {
return null;
Expand Down Expand Up @@ -156,7 +156,7 @@ class UserConfig {
personalizeUrl: regionObject['personalizeUrl'],
launchHubUrl: regionObject['launchHubUrl'],
composableStudioUrl: regionObject['composableStudioUrl'],
assetManagementUrl: regionObject['assetManagementUrl'],
csAssetsUrl: regionObject['csAssetsUrl'],
};

return sanitizedRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Region command', function () {
launchHubUrl: 'https://launch-api.contentstack.com',
personalizeUrl: 'https://personalization-api.contentstack.com',
composableStudioUrl: 'https://composable-studio-api.contentstack.com',
assetManagementUrl: 'https://am-api.contentstack.com',
csAssetsUrl: 'https://am-api.contentstack.com',
};
let cliuxPrintStub: sinon.SinonStub;
let configGetStub: sinon.SinonStub;
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('Region command', function () {
personalizeUrl: 'https://custom-personalize.com',
launchHubUrl: 'https://custom-launch.com',
composableStudioUrl: 'https://custom-composable-studio.com',
assetManagementUrl: 'https://custom-asset-management.com',
csAssetsUrl: 'https://custom-asset-management.com',
};
const result = UserConfig.setCustomRegion(customRegion);
expect(result).to.deep.equal(customRegion);
Expand Down
Loading