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,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { deleteProject } from '../../requests/project.js'
|
|
3
|
+
import { getProjectIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
5
5
|
|
|
6
6
|
class DeleteProjectCommand extends BaseCommand {
|
|
7
7
|
constructor(...props) {
|
|
@@ -26,7 +26,7 @@ class DeleteProjectCommand extends BaseCommand {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
DeleteProjectCommand.description = 'Deletes a project from
|
|
29
|
+
DeleteProjectCommand.description = 'Deletes a project from Swagger.'
|
|
30
30
|
|
|
31
31
|
DeleteProjectCommand.examples = [
|
|
32
32
|
'swaggerhub project:delete organization/project_name'
|
|
@@ -35,7 +35,7 @@ DeleteProjectCommand.examples = [
|
|
|
35
35
|
DeleteProjectCommand.args = {
|
|
36
36
|
'OWNER/PROJECT_NAME': Args.string({
|
|
37
37
|
required: true,
|
|
38
|
-
description: 'The project to delete on
|
|
38
|
+
description: 'The project to delete on Swagger'
|
|
39
39
|
})
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -43,4 +43,4 @@ DeleteProjectCommand.flags = {
|
|
|
43
43
|
...BaseCommand.flags
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
export default DeleteProjectCommand
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} = require('../../../support/command/parse-input')
|
|
6
|
-
const BaseCommand = require('../../../support/command/base-command')
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { putProject } from '../../../requests/project.js'
|
|
3
|
+
import { getProjectIdentifierArg } from '../../../support/command/parse-input.js'
|
|
4
|
+
import BaseCommand from '../../../support/command/base-command.js'
|
|
7
5
|
|
|
8
6
|
class ProjectDomainAddCommand extends BaseCommand {
|
|
9
7
|
|
|
@@ -35,12 +33,12 @@ ProjectDomainAddCommand.examples = [
|
|
|
35
33
|
ProjectDomainAddCommand.args = {
|
|
36
34
|
'OWNER/PROJECT_NAME': Args.string({
|
|
37
35
|
required: true,
|
|
38
|
-
description: 'The project to add the domain to on
|
|
36
|
+
description: 'The project to add the domain to on Swagger'
|
|
39
37
|
}),
|
|
40
38
|
'DOMAIN': Args.string({
|
|
41
39
|
required: true,
|
|
42
|
-
description: 'The name of the domain on
|
|
40
|
+
description: 'The name of the domain on Swagger to add'
|
|
43
41
|
})
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
export default ProjectDomainAddCommand
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
const BaseCommand = require('../../../support/command/base-command')
|
|
8
|
-
const { getResponseContent } = require('../../../support/command/handle-response')
|
|
9
|
-
const { pipeAsync } = require('../../../utils/general')
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { putProject, getProject } from '../../../requests/project.js'
|
|
3
|
+
import { getProjectIdentifierArg, splitPathParams } from '../../../support/command/parse-input.js'
|
|
4
|
+
import BaseCommand from '../../../support/command/base-command.js'
|
|
5
|
+
import { getResponseContent } from '../../../support/command/handle-response.js'
|
|
6
|
+
import { pipeAsync } from '../../../utils/general.js'
|
|
10
7
|
|
|
11
8
|
class ProjectDomainRemoveCommand extends BaseCommand {
|
|
12
9
|
|
|
@@ -48,7 +45,7 @@ class ProjectDomainRemoveCommand extends BaseCommand {
|
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
ProjectDomainRemoveCommand.description = 'Removes a domain from a project in
|
|
48
|
+
ProjectDomainRemoveCommand.description = 'Removes a domain from a project in Swagger.'
|
|
52
49
|
|
|
53
50
|
ProjectDomainRemoveCommand.examples = [
|
|
54
51
|
'swaggerhub project:domain:remove organization/project_name my_domain',
|
|
@@ -57,12 +54,12 @@ ProjectDomainRemoveCommand.examples = [
|
|
|
57
54
|
ProjectDomainRemoveCommand.args = {
|
|
58
55
|
'OWNER/PROJECT_NAME': Args.string({
|
|
59
56
|
required: true,
|
|
60
|
-
description: 'The project to remove the domain from on
|
|
57
|
+
description: 'The project to remove the domain from on Swagger'
|
|
61
58
|
}),
|
|
62
59
|
'DOMAIN': Args.string({
|
|
63
60
|
required: true,
|
|
64
|
-
description: 'The name of the domain on
|
|
61
|
+
description: 'The name of the domain on Swagger to remove'
|
|
65
62
|
})
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
export default ProjectDomainRemoveCommand
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { getProject } from '../../requests/project.js'
|
|
3
|
+
import { getProjectIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import { getResponseContent } from '../../support/command/handle-response.js'
|
|
5
|
+
import { prettyPrintJSON } from '../../utils/general.js'
|
|
6
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
7
7
|
|
|
8
8
|
class GetProjectCommand extends BaseCommand {
|
|
9
9
|
constructor(...props) {
|
|
@@ -42,7 +42,7 @@ GetProjectCommand.examples = [
|
|
|
42
42
|
GetProjectCommand.args = {
|
|
43
43
|
'OWNER/PROJECT_NAME': Args.string({
|
|
44
44
|
required: true,
|
|
45
|
-
description: 'The project to get details for on
|
|
45
|
+
description: 'The project to get details for on Swagger'
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -50,4 +50,4 @@ GetProjectCommand.flags = {
|
|
|
50
50
|
...BaseCommand.flags
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
export default GetProjectCommand
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ux, Args, Flags } from '@oclif/core'
|
|
2
|
+
import { getProject } from '../../requests/project.js'
|
|
3
|
+
import { getResponseContent } from '../../support/command/handle-response.js'
|
|
4
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
5
5
|
|
|
6
6
|
class ListProjectCommand extends BaseCommand {
|
|
7
7
|
constructor(...props) {
|
|
@@ -57,7 +57,7 @@ ListProjectCommand.examples = [
|
|
|
57
57
|
ListProjectCommand.args = {
|
|
58
58
|
'OWNER': Args.string({
|
|
59
59
|
required: false,
|
|
60
|
-
description: 'The organization to list projects for on
|
|
60
|
+
description: 'The organization to list projects for on Swagger'
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -79,4 +79,4 @@ ListProjectCommand.flags = {
|
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
export default ListProjectCommand
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ux, Args } from '@oclif/core'
|
|
2
|
+
import { getProject } from '../../../requests/project.js'
|
|
3
|
+
import { getResponseContent } from '../../../support/command/handle-response.js'
|
|
4
|
+
import BaseCommand from '../../../support/command/base-command.js'
|
|
5
|
+
import { getProjectIdentifierArg } from '../../../support/command/parse-input.js'
|
|
6
6
|
|
|
7
7
|
class ListProjectMembersCommand extends BaseCommand {
|
|
8
8
|
constructor(...props) {
|
|
@@ -44,13 +44,13 @@ class ListProjectMembersCommand extends BaseCommand {
|
|
|
44
44
|
ListProjectMembersCommand.description = 'list members of a project'
|
|
45
45
|
|
|
46
46
|
ListProjectMembersCommand.examples = [
|
|
47
|
-
'swaggerhub project:member:list
|
|
47
|
+
'swaggerhub project:member:list organization/project_name',
|
|
48
48
|
]
|
|
49
49
|
|
|
50
50
|
ListProjectMembersCommand.args = {
|
|
51
51
|
'OWNER/PROJECT_NAME': Args.string({
|
|
52
52
|
required: true,
|
|
53
|
-
description: 'Project to list members of
|
|
53
|
+
description: 'Project to list members of'
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -58,4 +58,4 @@ ListProjectMembersCommand.flags = {
|
|
|
58
58
|
...BaseCommand.flags
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
export default ListProjectMembersCommand
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Args, Errors } from '@oclif/core'
|
|
2
|
+
import { getSpectralRuleset } from '../../requests/spectral.js'
|
|
3
|
+
import { getSpectralIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
6
|
+
import unzipper from 'unzipper'
|
|
7
|
+
import fs from 'fs'
|
|
8
8
|
|
|
9
9
|
class DownloadSpectralRulesetCommand extends BaseCommand {
|
|
10
10
|
async run() {
|
|
@@ -54,7 +54,7 @@ DownloadSpectralRulesetCommand.examples = [
|
|
|
54
54
|
DownloadSpectralRulesetCommand.args = {
|
|
55
55
|
'OWNER/RULESET_NAME': Args.string({
|
|
56
56
|
required: true,
|
|
57
|
-
description: 'Organization\'s Spectral ruleset to create or update on
|
|
57
|
+
description: 'Organization\'s Spectral ruleset to create or update on Swagger'
|
|
58
58
|
}),
|
|
59
59
|
'directory': Args.string({
|
|
60
60
|
required: true,
|
|
@@ -66,4 +66,4 @@ DownloadSpectralRulesetCommand.flags = {
|
|
|
66
66
|
...BaseCommand.flags
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
export default DownloadSpectralRulesetCommand
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { saveSpectralRuleset } from '../../requests/spectral.js'
|
|
3
|
+
import { getSpectralIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
5
|
+
import { PassThrough } from 'stream'
|
|
6
|
+
import { pipeAsync } from '../../utils/general.js'
|
|
7
|
+
import { ZipArchive } from 'archiver'
|
|
8
|
+
import { getResponseContent } from '../../support/command/handle-response.js'
|
|
9
9
|
|
|
10
10
|
class UploadSpectralRulesetCommand extends BaseCommand {
|
|
11
11
|
async run() {
|
|
@@ -17,7 +17,7 @@ class UploadSpectralRulesetCommand extends BaseCommand {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async zipTheDirectory(directoryPath) {
|
|
20
|
-
const archive =
|
|
20
|
+
const archive = new ZipArchive({ zlib: { level: 9 } })
|
|
21
21
|
const passthrough = new PassThrough()
|
|
22
22
|
|
|
23
23
|
archive.directory(directoryPath, false)
|
|
@@ -44,7 +44,7 @@ UploadSpectralRulesetCommand.examples = [
|
|
|
44
44
|
UploadSpectralRulesetCommand.args = {
|
|
45
45
|
'OWNER/RULESET_NAME': Args.string({
|
|
46
46
|
required: true,
|
|
47
|
-
description: 'Organization\'s Spectral ruleset to create or update on
|
|
47
|
+
description: 'Organization\'s Spectral ruleset to create or update on Swagger'
|
|
48
48
|
}),
|
|
49
49
|
'directory': Args.string({
|
|
50
50
|
required: true,
|
|
@@ -56,4 +56,4 @@ UploadSpectralRulesetCommand.flags = {
|
|
|
56
56
|
...BaseCommand.flags
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
export default UploadSpectralRulesetCommand
|
package/src/config/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fse from 'fs-extra' // We're not using {readSyncJSON, ...} expansion, since we want to mock it.
|
|
2
|
+
import { mergeDeep, pick } from '../utils/general.js'
|
|
3
3
|
|
|
4
4
|
const swaggerhubUrlRegex = new RegExp(/^https?:\/\/api\..*swaggerhub\.com$/)
|
|
5
5
|
const environmentalKeys = ['SWAGGERHUB_URL', 'SWAGGERHUB_API_KEY']
|
|
@@ -9,9 +9,15 @@ const checkEnvOverrides = config => ({
|
|
|
9
9
|
...pick(process.env, environmentalKeys)
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
+
const stripTrailingSlashes = config => (
|
|
13
|
+
typeof config.SWAGGERHUB_URL === 'string'
|
|
14
|
+
? { ...config, SWAGGERHUB_URL: config.SWAGGERHUB_URL.replace(/\/+$/, '') }
|
|
15
|
+
: config
|
|
16
|
+
)
|
|
17
|
+
|
|
12
18
|
const getConfig = () => {
|
|
13
19
|
const { configFilePath } = global
|
|
14
|
-
return checkEnvOverrides(fse.readJSONSync(configFilePath))
|
|
20
|
+
return stripTrailingSlashes(checkEnvOverrides(fse.readJSONSync(configFilePath)))
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
const setConfig = update => {
|
|
@@ -27,8 +33,16 @@ const isURLValid = () => {
|
|
|
27
33
|
url.hostname === 'localhost'
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
module
|
|
36
|
+
// A mutable default export keeps these functions stubbable (ES module namespaces are frozen).
|
|
37
|
+
const config = {
|
|
31
38
|
setConfig,
|
|
32
39
|
getConfig,
|
|
33
40
|
isURLValid
|
|
34
41
|
}
|
|
42
|
+
|
|
43
|
+
export default config
|
|
44
|
+
export {
|
|
45
|
+
setConfig,
|
|
46
|
+
getConfig,
|
|
47
|
+
isURLValid
|
|
48
|
+
}
|
package/src/format-readme.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
2
3
|
|
|
3
4
|
const removeArgsFromHeaders = line => {
|
|
4
5
|
const words = line.split(' ')
|
|
@@ -33,6 +34,6 @@ const main = () => {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
if (
|
|
37
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
37
38
|
main()
|
|
38
39
|
}
|
package/src/help.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import fse from 'fs-extra'
|
|
4
|
+
import packageJson from '../../package.json' with { type: 'json' }
|
|
5
|
+
import { pipe } from '../utils/general.js'
|
|
6
|
+
|
|
7
|
+
const { outputJsonSync } = fse
|
|
8
|
+
const { configDefaults } = packageJson.oclif
|
|
5
9
|
|
|
6
10
|
const createConfigFile = (filePath, config) => outputJsonSync(filePath, config, { mode: 0o600 })
|
|
7
11
|
|
|
@@ -20,4 +24,4 @@ const SetupConfig = async ({ config: defaults }) => (
|
|
|
20
24
|
pipe(setAsGlobalUserAgent, createConfigPath, setAsGlobalPath, initConfig)(defaults)
|
|
21
25
|
)
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
export default SetupConfig
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { run } from '@oclif/core'
|
|
2
|
+
export { run }
|
package/src/requests/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { getSpec, putSpec, postSpec, deleteSpec } from './spec.js'
|
|
2
2
|
|
|
3
3
|
const getApi = (pathParams, queryParams, accept = 'json') =>
|
|
4
4
|
getSpec('apis', pathParams, queryParams, accept)
|
|
@@ -12,9 +12,9 @@ const putApi = ({ pathParams, body }) =>
|
|
|
12
12
|
const postApi = ({ pathParams, queryParams, body }) =>
|
|
13
13
|
postSpec('apis', pathParams, queryParams, body)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export {
|
|
16
16
|
getApi,
|
|
17
17
|
deleteApi,
|
|
18
18
|
putApi,
|
|
19
19
|
postApi
|
|
20
|
-
}
|
|
20
|
+
}
|
package/src/requests/domain.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { getSpec, postSpec, deleteSpec } from './spec.js'
|
|
2
2
|
|
|
3
3
|
const getDomain = (pathParams, queryParams, accept = 'json') =>
|
|
4
4
|
getSpec('domains', pathParams, queryParams, accept)
|
|
@@ -9,8 +9,8 @@ const deleteDomain = (pathParams, queryParams) =>
|
|
|
9
9
|
const postDomain = ({ pathParams, queryParams, body }) =>
|
|
10
10
|
postSpec('domains', pathParams, queryParams, body)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export {
|
|
13
13
|
getDomain,
|
|
14
14
|
deleteDomain,
|
|
15
15
|
postDomain
|
|
16
|
-
}
|
|
16
|
+
}
|
package/src/requests/project.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { getSpec, postSpec, deleteSpec, putSpec } from './spec.js'
|
|
2
2
|
|
|
3
3
|
const getProject = (pathParams, queryParams, accept = 'json') =>
|
|
4
4
|
getSpec('projects', pathParams, queryParams, accept)
|
|
@@ -12,7 +12,7 @@ const putProject = ({ pathParams, body }) =>
|
|
|
12
12
|
const deleteProject = pathParams =>
|
|
13
13
|
deleteSpec('projects', pathParams)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export {
|
|
16
16
|
getProject,
|
|
17
17
|
postProject,
|
|
18
18
|
putProject,
|
package/src/requests/spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import config from '../config/index.js'
|
|
2
|
+
import http from '../support/http/index.js'
|
|
3
|
+
import { hasJsonStructure } from '../utils/general.js'
|
|
4
4
|
|
|
5
5
|
const getSpec = (specType, pathParams, queryParams, accept) => {
|
|
6
6
|
const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
|
|
@@ -49,9 +49,9 @@ const postSpec = (specType, pathParams, queryParams, body) => {
|
|
|
49
49
|
})
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
export {
|
|
53
53
|
getSpec,
|
|
54
54
|
deleteSpec,
|
|
55
55
|
putSpec,
|
|
56
56
|
postSpec
|
|
57
|
-
}
|
|
57
|
+
}
|
package/src/requests/spectral.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import config from '../config/index.js'
|
|
2
|
+
import http from '../support/http/index.js'
|
|
3
3
|
|
|
4
4
|
const saveSpectralRuleset = (pathParams, body) => {
|
|
5
5
|
const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
|
|
@@ -24,7 +24,7 @@ const getSpectralRuleset = pathParams => {
|
|
|
24
24
|
})
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
export {
|
|
28
28
|
saveSpectralRuleset,
|
|
29
29
|
getSpectralRuleset
|
|
30
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import config from '../config/index.js'
|
|
2
|
+
import http from '../support/http/index.js'
|
|
3
|
+
import { hasJsonStructure } from '../utils/general.js'
|
|
4
4
|
|
|
5
5
|
const postStandardization = (pathParams, body) => {
|
|
6
6
|
const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
|
|
@@ -27,7 +27,7 @@ const getStandardization = (pathParams, queryParams) => {
|
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
export {
|
|
31
31
|
postStandardization,
|
|
32
32
|
getStandardization
|
|
33
33
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const config = require('../../config')
|
|
9
|
-
const {
|
|
1
|
+
import { Command, Flags } from '@oclif/core'
|
|
2
|
+
import { capitalise, pipeAsync } from '../../utils/general.js'
|
|
3
|
+
import { infoMsg, errorMsg } from '../../template-strings/index.js'
|
|
4
|
+
import { getApi } from '../../requests/api.js'
|
|
5
|
+
import { getDomain } from '../../requests/domain.js'
|
|
6
|
+
import {
|
|
7
|
+
getResponseContent,
|
|
10
8
|
parseResponse,
|
|
11
9
|
checkForErrors,
|
|
12
10
|
handleErrors,
|
|
13
11
|
filterResponseMessaging
|
|
14
|
-
}
|
|
12
|
+
} from './handle-response.js'
|
|
13
|
+
import config from '../../config/index.js'
|
|
15
14
|
|
|
16
15
|
const versionResponse = content => JSON.parse(content).version
|
|
17
16
|
|
|
@@ -72,7 +71,7 @@ class BaseCommand extends Command {
|
|
|
72
71
|
executeHttp({ execute, onResolve, onReject = handleErrors, options: { resolveStatus = [] } }) {
|
|
73
72
|
|
|
74
73
|
if (!config.isURLValid()) {
|
|
75
|
-
this.error('Please verify that the configured
|
|
74
|
+
this.error('Please verify that the configured Swagger URL is correct.')
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
return execute()
|
|
@@ -88,4 +87,4 @@ BaseCommand.flags = {
|
|
|
88
87
|
help: Flags.help({ char: 'h' })
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
export default BaseCommand
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Flags, ux } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
3
3
|
|
|
4
4
|
class BaseValidateCommand extends BaseCommand {
|
|
5
5
|
|
|
@@ -37,4 +37,4 @@ BaseValidateCommand.flags = {
|
|
|
37
37
|
}),
|
|
38
38
|
...BaseCommand.flags
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
export default BaseValidateCommand
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Errors } from '@oclif/core'
|
|
2
|
+
import { hasJsonStructure, isError } from '../../utils/general.js'
|
|
3
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
4
|
+
|
|
5
|
+
const { CLIError } = Errors
|
|
4
6
|
|
|
5
7
|
const parseResponse = response => new Promise(resolve => {
|
|
6
8
|
|
|
@@ -60,10 +62,10 @@ const handleErrors = error => {
|
|
|
60
62
|
throw new CLIError(cliError)
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
export {
|
|
64
66
|
parseResponse,
|
|
65
67
|
checkForErrors,
|
|
66
68
|
getResponseContent,
|
|
67
69
|
handleErrors,
|
|
68
70
|
filterResponseMessaging
|
|
69
|
-
}
|
|
71
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { hasJsonStructure } from '../../utils/general.js'
|
|
3
|
+
import { Errors } from '@oclif/core'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
|
|
6
|
+
const { CLIError } = Errors
|
|
5
7
|
|
|
6
8
|
const noVersionRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+$/)
|
|
7
9
|
const apiNameRegex = new RegExp(/^[\w\-.]+$/)
|
|
@@ -88,7 +90,7 @@ const reqType = ({ json }) => json ? 'json' : 'yaml'
|
|
|
88
90
|
|
|
89
91
|
const resolvedParam = ({ resolved }) => resolved ? { resolved: true } : null
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
export {
|
|
92
94
|
getApiIdentifierArg,
|
|
93
95
|
apiNameRegex,
|
|
94
96
|
noVersionRegex,
|
|
@@ -102,4 +104,4 @@ module.exports = {
|
|
|
102
104
|
reqType,
|
|
103
105
|
resolvedParam,
|
|
104
106
|
isValidIdentifier
|
|
105
|
-
}
|
|
107
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import BaseCommand from './base-command.js'
|
|
2
|
+
import { putSpec } from '../../requests/spec.js'
|
|
3
|
+
import { handleErrors } from './handle-response.js'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
5
|
|
|
6
6
|
class UpdateCommand extends BaseCommand {
|
|
7
7
|
|
|
@@ -84,4 +84,4 @@ class UpdateCommand extends BaseCommand {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
export default UpdateCommand
|