Skip to content

Commit

Permalink
Merge pull request #200 from contentstack/fix/CS-43661
Browse files Browse the repository at this point in the history
CS-43661-added developerhub url from cma, and version bump
  • Loading branch information
cs-raj authored Feb 12, 2024
2 parents 12c4f36 + cd6dab0 commit 3e91479
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.0.6",
"version": "1.0.7",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
Expand Down
29 changes: 10 additions & 19 deletions src/util/inquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
import { Installation } from "@contentstack/management/types/app/installation";
import { AppTarget } from "@contentstack/management/types/app/index";

import config from "../config";
import messages, { $t, commonMsg, errors, uninstallAppMsg } from "../messages";
import messages, { $t, errors, uninstallAppMsg } from "../messages";
import {
CommonOptions,
getOrganizations,
Expand Down Expand Up @@ -159,28 +158,20 @@ async function getInstalledApps(
* @return {*} {Promise<string>}
*/
async function getDeveloperHubUrl(): Promise<string> {
const { cma, name } = configHandler.get("region") || {};
let developerHubBaseUrl = (config.developerHubUrls as Record<string, string>)[
cma
];

if (!developerHubBaseUrl) {
developerHubBaseUrl = await cliux.inquire({
type: "input",
name: "name",
validate: (url) => {
if (!url) return errors.BASE_URL_EMPTY;

return true;
},
message: $t(commonMsg.DEVELOPER_HUB_URL_PROMPT, { name }),
});
}
const { cma } = configHandler.get("region") || {};
let developerHubBaseUrl = cma.replace("api", "developerhub-api");

if (developerHubBaseUrl.startsWith("http")) {
developerHubBaseUrl = developerHubBaseUrl.split("//")[1];
}

developerHubBaseUrl = developerHubBaseUrl.startsWith("dev11")
? developerHubBaseUrl.replace("dev11", "dev")
: developerHubBaseUrl;
developerHubBaseUrl = developerHubBaseUrl.endsWith("io")
? developerHubBaseUrl.replace("io", "com")
: developerHubBaseUrl;

return developerHubBaseUrl;
}

Expand Down

0 comments on commit 3e91479

Please sign in to comment.