Skip to content

Commit 065e56b

Browse files
fix: updated value of developerHubBaseUrl to fetch dynamically
1 parent baadfeb commit 065e56b

File tree

10 files changed

+26
-15
lines changed

10 files changed

+26
-15
lines changed

src/base-command.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
7070
this.registerConfig();
7171

7272
this.developerHubBaseUrl =
73-
this.sharedConfig.developerHubBaseUrl || (await getDeveloperHubUrl());
73+
this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl();
7474
await this.initCmaSDK();
75-
75+
7676
// Init logger
7777
const logger = new Logger(this.sharedConfig);
7878
this.log = logger.log.bind(logger);
@@ -164,9 +164,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
164164
validateRegionAndAuth() {
165165
if (this.region) {
166166
if (!isAuthenticated()) {
167-
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
168-
this.exit(1);
169-
}
167+
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
168+
this.exit(1);
169+
}
170170
}
171171
}
172172
}

src/util/inquirer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ async function getInstalledApps(
158158
*
159159
* @return {*} {Promise<string>}
160160
*/
161-
async function getDeveloperHubUrl(): Promise<string> {
161+
function getDeveloperHubUrl(): string {
162162
const { cma } = configHandler.get("region") || {};
163163
let developerHubBaseUrl = cma.replace("api", "developerhub-api");
164164

test/unit/commands/app/create.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import config from "../../../../src/config";
1212
import messages from "../../../../src/messages";
1313
import * as mock from "../../mock/common.mock.json";
1414
import manifestData from "../../../../src/config/manifest.json";
15+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
1516

1617
const { origin, pathname } = new URL(config.appBoilerplateGithubUrl);
1718
const zipPath = join(process.cwd(), "test", "unit", "mock", "boilerplate.zip");
1819
const region: { cma: string; name: string; cda: string } =
1920
configHandler.get("region");
20-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
21+
const developerHubBaseUrl = getDeveloperHubUrl();
2122

2223
describe("app:create", () => {
2324
beforeEach(() => {

test/unit/commands/app/delete.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { cliux, configHandler, ux } from "@contentstack/cli-utilities";
33
import * as mock from "../../mock/common.mock.json"
44

55
import messages, {$t} from "../../../../src/messages";
6+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
67

78
const region: { cma: string; name: string; cda: string } =
89
configHandler.get("region");
9-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
10+
const developerHubBaseUrl = getDeveloperHubUrl();
1011

1112
describe("app:delete", () => {
1213
describe("app:delete with --org and --app-uid flags", () => {

test/unit/commands/app/get.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import * as mock from "../../mock/common.mock.json";
99
import manifestData from "../../config/manifest.json";
1010
import messages, { $t } from "../../../../src/messages";
1111
import * as commonUtils from "../../../../src/util/common-utils";
12+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
1213

1314
const region: { cma: string; name: string; cda: string } =
1415
configHandler.get("region");
15-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
16+
const developerHubBaseUrl = getDeveloperHubUrl();
17+
1618

1719
describe("app:get", () => {
1820
describe("Get app manifest", () => {

test/unit/commands/app/install.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {expect, test} from "@oclif/test";
44
import * as mock from "../../mock/common.mock.json"
55

66
import messages, { $t } from "../../../../src/messages";
7+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
78

89
const region: { cma: string, cda: string, name: string } = configHandler.get("region");
9-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
10+
const developerHubBaseUrl = getDeveloperHubUrl();
1011

1112
describe("app:install", () => {
1213
describe("Install an app on organization", () => {

test/unit/commands/app/reinstall.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { ux, cliux, configHandler } from "@contentstack/cli-utilities";
22
import { expect, test } from "@oclif/test";
33
import * as mock from "../../mock/common.mock.json";
44
import messages, { $t } from "../../../../src/messages";
5+
import { getDeveloperHubUrl } from "../../../../lib/util/inquirer";
56

67
const region: { cma: string; cda: string; name: string } =
78
configHandler.get("region");
8-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
9+
const developerHubBaseUrl = getDeveloperHubUrl();
10+
911
describe("app:reinstall", () => {
1012
describe("Reinstall an app on a stack", () => {
1113
test
12-
.stdout({ print: true })
14+
.stdout({ print: process.env.PRINT === "true" || false })
1315
.stub(ux.action, "stop", () => {})
1416
.stub(ux.action, "start", () => {})
1517
.stub(cliux, "inquire", async (...args: any) => {

test/unit/commands/app/uninstall.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { expect, test } from "@oclif/test";
44
import * as mock from "../../mock/common.mock.json"
55

66
import messages, {$t} from "../../../../src/messages";
7+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
78

89
const region: { cma: string, cda: string, name: string } = configHandler.get("region");
9-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
10+
const developerHubBaseUrl = getDeveloperHubUrl();
1011

1112
describe("app:uninstall", () => {
1213
describe("Uninstall an app from organization", () => {

test/unit/commands/app/update.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import { cliux, ux, configHandler } from "@contentstack/cli-utilities";
77
import messages from "../../../../src/messages";
88
import * as mock from "../../mock/common.mock.json";
99
import manifestData from "../../config/manifest.json";
10+
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
1011

1112
const region: { cma: string; name: string; cda: string } =
1213
configHandler.get("region");
13-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
14+
const developerHubBaseUrl = getDeveloperHubUrl();
1415

1516
describe("app:update", () => {
1617
describe("Update app with `--app-manifest` flag", () => {

test/unit/util/common-utils.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import {
1010
import { LogFn } from "../../../src/types";
1111
import * as mock from "../mock/common.mock.json";
1212
import { fetchApps, getOrganizations } from "../../../src/util/common-utils";
13+
import { getDeveloperHubUrl } from "../../../src/util/inquirer";
1314

1415
const region: { cma: string; name: string; cda: string } =
1516
configHandler.get("region");
16-
const developerHubBaseUrl = configHandler.get("developerHubBaseUrl");
17+
const developerHubBaseUrl = getDeveloperHubUrl();
18+
1719

1820
describe("common utils", () => {
1921
const log: LogFn = () => {};

0 commit comments

Comments
 (0)