@sap/cli-core 2023.12.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/CHANGELOG.md +40 -0
- package/LICENSE +44 -0
- package/README.md +13 -0
- package/assets/error.html +20 -0
- package/assets/success.html +20 -0
- package/cache/cache.d.ts +6 -0
- package/cache/cache.js +82 -0
- package/cache/index.d.ts +2 -0
- package/cache/index.js +12 -0
- package/cache/utils.d.ts +1 -0
- package/cache/utils.js +16 -0
- package/commands/cache.command/clean.command.d.ts +3 -0
- package/commands/cache.command/clean.command.js +15 -0
- package/commands/cache.command/index.d.ts +3 -0
- package/commands/cache.command/index.js +15 -0
- package/commands/cache.command/init.command.d.ts +3 -0
- package/commands/cache.command/init.command.js +36 -0
- package/commands/cache.command/show.command.d.ts +3 -0
- package/commands/cache.command/show.command.js +30 -0
- package/commands/handler/authentication/index.d.ts +2 -0
- package/commands/handler/authentication/index.js +21 -0
- package/commands/handler/authentication/oauth/index.d.ts +2 -0
- package/commands/handler/authentication/oauth/index.js +18 -0
- package/commands/handler/authentication/oauth/secretsProvider/cache.d.ts +2 -0
- package/commands/handler/authentication/oauth/secretsProvider/cache.js +19 -0
- package/commands/handler/authentication/oauth/secretsProvider/file.d.ts +2 -0
- package/commands/handler/authentication/oauth/secretsProvider/file.js +25 -0
- package/commands/handler/authentication/oauth/secretsProvider/index.d.ts +2 -0
- package/commands/handler/authentication/oauth/secretsProvider/index.js +10 -0
- package/commands/handler/authentication/oauth/secretsProvider/options.d.ts +2 -0
- package/commands/handler/authentication/oauth/secretsProvider/options.js +30 -0
- package/commands/handler/authentication/oauth/tokenProvider/getToken.d.ts +2 -0
- package/commands/handler/authentication/oauth/tokenProvider/getToken.js +88 -0
- package/commands/handler/authentication/oauth/tokenProvider/index.d.ts +2 -0
- package/commands/handler/authentication/oauth/tokenProvider/index.js +11 -0
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.d.ts +2 -0
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.js +15 -0
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.d.ts +3 -0
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.js +35 -0
- package/commands/handler/authentication/oauth/tokenProvider/utils.d.ts +1 -0
- package/commands/handler/authentication/oauth/tokenProvider/utils.js +27 -0
- package/commands/handler/authentication/oauth/utils.d.ts +15 -0
- package/commands/handler/authentication/oauth/utils.js +58 -0
- package/commands/handler/authentication/passcode/function.d.ts +2 -0
- package/commands/handler/authentication/passcode/function.js +22 -0
- package/commands/handler/authentication/passcode/index.d.ts +2 -0
- package/commands/handler/authentication/passcode/index.js +19 -0
- package/commands/handler/authentication/passcode/input.d.ts +2 -0
- package/commands/handler/authentication/passcode/input.js +42 -0
- package/commands/handler/authentication/passcode/setPasscode.d.ts +2 -0
- package/commands/handler/authentication/passcode/setPasscode.js +16 -0
- package/commands/handler/authentication/passcode/types.d.ts +1 -0
- package/commands/handler/authentication/passcode/types.js +2 -0
- package/commands/handler/authentication/technicalJWT/cf.d.ts +4 -0
- package/commands/handler/authentication/technicalJWT/cf.js +133 -0
- package/commands/handler/authentication/technicalJWT/exec.d.ts +9 -0
- package/commands/handler/authentication/technicalJWT/exec.js +196 -0
- package/commands/handler/authentication/technicalJWT/index.d.ts +2 -0
- package/commands/handler/authentication/technicalJWT/index.js +15 -0
- package/commands/handler/authentication/technicalJWT/types.d.ts +2 -0
- package/commands/handler/authentication/technicalJWT/types.js +8 -0
- package/commands/handler/authentication/technicalJWT/utils.d.ts +1 -0
- package/commands/handler/authentication/technicalJWT/utils.js +70 -0
- package/commands/handler/authentication/utils.d.ts +3 -0
- package/commands/handler/authentication/utils.js +8 -0
- package/commands/handler/checkOptionsExistence.d.ts +2 -0
- package/commands/handler/checkOptionsExistence.js +17 -0
- package/commands/handler/error.d.ts +2 -0
- package/commands/handler/error.js +21 -0
- package/commands/handler/fail.d.ts +2 -0
- package/commands/handler/fail.js +10 -0
- package/commands/handler/fetch/fetch.d.ts +2 -0
- package/commands/handler/fetch/fetch.js +83 -0
- package/commands/handler/fetch/index.d.ts +2 -0
- package/commands/handler/fetch/index.js +25 -0
- package/commands/handler/fetch/utils.d.ts +14 -0
- package/commands/handler/fetch/utils.js +152 -0
- package/commands/handler/force.d.ts +2 -0
- package/commands/handler/force.js +35 -0
- package/commands/handler/index.d.ts +18 -0
- package/commands/handler/index.js +39 -0
- package/commands/handler/input/file.d.ts +2 -0
- package/commands/handler/input/file.js +34 -0
- package/commands/handler/input/index.d.ts +2 -0
- package/commands/handler/input/index.js +8 -0
- package/commands/handler/input/input.d.ts +2 -0
- package/commands/handler/input/input.js +44 -0
- package/commands/handler/mandatoryOptions.d.ts +2 -0
- package/commands/handler/mandatoryOptions.js +25 -0
- package/commands/handler/next.d.ts +2 -0
- package/commands/handler/next.js +19 -0
- package/commands/handler/options/env.d.ts +2 -0
- package/commands/handler/options/env.js +18 -0
- package/commands/handler/options/file.d.ts +2 -0
- package/commands/handler/options/file.js +21 -0
- package/commands/handler/options/index.d.ts +7 -0
- package/commands/handler/options/index.js +32 -0
- package/commands/handler/options/option.d.ts +2 -0
- package/commands/handler/options/option.js +20 -0
- package/commands/handler/options/pipe.d.ts +2 -0
- package/commands/handler/options/pipe.js +34 -0
- package/commands/handler/options/utils.d.ts +6 -0
- package/commands/handler/options/utils.js +63 -0
- package/commands/handler/or.d.ts +2 -0
- package/commands/handler/or.js +37 -0
- package/commands/handler/parseArguments.d.ts +4 -0
- package/commands/handler/parseArguments.js +22 -0
- package/commands/handler/resilient.d.ts +2 -0
- package/commands/handler/resilient.js +18 -0
- package/commands/handler/root/index.d.ts +2 -0
- package/commands/handler/root/index.js +18 -0
- package/commands/handler/stackTrace.d.ts +2 -0
- package/commands/handler/stackTrace.js +22 -0
- package/commands/handler/succeed.d.ts +2 -0
- package/commands/handler/succeed.js +9 -0
- package/commands/handler/utils.d.ts +7 -0
- package/commands/handler/utils.js +56 -0
- package/commands/host.command.d.ts +2 -0
- package/commands/host.command.js +68 -0
- package/commands/login.command.d.ts +3 -0
- package/commands/login.command.js +16 -0
- package/commands/logout.command.d.ts +3 -0
- package/commands/logout.command.js +21 -0
- package/commands/openAPI.command/index.d.ts +2 -0
- package/commands/openAPI.command/index.js +102 -0
- package/commands/openAPI.command/utils.d.ts +19 -0
- package/commands/openAPI.command/utils.js +334 -0
- package/commands/passcode.command.d.ts +2 -0
- package/commands/passcode.command.js +26 -0
- package/commands/secrets.command/index.d.ts +3 -0
- package/commands/secrets.command/index.js +13 -0
- package/commands/secrets.command/show.command.d.ts +3 -0
- package/commands/secrets.command/show.command.js +25 -0
- package/config/core.d.ts +10 -0
- package/config/core.js +23 -0
- package/config/index.d.ts +5 -0
- package/config/index.js +90 -0
- package/configureLoggers.d.ts +1 -0
- package/configureLoggers.js +11 -0
- package/constants.d.ts +43 -0
- package/constants.js +175 -0
- package/discovery/index.d.ts +10 -0
- package/discovery/index.js +142 -0
- package/discovery/utils.d.ts +7 -0
- package/discovery/utils.js +27 -0
- package/dwc/dwc.d.ts +10 -0
- package/dwc/dwc.js +180 -0
- package/dwc/run.d.ts +1 -0
- package/dwc/run.js +37 -0
- package/dwc/utils.d.ts +4 -0
- package/dwc/utils.js +37 -0
- package/index.d.ts +16 -0
- package/index.js +59 -0
- package/logger/index.d.ts +28 -0
- package/logger/index.js +63 -0
- package/module.d.ts +4 -0
- package/module.js +45 -0
- package/package.json +32 -0
- package/result/ResultHandlerFactory.d.ts +6 -0
- package/result/ResultHandlerFactory.js +12 -0
- package/result/ResultHandlerImpl.d.ts +6 -0
- package/result/ResultHandlerImpl.js +12 -0
- package/result/types.d.ts +4 -0
- package/result/types.js +2 -0
- package/schemas/discovery.json +347 -0
- package/settings/index.d.ts +4 -0
- package/settings/index.js +34 -0
- package/types.d.ts +182 -0
- package/types.js +67 -0
- package/utils/commands.d.ts +8 -0
- package/utils/commands.js +115 -0
- package/utils/http/index.d.ts +7 -0
- package/utils/http/index.js +69 -0
- package/utils/http/utils.d.ts +7 -0
- package/utils/http/utils.js +47 -0
- package/utils/options.d.ts +3 -0
- package/utils/options.js +25 -0
- package/utils/utils.d.ts +24 -0
- package/utils/utils.js +163 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$async": true,
|
|
3
|
+
"$id": "https://www.sap.com/products/data-warehouse-cloud/cli/schemas/discovery.json",
|
|
4
|
+
"title": "Command-Line Interface Commands",
|
|
5
|
+
"description": "This document describes the schema for the discovery document command-line interfaces.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"openapi": {
|
|
10
|
+
"const": "3.0.3"
|
|
11
|
+
},
|
|
12
|
+
"info": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"properties": {
|
|
16
|
+
"title": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"description": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"contact": {
|
|
23
|
+
"$ref": "#/$defs/reference"
|
|
24
|
+
},
|
|
25
|
+
"license": {
|
|
26
|
+
"$ref": "#/$defs/reference"
|
|
27
|
+
},
|
|
28
|
+
"version": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"pattern": "^[0-9]{1,4}\\.[0-9]{1,2}(\\.[0-9]{1,2})?$"
|
|
31
|
+
},
|
|
32
|
+
"x-document-version": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"pattern": "^[0-9]{1,4}\\.[0-9]{1,2}(\\.[0-9]{1,2})?$"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": [
|
|
38
|
+
"title",
|
|
39
|
+
"description",
|
|
40
|
+
"contact",
|
|
41
|
+
"license",
|
|
42
|
+
"version",
|
|
43
|
+
"x-document-version"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"tags": {
|
|
47
|
+
"type": "array",
|
|
48
|
+
"items": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"properties": {
|
|
52
|
+
"name": {
|
|
53
|
+
"$ref": "#/$defs/lowercaseString"
|
|
54
|
+
},
|
|
55
|
+
"description": {
|
|
56
|
+
"$ref": "#/$defs/text"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": ["name", "description"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"externalDocs": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"additionalProperties": false,
|
|
65
|
+
"properties": {
|
|
66
|
+
"description": {
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"url": {
|
|
70
|
+
"type": "string"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"required": ["description", "url"]
|
|
74
|
+
},
|
|
75
|
+
"paths": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"minProperties": 1,
|
|
78
|
+
"patternProperties": {
|
|
79
|
+
"^[a-z/0-9]*$": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"minProperties": 1,
|
|
82
|
+
"patternProperties": {
|
|
83
|
+
"^(post|put|get|delete|patch|head)$": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"additionalProperties": true,
|
|
86
|
+
"properties": {
|
|
87
|
+
"operationId": {
|
|
88
|
+
"$ref": "#/$defs/lowercaseString"
|
|
89
|
+
},
|
|
90
|
+
"summary": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"description": {
|
|
94
|
+
"type": "string"
|
|
95
|
+
},
|
|
96
|
+
"x-requestbody-fileonly": {
|
|
97
|
+
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"x-user-to-confirm": {
|
|
100
|
+
"type": "string"
|
|
101
|
+
},
|
|
102
|
+
"x-read-command": {
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"parameters": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"items": {
|
|
108
|
+
"$ref": "#/$defs/parameters"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"requestBody": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"additionalProperties": true,
|
|
114
|
+
"properties": {
|
|
115
|
+
"description": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"content": {
|
|
119
|
+
"oneOf": [
|
|
120
|
+
{
|
|
121
|
+
"$ref": "#/$defs/SingleContentType"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"$ref": "#/$defs/MultipleContentTypesIncludingCommands"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"required": ["description", "content", "required"]
|
|
130
|
+
},
|
|
131
|
+
"responses": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"minProperties": 1,
|
|
134
|
+
"patternProperties": {
|
|
135
|
+
"^[2-5][0-9]{2}$": {
|
|
136
|
+
"oneOf": [
|
|
137
|
+
{
|
|
138
|
+
"$ref": "#/$defs/component"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "object",
|
|
142
|
+
"properties": {
|
|
143
|
+
"description": {
|
|
144
|
+
"type": "string"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"required": ["description"]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"required": ["operationId", "responses"]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"components": {
|
|
161
|
+
"type": "object",
|
|
162
|
+
"additionalProperties": false,
|
|
163
|
+
"properties": {
|
|
164
|
+
"schemas": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"patternProperties": {
|
|
167
|
+
".*": {}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"parameters": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"patternProperties": {
|
|
173
|
+
".*": {
|
|
174
|
+
"$ref": "#/$defs/parameters"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"required": [
|
|
182
|
+
"openapi",
|
|
183
|
+
"info",
|
|
184
|
+
"tags",
|
|
185
|
+
"externalDocs",
|
|
186
|
+
"paths",
|
|
187
|
+
"components"
|
|
188
|
+
],
|
|
189
|
+
"$defs": {
|
|
190
|
+
"SingleContentType": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"additionalProperties": true,
|
|
193
|
+
"minProperties": 1,
|
|
194
|
+
"maxProperties": 1,
|
|
195
|
+
"patternProperties": {
|
|
196
|
+
"^application/[a-z.+;=0-9]*": {
|
|
197
|
+
"type": "object",
|
|
198
|
+
"additionalProperties": false,
|
|
199
|
+
"properties": {
|
|
200
|
+
"schema": {
|
|
201
|
+
"type": "object",
|
|
202
|
+
"additionalProperties": false,
|
|
203
|
+
"properties": {
|
|
204
|
+
"$ref": {
|
|
205
|
+
"type": "string"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"required": ["$ref"]
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"required": ["schema"]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"MultipleContentTypesIncludingCommands": {
|
|
216
|
+
"type": "object",
|
|
217
|
+
"additionalProperties": true,
|
|
218
|
+
"minProperties": 1,
|
|
219
|
+
"patternProperties": {
|
|
220
|
+
"^application/[a-z.+;=0-9]*": {
|
|
221
|
+
"type": "object",
|
|
222
|
+
"additionalProperties": false,
|
|
223
|
+
"properties": {
|
|
224
|
+
"x-command": {
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
227
|
+
"schema": {
|
|
228
|
+
"type": "object",
|
|
229
|
+
"additionalProperties": false,
|
|
230
|
+
"properties": {
|
|
231
|
+
"$ref": {
|
|
232
|
+
"type": "string"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"required": ["$ref"]
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"required": ["schema", "x-command"]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"parameters": {
|
|
243
|
+
"oneOf": [
|
|
244
|
+
{
|
|
245
|
+
"$ref": "#/$defs/component"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"$ref": "#/$defs/parameter"
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"parameter": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"properties": {
|
|
255
|
+
"name": {
|
|
256
|
+
"type": "string"
|
|
257
|
+
},
|
|
258
|
+
"in": {
|
|
259
|
+
"type": "string",
|
|
260
|
+
"enum": ["query", "header", "path"]
|
|
261
|
+
},
|
|
262
|
+
"description": {
|
|
263
|
+
"type": "string"
|
|
264
|
+
},
|
|
265
|
+
"required": {
|
|
266
|
+
"type": "boolean"
|
|
267
|
+
},
|
|
268
|
+
"allowEmptyValue": {
|
|
269
|
+
"type": "boolean"
|
|
270
|
+
},
|
|
271
|
+
"schema": {
|
|
272
|
+
"oneOf": [
|
|
273
|
+
{
|
|
274
|
+
"$ref": "#/$defs/component"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"type": "object",
|
|
278
|
+
"additionalProperties": false,
|
|
279
|
+
"properties": {
|
|
280
|
+
"oneOf": {
|
|
281
|
+
"type": "array",
|
|
282
|
+
"minItems": 1,
|
|
283
|
+
"maxItems": 2,
|
|
284
|
+
"items": {
|
|
285
|
+
"oneOf": [
|
|
286
|
+
{
|
|
287
|
+
"$ref": "#/$defs/component"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"$ref": "#/$defs/scalarType"
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"required": ["oneOf"]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"$ref": "#/$defs/scalarType"
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"required": ["name", "in", "description", "schema"]
|
|
305
|
+
},
|
|
306
|
+
"scalarType": {
|
|
307
|
+
"type": "object",
|
|
308
|
+
"properties": {
|
|
309
|
+
"type": {
|
|
310
|
+
"type": "string",
|
|
311
|
+
"enum": ["boolean", "string", "number"]
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
"required": ["type"]
|
|
315
|
+
},
|
|
316
|
+
"component": {
|
|
317
|
+
"type": "object",
|
|
318
|
+
"properties": {
|
|
319
|
+
"$ref": {
|
|
320
|
+
"type": "string"
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"required": ["$ref"]
|
|
324
|
+
},
|
|
325
|
+
"text": {
|
|
326
|
+
"type": "string",
|
|
327
|
+
"pattern": "^[a-zA-Z\\s]*$"
|
|
328
|
+
},
|
|
329
|
+
"lowercaseString": {
|
|
330
|
+
"type": "string",
|
|
331
|
+
"pattern": "^[a-z\\s-]*$"
|
|
332
|
+
},
|
|
333
|
+
"reference": {
|
|
334
|
+
"type": "object",
|
|
335
|
+
"additionalProperties": false,
|
|
336
|
+
"properties": {
|
|
337
|
+
"name": {
|
|
338
|
+
"type": "string"
|
|
339
|
+
},
|
|
340
|
+
"url": {
|
|
341
|
+
"type": "string"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"required": ["name", "url"]
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remove = exports.set = exports.get = void 0;
|
|
4
|
+
const cache_1 = require("../cache");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const SETTINGS_FILE = "settings.json";
|
|
7
|
+
const getLogger = () => (0, logger_1.get)("settings");
|
|
8
|
+
const get = async () => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(await (0, cache_1.readFile)(SETTINGS_FILE));
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
const { debug } = getLogger();
|
|
14
|
+
debug("failed to read settings file", err);
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.get = get;
|
|
19
|
+
const set = async (key, value) => {
|
|
20
|
+
const settings = await (0, exports.get)();
|
|
21
|
+
settings[key] = value;
|
|
22
|
+
await (0, cache_1.writeFile)(SETTINGS_FILE, JSON.stringify(settings));
|
|
23
|
+
const { debug } = getLogger();
|
|
24
|
+
debug(`updated key ${key}, value ${value}`);
|
|
25
|
+
};
|
|
26
|
+
exports.set = set;
|
|
27
|
+
const remove = async (key) => {
|
|
28
|
+
const settings = await (0, exports.get)();
|
|
29
|
+
delete settings[key];
|
|
30
|
+
await (0, cache_1.writeFile)(SETTINGS_FILE, JSON.stringify(settings));
|
|
31
|
+
const { debug } = getLogger();
|
|
32
|
+
debug(`removed key ${key}`);
|
|
33
|
+
};
|
|
34
|
+
exports.remove = remove;
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Method as HTTPMethod, AxiosRequestConfig as HTTPConfig, AxiosResponse as HTTPResponse } from "axios";
|
|
2
|
+
import { Command as CommandType } from "commander";
|
|
3
|
+
export type Secrets = {
|
|
4
|
+
client_id: string;
|
|
5
|
+
client_secret: string;
|
|
6
|
+
access_token: string;
|
|
7
|
+
expires_in: number;
|
|
8
|
+
expires_after: number;
|
|
9
|
+
refresh_token: string;
|
|
10
|
+
token_url: string;
|
|
11
|
+
authorization_url: string;
|
|
12
|
+
token_type: string;
|
|
13
|
+
jti: string;
|
|
14
|
+
scope: string;
|
|
15
|
+
id_token: string;
|
|
16
|
+
};
|
|
17
|
+
export { HTTPMethod, HTTPConfig, HTTPResponse };
|
|
18
|
+
export type In = "query" | "body" | "header" | "path";
|
|
19
|
+
export type DataType = "boolean" | "string" | "number";
|
|
20
|
+
export type ParameterMapping = {
|
|
21
|
+
name: string;
|
|
22
|
+
in: In;
|
|
23
|
+
source: {
|
|
24
|
+
type: "option";
|
|
25
|
+
name: string;
|
|
26
|
+
dataType: DataType;
|
|
27
|
+
} | {
|
|
28
|
+
type: "value";
|
|
29
|
+
value: any;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type ParameterMappings = Array<ParameterMapping>;
|
|
33
|
+
export declare enum LogLevel {
|
|
34
|
+
INACTIVE = 1,
|
|
35
|
+
ERROR = 2,
|
|
36
|
+
WARN = 3,
|
|
37
|
+
INFO = 4,
|
|
38
|
+
DEBUG = 5,
|
|
39
|
+
TRACE = 6
|
|
40
|
+
}
|
|
41
|
+
export type JSONOneOf<T> = {
|
|
42
|
+
oneOf: Array<T | JSONReference>;
|
|
43
|
+
};
|
|
44
|
+
export type JSONObject = {
|
|
45
|
+
type: "object";
|
|
46
|
+
description?: string;
|
|
47
|
+
properties: {
|
|
48
|
+
[key: string]: JSONSchema;
|
|
49
|
+
};
|
|
50
|
+
required?: Array<string>;
|
|
51
|
+
};
|
|
52
|
+
export type JSONSimpleType = {
|
|
53
|
+
type: DataType;
|
|
54
|
+
description?: string;
|
|
55
|
+
enum?: Array<boolean | string | number>;
|
|
56
|
+
default?: boolean | string | number;
|
|
57
|
+
};
|
|
58
|
+
export type JSONReference = {
|
|
59
|
+
$ref: string;
|
|
60
|
+
};
|
|
61
|
+
// @ts-expect-error Type alias 'Schema' circularly references itself.ts(2456)
|
|
62
|
+
export type JSONSchema = JSONObject | JSONSimpleType | JSONReference | JSONOneOf<JSONSchema>;
|
|
63
|
+
export type Parameter = {
|
|
64
|
+
name: string;
|
|
65
|
+
in: In;
|
|
66
|
+
description: string;
|
|
67
|
+
required?: boolean;
|
|
68
|
+
allowEmptyValue?: boolean;
|
|
69
|
+
schema: JSONSchema;
|
|
70
|
+
};
|
|
71
|
+
export type Operation = {
|
|
72
|
+
operationId: string;
|
|
73
|
+
parameters?: Array<JSONReference | Parameter>;
|
|
74
|
+
summary?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
"x-requestbody-fileonly"?: boolean;
|
|
77
|
+
"x-user-to-confirm"?: string;
|
|
78
|
+
"x-read-path"?: string;
|
|
79
|
+
requestBody?: {
|
|
80
|
+
description: string;
|
|
81
|
+
content: {
|
|
82
|
+
[contentType: string]: {
|
|
83
|
+
schema: JSONSchema | JSONReference;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
required?: boolean;
|
|
87
|
+
};
|
|
88
|
+
responses?: {
|
|
89
|
+
[httpStatusCode: number]: unknown;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type HTTPMethodPath = {
|
|
93
|
+
[method in HTTPMethod]?: Operation;
|
|
94
|
+
};
|
|
95
|
+
export type Parameters = Array<Parameter | JSONReference>;
|
|
96
|
+
export type ParameterPath = {
|
|
97
|
+
parameters?: Parameters;
|
|
98
|
+
};
|
|
99
|
+
export type Discovery = {
|
|
100
|
+
openapi: string;
|
|
101
|
+
info: {
|
|
102
|
+
["x-document-version"]: string;
|
|
103
|
+
version: string;
|
|
104
|
+
};
|
|
105
|
+
tags: Array<{
|
|
106
|
+
name: string;
|
|
107
|
+
description: string;
|
|
108
|
+
}>;
|
|
109
|
+
paths: {
|
|
110
|
+
[path: string]: HTTPMethodPath | ParameterPath;
|
|
111
|
+
};
|
|
112
|
+
components?: {
|
|
113
|
+
parameters?: {
|
|
114
|
+
[parameter: string]: Parameter;
|
|
115
|
+
};
|
|
116
|
+
schemas?: {
|
|
117
|
+
[schema: string]: JSONSchema;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export declare const CHARACTERS: string[];
|
|
122
|
+
export type PackageJson = {
|
|
123
|
+
name: string;
|
|
124
|
+
description: string;
|
|
125
|
+
version: string;
|
|
126
|
+
bin?: {
|
|
127
|
+
[key: string]: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export type DiscoveryMetadata = {
|
|
131
|
+
tenant: string;
|
|
132
|
+
addedAt: number;
|
|
133
|
+
};
|
|
134
|
+
export type KeyValuePair = {
|
|
135
|
+
[key: string]: any;
|
|
136
|
+
};
|
|
137
|
+
export type Option = {
|
|
138
|
+
longName: string;
|
|
139
|
+
description: string;
|
|
140
|
+
default?: string;
|
|
141
|
+
required?: boolean;
|
|
142
|
+
choices?: Array<string>;
|
|
143
|
+
args?: Array<{
|
|
144
|
+
name: string;
|
|
145
|
+
optional?: boolean;
|
|
146
|
+
}>;
|
|
147
|
+
prompts?: {
|
|
148
|
+
initial?: any;
|
|
149
|
+
message: string | (() => string);
|
|
150
|
+
type: "confirm" | "text" | "password" | "multiselect" | "number" | "select";
|
|
151
|
+
inputValidator?: (value: any) => boolean;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
export type HandlerProps = {
|
|
155
|
+
command: string;
|
|
156
|
+
args: KeyValuePair;
|
|
157
|
+
options: KeyValuePair;
|
|
158
|
+
};
|
|
159
|
+
export type CommanderHandler = (...args: any[]) => void | Promise<void>;
|
|
160
|
+
export type Handler = (command: CommandType) => CommanderHandler;
|
|
161
|
+
export type CommandsArgument = {
|
|
162
|
+
argument: string;
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
export type TopCommand = {
|
|
166
|
+
type: "topCommand";
|
|
167
|
+
command: string;
|
|
168
|
+
description: string;
|
|
169
|
+
subCommands: Array<Command>;
|
|
170
|
+
options?: Array<Option>;
|
|
171
|
+
};
|
|
172
|
+
export type LeafCommand = {
|
|
173
|
+
type: "command";
|
|
174
|
+
command: string;
|
|
175
|
+
description: string;
|
|
176
|
+
options?: Array<Option>;
|
|
177
|
+
args?: Array<CommandsArgument>;
|
|
178
|
+
handler: Handler;
|
|
179
|
+
};
|
|
180
|
+
export type Command = TopCommand | LeafCommand;
|
|
181
|
+
export type AddCommands = (program: CommandType) => Promise<void>;
|
|
182
|
+
export type ResponsePostProcessor = (response: HTTPResponse) => Promise<void>;
|
package/types.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CHARACTERS = exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel[LogLevel["INACTIVE"] = 1] = "INACTIVE";
|
|
7
|
+
LogLevel[LogLevel["ERROR"] = 2] = "ERROR";
|
|
8
|
+
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
|
9
|
+
LogLevel[LogLevel["INFO"] = 4] = "INFO";
|
|
10
|
+
LogLevel[LogLevel["DEBUG"] = 5] = "DEBUG";
|
|
11
|
+
LogLevel[LogLevel["TRACE"] = 6] = "TRACE";
|
|
12
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
13
|
+
/* jscpd:ignore-start */
|
|
14
|
+
exports.CHARACTERS = [
|
|
15
|
+
"a",
|
|
16
|
+
"b",
|
|
17
|
+
"c",
|
|
18
|
+
"d",
|
|
19
|
+
"e",
|
|
20
|
+
"f",
|
|
21
|
+
"g",
|
|
22
|
+
"h",
|
|
23
|
+
"i",
|
|
24
|
+
"j",
|
|
25
|
+
"k",
|
|
26
|
+
"l",
|
|
27
|
+
"m",
|
|
28
|
+
"n",
|
|
29
|
+
"o",
|
|
30
|
+
"p",
|
|
31
|
+
"q",
|
|
32
|
+
"r",
|
|
33
|
+
"s",
|
|
34
|
+
"t",
|
|
35
|
+
"u",
|
|
36
|
+
"v",
|
|
37
|
+
"w",
|
|
38
|
+
"x",
|
|
39
|
+
"y",
|
|
40
|
+
"z",
|
|
41
|
+
"A",
|
|
42
|
+
"B",
|
|
43
|
+
"C",
|
|
44
|
+
"D",
|
|
45
|
+
"E",
|
|
46
|
+
"F",
|
|
47
|
+
"G",
|
|
48
|
+
"H",
|
|
49
|
+
"I",
|
|
50
|
+
"J",
|
|
51
|
+
"K",
|
|
52
|
+
"L",
|
|
53
|
+
"M",
|
|
54
|
+
"N",
|
|
55
|
+
"O",
|
|
56
|
+
"P",
|
|
57
|
+
"Q",
|
|
58
|
+
"R",
|
|
59
|
+
"S",
|
|
60
|
+
"T",
|
|
61
|
+
"U",
|
|
62
|
+
"V",
|
|
63
|
+
"W",
|
|
64
|
+
"X",
|
|
65
|
+
"Y",
|
|
66
|
+
"Z",
|
|
67
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import commander, { Command, Option } from "commander";
|
|
2
|
+
import { Command as CommandType, Option as OptionType } from "../types";
|
|
3
|
+
export declare const createCommand: (name?: string) => Command;
|
|
4
|
+
export declare const getShortFlagForLongName: (longName: string) => string;
|
|
5
|
+
export declare const isOptionAlreadyRegistered: ({ longName }: OptionType, command: Command) => boolean;
|
|
6
|
+
export declare const registerLongName: (longName: string) => string;
|
|
7
|
+
export declare const buildOption: ({ longName, description, choices, required, default: defaultValue, args, }: OptionType) => Option;
|
|
8
|
+
export declare const buildCommand: (topCommand: commander.Command, command: CommandType) => void;
|