Skip to content

Commit f5bf3eb

Browse files
updated with a flag and added example
1 parent 0d2a350 commit f5bf3eb

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

README.md

Lines changed: 15 additions & 11 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.2.1 darwin-arm64 node-v18.20.2
23+
@contentstack/apps-cli/1.3.0 darwin-arm64 node-v18.16.0
2424
$ csdx --help [COMMAND]
2525
USAGE
2626
$ csdx COMMAND
@@ -67,22 +67,24 @@ EXAMPLES
6767
$ csdx app:reinstall
6868
```
6969

70-
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/index.ts)_
70+
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/index.ts)_
7171

7272
## `csdx app:create`
7373

7474
Create a new app in Developer Hub and optionally clone a boilerplate locally.
7575

7676
```
7777
USAGE
78-
$ csdx app:create [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
78+
$ csdx app:create [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>] [--boilerplates
79+
<value>]
7980
8081
FLAGS
8182
-c, --config=<value> Path of the external config
8283
-d, --data-dir=<value> Current working directory.
8384
-n, --name=<value> [default: app-boilerplate] Name of the app to be created
8485
--app-type=<option> [default: stack] Type of app
8586
<options: stack|organization>
87+
--boilerplates=<value> Choose a boilerplate from search list
8688
8789
DESCRIPTION
8890
Create a new app in Developer Hub and optionally clone a boilerplate locally.
@@ -95,9 +97,11 @@ EXAMPLES
9597
$ csdx app:create --name App-2 --app-type stack -d ./boilerplate
9698
9799
$ csdx app:create --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json
100+
101+
$ csdx app:create --name App-4 --app-type organization --org <UID> -boilerplates <boilerplate-name>
98102
```
99103

100-
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/create.ts)_
104+
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/create.ts)_
101105

102106
## `csdx app:delete`
103107

@@ -121,7 +125,7 @@ EXAMPLES
121125
$ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
122126
```
123127

124-
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/delete.ts)_
128+
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/delete.ts)_
125129

126130
## `csdx app:deploy`
127131

@@ -158,7 +162,7 @@ EXAMPLES
158162
$ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new> --config <config-path>
159163
```
160164

161-
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/deploy.ts)_
165+
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/deploy.ts)_
162166

163167
## `csdx app:get`
164168

@@ -187,7 +191,7 @@ EXAMPLES
187191
$ csdx app:get --org <value> --app-uid <value> --app-type organization
188192
```
189193

190-
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/get.ts)_
194+
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/get.ts)_
191195

192196
## `csdx app:install`
193197

@@ -212,7 +216,7 @@ EXAMPLES
212216
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
213217
```
214218

215-
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/install.ts)_
219+
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/install.ts)_
216220

217221
## `csdx app:reinstall`
218222

@@ -237,7 +241,7 @@ EXAMPLES
237241
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
238242
```
239243

240-
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/reinstall.ts)_
244+
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/reinstall.ts)_
241245

242246
## `csdx app:uninstall`
243247

@@ -263,7 +267,7 @@ EXAMPLES
263267
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
264268
```
265269

266-
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/uninstall.ts)_
270+
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/uninstall.ts)_
267271

268272
## `csdx app:update`
269273

@@ -285,5 +289,5 @@ EXAMPLES
285289
$ csdx app:update --app-manifest ./boilerplate/manifest.json
286290
```
287291

288-
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/update.ts)_
292+
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.0/src/commands/app/update.ts)_
289293
<!-- commandsstop -->

src/commands/app/create.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class Create extends BaseCommand<typeof Create> {
5252
"$ <%= config.bin %> <%= command.id %> --name App-1 --app-type stack",
5353
"$ <%= config.bin %> <%= command.id %> --name App-2 --app-type stack -d ./boilerplate",
5454
"$ <%= config.bin %> <%= command.id %> --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json",
55+
"$ <%= config.bin %> <%= command.id %> --name App-4 --app-type organization --org <UID> -boilerplates <boilerplate-name>",
5556
];
5657

5758
static flags: FlagInput = {
@@ -73,6 +74,9 @@ export default class Create extends BaseCommand<typeof Create> {
7374
char: "d",
7475
description: commonMsg.CURRENT_WORKING_DIR,
7576
}),
77+
"boilerplates": flags.string({
78+
description: appCreate.BOILERPLATE_TEMPLATES,
79+
}),
7680
};
7781

7882
async run(): Promise<void> {
@@ -89,7 +93,15 @@ export default class Create extends BaseCommand<typeof Create> {
8993
}
9094

9195
try {
92-
if (
96+
if (this.flags.boilerplates) {
97+
this.sharedConfig.boilerplateName = this.flags.boilerplates
98+
.toLowerCase()
99+
.replace(/ /g, "-");
100+
this.sharedConfig.appName = await getAppName(
101+
this.sharedConfig.boilerplateName
102+
);
103+
await this.boilerplateFlow();
104+
} else if (
93105
this.flags.yes ||
94106
(await cliux.inquire({
95107
type: "confirm",

src/messages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const appCreate = {
5858
REGISTER_THE_APP_ON_DEVELOPER_HUB:
5959
"Registering the app with the name {appName} on the Developer Hub...",
6060
START_APP_COMMAND: "Start the app using the following command: {command}",
61+
BOILERPLATE_TEMPLATES: "Choose a boilerplate from search list"
6162
};
6263

6364
const getAppMsg = {

src/util/inquirer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { AppTarget } from "@contentstack/management/types/app/index";
1414

1515
import messages, {
1616
$t,
17+
appCreate,
1718
deployAppMsg,
1819
errors,
1920
uninstallAppMsg,
@@ -394,7 +395,7 @@ const selectedBoilerplate = async (): Promise<any> => {
394395
type: "search-list",
395396
name: "App",
396397
choices: boilerplates.map((bp) => bp.name),
397-
message: "Select a boilerplate from search list",
398+
message: appCreate.BOILERPLATE_TEMPLATES,
398399
})
399400
.then((name) => {
400401
return find(boilerplates, (boilerplate) => boilerplate.name === name);

0 commit comments

Comments
 (0)