Skip to content

Commit

Permalink
fix: updated reinstall api call with marketplace call
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Jul 3, 2024
1 parent 6afde49 commit 52097a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
9 changes: 3 additions & 6 deletions src/commands/app/reinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ export default class Reinstall extends AppCLIBaseCommand {
}),
"info"
);
await reinstallApp({
flags: this.flags,
type: appType,
developerHubBaseUrl: this.developerHubBaseUrl,
orgUid: this.sharedConfig.org,
manifestUid: this.flags["app-uid"],
await reinstallApp(this.flags, this.sharedConfig.org, appType, {
marketplaceSdk: this.marketplaceAppSdk,
log: this.log,
});
this.log(
$t(reinstallAppMsg.APP_REINSTALLED_SUCCESSFULLY, {
Expand Down
37 changes: 13 additions & 24 deletions src/util/common-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,20 @@ function installApp(
});
}

async function reinstallApp(params: {
flags: FlagInput;
type: string;
developerHubBaseUrl: string;
orgUid: string;
manifestUid: string;
}): Promise<void> {
const { type, developerHubBaseUrl, flags, orgUid, manifestUid } = params;
const payload = {
target_type: type,
target_uid: (flags["stack-api-key"] as any) || orgUid,
};

const url = `https://${developerHubBaseUrl}/manifests/${manifestUid}/reinstall`;
try {
const result = await apiRequestHandler({
orgUid,
payload,
url,
method: "PUT",
function reinstallApp(
flags: FlagInput,
orgUid: string,
type: string,
options: MarketPlaceOptions
) {
const { marketplaceSdk } = options;
return marketplaceSdk
.marketplace(orgUid)
.app(flags["app-uid"] as any)
.reinstall({
targetUid: (flags["stack-api-key"] as any) || orgUid,
targetType: type as any,
});
return result;
} catch (err) {
throw err;
}
}

function fetchStack(flags: FlagInput, options: CommonOptions) {
Expand Down

0 comments on commit 52097a4

Please sign in to comment.