swaggerhub-cli 0.14.0 → 0.16.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 +152 -41
- package/bin/run +5 -4
- package/oclif.manifest.json +841 -670
- package/package.json +21 -16
- package/skills/swaggerhub-cli/SKILL.md +43 -0
- package/src/check-node-version.js +3 -2
- package/src/commands/api/clone.js +8 -7
- package/src/commands/api/comment/list.js +91 -0
- package/src/commands/api/create.js +8 -8
- package/src/commands/api/delete.js +6 -6
- package/src/commands/api/fork.js +75 -0
- package/src/commands/api/get.js +7 -7
- package/src/commands/api/publish.js +6 -6
- package/src/commands/api/rename.js +8 -10
- package/src/commands/api/setdefault.js +5 -5
- package/src/commands/api/unpublish.js +5 -5
- package/src/commands/api/update.js +8 -8
- package/src/commands/api/validate/download-rules.js +6 -6
- package/src/commands/api/validate/index.js +8 -8
- package/src/commands/api/validate/local.js +8 -8
- package/src/commands/configure.js +6 -6
- package/src/commands/domain/clone.js +8 -7
- package/src/commands/domain/create.js +8 -8
- package/src/commands/domain/delete.js +6 -6
- package/src/commands/domain/fork.js +75 -0
- package/src/commands/domain/get.js +7 -7
- package/src/commands/domain/publish.js +5 -5
- package/src/commands/domain/rename.js +9 -8
- package/src/commands/domain/setdefault.js +5 -5
- package/src/commands/domain/unpublish.js +5 -5
- package/src/commands/domain/update.js +8 -8
- package/src/commands/integration/create.js +5 -5
- package/src/commands/integration/delete.js +5 -5
- package/src/commands/integration/execute.js +5 -5
- package/src/commands/integration/get.js +7 -7
- package/src/commands/integration/list.js +6 -6
- package/src/commands/integration/update.js +5 -5
- package/src/commands/project/api/add.js +5 -7
- package/src/commands/project/api/remove.js +7 -10
- package/src/commands/project/create.js +5 -9
- package/src/commands/project/delete.js +5 -5
- package/src/commands/project/domain/add.js +5 -7
- package/src/commands/project/domain/remove.js +7 -10
- package/src/commands/project/get.js +7 -7
- package/src/commands/project/list.js +5 -5
- package/src/commands/project/member/list.js +6 -6
- package/src/commands/spectral/download.js +8 -8
- package/src/commands/spectral/upload.js +10 -10
- package/src/config/index.js +27 -5
- package/src/format-readme.js +3 -2
- package/src/help.js +2 -2
- package/src/hooks/setup-config.js +11 -6
- 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 +10 -11
- 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 +2 -2
- package/src/support/isOnPrem.js +4 -4
- package/src/template-strings/errors.js +2 -2
- package/src/template-strings/index.js +3 -3
- package/src/template-strings/info.js +6 -2
- package/src/utils/definitions.js +8 -6
- package/src/utils/general.js +3 -3
|
@@ -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)
|
|
@@ -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 fs from 'node:fs'
|
|
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,14 +9,26 @@ 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
|
+
|
|
18
|
+
// A mutable object keeps file access stubbable in tests (ES module namespaces are frozen).
|
|
19
|
+
const fileIO = {
|
|
20
|
+
readJSON: filePath => JSON.parse(fs.readFileSync(filePath, 'utf8')),
|
|
21
|
+
writeJSON: (filePath, data) => fs.writeFileSync(filePath, `${JSON.stringify(data)}\n`)
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
const getConfig = () => {
|
|
13
25
|
const { configFilePath } = global
|
|
14
|
-
return checkEnvOverrides(
|
|
26
|
+
return stripTrailingSlashes(checkEnvOverrides(fileIO.readJSON(configFilePath)))
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
const setConfig = update => {
|
|
18
30
|
const { configFilePath } = global
|
|
19
|
-
return
|
|
31
|
+
return fileIO.writeJSON(configFilePath, mergeDeep(fileIO.readJSON(configFilePath), update))
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
const isURLValid = () => {
|
|
@@ -27,8 +39,18 @@ const isURLValid = () => {
|
|
|
27
39
|
url.hostname === 'localhost'
|
|
28
40
|
}
|
|
29
41
|
|
|
30
|
-
module
|
|
42
|
+
// A mutable default export keeps these functions stubbable (ES module namespaces are frozen).
|
|
43
|
+
const config = {
|
|
44
|
+
fileIO,
|
|
31
45
|
setConfig,
|
|
32
46
|
getConfig,
|
|
33
47
|
isURLValid
|
|
34
48
|
}
|
|
49
|
+
|
|
50
|
+
export default config
|
|
51
|
+
export {
|
|
52
|
+
fileIO,
|
|
53
|
+
setConfig,
|
|
54
|
+
getConfig,
|
|
55
|
+
isURLValid
|
|
56
|
+
}
|
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,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs, { existsSync } from 'node:fs'
|
|
3
|
+
import packageJson from '../../package.json' with { type: 'json' }
|
|
4
|
+
import { pipe } from '../utils/general.js'
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const { configDefaults } = packageJson.oclif
|
|
7
|
+
|
|
8
|
+
const createConfigFile = (filePath, config) => {
|
|
9
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true })
|
|
10
|
+
fs.writeFileSync(filePath, `${JSON.stringify(config)}\n`, { mode: 0o600 })
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
const createConfigPath = ({ configDir }) => path.join(configDir, 'config.json')
|
|
9
14
|
|
|
@@ -20,4 +25,4 @@ const SetupConfig = async ({ config: defaults }) => (
|
|
|
20
25
|
pipe(setAsGlobalUserAgent, createConfigPath, setAsGlobalPath, initConfig)(defaults)
|
|
21
26
|
)
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
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
|
|
|
@@ -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
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const swaggerHubUrl = {
|
|
4
4
|
name: 'SWAGGERHUB_URL',
|
|
@@ -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
|
-
const { SWAGGERHUB_URL } =
|
|
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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrapTemplates } from '../utils/general.js'
|
|
2
2
|
|
|
3
3
|
const errorMsg = {
|
|
4
4
|
ApiCreate: 'API version \'{{owner}}/{{name}}/{{version}}\' already exists in Swagger',
|
|
@@ -28,6 +28,6 @@ const errorMsg = {
|
|
|
28
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}}\'',
|
|
@@ -9,8 +9,12 @@ const infoMsg = {
|
|
|
9
9
|
|
|
10
10
|
ApiClone: 'Cloned API \'{{apiPath}}\' as version {{newVersion}}',
|
|
11
11
|
|
|
12
|
+
ApiFork: 'Forked API \'{{apiPath}}\' as \'{{forkPath}}\'',
|
|
13
|
+
|
|
12
14
|
DomainClone: 'Cloned domain \'{{domainPath}}\' as version {{newVersion}}',
|
|
13
15
|
|
|
16
|
+
DomainFork: 'Forked domain \'{{domainPath}}\' as \'{{forkPath}}\'',
|
|
17
|
+
|
|
14
18
|
DomainRename: 'Renamed domain \'{{domainPath}}\' to \'{{newName}}\'',
|
|
15
19
|
|
|
16
20
|
DomainCreate: 'Created domain \'{{owner}}/{{name}}\'',
|
|
@@ -69,6 +73,6 @@ const infoMsg = {
|
|
|
69
73
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
export default wrapTemplates({
|
|
73
77
|
...infoMsg
|
|
74
78
|
})
|
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,
|