@contentstack/apps-cli 1.3.1 → 1.3.3

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.3 darwin-arm64 node-v18.12.1
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.3/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.3/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.3/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.3/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.3/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.3/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.3/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.3/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.3/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
  }
@@ -96,8 +96,7 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
96
96
  * @returns {Promise<ApolloClient>} The Apollo Client instance.
97
97
  */
98
98
  async getApolloClient(projectUid = "") {
99
- const baseUrl = config_1.default.launchBaseUrl ||
100
- config_1.default.launchHubUrls[this.cmaAPIUrl];
99
+ const baseUrl = config_1.default.launchBaseUrl || (0, util_2.getLaunchHubUrl)();
101
100
  const manageApiBaseUrl = `${baseUrl}/${config_1.default.manageApiEndpoint}`;
102
101
  return await new util_1.GraphqlApiClient({
103
102
  headers: {
@@ -195,7 +194,10 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
195
194
  if (!this.flags["yes"]) {
196
195
  throw new Error(messages_1.deployAppMsg.APP_UPDATE_TERMINATION_MSG);
197
196
  }
198
- await (0, util_2.disconnectApp)(this.flags, this.sharedConfig.org, this.developerHubBaseUrl);
197
+ await (0, util_2.disconnectApp)(this.flags, this.sharedConfig.org, {
198
+ marketplaceSdk: this.marketplaceAppSdk,
199
+ log: this.log,
200
+ });
199
201
  }
200
202
  }
201
203
  }
@@ -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() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apiRequestHandler = void 0;
3
+ exports.apiRequestHandler = apiRequestHandler;
4
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
5
  const error_helper_1 = require("./error-helper");
6
6
  async function apiRequestHandler(params) {
@@ -49,4 +49,3 @@ async function apiRequestHandler(params) {
49
49
  throw error;
50
50
  }
51
51
  }
52
- exports.apiRequestHandler = apiRequestHandler;
@@ -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>[]>;
@@ -1,11 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.handleProjectNameConflict = exports.sanitizePath = void 0;
4
+ exports.getOrganizations = getOrganizations;
5
+ exports.getOrgAppUiLocation = getOrgAppUiLocation;
6
+ exports.fetchApps = fetchApps;
7
+ exports.fetchApp = fetchApp;
8
+ exports.fetchAppInstallations = fetchAppInstallations;
9
+ exports.deleteApp = deleteApp;
10
+ exports.installApp = installApp;
11
+ exports.getStacks = getStacks;
12
+ exports.fetchStack = fetchStack;
13
+ exports.uninstallApp = uninstallApp;
14
+ exports.fetchInstalledApps = fetchInstalledApps;
15
+ exports.reinstallApp = reinstallApp;
16
+ exports.updateApp = updateApp;
17
+ exports.getProjects = getProjects;
18
+ exports.getManifestDetails = getManifestDetails;
19
+ exports.setupConfig = setupConfig;
20
+ exports.disconnectApp = disconnectApp;
21
+ exports.formatUrl = formatUrl;
22
+ exports.fetchBoilerplateDetails = fetchBoilerplateDetails;
23
+ exports.validateBoilerplate = validateBoilerplate;
4
24
  const tslib_1 = require("tslib");
5
25
  const map_1 = tslib_1.__importDefault(require("lodash/map"));
6
26
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
27
  const queries_1 = require("../graphql/queries");
8
- const api_request_handler_1 = require("./api-request-handler");
9
28
  const types_1 = require("../types");
10
29
  const inquirer_1 = require("./inquirer");
11
30
  const messages_1 = require("../messages");
@@ -29,7 +48,6 @@ async function getOrganizations(options, skip = 0, organizations = []) {
29
48
  }
30
49
  return organizations;
31
50
  }
32
- exports.getOrganizations = getOrganizations;
33
51
  function getOrgAppUiLocation() {
34
52
  const orgConfigLocation = {
35
53
  type: types_1.AppLocation.ORG_CONFIG,
@@ -43,7 +61,6 @@ function getOrgAppUiLocation() {
43
61
  };
44
62
  return [orgConfigLocation];
45
63
  }
46
- exports.getOrgAppUiLocation = getOrgAppUiLocation;
47
64
  async function fetchApps(flags, orgUid, options, skip = 0, apps = []) {
48
65
  const { log, marketplaceSdk } = options;
49
66
  const response = await marketplaceSdk
@@ -68,7 +85,6 @@ async function fetchApps(flags, orgUid, options, skip = 0, apps = []) {
68
85
  }
69
86
  return apps;
70
87
  }
71
- exports.fetchApps = fetchApps;
72
88
  function fetchApp(flags, orgUid, options) {
73
89
  const { marketplaceSdk } = options;
74
90
  const app = flags["app-uid"];
@@ -77,7 +93,6 @@ function fetchApp(flags, orgUid, options) {
77
93
  .app(app)
78
94
  .fetch();
79
95
  }
80
- exports.fetchApp = fetchApp;
81
96
  function fetchAppInstallations(flags, orgUid, options) {
82
97
  const { managementSdk } = options;
83
98
  const app = flags["app-uid"];
@@ -93,7 +108,6 @@ function fetchAppInstallations(flags, orgUid, options) {
93
108
  throw error; // throwing error here instead of removing the catch block, as the loader needs to stopped in case there is an error.
94
109
  });
95
110
  }
96
- exports.fetchAppInstallations = fetchAppInstallations;
97
111
  function deleteApp(flags, orgUid, options) {
98
112
  const { marketplaceSdk } = options;
99
113
  const app = flags["app-uid"];
@@ -102,7 +116,6 @@ function deleteApp(flags, orgUid, options) {
102
116
  .app(app)
103
117
  .delete();
104
118
  }
105
- exports.deleteApp = deleteApp;
106
119
  function installApp(flags, orgUid, type, options) {
107
120
  const { marketplaceSdk } = options;
108
121
  return marketplaceSdk
@@ -113,35 +126,22 @@ function installApp(flags, orgUid, type, options) {
113
126
  targetType: type,
114
127
  });
115
128
  }
116
- 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
- }
129
+ function reinstallApp(flags, orgUid, type, options) {
130
+ const { marketplaceSdk } = options;
131
+ return marketplaceSdk
132
+ .marketplace(orgUid)
133
+ .app(flags["app-uid"])
134
+ .reinstall({
135
+ targetUid: flags["stack-api-key"] || orgUid,
136
+ targetType: type,
137
+ });
136
138
  }
137
- exports.reinstallApp = reinstallApp;
138
139
  function fetchStack(flags, options) {
139
140
  const { managementSdk } = options;
140
141
  return managementSdk
141
142
  .stack({ api_key: flags["stack-api-key"] })
142
143
  .fetch();
143
144
  }
144
- exports.fetchStack = fetchStack;
145
145
  async function getStacks(options, orgUid, skip = 0, stacks = []) {
146
146
  const { log, managementSdk } = options;
147
147
  const response = await managementSdk
@@ -161,7 +161,6 @@ async function getStacks(options, orgUid, skip = 0, stacks = []) {
161
161
  }
162
162
  return stacks;
163
163
  }
164
- exports.getStacks = getStacks;
165
164
  function uninstallApp(flags, orgUid, options, installationUid) {
166
165
  const { managementSdk } = options;
167
166
  const app = flags["app-uid"];
@@ -171,7 +170,6 @@ function uninstallApp(flags, orgUid, options, installationUid) {
171
170
  .installation(installationUid)
172
171
  .uninstall();
173
172
  }
174
- exports.uninstallApp = uninstallApp;
175
173
  async function fetchInstalledApps(flags, orgUid, options) {
176
174
  const { marketplaceSdk, log } = options;
177
175
  const apps = (await fetchApps(flags, orgUid, options)) || [];
@@ -209,7 +207,6 @@ async function fetchInstalledApps(flags, orgUid, options) {
209
207
  }
210
208
  return batchRequests.flat();
211
209
  }
212
- exports.fetchInstalledApps = fetchInstalledApps;
213
210
  // To remove the relative path
214
211
  const sanitizePath = (str) => str === null || str === void 0 ? void 0 : str.replace(/^(\.\.(\/|\\|$))+/, "");
215
212
  exports.sanitizePath = sanitizePath;
@@ -224,7 +221,6 @@ async function updateApp(flags, orgUid, options, updateReqPayload) {
224
221
  app = Object.assign(app, payload);
225
222
  await app.update();
226
223
  }
227
- exports.updateApp = updateApp;
228
224
  async function getProjects(apolloClient) {
229
225
  const projects = await apolloClient
230
226
  .query({ query: queries_1.projectsQuery, variables: { query: {} } })
@@ -240,7 +236,6 @@ async function getProjects(apolloClient) {
240
236
  });
241
237
  });
242
238
  }
243
- exports.getProjects = getProjects;
244
239
  function getManifestDetails(flags, orgUid, options) {
245
240
  const { managementSdk } = options;
246
241
  const app = flags["app-uid"];
@@ -249,7 +244,6 @@ function getManifestDetails(flags, orgUid, options) {
249
244
  .app(app)
250
245
  .hosting();
251
246
  }
252
- exports.getManifestDetails = getManifestDetails;
253
247
  function setupConfig(configPath) {
254
248
  const configDetails = {};
255
249
  if (configPath) {
@@ -264,28 +258,17 @@ function setupConfig(configPath) {
264
258
  }
265
259
  return configDetails;
266
260
  }
267
- 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
- }
261
+ async function disconnectApp(flags, orgUid, options) {
262
+ const { marketplaceSdk } = options;
263
+ return marketplaceSdk
264
+ .marketplace(orgUid)
265
+ .app(flags["app-uid"])
266
+ .hosting()
267
+ .disconnect({ provider: "launch" });
283
268
  }
284
- exports.disconnectApp = disconnectApp;
285
269
  function formatUrl(url) {
286
270
  return url ? (url.startsWith("https") ? url : `https://${url}`) : "";
287
271
  }
288
- exports.formatUrl = formatUrl;
289
272
  const handleProjectNameConflict = async (projectName, projects, retry = 1) => {
290
273
  if (retry > 3) {
291
274
  throw new Error(messages_1.deployAppMsg.PROJECT_NAME_CONFLICT_FAILED);
@@ -308,7 +291,6 @@ async function fetchBoilerplateDetails() {
308
291
  throw error;
309
292
  }
310
293
  }
311
- exports.fetchBoilerplateDetails = fetchBoilerplateDetails;
312
294
  async function validateBoilerplate(boilerplateName) {
313
295
  const boilerplates = await fetchBoilerplateDetails();
314
296
  const boilerplate = (0, find_1.default)(boilerplates, (boilerplate) => boilerplate.name === boilerplateName);
@@ -317,4 +299,3 @@ async function validateBoilerplate(boilerplateName) {
317
299
  }
318
300
  return boilerplate;
319
301
  }
320
- exports.validateBoilerplate = validateBoilerplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatErrors = void 0;
3
+ exports.formatErrors = formatErrors;
4
4
  function formatErrors(errors) {
5
5
  let errorMessage = "";
6
6
  if (errors.message) {
@@ -8,4 +8,3 @@ function formatErrors(errors) {
8
8
  }
9
9
  return errorMessage;
10
10
  }
11
- exports.formatErrors = formatErrors;
package/lib/util/fs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeFile = void 0;
3
+ exports.writeFile = writeFile;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
@@ -26,7 +26,6 @@ async function writeFile(dir = process.cwd(), force = false, data = {}, log = co
26
26
  await (0, fs_1.writeFileSync)(target, JSON.stringify(data));
27
27
  log((0, messages_1.$t)(messages_1.default.FILE_WRITTEN_SUCCESS, { file: target }), "info");
28
28
  }
29
- exports.writeFile = writeFile;
30
29
  async function ensureDirectoryExists(dir) {
31
30
  if (!(0, fs_1.existsSync)(dir)) {
32
31
  await (0, fs_1.mkdirSync)(dir, { recursive: true });
@@ -41,4 +41,5 @@ declare function askConfirmation(): Promise<boolean>;
41
41
  declare const askProjectName: (projectName: string) => Promise<string>;
42
42
  declare const selectedBoilerplate: () => Promise<any>;
43
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, };
44
+ declare function getLaunchHubUrl(): string;
45
+ export { getOrg, getAppName, getDirName, getDeveloperHubUrl, getApp, getInstalledApps, getStack, getInstallation, getHostingType, getAppUrl, askProjectType, askConfirmation, selectProject, askProjectName, selectedBoilerplate, validateAppName, getLaunchHubUrl, };
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.validateAppName = exports.selectedBoilerplate = exports.askProjectName = exports.askProjectType = void 0;
4
+ exports.getOrg = getOrg;
5
+ exports.getAppName = getAppName;
6
+ exports.getDirName = getDirName;
7
+ exports.getDeveloperHubUrl = getDeveloperHubUrl;
8
+ exports.getApp = getApp;
9
+ exports.getInstalledApps = getInstalledApps;
10
+ exports.getStack = getStack;
11
+ exports.getInstallation = getInstallation;
12
+ exports.getHostingType = getHostingType;
13
+ exports.getAppUrl = getAppUrl;
14
+ exports.askConfirmation = askConfirmation;
15
+ exports.selectProject = selectProject;
16
+ exports.getLaunchHubUrl = getLaunchHubUrl;
4
17
  const tslib_1 = require("tslib");
5
18
  const find_1 = tslib_1.__importDefault(require("lodash/find"));
6
19
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
@@ -28,7 +41,6 @@ async function getAppName(defaultName = "") {
28
41
  },
29
42
  });
30
43
  }
31
- exports.getAppName = getAppName;
32
44
  /**
33
45
  * @method getDirName
34
46
  *
@@ -56,7 +68,6 @@ async function getDirName(path) {
56
68
  })
57
69
  .then((name) => (0, path_1.join)((0, common_utils_1.sanitizePath)(basePath), (0, common_utils_1.sanitizePath)(name)));
58
70
  }
59
- exports.getDirName = getDirName;
60
71
  /**
61
72
  * @method getOrg
62
73
  *
@@ -82,7 +93,6 @@ async function getOrg(flags, options) {
82
93
  }
83
94
  return orgUid;
84
95
  }
85
- exports.getOrg = getOrg;
86
96
  async function getApp(flags, orgUid, options) {
87
97
  cli_utilities_1.cliux.loader("Loading Apps");
88
98
  const apps = await (0, common_utils_1.fetchApps)(flags, orgUid, options);
@@ -100,7 +110,6 @@ async function getApp(flags, orgUid, options) {
100
110
  .then((name) => { var _a; return (_a = apps.find((app) => app.name === name)) === null || _a === void 0 ? void 0 : _a.uid; });
101
111
  return apps.find((app) => app.uid === flags.app);
102
112
  }
103
- exports.getApp = getApp;
104
113
  async function getInstalledApps(flags, orgUid, options) {
105
114
  cli_utilities_1.cliux.loader("Loading Apps");
106
115
  const apps = await (0, common_utils_1.fetchInstalledApps)(flags, orgUid, options);
@@ -118,7 +127,6 @@ async function getInstalledApps(flags, orgUid, options) {
118
127
  .then((name) => { var _a; return (_a = apps.find((app) => app.name === name)) === null || _a === void 0 ? void 0 : _a.uid; });
119
128
  return apps.find((app) => app.uid === flags.app);
120
129
  }
121
- exports.getInstalledApps = getInstalledApps;
122
130
  /**
123
131
  * @method getDeveloperHubUrl
124
132
  *
@@ -141,7 +149,6 @@ function getDeveloperHubUrl() {
141
149
  : developerHubBaseUrl;
142
150
  return developerHubBaseUrl;
143
151
  }
144
- exports.getDeveloperHubUrl = getDeveloperHubUrl;
145
152
  async function getStack(orgUid, options) {
146
153
  cli_utilities_1.cliux.loader("Loading Stacks");
147
154
  const stacks = (await (0, common_utils_1.getStacks)(options, orgUid)) || [];
@@ -160,7 +167,6 @@ async function getStack(orgUid, options) {
160
167
  .then((name) => stacks.find((stack) => stack.name === name));
161
168
  return selectedStack;
162
169
  }
163
- exports.getStack = getStack;
164
170
  async function getInstallation(flags, orgUid, managementSdkForStacks, appType, options, uninstallAll) {
165
171
  var _a;
166
172
  const { log } = options;
@@ -207,7 +213,6 @@ async function getInstallation(flags, orgUid, managementSdkForStacks, appType, o
207
213
  }), "info");
208
214
  return selectedInstallation;
209
215
  }
210
- exports.getInstallation = getInstallation;
211
216
  function populateMissingDataInInstallations(installations, stacks) {
212
217
  let result = installations.map((installation) => {
213
218
  var _a;
@@ -234,7 +239,6 @@ async function getHostingType() {
234
239
  choices: hostingTypes,
235
240
  });
236
241
  }
237
- exports.getHostingType = getHostingType;
238
242
  async function getAppUrl(defaultUrl = "") {
239
243
  return cli_utilities_1.cliux.inquire({
240
244
  type: "input",
@@ -253,7 +257,6 @@ async function getAppUrl(defaultUrl = "") {
253
257
  },
254
258
  });
255
259
  }
256
- exports.getAppUrl = getAppUrl;
257
260
  async function selectProject(projects) {
258
261
  return await cli_utilities_1.cliux
259
262
  .inquire({
@@ -264,7 +267,6 @@ async function selectProject(projects) {
264
267
  })
265
268
  .then((name) => (0, find_1.default)(projects, { name }));
266
269
  }
267
- exports.selectProject = selectProject;
268
270
  const askProjectType = async () => {
269
271
  return await cli_utilities_1.cliux.inquire({
270
272
  type: "list",
@@ -284,7 +286,6 @@ async function askConfirmation() {
284
286
  name: "disconnect_launch_confirmation",
285
287
  });
286
288
  }
287
- exports.askConfirmation = askConfirmation;
288
289
  const askProjectName = async (projectName) => {
289
290
  return await cli_utilities_1.cliux.inquire({
290
291
  type: "input",
@@ -320,3 +321,16 @@ const validateAppName = (name) => {
320
321
  }
321
322
  };
322
323
  exports.validateAppName = validateAppName;
324
+ function getLaunchHubUrl() {
325
+ const { cma } = cli_utilities_1.configHandler.get('region') || {};
326
+ if (!cma) {
327
+ throw new Error('Region not configured. Please set the region with command $ csdx config:set:region');
328
+ }
329
+ let launchHubBaseUrl = cma.replace('api', 'launch-api');
330
+ if (launchHubBaseUrl.startsWith('http')) {
331
+ launchHubBaseUrl = launchHubBaseUrl.split('//')[1];
332
+ }
333
+ launchHubBaseUrl = launchHubBaseUrl.startsWith('dev11') ? launchHubBaseUrl.replace('dev11', 'dev') : launchHubBaseUrl;
334
+ launchHubBaseUrl = launchHubBaseUrl.endsWith('io') ? launchHubBaseUrl.replace('io', 'com') : launchHubBaseUrl;
335
+ return `https://${launchHubBaseUrl}`;
336
+ }
package/lib/util/log.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.print = void 0;
3
+ exports.print = print;
4
4
  const tslib_1 = require("tslib");
5
5
  const map_1 = tslib_1.__importDefault(require("lodash/map"));
6
6
  const winston_1 = tslib_1.__importDefault(require("winston"));
@@ -147,4 +147,3 @@ function print(printInput) {
147
147
  }).join(" ");
148
148
  cli_utilities_1.cliux.print(str);
149
149
  }
150
- exports.print = print;
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.3",
4
4
  "description": "App ClI",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/contentstack-apps-cli",
@@ -21,16 +21,15 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@apollo/client": "^3.7.9",
24
- "@contentstack/cli-command": "^1.2.18",
25
- "@contentstack/cli-launch": "^1.0.18",
26
- "@contentstack/cli-utilities": "^1.7.0",
27
- "adm-zip": "^0.5.10",
24
+ "@contentstack/cli-command": "~1.2.19",
25
+ "@contentstack/cli-launch": "~1.2.0",
26
+ "@contentstack/cli-utilities": "~1.7.0",
27
+ "adm-zip": "^0.5.15",
28
28
  "chalk": "^4.1.2",
29
29
  "lodash": "^4.17.21",
30
- "open": "^9.1.0",
31
30
  "shelljs": "^0.8.5",
32
- "tmp": "^0.2.2",
33
- "winston": "^3.11.0"
31
+ "tmp": "^0.2.3",
32
+ "winston": "^3.12.0"
34
33
  },
35
34
  "devDependencies": {
36
35
  "@oclif/test": "^2.5.6",
@@ -38,13 +37,13 @@
38
37
  "@types/chai": "^4.3.11",
39
38
  "@types/lodash": "^4.17.4",
40
39
  "@types/mocha": "^10.0.6",
41
- "@types/node": "^20.10.7",
40
+ "@types/node": "^20.15.0",
42
41
  "@types/shelljs": "^0.8.15",
43
42
  "@types/tmp": "^0.2.6",
44
- "axios": "^1.6.5",
43
+ "axios": "^1.7.4",
45
44
  "chai": "^4.3.10",
46
- "dotenv": "^16.3.1",
47
- "eslint": "^8.56.0",
45
+ "dotenv": "^16.4.5",
46
+ "eslint": "^8.57.0",
48
47
  "eslint-config-oclif": "^5.0.0",
49
48
  "eslint-config-oclif-typescript": "^3.1.0",
50
49
  "mocha": "^10.2.0",