@contentstack/apps-cli 1.5.0 → 1.6.0

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
@@ -16,31 +16,34 @@ $ csdx plugins:install @contentstack/apps-cli
16
16
  This plugin requires you to be authenticated using [csdx auth:login](https://www.contentstack.com/docs/developers/cli/authenticate-with-the-cli/).
17
17
 
18
18
  <!-- usage -->
19
+
19
20
  ```sh-session
20
21
  $ npm install -g @contentstack/apps-cli
21
22
  $ csdx COMMAND
22
23
  running command...
23
24
  $ csdx (--version|-v)
24
- @contentstack/apps-cli/1.5.0 darwin-arm64 node-v22.13.1
25
+ @contentstack/apps-cli/1.6.0 darwin-arm64 node-v22.13.1
25
26
  $ csdx --help [COMMAND]
26
27
  USAGE
27
28
  $ csdx COMMAND
28
29
  ...
29
30
  ```
31
+
30
32
  <!-- usagestop -->
31
33
 
32
34
  # Commands
33
35
 
34
36
  <!-- commands -->
35
- * [`csdx app`](#csdx-app)
36
- * [`csdx app:create`](#csdx-appcreate)
37
- * [`csdx app:delete`](#csdx-appdelete)
38
- * [`csdx app:deploy`](#csdx-appdeploy)
39
- * [`csdx app:get`](#csdx-appget)
40
- * [`csdx app:install`](#csdx-appinstall)
41
- * [`csdx app:reinstall`](#csdx-appreinstall)
42
- * [`csdx app:uninstall`](#csdx-appuninstall)
43
- * [`csdx app:update`](#csdx-appupdate)
37
+
38
+ - [`csdx app`](#csdx-app)
39
+ - [`csdx app:create`](#csdx-appcreate)
40
+ - [`csdx app:delete`](#csdx-appdelete)
41
+ - [`csdx app:deploy`](#csdx-appdeploy)
42
+ - [`csdx app:get`](#csdx-appget)
43
+ - [`csdx app:install`](#csdx-appinstall)
44
+ - [`csdx app:reinstall`](#csdx-appreinstall)
45
+ - [`csdx app:uninstall`](#csdx-appuninstall)
46
+ - [`csdx app:update`](#csdx-appupdate)
44
47
 
45
48
  ## `csdx app`
46
49
 
@@ -71,7 +74,7 @@ EXAMPLES
71
74
  $ csdx app:update
72
75
  ```
73
76
 
74
- _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/index.ts)_
77
+ _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/index.ts)_
75
78
 
76
79
  ## `csdx app:create`
77
80
 
@@ -111,7 +114,7 @@ EXAMPLES
111
114
  $ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>
112
115
  ```
113
116
 
114
- _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/create.ts)_
117
+ _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/create.ts)_
115
118
 
116
119
  ## `csdx app:delete`
117
120
 
@@ -136,7 +139,7 @@ EXAMPLES
136
139
  $ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
137
140
  ```
138
141
 
139
- _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/delete.ts)_
142
+ _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/delete.ts)_
140
143
 
141
144
  ## `csdx app:deploy`
142
145
 
@@ -174,7 +177,7 @@ EXAMPLES
174
177
  $ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <hosting-with-launch> --launch-project <new> --config <config-path>
175
178
  ```
176
179
 
177
- _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/deploy.ts)_
180
+ _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/deploy.ts)_
178
181
 
179
182
  ## `csdx app:get`
180
183
 
@@ -204,7 +207,7 @@ EXAMPLES
204
207
  $ csdx app:get --org <value> --app-uid <value> --app-type organization
205
208
  ```
206
209
 
207
- _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/get.ts)_
210
+ _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/get.ts)_
208
211
 
209
212
  ## `csdx app:install`
210
213
 
@@ -230,7 +233,7 @@ EXAMPLES
230
233
  $ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
231
234
  ```
232
235
 
233
- _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/install.ts)_
236
+ _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/install.ts)_
234
237
 
235
238
  ## `csdx app:reinstall`
236
239
 
@@ -256,7 +259,7 @@ EXAMPLES
256
259
  $ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
257
260
  ```
258
261
 
259
- _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/reinstall.ts)_
262
+ _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/reinstall.ts)_
260
263
 
261
264
  ## `csdx app:uninstall`
262
265
 
@@ -283,7 +286,7 @@ EXAMPLES
283
286
  $ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
284
287
  ```
285
288
 
286
- _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/uninstall.ts)_
289
+ _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/uninstall.ts)_
287
290
 
288
291
  ## `csdx app:update`
289
292
 
@@ -306,5 +309,6 @@ EXAMPLES
306
309
  $ csdx app:update --app-manifest ./boilerplate/manifest.json
307
310
  ```
308
311
 
309
- _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/update.ts)_
312
+ _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.6.0/src/commands/app/update.ts)_
313
+
310
314
  <!-- commandsstop -->
@@ -20,14 +20,19 @@ class BaseCommand extends cli_command_1.Command {
20
20
  async init() {
21
21
  var _a, _b;
22
22
  await super.init();
23
- const { args, flags } = await this.parse({
24
- flags: this.ctor.flags,
25
- baseFlags: super.ctor.baseFlags,
26
- args: this.ctor.args,
27
- strict: this.ctor.strict,
28
- });
29
- this.flags = flags;
30
- this.args = args;
23
+ try {
24
+ const { args, flags } = await this.parse({
25
+ flags: this.ctor.flags,
26
+ baseFlags: super.ctor.baseFlags,
27
+ args: this.ctor.args,
28
+ strict: this.ctor.strict,
29
+ });
30
+ this.flags = flags;
31
+ this.args = args;
32
+ }
33
+ catch (error) {
34
+ throw error;
35
+ }
31
36
  cli_utilities_1.cliux.registerSearchPlugin();
32
37
  this.registerConfig();
33
38
  // Init logger
@@ -46,6 +51,11 @@ class BaseCommand extends cli_command_1.Command {
46
51
  async catch(err) {
47
52
  // add any custom logic to handle errors from the command
48
53
  // or simply return the parent class error handling
54
+ // Handle NonExistentFlagsError specifically
55
+ if (err.message && err.message.includes("Nonexistent flag")) {
56
+ console.error(err.message);
57
+ process.exit(2);
58
+ }
49
59
  return super.catch(err);
50
60
  }
51
61
  async finally(_) {
@@ -68,7 +78,9 @@ class BaseCommand extends cli_command_1.Command {
68
78
  ];
69
79
  this.sharedConfig = (0, merge_1.default)(this.sharedConfig, (0, omit_1.default)(config, omitKeys));
70
80
  }
71
- catch (error) { }
81
+ catch (error) {
82
+ throw error;
83
+ }
72
84
  }
73
85
  }
74
86
  /**
@@ -4,6 +4,7 @@ export default class Create extends BaseCommand<typeof Create> {
4
4
  private appData;
5
5
  private tempAppData;
6
6
  static description: string;
7
+ static strict: boolean;
7
8
  static examples: string[];
8
9
  static flags: FlagInput;
9
10
  run(): Promise<void>;
@@ -326,6 +326,7 @@ class Create extends base_command_1.BaseCommand {
326
326
  }
327
327
  }
328
328
  Create.description = "Create a new app in Developer Hub and optionally clone a boilerplate locally.";
329
+ Create.strict = true;
329
330
  Create.examples = [
330
331
  "$ <%= config.bin %> <%= command.id %>",
331
332
  "$ <%= config.bin %> <%= command.id %> --name App-1 --app-type stack",
@@ -24,7 +24,7 @@ class Delete extends app_cli_base_command_1.AppCLIBaseCommand {
24
24
  });
25
25
  this.flags["app-uid"] = app === null || app === void 0 ? void 0 : app.uid;
26
26
  }
27
- const { items: appInstallations } = await (0, util_1.fetchAppInstallations)(this.flags, this.sharedConfig.org, { managementSdk: this.managementAppSdk, log: this.log });
27
+ const { items: appInstallations } = await (0, util_1.fetchAppInstallations)(this.flags, this.sharedConfig.org, { marketplaceSdk: this.marketplaceAppSdk, log: this.log });
28
28
  if (appInstallations.length === 0) {
29
29
  const userConfirmation = this.flags["yes"] ||
30
30
  (await cli_utilities_1.cliux.inquire({
@@ -42,7 +42,7 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
42
42
  }
43
43
  if (this.flags["app-uid"]) {
44
44
  await (0, util_1.updateApp)(flags, this.sharedConfig.org, {
45
- managementSdk: this.managementAppSdk,
45
+ marketplaceSdk: this.marketplaceAppSdk,
46
46
  log: this.log,
47
47
  }, updateHostingPayload);
48
48
  }
@@ -8,7 +8,7 @@ class Install extends app_cli_base_command_1.AppCLIBaseCommand {
8
8
  async run() {
9
9
  var _a, _b, _c;
10
10
  try {
11
- let app, stack, appType;
11
+ let app, stack;
12
12
  this.flags["app-uid"] = (_b = (_a = this.manifestData) === null || _a === void 0 ? void 0 : _a.uid) !== null && _b !== void 0 ? _b : this.flags["app-uid"]; //manifest file first preference
13
13
  // validating user given stack, as installation API doesn't return appropriate errors if stack-api-key is invalid
14
14
  // validating this first, as orgUid is not required for fetching stack
@@ -39,7 +39,7 @@ class Install extends app_cli_base_command_1.AppCLIBaseCommand {
39
39
  log: this.log,
40
40
  });
41
41
  }
42
- appType = app === null || app === void 0 ? void 0 : app["target_type"]; // get app-type from the fetched app
42
+ const appType = app === null || app === void 0 ? void 0 : app["target_type"]; // get app-type from the fetched app
43
43
  this.flags["app-uid"] = app === null || app === void 0 ? void 0 : app.uid;
44
44
  // in case stack-api-key is provided and the selected app is an organization app
45
45
  if (appType === "organization" && this.flags["stack-api-key"]) {
@@ -9,7 +9,7 @@ class Uninstall extends app_cli_base_command_1.AppCLIBaseCommand {
9
9
  async run() {
10
10
  var _a, _b, _c;
11
11
  try {
12
- let app, appType;
12
+ let app;
13
13
  this.flags["app-uid"] = (_b = (_a = this.manifestData) === null || _a === void 0 ? void 0 : _a.uid) !== null && _b !== void 0 ? _b : this.flags["app-uid"];
14
14
  // get organization to be used
15
15
  this.sharedConfig.org = (_c = this.manifestData) === null || _c === void 0 ? void 0 : _c.organization_uid;
@@ -20,18 +20,26 @@ class Uninstall extends app_cli_base_command_1.AppCLIBaseCommand {
20
20
  });
21
21
  }
22
22
  // fetch app details
23
- if (!this.flags['app-uid']) {
24
- app = await (0, util_1.getInstalledApps)(this.flags, this.sharedConfig.org, { marketplaceSdk: this.marketplaceAppSdk, log: this.log });
23
+ if (!this.flags["app-uid"]) {
24
+ app = await (0, util_1.getInstalledApps)(this.flags, this.sharedConfig.org, {
25
+ marketplaceSdk: this.marketplaceAppSdk,
26
+ log: this.log,
27
+ });
25
28
  }
26
29
  else {
27
- app = await (0, util_1.fetchApp)(this.flags, this.sharedConfig.org, { marketplaceSdk: this.marketplaceAppSdk, log: this.log });
30
+ app = await (0, util_1.fetchApp)(this.flags, this.sharedConfig.org, {
31
+ marketplaceSdk: this.marketplaceAppSdk,
32
+ log: this.log,
33
+ });
28
34
  }
29
- this.flags['app-uid'] = app === null || app === void 0 ? void 0 : app.uid;
30
- appType = app === null || app === void 0 ? void 0 : app['target_type'];
35
+ this.flags["app-uid"] = app === null || app === void 0 ? void 0 : app.uid;
36
+ const appType = app === null || app === void 0 ? void 0 : app["target_type"];
31
37
  const factory = new uninstall_app_factory_1.UninstallAppFactory();
32
- const strategy = factory.getStrategyInstance(this.flags['uninstall-all']);
33
- await strategy.run(this.flags, this.sharedConfig.org, this.managementSdk, { managementSdk: this.managementAppSdk, log: this.log }, appType);
34
- this.log(this.$t(messages_1.uninstallAppMsg.APP_UNINSTALLED, { app: (app === null || app === void 0 ? void 0 : app.name) || this.flags["app-uid"] }), "info");
38
+ const strategy = factory.getStrategyInstance(this.flags["uninstall-all"]);
39
+ await strategy.run(this.flags, this.sharedConfig.org, this.managementSdk, { managementSdk: this.managementAppSdk, log: this.log }, appType, this.marketplaceAppSdk);
40
+ this.log(this.$t(messages_1.uninstallAppMsg.APP_UNINSTALLED, {
41
+ app: (app === null || app === void 0 ? void 0 : app.name) || this.flags["app-uid"],
42
+ }), "info");
35
43
  }
36
44
  catch (error) {
37
45
  this.log((error === null || error === void 0 ? void 0 : error.errorMessage) || (error === null || error === void 0 ? void 0 : error.message) || error, "error");
@@ -45,11 +53,11 @@ Uninstall.examples = [
45
53
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1>",
46
54
  "$ <%= config.bin %> <%= command.id %> --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>",
47
55
  ];
48
- Uninstall.flags = Object.assign({ 'app-uid': cli_utilities_1.flags.string({
56
+ Uninstall.flags = Object.assign({ "app-uid": cli_utilities_1.flags.string({
49
57
  description: messages_1.commonMsg.APP_UID,
50
- }), 'installation-uid': cli_utilities_1.flags.string({
51
- description: messages_1.uninstallAppMsg.INSTALLATION_UID
52
- }), 'uninstall-all': cli_utilities_1.flags.boolean({
58
+ }), "installation-uid": cli_utilities_1.flags.string({
59
+ description: messages_1.uninstallAppMsg.INSTALLATION_UID,
60
+ }), "uninstall-all": cli_utilities_1.flags.boolean({
53
61
  description: messages_1.uninstallAppMsg.UNINSTALL_ALL,
54
62
  }) }, app_cli_base_command_1.AppCLIBaseCommand.baseFlags);
55
63
  exports.default = Uninstall;
@@ -1,6 +1,6 @@
1
- import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities";
1
+ import { ContentstackClient, ContentstackMarketplaceClient, FlagInput } from "@contentstack/cli-utilities";
2
2
  import { CommonOptions } from "../util";
3
- import { AppTarget } from "@contentstack/management/types/app/index";
3
+ import { AppTarget } from "@contentstack/marketplace-sdk/types/marketplace/app";
4
4
  export interface UninstallApp {
5
- run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget): Promise<void>;
5
+ run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget, marketplaceSdk: ContentstackMarketplaceClient): Promise<void>;
6
6
  }
@@ -1,8 +1,8 @@
1
- import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities";
1
+ import { ContentstackClient, ContentstackMarketplaceClient, FlagInput } from "@contentstack/cli-utilities";
2
2
  import { UninstallApp } from "../interfaces/uninstall-app";
3
3
  import { CommonOptions } from "../util";
4
- import { AppTarget } from "@contentstack/management/types/app/index";
4
+ import { AppTarget } from "@contentstack/marketplace-sdk/types/marketplace/app";
5
5
  export declare class UninstallAll implements UninstallApp {
6
- run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget): Promise<void>;
7
- getInstallations(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget): Promise<string[]>;
6
+ run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget, marketplaceSdk: ContentstackMarketplaceClient): Promise<void>;
7
+ getInstallations(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget, marketplaceSdk: ContentstackMarketplaceClient): Promise<string[]>;
8
8
  }
@@ -3,16 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UninstallAll = void 0;
4
4
  const util_1 = require("../util");
5
5
  class UninstallAll {
6
- async run(flags, org, managementSdk, options, appType) {
6
+ async run(flags, org, managementSdk, options, appType, marketplaceSdk) {
7
7
  // get all installation uids to uninstall
8
- const installationUids = await this.getInstallations(flags, org, managementSdk, options, appType);
8
+ const installationUids = await this.getInstallations(flags, org, managementSdk, options, appType, marketplaceSdk);
9
9
  for (const installationUid of installationUids) {
10
- await (0, util_1.uninstallApp)(flags, org, options, installationUid);
10
+ const marketplaceOptions = {
11
+ log: options.log,
12
+ marketplaceSdk: marketplaceSdk,
13
+ };
14
+ await (0, util_1.uninstallApp)(org, marketplaceOptions, installationUid);
11
15
  }
12
16
  }
13
- async getInstallations(flags, org, managementSdk, options, appType) {
14
- let installationUids = await (0, util_1.getInstallation)(flags, org, managementSdk, appType, options, true);
15
- return installationUids.split(',');
17
+ async getInstallations(flags, org, managementSdk, options, appType, marketplaceSdk) {
18
+ const installationUids = await (0, util_1.getInstallation)(flags, org, managementSdk, appType, options, marketplaceSdk, true);
19
+ return installationUids.split(",");
16
20
  }
17
21
  }
18
22
  exports.UninstallAll = UninstallAll;
@@ -1,8 +1,8 @@
1
- import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities";
1
+ import { ContentstackClient, ContentstackMarketplaceClient, FlagInput } from "@contentstack/cli-utilities";
2
2
  import { UninstallApp } from "../interfaces/uninstall-app";
3
3
  import { CommonOptions } from "../util";
4
- import { AppTarget } from "@contentstack/management/types/app/index";
4
+ import { AppTarget } from "@contentstack/marketplace-sdk/types/marketplace/app";
5
5
  export declare class UninstallSelected implements UninstallApp {
6
- run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget): Promise<void>;
7
- getInstallations(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget): Promise<string[]>;
6
+ run(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget, marketplaceSdk: ContentstackMarketplaceClient): Promise<void>;
7
+ getInstallations(flags: FlagInput, org: string, managementSdk: ContentstackClient, options: CommonOptions, appType: AppTarget, marketplaceSdk: ContentstackMarketplaceClient): Promise<string[]>;
8
8
  }
@@ -3,19 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UninstallSelected = void 0;
4
4
  const util_1 = require("../util");
5
5
  class UninstallSelected {
6
- async run(flags, org, managementSdk, options, appType) {
6
+ async run(flags, org, managementSdk, options, appType, marketplaceSdk) {
7
7
  // select installation uid to uninstall
8
- const installationUids = await this.getInstallations(flags, org, managementSdk, options, appType);
8
+ const installationUids = await this.getInstallations(flags, org, managementSdk, options, appType, marketplaceSdk);
9
9
  for (const installationUid of installationUids) {
10
- await (0, util_1.uninstallApp)(flags, org, options, installationUid);
10
+ const marketplaceOptions = {
11
+ log: options.log,
12
+ marketplaceSdk: marketplaceSdk,
13
+ };
14
+ await (0, util_1.uninstallApp)(org, marketplaceOptions, installationUid);
11
15
  }
12
16
  }
13
- async getInstallations(flags, org, managementSdk, options, appType) {
14
- let installationUids = flags['installation-uid'];
17
+ async getInstallations(flags, org, managementSdk, options, appType, marketplaceSdk) {
18
+ let installationUids = flags["installation-uid"];
15
19
  if (!installationUids) {
16
- installationUids = await (0, util_1.getInstallation)(flags, org, managementSdk, appType, options);
20
+ installationUids = await (0, util_1.getInstallation)(flags, org, managementSdk, appType, options, marketplaceSdk);
17
21
  }
18
- return installationUids.split(',');
22
+ return installationUids.split(",");
19
23
  }
20
24
  }
21
25
  exports.UninstallSelected = UninstallSelected;
@@ -13,18 +13,18 @@ declare function getOrganizations(options: CommonOptions, skip?: number, organiz
13
13
  declare function getOrgAppUiLocation(): Extension[];
14
14
  declare function fetchApps(flags: FlagInput, orgUid: string, options: MarketPlaceOptions, skip?: number, apps?: Record<string, any>[]): Promise<Record<string, any>[]>;
15
15
  declare function fetchApp(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<import("@contentstack/cli-utilities").App>;
16
- declare function fetchAppInstallations(flags: FlagInput, orgUid: string, options: CommonOptions): Promise<import("@contentstack/management/types/contentstackCollection").ContentstackCollection<import("@contentstack/management/types/app/installation").Installation>>;
16
+ declare function fetchAppInstallations(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<import("@contentstack/marketplace-sdk/types/contentstackCollection").ContentstackCollection<import("@contentstack/cli-utilities").App>>;
17
17
  declare function deleteApp(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<import("@contentstack/cli-utilities").App>;
18
18
  declare function installApp(flags: FlagInput, orgUid: string, type: string, options: MarketPlaceOptions): Promise<import("@contentstack/cli-utilities").Installation>;
19
19
  declare function reinstallApp(flags: FlagInput, orgUid: string, type: string, options: MarketPlaceOptions): Promise<import("@contentstack/cli-utilities").Installation>;
20
20
  declare function fetchStack(flags: FlagInput, options: CommonOptions): Promise<any>;
21
21
  declare function getStacks(options: CommonOptions, orgUid: string, skip?: number, stacks?: Stack[]): Promise<Stack[]>;
22
- declare function uninstallApp(flags: FlagInput, orgUid: string, options: CommonOptions, installationUid: string): Promise<import("@contentstack/management/types/utility/fields").AnyProperty>;
22
+ declare function uninstallApp(orgUid: string, options: MarketPlaceOptions, installationUid: string): Promise<import("@contentstack/marketplace-sdk/types/utility/fields").AnyProperty>;
23
23
  declare function fetchInstalledApps(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<Record<string, any>[]>;
24
24
  declare const sanitizePath: (str: string) => string;
25
- declare function updateApp(flags: FlagInput, orgUid: string, options: CommonOptions, updateReqPayload: UpdateHostingParams): Promise<void>;
25
+ declare function updateApp(flags: FlagInput, orgUid: string, options: MarketPlaceOptions, updateReqPayload: UpdateHostingParams): Promise<void>;
26
26
  declare function getProjects(apolloClient: ApolloClient<any>): Promise<LaunchProjectRes[]>;
27
- declare function getManifestDetails(flags: FlagInput, orgUid: string, options: CommonOptions): import("@contentstack/management/types/app/hosting").Hosting;
27
+ declare function getManifestDetails(flags: FlagInput, orgUid: string, options: CommonOptions): any;
28
28
  declare function setupConfig(configPath: string): Record<string, string>;
29
29
  declare function disconnectApp(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<any>;
30
30
  declare function formatUrl(url: string): string;
@@ -94,13 +94,12 @@ function fetchApp(flags, orgUid, options) {
94
94
  .fetch();
95
95
  }
96
96
  function fetchAppInstallations(flags, orgUid, options) {
97
- const { managementSdk } = options;
97
+ const { marketplaceSdk } = options;
98
98
  const app = flags["app-uid"];
99
- return managementSdk
100
- .organization(orgUid)
99
+ return marketplaceSdk
100
+ .marketplace(orgUid)
101
101
  .app(app)
102
- .installation()
103
- .findAll()
102
+ .listInstallations()
104
103
  .catch((error) => {
105
104
  const { log } = options;
106
105
  cli_utilities_1.cliux.loader("failed");
@@ -161,19 +160,18 @@ async function getStacks(options, orgUid, skip = 0, stacks = []) {
161
160
  }
162
161
  return stacks;
163
162
  }
164
- function uninstallApp(flags, orgUid, options, installationUid) {
165
- const { managementSdk } = options;
166
- const app = flags["app-uid"];
167
- return managementSdk
168
- .organization(orgUid)
169
- .app(app)
163
+ function uninstallApp(orgUid, options, installationUid) {
164
+ const { marketplaceSdk } = options;
165
+ // const app: any = flags["app-uid"];
166
+ return marketplaceSdk
167
+ .marketplace(orgUid)
170
168
  .installation(installationUid)
171
169
  .uninstall();
172
170
  }
173
171
  async function fetchInstalledApps(flags, orgUid, options) {
174
172
  const { marketplaceSdk, log } = options;
175
173
  const apps = (await fetchApps(flags, orgUid, options)) || [];
176
- let batchRequests = [];
174
+ const batchRequests = [];
177
175
  // Make calls in batch. 10 requests per batch allowed.
178
176
  while (apps.length) {
179
177
  batchRequests.push(apps.splice(0, 10));
@@ -208,16 +206,16 @@ async function fetchInstalledApps(flags, orgUid, options) {
208
206
  return batchRequests.flat();
209
207
  }
210
208
  // To remove the relative path
211
- const sanitizePath = (str) => str === null || str === void 0 ? void 0 : str.replace(/^(\.\.(\/|\\|$))+/, "");
209
+ const sanitizePath = (str) => str === null || str === void 0 ? void 0 : str.replace(/^([\/\\]){2,}/, "./").replace(/[\/\\]+/g, "/").replace(/(\.\.(\/|\\|$))+/g, ""); // Remove directory traversal (../ or ..\)
212
210
  exports.sanitizePath = sanitizePath;
213
211
  async function updateApp(flags, orgUid, options, updateReqPayload) {
214
- const { managementSdk } = options;
212
+ const { marketplaceSdk } = options;
215
213
  const appUid = flags["app-uid"];
216
214
  const payload = {
217
215
  uid: appUid,
218
216
  hosting: updateReqPayload,
219
217
  };
220
- let app = managementSdk.organization(orgUid).app(appUid);
218
+ let app = marketplaceSdk.marketplace(orgUid).app(appUid);
221
219
  app = Object.assign(app, payload);
222
220
  await app.update();
223
221
  }
@@ -1,5 +1,5 @@
1
- import { FlagInput, ContentstackClient } from "@contentstack/cli-utilities";
2
- import { AppTarget } from "@contentstack/management/types/app/index";
1
+ import { FlagInput, ContentstackClient, ContentstackMarketplaceClient } from "@contentstack/cli-utilities";
2
+ import { AppTarget } from "@contentstack/marketplace-sdk/types/marketplace/app";
3
3
  import { CommonOptions, MarketPlaceOptions } from "./common-utils";
4
4
  import { LaunchProjectRes } from "../types";
5
5
  /**
@@ -32,7 +32,7 @@ declare function getInstalledApps(flags: FlagInput, orgUid: string, options: Mar
32
32
  */
33
33
  declare function getDeveloperHubUrl(): string;
34
34
  declare function getStack(orgUid: string, options: CommonOptions): Promise<Record<string, any> | undefined>;
35
- declare function getInstallation(flags: FlagInput, orgUid: string, managementSdkForStacks: ContentstackClient, appType: AppTarget, options: CommonOptions, uninstallAll?: boolean): Promise<string>;
35
+ declare function getInstallation(flags: FlagInput, orgUid: string, managementSdkForStacks: ContentstackClient, appType: AppTarget, options: CommonOptions, marketplaceSdk: ContentstackMarketplaceClient, uninstallAll?: boolean): Promise<string>;
36
36
  declare function getHostingType(): Promise<string>;
37
37
  declare function getAppUrl(defaultUrl?: string): Promise<string | boolean>;
38
38
  declare function selectProject(projects: LaunchProjectRes[]): Promise<LaunchProjectRes | undefined>;
@@ -167,14 +167,18 @@ async function getStack(orgUid, options) {
167
167
  .then((name) => stacks.find((stack) => stack.name === name));
168
168
  return selectedStack;
169
169
  }
170
- async function getInstallation(flags, orgUid, managementSdkForStacks, appType, options, uninstallAll) {
170
+ async function getInstallation(flags, orgUid, managementSdkForStacks, appType, options, marketplaceSdk, uninstallAll) {
171
171
  var _a;
172
172
  const { log } = options;
173
173
  if (appType === "stack") {
174
174
  cli_utilities_1.cliux.loader("Loading App Installations");
175
175
  }
176
- let { items: installations } = (await (0, common_utils_1.fetchAppInstallations)(flags, orgUid, options)) || { items: [] };
177
- if (!(installations === null || installations === void 0 ? void 0 : installations.length)) {
176
+ const { items: installations } = (await (0, common_utils_1.fetchAppInstallations)(flags, orgUid, {
177
+ log,
178
+ marketplaceSdk,
179
+ })) || { items: [] };
180
+ let installationsArray = installations;
181
+ if (!(installationsArray === null || installationsArray === void 0 ? void 0 : installationsArray.length)) {
178
182
  if (appType === "stack")
179
183
  cli_utilities_1.cliux.loader("done");
180
184
  throw new Error(messages_1.default.NO_INSTALLATIONS_FOUND);
@@ -184,15 +188,17 @@ async function getInstallation(flags, orgUid, managementSdkForStacks, appType, o
184
188
  // fetch stacks from where the app has to be uninstalled
185
189
  cli_utilities_1.cliux.loader("done");
186
190
  const stacks = await (0, common_utils_1.getStacks)({ managementSdk: managementSdkForStacks, log: options.log }, orgUid);
187
- installations = populateMissingDataInInstallations(installations, stacks);
191
+ installationsArray = populateMissingDataInInstallations(installationsArray, stacks);
188
192
  // To support uninstall all flag
189
193
  if (uninstallAll) {
190
- return installations.map((installation) => installation.uid).join(",");
194
+ return installationsArray
195
+ .map((installation) => installation.uid)
196
+ .join(",");
191
197
  }
192
- let _selectedInstallation = await cli_utilities_1.cliux.inquire({
198
+ const _selectedInstallation = await cli_utilities_1.cliux.inquire({
193
199
  type: "checkbox",
194
200
  name: "appInstallation",
195
- choices: installations,
201
+ choices: installationsArray,
196
202
  message: messages_1.default.CHOOSE_AN_INSTALLATION,
197
203
  validate: (input) => {
198
204
  if ((0, isEmpty_1.default)(input)) {
@@ -206,7 +212,7 @@ async function getInstallation(flags, orgUid, managementSdkForStacks, appType, o
206
212
  else {
207
213
  // as this is an organization app, and it is supposed to only be installed on the source organization
208
214
  // it will be uninstalled from the selected organization
209
- selectedInstallation = ((_a = installations.pop()) === null || _a === void 0 ? void 0 : _a.uid) || "";
215
+ selectedInstallation = ((_a = installationsArray.pop()) === null || _a === void 0 ? void 0 : _a.uid) || "";
210
216
  }
211
217
  log((0, messages_1.$t)(messages_1.uninstallAppMsg.UNINSTALLING_APP, {
212
218
  type: appType,
@@ -214,9 +220,9 @@ async function getInstallation(flags, orgUid, managementSdkForStacks, appType, o
214
220
  return selectedInstallation;
215
221
  }
216
222
  function populateMissingDataInInstallations(installations, stacks) {
217
- let result = installations.map((installation) => {
223
+ const result = installations.map((installation) => {
218
224
  var _a;
219
- let stack = (_a = stacks
225
+ const stack = (_a = stacks
220
226
  .filter((stack) => stack.api_key === installation.target.uid)) === null || _a === void 0 ? void 0 : _a.pop();
221
227
  installation.name = (stack === null || stack === void 0 ? void 0 : stack.name) || installation.target.uid;
222
228
  installation.value = installation.uid;
@@ -322,15 +328,19 @@ const validateAppName = (name) => {
322
328
  };
323
329
  exports.validateAppName = validateAppName;
324
330
  function getLaunchHubUrl() {
325
- const { cma } = cli_utilities_1.configHandler.get('region') || {};
331
+ const { cma } = cli_utilities_1.configHandler.get("region") || {};
326
332
  if (!cma) {
327
- throw new Error('Region not configured. Please set the region with command $ csdx config:set:region');
333
+ throw new Error("Region not configured. Please set the region with command $ csdx config:set:region");
328
334
  }
329
- let launchHubBaseUrl = cma.replace('api', 'launch-api');
330
- if (launchHubBaseUrl.startsWith('http')) {
331
- launchHubBaseUrl = launchHubBaseUrl.split('//')[1];
335
+ let launchHubBaseUrl = cma.replace("api", "launch-api");
336
+ if (launchHubBaseUrl.startsWith("http")) {
337
+ launchHubBaseUrl = launchHubBaseUrl.split("//")[1];
332
338
  }
333
- launchHubBaseUrl = launchHubBaseUrl.startsWith('dev11') ? launchHubBaseUrl.replace('dev11', 'dev') : launchHubBaseUrl;
334
- launchHubBaseUrl = launchHubBaseUrl.endsWith('io') ? launchHubBaseUrl.replace('io', 'com') : launchHubBaseUrl;
339
+ launchHubBaseUrl = launchHubBaseUrl.startsWith("dev11")
340
+ ? launchHubBaseUrl.replace("dev11", "dev")
341
+ : launchHubBaseUrl;
342
+ launchHubBaseUrl = launchHubBaseUrl.endsWith("io")
343
+ ? launchHubBaseUrl.replace("io", "com")
344
+ : launchHubBaseUrl;
335
345
  return `https://${launchHubBaseUrl}`;
336
346
  }
package/lib/util/log.js CHANGED
@@ -106,7 +106,9 @@ class Logger {
106
106
  try {
107
107
  return JSON.stringify(item).replace(/authtoken":"blt................/g, 'authtoken":"blt....');
108
108
  }
109
- catch (error) { }
109
+ catch (error) {
110
+ throw error;
111
+ }
110
112
  return item;
111
113
  };
112
114
  if (Array.isArray(message) && message.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/apps-cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "App ClI",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/contentstack-apps-cli",
@@ -20,42 +20,42 @@
20
20
  "/oclif.manifest.json"
21
21
  ],
22
22
  "dependencies": {
23
- "@apollo/client": "^3.11.8",
23
+ "@apollo/client": "^3.13.8",
24
24
  "@contentstack/cli-command": "^1.5.0",
25
- "@contentstack/cli-launch": "^1.8.0",
26
- "@contentstack/cli-utilities": "^1.11.0",
25
+ "@contentstack/cli-launch": "^1.9.0",
26
+ "@contentstack/cli-utilities": "^1.12.0",
27
27
  "adm-zip": "^0.5.16",
28
- "chai-as-promised": "^8.0.0",
29
28
  "chalk": "^4.1.2",
30
- "fancy-test": "^3.0.16",
31
29
  "lodash": "^4.17.21",
32
- "shelljs": "^0.9.0",
30
+ "shelljs": "^0.9.2",
33
31
  "tmp": "^0.2.3",
34
- "winston": "^3.15.0"
32
+ "winston": "^3.17.0"
35
33
  },
36
34
  "devDependencies": {
37
- "@oclif/test": "^4.0.10",
38
- "@types/adm-zip": "^0.5.5",
35
+ "@oclif/test": "^4.1.12",
36
+ "@types/adm-zip": "^0.5.7",
39
37
  "@types/chai": "^4.3.20",
40
- "@types/lodash": "^4.17.10",
41
- "@types/mocha": "^10.0.9",
42
- "@types/node": "^20.16.11",
38
+ "@types/lodash": "^4.17.16",
39
+ "@types/mocha": "^10.0.10",
40
+ "@types/node": "^20.17.30",
43
41
  "@types/shelljs": "^0.8.15",
44
42
  "@types/tmp": "^0.2.6",
45
- "axios": "^1.7.7",
43
+ "@typescript-eslint/eslint-plugin": "^8.37.0",
44
+ "@typescript-eslint/parser": "^8.37.0",
45
+ "axios": "^1.8.4",
46
46
  "chai": "^4.5.0",
47
- "dotenv": "^16.4.5",
47
+ "dotenv": "^16.5.0",
48
48
  "eslint": "^8.57.1",
49
- "eslint-config-oclif": "^6.0.15",
50
- "eslint-config-oclif-typescript": "^3.1.12",
49
+ "eslint-config-oclif": "^6.0.62",
50
+ "eslint-config-oclif-typescript": "^3.1.14",
51
51
  "fancy-test": "3.0.16",
52
- "mocha": "^10.7.3",
52
+ "mocha": "^10.8.2",
53
53
  "nyc": "^15.1.0",
54
- "oclif": "^4.17.30",
55
- "shx": "^0.3.4",
54
+ "oclif": "^4.17.46",
55
+ "shx": "^0.4.0",
56
56
  "ts-node": "^10.9.2",
57
- "tslib": "^2.8.0",
58
- "typescript": "^5.6.3"
57
+ "tslib": "^2.8.1",
58
+ "typescript": "^5.8.3"
59
59
  },
60
60
  "oclif": {
61
61
  "bin": "csdx",