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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggerhub-cli",
|
|
3
|
-
"description": "SwaggerHub CLI",
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "SwaggerHub CLI. Includes an agent skill",
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"author": "SmartBear",
|
|
6
6
|
"bin": {
|
|
7
7
|
"swaggerhub": "./bin/run"
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
"@oclif/core": "^3.26.3",
|
|
12
12
|
"@oclif/plugin-help": "^6.0.21",
|
|
13
13
|
"@oclif/plugin-plugins": "^5.0.21",
|
|
14
|
-
"archiver": "^
|
|
14
|
+
"archiver": "^8.0.0",
|
|
15
15
|
"deep-extend": "^0.6.0",
|
|
16
|
-
"fs-extra": "^11.1.1",
|
|
17
16
|
"http-proxy-agent": "^9.1.0",
|
|
18
17
|
"https-proxy-agent": "^9.1.0",
|
|
19
18
|
"inquirer": "^8.2.5",
|
|
@@ -25,29 +24,26 @@
|
|
|
25
24
|
"unzipper": "^0.12.3"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
27
|
+
"@eslint/js": "^10.0.1",
|
|
28
28
|
"@faker-js/faker": "^10.0.0",
|
|
29
29
|
"@oclif/test": "^3.2.15",
|
|
30
|
+
"c8": "^12.0.0",
|
|
30
31
|
"chai": "^6.3.0",
|
|
31
32
|
"eslint": "^10.13.0",
|
|
32
33
|
"eslint-plugin-chai-friendly": "^1.0.0",
|
|
33
34
|
"eslint-plugin-immutable": "^1.0.0",
|
|
34
35
|
"eslint-plugin-mocha": "^12.0.0",
|
|
35
36
|
"eslint-plugin-n": "^18.3.0",
|
|
36
|
-
"globby": "^16.2.0",
|
|
37
37
|
"husky": "^9.0.1",
|
|
38
38
|
"mocha": "^11.7.6",
|
|
39
39
|
"nock": "^14.0.1",
|
|
40
|
-
"
|
|
41
|
-
"rewire": "^9.0.1",
|
|
42
|
-
"sinon": "^22.0.0",
|
|
43
|
-
"tmp": "^0.2.7"
|
|
40
|
+
"sinon": "^22.0.0"
|
|
44
41
|
},
|
|
45
42
|
"engines": {
|
|
46
|
-
"node": ">=22.
|
|
43
|
+
"node": ">=22.12.0",
|
|
47
44
|
"npm": ">=11.9.0"
|
|
48
45
|
},
|
|
49
46
|
"overrides": {
|
|
50
|
-
"npm": "^11.9.0",
|
|
51
47
|
"glob": "^10.5.0",
|
|
52
48
|
"serialize-javascript": "^7.1.4"
|
|
53
49
|
},
|
|
@@ -55,18 +51,27 @@
|
|
|
55
51
|
"/bin",
|
|
56
52
|
"/npm-shrinkwrap.json",
|
|
57
53
|
"/oclif.manifest.json",
|
|
58
|
-
"/src"
|
|
54
|
+
"/src",
|
|
55
|
+
"/skills"
|
|
59
56
|
],
|
|
60
57
|
"homepage": "https://github.com/SmartBear/swaggerhub-cli",
|
|
61
58
|
"keywords": [
|
|
62
|
-
"oclif"
|
|
59
|
+
"oclif",
|
|
60
|
+
"agent-skill",
|
|
61
|
+
"claude-code",
|
|
62
|
+
"swagger"
|
|
63
63
|
],
|
|
64
64
|
"license": "Apache-2.0",
|
|
65
65
|
"main": "src/index.js",
|
|
66
|
+
"type": "module",
|
|
67
|
+
"exports": {
|
|
68
|
+
".": "./src/index.js",
|
|
69
|
+
"./package.json": "./package.json"
|
|
70
|
+
},
|
|
66
71
|
"oclif": {
|
|
67
72
|
"commands": "./src/commands",
|
|
68
73
|
"hooks": {
|
|
69
|
-
"init": "./src/hooks/setup-config"
|
|
74
|
+
"init": "./src/hooks/setup-config.js"
|
|
70
75
|
},
|
|
71
76
|
"bin": "swaggerhub",
|
|
72
77
|
"plugins": [
|
|
@@ -93,14 +98,14 @@
|
|
|
93
98
|
"description": "this topic supports the management of Spectral rulesets"
|
|
94
99
|
}
|
|
95
100
|
},
|
|
96
|
-
"helpClass": "./src/help"
|
|
101
|
+
"helpClass": "./src/help.js"
|
|
97
102
|
},
|
|
98
103
|
"repository": "SmartBear/swaggerhub-cli",
|
|
99
104
|
"scripts": {
|
|
100
105
|
"postpack": "rm -f oclif.manifest.json",
|
|
101
106
|
"prepack": "npx oclif manifest",
|
|
102
107
|
"prepare": "husky",
|
|
103
|
-
"test": "
|
|
108
|
+
"test": "c8 mocha --forbid-only \"test/**/*.test.js\"",
|
|
104
109
|
"lint": "eslint ./src ./test",
|
|
105
110
|
"postinstall": "node ./src/check-node-version"
|
|
106
111
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swaggerhub-cli
|
|
3
|
+
description: Use the Swagger CLI (`swaggerhub`) to manage APIs, domains, projects, integrations and Spectral rulesets in Swagger (SwaggerHub) from the terminal or CI. Use when asked to fetch, create, update, clone, fork, publish, validate or delete an API or domain definition on Swagger.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Swagger CLI (`swaggerhub`)
|
|
7
|
+
|
|
8
|
+
Install: `npm i -g swaggerhub-cli` (Node.js >= 22.9). Run `swaggerhub <command> --help` for exact flags; it is the source of truth.
|
|
9
|
+
|
|
10
|
+
## Authentication
|
|
11
|
+
|
|
12
|
+
Set `SWAGGERHUB_API_KEY` (required). For Swagger Studio On-Premise 2.x also set `SWAGGERHUB_URL=https://<host>/v1`. Never print or commit the key. Alternatively `swaggerhub configure` (interactive, so avoid it in non-interactive agent runs; use env vars).
|
|
13
|
+
|
|
14
|
+
## Identifiers
|
|
15
|
+
|
|
16
|
+
- API / domain: `OWNER/NAME/VERSION` (VERSION optional on get/update/delete/validate; the default version is used).
|
|
17
|
+
- Project: `OWNER/PROJECT_NAME`.
|
|
18
|
+
- Integration: `OWNER/API_NAME/VERSION/INTEGRATION_ID`.
|
|
19
|
+
|
|
20
|
+
## Common tasks
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
swaggerhub api:get org/api/1.0.0 --json # YAML by default; -r for resolved definition
|
|
24
|
+
swaggerhub api:create org/api/1.0.0 -f api.yaml # errors if the version already exists
|
|
25
|
+
swaggerhub api:update org/api/1.0.0 -f api.yaml # --published=publish|unpublish, --setdefault, --visibility
|
|
26
|
+
swaggerhub api:clone org/api/1.0.0 1.0.1
|
|
27
|
+
swaggerhub api:fork org/api/1.0.0 myorg/api-fork/1.0.0 # --project, --visibility
|
|
28
|
+
swaggerhub api:comment:list org/api/1.0.0 # table of comments; --json for full detail
|
|
29
|
+
swaggerhub api:publish org/api/1.0.0 --force # --force skips the confirmation prompt
|
|
30
|
+
swaggerhub api:validate org/api/1.0.0 -c -j # -c exits 1 on critical errors, -j prints JSON
|
|
31
|
+
swaggerhub api:validate:local -o org -f api.yaml -c
|
|
32
|
+
swaggerhub project:list org
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The `domain:*` commands mirror `api:*` (get, create, update, clone, fork, publish, unpublish, setdefault, rename, delete). Other groups: `project:*` (create, get, list, delete, api/domain add/remove, member:list), `integration:*` (create, get, list, update, delete, execute), `spectral:download|upload`. Use `swaggerhub help` to list everything.
|
|
36
|
+
|
|
37
|
+
## Guidance for agents
|
|
38
|
+
|
|
39
|
+
- Commands that prompt for confirmation (`api:publish`, `api:delete`, and their domain equivalents) hang without a TTY. Pass `--force`/`-f` only after the user has agreed to the action.
|
|
40
|
+
- Deletes, publishes and unpublishes affect shared, live resources. Confirm with the user before running them, and prefer `api:get` first to check the target exists.
|
|
41
|
+
- Prefer `--json` where available for output you need to parse.
|
|
42
|
+
- To edit a definition: `api:get` to a file, modify it, then `api:update -f`. Run `api:validate:local` before publishing.
|
|
43
|
+
- A non-zero exit code means failure; read stderr rather than retrying blindly.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
2
|
+
import { Args, Flags, Errors } from '@oclif/core'
|
|
3
|
+
import { getApiIdentifierArg, apiNameRegex } from '../../support/command/parse-input.js'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
import { postApi } from '../../requests/api.js'
|
|
6
|
+
|
|
7
|
+
const { CLIError } = Errors
|
|
7
8
|
|
|
8
9
|
const getNewVersion = args => {
|
|
9
10
|
const newVersion = args['NEW_VERSION']
|
|
@@ -62,4 +63,4 @@ CloneApiCommand.flags = {
|
|
|
62
63
|
...BaseCommand.flags
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
export default CloneApiCommand
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Args, Flags, ux } from '@oclif/core'
|
|
2
|
+
import { getApiIdentifierArg } from '../../../support/command/parse-input.js'
|
|
3
|
+
import { hasJsonStructure, prettyPrintJSON } from '../../../utils/general.js'
|
|
4
|
+
import { getApi } from '../../../requests/api.js'
|
|
5
|
+
import BaseCommand from '../../../support/command/base-command.js'
|
|
6
|
+
|
|
7
|
+
const toRow = comment => ({
|
|
8
|
+
id: comment.id,
|
|
9
|
+
user: comment.user?.id ?? '',
|
|
10
|
+
status: comment.status ?? '',
|
|
11
|
+
line: comment.range?.startLine ?? '',
|
|
12
|
+
replies: (comment.replies ?? []).length,
|
|
13
|
+
created: comment.created,
|
|
14
|
+
body: (comment.body ?? '').replaceAll(/\s+/g, ' ')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
class ListApiCommentsCommand extends BaseCommand {
|
|
18
|
+
constructor(...props) {
|
|
19
|
+
super(...props)
|
|
20
|
+
this.logComments = this.logComments.bind(this)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async logComments(response) {
|
|
24
|
+
// the server answers 204 with an empty body when a version has no comments
|
|
25
|
+
const content = (await response.content) || '[]'
|
|
26
|
+
|
|
27
|
+
if (this.jsonOutput || !hasJsonStructure(content)) {
|
|
28
|
+
this.log(hasJsonStructure(content) ? prettyPrintJSON(content) : content)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const comments = JSON.parse(content)
|
|
33
|
+
if (!Array.isArray(comments)) {
|
|
34
|
+
this.log(prettyPrintJSON(content))
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (comments.length === 0) {
|
|
39
|
+
this.log('No comments found.')
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ux.table(comments.map(toRow), {
|
|
44
|
+
id: {},
|
|
45
|
+
user: {},
|
|
46
|
+
status: {},
|
|
47
|
+
line: {},
|
|
48
|
+
replies: {},
|
|
49
|
+
created: {},
|
|
50
|
+
body: {}
|
|
51
|
+
}, {
|
|
52
|
+
printLine: this.log.bind(this)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async run() {
|
|
57
|
+
const { args, flags } = await this.parse(ListApiCommentsCommand)
|
|
58
|
+
const apiPath = getApiIdentifierArg(args)
|
|
59
|
+
this.jsonOutput = flags.json
|
|
60
|
+
|
|
61
|
+
await this.executeHttp({
|
|
62
|
+
execute: () => getApi([apiPath, 'comments']),
|
|
63
|
+
onResolve: this.logComments,
|
|
64
|
+
options: {}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ListApiCommentsCommand.description = 'list the comments of an API version'
|
|
70
|
+
|
|
71
|
+
ListApiCommentsCommand.examples = [
|
|
72
|
+
'swaggerhub api:comment:list organization/api/1.0.0',
|
|
73
|
+
'swaggerhub api:comment:list organization/api/1.0.0 --json'
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
ListApiCommentsCommand.args = {
|
|
77
|
+
'OWNER/API_NAME/VERSION': Args.string({
|
|
78
|
+
required: true,
|
|
79
|
+
description: 'API version to list comments for'
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ListApiCommentsCommand.flags = {
|
|
84
|
+
json: Flags.boolean({
|
|
85
|
+
char: 'j',
|
|
86
|
+
description: 'prints the comments, including replies and ranges, as JSON'
|
|
87
|
+
}),
|
|
88
|
+
...BaseCommand.flags
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default ListApiCommentsCommand
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { getApi, postApi } from '../../requests/api.js'
|
|
4
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
5
|
+
import { getVersion, parseDefinition, getSpecification } from '../../utils/definitions.js'
|
|
6
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
7
|
+
import UpdateCommand from '../../support/command/update-command.js'
|
|
8
8
|
|
|
9
9
|
const isApiNameAvailable = response => response.status === 404
|
|
10
10
|
|
|
@@ -137,4 +137,4 @@ CreateAPICommand.flags = {
|
|
|
137
137
|
...BaseCommand.flags
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
export default CreateAPICommand
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import { deleteApi } from '../../requests/api.js'
|
|
3
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
5
|
+
import inquirer from 'inquirer'
|
|
6
6
|
|
|
7
7
|
class DeleteAPICommand extends BaseCommand {
|
|
8
8
|
|
|
@@ -61,4 +61,4 @@ DeleteAPICommand.flags = {
|
|
|
61
61
|
...BaseCommand.flags
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
export default DeleteAPICommand
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
2
|
+
import { Args, Flags, Errors } from '@oclif/core'
|
|
3
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
import { postApi } from '../../requests/api.js'
|
|
6
|
+
|
|
7
|
+
const { CLIError } = Errors
|
|
8
|
+
|
|
9
|
+
const targetRegex = new RegExp(/^[\w\-.]+\/[\w\-.]+\/[\w\-.]+$/)
|
|
10
|
+
|
|
11
|
+
const getTarget = args => {
|
|
12
|
+
const target = args['NEW_OWNER/NEW_API_NAME/NEW_VERSION']
|
|
13
|
+
if (!targetRegex.test(target)) {
|
|
14
|
+
throw new CLIError(errorMsg.argsMustMatchFormat({ format: 'NEW_OWNER/NEW_API_NAME/NEW_VERSION' }))
|
|
15
|
+
}
|
|
16
|
+
const [owner, name, version] = splitPathParams(target)
|
|
17
|
+
return { owner, name, version }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class ForkApiCommand extends BaseCommand {
|
|
21
|
+
|
|
22
|
+
async run() {
|
|
23
|
+
const { args, flags } = await this.parse(ForkApiCommand)
|
|
24
|
+
|
|
25
|
+
const apiPath = getApiIdentifierArg(args)
|
|
26
|
+
const body = getTarget(args)
|
|
27
|
+
const forkPath = `${body.owner}/${body.name}/${body.version}`
|
|
28
|
+
if (flags.project) body.project = flags.project
|
|
29
|
+
if (flags.visibility) body.private = flags.visibility === 'private'
|
|
30
|
+
|
|
31
|
+
this.log(`Forking API: '${apiPath}' as '${forkPath}'`)
|
|
32
|
+
|
|
33
|
+
await this.executeHttp({
|
|
34
|
+
execute: () => postApi({
|
|
35
|
+
pathParams: [apiPath, 'fork'],
|
|
36
|
+
body: JSON.stringify(body)
|
|
37
|
+
}),
|
|
38
|
+
onResolve: this.logCommandSuccess({ apiPath, forkPath }),
|
|
39
|
+
options: {}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ForkApiCommand.description = `fork an API version
|
|
45
|
+
The fork can be created as a new API, or as a new version of another existing API.
|
|
46
|
+
`
|
|
47
|
+
|
|
48
|
+
ForkApiCommand.examples = [
|
|
49
|
+
'swaggerhub api:fork organization/api/1.0.0 myorg/api-fork/1.0.0',
|
|
50
|
+
'swaggerhub api:fork organization/api/1.0.0 myorg/api-fork/1.0.0 --project my-project --visibility private'
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
ForkApiCommand.args = {
|
|
54
|
+
'OWNER/API_NAME/VERSION': Args.string({
|
|
55
|
+
required: true,
|
|
56
|
+
description: 'API version to fork'
|
|
57
|
+
}),
|
|
58
|
+
'NEW_OWNER/NEW_API_NAME/NEW_VERSION': Args.string({
|
|
59
|
+
required: true,
|
|
60
|
+
description: 'Owner, name and version of the fork. An existing API name creates a new version of it.'
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ForkApiCommand.flags = {
|
|
65
|
+
project: Flags.string({
|
|
66
|
+
description: 'existing project of the target organization to add the fork to'
|
|
67
|
+
}),
|
|
68
|
+
visibility: Flags.string({
|
|
69
|
+
description: 'visibility of the fork (defaults to the visibility of the source version)',
|
|
70
|
+
options: ['public', 'private']
|
|
71
|
+
}),
|
|
72
|
+
...BaseCommand.flags
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default ForkApiCommand
|
package/src/commands/api/get.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import { getApiIdentifierArg, reqType, resolvedParam } from '../../support/command/parse-input.js'
|
|
3
|
+
import { hasJsonStructure, prettyPrintJSON } from '../../utils/general.js'
|
|
4
|
+
import { getApi } from '../../requests/api.js'
|
|
5
|
+
import { getResponseContent } from '../../support/command/handle-response.js'
|
|
6
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
7
7
|
|
|
8
8
|
class GetAPICommand extends BaseCommand {
|
|
9
9
|
constructor(...props) {
|
|
@@ -64,4 +64,4 @@ GetAPICommand.flags = {
|
|
|
64
64
|
...BaseCommand.flags
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
export default GetAPICommand
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
3
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
4
|
+
import UpdateCommand from '../../support/command/update-command.js'
|
|
5
|
+
import inquirer from 'inquirer'
|
|
6
6
|
|
|
7
7
|
class PublishCommand extends UpdateCommand {
|
|
8
8
|
async run() {
|
|
@@ -50,4 +50,4 @@ PublishCommand.flags = {
|
|
|
50
50
|
...BaseCommand.flags
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
export default PublishCommand
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
const { CLIError } = require('@oclif/core/lib/errors')
|
|
9
|
-
const { postApi } = require('../../requests/api')
|
|
1
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
2
|
+
import { Args, Errors } from '@oclif/core'
|
|
3
|
+
import { noVersionRegex, apiNameRegex } from '../../support/command/parse-input.js'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
import { postApi } from '../../requests/api.js'
|
|
6
|
+
|
|
7
|
+
const { CLIError } = Errors
|
|
10
8
|
|
|
11
9
|
const getApiToRename = args => {
|
|
12
10
|
const newName = args['OWNER/API_NAME']
|
|
@@ -66,4 +64,4 @@ RenameApiCommand.args = {
|
|
|
66
64
|
|
|
67
65
|
RenameApiCommand.flags = BaseCommand.flags
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
export default RenameApiCommand
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
3
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
4
|
+
import UpdateCommand from '../../support/command/update-command.js'
|
|
5
5
|
|
|
6
6
|
class SetDefaultCommand extends UpdateCommand {
|
|
7
7
|
|
|
@@ -29,4 +29,4 @@ SetDefaultCommand.args = {
|
|
|
29
29
|
|
|
30
30
|
SetDefaultCommand.flags = BaseCommand.flags
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
export default SetDefaultCommand
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
3
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
4
|
+
import UpdateCommand from '../../support/command/update-command.js'
|
|
5
5
|
|
|
6
6
|
class UnpublishCommand extends UpdateCommand {
|
|
7
7
|
|
|
@@ -29,4 +29,4 @@ UnpublishCommand.args = {
|
|
|
29
29
|
|
|
30
30
|
UnpublishCommand.flags = BaseCommand.flags
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
export default UnpublishCommand
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { getApi, postApi } from '../../requests/api.js'
|
|
4
|
+
import { getApiIdentifierArg, splitPathParams } from '../../support/command/parse-input.js'
|
|
5
|
+
import { getVersion, parseDefinition } from '../../utils/definitions.js'
|
|
6
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
7
|
+
import UpdateCommand from '../../support/command/update-command.js'
|
|
8
8
|
|
|
9
9
|
class UpdateAPICommand extends UpdateCommand {
|
|
10
10
|
|
|
@@ -107,4 +107,4 @@ UpdateAPICommand.flags = {
|
|
|
107
107
|
...BaseCommand.flags
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
export default UpdateAPICommand
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Flags, Args } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../../support/command/base-command.js'
|
|
3
|
+
import { pipeAsync } from '../../../utils/general.js'
|
|
4
|
+
import { getResponseContent } from '../../../support/command/handle-response.js'
|
|
5
|
+
import { getStandardization } from '../../../requests/standardization.js'
|
|
6
6
|
|
|
7
7
|
class ValidateDownloadRulesCommand extends BaseCommand {
|
|
8
8
|
async run() {
|
|
@@ -57,4 +57,4 @@ ValidateDownloadRulesCommand.flags = {
|
|
|
57
57
|
}),
|
|
58
58
|
...BaseCommand.flags
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
export default ValidateDownloadRulesCommand
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import BaseValidateCommand from '../../../support/command/base-validate-command.js'
|
|
3
|
+
import { getApiIdentifierArg } from '../../../support/command/parse-input.js'
|
|
4
|
+
import { getApi } from '../../../requests/api.js'
|
|
5
|
+
import { pipeAsync } from '../../../utils/general.js'
|
|
6
|
+
import { getResponseContent } from '../../../support/command/handle-response.js'
|
|
7
|
+
import { isOnPrem } from '../../../support/isOnPrem.js'
|
|
8
8
|
|
|
9
9
|
class ValidateCommand extends BaseValidateCommand {
|
|
10
10
|
async run() {
|
|
@@ -72,4 +72,4 @@ ValidateCommand.args = {
|
|
|
72
72
|
ValidateCommand.flags = {
|
|
73
73
|
...BaseValidateCommand.flags
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
export default ValidateCommand
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Flags } from '@oclif/core'
|
|
2
|
+
import BaseValidateCommand from '../../../support/command/base-validate-command.js'
|
|
3
|
+
import { pipeAsync } from '../../../utils/general.js'
|
|
4
|
+
import { getResponseContent } from '../../../support/command/handle-response.js'
|
|
5
|
+
import { postStandardization } from '../../../requests/standardization.js'
|
|
6
|
+
import { parseDefinition, getSpecification, getVersion } from '../../../utils/definitions.js'
|
|
7
|
+
import { readFileSync } from 'node:fs'
|
|
8
8
|
|
|
9
9
|
class ValidateLocalCommand extends BaseValidateCommand {
|
|
10
10
|
async run() {
|
|
@@ -57,4 +57,4 @@ ValidateLocalCommand.flags = {
|
|
|
57
57
|
}),
|
|
58
58
|
...BaseValidateCommand.flags
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
export default ValidateLocalCommand
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import BaseCommand from '../support/command/base-command.js'
|
|
3
|
+
import inquirer from 'inquirer'
|
|
4
|
+
import { getPrompts } from '../support/inquirer/index.js'
|
|
5
|
+
import { setConfig, getConfig } from '../config/index.js'
|
|
6
6
|
|
|
7
7
|
class ConfigureCommand extends BaseCommand {
|
|
8
8
|
async run() {
|
|
@@ -23,5 +23,5 @@ Customers with on-premise installations (version 2.x) need to point this to thei
|
|
|
23
23
|
Enter the API Key - this can be retrieved from https://app.swaggerhub.com/settings/apiKey
|
|
24
24
|
You can set these as environment variables: SWAGGERHUB_URL, SWAGGERHUB_API_KEY. These take priority over config settings.
|
|
25
25
|
`
|
|
26
|
-
|
|
26
|
+
export default ConfigureCommand
|
|
27
27
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import BaseCommand from '../../support/command/base-command.js'
|
|
2
|
+
import { Args, Flags, Errors } from '@oclif/core'
|
|
3
|
+
import { getDomainIdentifierArg, apiNameRegex } from '../../support/command/parse-input.js'
|
|
4
|
+
import { errorMsg } from '../../template-strings/index.js'
|
|
5
|
+
import { postDomain } from '../../requests/domain.js'
|
|
6
|
+
|
|
7
|
+
const { CLIError } = Errors
|
|
7
8
|
|
|
8
9
|
const getNewVersion = args => {
|
|
9
10
|
const newVersion = args['NEW_VERSION']
|
|
@@ -62,4 +63,4 @@ CloneDomainCommand.flags = {
|
|
|
62
63
|
...BaseCommand.flags
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
export default CloneDomainCommand
|