Skip to content

Commit 9eb1650

Browse files
Merge branch 'development' into feat/CS-39674
2 parents 5754660 + 7ded967 commit 9eb1650

File tree

7 files changed

+91
-282
lines changed

7 files changed

+91
-282
lines changed

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,31 @@ USAGE
3939

4040
## `csdx app:create`
4141

42-
Create new app in developer hub
42+
Create a new app in Developer Hub and optionally clone a boilerplate locally.
4343

4444
```
4545
USAGE
46-
$ csdx app:create [--org <value>] [-y] [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
46+
$ csdx app:create [--org <value>] [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
4747
4848
FLAGS
4949
-c, --config=<value> Path of the external config
5050
-d, --data-dir=<value> Current working directory.
5151
-n, --name=<value> Name of the app to be created
52-
-y, --yes Use this flag to skip the confirmation.
5352
--app-type=<option> [default: stack] Type of App
5453
<options: stack|organization>
5554
--org=<value> Provide the organization UID
5655
5756
DESCRIPTION
58-
Create new app in developer hub
57+
Create a new app in Developer Hub and optionally clone a boilerplate locally.
5958
6059
EXAMPLES
6160
$ csdx app:create
6261
63-
$ csdx app:create --name App-1 --app-type stack --yes
62+
$ csdx app:create --name App-1 --app-type stack
6463
65-
$ csdx app:create --name App-2 --app-type stack -d ./boilerplate --yes
64+
$ csdx app:create --name App-2 --app-type stack -d ./boilerplate
6665
67-
$ csdx app:create --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json --yes
66+
$ csdx app:create --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json
6867
```
6968

7069
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.0.0/src/commands/app/create.ts)_
@@ -75,10 +74,9 @@ Delete app from marketplace
7574

7675
```
7776
USAGE
78-
$ csdx app:delete [--org <value>] [-y] [--app-uid <value>]
77+
$ csdx app:delete [--org <value>] [--app-uid <value>]
7978
8079
FLAGS
81-
-y, --yes Use this flag to skip the confirmation.
8280
--app-uid=<value> Provide the app UID
8381
--org=<value> Provide the organization UID
8482
@@ -101,11 +99,10 @@ Get details of an app in developer hub
10199

102100
```
103101
USAGE
104-
$ csdx app:get [--org <value>] [-y] [--app-uid <value>] [--app-type stack|organization] [-d <value>]
102+
$ csdx app:get [--org <value>] [--app-uid <value>] [--app-type stack|organization] [-d <value>]
105103
106104
FLAGS
107105
-d, --data-dir=<value> Current working directory.
108-
-y, --yes Use this flag to skip the confirmation.
109106
--app-type=<option> [default: stack] Type of App
110107
<options: stack|organization>
111108
--app-uid=<value> Provide the app UID
@@ -132,10 +129,9 @@ Install an app from the marketplace
132129

133130
```
134131
USAGE
135-
$ csdx app:install [--org <value>] [-y] [--app-uid <value>] [--stack-api-key <value>]
132+
$ csdx app:install [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
136133
137134
FLAGS
138-
-y, --yes Use this flag to skip the confirmation.
139135
--app-uid=<value> Provide the app UID
140136
--org=<value> Provide the organization UID
141137
--stack-api-key=<value> API key of the stack where the app is to be installed.
@@ -159,10 +155,9 @@ Uninstall an app
159155

160156
```
161157
USAGE
162-
$ csdx app:uninstall [--org <value>] [-y] [--app-uid <value>] [--installation-uid <value>]
158+
$ csdx app:uninstall [--org <value>] [--app-uid <value>] [--installation-uid <value>]
163159
164160
FLAGS
165-
-y, --yes Use this flag to skip the confirmation.
166161
--app-uid=<value> Provide the app UID
167162
--installation-uid=<value> Provide the installation ID of the app that needs to be uninstalled.
168163
--org=<value> Provide the organization UID
@@ -186,14 +181,10 @@ Update the existing app in developer hub
186181

187182
```
188183
USAGE
189-
$ csdx app:update [--org <value>] [-y] [--app-uid <value>] [--app-manifest <value>] [-c <value>] [-d <value>]
184+
$ csdx app:update [--org <value>] [--app-manifest <value>]
190185
191186
FLAGS
192-
-c, --config=<value> Path of the external config
193-
-d, --data-dir=<value> Current working directory.
194-
-y, --yes Use this flag to skip the confirmation.
195187
--app-manifest=<value> Path to the app manifest.json file:
196-
--app-uid=<value> Provide the app UID
197188
--org=<value> Provide the organization UID
198189
199190
DESCRIPTION
@@ -202,11 +193,7 @@ DESCRIPTION
202193
EXAMPLES
203194
$ csdx app:update
204195
205-
$ csdx app:update --org <value> --app-uid <value> --app-manifest <value>
206-
207-
$ csdx app:update --org <value> --app-uid <value> --app-manifest ./boilerplate/manifest.json
208-
209-
$ csdx app:update --org <value> --app-uid <value> -d ./boilerplate -c ./external-config.json --yes
196+
$ csdx app:update --app-manifest ./boilerplate/manifest.json
210197
```
211198

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

src/commands/app/base-command.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
5151
}),
5252
yes: Flags.boolean({
5353
char: "y",
54+
hidden: true,
5455
description: commonMsg.SKIP_CONFIRMATION,
5556
}),
5657
};
@@ -139,9 +140,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
139140
*/
140141
getValPrompt(
141142
options: Partial<InquirePayload> & Record<string, any> = {
142-
message: 'Enter value',
143+
message: "Enter value",
143144
validate: (val) => {
144-
if (!val) return this.$t(this.messages.NOT_EMPTY, { value: 'Value' });
145+
if (!val) return this.$t(this.messages.NOT_EMPTY, { value: "Value" });
145146
return true;
146147
},
147148
}

src/commands/app/create.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import pick from "lodash/pick";
44
import * as shell from "shelljs";
55
import merge from "lodash/merge";
66
import isEmpty from "lodash/isEmpty";
7-
import { dirname, join } from "path";
7+
import { dirname, resolve } from "path";
88
import { AppData } from "@contentstack/management/types/app";
99
import {
1010
rmSync,
@@ -16,9 +16,9 @@ import {
1616
} from "fs";
1717
import { ux, cliux, flags, HttpClient } from "@contentstack/cli-utilities";
1818

19-
import { appCreate, commonMsg } from "../../messages";
2019
import { BaseCommand } from "./base-command";
2120
import { AppManifest, AppType } from "../../types";
21+
import { appCreate, commonMsg } from "../../messages";
2222
import {
2323
getOrg,
2424
getAppName,
@@ -30,13 +30,14 @@ export default class Create extends BaseCommand<typeof Create> {
3030
private appData!: AppManifest;
3131
static hidden: boolean = false;
3232

33-
static description = "Create new app in developer hub";
33+
static description =
34+
"Create a new app in Developer Hub and optionally clone a boilerplate locally.";
3435

3536
static examples = [
3637
"$ <%= config.bin %> <%= command.id %>",
37-
"$ <%= config.bin %> <%= command.id %> --name App-1 --app-type stack --yes",
38-
"$ <%= config.bin %> <%= command.id %> --name App-2 --app-type stack -d ./boilerplate --yes",
39-
"$ <%= config.bin %> <%= command.id %> --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json --yes",
38+
"$ <%= config.bin %> <%= command.id %> --name App-1 --app-type stack",
39+
"$ <%= config.bin %> <%= command.id %> --name App-2 --app-type stack -d ./boilerplate",
40+
"$ <%= config.bin %> <%= command.id %> --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json",
4041
];
4142

4243
static flags = {
@@ -86,8 +87,11 @@ export default class Create extends BaseCommand<typeof Create> {
8687
} else {
8788
await this.registerTheAppOnDeveloperHub(false);
8889
}
89-
} catch (error) {
90-
this.log(error, "error");
90+
} catch (error: Error | any) {
91+
if (error?.errorMessage || error?.message || !isEmpty(error)) {
92+
this.log(error?.errorMessage || error?.message || error, "error");
93+
}
94+
9195
this.exit(1);
9296
}
9397
}
@@ -173,9 +177,9 @@ export default class Create extends BaseCommand<typeof Create> {
173177
*/
174178
async unZipBoilerplate(filepath: string) {
175179
const zip = new AdmZip(filepath);
176-
const dataDir = this.flags["data-dir"] || process.cwd();
177-
let targetPath = join(dataDir, this.sharedConfig.appName);
178-
const sourcePath = join(dataDir, this.sharedConfig.boilerplateName);
180+
const dataDir = this.flags["data-dir"] ?? process.cwd();
181+
let targetPath = resolve(dataDir, this.sharedConfig.appName);
182+
const sourcePath = resolve(dataDir, this.sharedConfig.boilerplateName);
179183

180184
if (this.flags["data-dir"] && !existsSync(this.flags["data-dir"])) {
181185
mkdirSync(this.flags["data-dir"], { recursive: true });
@@ -250,7 +254,7 @@ export default class Create extends BaseCommand<typeof Create> {
250254
this.appData = merge(this.appData, pick(response, validKeys));
251255
if (saveManifest) {
252256
writeFileSync(
253-
join(this.sharedConfig.folderPath, "manifest.json"),
257+
resolve(this.sharedConfig.folderPath, "manifest.json"),
254258
JSON.stringify(this.appData),
255259
{
256260
encoding: "utf8",
@@ -335,7 +339,7 @@ export default class Create extends BaseCommand<typeof Create> {
335339
this.sharedConfig.oldFolderPath = this.sharedConfig.folderPath;
336340
}
337341

338-
this.sharedConfig.folderPath = join(
342+
this.sharedConfig.folderPath = resolve(
339343
dirname(this.sharedConfig.folderPath),
340344
this.appData.name
341345
);

src/commands/app/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { resolve } from "path";
2+
import { exec } from "child_process";
13
import { Command } from "@contentstack/cli-utilities";
24

35
import { print } from "../../util/log";
4-
import { exec } from "child_process";
5-
import { join } from "path";
66

77
export default class App extends Command {
88
static description = "Apps CLI plugin";
@@ -20,7 +20,7 @@ export default class App extends Command {
2020

2121
async run(): Promise<void> {
2222
exec(
23-
`${join(process.cwd(), "bin", "run")} app --help`,
23+
`${resolve(process.cwd(), "bin", "run")} app --help`,
2424
(_er, stdout, _stderr) => {
2525
if (stdout) {
2626
this.log(`\n${stdout}`);

0 commit comments

Comments
 (0)