Skip to content

Commit a1d5cc6

Browse files
Merge pull request #240 from contentstack/feat/DX-661-Create-command-api-call
DX - 661 | removed old api calls and added new calls
2 parents 2b80c66 + bd7e2cf commit a1d5cc6

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/base-command.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
InquirePayload,
1414
cliux,
1515
isAuthenticated,
16+
ContentstackMarketplaceClient,
17+
marketplaceSDKInitiator,
18+
marketplaceSDKClient,
1619
} from "@contentstack/cli-utilities";
1720

1821
import config from "./config";
@@ -39,6 +42,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
3942
};
4043
protected managementSdk!: ContentstackClient;
4144
protected managementAppSdk!: ContentstackClient;
45+
protected marketplaceAppSdk!: ContentstackMarketplaceClient;
4246

4347
protected flags!: Flags<T>;
4448
protected args!: Args<T>;
@@ -72,6 +76,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
7276
this.developerHubBaseUrl =
7377
this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl();
7478
await this.initCmaSDK();
79+
await this.initMarketplaceSDK();
7580

7681
// Init logger
7782
const logger = new Logger(this.sharedConfig);
@@ -126,6 +131,13 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
126131
host: this.developerHubBaseUrl,
127132
});
128133
}
134+
135+
async initMarketplaceSDK() {
136+
marketplaceSDKInitiator.init(this.context);
137+
this.marketplaceAppSdk = await marketplaceSDKClient({
138+
host: this.developerHubBaseUrl,
139+
});
140+
}
129141

130142
/**
131143
* @method getValPrompt

src/commands/app/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ export default class Create extends BaseCommand<typeof Create> {
266266
appName: this.sharedConfig.appName,
267267
})
268268
);
269-
await this.managementAppSdk
270-
.organization(this.sharedConfig.org)
269+
await this.marketplaceAppSdk
270+
.marketplace(this.sharedConfig.org)
271271
.app()
272272
.create(this.appData as AppData)
273273
.then((response) => {

src/util/common-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities";
1+
import { ContentstackClient, FlagInput, ContentstackMarketplaceClient } from "@contentstack/cli-utilities";
22
import { AppLocation, Extension, LogFn } from "../types";
33
import { cliux, Stack } from "@contentstack/cli-utilities";
44
import { apiRequestHandler } from "./api-request-handler";
@@ -7,6 +7,10 @@ export type CommonOptions = {
77
log: LogFn;
88
managementSdk: ContentstackClient;
99
};
10+
export type MarketPlaceOptions = {
11+
log: LogFn;
12+
marketplaceSdk: ContentstackMarketplaceClient;
13+
};
1014

1115
async function getOrganizations(
1216
options: CommonOptions,

0 commit comments

Comments
 (0)