Skip to content

Commit c05a93c

Browse files
Merge pull request #74 from contentstack/fix/CS-40403
fix: handled errors and set hidden to false
2 parents 438dbb0 + d5ba1f3 commit c05a93c

7 files changed

Lines changed: 83 additions & 23 deletions

File tree

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $ npm install -g @contentstack/apps-cli
2828
$ csdx COMMAND
2929
running command...
3030
$ csdx (--version|-v)
31-
@contentstack/apps-cli/0.0.0-alpha-1 darwin-arm64 node-v16.19.0
31+
@contentstack/apps-cli/0.0.0-alpha-1 darwin-arm64 node-v20.3.1
3232
$ csdx --help [COMMAND]
3333
USAGE
3434
$ csdx COMMAND
@@ -41,6 +41,8 @@ USAGE
4141
* [`csdx app:create`](#csdx-appcreate)
4242
* [`csdx app:delete`](#csdx-appdelete)
4343
* [`csdx app:get`](#csdx-appget)
44+
* [`csdx app:install`](#csdx-appinstall)
45+
* [`csdx app:uninstall`](#csdx-appuninstall)
4446
* [`csdx app:update`](#csdx-appupdate)
4547

4648
## `csdx app:create`
@@ -132,6 +134,60 @@ EXAMPLES
132134

133135
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v0.0.0-alpha-1/src/commands/app/get.ts)_
134136

137+
## `csdx app:install`
138+
139+
Install an app from the marketplace
140+
141+
```
142+
USAGE
143+
$ csdx app:install [--org <value>] [-y] [--app-uid <value>] [--stack-api-key <value>]
144+
145+
FLAGS
146+
-y, --yes Use this flag to skip the confirmation.
147+
--app-uid=<value> Provide the app UID
148+
--org=<value> Provide the organization UID
149+
--stack-api-key=<value> API key of the stack where the app is to be installed.
150+
151+
DESCRIPTION
152+
Install an app from the marketplace
153+
154+
EXAMPLES
155+
$ csdx app:install
156+
157+
$ csdx app:install --org <UID> --app-uid <APP-UID-1>
158+
159+
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
160+
```
161+
162+
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v0.0.0-alpha-1/src/commands/app/install.ts)_
163+
164+
## `csdx app:uninstall`
165+
166+
Uninstall an app
167+
168+
```
169+
USAGE
170+
$ csdx app:uninstall [--org <value>] [-y] [--app-uid <value>] [--installation-uid <value>]
171+
172+
FLAGS
173+
-y, --yes Use this flag to skip the confirmation.
174+
--app-uid=<value> Provide the app UID
175+
--installation-uid=<value> Provide the installation ID of the app that needs to be uninstalled.
176+
--org=<value> Provide the organization UID
177+
178+
DESCRIPTION
179+
Uninstall an app
180+
181+
EXAMPLES
182+
$ csdx app:uninstall
183+
184+
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1>
185+
186+
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
187+
```
188+
189+
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v0.0.0-alpha-1/src/commands/app/uninstall.ts)_
190+
135191
## `csdx app:update`
136192

137193
Update the existing app in developer hub

src/commands/app/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class Delete extends BaseCommand<typeof Delete> {
5353
this.log(deleteAppMsg.APP_IS_INSTALLED, "error");
5454
}
5555
} catch (error: any) {
56-
this.log(error.errorMessage, "error");
56+
this.log(error?.errorMessage || error?.message || error, "error");
5757
if (error.status === 400) {
5858
// check for invalid app-uid
5959
this.log(deleteAppMsg.PLEASE_SELECT_APP_FROM_LIST);

src/commands/app/get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export default class Get extends BaseCommand<typeof Get> {
5555
this.log
5656
);
5757
} catch (error: any) {
58-
this.log(error.errorMessage, "error");
59-
this.exit();
58+
this.log(error?.errorMessage || error?.message || error, "error");
59+
this.exit(1);
6060
}
6161
}
6262
}

src/commands/app/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export default class App extends Command {
1414
"$ <%= config.bin %> <%= command.id %>:get",
1515
"$ <%= config.bin %> <%= command.id %>:update",
1616
"$ <%= config.bin %> <%= command.id %>:delete",
17+
"$ <%= config.bin %> <%= command.id %>:install",
18+
"$ <%= config.bin %> <%= command.id %>:uninstall",
1719
];
1820

1921
async run(): Promise<void> {

src/commands/app/install.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getOrg, getApp, getStack, installApp, fetchApp, fetchStack} from "../..
55

66
export default class Install extends BaseCommand<typeof Install> {
77
static description: string | undefined = "Install an app from the marketplace";
8+
static hidden: boolean = false;
89

910
static examples = [
1011
"$ <%= config.bin %> <%= command.id %>",
@@ -67,15 +68,15 @@ export default class Install extends BaseCommand<typeof Install> {
6768
app: app?.name || app?.uid,
6869
type: appType,
6970
target: this.flags['stack-api-key'] || this.sharedConfig.org
70-
}), "warn")
71+
}), "info")
7172
await installApp(this.flags, this.sharedConfig.org, appType, {managementSdk: this.managementAppSdk, log: this.log})
7273
this.log($t(installAppMsg.APP_INSTALLED_SUCCESSFULLY, {
7374
app: app?.name || this.flags['app-uid'] as string,
7475
target: stack?.name || this.sharedConfig.org
7576
}), "info");
7677
} catch(error: any) {
7778
this.log(error?.errorMessage || error?.message || error, "error")
78-
this.exit()
79+
this.exit(1)
7980
}
8081
}
8182
}

src/commands/app/uninstall.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { commonMsg, uninstallAppMsg } from "../../messages";
55

66
export default class Uninstall extends BaseCommand<typeof Uninstall> {
77
static description = "Uninstall an app";
8+
static hidden: boolean = false;
89

910
static examples = [
1011
"$ <%= config.bin %> <%= command.id %>",
@@ -17,7 +18,7 @@ export default class Uninstall extends BaseCommand<typeof Uninstall> {
1718
description: commonMsg.APP_UID,
1819
}),
1920
'installation-uid': flags.string({
20-
description: uninstallAppMsg.CHOOSE_AN_INSTALLATION
21+
description: uninstallAppMsg.INSTALLATION_UID
2122
})
2223
}
2324

@@ -48,7 +49,7 @@ export default class Uninstall extends BaseCommand<typeof Uninstall> {
4849

4950
} catch (error: any) {
5051
this.log(error?.errorMessage || error?.message || error, "error")
51-
this.exit();
52+
this.exit(1);
5253
}
5354
}
5455

src/messages/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const commonMsg = {
3232
"Enter the Developer Hub Base URL for the {name} region: ",
3333
APP_UID: "Provide the app UID",
3434
APP_TYPE_DESCRIPTION: "Type of App",
35-
CONTACT_SUPPORT: "Please contact support team.",
36-
STACK_API_KEY: "Please provide api-key for the stack",
37-
USER_TERMINATION: "Process terminated by user."
35+
CONTACT_SUPPORT: "Please contact the support team.",
36+
STACK_API_KEY: "API key of the stack where the app is to be installed.",
37+
USER_TERMINATION: "Process terminated by the user."
3838
};
3939

4040
const appCreate = {
@@ -75,26 +75,26 @@ const appUpdate = {
7575
};
7676

7777
const deleteAppMsg = {
78-
APP_IS_INSTALLED: "This app is installed in one of your stacks. Please uninstall to proceed with delete.",
79-
APP_DELETED_SUCCESSFULLY: "{app} has been deleted successfully.",
80-
APP_UID_INVALID: "app uid must be valid",
78+
APP_IS_INSTALLED: "This app is installed in one of your stacks. Please uninstall the app from your stack to proceed with the delete operation.",
79+
APP_DELETED_SUCCESSFULLY: "{app} deleted successfully.",
80+
APP_UID_INVALID: "App UID must be valid.",
8181
PLEASE_SELECT_APP_FROM_LIST: "Please select an app from the list",
8282
}
8383

8484
const installAppMsg = {
8585
CHOOSE_A_STACK: "Please select a stack",
86-
APP_INSTALLED_SUCCESSFULLY: "{app} has been installed successfully on {target}.",
87-
INSTALL_ORG_APP_TO_STACK: "{app} is an organization app, it cannot be installed to a stack. Do you want to proceed",
88-
MISSING_STACK_API_KEY: "As {app} is a stack app, it can only be installed on a stack. Please select a stack.",
89-
INSTALLING_APP_NOTICE: "Installing {app} on {type} {target}"
86+
APP_INSTALLED_SUCCESSFULLY: "{app} installed successfully in {target}.",
87+
INSTALL_ORG_APP_TO_STACK: "{app} is an organization app. It cannot be installed to a stack. Do you want to proceed?",
88+
MISSING_STACK_API_KEY: "As {app} is a stack app, it can only be installed in a stack. Please select a stack.",
89+
INSTALLING_APP_NOTICE: "Installing {app} on {type} {target}."
9090
}
9191

9292
const uninstallAppMsg = {
93-
CHOOSE_AN_INSTALLATION: "Please select where the app needs to be uninstalled",
94-
INSTALLATION_UID: "Installation UID which needs to be uninstalled",
95-
NO_INSTALLATIONS_FOUND: "No installations found for this app",
96-
APP_UNINSTALLED: "{app} has been uninstalled successfully.",
97-
UNINSTALLING_APP: "Uninstalling app from {type}"
93+
CHOOSE_AN_INSTALLATION: "Please select the stack from where the app must be uninstalled",
94+
INSTALLATION_UID: "Provide the installation ID of the app that needs to be uninstalled.",
95+
NO_INSTALLATIONS_FOUND: "Cannot find any installations for this app.",
96+
APP_UNINSTALLED: "{app} uninstalled successfully.",
97+
UNINSTALLING_APP: "Uninstalling app from {type}..."
9898
}
9999

100100
const messages: typeof errors &

0 commit comments

Comments
 (0)