@apimatic/cli 1.1.0-alpha.14 → 1.1.0-alpha.15
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 +92 -68
- package/lib/actions/{actionResult.js → action-result.js} +1 -1
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/auth/login.d.ts +12 -0
- package/lib/actions/auth/login.js +63 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +11 -0
- package/lib/actions/portal/copilot.js +46 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/{generatePortalAction.d.ts → generate.d.ts} +2 -4
- package/lib/actions/portal/{generatePortalAction.js → generate.js} +17 -32
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +0 -1
- package/lib/actions/portal/recipe/new-recipe.js +0 -6
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +1 -1
- package/lib/actions/portal/toc/new-toc.d.ts +2 -0
- package/lib/actions/portal/toc/new-toc.js +21 -18
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +13 -0
- package/lib/actions/sdk/generate.js +49 -0
- package/lib/actions/sdk/generate.js.map +1 -0
- package/lib/application/portal/serve/portal-watcher.d.ts +4 -1
- package/lib/application/portal/serve/portal-watcher.js +11 -4
- package/lib/application/portal/serve/portal-watcher.js.map +1 -1
- package/lib/application/portal/serve/serve-handler.d.ts +1 -1
- package/lib/application/portal/serve/serve-handler.js +1 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -1
- package/lib/application/portal/serve/watcher-handler.d.ts +5 -0
- package/lib/application/portal/serve/watcher-handler.js +36 -12
- package/lib/application/portal/serve/watcher-handler.js.map +1 -1
- package/lib/client-utils/auth-manager.d.ts +7 -2
- package/lib/client-utils/auth-manager.js +24 -7
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/client-utils/sdk-client.d.ts +0 -1
- package/lib/client-utils/sdk-client.js +6 -20
- package/lib/client-utils/sdk-client.js.map +1 -1
- package/lib/commands/api/transform.d.ts +2 -2
- package/lib/commands/api/transform.js +10 -15
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.d.ts +1 -1
- package/lib/commands/api/validate.js +5 -9
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.d.ts +2 -1
- package/lib/commands/auth/login.js +19 -63
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +2 -2
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +3 -2
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/portal/copilot.d.ts +12 -0
- package/lib/commands/portal/copilot.js +35 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +3 -4
- package/lib/commands/portal/generate.js +7 -22
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/quickstart.js +13 -16
- package/lib/commands/portal/quickstart.js.map +1 -1
- package/lib/commands/portal/recipe/new.d.ts +0 -1
- package/lib/commands/portal/recipe/new.js +11 -10
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +3 -4
- package/lib/commands/portal/serve.js +12 -25
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/portal/toc/new.d.ts +4 -5
- package/lib/commands/portal/toc/new.js +14 -21
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +8 -6
- package/lib/commands/sdk/generate.js +53 -116
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/infrastructure/api-utils.d.ts +9 -0
- package/lib/infrastructure/api-utils.js +33 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +8 -0
- package/lib/infrastructure/env-info.js +37 -0
- package/lib/infrastructure/env-info.js.map +1 -0
- package/lib/infrastructure/file-service.d.ts +3 -1
- package/lib/infrastructure/file-service.js +15 -8
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +10 -0
- package/lib/infrastructure/services/api-service.js +52 -0
- package/lib/infrastructure/services/api-service.js.map +1 -0
- package/lib/infrastructure/services/auth-service.d.ts +11 -0
- package/lib/infrastructure/services/auth-service.js +33 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +3 -0
- package/lib/infrastructure/services/portal-service.js +50 -7
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
- package/lib/infrastructure/services/telemetry-service.js +40 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +2 -0
- package/lib/infrastructure/tmp-extensions.js +6 -0
- package/lib/infrastructure/tmp-extensions.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +5 -0
- package/lib/prompts/auth/login.js +13 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +6 -0
- package/lib/prompts/portal/copilot.js +35 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +0 -1
- package/lib/prompts/portal/generate.js +7 -35
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +3 -3
- package/lib/prompts/portal/quickstart.js +18 -14
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +1 -0
- package/lib/prompts/portal/recipe/new-recipe.js +14 -3
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +3 -2
- package/lib/prompts/portal/toc/new-toc.js +9 -13
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +42 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/types/api/account.d.ts +10 -0
- package/lib/types/api/account.js +2 -0
- package/lib/types/api/account.js.map +1 -0
- package/lib/types/build/build.d.ts +14 -0
- package/lib/types/build/build.js +4 -0
- package/lib/types/build/build.js.map +1 -0
- package/lib/types/build-context.d.ts +13 -0
- package/lib/types/build-context.js +30 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/events/domain-event.d.ts +8 -0
- package/lib/types/events/domain-event.js +11 -0
- package/lib/types/events/domain-event.js.map +1 -0
- package/lib/types/events/recipe-creation-failed.d.ts +5 -0
- package/lib/types/events/recipe-creation-failed.js +8 -0
- package/lib/types/events/recipe-creation-failed.js.map +1 -0
- package/lib/types/events/toc-creation-failed.d.ts +5 -0
- package/lib/types/events/toc-creation-failed.js +8 -0
- package/lib/types/events/toc-creation-failed.js.map +1 -0
- package/lib/types/flags-provider.d.ts +15 -0
- package/lib/types/flags-provider.js +34 -0
- package/lib/types/flags-provider.js.map +1 -0
- package/lib/types/portal/generate.d.ts +0 -13
- package/lib/types/portal-context.d.ts +11 -0
- package/lib/types/portal-context.js +28 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +8 -8
- package/lib/types/sdk/generate.js +10 -10
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk-context.d.ts +13 -0
- package/lib/types/sdk-context.js +28 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/spec-context.d.ts +7 -0
- package/lib/types/spec-context.js +12 -0
- package/lib/types/spec-context.js.map +1 -0
- package/lib/utils/utils.js +9 -8
- package/lib/utils/utils.js.map +1 -1
- package/package.json +3 -1
- package/lib/actions/actionResult.js.map +0 -1
- package/lib/actions/portal/generatePortalAction.js.map +0 -1
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -61
- package/lib/controllers/sdk/generate.js.map +0 -1
- /package/lib/actions/{actionResult.d.ts → action-result.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ USAGE
|
|
|
41
41
|
* [`apimatic auth:status`](#apimatic-authstatus)
|
|
42
42
|
* [`apimatic autocomplete [SHELL]`](#apimatic-autocomplete-shell)
|
|
43
43
|
* [`apimatic help [COMMAND]`](#apimatic-help-command)
|
|
44
|
+
* [`apimatic portal:copilot`](#apimatic-portalcopilot)
|
|
44
45
|
* [`apimatic portal:generate`](#apimatic-portalgenerate)
|
|
45
46
|
* [`apimatic portal:quickstart`](#apimatic-portalquickstart)
|
|
46
47
|
* [`apimatic portal:recipe:new`](#apimatic-portalrecipenew)
|
|
@@ -54,13 +55,12 @@ Transform API specifications from one format to another. Supports [10+ different
|
|
|
54
55
|
|
|
55
56
|
```
|
|
56
57
|
USAGE
|
|
57
|
-
$ apimatic api:transform --format <value> [--file <value>] [--url <value>] [
|
|
58
|
-
[--auth-key <value>]
|
|
58
|
+
$ apimatic api:transform --format <value> [--file <value>] [--url <value>] [-d <value>] [-f] [-k <value>]
|
|
59
59
|
|
|
60
60
|
FLAGS
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
-d, --destination=<value> [default: ./] directory to download transformed file to
|
|
62
|
+
-f, --force overwrite changes without asking for user consent.
|
|
63
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
64
64
|
--file=<value> path to the API specification file to transform
|
|
65
65
|
--format=<value> (required) specification format to transform API specification into
|
|
66
66
|
APIMATIC|WADL2009|WSDL|SWAGGER10|SWAGGER20|SWAGGERYAML|OAS3|OPENAPI3YAML|APIBLUEPRINT|RAML|
|
|
@@ -87,13 +87,13 @@ Validate the syntactic and semantic correctness of an API specification
|
|
|
87
87
|
|
|
88
88
|
```
|
|
89
89
|
USAGE
|
|
90
|
-
$ apimatic api:validate [--file <value>] [--url <value>] [
|
|
90
|
+
$ apimatic api:validate [--file <value>] [--url <value>] [-k <value>]
|
|
91
91
|
|
|
92
92
|
FLAGS
|
|
93
|
-
--auth-key=<value> override current authentication state with an authentication key
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
94
|
+
--file=<value> Path to the API specification file to validate
|
|
95
|
+
--url=<value> URL to the specification file to validate. Can be used in place of the --file option if the
|
|
96
|
+
API specification is publicly available.
|
|
97
97
|
|
|
98
98
|
DESCRIPTION
|
|
99
99
|
Validate the syntactic and semantic correctness of an API specification
|
|
@@ -112,10 +112,10 @@ Login using your APIMatic credentials or an API Key
|
|
|
112
112
|
|
|
113
113
|
```
|
|
114
114
|
USAGE
|
|
115
|
-
$ apimatic auth:login [
|
|
115
|
+
$ apimatic auth:login [-k <value>]
|
|
116
116
|
|
|
117
117
|
FLAGS
|
|
118
|
-
--auth-key=<value>
|
|
118
|
+
-k, --auth-key=<value> Sets authentication key for all commands.
|
|
119
119
|
|
|
120
120
|
DESCRIPTION
|
|
121
121
|
Login using your APIMatic credentials or an API Key
|
|
@@ -123,21 +123,21 @@ DESCRIPTION
|
|
|
123
123
|
EXAMPLES
|
|
124
124
|
$ apimatic auth:login
|
|
125
125
|
|
|
126
|
-
$ apimatic auth:login --auth-key=
|
|
126
|
+
$ apimatic auth:login --auth-key={api-key}
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/login.ts)_
|
|
130
130
|
|
|
131
131
|
## `apimatic auth:logout`
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Clears the local login credentials.
|
|
134
134
|
|
|
135
135
|
```
|
|
136
136
|
USAGE
|
|
137
137
|
$ apimatic auth:logout
|
|
138
138
|
|
|
139
139
|
DESCRIPTION
|
|
140
|
-
|
|
140
|
+
Clears the local login credentials.
|
|
141
141
|
|
|
142
142
|
EXAMPLES
|
|
143
143
|
$ apimatic auth:logout
|
|
@@ -147,14 +147,14 @@ _See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cl
|
|
|
147
147
|
|
|
148
148
|
## `apimatic auth:status`
|
|
149
149
|
|
|
150
|
-
View
|
|
150
|
+
View the currently logged in user.
|
|
151
151
|
|
|
152
152
|
```
|
|
153
153
|
USAGE
|
|
154
154
|
$ apimatic auth:status
|
|
155
155
|
|
|
156
156
|
DESCRIPTION
|
|
157
|
-
View
|
|
157
|
+
View the currently logged in user.
|
|
158
158
|
|
|
159
159
|
EXAMPLES
|
|
160
160
|
$ apimatic auth:status
|
|
@@ -208,20 +208,46 @@ DESCRIPTION
|
|
|
208
208
|
|
|
209
209
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/main/src/commands/help.ts)_
|
|
210
210
|
|
|
211
|
+
## `apimatic portal:copilot`
|
|
212
|
+
|
|
213
|
+
Adds the API Copilot configuration in APIMATIC-BUILD.json
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
USAGE
|
|
217
|
+
$ apimatic portal:copilot [-i <value>] [-m <value>] [--disable] [-k <value>]
|
|
218
|
+
|
|
219
|
+
FLAGS
|
|
220
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which
|
|
221
|
+
includes API specifications and configuration files.
|
|
222
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
223
|
+
-m, --welcome-message=<value> welcome message for the API copilot
|
|
224
|
+
--disable marks the API Copilot as disabled in the configuration
|
|
225
|
+
|
|
226
|
+
DESCRIPTION
|
|
227
|
+
Adds the API Copilot configuration in APIMATIC-BUILD.json
|
|
228
|
+
|
|
229
|
+
EXAMPLES
|
|
230
|
+
$ apimatic portal:copilot --input="./" --welcome-message="Welcome to our API!"
|
|
231
|
+
|
|
232
|
+
$ apimatic portal:copilot --input="./"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
_See code: [src/commands/portal/copilot.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/copilot.ts)_
|
|
236
|
+
|
|
211
237
|
## `apimatic portal:generate`
|
|
212
238
|
|
|
213
239
|
Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
|
|
214
240
|
|
|
215
241
|
```
|
|
216
242
|
USAGE
|
|
217
|
-
$ apimatic portal:generate [
|
|
243
|
+
$ apimatic portal:generate [-i <value>] [-d <value>] [-f] [--zip] [-k <value>]
|
|
218
244
|
|
|
219
245
|
FLAGS
|
|
220
|
-
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
246
|
+
-d, --destination=<value> [default: <input>/portal] path where the portal will be generated.
|
|
247
|
+
-f, --force overwrite changes without asking for user consent.
|
|
248
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
249
|
+
API specifications and configuration files.
|
|
250
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
225
251
|
--zip download the generated portal as a .zip archive
|
|
226
252
|
|
|
227
253
|
DESCRIPTION
|
|
@@ -230,7 +256,9 @@ DESCRIPTION
|
|
|
230
256
|
rm-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
|
|
231
257
|
|
|
232
258
|
EXAMPLES
|
|
233
|
-
$ apimatic portal:generate
|
|
259
|
+
$ apimatic portal:generate
|
|
260
|
+
|
|
261
|
+
$ apimatic portal:generate --input="./" --destination="./portal"
|
|
234
262
|
```
|
|
235
263
|
|
|
236
264
|
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/generate.ts)_
|
|
@@ -258,12 +286,12 @@ Generate an API Recipe for a static API Documentation portal.
|
|
|
258
286
|
|
|
259
287
|
```
|
|
260
288
|
USAGE
|
|
261
|
-
$ apimatic portal:recipe:new [--name <value>] [
|
|
289
|
+
$ apimatic portal:recipe:new [--name <value>] [-i <value>]
|
|
262
290
|
|
|
263
291
|
FLAGS
|
|
264
|
-
--
|
|
265
|
-
|
|
266
|
-
|
|
292
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes API
|
|
293
|
+
specifications and configuration files.
|
|
294
|
+
--name=<value> name for the recipe
|
|
267
295
|
|
|
268
296
|
DESCRIPTION
|
|
269
297
|
Generate an API Recipe for a static API Documentation portal.
|
|
@@ -272,9 +300,9 @@ DESCRIPTION
|
|
|
272
300
|
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes
|
|
273
301
|
|
|
274
302
|
EXAMPLES
|
|
275
|
-
$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder"
|
|
276
|
-
|
|
277
303
|
$ apimatic portal:recipe:new
|
|
304
|
+
|
|
305
|
+
$ apimatic portal:recipe:new --name="My API Recipe" --input="./"
|
|
278
306
|
```
|
|
279
307
|
|
|
280
308
|
_See code: [src/commands/portal/recipe/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/recipe/new.ts)_
|
|
@@ -285,25 +313,26 @@ Generate and deploy a Docs as Code portal with hot reload.
|
|
|
285
313
|
|
|
286
314
|
```
|
|
287
315
|
USAGE
|
|
288
|
-
$ apimatic portal:serve [-p <value>] [-
|
|
289
|
-
<value>]
|
|
316
|
+
$ apimatic portal:serve [-p <value>] [-i <value>] [-d <value>] [-o] [--no-reload] [-i <value>] [-k <value>]
|
|
290
317
|
|
|
291
318
|
FLAGS
|
|
319
|
+
-d, --destination=<value> [default: <input>/portal] path where the portal will be generated.
|
|
292
320
|
-i, --ignore=<value> Comma-separated list of file and directory paths to exclude from portal generation and hot
|
|
293
321
|
reload.
|
|
322
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
323
|
+
API specifications and configuration files.
|
|
324
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
294
325
|
-o, --open Open the portal in the default browser.
|
|
295
|
-
-p, --port=<value>
|
|
296
|
-
--auth-key=<value> Override current authentication state with an authentication key.
|
|
297
|
-
--folder=<value> [default: ./] Path to the parent directory containing the 'build' folder,
|
|
298
|
-
which includes API specifications and configuration files.
|
|
299
|
-
--destination=<value> [default: <folder>/portal] Path to the generated portal.
|
|
326
|
+
-p, --port=<value> [default: 3000] port to serve the portal.
|
|
300
327
|
--no-reload Disable hot reload.
|
|
301
328
|
|
|
302
329
|
DESCRIPTION
|
|
303
330
|
Generate and deploy a Docs as Code portal with hot reload.
|
|
304
331
|
|
|
305
332
|
EXAMPLES
|
|
306
|
-
$ apimatic portal:serve
|
|
333
|
+
$ apimatic portal:serve
|
|
334
|
+
|
|
335
|
+
$ apimatic portal:serve --input="./" --destination="./portal" --port=3000 --open --no-reload
|
|
307
336
|
```
|
|
308
337
|
|
|
309
338
|
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/serve.ts)_
|
|
@@ -314,18 +343,17 @@ Generates a TOC file based on the content directory and spec folder provided in
|
|
|
314
343
|
|
|
315
344
|
```
|
|
316
345
|
USAGE
|
|
317
|
-
$ apimatic portal:toc:new [
|
|
318
|
-
[--expand-models]
|
|
346
|
+
$ apimatic portal:toc:new [-d <value>] [-i <value>] [-f] [--expand-endpoints] [--expand-models]
|
|
319
347
|
|
|
320
348
|
FLAGS
|
|
321
|
-
--destination=<value> [default: <
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
349
|
+
-d, --destination=<value> [default: <input>/src/content] path where the 'toc.yml' will be generated.
|
|
350
|
+
-f, --force overwrite changes without asking for user consent.
|
|
351
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
352
|
+
API specifications and configuration files.
|
|
353
|
+
--expand-endpoints include individual entries for each endpoint in the generated 'toc.yml'. Requires a valid
|
|
354
|
+
API specification in the working directory.
|
|
355
|
+
--expand-models include individual entries for each model in the generated 'toc.yml'. Requires a valid API
|
|
356
|
+
specification in the working directory.
|
|
329
357
|
|
|
330
358
|
DESCRIPTION
|
|
331
359
|
Generates a TOC file based on the content directory and spec folder provided in your working directory
|
|
@@ -339,45 +367,41 @@ DESCRIPTION
|
|
|
339
367
|
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal
|
|
340
368
|
|
|
341
369
|
EXAMPLES
|
|
342
|
-
$ apimatic portal:toc:new --destination="./
|
|
370
|
+
$ apimatic portal:toc:new --destination="./src/content/"
|
|
343
371
|
|
|
344
|
-
$ apimatic portal:toc:new --
|
|
372
|
+
$ apimatic portal:toc:new --input="./"
|
|
345
373
|
|
|
346
|
-
$ apimatic portal:toc:new --
|
|
374
|
+
$ apimatic portal:toc:new --input="./" --destination="./src/content/"
|
|
347
375
|
```
|
|
348
376
|
|
|
349
377
|
_See code: [src/commands/portal/toc/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/toc/new.ts)_
|
|
350
378
|
|
|
351
379
|
## `apimatic sdk:generate`
|
|
352
380
|
|
|
353
|
-
|
|
381
|
+
Generates SDK for your API
|
|
354
382
|
|
|
355
383
|
```
|
|
356
384
|
USAGE
|
|
357
|
-
$ apimatic sdk:generate --platform
|
|
358
|
-
[--
|
|
385
|
+
$ apimatic sdk:generate --platform csharp|java|php|python|ruby|typescript|go [--spec <value>] [-d <value>] [-f]
|
|
386
|
+
[--zip] [-k <value>]
|
|
359
387
|
|
|
360
388
|
FLAGS
|
|
361
|
-
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
--
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
Legacy: CS_NET_STANDARD_LIB|JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB_V2|PYTHON_GENERIC_LIB|RUBY
|
|
368
|
-
_GENERIC_LIB|TS_GENERIC_LIB|GO_GENERIC_LIB
|
|
369
|
-
--url=<value> URL to the API specification to generate SDKs for. Can be used in place of the --file
|
|
370
|
-
option if the API specification is publicly available.
|
|
389
|
+
-d, --destination=<value> [default: <input>/sdk] path where the sdk will be generated.
|
|
390
|
+
-f, --force overwrite changes without asking for user consent.
|
|
391
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
392
|
+
--platform=<option> (required) language platform for sdk
|
|
393
|
+
<options: csharp|java|php|python|ruby|typescript|go>
|
|
394
|
+
--spec=<value> [default: ./src/spec] path to the folder containing the API specification file.
|
|
371
395
|
--zip download the generated SDK as a .zip archive
|
|
372
396
|
|
|
373
397
|
DESCRIPTION
|
|
374
|
-
|
|
398
|
+
Generates SDK for your API
|
|
375
399
|
|
|
376
400
|
EXAMPLES
|
|
377
|
-
$ apimatic sdk:generate --platform="
|
|
401
|
+
$ apimatic sdk:generate --platform="java"
|
|
378
402
|
|
|
379
|
-
$ apimatic sdk:generate --platform="
|
|
403
|
+
$ apimatic sdk:generate --platform="csharp" --spec="./src/spec"
|
|
380
404
|
```
|
|
381
405
|
|
|
382
406
|
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/sdk/generate.ts)_
|
|
383
|
-
<!-- commandsstop -->
|
|
407
|
+
<!-- commandsstop -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-result.js","sourceRoot":"","sources":["../../src/actions/action-result.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAGvB,YAAoB,OAAgB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe;QAC1B,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,OAAkC;QACpC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,MAAM,CAAI,SAAiB,EAAE,OAA+B;QAC1D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAK,CAAC;YACL,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
export declare class LoginAction {
|
|
4
|
+
private readonly configDir;
|
|
5
|
+
private readonly authService;
|
|
6
|
+
private readonly apiService;
|
|
7
|
+
private readonly prompts;
|
|
8
|
+
constructor(configDir: DirectoryPath);
|
|
9
|
+
execute(apiKey?: string | undefined): Promise<Result<string, string>>;
|
|
10
|
+
private poolDeviceToken;
|
|
11
|
+
private verifyKeyAndSave;
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AuthService } from "../../infrastructure/services/auth-service.js";
|
|
2
|
+
import { ApiService } from "../../infrastructure/services/api-service.js";
|
|
3
|
+
import { err, ok } from "neverthrow";
|
|
4
|
+
import { v4 as uuid } from "uuid";
|
|
5
|
+
import open from "open";
|
|
6
|
+
import { setAuthInfo } from "../../client-utils/auth-manager.js";
|
|
7
|
+
import { LoginPrompts } from "../../prompts/auth/login.js";
|
|
8
|
+
import { getErrorMessage } from "../../infrastructure/api-utils.js";
|
|
9
|
+
export class LoginAction {
|
|
10
|
+
constructor(configDir) {
|
|
11
|
+
this.configDir = configDir;
|
|
12
|
+
this.authService = new AuthService();
|
|
13
|
+
this.apiService = new ApiService();
|
|
14
|
+
this.prompts = new LoginPrompts();
|
|
15
|
+
}
|
|
16
|
+
async execute(apiKey = undefined) {
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
const result = await this.poolDeviceToken();
|
|
19
|
+
return (await result.asyncMap(async (token) => {
|
|
20
|
+
return await this.verifyKeyAndSave(token);
|
|
21
|
+
})).andThen((r) => r);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return await this.verifyKeyAndSave(apiKey);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async poolDeviceToken() {
|
|
28
|
+
const state = uuid();
|
|
29
|
+
this.prompts.openBrowser();
|
|
30
|
+
await open(this.authService.getDeviceLoginUrl(state));
|
|
31
|
+
const timeoutDuration = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
const delayMs = 3 * 1000;
|
|
34
|
+
while (true) {
|
|
35
|
+
if (Date.now() - startTime > timeoutDuration) {
|
|
36
|
+
return err("Authentication timed out. Please try again.");
|
|
37
|
+
}
|
|
38
|
+
const result = await this.authService.getDeviceLoginToken(state);
|
|
39
|
+
const token = result.match((res) => res.apiKey, () => {
|
|
40
|
+
/* ignore errors */
|
|
41
|
+
});
|
|
42
|
+
if (token)
|
|
43
|
+
return ok(token);
|
|
44
|
+
// eslint-disable-next-line no-undef
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async verifyKeyAndSave(apiKey) {
|
|
49
|
+
const result = await this.apiService.getAccountInfo(this.configDir, apiKey);
|
|
50
|
+
return result.asyncMap(async (info) => {
|
|
51
|
+
await setAuthInfo(info.Email, apiKey, false, this.configDir);
|
|
52
|
+
return info.Email;
|
|
53
|
+
}).mapErr(e => {
|
|
54
|
+
switch (e) {
|
|
55
|
+
case "UNAUTHORIZED" /* ServiceError.UnAuthorized */:
|
|
56
|
+
return "The provided auth key is invalid";
|
|
57
|
+
default:
|
|
58
|
+
return getErrorMessage(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/actions/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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C,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;YACV,QAAQ,CAAC,EAAE,CAAC;gBACV;oBACE,OAAO,kCAAkC,CAAA;gBAC3C;oBACE,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
export declare class CopilotAction {
|
|
4
|
+
private readonly apiService;
|
|
5
|
+
private readonly prompts;
|
|
6
|
+
private readonly configDir;
|
|
7
|
+
private readonly authKey;
|
|
8
|
+
constructor(configDir: DirectoryPath, authKey?: string | null);
|
|
9
|
+
execute(buildDirectory: DirectoryPath, welcomeMessage: string, enable: boolean): Promise<ActionResult>;
|
|
10
|
+
private selectCopilotKey;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ApiService } from "../../infrastructure/services/api-service.js";
|
|
2
|
+
import { PortalCopilotPrompts } from "../../prompts/portal/copilot.js";
|
|
3
|
+
import { ActionResult } from "../action-result.js";
|
|
4
|
+
import { BuildContext } from "../../types/build-context.js";
|
|
5
|
+
export class CopilotAction {
|
|
6
|
+
constructor(configDir, authKey = null) {
|
|
7
|
+
this.apiService = new ApiService();
|
|
8
|
+
this.prompts = new PortalCopilotPrompts();
|
|
9
|
+
this.configDir = configDir;
|
|
10
|
+
this.authKey = authKey;
|
|
11
|
+
}
|
|
12
|
+
async execute(buildDirectory, welcomeMessage, enable) {
|
|
13
|
+
const buildContext = new BuildContext(buildDirectory);
|
|
14
|
+
if (!(await buildContext.validate())) {
|
|
15
|
+
return ActionResult.error("'src' directory is empty or not valid.");
|
|
16
|
+
}
|
|
17
|
+
const buildJson = await buildContext.getBuildFileContents();
|
|
18
|
+
if (buildJson.apiCopilotConfig != null && !(await this.prompts.confirmOverwrite()))
|
|
19
|
+
return ActionResult.error("Exiting without making any change.");
|
|
20
|
+
const response = await this.apiService.getAccountInfo(this.configDir, this.authKey);
|
|
21
|
+
if (!response.isErr()) {
|
|
22
|
+
return ActionResult.error(response._unsafeUnwrapErr());
|
|
23
|
+
}
|
|
24
|
+
const apiCopilotKey = await this.selectCopilotKey(response._unsafeUnwrap());
|
|
25
|
+
if (apiCopilotKey === null) {
|
|
26
|
+
return ActionResult.error("No copilot key found for the current subscription. Please contact support at support@apimatic.io.");
|
|
27
|
+
}
|
|
28
|
+
buildJson.apiCopilotConfig = {
|
|
29
|
+
isEnabled: enable,
|
|
30
|
+
key: apiCopilotKey,
|
|
31
|
+
welcomeMessage: welcomeMessage
|
|
32
|
+
};
|
|
33
|
+
await buildContext.updateBuildFileContents(buildJson);
|
|
34
|
+
this.prompts.copilotConfigured(apiCopilotKey);
|
|
35
|
+
return ActionResult.success();
|
|
36
|
+
}
|
|
37
|
+
async selectCopilotKey(subscription) {
|
|
38
|
+
if (subscription === undefined ||
|
|
39
|
+
subscription.ApiCopilotKeys === undefined ||
|
|
40
|
+
subscription.ApiCopilotKeys.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return await this.prompts.selectCopilotKey(subscription.ApiCopilotKeys);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/actions/portal/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,aAAa;IAMxB,YAAY,SAAwB,EAAE,UAAyB,IAAI;QALlD,eAAU,GA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,EAAE,cAAc;SAC/B,CAAC;QAEF,MAAM,YAAY,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAC9C,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,YAA0C;QACvE,IACE,YAAY,KAAK,SAAS;YAC1B,YAAY,CAAC,cAAc,KAAK,SAAS;YACzC,YAAY,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EACxC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
-
import { ActionResult } from "../
|
|
3
|
-
export declare class
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
export declare class GenerateAction {
|
|
4
4
|
private readonly prompts;
|
|
5
5
|
private readonly zipArchiver;
|
|
6
6
|
private readonly fileService;
|
|
@@ -9,7 +9,5 @@ export declare class GeneratePortalAction {
|
|
|
9
9
|
private readonly authKey;
|
|
10
10
|
constructor(configDir: DirectoryPath, authKey?: string | null);
|
|
11
11
|
readonly execute: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, force: boolean, zipPortal: boolean) => Promise<ActionResult>;
|
|
12
|
-
private validateBuild;
|
|
13
|
-
private validatePortal;
|
|
14
12
|
private parseError;
|
|
15
13
|
}
|
|
@@ -2,12 +2,13 @@ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
|
|
|
2
2
|
import { ZipService } from "../../infrastructure/zip-service.js";
|
|
3
3
|
import { FileService } from "../../infrastructure/file-service.js";
|
|
4
4
|
import { PortalService } from "../../infrastructure/services/portal-service.js";
|
|
5
|
-
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
6
|
-
import { withDir } from "tmp-promise";
|
|
7
5
|
import { FilePath } from "../../types/file/filePath.js";
|
|
8
6
|
import { FileName } from "../../types/file/fileName.js";
|
|
9
|
-
import { ActionResult } from "../
|
|
10
|
-
|
|
7
|
+
import { ActionResult } from "../action-result.js";
|
|
8
|
+
import { BuildContext } from "../../types/build-context.js";
|
|
9
|
+
import { PortalContext } from "../../types/portal-context.js";
|
|
10
|
+
import { withDirPath } from "../../infrastructure/tmp-extensions.js";
|
|
11
|
+
export class GenerateAction {
|
|
11
12
|
constructor(configDir, authKey = null) {
|
|
12
13
|
this.prompts = new PortalGeneratePrompts();
|
|
13
14
|
this.zipArchiver = new ZipService();
|
|
@@ -15,17 +16,18 @@ export class GeneratePortalAction {
|
|
|
15
16
|
this.portalService = new PortalService();
|
|
16
17
|
this.execute = async (buildDirectory, portalDirectory, force, zipPortal) => {
|
|
17
18
|
if (buildDirectory.isEqual(portalDirectory)) {
|
|
18
|
-
return ActionResult.error(
|
|
19
|
+
return ActionResult.error(`The 'src' and 'portal' directory cannot be the same: "${portalDirectory}"`);
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const buildContext = new BuildContext(buildDirectory);
|
|
22
|
+
if (!await buildContext.validate()) {
|
|
23
|
+
return ActionResult.error(`The 'src' directory is either empty or invalid: "${buildDirectory}"`);
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const portalContext = new PortalContext(portalDirectory);
|
|
26
|
+
if (!force && (await portalContext.exists()) && !(await this.prompts.overwritePortal(portalDirectory))) {
|
|
27
|
+
return ActionResult.error("Please enter a different destination folder or remove the existing files and try again.");
|
|
25
28
|
}
|
|
26
|
-
return await
|
|
29
|
+
return await withDirPath(async (tempDirectory) => {
|
|
27
30
|
this.prompts.displayPortalGenerationMessage();
|
|
28
|
-
const tempDirectory = new DirectoryPath(tempDirResult.path);
|
|
29
31
|
const buildZipPath = new FilePath(tempDirectory, new FileName("build.zip"));
|
|
30
32
|
await this.zipArchiver.archive(buildDirectory, buildZipPath);
|
|
31
33
|
const response = await this.portalService.generatePortal(buildZipPath, this.configDir, this.authKey);
|
|
@@ -33,33 +35,16 @@ export class GeneratePortalAction {
|
|
|
33
35
|
this.prompts.displayPortalGenerationErrorMessage();
|
|
34
36
|
return ActionResult.error(await this.parseError(response.error, portalDirectory, tempDirectory));
|
|
35
37
|
}
|
|
36
|
-
this.prompts.displayPortalGenerationSuccessMessage();
|
|
37
38
|
const tempPortalFilePath = new FilePath(tempDirectory, new FileName("portal.zip"));
|
|
38
39
|
await this.fileService.writeFile(tempPortalFilePath, response.value);
|
|
39
|
-
await
|
|
40
|
-
|
|
41
|
-
const portalFilePath = new FilePath(portalDirectory, new FileName("portal.zip"));
|
|
42
|
-
await this.fileService.copy(tempPortalFilePath, portalFilePath);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
await this.zipArchiver.unArchive(tempPortalFilePath, portalDirectory);
|
|
46
|
-
}
|
|
40
|
+
await portalContext.save(tempPortalFilePath, zipPortal);
|
|
41
|
+
this.prompts.displayPortalGenerationSuccessMessage();
|
|
47
42
|
return ActionResult.success();
|
|
48
|
-
}
|
|
43
|
+
});
|
|
49
44
|
};
|
|
50
45
|
this.configDir = configDir;
|
|
51
46
|
this.authKey = authKey;
|
|
52
47
|
}
|
|
53
|
-
async validateBuild(buildDirectory) {
|
|
54
|
-
// TODO: add more checks here
|
|
55
|
-
return await this.fileService.directoryExists(buildDirectory);
|
|
56
|
-
}
|
|
57
|
-
async validatePortal(portalDirectory, forceCleanup) {
|
|
58
|
-
const isEmptyOrNotExists = await this.fileService.directoryEmpty(portalDirectory);
|
|
59
|
-
if (isEmptyOrNotExists)
|
|
60
|
-
return true;
|
|
61
|
-
return forceCleanup || (await this.prompts.overwritePortal(portalDirectory));
|
|
62
|
-
}
|
|
63
48
|
async parseError(error, portalDirectory, tempDirectory) {
|
|
64
49
|
if (typeof error === 'string') {
|
|
65
50
|
return error;
|
|
@@ -73,4 +58,4 @@ export class GeneratePortalAction {
|
|
|
73
58
|
errorReportPath;
|
|
74
59
|
}
|
|
75
60
|
}
|
|
76
|
-
//# sourceMappingURL=
|
|
61
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/actions/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAGrE,MAAM,OAAO,cAAc;IAQzB,YAAY,SAAwB,EAAE,UAAyB,IAAI;QAPlD,YAAO,GAA0B,IAAI,qBAAqB,EAAE,CAAC;QAC7D,gBAAW,GAAe,IAAI,UAAU,EAAE,CAAC;QAC3C,gBAAW,GAAgB,IAAI,WAAW,EAAE,CAAC;QAC7C,kBAAa,GAAkB,IAAI,aAAa,EAAE,CAAC;QASpD,YAAO,GAAG,KAAK,EAC7B,cAA6B,EAC7B,eAA8B,EAC9B,KAAc,EACd,SAAkB,EACK,EAAE;YAEzB,IAAI,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;gBAC5C,OAAO,YAAY,CAAC,KAAK,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
12
|
-
private validateBuildConfigFilePath;
|
|
13
12
|
private promptUserAndBuildNewRecipe;
|
|
14
13
|
private promptUserAndAddContentStepToRecipe;
|
|
15
14
|
private promptUserAndAddEndpointStepToRecipe;
|
|
@@ -68,12 +68,6 @@ export class PortalRecipeAction {
|
|
|
68
68
|
}
|
|
69
69
|
return Result.success("Portal build input folder path validated successfully.");
|
|
70
70
|
}
|
|
71
|
-
async validateBuildConfigFilePath(buildConfigFilePath) {
|
|
72
|
-
if (buildConfigFilePath && !(await fsExtra.pathExists(buildConfigFilePath))) {
|
|
73
|
-
return Result.failure(`Portal build config file ${buildConfigFilePath} does not exist.`);
|
|
74
|
-
}
|
|
75
|
-
return Result.success("Portal build config file path validated successfully.");
|
|
76
|
-
}
|
|
77
71
|
//TODO: Figure out a better way to do this without the while loop.
|
|
78
72
|
async promptUserAndBuildNewRecipe(buildConfig, contentFolderPath, recipeName, configDir) {
|
|
79
73
|
const recipe = new PortalRecipe(recipeName);
|