swaggerhub-cli 0.8.1 → 0.9.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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "swaggerhub-cli",
3
3
  "description": "SwaggerHub CLI",
4
- "version": "0.8.1",
4
+ "version": "0.9.0",
5
5
  "author": "SmartBear",
6
6
  "bin": {
7
7
  "swaggerhub": "./bin/run"
8
8
  },
9
9
  "bugs": "https://github.com/SmartBear/swaggerhub-cli/issues",
10
10
  "dependencies": {
11
- "@oclif/core": "^2.11.5",
12
- "@oclif/plugin-help": "^5.2.15",
11
+ "@oclif/core": "^3.3.1",
12
+ "@oclif/plugin-help": "^6.0.3",
13
13
  "@oclif/plugin-plugins": "^3.1.8",
14
14
  "deep-extend": "^0.6.0",
15
15
  "fs-extra": "^11.1.1",
@@ -27,12 +27,12 @@
27
27
  "eslint-plugin-immutable": "^1.0.0",
28
28
  "eslint-plugin-mocha": "^10.1.0",
29
29
  "eslint-plugin-node": "^11.1.0",
30
- "globby": "^13.2.2",
30
+ "globby": "^14.0.0",
31
31
  "husky": "^8.0.3",
32
32
  "mocha": "^10.2.0",
33
33
  "nock": "^13.3.2",
34
34
  "nyc": "^15.1.0",
35
- "rewire": "^6.0.0",
35
+ "rewire": "^7.0.0",
36
36
  "tmp": "^0.2.1"
37
37
  },
38
38
  "engines": {
@@ -0,0 +1,58 @@
1
+ const { Flags, Args } = require('@oclif/core')
2
+ const BaseCommand = require('../../../support/command/base-command')
3
+ const { pipeAsync } = require('../../../utils/general')
4
+ const { getResponseContent } = require('../../../support/command/handle-response')
5
+ const { getStandardization } = require('../../../requests/standardization')
6
+
7
+ class ValidateDownloadRulesCommand extends BaseCommand {
8
+ async run() {
9
+ const { args, flags } = await this.parse(ValidateDownloadRulesCommand)
10
+
11
+ const includeSystemRules = flags['include-system-rules'] ?? false
12
+ const includeDisabledRules = flags['include-disabled-rules'] ?? false
13
+ const organization = args['OWNER']
14
+
15
+ const organizationRuleset = await this.getExportedOrganizationRuleset(organization, {includeSystemRules, includeDisabledRules})
16
+ this.log(JSON.stringify(organizationRuleset, null, 2))
17
+ }
18
+
19
+ getExportedOrganizationRuleset(orgName, queryParams) {
20
+ return this.executeHttp({
21
+ execute: () => getStandardization([orgName, 'spectral'], queryParams),
22
+ onResolve: pipeAsync(getResponseContent, JSON.parse),
23
+ options: {}
24
+ })
25
+ }
26
+ }
27
+
28
+ ValidateDownloadRulesCommand.description = `Get existing SwaggerHub's organization standardization ruleset.
29
+ Requires organization name argument. An error will occur if provided organization doesn't exist
30
+ or your account is not permitted to access that organization's settings.
31
+ If the flag \`-s\` or \`--include-system-rules\` is used, the returned ruleset will also include SwaggerHub system rules.
32
+ If the flag \`-d\` or \`--include-disabled-rules\` is used, the returned ruleset will also include disabled custom rules`
33
+
34
+ ValidateDownloadRulesCommand.examples = [
35
+ 'swaggerhub api:validate:download-rules myOrg -s',
36
+ 'swaggerhub api:validate:download-rules myOrg --include-disabled-rules -s',
37
+ ]
38
+
39
+ ValidateDownloadRulesCommand.args = {
40
+ 'OWNER': Args.string({
41
+ required: true,
42
+ description: 'Which organization standardization rules to fetch from SwaggerHub'
43
+ })
44
+ }
45
+ ValidateDownloadRulesCommand.flags = {
46
+ 'include-system-rules': Flags.boolean({
47
+ char: 's',
48
+ description: 'Includes system rules in fetched organization\'s ruleset',
49
+ required: false
50
+ }),
51
+ 'include-disabled-rules': Flags.boolean({
52
+ char: 'd',
53
+ description: 'Includes disabled rules in fetched organization\'s ruleset',
54
+ required: false
55
+ }),
56
+ ...BaseCommand.flags
57
+ }
58
+ module.exports = ValidateDownloadRulesCommand
@@ -15,6 +15,19 @@ const postStandardization = (pathParams, body) => {
15
15
  })
16
16
  }
17
17
 
18
+ const getStandardization = (pathParams, queryParams) => {
19
+ const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
20
+
21
+ return http({
22
+ url: [SWAGGERHUB_URL, 'standardization', ...pathParams],
23
+ query: queryParams,
24
+ accept: 'json',
25
+ auth: SWAGGERHUB_API_KEY,
26
+ method: 'GET',
27
+ })
28
+ }
29
+
18
30
  module.exports = {
19
- postStandardization
31
+ postStandardization,
32
+ getStandardization
20
33
  }