From 40e37d7b356ba5c374f8beb7049a48cb7b72d4ab Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 5 Feb 2024 16:04:51 +0530 Subject: [PATCH 1/5] added developerhub url from cma, and version bump --- package-lock.json | 4 ++-- package.json | 2 +- src/util/inquirer.ts | 19 +++---------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea9ed0c..c08f62b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/apps-cli", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/apps-cli", - "version": "1.0.6", + "version": "1.0.7", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.17", diff --git a/package.json b/package.json index 76360c0..f3a48e2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index a00d1df..c58a4a5 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -160,23 +160,10 @@ async function getInstalledApps( */ async function getDeveloperHubUrl(): Promise { const { cma, name } = configHandler.get("region") || {}; - let developerHubBaseUrl = (config.developerHubUrls as Record)[ - 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 }), - }); - } + let developerHubBaseUrl = cma.replace('api','developerhub-api') + developerHubBaseUrl = developerHubBaseUrl.startsWith('dev9')?developerHubBaseUrl.replace('dev9','dev'):developerHubBaseUrl; + if (developerHubBaseUrl.startsWith("http")) { developerHubBaseUrl = developerHubBaseUrl.split("//")[1]; } From 5a9b0f3c0886eeecf26069b129bf7f5fe3299828 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 8 Feb 2024 11:40:30 +0530 Subject: [PATCH 2/5] replaced dev9 with dev11 --- src/util/inquirer.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index c58a4a5..22e64d5 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -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, @@ -159,15 +158,15 @@ async function getInstalledApps( * @return {*} {Promise} */ async function getDeveloperHubUrl(): Promise { - const { cma, name } = configHandler.get("region") || {}; + const { cma } = configHandler.get("region") || {}; let developerHubBaseUrl = cma.replace('api','developerhub-api') - - developerHubBaseUrl = developerHubBaseUrl.startsWith('dev9')?developerHubBaseUrl.replace('dev9','dev'):developerHubBaseUrl; if (developerHubBaseUrl.startsWith("http")) { developerHubBaseUrl = developerHubBaseUrl.split("//")[1]; } + developerHubBaseUrl = developerHubBaseUrl.startsWith('dev11')?developerHubBaseUrl.replace('dev11','dev'):developerHubBaseUrl; + console.log(developerHubBaseUrl) return developerHubBaseUrl; } From 61732f14b5267f41807c261869ec9d8f747908d3 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 8 Feb 2024 11:46:52 +0530 Subject: [PATCH 3/5] Removed console.log --- src/util/inquirer.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index 22e64d5..7babcd4 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -166,7 +166,6 @@ async function getDeveloperHubUrl(): Promise { } developerHubBaseUrl = developerHubBaseUrl.startsWith('dev11')?developerHubBaseUrl.replace('dev11','dev'):developerHubBaseUrl; - console.log(developerHubBaseUrl) return developerHubBaseUrl; } From e30dd86420d264e53cb6aac5e5368e4f3181cb90 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 8 Feb 2024 11:49:21 +0530 Subject: [PATCH 4/5] formatted the code --- src/util/inquirer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index 7babcd4..9f6feac 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -159,13 +159,15 @@ async function getInstalledApps( */ async function getDeveloperHubUrl(): Promise { const { cma } = configHandler.get("region") || {}; - let developerHubBaseUrl = cma.replace('api','developerhub-api') - + 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.startsWith("dev11") + ? developerHubBaseUrl.replace("dev11", "dev") + : developerHubBaseUrl; return developerHubBaseUrl; } From cd6dab00cba1b906a70a9876e83ec33f7c04dc47 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Fri, 9 Feb 2024 13:34:24 +0530 Subject: [PATCH 5/5] fixed the developerhub url for NA region --- src/util/inquirer.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index 9f6feac..c55142e 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -168,6 +168,10 @@ async function getDeveloperHubUrl(): Promise { developerHubBaseUrl = developerHubBaseUrl.startsWith("dev11") ? developerHubBaseUrl.replace("dev11", "dev") : developerHubBaseUrl; + developerHubBaseUrl = developerHubBaseUrl.endsWith("io") + ? developerHubBaseUrl.replace("io", "com") + : developerHubBaseUrl; + return developerHubBaseUrl; }