@contentstack/apps-cli 1.4.0 → 1.5.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/LICENSE +2 -2
- package/README.md +43 -41
- package/lib/commands/app/create.js +11 -11
- package/lib/commands/app/deploy.d.ts +1 -1
- package/lib/commands/app/deploy.js +22 -25
- package/lib/graphql/queries.d.ts +1 -1
- package/lib/graphql/queries.js +2 -2
- package/lib/util/common-utils.d.ts +1 -1
- package/package.json +7 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 Contentstack
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<!-- Insert Apps CLI version here -->
|
|
3
3
|
|
|
4
4
|
# @contentstack/apps-cli
|
|
5
|
+
|
|
5
6
|
Contentstack lets you develop apps in your organization using the Developer Hub portal. With the Apps CLI plugin, Contentstack CLI allows you to perform the CRUD operations on your app in Developer Hub and then use the app in your organization or stack by installing or uninstalling your app as required.
|
|
6
7
|
|
|
7
8
|
## How to install this plugin
|
|
@@ -20,7 +21,7 @@ $ npm install -g @contentstack/apps-cli
|
|
|
20
21
|
$ csdx COMMAND
|
|
21
22
|
running command...
|
|
22
23
|
$ csdx (--version|-v)
|
|
23
|
-
@contentstack/apps-cli/1.
|
|
24
|
+
@contentstack/apps-cli/1.5.0 darwin-arm64 node-v22.13.1
|
|
24
25
|
$ csdx --help [COMMAND]
|
|
25
26
|
USAGE
|
|
26
27
|
$ csdx COMMAND
|
|
@@ -29,6 +30,7 @@ USAGE
|
|
|
29
30
|
<!-- usagestop -->
|
|
30
31
|
|
|
31
32
|
# Commands
|
|
33
|
+
|
|
32
34
|
<!-- commands -->
|
|
33
35
|
* [`csdx app`](#csdx-app)
|
|
34
36
|
* [`csdx app:create`](#csdx-appcreate)
|
|
@@ -69,7 +71,7 @@ EXAMPLES
|
|
|
69
71
|
$ csdx app:update
|
|
70
72
|
```
|
|
71
73
|
|
|
72
|
-
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
74
|
+
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/index.ts)_
|
|
73
75
|
|
|
74
76
|
## `csdx app:create`
|
|
75
77
|
|
|
@@ -77,18 +79,18 @@ Create a new app in Developer Hub and optionally clone a boilerplate locally.
|
|
|
77
79
|
|
|
78
80
|
```
|
|
79
81
|
USAGE
|
|
80
|
-
$ csdx app:create [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
|
|
81
|
-
|
|
82
|
+
$ csdx app:create [--org <value>] [-n <value>] [--app-type stack|organization] [-c <value>] [-d <value>]
|
|
83
|
+
[--boilerplate <value>]
|
|
82
84
|
|
|
83
85
|
FLAGS
|
|
84
|
-
-c, --config=<value>
|
|
85
|
-
-d, --data-dir=<value>
|
|
86
|
-
-n, --name=<value>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
-c, --config=<value> Path of the external config
|
|
87
|
+
-d, --data-dir=<value> Current working directory.
|
|
88
|
+
-n, --name=<value> Name of the app to be created
|
|
89
|
+
--app-type=<option> [default: stack] Type of app
|
|
90
|
+
<options: stack|organization>
|
|
91
|
+
--boilerplate=<value> Provide a boilerplate. <options: App Boilerplate|DAM App Boilerplate|Ecommerce App
|
|
92
|
+
Boilerplate>
|
|
93
|
+
--org=<value> Provide the organization UID to fetch the app details for the operation.
|
|
92
94
|
|
|
93
95
|
DESCRIPTION
|
|
94
96
|
Create a new app in Developer Hub and optionally clone a boilerplate locally.
|
|
@@ -109,7 +111,7 @@ EXAMPLES
|
|
|
109
111
|
$ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App Boilerplate>
|
|
110
112
|
```
|
|
111
113
|
|
|
112
|
-
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
114
|
+
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/create.ts)_
|
|
113
115
|
|
|
114
116
|
## `csdx app:delete`
|
|
115
117
|
|
|
@@ -117,7 +119,7 @@ Delete app from marketplace
|
|
|
117
119
|
|
|
118
120
|
```
|
|
119
121
|
USAGE
|
|
120
|
-
$ csdx app:delete [--
|
|
122
|
+
$ csdx app:delete [--org <value>] [--app-uid <value>]
|
|
121
123
|
|
|
122
124
|
FLAGS
|
|
123
125
|
--app-uid=<value> Provide the app UID of an existing app.
|
|
@@ -134,7 +136,7 @@ EXAMPLES
|
|
|
134
136
|
$ csdx app:delete --app-uid <value> --org <value> -d ./boilerplate
|
|
135
137
|
```
|
|
136
138
|
|
|
137
|
-
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
139
|
+
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/delete.ts)_
|
|
138
140
|
|
|
139
141
|
## `csdx app:deploy`
|
|
140
142
|
|
|
@@ -142,18 +144,18 @@ Deploy an app
|
|
|
142
144
|
|
|
143
145
|
```
|
|
144
146
|
USAGE
|
|
145
|
-
$ csdx app:deploy [--app-uid <value>] [--hosting-type hosting-with-launch|custom-hosting]
|
|
146
|
-
[--launch-project existing|new] [-c <value>]
|
|
147
|
+
$ csdx app:deploy [--org <value>] [--app-uid <value>] [--hosting-type hosting-with-launch|custom-hosting]
|
|
148
|
+
[--app-url <value>] [--launch-project existing|new] [-c <value>]
|
|
147
149
|
|
|
148
150
|
FLAGS
|
|
149
|
-
-c, --config=<value>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
-c, --config=<value> [optional] Please enter the path of the config file.
|
|
152
|
+
--app-uid=<value> Provide the app UID of an existing app.
|
|
153
|
+
--app-url=<value> Please enter the URL of the app you want to deploy.
|
|
154
|
+
--hosting-type=<option> Choose a valid Hosting Type.
|
|
155
|
+
<options: hosting-with-launch|custom-hosting>
|
|
156
|
+
--launch-project=<option> Choose a new or an existing Launch project.
|
|
157
|
+
<options: existing|new>
|
|
158
|
+
--org=<value> Provide the organization UID to fetch the app details for the operation.
|
|
157
159
|
|
|
158
160
|
DESCRIPTION
|
|
159
161
|
Deploy an app
|
|
@@ -172,7 +174,7 @@ EXAMPLES
|
|
|
172
174
|
$ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <hosting-with-launch> --launch-project <new> --config <config-path>
|
|
173
175
|
```
|
|
174
176
|
|
|
175
|
-
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
177
|
+
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/deploy.ts)_
|
|
176
178
|
|
|
177
179
|
## `csdx app:get`
|
|
178
180
|
|
|
@@ -180,14 +182,14 @@ Get details of an app in developer hub
|
|
|
180
182
|
|
|
181
183
|
```
|
|
182
184
|
USAGE
|
|
183
|
-
$ csdx app:get [--app-uid <value>] [--app-type stack|organization] [-d <value>]
|
|
185
|
+
$ csdx app:get [--org <value>] [--app-uid <value>] [--app-type stack|organization] [-d <value>]
|
|
184
186
|
|
|
185
187
|
FLAGS
|
|
186
|
-
-d, --data-dir=<value>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
-d, --data-dir=<value> Current working directory.
|
|
189
|
+
--app-type=<option> [default: stack] Type of app
|
|
190
|
+
<options: stack|organization>
|
|
191
|
+
--app-uid=<value> Provide the app UID of an existing app.
|
|
192
|
+
--org=<value> Provide the organization UID to fetch the app details for the operation.
|
|
191
193
|
|
|
192
194
|
DESCRIPTION
|
|
193
195
|
Get details of an app in developer hub
|
|
@@ -202,7 +204,7 @@ EXAMPLES
|
|
|
202
204
|
$ csdx app:get --org <value> --app-uid <value> --app-type organization
|
|
203
205
|
```
|
|
204
206
|
|
|
205
|
-
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
207
|
+
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/get.ts)_
|
|
206
208
|
|
|
207
209
|
## `csdx app:install`
|
|
208
210
|
|
|
@@ -210,7 +212,7 @@ Install an app from the marketplace
|
|
|
210
212
|
|
|
211
213
|
```
|
|
212
214
|
USAGE
|
|
213
|
-
$ csdx app:install [--
|
|
215
|
+
$ csdx app:install [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
|
|
214
216
|
|
|
215
217
|
FLAGS
|
|
216
218
|
--app-uid=<value> Provide the app UID of an existing app.
|
|
@@ -228,7 +230,7 @@ EXAMPLES
|
|
|
228
230
|
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
|
|
229
231
|
```
|
|
230
232
|
|
|
231
|
-
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
233
|
+
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/install.ts)_
|
|
232
234
|
|
|
233
235
|
## `csdx app:reinstall`
|
|
234
236
|
|
|
@@ -236,7 +238,7 @@ Reinstall an app from the marketplace
|
|
|
236
238
|
|
|
237
239
|
```
|
|
238
240
|
USAGE
|
|
239
|
-
$ csdx app:reinstall [--
|
|
241
|
+
$ csdx app:reinstall [--org <value>] [--app-uid <value>] [--stack-api-key <value>]
|
|
240
242
|
|
|
241
243
|
FLAGS
|
|
242
244
|
--app-uid=<value> Provide the app UID of an existing app.
|
|
@@ -254,7 +256,7 @@ EXAMPLES
|
|
|
254
256
|
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
|
|
255
257
|
```
|
|
256
258
|
|
|
257
|
-
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
259
|
+
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/reinstall.ts)_
|
|
258
260
|
|
|
259
261
|
## `csdx app:uninstall`
|
|
260
262
|
|
|
@@ -262,7 +264,7 @@ Uninstall an app
|
|
|
262
264
|
|
|
263
265
|
```
|
|
264
266
|
USAGE
|
|
265
|
-
$ csdx app:uninstall [--app-uid <value>] [--installation-uid <value>] [--uninstall-all]
|
|
267
|
+
$ csdx app:uninstall [--org <value>] [--app-uid <value>] [--installation-uid <value>] [--uninstall-all]
|
|
266
268
|
|
|
267
269
|
FLAGS
|
|
268
270
|
--app-uid=<value> Provide the app UID of an existing app.
|
|
@@ -281,7 +283,7 @@ EXAMPLES
|
|
|
281
283
|
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
|
|
282
284
|
```
|
|
283
285
|
|
|
284
|
-
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
286
|
+
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/uninstall.ts)_
|
|
285
287
|
|
|
286
288
|
## `csdx app:update`
|
|
287
289
|
|
|
@@ -289,7 +291,7 @@ Update the existing app in developer hub
|
|
|
289
291
|
|
|
290
292
|
```
|
|
291
293
|
USAGE
|
|
292
|
-
$ csdx app:update [--
|
|
294
|
+
$ csdx app:update [--org <value>] [--app-manifest <value>]
|
|
293
295
|
|
|
294
296
|
FLAGS
|
|
295
297
|
--app-manifest=<value> Path to the app manifest.json file:
|
|
@@ -304,5 +306,5 @@ EXAMPLES
|
|
|
304
306
|
$ csdx app:update --app-manifest ./boilerplate/manifest.json
|
|
305
307
|
```
|
|
306
308
|
|
|
307
|
-
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.
|
|
309
|
+
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.5.0/src/commands/app/update.ts)_
|
|
308
310
|
<!-- commandsstop -->
|
|
@@ -78,9 +78,9 @@ class Create extends base_command_1.BaseCommand {
|
|
|
78
78
|
// NOTE Step 2: Registering the app
|
|
79
79
|
await this.registerTheAppOnDeveloperHub();
|
|
80
80
|
// NOTE Step 3: Install dependencies
|
|
81
|
-
cli_utilities_1.
|
|
81
|
+
cli_utilities_1.cliux.loader(this.messages.INSTALL_DEPENDENCIES);
|
|
82
82
|
await this.installDependencies();
|
|
83
|
-
cli_utilities_1.
|
|
83
|
+
cli_utilities_1.cliux.loader("done");
|
|
84
84
|
this.log(this.$t(this.messages.START_APP_COMMAND, {
|
|
85
85
|
command: `cd "${this.sharedConfig.folderPath}" && npm run start`,
|
|
86
86
|
}), "info");
|
|
@@ -128,7 +128,7 @@ class Create extends base_command_1.BaseCommand {
|
|
|
128
128
|
* @memberof Create
|
|
129
129
|
*/
|
|
130
130
|
async cloneBoilerplate() {
|
|
131
|
-
cli_utilities_1.
|
|
131
|
+
cli_utilities_1.cliux.loader(this.messages.CLONE_BOILERPLATE);
|
|
132
132
|
const tmpObj = tmp.fileSync();
|
|
133
133
|
const filePath = tmpObj.name;
|
|
134
134
|
const writer = (0, fs_1.createWriteStream)(filePath);
|
|
@@ -138,7 +138,7 @@ class Create extends base_command_1.BaseCommand {
|
|
|
138
138
|
writer
|
|
139
139
|
.on("finish", function () {
|
|
140
140
|
resolve(filePath);
|
|
141
|
-
cli_utilities_1.
|
|
141
|
+
cli_utilities_1.cliux.loader("done");
|
|
142
142
|
})
|
|
143
143
|
.on("error", () => {
|
|
144
144
|
reject(this.messages.FILE_GENERATION_FAILURE);
|
|
@@ -169,9 +169,9 @@ class Create extends base_command_1.BaseCommand {
|
|
|
169
169
|
}
|
|
170
170
|
this.sharedConfig.folderPath = targetPath;
|
|
171
171
|
await new Promise((resolve, reject) => {
|
|
172
|
-
cli_utilities_1.
|
|
172
|
+
cli_utilities_1.cliux.loader(this.messages.UNZIP);
|
|
173
173
|
zip.extractAllToAsync(dataDir, true, false, (error) => {
|
|
174
|
-
cli_utilities_1.
|
|
174
|
+
cli_utilities_1.cliux.loader("done");
|
|
175
175
|
if (!error) {
|
|
176
176
|
(0, fs_1.renameSync)(sourcePath, targetPath);
|
|
177
177
|
// NOTE write manifest into Boilerplate location
|
|
@@ -209,7 +209,7 @@ class Create extends base_command_1.BaseCommand {
|
|
|
209
209
|
* @memberof Create
|
|
210
210
|
*/
|
|
211
211
|
async registerTheAppOnDeveloperHub(saveManifest = true, retry = 0) {
|
|
212
|
-
cli_utilities_1.
|
|
212
|
+
cli_utilities_1.cliux.loader(this.$t(this.messages.REGISTER_THE_APP_ON_DEVELOPER_HUB, {
|
|
213
213
|
appName: this.sharedConfig.appName,
|
|
214
214
|
}));
|
|
215
215
|
await this.marketplaceAppSdk
|
|
@@ -217,7 +217,7 @@ class Create extends base_command_1.BaseCommand {
|
|
|
217
217
|
.app()
|
|
218
218
|
.create(this.appData)
|
|
219
219
|
.then((response) => {
|
|
220
|
-
cli_utilities_1.
|
|
220
|
+
cli_utilities_1.cliux.loader("done");
|
|
221
221
|
if (this.sharedConfig.nameChanged) {
|
|
222
222
|
(0, fs_1.renameSync)(this.sharedConfig.oldFolderPath, this.sharedConfig.folderPath);
|
|
223
223
|
}
|
|
@@ -248,7 +248,7 @@ class Create extends base_command_1.BaseCommand {
|
|
|
248
248
|
this.log(this.messages.APP_CREATION_SUCCESS, "info");
|
|
249
249
|
})
|
|
250
250
|
.catch(async (error) => {
|
|
251
|
-
cli_utilities_1.
|
|
251
|
+
cli_utilities_1.cliux.loader("Failed");
|
|
252
252
|
switch (error.status) {
|
|
253
253
|
case 400:
|
|
254
254
|
this.log(this.messages.APP_CREATION_CONSTRAINT_FAILURE, "error");
|
|
@@ -281,13 +281,13 @@ class Create extends base_command_1.BaseCommand {
|
|
|
281
281
|
*/
|
|
282
282
|
rollbackBoilerplate() {
|
|
283
283
|
if ((0, fs_1.existsSync)(this.sharedConfig.folderPath)) {
|
|
284
|
-
cli_utilities_1.
|
|
284
|
+
cli_utilities_1.cliux.loader(this.messages.ROLLBACK_BOILERPLATE);
|
|
285
285
|
(0, fs_1.rmSync)(this.sharedConfig.folderPath, {
|
|
286
286
|
force: true,
|
|
287
287
|
recursive: true,
|
|
288
288
|
maxRetries: 3,
|
|
289
289
|
});
|
|
290
|
-
cli_utilities_1.
|
|
290
|
+
cli_utilities_1.cliux.loader("done");
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApolloClient } from "@apollo/client/core";
|
|
2
1
|
import { FlagInput } from "@contentstack/cli-utilities";
|
|
2
|
+
import { ApolloClient } from "@contentstack/cli-launch";
|
|
3
3
|
import { LaunchProjectRes, UpdateHostingParams } from "../../types";
|
|
4
4
|
import { AppCLIBaseCommand } from "../../app-cli-base-command";
|
|
5
5
|
export default class Deploy extends AppCLIBaseCommand {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
-
const
|
|
6
|
-
const util_1 = require("@contentstack/cli-launch/dist/util");
|
|
7
|
-
const index_1 = tslib_1.__importDefault(require("@contentstack/cli-launch/dist/commands/launch/index"));
|
|
4
|
+
const cli_launch_1 = require("@contentstack/cli-launch");
|
|
8
5
|
const messages_1 = require("../../messages");
|
|
9
6
|
const app_cli_base_command_1 = require("../../app-cli-base-command");
|
|
10
|
-
const
|
|
7
|
+
const util_1 = require("../../util");
|
|
11
8
|
class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
12
9
|
async run() {
|
|
13
10
|
var _a, _b;
|
|
@@ -18,25 +15,25 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
18
15
|
const app = await this.fetchAppDetails();
|
|
19
16
|
this.flags["app-uid"] = (app === null || app === void 0 ? void 0 : app.uid) || "";
|
|
20
17
|
const apolloClient = await this.getApolloClient();
|
|
21
|
-
const projects = await (0,
|
|
18
|
+
const projects = await (0, util_1.getProjects)(apolloClient);
|
|
22
19
|
await this.handleAppDisconnect(projects);
|
|
23
|
-
flags["hosting-type"] = flags["hosting-type"] || (await (0,
|
|
20
|
+
flags["hosting-type"] = flags["hosting-type"] || (await (0, util_1.getHostingType)());
|
|
24
21
|
const updateHostingPayload = {
|
|
25
22
|
provider: "external",
|
|
26
23
|
deployment_url: "",
|
|
27
24
|
};
|
|
28
25
|
switch (flags["hosting-type"]) {
|
|
29
26
|
case "custom-hosting":
|
|
30
|
-
flags["app-url"] = flags["app-url"] || (await (0,
|
|
31
|
-
this.flags["app-url"] = (0,
|
|
27
|
+
flags["app-url"] = flags["app-url"] || (await (0, util_1.getAppUrl)());
|
|
28
|
+
this.flags["app-url"] = (0, util_1.formatUrl)(flags["app-url"]);
|
|
32
29
|
updateHostingPayload["deployment_url"] = this.flags["app-url"];
|
|
33
30
|
break;
|
|
34
31
|
case "hosting-with-launch":
|
|
35
32
|
updateHostingPayload["provider"] = "launch";
|
|
36
|
-
const config = (0,
|
|
33
|
+
const config = (0, util_1.setupConfig)(flags["config"]);
|
|
37
34
|
config["name"] = config["name"] || (app === null || app === void 0 ? void 0 : app.name);
|
|
38
35
|
this.flags["launch-project"] =
|
|
39
|
-
this.flags["launch-project"] || (await (0,
|
|
36
|
+
this.flags["launch-project"] || (await (0, util_1.askProjectType)());
|
|
40
37
|
await this.handleHostingWithLaunch(config, updateHostingPayload, projects);
|
|
41
38
|
break;
|
|
42
39
|
default:
|
|
@@ -44,7 +41,7 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
44
41
|
return;
|
|
45
42
|
}
|
|
46
43
|
if (this.flags["app-uid"]) {
|
|
47
|
-
await (0,
|
|
44
|
+
await (0, util_1.updateApp)(flags, this.sharedConfig.org, {
|
|
48
45
|
managementSdk: this.managementAppSdk,
|
|
49
46
|
log: this.log,
|
|
50
47
|
}, updateHostingPayload);
|
|
@@ -70,7 +67,7 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
70
67
|
var _a, _b;
|
|
71
68
|
const organizationUid = (_b = (_a = this.manifestData) === null || _a === void 0 ? void 0 : _a.organization_uid) !== null && _b !== void 0 ? _b : "";
|
|
72
69
|
if (!organizationUid) {
|
|
73
|
-
return await (0,
|
|
70
|
+
return await (0, util_1.getOrg)(this.flags, {
|
|
74
71
|
managementSdk: this.managementSdk,
|
|
75
72
|
log: this.log,
|
|
76
73
|
});
|
|
@@ -85,12 +82,12 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
85
82
|
*/
|
|
86
83
|
async fetchAppDetails() {
|
|
87
84
|
if (!this.flags["app-uid"]) {
|
|
88
|
-
return await (0,
|
|
85
|
+
return await (0, util_1.getApp)(this.flags, this.sharedConfig.org, {
|
|
89
86
|
marketplaceSdk: this.marketplaceAppSdk,
|
|
90
87
|
log: this.log,
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
|
-
return await (0,
|
|
90
|
+
return await (0, util_1.fetchApp)(this.flags, this.sharedConfig.org, {
|
|
94
91
|
marketplaceSdk: this.marketplaceAppSdk,
|
|
95
92
|
log: this.log,
|
|
96
93
|
});
|
|
@@ -100,9 +97,9 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
100
97
|
* @returns {Promise<ApolloClient>} The Apollo Client instance.
|
|
101
98
|
*/
|
|
102
99
|
async getApolloClient(projectUid = "") {
|
|
103
|
-
const baseUrl =
|
|
104
|
-
const manageApiBaseUrl = `${baseUrl}/${
|
|
105
|
-
return await new
|
|
100
|
+
const baseUrl = cli_launch_1.config.launchBaseUrl || (0, util_1.getLaunchHubUrl)();
|
|
101
|
+
const manageApiBaseUrl = `${baseUrl}/${cli_launch_1.config.manageApiEndpoint}`;
|
|
102
|
+
return await new cli_launch_1.GraphqlApiClient({
|
|
106
103
|
headers: {
|
|
107
104
|
"X-CS-CLI": this.context.analyticsInfo,
|
|
108
105
|
"x-project-uid": projectUid,
|
|
@@ -124,14 +121,14 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
124
121
|
url = await this.handleExistingProject(updateHostingPayload, projects);
|
|
125
122
|
}
|
|
126
123
|
else if (this.flags["launch-project"] === "new") {
|
|
127
|
-
config["name"] = await (0,
|
|
124
|
+
config["name"] = await (0, util_1.handleProjectNameConflict)(config["name"], projects);
|
|
128
125
|
url = await this.handleNewProject(config, updateHostingPayload);
|
|
129
126
|
}
|
|
130
127
|
else {
|
|
131
128
|
this.log("Please provide a valid launch project.", "error");
|
|
132
129
|
return;
|
|
133
130
|
}
|
|
134
|
-
this.flags["app-url"] = (0,
|
|
131
|
+
this.flags["app-url"] = (0, util_1.formatUrl)(url);
|
|
135
132
|
updateHostingPayload["deployment_url"] = this.flags["app-url"];
|
|
136
133
|
}
|
|
137
134
|
/**
|
|
@@ -141,7 +138,7 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
141
138
|
* @returns A Promise that resolves to the project URL if a project is selected, otherwise an empty string.
|
|
142
139
|
*/
|
|
143
140
|
async handleExistingProject(updateHostingPayload, projects) {
|
|
144
|
-
const selectedProject = await (0,
|
|
141
|
+
const selectedProject = await (0, util_1.selectProject)(projects);
|
|
145
142
|
if (selectedProject) {
|
|
146
143
|
updateHostingPayload["environment_uid"] = selectedProject.environmentUid;
|
|
147
144
|
updateHostingPayload["project_uid"] = selectedProject.uid;
|
|
@@ -178,9 +175,9 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
178
175
|
args.push(`--${key}`, value);
|
|
179
176
|
}
|
|
180
177
|
}
|
|
181
|
-
await
|
|
178
|
+
await cli_launch_1.Launch.run(args);
|
|
182
179
|
const apolloClient = await this.getApolloClient();
|
|
183
|
-
const projects = await (0,
|
|
180
|
+
const projects = await (0, util_1.getProjects)(apolloClient);
|
|
184
181
|
const project = projects.find((project) => project.name === config["name"]);
|
|
185
182
|
if (project) {
|
|
186
183
|
updateHostingPayload["environment_uid"] = project.environmentUid;
|
|
@@ -199,11 +196,11 @@ class Deploy extends app_cli_base_command_1.AppCLIBaseCommand {
|
|
|
199
196
|
async handleAppDisconnect(projects) {
|
|
200
197
|
const isProjectConnected = projects.filter((project) => (project === null || project === void 0 ? void 0 : project.developerHubAppUid) === this.flags["app-uid"]);
|
|
201
198
|
if (isProjectConnected === null || isProjectConnected === void 0 ? void 0 : isProjectConnected.length) {
|
|
202
|
-
this.flags["yes"] = this.flags["yes"] || (await (0,
|
|
199
|
+
this.flags["yes"] = this.flags["yes"] || (await (0, util_1.askConfirmation)());
|
|
203
200
|
if (!this.flags["yes"]) {
|
|
204
201
|
throw new Error(messages_1.deployAppMsg.APP_UPDATE_TERMINATION_MSG);
|
|
205
202
|
}
|
|
206
|
-
await (0,
|
|
203
|
+
await (0, util_1.disconnectApp)(this.flags, this.sharedConfig.org, {
|
|
207
204
|
marketplaceSdk: this.marketplaceAppSdk,
|
|
208
205
|
log: this.log,
|
|
209
206
|
});
|
package/lib/graphql/queries.d.ts
CHANGED
package/lib/graphql/queries.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectsQuery = void 0;
|
|
4
|
-
const
|
|
5
|
-
const projectsQuery = (0,
|
|
4
|
+
const cli_launch_1 = require("@contentstack/cli-launch");
|
|
5
|
+
const projectsQuery = (0, cli_launch_1.gql) `
|
|
6
6
|
query Projects($query: QueryProjectsInput!) {
|
|
7
7
|
projects: Projects(query: $query) {
|
|
8
8
|
edges {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApolloClient } from "@
|
|
1
|
+
import { ApolloClient } from "@contentstack/cli-launch";
|
|
2
2
|
import { ContentstackClient, FlagInput, ContentstackMarketplaceClient, Stack } from "@contentstack/cli-utilities";
|
|
3
3
|
import { Extension, LaunchProjectRes, LogFn, UpdateHostingParams } from "../types";
|
|
4
4
|
export type CommonOptions = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/apps-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "App ClI",
|
|
5
5
|
"author": "Contentstack CLI",
|
|
6
6
|
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@apollo/client": "^3.11.8",
|
|
24
|
-
"@contentstack/cli-command": "^1.
|
|
25
|
-
"@contentstack/cli-launch": "^1.
|
|
26
|
-
"@contentstack/cli-utilities": "^1.
|
|
24
|
+
"@contentstack/cli-command": "^1.5.0",
|
|
25
|
+
"@contentstack/cli-launch": "^1.8.0",
|
|
26
|
+
"@contentstack/cli-utilities": "^1.11.0",
|
|
27
27
|
"adm-zip": "^0.5.16",
|
|
28
28
|
"chai-as-promised": "^8.0.0",
|
|
29
29
|
"chalk": "^4.1.2",
|
|
30
30
|
"fancy-test": "^3.0.16",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
|
-
"shelljs": "^0.
|
|
32
|
+
"shelljs": "^0.9.0",
|
|
33
33
|
"tmp": "^0.2.3",
|
|
34
34
|
"winston": "^3.15.0"
|
|
35
35
|
},
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"chai": "^4.5.0",
|
|
47
47
|
"dotenv": "^16.4.5",
|
|
48
48
|
"eslint": "^8.57.1",
|
|
49
|
-
"eslint-config-oclif": "^
|
|
49
|
+
"eslint-config-oclif": "^6.0.15",
|
|
50
50
|
"eslint-config-oclif-typescript": "^3.1.12",
|
|
51
51
|
"fancy-test": "3.0.16",
|
|
52
52
|
"mocha": "^10.7.3",
|
|
53
53
|
"nyc": "^15.1.0",
|
|
54
|
-
"oclif": "^
|
|
54
|
+
"oclif": "^4.17.30",
|
|
55
55
|
"shx": "^0.3.4",
|
|
56
56
|
"ts-node": "^10.9.2",
|
|
57
57
|
"tslib": "^2.8.0",
|