Skip to content

Commit

Permalink
Merge pull request #236 from contentstack/development
Browse files Browse the repository at this point in the history
DX | 03-06-2024 | Release
  • Loading branch information
harshithad0703 authored May 31, 2024
2 parents 6ce1964 + 2b80c66 commit b6eb586
Show file tree
Hide file tree
Showing 25 changed files with 660 additions and 99 deletions.
73 changes: 51 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ npm install -g @contentstack/apps-cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/apps-cli/1.0.5 darwin-arm64 node-v20.10.0
@contentstack/apps-cli/1.1.0 darwin-arm64 node-v18.17.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand All @@ -35,6 +35,7 @@ USAGE
* [`csdx app:delete`](#csdx-appdelete)
* [`csdx app:get`](#csdx-appget)
* [`csdx app:install`](#csdx-appinstall)
* [`csdx app:reinstall`](#csdx-appreinstall)
* [`csdx app:uninstall`](#csdx-appuninstall)
* [`csdx app:update`](#csdx-appupdate)

Expand All @@ -61,9 +62,11 @@ EXAMPLES
$ csdx app:install
$ csdx app:uninstall
$ csdx app:reinstall
```

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

## `csdx app:create`

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

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

## `csdx app:delete`

Expand All @@ -105,8 +108,8 @@ USAGE
$ csdx app:delete [--org <value>] [--app-uid <value>]
FLAGS
--app-uid=<value> Provide the app UID
--org=<value> Provide the organization UID
--app-uid=<value> Provide the app UID of an existing app.
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
DESCRIPTION
Delete app from marketplace
Expand All @@ -119,7 +122,7 @@ EXAMPLES
$ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
```

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

## `csdx app:get`

Expand All @@ -131,10 +134,10 @@ USAGE
FLAGS
-d, --data-dir=<value> Current working directory.
--app-type=<option> [default: stack] Type of App
--app-type=<option> [default: stack] Type of app
<options: stack|organization>
--app-uid=<value> Provide the app UID
--org=<value> Provide the organization UID
--app-uid=<value> Provide the app UID of an existing app.
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
DESCRIPTION
Get details of an app in developer hub
Expand All @@ -149,7 +152,7 @@ EXAMPLES
$ csdx app:get --org <value> --app-uid <value> --app-type organization
```

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

## `csdx app:install`

Expand All @@ -160,9 +163,9 @@ USAGE
$ csdx app:install [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
FLAGS
--app-uid=<value> Provide the app UID
--org=<value> Provide the organization UID
--stack-api-key=<value> API key of the stack where the app is to be installed.
--app-uid=<value> Provide the app UID of an existing app.
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
--stack-api-key=<value> API key of the stack where the app operation is to be performed.
DESCRIPTION
Install an app from the marketplace
Expand All @@ -175,7 +178,33 @@ EXAMPLES
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

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

## `csdx app:reinstall`

Reinstall an app from the marketplace

```
USAGE
$ csdx app:reinstall [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
FLAGS
--app-uid=<value> Provide the app UID of an existing app.
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
--stack-api-key=<value> API key of the stack where the app operation is to be performed.
DESCRIPTION
Reinstall an app from the marketplace
EXAMPLES
$ csdx app:reinstall
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1>
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/reinstall.ts)_

## `csdx app:uninstall`

Expand All @@ -186,9 +215,9 @@ USAGE
$ csdx app:uninstall [--org <value>] [--app-uid <value>] [--installation-uid <value>] [--uninstall-all]
FLAGS
--app-uid=<value> Provide the app UID
--app-uid=<value> Provide the app UID of an existing app.
--installation-uid=<value> Provide the installation ID of the app that needs to be uninstalled.
--org=<value> Provide the organization UID
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
--uninstall-all Please select stacks from where the app must be uninstalled.
DESCRIPTION
Expand All @@ -202,7 +231,7 @@ EXAMPLES
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
```

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

## `csdx app:update`

Expand All @@ -214,7 +243,7 @@ USAGE
FLAGS
--app-manifest=<value> Path to the app manifest.json file:
--org=<value> Provide the organization UID
--org=<value> Provide the organization UID to fetch the app details for the desired operation.
DESCRIPTION
Update the existing app in developer hub
Expand All @@ -225,5 +254,5 @@ EXAMPLES
$ csdx app:update --app-manifest ./boilerplate/manifest.json
```

_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.0.5/src/commands/app/update.ts)_
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.1.0/src/commands/app/update.ts)_
<!-- commandsstop -->
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.0.7",
"version": "1.1.0",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
Expand Down Expand Up @@ -96,7 +96,8 @@
"app:update": "APUPT",
"app:delete": "APDLT",
"app:install": "API",
"app:uninstall": "APUI"
"app:uninstall": "APUI",
"app:reinstall": "APRI"
}
}
}
}
10 changes: 5 additions & 5 deletions src/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
this.registerConfig();

this.developerHubBaseUrl =
this.sharedConfig.developerHubBaseUrl || (await getDeveloperHubUrl());
this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl();
await this.initCmaSDK();

// Init logger
const logger = new Logger(this.sharedConfig);
this.log = logger.log.bind(logger);
Expand Down Expand Up @@ -164,9 +164,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
validateRegionAndAuth() {
if (this.region) {
if (!isAuthenticated()) {
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
this.exit(1);
}
this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error");
this.exit(1);
}
}
}
}
4 changes: 3 additions & 1 deletion src/commands/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
getAppName,
getDirName,
getOrgAppUiLocation,
sanitizePath
} from "../../util";

export default class Create extends BaseCommand<typeof Create> {
Expand All @@ -54,6 +55,7 @@ export default class Create extends BaseCommand<typeof Create> {
static flags = {
name: flags.string({
char: "n",
default: "app-boilerplate",
description: appCreate.NAME_DESCRIPTION,
}),
"app-type": flags.string({
Expand Down Expand Up @@ -385,7 +387,7 @@ export default class Create extends BaseCommand<typeof Create> {

this.sharedConfig.folderPath = resolve(
dirname(this.sharedConfig.folderPath),
this.appData.name
sanitizePath(this.appData.name)
);
this.sharedConfig.nameChanged = true;

Expand Down
1 change: 1 addition & 0 deletions src/commands/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class App extends Command {
"$ <%= config.bin %> <%= command.id %>:delete",
"$ <%= config.bin %> <%= command.id %>:install",
"$ <%= config.bin %> <%= command.id %>:uninstall",
"$ <%= config.bin %> <%= command.id %>:reinstall",
];

async run(): Promise<void> {
Expand Down
15 changes: 14 additions & 1 deletion src/commands/app/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export default class Install extends AppCLIBaseCommand {
this.displayStackUrl();
} catch (error: any) {
this.log(error?.errorMessage || error?.message || error, "error");
if (
error?.errorMessage === "Installation for app is already done" &&
error?.status === 400
) {
this.displayReInstallMsg();
}
this.exit(1);
}
}
Expand All @@ -136,4 +142,11 @@ export default class Install extends AppCLIBaseCommand {
"info"
);
}
}

/**
* @method displayStackUrl - show guid to stack after installing app successfully in the stack
*/
displayReInstallMsg(): void {
this.log(this.messages.APP_ALREADY_INSTALLED, "info");
}
}
Loading

0 comments on commit b6eb586

Please sign in to comment.