diff --git a/src/base-command.ts b/src/base-command.ts index 6ab435e..1cb1f74 100644 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -13,6 +13,9 @@ import { InquirePayload, cliux, isAuthenticated, + ContentstackMarketplaceClient, + marketplaceSDKInitiator, + marketplaceSDKClient, } from "@contentstack/cli-utilities"; import config from "./config"; @@ -39,6 +42,7 @@ export abstract class BaseCommand extends Command { }; protected managementSdk!: ContentstackClient; protected managementAppSdk!: ContentstackClient; + protected marketplaceAppSdk!: ContentstackMarketplaceClient; protected flags!: Flags; protected args!: Args; @@ -72,6 +76,7 @@ export abstract class BaseCommand extends Command { this.developerHubBaseUrl = this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl(); await this.initCmaSDK(); + await this.initMarketplaceSDK(); // Init logger const logger = new Logger(this.sharedConfig); @@ -126,6 +131,13 @@ export abstract class BaseCommand extends Command { host: this.developerHubBaseUrl, }); } + + async initMarketplaceSDK() { + marketplaceSDKInitiator.init(this.context); + this.marketplaceAppSdk = await marketplaceSDKClient({ + host: this.developerHubBaseUrl, + }); + } /** * @method getValPrompt diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index 38471b0..eca0ba8 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -266,8 +266,8 @@ export default class Create extends BaseCommand { appName: this.sharedConfig.appName, }) ); - await this.managementAppSdk - .organization(this.sharedConfig.org) + await this.marketplaceAppSdk + .marketplace(this.sharedConfig.org) .app() .create(this.appData as AppData) .then((response) => { diff --git a/src/util/common-utils.ts b/src/util/common-utils.ts index 6a843e2..1731094 100644 --- a/src/util/common-utils.ts +++ b/src/util/common-utils.ts @@ -1,4 +1,4 @@ -import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities"; +import { ContentstackClient, FlagInput, ContentstackMarketplaceClient } from "@contentstack/cli-utilities"; import { AppLocation, Extension, LogFn } from "../types"; import { cliux, Stack } from "@contentstack/cli-utilities"; import { apiRequestHandler } from "./api-request-handler"; @@ -7,6 +7,10 @@ export type CommonOptions = { log: LogFn; managementSdk: ContentstackClient; }; +export type MarketPlaceOptions = { + log: LogFn; + marketplaceSdk: ContentstackMarketplaceClient; +}; async function getOrganizations( options: CommonOptions,