swaggerhub-cli 0.13.0 → 0.15.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/README.md +209 -122
- package/bin/run +5 -4
- package/oclif.manifest.json +283 -122
- package/package.json +14 -12
- package/src/check-node-version.js +3 -2
- package/src/commands/api/clone.js +66 -0
- package/src/commands/api/create.js +10 -10
- package/src/commands/api/delete.js +7 -7
- package/src/commands/api/get.js +9 -9
- package/src/commands/api/publish.js +7 -7
- package/src/commands/api/rename.js +8 -10
- package/src/commands/api/setdefault.js +6 -6
- package/src/commands/api/unpublish.js +5 -5
- package/src/commands/api/update.js +11 -11
- package/src/commands/api/validate/download-rules.js +11 -11
- package/src/commands/api/validate/index.js +10 -10
- package/src/commands/api/validate/local.js +11 -11
- package/src/commands/configure.js +8 -8
- package/src/commands/domain/clone.js +66 -0
- package/src/commands/domain/create.js +14 -14
- package/src/commands/domain/delete.js +7 -7
- package/src/commands/domain/get.js +8 -8
- package/src/commands/domain/publish.js +6 -6
- package/src/commands/domain/rename.js +78 -0
- package/src/commands/domain/setdefault.js +6 -6
- package/src/commands/domain/unpublish.js +6 -6
- package/src/commands/domain/update.js +11 -11
- package/src/commands/integration/create.js +7 -7
- package/src/commands/integration/delete.js +6 -6
- package/src/commands/integration/execute.js +6 -6
- package/src/commands/integration/get.js +9 -9
- package/src/commands/integration/list.js +7 -7
- package/src/commands/integration/update.js +6 -6
- package/src/commands/project/api/add.js +7 -9
- package/src/commands/project/api/remove.js +10 -13
- package/src/commands/project/create.js +9 -13
- package/src/commands/project/delete.js +7 -7
- package/src/commands/project/domain/add.js +7 -9
- package/src/commands/project/domain/remove.js +10 -13
- package/src/commands/project/get.js +8 -8
- package/src/commands/project/list.js +6 -6
- package/src/commands/project/member/list.js +8 -8
- package/src/commands/spectral/download.js +9 -9
- package/src/commands/spectral/upload.js +11 -11
- package/src/config/index.js +18 -4
- package/src/format-readme.js +3 -2
- package/src/help.js +2 -2
- package/src/hooks/setup-config.js +9 -5
- package/src/index.js +2 -2
- package/src/requests/api.js +3 -3
- package/src/requests/domain.js +3 -3
- package/src/requests/project.js +2 -2
- package/src/requests/spec.js +5 -5
- package/src/requests/spectral.js +3 -3
- package/src/requests/standardization.js +4 -4
- package/src/support/command/base-command.js +11 -12
- package/src/support/command/base-validate-command.js +3 -3
- package/src/support/command/handle-response.js +7 -5
- package/src/support/command/parse-input.js +8 -6
- package/src/support/command/update-command.js +5 -5
- package/src/support/http/default-headers.js +1 -1
- package/src/support/http/header-templates.js +2 -2
- package/src/support/http/index.js +7 -7
- package/src/support/http/proxy-agent.js +4 -4
- package/src/support/inquirer/index.js +4 -4
- package/src/support/inquirer/prompt-templates.js +3 -3
- package/src/support/isOnPrem.js +3 -3
- package/src/template-strings/errors.js +6 -6
- package/src/template-strings/index.js +3 -3
- package/src/template-strings/info.js +10 -4
- package/src/utils/definitions.js +8 -6
- package/src/utils/general.js +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const accept = {
|
|
4
4
|
'Accept': 'application/{{accept}}'
|
|
@@ -12,7 +12,7 @@ const contentType = {
|
|
|
12
12
|
'Content-Type': 'application/{{contentType}}'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export default wrapTemplates({
|
|
16
16
|
accept,
|
|
17
17
|
auth,
|
|
18
18
|
contentType
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fetch from 'node-fetch'
|
|
2
|
+
import qs from 'querystring'
|
|
3
|
+
import headerTemplates from './header-templates.js'
|
|
4
|
+
import defaultHeaders from './default-headers.js'
|
|
5
|
+
import { agentFor } from './proxy-agent.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { pipe, pick, omit } from '../../utils/general.js'
|
|
8
8
|
|
|
9
9
|
const buildHeaders = options => Object.keys(options)
|
|
10
10
|
.reduce((obj, key) => ({
|
|
@@ -37,6 +37,6 @@ const parseHeaders = options => {
|
|
|
37
37
|
|
|
38
38
|
const request = ({ url, ...options }) => fetch(url, { agent: agentFor, ...options })
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export default options => (
|
|
41
41
|
pipe(parseQuery, parseUrl, parseHeaders, request)(options)
|
|
42
42
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getProxyForUrl } from 'proxy-from-env'
|
|
2
|
+
import { HttpsProxyAgent } from 'https-proxy-agent'
|
|
3
|
+
import { HttpProxyAgent } from 'http-proxy-agent'
|
|
4
4
|
|
|
5
5
|
const normalizeProxy = proxy => {
|
|
6
6
|
try {
|
|
@@ -22,4 +22,4 @@ const agentFor = parsedUrl => {
|
|
|
22
22
|
new HttpProxyAgent(proxyUrl)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
export { agentFor }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import promptTemplates from './prompt-templates.js'
|
|
2
2
|
|
|
3
|
-
const getPrompts = prompts => (
|
|
4
|
-
(options = {}) => prompts.map(p =>
|
|
3
|
+
const getPrompts = (prompts, templates = promptTemplates) => (
|
|
4
|
+
(options = {}) => prompts.map(p => templates[p](options))
|
|
5
5
|
)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export {
|
|
8
8
|
getPrompts
|
|
9
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const swaggerHubUrl = {
|
|
4
4
|
name: 'SWAGGERHUB_URL',
|
|
5
|
-
message: '
|
|
5
|
+
message: 'Swagger URL:',
|
|
6
6
|
default: '{{SWAGGERHUB_URL}}'
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ const apiKey = {
|
|
|
12
12
|
default: '{{SWAGGERHUB_API_KEY}}'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export default wrapTemplates({
|
|
16
16
|
swaggerHubUrl,
|
|
17
17
|
apiKey
|
|
18
18
|
})
|
package/src/support/isOnPrem.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { getConfig } from '../config/index.js'
|
|
2
2
|
|
|
3
3
|
const isOnPrem = () => {
|
|
4
4
|
const { SWAGGERHUB_URL } = getConfig()
|
|
5
5
|
return !SWAGGERHUB_URL.endsWith('swaggerhub.com')
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export {
|
|
9
9
|
isOnPrem
|
|
10
|
-
}
|
|
10
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const errorMsg = {
|
|
4
|
-
ApiCreate: 'API version \'{{owner}}/{{name}}/{{version}}\' already exists in
|
|
4
|
+
ApiCreate: 'API version \'{{owner}}/{{name}}/{{version}}\' already exists in Swagger',
|
|
5
5
|
|
|
6
|
-
DomainCreate: 'Domain version \'{{owner}}/{{name}}/{{version}}\' already exists in
|
|
6
|
+
DomainCreate: 'Domain version \'{{owner}}/{{name}}/{{version}}\' already exists in Swagger',
|
|
7
7
|
|
|
8
8
|
Configure: 'Failed to write config to {{configFilePath}}',
|
|
9
9
|
|
|
10
10
|
argsMustMatchFormat: 'Argument must match {{format}} format',
|
|
11
11
|
|
|
12
|
-
cannotParseDefinition: 'There was a problem
|
|
12
|
+
cannotParseDefinition: 'There was a problem parsing {{filename}}. \nReason: {{e}}',
|
|
13
13
|
|
|
14
14
|
cannotParseSpecification: 'Cannot determine specification from file',
|
|
15
15
|
|
|
@@ -25,9 +25,9 @@ const errorMsg = {
|
|
|
25
25
|
|
|
26
26
|
directoryExists: 'Directory already exists: \'{{directory}}\'',
|
|
27
27
|
|
|
28
|
-
unknown: 'Unknown
|
|
28
|
+
unknown: 'Unknown error',
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
export default wrapTemplates({
|
|
32
32
|
...errorMsg
|
|
33
33
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const infoMsg = {
|
|
4
4
|
ApiCreate: 'Created API \'{{owner}}/{{name}}\'',
|
|
@@ -7,6 +7,12 @@ const infoMsg = {
|
|
|
7
7
|
|
|
8
8
|
ApiRename: 'Renamed API \'{{apiPath}}\' to \'{{newName}}\'',
|
|
9
9
|
|
|
10
|
+
ApiClone: 'Cloned API \'{{apiPath}}\' as version {{newVersion}}',
|
|
11
|
+
|
|
12
|
+
DomainClone: 'Cloned domain \'{{domainPath}}\' as version {{newVersion}}',
|
|
13
|
+
|
|
14
|
+
DomainRename: 'Renamed domain \'{{domainPath}}\' to \'{{newName}}\'',
|
|
15
|
+
|
|
10
16
|
DomainCreate: 'Created domain \'{{owner}}/{{name}}\'',
|
|
11
17
|
|
|
12
18
|
DomainDelete: 'Deleted domain \'{{owner}}/{{name}}\'',
|
|
@@ -51,9 +57,9 @@ const infoMsg = {
|
|
|
51
57
|
|
|
52
58
|
ProjectUpdate: 'Updated project \'{{owner}}/{{projectName}}\'',
|
|
53
59
|
|
|
54
|
-
ProjectApiAdd: 'Added
|
|
60
|
+
ProjectApiAdd: 'Added API \'{{apiName}}\' to project \'{{projectPath}}\'',
|
|
55
61
|
|
|
56
|
-
ProjectApiRemove: 'Removed
|
|
62
|
+
ProjectApiRemove: 'Removed API \'{{apiName}}\' from project \'{{projectPath}}\'',
|
|
57
63
|
|
|
58
64
|
ProjectDomainAdd: 'Added domain \'{{domainName}}\' to project \'{{projectPath}}\'',
|
|
59
65
|
|
|
@@ -63,6 +69,6 @@ const infoMsg = {
|
|
|
63
69
|
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
export default wrapTemplates({
|
|
67
73
|
...infoMsg
|
|
68
74
|
})
|
package/src/utils/definitions.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Errors } from '@oclif/core'
|
|
2
|
+
import { hasJsonStructure } from './general.js'
|
|
3
|
+
import * as yaml from 'js-yaml'
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
+
import { errorMsg } from '../template-strings/index.js'
|
|
6
|
+
|
|
7
|
+
const { CLIError } = Errors
|
|
6
8
|
|
|
7
9
|
const specVersionToSpecification = specVersion => {
|
|
8
10
|
if (/2.0$/.test(specVersion))
|
|
@@ -44,7 +46,7 @@ const parseDefinition = filename => {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
export {
|
|
48
50
|
getSpecification,
|
|
49
51
|
getVersion,
|
|
50
52
|
parseDefinition,
|
package/src/utils/general.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import deepExtend from 'deep-extend'
|
|
2
|
+
import jsonTemplate from 'json-templates'
|
|
3
3
|
|
|
4
4
|
const pick = (object, keys) => {
|
|
5
5
|
const newObject = {}
|
|
@@ -64,7 +64,7 @@ const prettyPrintJSON = str => {
|
|
|
64
64
|
return JSON.stringify(result, null, 2)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
export {
|
|
68
68
|
hasJsonStructure,
|
|
69
69
|
prettyPrintJSON,
|
|
70
70
|
isError,
|