swaggerhub-cli 0.6.4 → 0.7.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 +535 -291
- package/bin/run +3 -3
- package/oclif.manifest.json +1165 -1
- package/package.json +19 -26
- package/src/commands/api/create.js +12 -11
- package/src/commands/api/delete.js +9 -8
- package/src/commands/api/get.js +10 -9
- package/src/commands/api/publish.js +12 -9
- package/src/commands/api/setdefault.js +8 -6
- package/src/commands/api/unpublish.js +8 -6
- package/src/commands/api/update.js +12 -11
- package/src/commands/api/validate.js +41 -12
- package/src/commands/domain/create.js +12 -11
- package/src/commands/domain/delete.js +9 -8
- package/src/commands/domain/get.js +9 -8
- package/src/commands/domain/publish.js +8 -6
- package/src/commands/domain/setdefault.js +8 -6
- package/src/commands/domain/unpublish.js +8 -6
- package/src/commands/domain/update.js +12 -11
- package/src/commands/integration/create.js +10 -9
- package/src/commands/integration/delete.js +8 -6
- package/src/commands/integration/execute.js +8 -6
- package/src/commands/integration/get.js +8 -6
- package/src/commands/integration/list.js +11 -10
- package/src/commands/integration/update.js +9 -8
- package/src/commands/project/api/add.js +10 -12
- package/src/commands/project/api/remove.js +10 -11
- package/src/commands/project/create.js +11 -10
- package/src/commands/project/delete.js +8 -6
- package/src/commands/project/domain/add.js +10 -12
- package/src/commands/project/domain/remove.js +10 -11
- package/src/commands/project/get.js +8 -6
- package/src/commands/project/list.js +10 -9
- package/src/commands/project/member/list.js +10 -9
- package/src/config/index.js +1 -2
- package/src/help.js +1 -1
- package/src/index.js +2 -1
- package/src/support/command/base-command.js +2 -2
- package/src/support/command/handle-response.js +1 -1
- package/src/support/command/parse-input.js +1 -1
- package/src/support/command/update-command.js +1 -1
- package/src/support/http/index.js +1 -3
- package/src/support/isOnPrem.js +10 -0
- package/src/utils/definitions.js +4 -2
- package/src/utils/general.js +29 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { ux, Args } = require('@oclif/core')
|
|
2
2
|
const { getProject } = require('../../requests/project')
|
|
3
3
|
const { getResponseContent } = require('../../support/command/handle-response')
|
|
4
4
|
const BaseCommand = require('../../support/command/base-command')
|
|
@@ -10,7 +10,7 @@ class ListProjectCommand extends BaseCommand {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async run() {
|
|
13
|
-
const { args } = this.parse(ListProjectCommand)
|
|
13
|
+
const { args } = await this.parse(ListProjectCommand)
|
|
14
14
|
await this.listProjects(args['OWNER'])
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ class ListProjectCommand extends BaseCommand {
|
|
|
19
19
|
if (responseObj.projects.length === 0){
|
|
20
20
|
this.log('No projects found.')
|
|
21
21
|
} else {
|
|
22
|
-
|
|
22
|
+
ux.table(responseObj.projects, {
|
|
23
23
|
name: {},
|
|
24
24
|
owner: {},
|
|
25
25
|
description: {},
|
|
@@ -28,7 +28,7 @@ class ListProjectCommand extends BaseCommand {
|
|
|
28
28
|
},
|
|
29
29
|
domains: {}
|
|
30
30
|
}, {
|
|
31
|
-
printLine: this.log
|
|
31
|
+
printLine: this.log.bind(this)
|
|
32
32
|
})
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -49,11 +49,12 @@ ListProjectCommand.examples = [
|
|
|
49
49
|
'swaggerhub project:list organization'
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
-
ListProjectCommand.args =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
52
|
+
ListProjectCommand.args = {
|
|
53
|
+
'OWNER': Args.string({
|
|
54
|
+
required: false,
|
|
55
|
+
description: 'The organization to list projects for on Swaggerhub'
|
|
56
|
+
})
|
|
57
|
+
}
|
|
57
58
|
|
|
58
59
|
ListProjectCommand.flags = {
|
|
59
60
|
...BaseCommand.flags
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
const { ux, Args } = require('@oclif/core')
|
|
1
2
|
const { getProject } = require('../../../requests/project')
|
|
2
3
|
const { getResponseContent } = require('../../../support/command/handle-response')
|
|
3
4
|
const BaseCommand = require('../../../support/command/base-command')
|
|
4
5
|
const { getProjectIdentifierArg } = require('../../../support/command/parse-input')
|
|
5
|
-
const { cli } = require('cli-ux')
|
|
6
6
|
|
|
7
7
|
class ListProjectMembersCommand extends BaseCommand {
|
|
8
8
|
constructor(...props) {
|
|
@@ -11,7 +11,7 @@ class ListProjectMembersCommand extends BaseCommand {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async run() {
|
|
14
|
-
const { args } = this.parse(ListProjectMembersCommand)
|
|
14
|
+
const { args } = await this.parse(ListProjectMembersCommand)
|
|
15
15
|
const projectPath = getProjectIdentifierArg(args)
|
|
16
16
|
await this.getProjectMembers(projectPath)
|
|
17
17
|
}
|
|
@@ -21,13 +21,13 @@ class ListProjectMembersCommand extends BaseCommand {
|
|
|
21
21
|
if (responseObj.members.length === 0){
|
|
22
22
|
this.log('No members found.')
|
|
23
23
|
} else {
|
|
24
|
-
|
|
24
|
+
ux.table(responseObj.members, {
|
|
25
25
|
name: {
|
|
26
26
|
minWidth: 24
|
|
27
27
|
},
|
|
28
28
|
type: {}
|
|
29
29
|
}, {
|
|
30
|
-
printLine: this.log
|
|
30
|
+
printLine: this.log.bind(this)
|
|
31
31
|
})
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -47,11 +47,12 @@ ListProjectMembersCommand.examples = [
|
|
|
47
47
|
'swaggerhub project:member:list organisation/project_name',
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
ListProjectMembersCommand.args =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
50
|
+
ListProjectMembersCommand.args = {
|
|
51
|
+
'OWNER/PROJECT_NAME': Args.string({
|
|
52
|
+
required: true,
|
|
53
|
+
description: 'Project to list members of on Swaggerhub'
|
|
54
|
+
})
|
|
55
|
+
}
|
|
55
56
|
|
|
56
57
|
ListProjectMembersCommand.flags = {
|
|
57
58
|
...BaseCommand.flags
|
package/src/config/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fse = require('fs-extra') // We're not using {readSyncJSON, ...} expansion, since we want to mock it.
|
|
2
|
-
const { mergeDeep } = require('../utils/general')
|
|
3
|
-
const pick = require('lodash/pick')
|
|
2
|
+
const { mergeDeep, pick } = require('../utils/general')
|
|
4
3
|
|
|
5
4
|
const swaggerhubUrlRegex = new RegExp(/^https?:\/\/api\..*swaggerhub\.com$/)
|
|
6
5
|
const environmentalKeys = ['SWAGGERHUB_URL', 'SWAGGERHUB_API_KEY']
|
package/src/help.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const { run } = require('@oclif/core')
|
|
2
|
+
module.exports = { run }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Command,
|
|
1
|
+
const { Command, Flags } = require('@oclif/core')
|
|
2
2
|
const { capitalise, pipeAsync } = require('../../utils/general')
|
|
3
3
|
const { infoMsg, errorMsg } = require('../../template-strings')
|
|
4
4
|
const { getApi } = require('../../requests/api')
|
|
@@ -85,7 +85,7 @@ class BaseCommand extends Command {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
BaseCommand.flags = {
|
|
88
|
-
help:
|
|
88
|
+
help: Flags.help({ char: 'h' })
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
module.exports = BaseCommand
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { existsSync, readFileSync } = require('fs-extra')
|
|
2
2
|
const { hasJsonStructure } = require('../../utils/general')
|
|
3
|
-
const { CLIError } = require('@oclif/
|
|
3
|
+
const { CLIError } = require('@oclif/core').Errors
|
|
4
4
|
const { errorMsg } = require('../../template-strings')
|
|
5
5
|
|
|
6
6
|
const optionalVersionRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+(\/[\w\-.]+)?(\/?)$/)
|
|
@@ -15,7 +15,7 @@ class UpdateCommand extends BaseCommand {
|
|
|
15
15
|
type: type === 'apis' ? 'API' : 'domain',
|
|
16
16
|
path: `${owner}/${name}/${version}`
|
|
17
17
|
}),
|
|
18
|
-
onReject: async
|
|
18
|
+
onReject: async err => {
|
|
19
19
|
if (err.status === 424 && type === 'apis') {
|
|
20
20
|
if (await this.confirmPublish() === true) {
|
|
21
21
|
this.executeHttp({
|
|
@@ -3,9 +3,7 @@ const qs = require('querystring')
|
|
|
3
3
|
const headerTemplates = require('./header-templates')
|
|
4
4
|
const defaultHeaders = require('./default-headers')
|
|
5
5
|
|
|
6
|
-
const { pipe } = require('../../utils/general')
|
|
7
|
-
const pick = require('lodash/pick')
|
|
8
|
-
const omit = require('lodash/omit')
|
|
6
|
+
const { pipe, pick, omit } = require('../../utils/general')
|
|
9
7
|
|
|
10
8
|
const buildHeaders = options => Object.keys(options)
|
|
11
9
|
.reduce((obj, key) => ({
|
package/src/utils/definitions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { CLIError } = require('@oclif/
|
|
1
|
+
const { CLIError } = require('@oclif/core').Errors
|
|
2
2
|
const { hasJsonStructure } = require('./general')
|
|
3
3
|
const yaml = require('js-yaml')
|
|
4
4
|
const { existsSync, readFileSync } = require('fs-extra')
|
|
@@ -6,9 +6,11 @@ const { errorMsg } = require('../template-strings')
|
|
|
6
6
|
|
|
7
7
|
const specVersionToSpecification = specVersion => {
|
|
8
8
|
if (/2.0$/.test(specVersion))
|
|
9
|
-
|
|
9
|
+
return 'openapi-2.0'
|
|
10
10
|
if (/2.\d+.\d+$/.test(specVersion))
|
|
11
11
|
return 'asyncapi-2.x.x'
|
|
12
|
+
if (/3.1.\d+$/.test(specVersion))
|
|
13
|
+
return 'openapi-3.1.0'
|
|
12
14
|
return 'openapi-3.0.0'
|
|
13
15
|
}
|
|
14
16
|
|
package/src/utils/general.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
const deepExtend = require('deep-extend')
|
|
2
2
|
const jsonTemplate = require('json-templates')
|
|
3
3
|
|
|
4
|
+
const pick = (object, keys) => {
|
|
5
|
+
const newObject = {}
|
|
6
|
+
for (const key of keys) {
|
|
7
|
+
if (key in object) {
|
|
8
|
+
newObject[key] = object[key]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return newObject
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const omit = (object, keys_) => {
|
|
16
|
+
const keys = new Set(keys_)
|
|
17
|
+
const newObject = {}
|
|
18
|
+
for (const [key, value] of Object.entries(object)) {
|
|
19
|
+
if (!keys.has(key)) {
|
|
20
|
+
newObject[key] = value
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return newObject
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isEqual = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2)
|
|
28
|
+
|
|
4
29
|
const pipe = (...fns) => val => (
|
|
5
30
|
fns.reduce((acc, currentFn) => currentFn(acc), val)
|
|
6
31
|
)
|
|
@@ -47,5 +72,8 @@ module.exports = {
|
|
|
47
72
|
mergeDeep,
|
|
48
73
|
wrapTemplates,
|
|
49
74
|
pipe,
|
|
50
|
-
pipeAsync
|
|
75
|
+
pipeAsync,
|
|
76
|
+
pick,
|
|
77
|
+
omit,
|
|
78
|
+
isEqual
|
|
51
79
|
}
|