@contentstack/apps-cli 1.3.1 → 1.3.2

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.3.1 darwin-arm64 node-v18.20.2
23
+ @contentstack/apps-cli/1.3.2 darwin-arm64 node-v18.20.2
24
24
  $ csdx --help [COMMAND]
25
25
  USAGE
26
26
  $ csdx COMMAND
@@ -69,7 +69,7 @@ EXAMPLES
69
69
  $ csdx app:update
70
70
  ```
71
71
 
72
- _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/index.ts)_
72
+ _See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/index.ts)_
73
73
 
74
74
  ## `csdx app:create`
75
75
 
@@ -109,7 +109,7 @@ EXAMPLES
109
109
  $ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>
110
110
  ```
111
111
 
112
- _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/create.ts)_
112
+ _See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/create.ts)_
113
113
 
114
114
  ## `csdx app:delete`
115
115
 
@@ -134,7 +134,7 @@ EXAMPLES
134
134
  $ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
135
135
  ```
136
136
 
137
- _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/delete.ts)_
137
+ _See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/delete.ts)_
138
138
 
139
139
  ## `csdx app:deploy`
140
140
 
@@ -172,7 +172,7 @@ EXAMPLES
172
172
  $ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new> --config <config-path>
173
173
  ```
174
174
 
175
- _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/deploy.ts)_
175
+ _See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/deploy.ts)_
176
176
 
177
177
  ## `csdx app:get`
178
178
 
@@ -202,7 +202,7 @@ EXAMPLES
202
202
  $ csdx app:get --org <value> --app-uid <value> --app-type organization
203
203
  ```
204
204
 
205
- _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/get.ts)_
205
+ _See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/get.ts)_
206
206
 
207
207
  ## `csdx app:install`
208
208
 
@@ -228,7 +228,7 @@ EXAMPLES
228
228
  $ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
229
229
  ```
230
230
 
231
- _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/install.ts)_
231
+ _See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/install.ts)_
232
232
 
233
233
  ## `csdx app:reinstall`
234
234
 
@@ -254,7 +254,7 @@ EXAMPLES
254
254
  $ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
255
255
  ```
256
256
 
257
- _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/reinstall.ts)_
257
+ _See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/reinstall.ts)_
258
258
 
259
259
  ## `csdx app:uninstall`
260
260
 
@@ -281,7 +281,7 @@ EXAMPLES
281
281
  $ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
282
282
  ```
283
283
 
284
- _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/uninstall.ts)_
284
+ _See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/uninstall.ts)_
285
285
 
286
286
  ## `csdx app:update`
287
287
 
@@ -304,5 +304,5 @@ EXAMPLES
304
304
  $ csdx app:update --app-manifest ./boilerplate/manifest.json
305
305
  ```
306
306
 
307
- _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.1/src/commands/app/update.ts)_
307
+ _See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/update.ts)_
308
308
  <!-- commandsstop -->
@@ -25,6 +25,7 @@ class Create extends base_command_1.BaseCommand {
25
25
  };
26
26
  }
27
27
  async run() {
28
+ var _a;
28
29
  this.sharedConfig.org = this.flags.org;
29
30
  this.sharedConfig.appName = this.flags.name;
30
31
  this.sharedConfig.boilerplateName = this.flags.boilerplate;
@@ -44,6 +45,15 @@ class Create extends base_command_1.BaseCommand {
44
45
  await this.boilerplateFlow();
45
46
  }
46
47
  else {
48
+ if (this.sharedConfig.folderPath === undefined) {
49
+ const dataDir = (_a = this.flags["data-dir"]) !== null && _a !== void 0 ? _a : process.cwd();
50
+ let targetPath = (0, path_1.resolve)(dataDir, this.sharedConfig.defaultAppName);
51
+ if ((0, fs_1.existsSync)(targetPath)) {
52
+ this.log(this.messages.DIR_EXIST, "warn");
53
+ targetPath = await (0, util_1.getDirName)(targetPath);
54
+ }
55
+ this.sharedConfig.folderPath = targetPath;
56
+ }
47
57
  this.manageManifestToggeling();
48
58
  await this.registerTheAppOnDeveloperHub(false);
49
59
  }
@@ -195,7 +195,10 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
195
195
  if (!this.flags["yes"]) {
196
196
  throw new Error(messages_1.deployAppMsg.APP_UPDATE_TERMINATION_MSG);
197
197
  }
198
- await (0, util_2.disconnectApp)(this.flags, this.sharedConfig.org, this.developerHubBaseUrl);
198
+ await (0, util_2.disconnectApp)(this.flags, this.sharedConfig.org, {
199
+ marketplaceSdk: this.marketplaceAppSdk,
200
+ log: this.log,
201
+ });
199
202
  }
200
203
  }
201
204
  }
@@ -65,12 +65,9 @@ class Reinstall extends app_cli_base_command_1.AppCLIBaseCommand {
65
65
  type: appType,
66
66
  target: this.flags["stack-api-key"] || this.sharedConfig.org,
67
67
  }), "info");
68
- await (0, util_1.reinstallApp)({
69
- flags: this.flags,
70
- type: appType,
71
- developerHubBaseUrl: this.developerHubBaseUrl,
72
- orgUid: this.sharedConfig.org,
73
- manifestUid: this.flags["app-uid"],
68
+ await (0, util_1.reinstallApp)(this.flags, this.sharedConfig.org, appType, {
69
+ marketplaceSdk: this.marketplaceAppSdk,
70
+ log: this.log,
74
71
  });
75
72
  this.log((0, messages_1.$t)(messages_1.reinstallAppMsg.APP_REINSTALLED_SUCCESSFULLY, {
76
73
  app: (app === null || app === void 0 ? void 0 : app.name) || this.flags["app-uid"],
@@ -80,7 +77,7 @@ class Reinstall extends app_cli_base_command_1.AppCLIBaseCommand {
80
77
  }
81
78
  catch (error) {
82
79
  this.log((error === null || error === void 0 ? void 0 : error.errorMessage) || (error === null || error === void 0 ? void 0 : error.message) || error, "error");
83
- process.exit(1);
80
+ this.exit(1);
84
81
  }
85
82
  }
86
83
  displayStackUrl() {
@@ -16,14 +16,8 @@ declare function fetchApp(flags: FlagInput, orgUid: string, options: MarketPlace
16
16
  declare function fetchAppInstallations(flags: FlagInput, orgUid: string, options: CommonOptions): Promise<import("@contentstack/management/types/contentstackCollection").ContentstackCollection<import("@contentstack/management/types/app/installation").Installation>>;
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
- declare function reinstallApp(params: {
20
- flags: FlagInput;
21
- type: string;
22
- developerHubBaseUrl: string;
23
- orgUid: string;
24
- manifestUid: string;
25
- }): Promise<void>;
26
- declare function fetchStack(flags: FlagInput, options: CommonOptions): Promise<import("@contentstack/management/types/stack").Stack>;
19
+ declare function reinstallApp(flags: FlagInput, orgUid: string, type: string, options: MarketPlaceOptions): Promise<import("@contentstack/cli-utilities").Installation>;
20
+ declare function fetchStack(flags: FlagInput, options: CommonOptions): Promise<any>;
27
21
  declare function getStacks(options: CommonOptions, orgUid: string, skip?: number, stacks?: Stack[]): Promise<Stack[]>;
28
22
  declare function uninstallApp(flags: FlagInput, orgUid: string, options: CommonOptions, installationUid: string): Promise<import("@contentstack/management/types/utility/fields").AnyProperty>;
29
23
  declare function fetchInstalledApps(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<Record<string, any>[]>;
@@ -32,7 +26,7 @@ declare function updateApp(flags: FlagInput, orgUid: string, options: CommonOpti
32
26
  declare function getProjects(apolloClient: ApolloClient<any>): Promise<LaunchProjectRes[]>;
33
27
  declare function getManifestDetails(flags: FlagInput, orgUid: string, options: CommonOptions): import("@contentstack/management/types/app/hosting").Hosting;
34
28
  declare function setupConfig(configPath: string): Record<string, string>;
35
- declare function disconnectApp(flags: FlagInput, orgUid: string, developerHubBaseUrl: string): Promise<any>;
29
+ declare function disconnectApp(flags: FlagInput, orgUid: string, options: MarketPlaceOptions): Promise<any>;
36
30
  declare function formatUrl(url: string): string;
37
31
  declare const handleProjectNameConflict: (projectName: string, projects: any[], retry?: number) => Promise<string>;
38
32
  declare function fetchBoilerplateDetails(): Promise<Record<string, any>[]>;
@@ -5,7 +5,6 @@ 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");
7
7
  const queries_1 = require("../graphql/queries");
8
- const api_request_handler_1 = require("./api-request-handler");
9
8
  const types_1 = require("../types");
10
9
  const inquirer_1 = require("./inquirer");
11
10
  const messages_1 = require("../messages");
@@ -114,25 +113,15 @@ function installApp(flags, orgUid, type, options) {
114
113
  });
115
114
  }
116
115
  exports.installApp = installApp;
117
- async function reinstallApp(params) {
118
- const { type, developerHubBaseUrl, flags, orgUid, manifestUid } = params;
119
- const payload = {
120
- target_type: type,
121
- target_uid: flags["stack-api-key"] || orgUid,
122
- };
123
- const url = `https://${developerHubBaseUrl}/manifests/${manifestUid}/reinstall`;
124
- try {
125
- const result = await (0, api_request_handler_1.apiRequestHandler)({
126
- orgUid,
127
- payload,
128
- url,
129
- method: "PUT",
130
- });
131
- return result;
132
- }
133
- catch (err) {
134
- throw err;
135
- }
116
+ function reinstallApp(flags, orgUid, type, options) {
117
+ const { marketplaceSdk } = options;
118
+ return marketplaceSdk
119
+ .marketplace(orgUid)
120
+ .app(flags["app-uid"])
121
+ .reinstall({
122
+ targetUid: flags["stack-api-key"] || orgUid,
123
+ targetType: type,
124
+ });
136
125
  }
137
126
  exports.reinstallApp = reinstallApp;
138
127
  function fetchStack(flags, options) {
@@ -265,21 +254,13 @@ function setupConfig(configPath) {
265
254
  return configDetails;
266
255
  }
267
256
  exports.setupConfig = setupConfig;
268
- async function disconnectApp(flags, orgUid, developerHubBaseUrl) {
269
- const appUid = flags["app-uid"];
270
- const url = `https://${developerHubBaseUrl}/manifests/${appUid}/hosting/disconnect`;
271
- try {
272
- const result = await (0, api_request_handler_1.apiRequestHandler)({
273
- orgUid,
274
- payload: { provider: "launch" },
275
- url,
276
- method: "PATCH",
277
- });
278
- return result;
279
- }
280
- catch (err) {
281
- throw err;
282
- }
257
+ async function disconnectApp(flags, orgUid, options) {
258
+ const { marketplaceSdk } = options;
259
+ return marketplaceSdk
260
+ .marketplace(orgUid)
261
+ .app(flags["app-uid"])
262
+ .hosting()
263
+ .disconnect({ provider: "launch" });
283
264
  }
284
265
  exports.disconnectApp = disconnectApp;
285
266
  function formatUrl(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/apps-cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "App ClI",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/contentstack-apps-cli",