@apimatic/cli 1.1.0-alpha.13 → 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 +96 -95
- package/lib/actions/action-result.d.ts +8 -0
- package/lib/actions/action-result.js +25 -0
- 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/generate.d.ts +11 -5
- package/lib/actions/portal/generate.js +54 -47
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/recipe/new-recipe.d.ts +3 -3
- package/lib/actions/portal/recipe/new-recipe.js +18 -31
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +17 -0
- package/lib/actions/portal/serve.js +36 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +4 -1
- package/lib/actions/portal/toc/new-toc.js +37 -34
- 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 +11 -0
- package/lib/application/portal/serve/portal-watcher.js +67 -0
- package/lib/application/portal/serve/portal-watcher.js.map +1 -0
- package/lib/application/portal/serve/serve-handler.d.ts +16 -0
- package/lib/application/portal/serve/serve-handler.js +91 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -0
- package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
- package/lib/application/portal/serve/watcher-handler.js +51 -0
- package/lib/application/portal/serve/watcher-handler.js.map +1 -0
- package/lib/application/portal/toc/sdl-parser.d.ts +2 -1
- package/lib/application/portal/toc/sdl-parser.js +4 -4
- package/lib/application/portal/toc/sdl-parser.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 +7 -38
- 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 -19
- 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 -13
- 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 -65
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +2 -6
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +3 -6
- 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 +7 -10
- package/lib/commands/portal/generate.js +18 -83
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/quickstart.d.ts +2 -2
- package/lib/commands/portal/quickstart.js +58 -29
- package/lib/commands/portal/quickstart.js.map +1 -1
- package/lib/commands/portal/recipe/new.d.ts +1 -3
- package/lib/commands/portal/recipe/new.js +21 -27
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +7 -6
- package/lib/commands/portal/serve.js +62 -112
- 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 +26 -37
- 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 -124
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/controllers/portal/quickstart.d.ts +0 -2
- package/lib/controllers/portal/quickstart.js +2 -60
- package/lib/controllers/portal/quickstart.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 +15 -0
- package/lib/infrastructure/file-service.js +61 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- 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 +7 -4
- package/lib/infrastructure/services/portal-service.js +70 -49
- 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/infrastructure/zip-service.d.ts +6 -0
- package/lib/infrastructure/zip-service.js +25 -0
- package/lib/infrastructure/zip-service.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/common/base-prompts.d.ts +7 -0
- package/lib/prompts/portal/common/base-prompts.js +19 -0
- package/lib/prompts/portal/common/base-prompts.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 +3 -2
- package/lib/prompts/portal/generate.js +21 -36
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +8 -9
- package/lib/prompts/portal/quickstart.js +44 -32
- 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 +18 -8
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
- package/lib/prompts/portal/serve.d.ts +4 -6
- package/lib/prompts/portal/serve.js +24 -15
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +3 -2
- package/lib/prompts/portal/toc/new-toc.js +11 -14
- 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/file/directoryPath.d.ts +7 -0
- package/lib/types/file/directoryPath.js +16 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +5 -0
- package/lib/types/file/fileName.js +9 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +8 -0
- package/lib/types/file/filePath.js +11 -0
- package/lib/types/file/filePath.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/quickstart.d.ts +1 -1
- package/lib/types/portal/serve.d.ts +13 -0
- package/lib/types/portal/serve.js +2 -0
- package/lib/types/portal/serve.js.map +1 -0
- 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.d.ts +1 -4
- package/lib/utils/utils.js +18 -32
- package/lib/utils/utils.js.map +1 -1
- package/lib/validators/common/directoryValidator.d.ts +3 -7
- package/lib/validators/common/directoryValidator.js +10 -37
- package/lib/validators/common/directoryValidator.js.map +1 -1
- package/lib/validators/portal/serve-validator.d.ts +6 -0
- package/lib/validators/portal/serve-validator.js +15 -0
- package/lib/validators/portal/serve-validator.js.map +1 -0
- package/package.json +6 -3
- package/lib/controllers/portal/generate.d.ts +0 -3
- package/lib/controllers/portal/generate.js +0 -106
- package/lib/controllers/portal/generate.js.map +0 -1
- package/lib/controllers/portal/serve.d.ts +0 -3
- package/lib/controllers/portal/serve.js +0 -136
- package/lib/controllers/portal/serve.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/services/portal/server.d.ts +0 -14
- package/lib/services/portal/server.js +0 -97
- package/lib/services/portal/server.js.map +0 -1
- package/lib/validators/common/portValidator.d.ts +0 -5
- package/lib/validators/common/portValidator.js +0 -16
- package/lib/validators/common/portValidator.js.map +0 -1
- package/lib/validators/portal/serveValidator.d.ts +0 -6
- package/lib/validators/portal/serveValidator.js +0 -17
- package/lib/validators/portal/serveValidator.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ $ npm install -g @apimatic/cli
|
|
|
24
24
|
$ apimatic COMMAND
|
|
25
25
|
running command...
|
|
26
26
|
$ apimatic (--version)
|
|
27
|
-
@apimatic/cli/1.1.0-alpha.
|
|
27
|
+
@apimatic/cli/1.1.0-alpha.14 win32-x64 node-v20.18.3
|
|
28
28
|
$ apimatic --help [COMMAND]
|
|
29
29
|
USAGE
|
|
30
30
|
$ apimatic COMMAND
|
|
@@ -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|
|
|
@@ -75,10 +75,8 @@ DESCRIPTION
|
|
|
75
75
|
|
|
76
76
|
EXAMPLES
|
|
77
77
|
$ apimatic api:transform --format="OpenApi3Json" --file="./specs/sample.json" --destination="D:/"
|
|
78
|
-
Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
|
|
79
78
|
|
|
80
79
|
$ apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"
|
|
81
|
-
Success! Your transformed file is located at D:/swagger_raml.yaml
|
|
82
80
|
```
|
|
83
81
|
|
|
84
82
|
_See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/api/transform.ts)_
|
|
@@ -89,23 +87,21 @@ Validate the syntactic and semantic correctness of an API specification
|
|
|
89
87
|
|
|
90
88
|
```
|
|
91
89
|
USAGE
|
|
92
|
-
$ apimatic api:validate [--file <value>] [--url <value>] [
|
|
90
|
+
$ apimatic api:validate [--file <value>] [--url <value>] [-k <value>]
|
|
93
91
|
|
|
94
92
|
FLAGS
|
|
95
|
-
--auth-key=<value> override current authentication state with an authentication key
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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.
|
|
99
97
|
|
|
100
98
|
DESCRIPTION
|
|
101
99
|
Validate the syntactic and semantic correctness of an API specification
|
|
102
100
|
|
|
103
101
|
EXAMPLES
|
|
104
102
|
$ apimatic api:validate --file="./specs/sample.json"
|
|
105
|
-
Specification file provided is valid
|
|
106
103
|
|
|
107
104
|
$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
108
|
-
Specification file provided is valid
|
|
109
105
|
```
|
|
110
106
|
|
|
111
107
|
_See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/api/validate.ts)_
|
|
@@ -116,58 +112,52 @@ Login using your APIMatic credentials or an API Key
|
|
|
116
112
|
|
|
117
113
|
```
|
|
118
114
|
USAGE
|
|
119
|
-
$ apimatic auth:login [
|
|
115
|
+
$ apimatic auth:login [-k <value>]
|
|
120
116
|
|
|
121
117
|
FLAGS
|
|
122
|
-
--auth-key=<value>
|
|
118
|
+
-k, --auth-key=<value> Sets authentication key for all commands.
|
|
123
119
|
|
|
124
120
|
DESCRIPTION
|
|
125
121
|
Login using your APIMatic credentials or an API Key
|
|
126
122
|
|
|
127
123
|
EXAMPLES
|
|
128
124
|
$ apimatic auth:login
|
|
129
|
-
Enter your registered email: apimatic-user@gmail.com
|
|
130
|
-
Please enter your password: *********
|
|
131
|
-
You have successfully logged into APIMatic
|
|
132
125
|
|
|
133
|
-
$ apimatic auth:login --auth-key=
|
|
134
|
-
Authentication key successfully set
|
|
126
|
+
$ apimatic auth:login --auth-key={api-key}
|
|
135
127
|
```
|
|
136
128
|
|
|
137
129
|
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/login.ts)_
|
|
138
130
|
|
|
139
131
|
## `apimatic auth:logout`
|
|
140
132
|
|
|
141
|
-
|
|
133
|
+
Clears the local login credentials.
|
|
142
134
|
|
|
143
135
|
```
|
|
144
136
|
USAGE
|
|
145
137
|
$ apimatic auth:logout
|
|
146
138
|
|
|
147
139
|
DESCRIPTION
|
|
148
|
-
|
|
140
|
+
Clears the local login credentials.
|
|
149
141
|
|
|
150
142
|
EXAMPLES
|
|
151
143
|
$ apimatic auth:logout
|
|
152
|
-
Logged out
|
|
153
144
|
```
|
|
154
145
|
|
|
155
146
|
_See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/logout.ts)_
|
|
156
147
|
|
|
157
148
|
## `apimatic auth:status`
|
|
158
149
|
|
|
159
|
-
View
|
|
150
|
+
View the currently logged in user.
|
|
160
151
|
|
|
161
152
|
```
|
|
162
153
|
USAGE
|
|
163
154
|
$ apimatic auth:status
|
|
164
155
|
|
|
165
156
|
DESCRIPTION
|
|
166
|
-
View
|
|
157
|
+
View the currently logged in user.
|
|
167
158
|
|
|
168
159
|
EXAMPLES
|
|
169
160
|
$ apimatic auth:status
|
|
170
|
-
Currently logged in as apimatic-client@gmail.com
|
|
171
161
|
```
|
|
172
162
|
|
|
173
163
|
_See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/status.ts)_
|
|
@@ -218,19 +208,46 @@ DESCRIPTION
|
|
|
218
208
|
|
|
219
209
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/main/src/commands/help.ts)_
|
|
220
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
|
+
|
|
221
237
|
## `apimatic portal:generate`
|
|
222
238
|
|
|
223
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)
|
|
224
240
|
|
|
225
241
|
```
|
|
226
242
|
USAGE
|
|
227
|
-
$ apimatic portal:generate [
|
|
243
|
+
$ apimatic portal:generate [-i <value>] [-d <value>] [-f] [--zip] [-k <value>]
|
|
228
244
|
|
|
229
245
|
FLAGS
|
|
230
|
-
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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.
|
|
234
251
|
--zip download the generated portal as a .zip archive
|
|
235
252
|
|
|
236
253
|
DESCRIPTION
|
|
@@ -239,8 +256,9 @@ DESCRIPTION
|
|
|
239
256
|
rm-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
|
|
240
257
|
|
|
241
258
|
EXAMPLES
|
|
242
|
-
$ apimatic portal:generate
|
|
243
|
-
|
|
259
|
+
$ apimatic portal:generate
|
|
260
|
+
|
|
261
|
+
$ apimatic portal:generate --input="./" --destination="./portal"
|
|
244
262
|
```
|
|
245
263
|
|
|
246
264
|
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/generate.ts)_
|
|
@@ -268,14 +286,12 @@ Generate an API Recipe for a static API Documentation portal.
|
|
|
268
286
|
|
|
269
287
|
```
|
|
270
288
|
USAGE
|
|
271
|
-
$ apimatic portal:recipe:new [--name <value>] [
|
|
289
|
+
$ apimatic portal:recipe:new [--name <value>] [-i <value>]
|
|
272
290
|
|
|
273
291
|
FLAGS
|
|
274
|
-
--
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
content, and build config file. Defaults to the current working directory if not provided.
|
|
278
|
-
--name=<value> name for the recipe
|
|
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
|
|
279
295
|
|
|
280
296
|
DESCRIPTION
|
|
281
297
|
Generate an API Recipe for a static API Documentation portal.
|
|
@@ -284,11 +300,9 @@ DESCRIPTION
|
|
|
284
300
|
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes
|
|
285
301
|
|
|
286
302
|
EXAMPLES
|
|
287
|
-
$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder" --build-config-file="./build-folder/APIMATIC-BUILD.json"
|
|
288
|
-
Generated recipe has been added to build directory at: C:/build-folder/
|
|
289
|
-
|
|
290
303
|
$ apimatic portal:recipe:new
|
|
291
|
-
|
|
304
|
+
|
|
305
|
+
$ apimatic portal:recipe:new --name="My API Recipe" --input="./"
|
|
292
306
|
```
|
|
293
307
|
|
|
294
308
|
_See code: [src/commands/portal/recipe/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/recipe/new.ts)_
|
|
@@ -299,24 +313,26 @@ Generate and deploy a Docs as Code portal with hot reload.
|
|
|
299
313
|
|
|
300
314
|
```
|
|
301
315
|
USAGE
|
|
302
|
-
$ apimatic portal:serve [-p <value>] [-
|
|
303
|
-
<value>]
|
|
316
|
+
$ apimatic portal:serve [-p <value>] [-i <value>] [-d <value>] [-o] [--no-reload] [-i <value>] [-k <value>]
|
|
304
317
|
|
|
305
318
|
FLAGS
|
|
306
|
-
-d, --destination=<value> [default:
|
|
307
|
-
-i, --ignore=<value> Comma-separated list of
|
|
319
|
+
-d, --destination=<value> [default: <input>/portal] path where the portal will be generated.
|
|
320
|
+
-i, --ignore=<value> Comma-separated list of file and directory paths to exclude from portal generation and hot
|
|
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.
|
|
308
325
|
-o, --open Open the portal in the default browser.
|
|
309
|
-
-p, --port=<value> [default: 3000]
|
|
310
|
-
-s, --source=<value> [default: ./] Source directory containing specs, content, and build file. By default, the
|
|
311
|
-
current directory is used.
|
|
312
|
-
--auth-key=<value> Override current authentication state with an authentication key.
|
|
326
|
+
-p, --port=<value> [default: 3000] port to serve the portal.
|
|
313
327
|
--no-reload Disable hot reload.
|
|
314
328
|
|
|
315
329
|
DESCRIPTION
|
|
316
330
|
Generate and deploy a Docs as Code portal with hot reload.
|
|
317
331
|
|
|
318
332
|
EXAMPLES
|
|
319
|
-
$ apimatic portal:serve
|
|
333
|
+
$ apimatic portal:serve
|
|
334
|
+
|
|
335
|
+
$ apimatic portal:serve --input="./" --destination="./portal" --port=3000 --open --no-reload
|
|
320
336
|
```
|
|
321
337
|
|
|
322
338
|
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/serve.ts)_
|
|
@@ -327,19 +343,17 @@ Generates a TOC file based on the content directory and spec folder provided in
|
|
|
327
343
|
|
|
328
344
|
```
|
|
329
345
|
USAGE
|
|
330
|
-
$ apimatic portal:toc:new [
|
|
331
|
-
[--expand-models]
|
|
346
|
+
$ apimatic portal:toc:new [-d <value>] [-i <value>] [-f] [--expand-endpoints] [--expand-models]
|
|
332
347
|
|
|
333
348
|
FLAGS
|
|
334
|
-
--destination=<value>
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
--force overwrite the TOC file if one already exists at the destination.
|
|
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.
|
|
343
357
|
|
|
344
358
|
DESCRIPTION
|
|
345
359
|
Generates a TOC file based on the content directory and spec folder provided in your working directory
|
|
@@ -353,54 +367,41 @@ DESCRIPTION
|
|
|
353
367
|
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal
|
|
354
368
|
|
|
355
369
|
EXAMPLES
|
|
356
|
-
$ apimatic portal:toc:new --destination="./
|
|
357
|
-
A new toc file has been created at ./portal/content/toc.yml
|
|
370
|
+
$ apimatic portal:toc:new --destination="./src/content/"
|
|
358
371
|
|
|
359
|
-
$ apimatic portal:toc:new --
|
|
360
|
-
A new toc file has been created at ./my-project/content/toc.yml
|
|
372
|
+
$ apimatic portal:toc:new --input="./"
|
|
361
373
|
|
|
362
|
-
$ apimatic portal:toc:new --
|
|
363
|
-
A new toc file has been created at ./portal/content/toc.yml
|
|
374
|
+
$ apimatic portal:toc:new --input="./" --destination="./src/content/"
|
|
364
375
|
```
|
|
365
376
|
|
|
366
377
|
_See code: [src/commands/portal/toc/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/toc/new.ts)_
|
|
367
378
|
|
|
368
379
|
## `apimatic sdk:generate`
|
|
369
380
|
|
|
370
|
-
|
|
381
|
+
Generates SDK for your API
|
|
371
382
|
|
|
372
383
|
```
|
|
373
384
|
USAGE
|
|
374
|
-
$ apimatic sdk:generate --platform
|
|
375
|
-
[--
|
|
385
|
+
$ apimatic sdk:generate --platform csharp|java|php|python|ruby|typescript|go [--spec <value>] [-d <value>] [-f]
|
|
386
|
+
[--zip] [-k <value>]
|
|
376
387
|
|
|
377
388
|
FLAGS
|
|
378
|
-
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
--
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
Legacy: CS_NET_STANDARD_LIB|JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB_V2|PYTHON_GENERIC_LIB|RUBY
|
|
385
|
-
_GENERIC_LIB|TS_GENERIC_LIB|GO_GENERIC_LIB
|
|
386
|
-
--url=<value> URL to the API specification to generate SDKs for. Can be used in place of the --file
|
|
387
|
-
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.
|
|
388
395
|
--zip download the generated SDK as a .zip archive
|
|
389
396
|
|
|
390
397
|
DESCRIPTION
|
|
391
|
-
|
|
398
|
+
Generates SDK for your API
|
|
392
399
|
|
|
393
400
|
EXAMPLES
|
|
394
|
-
$ apimatic sdk:generate --platform="
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
Success! Your SDK is located at swagger_sdk_csharp
|
|
398
|
-
|
|
399
|
-
$ apimatic sdk:generate --platform="CSHARP" --url=https://petstore.swagger.io/v2/swagger.json
|
|
400
|
-
Generating SDK... done
|
|
401
|
-
Downloading SDK... done
|
|
402
|
-
Success! Your SDK is located at swagger_sdk_csharp
|
|
401
|
+
$ apimatic sdk:generate --platform="java"
|
|
402
|
+
|
|
403
|
+
$ apimatic sdk:generate --platform="csharp" --spec="./src/spec"
|
|
403
404
|
```
|
|
404
405
|
|
|
405
406
|
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/sdk/generate.ts)_
|
|
406
|
-
<!-- commandsstop -->
|
|
407
|
+
<!-- commandsstop -->
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class ActionResult {
|
|
2
|
+
private readonly message;
|
|
3
|
+
private constructor();
|
|
4
|
+
static error(message: string): ActionResult;
|
|
5
|
+
static success(): ActionResult;
|
|
6
|
+
map(onError: (message: string) => void): void;
|
|
7
|
+
mapAll<T>(onSuccess: () => T, onError: (message: string) => T): T;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ActionResult {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
this.message = message;
|
|
4
|
+
}
|
|
5
|
+
static error(message) {
|
|
6
|
+
return new ActionResult(message);
|
|
7
|
+
}
|
|
8
|
+
static success() {
|
|
9
|
+
return new ActionResult();
|
|
10
|
+
}
|
|
11
|
+
map(onError) {
|
|
12
|
+
if (this.message) {
|
|
13
|
+
onError(this.message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
mapAll(onSuccess, onError) {
|
|
17
|
+
if (this.message) {
|
|
18
|
+
return onError(this.message);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return onSuccess();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=action-result.js.map
|
|
@@ -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":"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"}
|
|
@@ -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,GAAG,IAAI,UAAU,EAAE,CAAC;QAC9B,YAAO,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAKpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,cAA6B,EAAE,cAAsB,EAAE,MAAe;QACzF,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC;QAEtD,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;YACrC,OAAO,YAAY,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,oBAAoB,EAAE,CAAC;QAE5D,IAAI,SAAS,CAAC,gBAAgB,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAChF,OAAO,YAAY,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;YACtB,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;QAC5E,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,YAAY,CAAC,KAAK,CAAC,mGAAmG,CAAC,CAAC;QACjI,CAAC;QAED,SAAS,CAAC,gBAAgB,GAAG;YAC3B,SAAS,EAAE,MAAM;YACjB,GAAG,EAAE,aAAa;YAClB,cAAc,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,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
export declare class GenerateAction {
|
|
3
4
|
private readonly prompts;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
private
|
|
5
|
+
private readonly zipArchiver;
|
|
6
|
+
private readonly fileService;
|
|
7
|
+
private readonly portalService;
|
|
8
|
+
private readonly configDir;
|
|
9
|
+
private readonly authKey;
|
|
10
|
+
constructor(configDir: DirectoryPath, authKey?: string | null);
|
|
11
|
+
readonly execute: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, force: boolean, zipPortal: boolean) => Promise<ActionResult>;
|
|
12
|
+
private parseError;
|
|
7
13
|
}
|