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.
Files changed (72) hide show
  1. package/README.md +209 -122
  2. package/bin/run +5 -4
  3. package/oclif.manifest.json +283 -122
  4. package/package.json +14 -12
  5. package/src/check-node-version.js +3 -2
  6. package/src/commands/api/clone.js +66 -0
  7. package/src/commands/api/create.js +10 -10
  8. package/src/commands/api/delete.js +7 -7
  9. package/src/commands/api/get.js +9 -9
  10. package/src/commands/api/publish.js +7 -7
  11. package/src/commands/api/rename.js +8 -10
  12. package/src/commands/api/setdefault.js +6 -6
  13. package/src/commands/api/unpublish.js +5 -5
  14. package/src/commands/api/update.js +11 -11
  15. package/src/commands/api/validate/download-rules.js +11 -11
  16. package/src/commands/api/validate/index.js +10 -10
  17. package/src/commands/api/validate/local.js +11 -11
  18. package/src/commands/configure.js +8 -8
  19. package/src/commands/domain/clone.js +66 -0
  20. package/src/commands/domain/create.js +14 -14
  21. package/src/commands/domain/delete.js +7 -7
  22. package/src/commands/domain/get.js +8 -8
  23. package/src/commands/domain/publish.js +6 -6
  24. package/src/commands/domain/rename.js +78 -0
  25. package/src/commands/domain/setdefault.js +6 -6
  26. package/src/commands/domain/unpublish.js +6 -6
  27. package/src/commands/domain/update.js +11 -11
  28. package/src/commands/integration/create.js +7 -7
  29. package/src/commands/integration/delete.js +6 -6
  30. package/src/commands/integration/execute.js +6 -6
  31. package/src/commands/integration/get.js +9 -9
  32. package/src/commands/integration/list.js +7 -7
  33. package/src/commands/integration/update.js +6 -6
  34. package/src/commands/project/api/add.js +7 -9
  35. package/src/commands/project/api/remove.js +10 -13
  36. package/src/commands/project/create.js +9 -13
  37. package/src/commands/project/delete.js +7 -7
  38. package/src/commands/project/domain/add.js +7 -9
  39. package/src/commands/project/domain/remove.js +10 -13
  40. package/src/commands/project/get.js +8 -8
  41. package/src/commands/project/list.js +6 -6
  42. package/src/commands/project/member/list.js +8 -8
  43. package/src/commands/spectral/download.js +9 -9
  44. package/src/commands/spectral/upload.js +11 -11
  45. package/src/config/index.js +18 -4
  46. package/src/format-readme.js +3 -2
  47. package/src/help.js +2 -2
  48. package/src/hooks/setup-config.js +9 -5
  49. package/src/index.js +2 -2
  50. package/src/requests/api.js +3 -3
  51. package/src/requests/domain.js +3 -3
  52. package/src/requests/project.js +2 -2
  53. package/src/requests/spec.js +5 -5
  54. package/src/requests/spectral.js +3 -3
  55. package/src/requests/standardization.js +4 -4
  56. package/src/support/command/base-command.js +11 -12
  57. package/src/support/command/base-validate-command.js +3 -3
  58. package/src/support/command/handle-response.js +7 -5
  59. package/src/support/command/parse-input.js +8 -6
  60. package/src/support/command/update-command.js +5 -5
  61. package/src/support/http/default-headers.js +1 -1
  62. package/src/support/http/header-templates.js +2 -2
  63. package/src/support/http/index.js +7 -7
  64. package/src/support/http/proxy-agent.js +4 -4
  65. package/src/support/inquirer/index.js +4 -4
  66. package/src/support/inquirer/prompt-templates.js +3 -3
  67. package/src/support/isOnPrem.js +3 -3
  68. package/src/template-strings/errors.js +6 -6
  69. package/src/template-strings/index.js +3 -3
  70. package/src/template-strings/info.js +10 -4
  71. package/src/utils/definitions.js +8 -6
  72. package/src/utils/general.js +3 -3
@@ -1,4 +1,4 @@
1
- const { wrapTemplates } = require('../../utils/general')
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
- module.exports = wrapTemplates({
15
+ export default wrapTemplates({
16
16
  accept,
17
17
  auth,
18
18
  contentType
@@ -1,10 +1,10 @@
1
- const fetch = require('node-fetch')
2
- const qs = require('querystring')
3
- const headerTemplates = require('./header-templates')
4
- const defaultHeaders = require('./default-headers')
5
- const { agentFor } = require('./proxy-agent')
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
- const { pipe, pick, omit } = require('../../utils/general')
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
- module.exports = options => (
40
+ export default options => (
41
41
  pipe(parseQuery, parseUrl, parseHeaders, request)(options)
42
42
  )
@@ -1,6 +1,6 @@
1
- const { getProxyForUrl } = require('proxy-from-env')
2
- const { HttpsProxyAgent } = require('https-proxy-agent')
3
- const { HttpProxyAgent } = require('http-proxy-agent')
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
- module.exports = { agentFor }
25
+ export { agentFor }
@@ -1,9 +1,9 @@
1
- const promptTemplates = require('./prompt-templates')
1
+ import promptTemplates from './prompt-templates.js'
2
2
 
3
- const getPrompts = prompts => (
4
- (options = {}) => prompts.map(p => promptTemplates[p](options))
3
+ const getPrompts = (prompts, templates = promptTemplates) => (
4
+ (options = {}) => prompts.map(p => templates[p](options))
5
5
  )
6
6
 
7
- module.exports = {
7
+ export {
8
8
  getPrompts
9
9
  }
@@ -1,8 +1,8 @@
1
- const { wrapTemplates } = require('../../utils/general')
1
+ import { wrapTemplates } from '../../utils/general.js'
2
2
 
3
3
  const swaggerHubUrl = {
4
4
  name: 'SWAGGERHUB_URL',
5
- message: 'SwaggerHub URL:',
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
- module.exports = wrapTemplates({
15
+ export default wrapTemplates({
16
16
  swaggerHubUrl,
17
17
  apiKey
18
18
  })
@@ -1,10 +1,10 @@
1
- const { getConfig } = require('../config')
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
- module.exports = {
8
+ export {
9
9
  isOnPrem
10
- }
10
+ }
@@ -1,15 +1,15 @@
1
- const { wrapTemplates } = require('../utils/general')
1
+ import { wrapTemplates } from '../utils/general.js'
2
2
 
3
3
  const errorMsg = {
4
- ApiCreate: 'API version \'{{owner}}/{{name}}/{{version}}\' already exists in SwaggerHub',
4
+ ApiCreate: 'API version \'{{owner}}/{{name}}/{{version}}\' already exists in Swagger',
5
5
 
6
- DomainCreate: 'Domain version \'{{owner}}/{{name}}/{{version}}\' already exists in SwaggerHub',
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 with parsing {{filename}}. \nReason: {{e}}',
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 Error',
28
+ unknown: 'Unknown error',
29
29
  }
30
30
 
31
- module.exports = wrapTemplates({
31
+ export default wrapTemplates({
32
32
  ...errorMsg
33
33
  })
@@ -1,7 +1,7 @@
1
- const errorMsg = require('./errors')
2
- const infoMsg = require('./info')
1
+ import errorMsg from './errors.js'
2
+ import infoMsg from './info.js'
3
3
 
4
- module.exports = {
4
+ export {
5
5
  errorMsg,
6
6
  infoMsg
7
7
  }
@@ -1,4 +1,4 @@
1
- const { wrapTemplates } = require('../utils/general')
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 api \'{{apiName}}\' to project \'{{projectPath}}\'',
60
+ ProjectApiAdd: 'Added API \'{{apiName}}\' to project \'{{projectPath}}\'',
55
61
 
56
- ProjectApiRemove: 'Removed api \'{{apiName}}\' from project \'{{projectPath}}\'',
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
- module.exports = wrapTemplates({
72
+ export default wrapTemplates({
67
73
  ...infoMsg
68
74
  })
@@ -1,8 +1,10 @@
1
- const { CLIError } = require('@oclif/core').Errors
2
- const { hasJsonStructure } = require('./general')
3
- const yaml = require('js-yaml')
4
- const { existsSync, readFileSync } = require('fs-extra')
5
- const { errorMsg } = require('../template-strings')
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
- module.exports = {
49
+ export {
48
50
  getSpecification,
49
51
  getVersion,
50
52
  parseDefinition,
@@ -1,5 +1,5 @@
1
- const deepExtend = require('deep-extend')
2
- const jsonTemplate = require('json-templates')
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
- module.exports = {
67
+ export {
68
68
  hasJsonStructure,
69
69
  prettyPrintJSON,
70
70
  isError,