@contentstack/apps-cli 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @contentstack/apps-cli
20
20
  $ csdx COMMAND
21
21
  running command...
22
22
  $ csdx (--version|-v)
23
- @contentstack/apps-cli/1.2.1 darwin-arm64 node-v18.12.1
23
+ @contentstack/apps-cli/1.3.1 darwin-arm64 node-v18.20.2
24
24
  $ csdx --help [COMMAND]
25
25
  USAGE
26
26
  $ csdx COMMAND
@@ -54,20 +54,22 @@ DESCRIPTION
54
54
  EXAMPLES
55
55
  $ csdx app:create
56
56
 
57
- $ csdx app:get
57
+ $ csdx app:delete
58
58
 
59
- $ csdx app:update
59
+ $ csdx app:deploy
60
60
 
61
- $ csdx app:delete
61
+ $ csdx app:get
62
62
 
63
63
  $ csdx app:install
64
64
 
65
+ $ csdx app:reinstall
66
+
65
67
  $ csdx app:uninstall
66
68
 
67
- $ csdx app:reinstall
69
+ $ csdx app:update
68
70
  ```
69
71
 
70
- _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/index.ts)_
72
+ _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/index.ts)_
71
73
 
72
74
  ## `csdx app:create`
73
75
 
@@ -75,14 +77,18 @@ Create a new app in Developer Hub and optionally clone a boilerplate locally.
75
77
 
76
78
  ```
77
79
  USAGE
78
- $ csdx app:create [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
80
+ $ csdx app:create [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>] [--boilerplate
81
+ <value>] [--org <value>]
79
82
 
80
83
  FLAGS
81
84
  -c, --config=<value> Path of the external config
82
85
  -d, --data-dir=<value> Current working directory.
83
- -n, --name=<value> [default: app-boilerplate] Name of the app to be created
86
+ -n, --name=<value> Name of the app to be created
84
87
  --app-type=<option> [default: stack] Type of app
85
88
  <options: stack|organization>
89
+ --boilerplate=<value> Provide a boilerplate. <options: App Boilerplate|DAM App Boilerplate|Ecommerce App
90
+ Boilerplate>
91
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
86
92
 
87
93
  DESCRIPTION
88
94
  Create a new app in Developer Hub and optionally clone a boilerplate locally.
@@ -95,9 +101,15 @@ EXAMPLES
95
101
  $ csdx app:create --name App-2 --app-type stack -d ./boilerplate
96
102
 
97
103
  $ csdx app:create --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json
104
+
105
+ $ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <App Boilerplate>
106
+
107
+ $ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <DAM App Boilerplate>
108
+
109
+ $ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>
98
110
  ```
99
111
 
100
- _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/create.ts)_
112
+ _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/create.ts)_
101
113
 
102
114
  ## `csdx app:delete`
103
115
 
@@ -105,10 +117,11 @@ Delete app from marketplace
105
117
 
106
118
  ```
107
119
  USAGE
108
- $ csdx app:delete [--app-uid <value>]
120
+ $ csdx app:delete [--app-uid <value>] [--org <value>]
109
121
 
110
122
  FLAGS
111
123
  --app-uid=<value> Provide the app UID of an existing app.
124
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
112
125
 
113
126
  DESCRIPTION
114
127
  Delete app from marketplace
@@ -121,7 +134,7 @@ EXAMPLES
121
134
  $ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
122
135
  ```
123
136
 
124
- _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/delete.ts)_
137
+ _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/delete.ts)_
125
138
 
126
139
  ## `csdx app:deploy`
127
140
 
@@ -130,7 +143,7 @@ Deploy an app
130
143
  ```
131
144
  USAGE
132
145
  $ csdx app:deploy [--app-uid <value>] [--hosting-type Hosting with Launch|Custom Hosting] [--app-url <value>]
133
- [--launch-project existing|new] [-c <value>]
146
+ [--launch-project existing|new] [-c <value>] [--org <value>]
134
147
 
135
148
  FLAGS
136
149
  -c, --config=<value> [optional] Please enter the path of the config file.
@@ -140,6 +153,7 @@ FLAGS
140
153
  <options: Hosting with Launch|Custom Hosting>
141
154
  --launch-project=<option> Choose a new or an existing Launch project.
142
155
  <options: existing|new>
156
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
143
157
 
144
158
  DESCRIPTION
145
159
  Deploy an app
@@ -158,7 +172,7 @@ EXAMPLES
158
172
  $ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new> --config <config-path>
159
173
  ```
160
174
 
161
- _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/deploy.ts)_
175
+ _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/deploy.ts)_
162
176
 
163
177
  ## `csdx app:get`
164
178
 
@@ -166,13 +180,14 @@ Get details of an app in developer hub
166
180
 
167
181
  ```
168
182
  USAGE
169
- $ csdx app:get [--app-uid <value>] [--app-type stack|organization] [-d <value>]
183
+ $ csdx app:get [--app-uid <value>] [--app-type stack|organization] [-d <value>] [--org <value>]
170
184
 
171
185
  FLAGS
172
186
  -d, --data-dir=<value> Current working directory.
173
187
  --app-type=<option> [default: stack] Type of app
174
188
  <options: stack|organization>
175
189
  --app-uid=<value> Provide the app UID of an existing app.
190
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
176
191
 
177
192
  DESCRIPTION
178
193
  Get details of an app in developer hub
@@ -187,7 +202,7 @@ EXAMPLES
187
202
  $ csdx app:get --org <value> --app-uid <value> --app-type organization
188
203
  ```
189
204
 
190
- _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/get.ts)_
205
+ _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/get.ts)_
191
206
 
192
207
  ## `csdx app:install`
193
208
 
@@ -195,10 +210,11 @@ Install an app from the marketplace
195
210
 
196
211
  ```
197
212
  USAGE
198
- $ csdx app:install [--app-uid <value>] [--stack-api-key <value>]
213
+ $ csdx app:install [--app-uid <value>] [--stack-api-key <value>] [--org <value>]
199
214
 
200
215
  FLAGS
201
216
  --app-uid=<value> Provide the app UID of an existing app.
217
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
202
218
  --stack-api-key=<value> API key of the stack where the app operation is to be performed.
203
219
 
204
220
  DESCRIPTION
@@ -212,7 +228,7 @@ EXAMPLES
212
228
  $ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
213
229
  ```
214
230
 
215
- _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/install.ts)_
231
+ _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/install.ts)_
216
232
 
217
233
  ## `csdx app:reinstall`
218
234
 
@@ -220,10 +236,11 @@ Reinstall an app from the marketplace
220
236
 
221
237
  ```
222
238
  USAGE
223
- $ csdx app:reinstall [--app-uid <value>] [--stack-api-key <value>]
239
+ $ csdx app:reinstall [--app-uid <value>] [--stack-api-key <value>] [--org <value>]
224
240
 
225
241
  FLAGS
226
242
  --app-uid=<value> Provide the app UID of an existing app.
243
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
227
244
  --stack-api-key=<value> API key of the stack where the app operation is to be performed.
228
245
 
229
246
  DESCRIPTION
@@ -237,7 +254,7 @@ EXAMPLES
237
254
  $ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
238
255
  ```
239
256
 
240
- _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/reinstall.ts)_
257
+ _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/reinstall.ts)_
241
258
 
242
259
  ## `csdx app:uninstall`
243
260
 
@@ -245,11 +262,12 @@ Uninstall an app
245
262
 
246
263
  ```
247
264
  USAGE
248
- $ csdx app:uninstall [--app-uid <value>] [--installation-uid <value>] [--uninstall-all]
265
+ $ csdx app:uninstall [--app-uid <value>] [--installation-uid <value>] [--uninstall-all] [--org <value>]
249
266
 
250
267
  FLAGS
251
268
  --app-uid=<value> Provide the app UID of an existing app.
252
269
  --installation-uid=<value> Provide the installation ID of the app that needs to be uninstalled.
270
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
253
271
  --uninstall-all Please select stacks from where the app must be uninstalled.
254
272
 
255
273
  DESCRIPTION
@@ -263,7 +281,7 @@ EXAMPLES
263
281
  $ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
264
282
  ```
265
283
 
266
- _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/uninstall.ts)_
284
+ _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/uninstall.ts)_
267
285
 
268
286
  ## `csdx app:update`
269
287
 
@@ -271,10 +289,11 @@ Update the existing app in developer hub
271
289
 
272
290
  ```
273
291
  USAGE
274
- $ csdx app:update [--app-manifest <value>]
292
+ $ csdx app:update [--app-manifest <value>] [--org <value>]
275
293
 
276
294
  FLAGS
277
295
  --app-manifest=<value> Path to the app manifest.json file:
296
+ --org=<value> Provide the organization UID to fetch the app details for the operation.
278
297
 
279
298
  DESCRIPTION
280
299
  Update the existing app in developer hub
@@ -285,5 +304,5 @@ EXAMPLES
285
304
  $ csdx app:update --app-manifest ./boilerplate/manifest.json
286
305
  ```
287
306
 
288
- _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.2.1/src/commands/app/update.ts)_
307
+ _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/update.ts)_
289
308
  <!-- commandsstop -->
@@ -29,14 +29,14 @@ class BaseCommand extends cli_command_1.Command {
29
29
  this.args = args;
30
30
  cli_utilities_1.cliux.registerSearchPlugin();
31
31
  this.registerConfig();
32
- this.developerHubBaseUrl =
33
- this.sharedConfig.developerHubBaseUrl || (0, util_1.getDeveloperHubUrl)();
34
- await this.initCmaSDK();
35
- await this.initMarketplaceSDK();
36
32
  // Init logger
37
33
  const logger = new util_1.Logger(this.sharedConfig);
38
34
  this.log = logger.log.bind(logger);
39
35
  this.validateRegionAndAuth();
36
+ this.developerHubBaseUrl =
37
+ this.sharedConfig.developerHubBaseUrl || (0, util_1.getDeveloperHubUrl)();
38
+ await this.initCmaSDK();
39
+ await this.initMarketplaceSDK();
40
40
  }
41
41
  async catch(err) {
42
42
  // add any custom logic to handle errors from the command
@@ -27,6 +27,7 @@ class Create extends base_command_1.BaseCommand {
27
27
  async run() {
28
28
  this.sharedConfig.org = this.flags.org;
29
29
  this.sharedConfig.appName = this.flags.name;
30
+ this.sharedConfig.boilerplateName = this.flags.boilerplate;
30
31
  await this.flagsPromptQueue();
31
32
  this.tempAppData.name = this.sharedConfig.appName;
32
33
  this.tempAppData.target_type = this.flags["app-type"];
@@ -81,8 +82,27 @@ class Create extends base_command_1.BaseCommand {
81
82
  */
82
83
  async flagsPromptQueue() {
83
84
  var _a;
84
- if ((0, isEmpty_1.default)(this.sharedConfig.appName)) {
85
- this.sharedConfig.appName = await (0, util_1.getAppName)(this.sharedConfig.defaultAppName);
85
+ if (this.sharedConfig.appName) {
86
+ (0, util_1.validateAppName)(this.sharedConfig.appName);
87
+ }
88
+ let boilerplate = null;
89
+ if ((0, isEmpty_1.default)(this.sharedConfig.boilerplateName)) {
90
+ boilerplate = await (0, util_1.selectedBoilerplate)();
91
+ }
92
+ else {
93
+ boilerplate = (await (0, util_1.validateBoilerplate)(this.sharedConfig.boilerplateName));
94
+ }
95
+ if (boilerplate) {
96
+ let boilerplateName = this.sharedConfig.appName || boilerplate.name;
97
+ if ((0, isEmpty_1.default)(this.sharedConfig.appName)) {
98
+ boilerplateName = boilerplateName
99
+ .toLowerCase()
100
+ .replace(/ /g, "-")
101
+ .substring(0, 20);
102
+ }
103
+ this.sharedConfig.boilerplateName = boilerplateName;
104
+ this.sharedConfig.appBoilerplateGithubUrl = boilerplate.link;
105
+ this.sharedConfig.appName = boilerplateName;
86
106
  }
87
107
  //Auto select org in case of oauth
88
108
  this.sharedConfig.org =
@@ -126,7 +146,10 @@ class Create extends base_command_1.BaseCommand {
126
146
  const zip = new adm_zip_1.default(filepath);
127
147
  const dataDir = (_a = this.flags["data-dir"]) !== null && _a !== void 0 ? _a : process.cwd();
128
148
  let targetPath = (0, path_1.resolve)(dataDir, this.sharedConfig.appName);
129
- const sourcePath = (0, path_1.resolve)(dataDir, this.sharedConfig.boilerplateName);
149
+ // Get the directory inside the zip file
150
+ const zipEntries = zip.getEntries();
151
+ const firstEntry = zipEntries[0];
152
+ const sourcePath = (0, path_1.resolve)((0, util_1.sanitizePath)(dataDir), (0, util_1.sanitizePath)(firstEntry.entryName.split("/")[0]));
130
153
  if (this.flags["data-dir"] && !(0, fs_1.existsSync)(this.flags["data-dir"])) {
131
154
  (0, fs_1.mkdirSync)(this.flags["data-dir"], { recursive: true });
132
155
  }
@@ -156,7 +179,7 @@ class Create extends base_command_1.BaseCommand {
156
179
  */
157
180
  manageManifestToggeling() {
158
181
  // NOTE Use boilerplate manifest if exist
159
- const manifestPath = (0, path_1.resolve)(this.sharedConfig.folderPath || "", "manifest.json");
182
+ const manifestPath = (0, path_1.resolve)(this.sharedConfig.folderPath, "manifest.json");
160
183
  if ((0, fs_1.existsSync)(manifestPath)) {
161
184
  this.sharedConfig.manifestPath = manifestPath;
162
185
  }
@@ -298,25 +321,24 @@ Create.examples = [
298
321
  "$ <%= config.bin %> <%= command.id %> --name App-1 --app-type stack",
299
322
  "$ <%= config.bin %> <%= command.id %> --name App-2 --app-type stack -d ./boilerplate",
300
323
  "$ <%= config.bin %> <%= command.id %> --name App-3 --app-type organization --org <UID> -d ./boilerplate -c ./external-config.json",
324
+ "$ <%= config.bin %> <%= command.id %> --name App-4 --app-type organization --org <UID> --boilerplate <App Boilerplate>",
325
+ "$ <%= config.bin %> <%= command.id %> --name App-4 --app-type organization --org <UID> --boilerplate <DAM App Boilerplate>",
326
+ "$ <%= config.bin %> <%= command.id %> --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>",
301
327
  ];
302
- Create.flags = {
303
- name: cli_utilities_1.flags.string({
328
+ Create.flags = Object.assign({ name: cli_utilities_1.flags.string({
304
329
  char: "n",
305
- default: "app-boilerplate",
306
330
  description: messages_1.appCreate.NAME_DESCRIPTION,
307
- }),
308
- "app-type": cli_utilities_1.flags.string({
331
+ }), "app-type": cli_utilities_1.flags.string({
309
332
  default: "stack",
310
333
  options: ["stack", "organization"],
311
334
  description: messages_1.appCreate.APP_TYPE_DESCRIPTION,
312
- }),
313
- config: cli_utilities_1.flags.string({
335
+ }), config: cli_utilities_1.flags.string({
314
336
  char: "c",
315
337
  description: messages_1.commonMsg.CONFIG,
316
- }),
317
- "data-dir": cli_utilities_1.flags.string({
338
+ }), "data-dir": cli_utilities_1.flags.string({
318
339
  char: "d",
319
340
  description: messages_1.commonMsg.CURRENT_WORKING_DIR,
320
- }),
321
- };
341
+ }), boilerplate: cli_utilities_1.flags.string({
342
+ description: messages_1.appCreate.BOILERPLATE_TEMPLATES,
343
+ }) }, base_command_1.BaseCommand.baseFlags);
322
344
  exports.default = Create;
@@ -67,9 +67,7 @@ Delete.examples = [
67
67
  "$ <%= config.bin %> <%= command.id %> --app-uid <value>",
68
68
  "$ <%= config.bin %> <%= command.id %> --app-uid <value> --org <value> -d ./boilerplate",
69
69
  ];
70
- Delete.flags = {
71
- "app-uid": cli_utilities_1.flags.string({
70
+ Delete.flags = Object.assign({ "app-uid": cli_utilities_1.flags.string({
72
71
  description: messages_1.commonMsg.APP_UID,
73
- }),
74
- };
72
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
75
73
  exports.default = Delete;
@@ -208,26 +208,20 @@ Deploy.examples = [
208
208
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new>",
209
209
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new> --config <config-path>",
210
210
  ];
211
- Deploy.flags = {
212
- "app-uid": cli_utilities_1.Flags.string({
211
+ Deploy.flags = Object.assign({ "app-uid": cli_utilities_1.Flags.string({
213
212
  description: messages_1.commonMsg.APP_UID,
214
- }),
215
- "hosting-type": cli_utilities_1.Flags.string({
213
+ }), "hosting-type": cli_utilities_1.Flags.string({
216
214
  multiple: false,
217
215
  options: ["Hosting with Launch", "Custom Hosting"],
218
216
  description: messages_1.deployAppMsg.HOSTING_TYPE,
219
- }),
220
- "app-url": cli_utilities_1.Flags.string({
217
+ }), "app-url": cli_utilities_1.Flags.string({
221
218
  description: messages_1.deployAppMsg.APP_URL,
222
- }),
223
- "launch-project": cli_utilities_1.Flags.string({
219
+ }), "launch-project": cli_utilities_1.Flags.string({
224
220
  multiple: false,
225
221
  options: ["existing", "new"],
226
222
  description: messages_1.deployAppMsg.LAUNCH_PROJECT,
227
- }),
228
- config: cli_utilities_1.Flags.string({
223
+ }), config: cli_utilities_1.Flags.string({
229
224
  char: "c",
230
225
  description: messages_1.deployAppMsg.CONFIG_FILE,
231
- }),
232
- };
226
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
233
227
  exports.default = Deploy;
@@ -42,18 +42,14 @@ Get.examples = [
42
42
  "$ <%= config.bin %> <%= command.id %> --org <value> --app-uid <value> --app-type stack",
43
43
  "$ <%= config.bin %> <%= command.id %> --org <value> --app-uid <value> --app-type organization",
44
44
  ];
45
- Get.flags = {
46
- "app-uid": cli_utilities_1.flags.string({
45
+ Get.flags = Object.assign({ "app-uid": cli_utilities_1.flags.string({
47
46
  description: messages_1.commonMsg.APP_UID,
48
- }),
49
- "app-type": cli_utilities_1.flags.string({
47
+ }), "app-type": cli_utilities_1.flags.string({
50
48
  default: "stack",
51
49
  options: ["stack", "organization"],
52
50
  description: messages_1.commonMsg.APP_TYPE_DESCRIPTION,
53
- }),
54
- "data-dir": cli_utilities_1.flags.string({
51
+ }), "data-dir": cli_utilities_1.flags.string({
55
52
  char: "d",
56
53
  description: messages_1.commonMsg.CURRENT_WORKING_DIR,
57
- }),
58
- };
54
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
59
55
  exports.default = Get;
@@ -25,11 +25,12 @@ class App extends cli_utilities_1.Command {
25
25
  App.description = "Apps CLI plugin";
26
26
  App.examples = [
27
27
  "$ <%= config.bin %> <%= command.id %>:create",
28
- "$ <%= config.bin %> <%= command.id %>:get",
29
- "$ <%= config.bin %> <%= command.id %>:update",
30
28
  "$ <%= config.bin %> <%= command.id %>:delete",
29
+ "$ <%= config.bin %> <%= command.id %>:deploy",
30
+ "$ <%= config.bin %> <%= command.id %>:get",
31
31
  "$ <%= config.bin %> <%= command.id %>:install",
32
- "$ <%= config.bin %> <%= command.id %>:uninstall",
33
32
  "$ <%= config.bin %> <%= command.id %>:reinstall",
33
+ "$ <%= config.bin %> <%= command.id %>:uninstall",
34
+ "$ <%= config.bin %> <%= command.id %>:update",
34
35
  ];
35
36
  exports.default = App;
@@ -109,12 +109,9 @@ Install.examples = [
109
109
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1>",
110
110
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>",
111
111
  ];
112
- Install.flags = {
113
- "app-uid": cli_utilities_1.flags.string({
112
+ Install.flags = Object.assign({ "app-uid": cli_utilities_1.flags.string({
114
113
  description: messages_1.commonMsg.APP_UID,
115
- }),
116
- "stack-api-key": cli_utilities_1.flags.string({
114
+ }), "stack-api-key": cli_utilities_1.flags.string({
117
115
  description: messages_1.commonMsg.STACK_API_KEY,
118
- }),
119
- };
116
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
120
117
  exports.default = Install;
@@ -94,12 +94,9 @@ Reinstall.examples = [
94
94
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1>",
95
95
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>",
96
96
  ];
97
- Reinstall.flags = {
98
- "app-uid": cli_utilities_1.flags.string({
97
+ Reinstall.flags = Object.assign({ "app-uid": cli_utilities_1.flags.string({
99
98
  description: messages_1.commonMsg.APP_UID,
100
- }),
101
- "stack-api-key": cli_utilities_1.flags.string({
99
+ }), "stack-api-key": cli_utilities_1.flags.string({
102
100
  description: messages_1.commonMsg.STACK_API_KEY,
103
- }),
104
- };
101
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
105
102
  exports.default = Reinstall;
@@ -39,15 +39,11 @@ Uninstall.examples = [
39
39
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1>",
40
40
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>",
41
41
  ];
42
- Uninstall.flags = {
43
- 'app-uid': cli_utilities_1.flags.string({
42
+ Uninstall.flags = Object.assign({ 'app-uid': cli_utilities_1.flags.string({
44
43
  description: messages_1.commonMsg.APP_UID,
45
- }),
46
- 'installation-uid': cli_utilities_1.flags.string({
44
+ }), 'installation-uid': cli_utilities_1.flags.string({
47
45
  description: messages_1.uninstallAppMsg.INSTALLATION_UID
48
- }),
49
- 'uninstall-all': cli_utilities_1.flags.boolean({
46
+ }), 'uninstall-all': cli_utilities_1.flags.boolean({
50
47
  description: messages_1.uninstallAppMsg.UNINSTALL_ALL,
51
- }),
52
- };
48
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
53
49
  exports.default = Uninstall;
@@ -187,9 +187,7 @@ Update.examples = [
187
187
  "$ <%= config.bin %> <%= command.id %>",
188
188
  "$ <%= config.bin %> <%= command.id %> --app-manifest ./boilerplate/manifest.json",
189
189
  ];
190
- Update.flags = {
191
- "app-manifest": cli_utilities_1.flags.string({
190
+ Update.flags = Object.assign({ "app-manifest": cli_utilities_1.flags.string({
192
191
  description: (0, messages_1.$t)(messages_1.appUpdate.FILE_PATH, { fileName: "app manifest.json" }),
193
- }),
194
- };
192
+ }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
195
193
  exports.default = Update;
@@ -1,9 +1,9 @@
1
1
  declare const config: {
2
2
  defaultAppName: string;
3
3
  manifestPath: string;
4
- boilerplateName: string;
5
4
  developerHubBaseUrl: string;
6
5
  appBoilerplateGithubUrl: string;
7
6
  defaultAppFileName: string;
7
+ boilerplatesUrl: string;
8
8
  };
9
9
  export default config;
@@ -4,9 +4,9 @@ const path_1 = require("path");
4
4
  const config = {
5
5
  defaultAppName: "app-boilerplate",
6
6
  manifestPath: (0, path_1.resolve)(__dirname, "manifest.json"),
7
- boilerplateName: "marketplace-app-boilerplate-main",
8
7
  developerHubBaseUrl: "",
9
8
  appBoilerplateGithubUrl: "https://codeload.github.com/contentstack/marketplace-app-boilerplate/zip/refs/heads/main",
10
9
  defaultAppFileName: "manifest",
10
+ boilerplatesUrl: 'https://marketplace-artifacts.contentstack.com/cli/starter-template.json'
11
11
  };
12
12
  exports.default = config;
@@ -44,6 +44,8 @@ declare const appCreate: {
44
44
  CONFIRM_CLONE_BOILERPLATE: string;
45
45
  REGISTER_THE_APP_ON_DEVELOPER_HUB: string;
46
46
  START_APP_COMMAND: string;
47
+ BOILERPLATE_TEMPLATES: string;
48
+ SELECT_BOILERPLATE: string;
47
49
  };
48
50
  declare const getAppMsg: {
49
51
  CHOOSE_APP: string;
@@ -49,6 +49,8 @@ const appCreate = {
49
49
  CONFIRM_CLONE_BOILERPLATE: "Would you like to fetch the app template from GitHub?",
50
50
  REGISTER_THE_APP_ON_DEVELOPER_HUB: "Registering the app with the name {appName} on the Developer Hub...",
51
51
  START_APP_COMMAND: "Start the app using the following command: {command}",
52
+ BOILERPLATE_TEMPLATES: "Provide a boilerplate. <options: App Boilerplate|DAM App Boilerplate|Ecommerce App Boilerplate>",
53
+ SELECT_BOILERPLATE: "Select one from the following boilerplates:"
52
54
  };
53
55
  exports.appCreate = appCreate;
54
56
  const getAppMsg = {
@@ -122,3 +122,11 @@ export interface LaunchProjectRes {
122
122
  environmentUid: any;
123
123
  developerHubAppUid: any;
124
124
  }
125
+ export interface BoilerplateAppType {
126
+ name: string;
127
+ description?: string;
128
+ link: string;
129
+ tags?: string[];
130
+ created_at?: string;
131
+ updated_at?: string;
132
+ }
@@ -35,4 +35,6 @@ declare function setupConfig(configPath: string): Record<string, string>;
35
35
  declare function disconnectApp(flags: FlagInput, orgUid: string, developerHubBaseUrl: string): Promise<any>;
36
36
  declare function formatUrl(url: string): string;
37
37
  declare const handleProjectNameConflict: (projectName: string, projects: any[], retry?: number) => Promise<string>;
38
- export { getOrganizations, getOrgAppUiLocation, fetchApps, fetchApp, fetchAppInstallations, deleteApp, installApp, getStacks, fetchStack, uninstallApp, fetchInstalledApps, reinstallApp, sanitizePath, updateApp, getProjects, getManifestDetails, setupConfig, disconnectApp, formatUrl, handleProjectNameConflict, };
38
+ declare function fetchBoilerplateDetails(): Promise<Record<string, any>[]>;
39
+ declare function validateBoilerplate(boilerplateName: string): Promise<Record<string, any>>;
40
+ export { getOrganizations, getOrgAppUiLocation, fetchApps, fetchApp, fetchAppInstallations, deleteApp, installApp, getStacks, fetchStack, uninstallApp, fetchInstalledApps, reinstallApp, sanitizePath, updateApp, getProjects, getManifestDetails, setupConfig, disconnectApp, formatUrl, handleProjectNameConflict, fetchBoilerplateDetails, validateBoilerplate, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleProjectNameConflict = exports.formatUrl = exports.disconnectApp = exports.setupConfig = exports.getManifestDetails = exports.getProjects = exports.updateApp = exports.sanitizePath = exports.reinstallApp = exports.fetchInstalledApps = exports.uninstallApp = exports.fetchStack = exports.getStacks = exports.installApp = exports.deleteApp = exports.fetchAppInstallations = exports.fetchApp = exports.fetchApps = exports.getOrgAppUiLocation = exports.getOrganizations = void 0;
3
+ exports.validateBoilerplate = exports.fetchBoilerplateDetails = exports.handleProjectNameConflict = exports.formatUrl = exports.disconnectApp = exports.setupConfig = exports.getManifestDetails = exports.getProjects = exports.updateApp = exports.sanitizePath = exports.reinstallApp = exports.fetchInstalledApps = exports.uninstallApp = exports.fetchStack = exports.getStacks = exports.installApp = exports.deleteApp = exports.fetchAppInstallations = exports.fetchApp = exports.fetchApps = exports.getOrgAppUiLocation = exports.getOrganizations = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const map_1 = tslib_1.__importDefault(require("lodash/map"));
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
@@ -9,6 +9,8 @@ const api_request_handler_1 = require("./api-request-handler");
9
9
  const types_1 = require("../types");
10
10
  const inquirer_1 = require("./inquirer");
11
11
  const messages_1 = require("../messages");
12
+ const config_1 = tslib_1.__importDefault(require("../config"));
13
+ const find_1 = tslib_1.__importDefault(require("lodash/find"));
12
14
  async function getOrganizations(options, skip = 0, organizations = []) {
13
15
  const { log, managementSdk } = options;
14
16
  const response = await managementSdk
@@ -296,3 +298,23 @@ const handleProjectNameConflict = async (projectName, projects, retry = 1) => {
296
298
  return projectName;
297
299
  };
298
300
  exports.handleProjectNameConflict = handleProjectNameConflict;
301
+ async function fetchBoilerplateDetails() {
302
+ var _a, _b;
303
+ try {
304
+ const content = await new cli_utilities_1.HttpClient().get(config_1.default.boilerplatesUrl);
305
+ return (_b = (_a = content === null || content === void 0 ? void 0 : content.data) === null || _a === void 0 ? void 0 : _a.templates) !== null && _b !== void 0 ? _b : [];
306
+ }
307
+ catch (error) {
308
+ throw error;
309
+ }
310
+ }
311
+ exports.fetchBoilerplateDetails = fetchBoilerplateDetails;
312
+ async function validateBoilerplate(boilerplateName) {
313
+ const boilerplates = await fetchBoilerplateDetails();
314
+ const boilerplate = (0, find_1.default)(boilerplates, (boilerplate) => boilerplate.name === boilerplateName);
315
+ if (!boilerplate) {
316
+ throw new Error("Invalid boilerplate! Please select a boilerplate from the following options: App Boilerplate, DAM App Boilerplate or Ecommerce App Boilerplate");
317
+ }
318
+ return boilerplate;
319
+ }
320
+ exports.validateBoilerplate = validateBoilerplate;
@@ -39,4 +39,6 @@ declare function selectProject(projects: LaunchProjectRes[]): Promise<LaunchProj
39
39
  declare const askProjectType: () => Promise<string>;
40
40
  declare function askConfirmation(): Promise<boolean>;
41
41
  declare const askProjectName: (projectName: string) => Promise<string>;
42
- export { getOrg, getAppName, getDirName, getDeveloperHubUrl, getApp, getInstalledApps, getStack, getInstallation, getHostingType, getAppUrl, askProjectType, askConfirmation, selectProject, askProjectName };
42
+ declare const selectedBoilerplate: () => Promise<any>;
43
+ declare const validateAppName: (name: string) => void;
44
+ export { getOrg, getAppName, getDirName, getDeveloperHubUrl, getApp, getInstalledApps, getStack, getInstallation, getHostingType, getAppUrl, askProjectType, askConfirmation, selectProject, askProjectName, selectedBoilerplate, validateAppName, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.askProjectName = exports.selectProject = exports.askConfirmation = exports.askProjectType = exports.getAppUrl = exports.getHostingType = exports.getInstallation = exports.getStack = exports.getInstalledApps = exports.getApp = exports.getDeveloperHubUrl = exports.getDirName = exports.getAppName = exports.getOrg = void 0;
3
+ exports.validateAppName = exports.selectedBoilerplate = exports.askProjectName = exports.selectProject = exports.askConfirmation = exports.askProjectType = exports.getAppUrl = exports.getHostingType = exports.getInstallation = exports.getStack = exports.getInstalledApps = exports.getApp = exports.getDeveloperHubUrl = exports.getDirName = exports.getAppName = exports.getOrg = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const find_1 = tslib_1.__importDefault(require("lodash/find"));
6
6
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
@@ -126,6 +126,9 @@ exports.getInstalledApps = getInstalledApps;
126
126
  */
127
127
  function getDeveloperHubUrl() {
128
128
  const { cma } = cli_utilities_1.configHandler.get("region") || {};
129
+ if (!cma) {
130
+ throw new Error("Region not configured. Please set the region with command $ csdx config:set:region");
131
+ }
129
132
  let developerHubBaseUrl = cma.replace("api", "developerhub-api");
130
133
  if (developerHubBaseUrl.startsWith("http")) {
131
134
  developerHubBaseUrl = developerHubBaseUrl.split("//")[1];
@@ -297,3 +300,23 @@ function inquireRequireValidation(input) {
297
300
  }
298
301
  return true;
299
302
  }
303
+ const selectedBoilerplate = async () => {
304
+ const boilerplates = await (0, common_utils_1.fetchBoilerplateDetails)();
305
+ return await cli_utilities_1.cliux
306
+ .inquire({
307
+ type: "search-list",
308
+ name: "App",
309
+ choices: boilerplates.map((bp) => bp.name),
310
+ message: messages_1.appCreate.SELECT_BOILERPLATE,
311
+ })
312
+ .then((name) => {
313
+ return (0, find_1.default)(boilerplates, (boilerplate) => boilerplate.name === name);
314
+ });
315
+ };
316
+ exports.selectedBoilerplate = selectedBoilerplate;
317
+ const validateAppName = (name) => {
318
+ if (name.length < 3 || name.length > 20) {
319
+ throw new Error((0, messages_1.$t)(messages_1.errors.INVALID_NAME, { min: "3", max: "20" }));
320
+ }
321
+ };
322
+ exports.validateAppName = validateAppName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/apps-cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "App ClI",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/contentstack-apps-cli",
@@ -23,7 +23,7 @@
23
23
  "@apollo/client": "^3.7.9",
24
24
  "@contentstack/cli-command": "^1.2.18",
25
25
  "@contentstack/cli-launch": "^1.0.18",
26
- "@contentstack/cli-utilities": "^1.6.2",
26
+ "@contentstack/cli-utilities": "^1.7.0",
27
27
  "adm-zip": "^0.5.10",
28
28
  "chalk": "^4.1.2",
29
29
  "lodash": "^4.17.21",