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,7 +1,7 @@
1
- const { Args } = require('@oclif/core')
2
- const { deleteProject } = require('../../requests/project')
3
- const { getProjectIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
4
- const BaseCommand = require('../../support/command/base-command')
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 SwaggerHub.'
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 Swaggerhub'
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
- module.exports = DeleteProjectCommand
46
+ export default DeleteProjectCommand
@@ -1,9 +1,7 @@
1
- const { Args } = require('@oclif/core')
2
- const { putProject } = require('../../../requests/project')
3
- const {
4
- getProjectIdentifierArg
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 Swaggerhub'
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 Swaggerhub to add'
40
+ description: 'The name of the domain on Swagger to add'
43
41
  })
44
42
  }
45
43
 
46
- module.exports = ProjectDomainAddCommand
44
+ export default ProjectDomainAddCommand
@@ -1,12 +1,9 @@
1
- const { Args } = require('@oclif/core')
2
- const { putProject, getProject } = require('../../../requests/project')
3
- const {
4
- getProjectIdentifierArg,
5
- splitPathParams,
6
- } = require('../../../support/command/parse-input')
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 SwaggerHub.'
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 Swaggerhub'
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 Swaggerhub to remove'
61
+ description: 'The name of the domain on Swagger to remove'
65
62
  })
66
63
  }
67
64
 
68
- module.exports = ProjectDomainRemoveCommand
65
+ export default ProjectDomainRemoveCommand
@@ -1,9 +1,9 @@
1
- const { Args } = require('@oclif/core')
2
- const { getProject } = require('../../requests/project')
3
- const { getProjectIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
4
- const { getResponseContent } = require('../../support/command/handle-response')
5
- const { prettyPrintJSON } = require('../../utils/general')
6
- const BaseCommand = require('../../support/command/base-command')
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 Swaggerhub'
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
- module.exports = GetProjectCommand
53
+ export default GetProjectCommand
@@ -1,7 +1,7 @@
1
- const { ux, Args, Flags } = require('@oclif/core')
2
- const { getProject } = require('../../requests/project')
3
- const { getResponseContent } = require('../../support/command/handle-response')
4
- const BaseCommand = require('../../support/command/base-command')
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 Swaggerhub'
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
- module.exports = ListProjectCommand
82
+ export default ListProjectCommand
@@ -1,8 +1,8 @@
1
- const { ux, Args } = require('@oclif/core')
2
- const { getProject } = require('../../../requests/project')
3
- const { getResponseContent } = require('../../../support/command/handle-response')
4
- const BaseCommand = require('../../../support/command/base-command')
5
- const { getProjectIdentifierArg } = require('../../../support/command/parse-input')
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 organisation/project_name',
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 on Swaggerhub'
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
- module.exports = ListProjectMembersCommand
61
+ export default ListProjectMembersCommand
@@ -1,10 +1,10 @@
1
- const { Args , Errors } = require('@oclif/core')
2
- const { getSpectralRuleset } = require('../../requests/spectral')
3
- const { getSpectralIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
4
- const { errorMsg } = require('../../template-strings')
5
- const BaseCommand = require('../../support/command/base-command')
6
- const unzipper = require('unzipper')
7
- const fs = require('fs')
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 SwaggerHub'
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
- module.exports = DownloadSpectralRulesetCommand
69
+ export default DownloadSpectralRulesetCommand
@@ -1,11 +1,11 @@
1
- const { Args } = require('@oclif/core')
2
- const { saveSpectralRuleset } = require('../../requests/spectral')
3
- const { getSpectralIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
4
- const BaseCommand = require('../../support/command/base-command')
5
- const { PassThrough } = require('stream')
6
- const { pipeAsync } = require('../../utils/general')
7
- const archiver = require('archiver')
8
- const { getResponseContent } = require('../../support/command/handle-response')
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 = archiver('zip', { zlib: { level: 9 } })
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 SwaggerHub'
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
- module.exports = UploadSpectralRulesetCommand
59
+ export default UploadSpectralRulesetCommand
@@ -1,5 +1,5 @@
1
- const fse = require('fs-extra') // We're not using {readSyncJSON, ...} expansion, since we want to mock it.
2
- const { mergeDeep, pick } = require('../utils/general')
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.exports = {
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
+ }
@@ -1,4 +1,5 @@
1
- const fs = require('fs')
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 (require.main === module) {
37
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
37
38
  main()
38
39
  }
package/src/help.js CHANGED
@@ -1,6 +1,6 @@
1
- const { Help } = require('@oclif/core')
1
+ import { Help } from '@oclif/core'
2
2
 
3
- module.exports = class CustomHelp extends Help {
3
+ export default class CustomHelp extends Help {
4
4
 
5
5
  constructor(config, opts) {
6
6
  super(config, opts)
@@ -1,7 +1,11 @@
1
- const path = require('path')
2
- const { existsSync, outputJsonSync } = require('fs-extra')
3
- const { configDefaults } = require('../../package.json').oclif
4
- const { pipe } = require('../utils/general')
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
- module.exports = SetupConfig
27
+ export default SetupConfig
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- const { run } = require('@oclif/core')
2
- module.exports = { run }
1
+ import { run } from '@oclif/core'
2
+ export { run }
@@ -1,4 +1,4 @@
1
- const { getSpec, putSpec, postSpec, deleteSpec } = require('./spec')
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
- module.exports = {
15
+ export {
16
16
  getApi,
17
17
  deleteApi,
18
18
  putApi,
19
19
  postApi
20
- }
20
+ }
@@ -1,4 +1,4 @@
1
- const { getSpec, postSpec, deleteSpec } = require('./spec')
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
- module.exports = {
12
+ export {
13
13
  getDomain,
14
14
  deleteDomain,
15
15
  postDomain
16
- }
16
+ }
@@ -1,4 +1,4 @@
1
- const { getSpec, postSpec, deleteSpec, putSpec } = require('./spec')
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
- module.exports = {
15
+ export {
16
16
  getProject,
17
17
  postProject,
18
18
  putProject,
@@ -1,6 +1,6 @@
1
- const config = require('../config')
2
- const http = require('../support/http')
3
- const { hasJsonStructure } = require('../utils/general')
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
- module.exports = {
52
+ export {
53
53
  getSpec,
54
54
  deleteSpec,
55
55
  putSpec,
56
56
  postSpec
57
- }
57
+ }
@@ -1,5 +1,5 @@
1
- const config = require('../config')
2
- const http = require('../support/http')
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
- module.exports = {
27
+ export {
28
28
  saveSpectralRuleset,
29
29
  getSpectralRuleset
30
30
  }
@@ -1,6 +1,6 @@
1
- const config = require('../config')
2
- const http = require('../support/http')
3
- const { hasJsonStructure } = require('../utils/general')
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
- module.exports = {
30
+ export {
31
31
  postStandardization,
32
32
  getStandardization
33
33
  }
@@ -1,17 +1,16 @@
1
- const { Command, Flags } = require('@oclif/core')
2
- const { capitalise, pipeAsync } = require('../../utils/general')
3
- const { infoMsg, errorMsg } = require('../../template-strings')
4
- const { getApi } = require('../../requests/api')
5
- const { getDomain } = require('../../requests/domain')
6
- const { getResponseContent } = require('./handle-response')
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
- } = require('./handle-response')
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 SwaggerHub URL is correct.')
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
- module.exports = BaseCommand
90
+ export default BaseCommand
@@ -1,5 +1,5 @@
1
- const { Flags, ux } = require('@oclif/core')
2
- const BaseCommand = require('../../support/command/base-command')
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
- module.exports = BaseValidateCommand
40
+ export default BaseValidateCommand
@@ -1,6 +1,8 @@
1
- const { CLIError } = require('@oclif/core').Errors
2
- const { hasJsonStructure, isError } = require('../../utils/general')
3
- const { errorMsg } = require('../../template-strings')
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
- module.exports = {
65
+ export {
64
66
  parseResponse,
65
67
  checkForErrors,
66
68
  getResponseContent,
67
69
  handleErrors,
68
70
  filterResponseMessaging
69
- }
71
+ }
@@ -1,7 +1,9 @@
1
- const { existsSync, readFileSync } = require('fs-extra')
2
- const { hasJsonStructure } = require('../../utils/general')
3
- const { CLIError } = require('@oclif/core').Errors
4
- const { errorMsg } = require('../../template-strings')
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
- module.exports = {
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
- const BaseCommand = require('./base-command')
2
- const { putSpec } = require('../../requests/spec')
3
- const { handleErrors } = require('./handle-response')
4
- const inquirer = require('inquirer')
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
- module.exports = UpdateCommand
87
+ export default UpdateCommand
@@ -1,3 +1,3 @@
1
- module.exports = () => ({
1
+ export default () => ({
2
2
  'User-Agent': global.shUserAgent
3
3
  })