Skip to content

Commit b6eb586

Browse files
Merge pull request #236 from contentstack/development
DX | 03-06-2024 | Release
2 parents 6ce1964 + 2b80c66 commit b6eb586

25 files changed

+660
-99
lines changed

README.md

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $ npm install -g @contentstack/apps-cli
2020
$ csdx COMMAND
2121
running command...
2222
$ csdx (--version|-v)
23-
@contentstack/apps-cli/1.0.5 darwin-arm64 node-v20.10.0
23+
@contentstack/apps-cli/1.1.0 darwin-arm64 node-v18.17.0
2424
$ csdx --help [COMMAND]
2525
USAGE
2626
$ csdx COMMAND
@@ -35,6 +35,7 @@ USAGE
3535
* [`csdx app:delete`](#csdx-appdelete)
3636
* [`csdx app:get`](#csdx-appget)
3737
* [`csdx app:install`](#csdx-appinstall)
38+
* [`csdx app:reinstall`](#csdx-appreinstall)
3839
* [`csdx app:uninstall`](#csdx-appuninstall)
3940
* [`csdx app:update`](#csdx-appupdate)
4041

@@ -61,9 +62,11 @@ EXAMPLES
6162
$ csdx app:install
6263
6364
$ csdx app:uninstall
65+
66+
$ csdx app:reinstall
6467
```
6568

66-
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/index.ts)_
69+
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/index.ts)_
6770

6871
## `csdx app:create`
6972

@@ -76,10 +79,10 @@ USAGE
7679
FLAGS
7780
-c, --config=<value> Path of the external config
7881
-d, --data-dir=<value> Current working directory.
79-
-n, --name=<value> Name of the app to be created
80-
--app-type=<option> [default: stack] Type of App
82+
-n, --name=<value> [default: app-boilerplate] Name of the app to be created
83+
--app-type=<option> [default: stack] Type of app
8184
<options: stack|organization>
82-
--org=<value> Provide the organization UID
85+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
8386
8487
DESCRIPTION
8588
Create a new app in Developer Hub and optionally clone a boilerplate locally.
@@ -94,7 +97,7 @@ EXAMPLES
9497
$ csdx app:create --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json
9598
```
9699

97-
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/create.ts)_
100+
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/create.ts)_
98101

99102
## `csdx app:delete`
100103

@@ -105,8 +108,8 @@ USAGE
105108
$ csdx app:delete [--org <value>] [--app-uid <value>]
106109
107110
FLAGS
108-
--app-uid=<value> Provide the app UID
109-
--org=<value> Provide the organization UID
111+
--app-uid=<value> Provide the app UID of an existing app.
112+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
110113
111114
DESCRIPTION
112115
Delete app from marketplace
@@ -119,7 +122,7 @@ EXAMPLES
119122
$ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
120123
```
121124

122-
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/delete.ts)_
125+
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/delete.ts)_
123126

124127
## `csdx app:get`
125128

@@ -131,10 +134,10 @@ USAGE
131134
132135
FLAGS
133136
-d, --data-dir=<value> Current working directory.
134-
--app-type=<option> [default: stack] Type of App
137+
--app-type=<option> [default: stack] Type of app
135138
<options: stack|organization>
136-
--app-uid=<value> Provide the app UID
137-
--org=<value> Provide the organization UID
139+
--app-uid=<value> Provide the app UID of an existing app.
140+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
138141
139142
DESCRIPTION
140143
Get details of an app in developer hub
@@ -149,7 +152,7 @@ EXAMPLES
149152
$ csdx app:get --org <value> --app-uid <value> --app-type organization
150153
```
151154

152-
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/get.ts)_
155+
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/get.ts)_
153156

154157
## `csdx app:install`
155158

@@ -160,9 +163,9 @@ USAGE
160163
$ csdx app:install [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
161164
162165
FLAGS
163-
--app-uid=<value> Provide the app UID
164-
--org=<value> Provide the organization UID
165-
--stack-api-key=<value> API key of the stack where the app is to be installed.
166+
--app-uid=<value> Provide the app UID of an existing app.
167+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
168+
--stack-api-key=<value> API key of the stack where the app operation is to be performed.
166169
167170
DESCRIPTION
168171
Install an app from the marketplace
@@ -175,7 +178,33 @@ EXAMPLES
175178
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
176179
```
177180

178-
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/install.ts)_
181+
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/install.ts)_
182+
183+
## `csdx app:reinstall`
184+
185+
Reinstall an app from the marketplace
186+
187+
```
188+
USAGE
189+
$ csdx app:reinstall [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
190+
191+
FLAGS
192+
--app-uid=<value> Provide the app UID of an existing app.
193+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
194+
--stack-api-key=<value> API key of the stack where the app operation is to be performed.
195+
196+
DESCRIPTION
197+
Reinstall an app from the marketplace
198+
199+
EXAMPLES
200+
$ csdx app:reinstall
201+
202+
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1>
203+
204+
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
205+
```
206+
207+
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/reinstall.ts)_
179208

180209
## `csdx app:uninstall`
181210

@@ -186,9 +215,9 @@ USAGE
186215
$ csdx app:uninstall [--org <value>] [--app-uid <value>] [--installation-uid <value>] [--uninstall-all]
187216
188217
FLAGS
189-
--app-uid=<value> Provide the app UID
218+
--app-uid=<value> Provide the app UID of an existing app.
190219
--installation-uid=<value> Provide the installation ID of the app that needs to be uninstalled.
191-
--org=<value> Provide the organization UID
220+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
192221
--uninstall-all Please select stacks from where the app must be uninstalled.
193222
194223
DESCRIPTION
@@ -202,7 +231,7 @@ EXAMPLES
202231
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
203232
```
204233

205-
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/uninstall.ts)_
234+
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/uninstall.ts)_
206235

207236
## `csdx app:update`
208237

@@ -214,7 +243,7 @@ USAGE
214243
215244
FLAGS
216245
--app-manifest=<value> Path to the app manifest.json file:
217-
--org=<value> Provide the organization UID
246+
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
218247
219248
DESCRIPTION
220249
Update the existing app in developer hub
@@ -225,5 +254,5 @@ EXAMPLES
225254
$ csdx app:update --app-manifest ./boilerplate/manifest.json
226255
```
227256

228-
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/update.ts)_
257+
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/update.ts)_
229258
<!-- commandsstop -->

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/apps-cli",
3-
"version": "1.0.7",
3+
"version": "1.1.0",
44
"description": "App ClI",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
@@ -96,7 +96,8 @@
9696
"app:update": "APUPT",
9797
"app:delete": "APDLT",
9898
"app:install": "API",
99-
"app:uninstall": "APUI"
99+
"app:uninstall": "APUI",
100+
"app:reinstall": "APRI"
100101
}
101102
}
102-
}
103+
}

src/base-command.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
7070
this.registerConfig();
7171

7272
this.developerHubBaseUrl =
73-
this.sharedConfig.developerHubBaseUrl || (await getDeveloperHubUrl());
73+
this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl();
7474
await this.initCmaSDK();
75-
75+
7676
// Init logger
7777
const logger = new Logger(this.sharedConfig);
7878
this.log = logger.log.bind(logger);
@@ -164,9 +164,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
164164
validateRegionAndAuth() {
165165
if (this.region) {
166166
if (!isAuthenticated()) {
167-
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
168-
this.exit(1);
169-
}
167+
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
168+
this.exit(1);
169+
}
170170
}
171171
}
172172
}

src/commands/app/create.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
getAppName,
3232
getDirName,
3333
getOrgAppUiLocation,
34+
sanitizePath
3435
} from "../../util";
3536

3637
export default class Create extends BaseCommand<typeof Create> {
@@ -54,6 +55,7 @@ export default class Create extends BaseCommand<typeof Create> {
5455
static flags = {
5556
name: flags.string({
5657
char: "n",
58+
default: "app-boilerplate",
5759
description: appCreate.NAME_DESCRIPTION,
5860
}),
5961
"app-type": flags.string({
@@ -385,7 +387,7 @@ export default class Create extends BaseCommand<typeof Create> {
385387

386388
this.sharedConfig.folderPath = resolve(
387389
dirname(this.sharedConfig.folderPath),
388-
this.appData.name
390+
sanitizePath(this.appData.name)
389391
);
390392
this.sharedConfig.nameChanged = true;
391393

src/commands/app/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class App extends Command {
1414
"$ <%= config.bin %> <%= command.id %>:delete",
1515
"$ <%= config.bin %> <%= command.id %>:install",
1616
"$ <%= config.bin %> <%= command.id %>:uninstall",
17+
"$ <%= config.bin %> <%= command.id %>:reinstall",
1718
];
1819

1920
async run(): Promise<void> {

src/commands/app/install.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ export default class Install extends AppCLIBaseCommand {
122122
this.displayStackUrl();
123123
} catch (error: any) {
124124
this.log(error?.errorMessage || error?.message || error, "error");
125+
if (
126+
error?.errorMessage === "Installation for app is already done" &&
127+
error?.status === 400
128+
) {
129+
this.displayReInstallMsg();
130+
}
125131
this.exit(1);
126132
}
127133
}
@@ -136,4 +142,11 @@ export default class Install extends AppCLIBaseCommand {
136142
"info"
137143
);
138144
}
139-
}
145+
146+
/**
147+
* @method displayStackUrl - show guid to stack after installing app successfully in the stack
148+
*/
149+
displayReInstallMsg(): void {
150+
this.log(this.messages.APP_ALREADY_INSTALLED, "info");
151+
}
152+
}

0 commit comments

Comments
 (0)