|
1 | 1 | import { BaseCommand } from "./base-command"; |
2 | | -import { flags } from "@contentstack/cli-utilities"; |
| 2 | +import { cliux, flags } from "@contentstack/cli-utilities"; |
3 | 3 | import { $t, commonMsg, deleteAppMsg } from "../../messages"; |
4 | 4 | import { getOrg, fetchAppInstallations, deleteApp, getApp } from "../../util"; |
5 | 5 |
|
@@ -40,15 +40,25 @@ export default class Delete extends BaseCommand<typeof Delete> { |
40 | 40 | { managementSdk: this.managementAppSdk, log: this.log } |
41 | 41 | ); |
42 | 42 | if (appInstallations.length === 0) { |
43 | | - await deleteApp(this.flags, this.sharedConfig.org, { |
44 | | - managementSdk: this.managementAppSdk, |
45 | | - log: this.log, |
46 | | - }); |
47 | | - this.log( |
48 | | - $t(deleteAppMsg.APP_DELETED_SUCCESSFULLY, { |
49 | | - app: app?.name || (this.flags["app-uid"] as string), |
50 | | - }) |
51 | | - ); |
| 43 | + const userConfirmation = this.flags['yes'] || await cliux.inquire({ |
| 44 | + type: "confirm", |
| 45 | + message: deleteAppMsg.DELETE_CONFIRMATION, |
| 46 | + name: "confirmation" |
| 47 | + }) |
| 48 | + |
| 49 | + if (userConfirmation) { |
| 50 | + await deleteApp(this.flags, this.sharedConfig.org, { |
| 51 | + managementSdk: this.managementAppSdk, |
| 52 | + log: this.log, |
| 53 | + }); |
| 54 | + this.log( |
| 55 | + $t(deleteAppMsg.APP_DELETED_SUCCESSFULLY, { |
| 56 | + app: app?.name || (this.flags["app-uid"] as string), |
| 57 | + }), "info" |
| 58 | + ); |
| 59 | + } else { |
| 60 | + this.log(commonMsg.USER_TERMINATION, "error") |
| 61 | + } |
52 | 62 | } else { |
53 | 63 | this.log(deleteAppMsg.APP_IS_INSTALLED, "error"); |
54 | 64 | } |
|
0 commit comments