swaggerhub-cli 0.9.0 → 0.10.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 CHANGED
@@ -16,7 +16,7 @@ The SwaggerHub CLI enables teams to build automation and workflows around Swagge
16
16
  * [Contributing](#contributing)
17
17
  <!-- tocstop -->
18
18
  # Requirements
19
- Node.js 16.x or later.
19
+ Node.js 20.x or later.
20
20
 
21
21
  # Installation
22
22
  ```sh-session
@@ -120,7 +120,7 @@ USAGE
120
120
  * [`swaggerhub domain:setdefault OWNER/DOMAIN_NAME/VERSION`](#swaggerhub-domainsetdefault)
121
121
  * [`swaggerhub domain:unpublish OWNER/DOMAIN_NAME/VERSION`](#swaggerhub-domainunpublish)
122
122
  * [`swaggerhub domain:update OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domainupdate)
123
- * [`swaggerhub help [COMMANDS]`](#swaggerhub-help)
123
+ * [`swaggerhub help [COMMAND]`](#swaggerhub-help)
124
124
  * [`swaggerhub integration:create OWNER/API_NAME/[VERSION]`](#swaggerhub-integrationcreate)
125
125
  * [`swaggerhub integration:delete OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationdelete)
126
126
  * [`swaggerhub integration:execute OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationexecute)
@@ -128,13 +128,14 @@ USAGE
128
128
  * [`swaggerhub integration:list OWNER/API_NAME/[VERSION]`](#swaggerhub-integrationlist)
129
129
  * [`swaggerhub integration:update OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationupdate)
130
130
  * [`swaggerhub plugins`](#swaggerhub-plugins)
131
- * [`swaggerhub plugins:install PLUGIN...`](#swaggerhub-pluginsinstall)
131
+ * [`swaggerhub plugins:add PLUGIN`](#swaggerhub-pluginsadd)
132
132
  * [`swaggerhub plugins:inspect PLUGIN...`](#swaggerhub-pluginsinspect)
133
- * [`swaggerhub plugins:install PLUGIN...`](#swaggerhub-pluginsinstall)
134
- * [`swaggerhub plugins:link PLUGIN`](#swaggerhub-pluginslink)
135
- * [`swaggerhub plugins:uninstall PLUGIN...`](#swaggerhub-pluginsuninstall)
136
- * [`swaggerhub plugins:uninstall PLUGIN...`](#swaggerhub-pluginsuninstall)
137
- * [`swaggerhub plugins:uninstall PLUGIN...`](#swaggerhub-pluginsuninstall)
133
+ * [`swaggerhub plugins:install PLUGIN`](#swaggerhub-pluginsinstall)
134
+ * [`swaggerhub plugins:link PATH`](#swaggerhub-pluginslink)
135
+ * [`swaggerhub plugins:remove [PLUGIN]`](#swaggerhub-pluginsremove)
136
+ * [`swaggerhub plugins:reset`](#swaggerhub-pluginsreset)
137
+ * [`swaggerhub plugins:uninstall [PLUGIN]`](#swaggerhub-pluginsuninstall)
138
+ * [`swaggerhub plugins:unlink [PLUGIN]`](#swaggerhub-pluginsunlink)
138
139
  * [`swaggerhub plugins:update`](#swaggerhub-pluginsupdate)
139
140
  * [`swaggerhub project:api:add OWNER/PROJECT_NAME API`](#swaggerhub-projectapiadd)
140
141
  * [`swaggerhub project:api:remove OWNER/PROJECT_NAME API`](#swaggerhub-projectapiremove)
@@ -145,6 +146,8 @@ USAGE
145
146
  * [`swaggerhub project:get OWNER/PROJECT_NAME`](#swaggerhub-projectget)
146
147
  * [`swaggerhub project:list [OWNER]`](#swaggerhub-projectlist)
147
148
  * [`swaggerhub project:member:list OWNER/PROJECT_NAME`](#swaggerhub-projectmemberlist)
149
+ * [`swaggerhub spectral:upload OWNER/RULESET_NAME directory`](#swaggerhub-spectralupload)
150
+ * [`swaggerhub spectral:download OWNER/RULESET_NAME directory`](#swaggerhub-spectraldownload)
148
151
 
149
152
  ## `swaggerhub api:create`
150
153
 
@@ -159,13 +162,13 @@ ARGUMENTS
159
162
  OWNER/API_NAME/[VERSION] API to create on SwaggerHub
160
163
 
161
164
  FLAGS
162
- -f, --file=<value> (required) file location of API to create
163
- -h, --help Show CLI help.
164
- --published=<option> [default: unpublish] sets the lifecycle setting of the API version
165
- <options: publish|unpublish>
166
- --setdefault sets API version to be the default
167
- --visibility=<option> [default: private] visibility of API in SwaggerHub
168
- <options: public|private>
165
+ -f, --file=<value> (required) file location of API to create
166
+ -h, --help Show CLI help.
167
+ --published=<option> [default: unpublish] sets the lifecycle setting of the API version
168
+ <options: publish|unpublish>
169
+ --setdefault sets API version to be the default
170
+ --visibility=<option> [default: private] visibility of API in SwaggerHub
171
+ <options: public|private>
169
172
 
170
173
  DESCRIPTION
171
174
  creates a new API / API version from a YAML/JSON file
@@ -185,7 +188,7 @@ EXAMPLES
185
188
  $ swaggerhub api:create organization/api/1.0.0 --published=publish --setdefault --file api.json
186
189
  ```
187
190
 
188
- _See code: [src/commands/api/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/create.js)_
191
+ _See code: [src/commands/api/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/create.js)_
189
192
 
190
193
  ## `swaggerhub api:delete`
191
194
 
@@ -214,7 +217,7 @@ EXAMPLES
214
217
  $ swaggerhub api:delete organization/api --force
215
218
  ```
216
219
 
217
- _See code: [src/commands/api/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/delete.js)_
220
+ _See code: [src/commands/api/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/delete.js)_
218
221
 
219
222
  ## `swaggerhub api:get`
220
223
 
@@ -244,7 +247,7 @@ EXAMPLES
244
247
  $ swaggerhub api:get organization/api/1.0.0 --json
245
248
  ```
246
249
 
247
- _See code: [src/commands/api/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/get.js)_
250
+ _See code: [src/commands/api/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/get.js)_
248
251
 
249
252
  ## `swaggerhub api:publish`
250
253
 
@@ -270,7 +273,7 @@ EXAMPLES
270
273
  $ swaggerhub api:publish organization/api/1.0.0 --force
271
274
  ```
272
275
 
273
- _See code: [src/commands/api/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/publish.js)_
276
+ _See code: [src/commands/api/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/publish.js)_
274
277
 
275
278
  ## `swaggerhub api:setdefault`
276
279
 
@@ -293,7 +296,7 @@ EXAMPLES
293
296
  $ swaggerhub api:setdefault organization/api/2.0.0
294
297
  ```
295
298
 
296
- _See code: [src/commands/api/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/setdefault.js)_
299
+ _See code: [src/commands/api/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/setdefault.js)_
297
300
 
298
301
  ## `swaggerhub api:unpublish`
299
302
 
@@ -316,7 +319,7 @@ EXAMPLES
316
319
  $ swaggerhub api:unpublish organization/api/1.0.0
317
320
  ```
318
321
 
319
- _See code: [src/commands/api/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/unpublish.js)_
322
+ _See code: [src/commands/api/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/unpublish.js)_
320
323
 
321
324
  ## `swaggerhub api:update`
322
325
 
@@ -331,13 +334,13 @@ ARGUMENTS
331
334
  OWNER/API_NAME/[VERSION] API to update on SwaggerHub
332
335
 
333
336
  FLAGS
334
- -f, --file=<value> file location of API to update
335
- -h, --help Show CLI help.
336
- --published=<option> sets the lifecycle setting of the API version
337
- <options: publish|unpublish>
338
- --setdefault sets API version to be the default
339
- --visibility=<option> visibility of API in SwaggerHub
340
- <options: public|private>
337
+ -f, --file=<value> file location of API to update
338
+ -h, --help Show CLI help.
339
+ --published=<option> sets the lifecycle setting of the API version
340
+ <options: publish|unpublish>
341
+ --setdefault sets API version to be the default
342
+ --visibility=<option> visibility of API in SwaggerHub
343
+ <options: public|private>
341
344
 
342
345
  DESCRIPTION
343
346
  update an API
@@ -360,7 +363,7 @@ EXAMPLES
360
363
  $ swaggerhub api:update organization/api/1.0.0 --visibility=private
361
364
  ```
362
365
 
363
- _See code: [src/commands/api/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/update.js)_
366
+ _See code: [src/commands/api/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/update.js)_
364
367
 
365
368
  ## `swaggerhub api:validate`
366
369
 
@@ -394,7 +397,7 @@ EXAMPLES
394
397
  $ swaggerhub api:validate --fail-on-critical --json organization/api
395
398
  ```
396
399
 
397
- _See code: [src/commands/api/validate/index.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/validate/index.js)_
400
+ _See code: [src/commands/api/validate/index.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/validate/index.js)_
398
401
 
399
402
  ## `swaggerhub api:validate:download-rules`
400
403
 
@@ -425,7 +428,7 @@ EXAMPLES
425
428
  $ swaggerhub api:validate:download-rules myOrg --include-disabled-rules -s
426
429
  ```
427
430
 
428
- _See code: [src/commands/api/validate/download-rules.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/validate/download-rules.js)_
431
+ _See code: [src/commands/api/validate/download-rules.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/validate/download-rules.js)_
429
432
 
430
433
  ## `swaggerhub api:validate:local`
431
434
 
@@ -455,7 +458,7 @@ EXAMPLES
455
458
  $ swaggerhub api:validate:local --organization myOrg --file ./my-api/json --fail-on-critical --json
456
459
  ```
457
460
 
458
- _See code: [src/commands/api/validate/local.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/api/validate/local.js)_
461
+ _See code: [src/commands/api/validate/local.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/api/validate/local.js)_
459
462
 
460
463
  ## `swaggerhub configure`
461
464
 
@@ -478,7 +481,7 @@ DESCRIPTION
478
481
  settings.
479
482
  ```
480
483
 
481
- _See code: [src/commands/configure.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/configure.js)_
484
+ _See code: [src/commands/configure.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/configure.js)_
482
485
 
483
486
  ## `swaggerhub domain:create`
484
487
 
@@ -493,13 +496,13 @@ ARGUMENTS
493
496
  OWNER/DOMAIN_NAME/[VERSION] Domain to create on SwaggerHub
494
497
 
495
498
  FLAGS
496
- -f, --file=<value> (required) file location of domain to create
497
- -h, --help Show CLI help.
498
- --published=<option> [default: unpublish] sets the lifecycle setting of the domain version
499
- <options: publish|unpublish>
500
- --setdefault sets domain version to be the default
501
- --visibility=<option> [default: private] visibility of domain in SwaggerHub
502
- <options: public|private>
499
+ -f, --file=<value> (required) file location of domain to create
500
+ -h, --help Show CLI help.
501
+ --published=<option> [default: unpublish] sets the lifecycle setting of the domain version
502
+ <options: publish|unpublish>
503
+ --setdefault sets domain version to be the default
504
+ --visibility=<option> [default: private] visibility of domain in SwaggerHub
505
+ <options: public|private>
503
506
 
504
507
  DESCRIPTION
505
508
  creates a new domain / domain version from a YAML/JSON file
@@ -519,7 +522,7 @@ EXAMPLES
519
522
  $ swaggerhub domain:create organization/domain/1.0.0 --publish --setdefault --file domain.json
520
523
  ```
521
524
 
522
- _See code: [src/commands/domain/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/create.js)_
525
+ _See code: [src/commands/domain/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/create.js)_
523
526
 
524
527
  ## `swaggerhub domain:delete`
525
528
 
@@ -548,7 +551,7 @@ EXAMPLES
548
551
  $ swaggerhub domain:delete organization/domain --force
549
552
  ```
550
553
 
551
- _See code: [src/commands/domain/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/delete.js)_
554
+ _See code: [src/commands/domain/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/delete.js)_
552
555
 
553
556
  ## `swaggerhub domain:get`
554
557
 
@@ -577,7 +580,7 @@ EXAMPLES
577
580
  $ swaggerhub domain:get organization/domain/1.0.0 --json
578
581
  ```
579
582
 
580
- _See code: [src/commands/domain/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/get.js)_
583
+ _See code: [src/commands/domain/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/get.js)_
581
584
 
582
585
  ## `swaggerhub domain:publish`
583
586
 
@@ -600,7 +603,7 @@ EXAMPLES
600
603
  $ swaggerhub domain:publish organization/domain/1.0.0
601
604
  ```
602
605
 
603
- _See code: [src/commands/domain/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/publish.js)_
606
+ _See code: [src/commands/domain/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/publish.js)_
604
607
 
605
608
  ## `swaggerhub domain:setdefault`
606
609
 
@@ -623,7 +626,7 @@ EXAMPLES
623
626
  $ swaggerhub domain:setdefault organization/domain/2.0.0
624
627
  ```
625
628
 
626
- _See code: [src/commands/domain/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/setdefault.js)_
629
+ _See code: [src/commands/domain/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/setdefault.js)_
627
630
 
628
631
  ## `swaggerhub domain:unpublish`
629
632
 
@@ -646,7 +649,7 @@ EXAMPLES
646
649
  $ swaggerhub domain:unpublish organization/domain/1.0.0
647
650
  ```
648
651
 
649
- _See code: [src/commands/domain/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/unpublish.js)_
652
+ _See code: [src/commands/domain/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/unpublish.js)_
650
653
 
651
654
  ## `swaggerhub domain:update`
652
655
 
@@ -661,13 +664,13 @@ ARGUMENTS
661
664
  OWNER/DOMAIN_NAME/[VERSION] Domain to update on SwaggerHub
662
665
 
663
666
  FLAGS
664
- -f, --file=<value> file location of domain to update
665
- -h, --help Show CLI help.
666
- --published=<option> sets the lifecycle setting of the domain version
667
- <options: publish|unpublish>
668
- --setdefault sets domain version to be the default
669
- --visibility=<option> visibility of domain in SwaggerHub
670
- <options: public|private>
667
+ -f, --file=<value> file location of domain to update
668
+ -h, --help Show CLI help.
669
+ --published=<option> sets the lifecycle setting of the domain version
670
+ <options: publish|unpublish>
671
+ --setdefault sets domain version to be the default
672
+ --visibility=<option> visibility of domain in SwaggerHub
673
+ <options: public|private>
671
674
 
672
675
  DESCRIPTION
673
676
  update a domain
@@ -690,7 +693,7 @@ EXAMPLES
690
693
  $ swaggerhub domain:update organization/domain/1.0.0 --visibility=private
691
694
  ```
692
695
 
693
- _See code: [src/commands/domain/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/domain/update.js)_
696
+ _See code: [src/commands/domain/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/domain/update.js)_
694
697
 
695
698
  ## `swaggerhub help`
696
699
 
@@ -698,10 +701,10 @@ Display help for swaggerhub.
698
701
 
699
702
  ```
700
703
  USAGE
701
- $ swaggerhub help [COMMANDS] [-n]
704
+ $ swaggerhub help [COMMAND...] [-n]
702
705
 
703
706
  ARGUMENTS
704
- COMMANDS Command to show help for.
707
+ COMMAND... Command to show help for.
705
708
 
706
709
  FLAGS
707
710
  -n, --nested-commands Include all nested commands in the output.
@@ -710,7 +713,7 @@ DESCRIPTION
710
713
  Display help for swaggerhub.
711
714
  ```
712
715
 
713
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.3/src/commands/help.ts)_
716
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.22/src/commands/help.ts)_
714
717
 
715
718
  ## `swaggerhub integration:create`
716
719
 
@@ -738,7 +741,7 @@ EXAMPLES
738
741
  $ swaggerhub integration:create organization/api/1.0.0 --file config.json
739
742
  ```
740
743
 
741
- _See code: [src/commands/integration/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/create.js)_
744
+ _See code: [src/commands/integration/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/create.js)_
742
745
 
743
746
  ## `swaggerhub integration:delete`
744
747
 
@@ -761,7 +764,7 @@ EXAMPLES
761
764
  $ swaggerhub integration:delete organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
762
765
  ```
763
766
 
764
- _See code: [src/commands/integration/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/delete.js)_
767
+ _See code: [src/commands/integration/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/delete.js)_
765
768
 
766
769
  ## `swaggerhub integration:execute`
767
770
 
@@ -784,7 +787,7 @@ EXAMPLES
784
787
  $ swaggerhub integration:execute organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
785
788
  ```
786
789
 
787
- _See code: [src/commands/integration/execute.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/execute.js)_
790
+ _See code: [src/commands/integration/execute.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/execute.js)_
788
791
 
789
792
  ## `swaggerhub integration:get`
790
793
 
@@ -807,7 +810,7 @@ EXAMPLES
807
810
  $ swaggerhub integration:get organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
808
811
  ```
809
812
 
810
- _See code: [src/commands/integration/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/get.js)_
813
+ _See code: [src/commands/integration/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/get.js)_
811
814
 
812
815
  ## `swaggerhub integration:list`
813
816
 
@@ -830,7 +833,7 @@ EXAMPLES
830
833
  $ swaggerhub integration:list organization/api/1.0.0
831
834
  ```
832
835
 
833
- _See code: [src/commands/integration/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/list.js)_
836
+ _See code: [src/commands/integration/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/list.js)_
834
837
 
835
838
  ## `swaggerhub integration:update`
836
839
 
@@ -854,7 +857,7 @@ EXAMPLES
854
857
  $ swaggerhub integration:update organization/api/1.0.0/503c2db6-448a-4678-abcd-0123456789abc --file config.json
855
858
  ```
856
859
 
857
- _See code: [src/commands/integration/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/integration/update.js)_
860
+ _See code: [src/commands/integration/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/integration/update.js)_
858
861
 
859
862
  ## `swaggerhub plugins`
860
863
 
@@ -877,44 +880,53 @@ EXAMPLES
877
880
  $ swaggerhub plugins
878
881
  ```
879
882
 
880
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/index.ts)_
883
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/index.ts)_
881
884
 
882
- ## `swaggerhub plugins:install`
885
+ ## `swaggerhub plugins:add`
883
886
 
884
- Installs a plugin into the CLI.
887
+ Installs a plugin into swaggerhub.
885
888
 
886
889
  ```
887
890
  USAGE
888
- $ swaggerhub plugins:install PLUGIN...
891
+ $ swaggerhub plugins:add PLUGIN... [--json] [-f] [-h] [-s | -v]
889
892
 
890
893
  ARGUMENTS
891
- PLUGIN Plugin to install.
894
+ PLUGIN... Plugin to install.
892
895
 
893
896
  FLAGS
894
- -f, --force Run yarn install with force flag.
897
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
895
898
  -h, --help Show CLI help.
896
- -v, --verbose
899
+ -s, --silent Silences npm output.
900
+ -v, --verbose Show verbose npm output.
901
+
902
+ GLOBAL FLAGS
903
+ --json Format output as json.
897
904
 
898
905
  DESCRIPTION
899
- Installs a plugin into the CLI.
900
- Can be installed from npm or a git url.
906
+ Installs a plugin into swaggerhub.
901
907
 
902
- Installation of a user-installed plugin will override a core plugin.
908
+ Uses npm to install plugins.
903
909
 
904
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
905
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
906
- the CLI without the need to patch and update the whole CLI.
910
+ Installation of a user-installed plugin will override a core plugin.
907
911
 
912
+ Use the SWAGGERHUB_NPM_LOG_LEVEL environment variable to set the npm loglevel.
913
+ Use the SWAGGERHUB_NPM_REGISTRY environment variable to set the npm registry.
908
914
 
909
915
  ALIASES
910
916
  $ swaggerhub plugins:add
911
917
 
912
918
  EXAMPLES
913
- $ swaggerhub plugins:install myplugin
919
+ Install a plugin from npm registry.
920
+
921
+ $ swaggerhub plugins:add myplugin
922
+
923
+ Install a plugin from a github url.
914
924
 
915
- $ swaggerhub plugins:install https://github.com/someuser/someplugin
925
+ $ swaggerhub plugins:add https://github.com/someuser/someplugin
916
926
 
917
- $ swaggerhub plugins:install someuser/someplugin
927
+ Install a plugin from a github slug.
928
+
929
+ $ swaggerhub plugins:add someuser/someplugin
918
930
  ```
919
931
 
920
932
  ## `swaggerhub plugins:inspect`
@@ -926,7 +938,7 @@ USAGE
926
938
  $ swaggerhub plugins:inspect PLUGIN...
927
939
 
928
940
  ARGUMENTS
929
- PLUGIN [default: .] Plugin to inspect.
941
+ PLUGIN... [default: .] Plugin to inspect.
930
942
 
931
943
  FLAGS
932
944
  -h, --help Show CLI help.
@@ -942,47 +954,56 @@ EXAMPLES
942
954
  $ swaggerhub plugins:inspect myplugin
943
955
  ```
944
956
 
945
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/inspect.ts)_
957
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/inspect.ts)_
946
958
 
947
959
  ## `swaggerhub plugins:install`
948
960
 
949
- Installs a plugin into the CLI.
961
+ Installs a plugin into swaggerhub.
950
962
 
951
963
  ```
952
964
  USAGE
953
- $ swaggerhub plugins:install PLUGIN...
965
+ $ swaggerhub plugins:install PLUGIN... [--json] [-f] [-h] [-s | -v]
954
966
 
955
967
  ARGUMENTS
956
- PLUGIN Plugin to install.
968
+ PLUGIN... Plugin to install.
957
969
 
958
970
  FLAGS
959
- -f, --force Run yarn install with force flag.
971
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
960
972
  -h, --help Show CLI help.
961
- -v, --verbose
973
+ -s, --silent Silences npm output.
974
+ -v, --verbose Show verbose npm output.
975
+
976
+ GLOBAL FLAGS
977
+ --json Format output as json.
962
978
 
963
979
  DESCRIPTION
964
- Installs a plugin into the CLI.
965
- Can be installed from npm or a git url.
980
+ Installs a plugin into swaggerhub.
966
981
 
967
- Installation of a user-installed plugin will override a core plugin.
982
+ Uses npm to install plugins.
968
983
 
969
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
970
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
971
- the CLI without the need to patch and update the whole CLI.
984
+ Installation of a user-installed plugin will override a core plugin.
972
985
 
986
+ Use the SWAGGERHUB_NPM_LOG_LEVEL environment variable to set the npm loglevel.
987
+ Use the SWAGGERHUB_NPM_REGISTRY environment variable to set the npm registry.
973
988
 
974
989
  ALIASES
975
990
  $ swaggerhub plugins:add
976
991
 
977
992
  EXAMPLES
978
- $ swaggerhub plugins:install myplugin
993
+ Install a plugin from npm registry.
994
+
995
+ $ swaggerhub plugins:install myplugin
996
+
997
+ Install a plugin from a github url.
979
998
 
980
- $ swaggerhub plugins:install https://github.com/someuser/someplugin
999
+ $ swaggerhub plugins:install https://github.com/someuser/someplugin
981
1000
 
982
- $ swaggerhub plugins:install someuser/someplugin
1001
+ Install a plugin from a github slug.
1002
+
1003
+ $ swaggerhub plugins:install someuser/someplugin
983
1004
  ```
984
1005
 
985
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/install.ts)_
1006
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/install.ts)_
986
1007
 
987
1008
  ## `swaggerhub plugins:link`
988
1009
 
@@ -990,18 +1011,19 @@ Links a plugin into the CLI for development.
990
1011
 
991
1012
  ```
992
1013
  USAGE
993
- $ swaggerhub plugins:link PLUGIN
1014
+ $ swaggerhub plugins:link PATH [-h] [--install] [-v]
994
1015
 
995
1016
  ARGUMENTS
996
1017
  PATH [default: .] path to plugin
997
1018
 
998
1019
  FLAGS
999
- -h, --help Show CLI help.
1020
+ -h, --help Show CLI help.
1000
1021
  -v, --verbose
1001
- --[no-]install Install dependencies after linking the plugin.
1022
+ --[no-]install Install dependencies after linking the plugin.
1002
1023
 
1003
1024
  DESCRIPTION
1004
1025
  Links a plugin into the CLI for development.
1026
+
1005
1027
  Installation of a linked plugin will override a user-installed or core plugin.
1006
1028
 
1007
1029
  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
@@ -1012,18 +1034,18 @@ EXAMPLES
1012
1034
  $ swaggerhub plugins:link myplugin
1013
1035
  ```
1014
1036
 
1015
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/link.ts)_
1037
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/link.ts)_
1016
1038
 
1017
- ## `swaggerhub plugins:uninstall`
1039
+ ## `swaggerhub plugins:remove`
1018
1040
 
1019
1041
  Removes a plugin from the CLI.
1020
1042
 
1021
1043
  ```
1022
1044
  USAGE
1023
- $ swaggerhub plugins:uninstall PLUGIN...
1045
+ $ swaggerhub plugins:remove [PLUGIN...] [-h] [-v]
1024
1046
 
1025
1047
  ARGUMENTS
1026
- PLUGIN plugin to uninstall
1048
+ PLUGIN... plugin to uninstall
1027
1049
 
1028
1050
  FLAGS
1029
1051
  -h, --help Show CLI help.
@@ -1035,7 +1057,25 @@ DESCRIPTION
1035
1057
  ALIASES
1036
1058
  $ swaggerhub plugins:unlink
1037
1059
  $ swaggerhub plugins:remove
1060
+
1061
+ EXAMPLES
1062
+ $ swaggerhub plugins:remove myplugin
1063
+ ```
1064
+
1065
+ ## `swaggerhub plugins:reset`
1066
+
1067
+ Remove all user-installed and linked plugins.
1068
+
1038
1069
  ```
1070
+ USAGE
1071
+ $ swaggerhub plugins:reset [--hard] [--reinstall]
1072
+
1073
+ FLAGS
1074
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
1075
+ --reinstall Reinstall all plugins after uninstalling.
1076
+ ```
1077
+
1078
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/reset.ts)_
1039
1079
 
1040
1080
  ## `swaggerhub plugins:uninstall`
1041
1081
 
@@ -1043,10 +1083,10 @@ Removes a plugin from the CLI.
1043
1083
 
1044
1084
  ```
1045
1085
  USAGE
1046
- $ swaggerhub plugins:uninstall PLUGIN...
1086
+ $ swaggerhub plugins:uninstall [PLUGIN...] [-h] [-v]
1047
1087
 
1048
1088
  ARGUMENTS
1049
- PLUGIN plugin to uninstall
1089
+ PLUGIN... plugin to uninstall
1050
1090
 
1051
1091
  FLAGS
1052
1092
  -h, --help Show CLI help.
@@ -1058,20 +1098,23 @@ DESCRIPTION
1058
1098
  ALIASES
1059
1099
  $ swaggerhub plugins:unlink
1060
1100
  $ swaggerhub plugins:remove
1101
+
1102
+ EXAMPLES
1103
+ $ swaggerhub plugins:uninstall myplugin
1061
1104
  ```
1062
1105
 
1063
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/uninstall.ts)_
1106
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/uninstall.ts)_
1064
1107
 
1065
- ## `swaggerhub plugins:uninstall`
1108
+ ## `swaggerhub plugins:unlink`
1066
1109
 
1067
1110
  Removes a plugin from the CLI.
1068
1111
 
1069
1112
  ```
1070
1113
  USAGE
1071
- $ swaggerhub plugins:uninstall PLUGIN...
1114
+ $ swaggerhub plugins:unlink [PLUGIN...] [-h] [-v]
1072
1115
 
1073
1116
  ARGUMENTS
1074
- PLUGIN plugin to uninstall
1117
+ PLUGIN... plugin to uninstall
1075
1118
 
1076
1119
  FLAGS
1077
1120
  -h, --help Show CLI help.
@@ -1083,6 +1126,9 @@ DESCRIPTION
1083
1126
  ALIASES
1084
1127
  $ swaggerhub plugins:unlink
1085
1128
  $ swaggerhub plugins:remove
1129
+
1130
+ EXAMPLES
1131
+ $ swaggerhub plugins:unlink myplugin
1086
1132
  ```
1087
1133
 
1088
1134
  ## `swaggerhub plugins:update`
@@ -1101,7 +1147,7 @@ DESCRIPTION
1101
1147
  Update installed plugins.
1102
1148
  ```
1103
1149
 
1104
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.1/src/commands/plugins/update.ts)_
1150
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/update.ts)_
1105
1151
 
1106
1152
  ## `swaggerhub project:api:add`
1107
1153
 
@@ -1125,7 +1171,7 @@ EXAMPLES
1125
1171
  $ swaggerhub project:api:add organization/project_name my_api
1126
1172
  ```
1127
1173
 
1128
- _See code: [src/commands/project/api/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/api/add.js)_
1174
+ _See code: [src/commands/project/api/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/api/add.js)_
1129
1175
 
1130
1176
  ## `swaggerhub project:api:remove`
1131
1177
 
@@ -1149,7 +1195,7 @@ EXAMPLES
1149
1195
  $ swaggerhub project:api:remove organization/project_name my_api
1150
1196
  ```
1151
1197
 
1152
- _See code: [src/commands/project/api/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/api/remove.js)_
1198
+ _See code: [src/commands/project/api/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/api/remove.js)_
1153
1199
 
1154
1200
  ## `swaggerhub project:create`
1155
1201
 
@@ -1163,10 +1209,10 @@ ARGUMENTS
1163
1209
  OWNER/PROJECT_NAME The new project to create on Swaggerhub
1164
1210
 
1165
1211
  FLAGS
1166
- -a, --apis=<value> Comma separated list of api names to include in project
1167
- -d, --domains=<value> Comma separated list of domain names to include in project
1168
- -h, --help Show CLI help.
1169
- --description=<value> Description of project
1212
+ -a, --apis=<value> Comma separated list of api names to include in project
1213
+ -d, --domains=<value> Comma separated list of domain names to include in project
1214
+ -h, --help Show CLI help.
1215
+ --description=<value> Description of project
1170
1216
 
1171
1217
  DESCRIPTION
1172
1218
  Creates a new project in SwaggerHub.
@@ -1185,7 +1231,7 @@ EXAMPLES
1185
1231
  $ swaggerhub project:create organization/new_project_name -a "testapi1" -d "testdomain3" --description "description"
1186
1232
  ```
1187
1233
 
1188
- _See code: [src/commands/project/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/create.js)_
1234
+ _See code: [src/commands/project/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/create.js)_
1189
1235
 
1190
1236
  ## `swaggerhub project:delete`
1191
1237
 
@@ -1208,7 +1254,7 @@ EXAMPLES
1208
1254
  $ swaggerhub project:delete organization/project_name
1209
1255
  ```
1210
1256
 
1211
- _See code: [src/commands/project/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/delete.js)_
1257
+ _See code: [src/commands/project/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/delete.js)_
1212
1258
 
1213
1259
  ## `swaggerhub project:domain:add`
1214
1260
 
@@ -1232,7 +1278,7 @@ EXAMPLES
1232
1278
  $ swaggerhub project:domain:add organization/project_name my_domain
1233
1279
  ```
1234
1280
 
1235
- _See code: [src/commands/project/domain/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/domain/add.js)_
1281
+ _See code: [src/commands/project/domain/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/domain/add.js)_
1236
1282
 
1237
1283
  ## `swaggerhub project:domain:remove`
1238
1284
 
@@ -1256,7 +1302,7 @@ EXAMPLES
1256
1302
  $ swaggerhub project:domain:remove organization/project_name my_domain
1257
1303
  ```
1258
1304
 
1259
- _See code: [src/commands/project/domain/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/domain/remove.js)_
1305
+ _See code: [src/commands/project/domain/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/domain/remove.js)_
1260
1306
 
1261
1307
  ## `swaggerhub project:get`
1262
1308
 
@@ -1279,7 +1325,7 @@ EXAMPLES
1279
1325
  $ swaggerhub project:get organization/project_name
1280
1326
  ```
1281
1327
 
1282
- _See code: [src/commands/project/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/get.js)_
1328
+ _See code: [src/commands/project/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/get.js)_
1283
1329
 
1284
1330
  ## `swaggerhub project:list`
1285
1331
 
@@ -1304,7 +1350,7 @@ EXAMPLES
1304
1350
  $ swaggerhub project:list organization
1305
1351
  ```
1306
1352
 
1307
- _See code: [src/commands/project/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/list.js)_
1353
+ _See code: [src/commands/project/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/list.js)_
1308
1354
 
1309
1355
  ## `swaggerhub project:member:list`
1310
1356
 
@@ -1327,7 +1373,56 @@ EXAMPLES
1327
1373
  $ swaggerhub project:member:list organisation/project_name
1328
1374
  ```
1329
1375
 
1330
- _See code: [src/commands/project/member/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.0/src/commands/project/member/list.js)_
1376
+ _See code: [src/commands/project/member/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/project/member/list.js)_
1377
+
1378
+ ## `swaggerhub spectral:upload`
1379
+
1380
+ Create or update organization's Spectral ruleset
1381
+
1382
+ ```
1383
+ USAGE
1384
+ $ swaggerhub spectral:upload OWNER/RULESET_NAME directory [-h]
1385
+
1386
+ ARGUMENTS
1387
+ OWNER/RULESET_NAME The Spectral ruleset details for SwaggerHub organization
1388
+ directory Relative path to directory with ruleset files
1389
+
1390
+ FLAGS
1391
+ -h, --help Show CLI help.
1392
+
1393
+ DESCRIPTION
1394
+ Create or update organization's Spectral ruleset
1395
+
1396
+ EXAMPLES
1397
+ $ swaggerhub spectral:upload my_organization/my_api_ruleset rules
1398
+ ```
1399
+
1400
+ _See code: [src/commands/spectral/upload.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/spectral/upload.js)_
1401
+
1402
+
1403
+ ## `swaggerhub spectral:download`
1404
+
1405
+ Fetch organization's Spectral ruleset
1406
+
1407
+ ```
1408
+ USAGE
1409
+ $ swaggerhub spectral:download OWNER/RULESET_NAME directory [-h]
1410
+
1411
+ ARGUMENTS
1412
+ OWNER/RULESET_NAME The Spectral ruleset details for SwaggerHub organization
1413
+ directory Relative path to directory the ruleset files should be saved to
1414
+
1415
+ FLAGS
1416
+ -h, --help Show CLI help.
1417
+
1418
+ DESCRIPTION
1419
+ Fetch organization's Spectral ruleset
1420
+
1421
+ EXAMPLES
1422
+ $ swaggerhub spectral:download my_organization/my_api_ruleset rules
1423
+ ```
1424
+
1425
+ _See code: [src/commands/spectral/download.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.9.1/src/commands/spectral/download.js)_
1331
1426
  <!-- commandsstop -->
1332
1427
 
1333
1428
  # Plugins
@@ -1219,6 +1219,92 @@
1219
1219
  "list.js"
1220
1220
  ]
1221
1221
  },
1222
+ "spectral:download": {
1223
+ "aliases": [],
1224
+ "args": {
1225
+ "OWNER/RULESET_NAME": {
1226
+ "description": "Organization's Spectral ruleset to create or update on SwaggerHub",
1227
+ "name": "OWNER/RULESET_NAME",
1228
+ "required": true
1229
+ },
1230
+ "directory": {
1231
+ "description": "Relative path to directory the ruleset files should be saved to",
1232
+ "name": "directory",
1233
+ "required": true
1234
+ }
1235
+ },
1236
+ "description": "Fetch organization's Spectral ruleset",
1237
+ "examples": [
1238
+ "swaggerhub spectral:download my_organization/my_api_ruleset rules/"
1239
+ ],
1240
+ "flags": {
1241
+ "help": {
1242
+ "char": "h",
1243
+ "description": "Show CLI help.",
1244
+ "name": "help",
1245
+ "allowNo": false,
1246
+ "type": "boolean"
1247
+ }
1248
+ },
1249
+ "hasDynamicHelp": false,
1250
+ "hiddenAliases": [],
1251
+ "id": "spectral:download",
1252
+ "pluginAlias": "swaggerhub-cli",
1253
+ "pluginName": "swaggerhub-cli",
1254
+ "pluginType": "core",
1255
+ "strict": true,
1256
+ "enableJsonFlag": false,
1257
+ "isESM": false,
1258
+ "relativePath": [
1259
+ "src",
1260
+ "commands",
1261
+ "spectral",
1262
+ "download.js"
1263
+ ]
1264
+ },
1265
+ "spectral:upload": {
1266
+ "aliases": [],
1267
+ "args": {
1268
+ "OWNER/RULESET_NAME": {
1269
+ "description": "Organization's Spectral ruleset to create or update on SwaggerHub",
1270
+ "name": "OWNER/RULESET_NAME",
1271
+ "required": true
1272
+ },
1273
+ "directory": {
1274
+ "description": "Relative path to directory with ruleset files",
1275
+ "name": "directory",
1276
+ "required": true
1277
+ }
1278
+ },
1279
+ "description": "Create or update organization's Spectral ruleset",
1280
+ "examples": [
1281
+ "swaggerhub spectral:upload my_organization/my_api_ruleset rules/"
1282
+ ],
1283
+ "flags": {
1284
+ "help": {
1285
+ "char": "h",
1286
+ "description": "Show CLI help.",
1287
+ "name": "help",
1288
+ "allowNo": false,
1289
+ "type": "boolean"
1290
+ }
1291
+ },
1292
+ "hasDynamicHelp": false,
1293
+ "hiddenAliases": [],
1294
+ "id": "spectral:upload",
1295
+ "pluginAlias": "swaggerhub-cli",
1296
+ "pluginName": "swaggerhub-cli",
1297
+ "pluginType": "core",
1298
+ "strict": true,
1299
+ "enableJsonFlag": false,
1300
+ "isESM": false,
1301
+ "relativePath": [
1302
+ "src",
1303
+ "commands",
1304
+ "spectral",
1305
+ "upload.js"
1306
+ ]
1307
+ },
1222
1308
  "api:validate:download-rules": {
1223
1309
  "aliases": [],
1224
1310
  "args": {
@@ -1612,5 +1698,5 @@
1612
1698
  ]
1613
1699
  }
1614
1700
  },
1615
- "version": "0.9.0"
1701
+ "version": "0.10.0"
1616
1702
  }
package/package.json CHANGED
@@ -1,42 +1,45 @@
1
1
  {
2
2
  "name": "swaggerhub-cli",
3
3
  "description": "SwaggerHub CLI",
4
- "version": "0.9.0",
4
+ "version": "0.10.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": "^3.3.1",
12
- "@oclif/plugin-help": "^6.0.3",
13
- "@oclif/plugin-plugins": "^3.1.8",
11
+ "@oclif/core": "^3.26.3",
12
+ "@oclif/plugin-help": "^6.0.21",
13
+ "@oclif/plugin-plugins": "^5.0.21",
14
+ "archiver": "^7.0.1",
14
15
  "deep-extend": "^0.6.0",
15
16
  "fs-extra": "^11.1.1",
16
17
  "inquirer": "^8.2.5",
17
18
  "js-yaml": "^4.1.0",
18
19
  "json-templates": "^5.0.0",
19
20
  "node-fetch": "^2.6.12",
20
- "semver": "^7.5.4"
21
+ "semver": "^7.6.0",
22
+ "unzipper": "^0.12.3"
21
23
  },
22
24
  "devDependencies": {
23
- "@oclif/test": "^2.4.2",
24
- "chai": "^4.3.7",
25
- "eslint": "^8.46.0",
26
- "eslint-plugin-chai-friendly": "^0.7.2",
25
+ "@oclif/test": "^3.2.10",
26
+ "chai": "^4.3.10",
27
+ "eslint": "^9.0.0",
28
+ "eslint-plugin-chai-friendly": "^1.0.0",
27
29
  "eslint-plugin-immutable": "^1.0.0",
28
30
  "eslint-plugin-mocha": "^10.1.0",
29
31
  "eslint-plugin-node": "^11.1.0",
30
32
  "globby": "^14.0.0",
31
- "husky": "^8.0.3",
32
- "mocha": "^10.2.0",
33
- "nock": "^13.3.2",
34
- "nyc": "^15.1.0",
33
+ "husky": "^9.0.1",
34
+ "mocha": "^11.1.0",
35
+ "nock": "^14.0.1",
36
+ "nyc": "^17.0.0",
35
37
  "rewire": "^7.0.0",
38
+ "sinon": "^19.0.2",
36
39
  "tmp": "^0.2.1"
37
40
  },
38
41
  "engines": {
39
- "node": ">=16.0.0"
42
+ "node": ">=20.0.0"
40
43
  },
41
44
  "files": [
42
45
  "/bin",
@@ -75,6 +78,9 @@
75
78
  },
76
79
  "projects": {
77
80
  "description": "this topic supports the management of Projects"
81
+ },
82
+ "spectral": {
83
+ "description": "this topic supports the management of Spectral rulesets"
78
84
  }
79
85
  },
80
86
  "helpClass": "./src/help"
@@ -0,0 +1,69 @@
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');
8
+
9
+ class DownloadSpectralRulesetCommand extends BaseCommand {
10
+ async run() {
11
+ const { args } = await this.parse(DownloadSpectralRulesetCommand)
12
+ const rulesetPath = getSpectralIdentifierArg(args)
13
+
14
+ await this.getSpectralRuleset(rulesetPath, args['directory'])
15
+ }
16
+
17
+ getSpectralRuleset(pathParams, outputDir) {
18
+ return this.executeHttp({
19
+ execute: () => getSpectralRuleset(pathParams),
20
+ onResolve: response => this.extractZipResponse(response, outputDir),
21
+ options: {}
22
+ })
23
+ }
24
+
25
+ async extractZipResponse(response, outputDir) {
26
+ const buffer = Buffer.from(response.content, 'binary');
27
+ await this.createDirectory(outputDir)
28
+ const directory = await unzipper.Open.buffer(buffer);
29
+ await directory.extract({ path: outputDir });
30
+ }
31
+
32
+ async createDirectory(outputDir) {
33
+ try {
34
+ await fs.promises.mkdir(outputDir)
35
+ } catch (err) {
36
+ if (err.code === 'EEXIST') {
37
+ throw new Errors.CLIError(errorMsg.directoryExists({ directory: outputDir }))
38
+ }
39
+ if (err.message) {
40
+ throw new Errors.CLIError(err.message)
41
+ }
42
+
43
+ throw new Errors.CLIError(errorMsg.unknown())
44
+ }
45
+ }
46
+ }
47
+
48
+ DownloadSpectralRulesetCommand.description = `Fetch organization's Spectral ruleset`
49
+
50
+ DownloadSpectralRulesetCommand.examples = [
51
+ 'swaggerhub spectral:download my_organization/my_api_ruleset rules/',
52
+ ]
53
+
54
+ DownloadSpectralRulesetCommand.args = {
55
+ 'OWNER/RULESET_NAME': Args.string({
56
+ required: true,
57
+ description: 'Organization\'s Spectral ruleset to create or update on SwaggerHub'
58
+ }),
59
+ 'directory': Args.string({
60
+ required: true,
61
+ description: 'Relative path to directory the ruleset files should be saved to'
62
+ })
63
+ }
64
+
65
+ DownloadSpectralRulesetCommand.flags = {
66
+ ...BaseCommand.flags
67
+ }
68
+
69
+ module.exports = DownloadSpectralRulesetCommand
@@ -0,0 +1,59 @@
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')
9
+
10
+ class UploadSpectralRulesetCommand extends BaseCommand {
11
+ async run() {
12
+ const { args } = await this.parse(UploadSpectralRulesetCommand)
13
+ const rulesetPath = getSpectralIdentifierArg(args)
14
+
15
+ const zippedDirectory = await this.zipTheDirectory(args.directory)
16
+ await this.saveSpectralRuleset(rulesetPath, zippedDirectory)
17
+ }
18
+
19
+ async zipTheDirectory(directoryPath) {
20
+ const archive = archiver('zip', { zlib: { level: 9 } });
21
+ const passthrough = new PassThrough();
22
+
23
+ archive.directory(directoryPath, false);
24
+ archive.finalize();
25
+ archive.pipe(passthrough);
26
+ return passthrough;
27
+ }
28
+
29
+ saveSpectralRuleset(pathParams, zippedDirectory) {
30
+ return this.executeHttp({
31
+ execute: () => saveSpectralRuleset(pathParams, zippedDirectory),
32
+ onResolve: pipeAsync(getResponseContent, JSON.parse),
33
+ options: {}
34
+ })
35
+ }
36
+ }
37
+
38
+ UploadSpectralRulesetCommand.description = `Create or update organization's Spectral ruleset`
39
+
40
+ UploadSpectralRulesetCommand.examples = [
41
+ 'swaggerhub spectral:upload my_organization/my_api_ruleset rules/',
42
+ ]
43
+
44
+ UploadSpectralRulesetCommand.args = {
45
+ 'OWNER/RULESET_NAME': Args.string({
46
+ required: true,
47
+ description: 'Organization\'s Spectral ruleset to create or update on SwaggerHub'
48
+ }),
49
+ 'directory': Args.string({
50
+ required: true,
51
+ description: 'Relative path to directory with ruleset files'
52
+ })
53
+ }
54
+
55
+ UploadSpectralRulesetCommand.flags = {
56
+ ...BaseCommand.flags
57
+ }
58
+
59
+ module.exports = UploadSpectralRulesetCommand
@@ -21,9 +21,10 @@ const setConfig = update => {
21
21
 
22
22
  const isURLValid = () => {
23
23
  const { SWAGGERHUB_URL } = getConfig()
24
+ const url = new URL(SWAGGERHUB_URL)
24
25
  return swaggerhubUrlRegex.test(SWAGGERHUB_URL) ||
25
- (!SWAGGERHUB_URL.includes('api.swaggerhub.com') && SWAGGERHUB_URL.endsWith('/v1')) ||
26
- SWAGGERHUB_URL.includes('localhost')
26
+ (!url.hostname.endsWith('api.swaggerhub.com') && url.pathname.endsWith('/v1')) ||
27
+ url.hostname === 'localhost'
27
28
  }
28
29
 
29
30
  module.exports = {
@@ -0,0 +1,30 @@
1
+ const config = require('../config')
2
+ const http = require('../support/http')
3
+
4
+ const saveSpectralRuleset = (pathParams, body) => {
5
+ const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
6
+
7
+ return http({
8
+ url: [SWAGGERHUB_URL, 'standardization', 'spectral-rulesets', pathParams, 'zip'],
9
+ auth: SWAGGERHUB_API_KEY,
10
+ contentType: 'zip',
11
+ method: 'PUT',
12
+ body
13
+ })
14
+ }
15
+
16
+ const getSpectralRuleset = (pathParams) => {
17
+ const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
18
+
19
+ return http({
20
+ url: [SWAGGERHUB_URL, 'standardization', 'spectral-rulesets', pathParams, 'zip'],
21
+ auth: SWAGGERHUB_API_KEY,
22
+ contentType: 'zip',
23
+ method: 'GET'
24
+ })
25
+ }
26
+
27
+ module.exports = {
28
+ saveSpectralRuleset,
29
+ getSpectralRuleset
30
+ }
@@ -2,12 +2,21 @@ const { CLIError } = require('@oclif/core').Errors
2
2
  const { hasJsonStructure, isError } = require('../../utils/general')
3
3
  const { errorMsg } = require('../../template-strings')
4
4
 
5
- const parseResponse = response => new Promise(resolve => response.text()
6
- .then(content => resolve({
5
+ const parseResponse = response => new Promise(resolve => {
6
+
7
+ const resolveContent = content => resolve({
7
8
  status: response.status,
8
9
  ok: response.ok,
9
- content: content,
10
- })))
10
+ content,
11
+ });
12
+
13
+ const contentType = response.headers?.get('content-type') || '';
14
+ if (contentType.includes('application/zip')) {
15
+ response.buffer().then(resolveContent)
16
+ } else {
17
+ response.text().then(resolveContent)
18
+ }
19
+ });
11
20
 
12
21
  const checkForErrors = ({ resolveStatus = [] } = {}) => response => {
13
22
  if (resolveStatus.includes(response.status) || response.ok) {
@@ -7,6 +7,7 @@ const optionalVersionRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+(\/[\w\-.]+)?(\/?
7
7
  const requiredVersionRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+\/[\w\-.]+(\/?)$/)
8
8
  const integrationIdentifierRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+\/[\w\-.]+\/[\w\-.]+(\/?)$/)
9
9
  const projectIdentifierRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+$/)
10
+ const spectralIdentifierRegex = new RegExp(/^\/?[\w\-.]+\/[\w\-.]+$/)
10
11
 
11
12
  const isValidIdentifier = (id, isVersionRequired) => isVersionRequired
12
13
  ? requiredVersionRegex.test(id)
@@ -52,6 +53,15 @@ const getProjectIdentifierArg = args => {
52
53
  return identifier
53
54
  }
54
55
 
56
+ const getSpectralIdentifierArg = args => {
57
+ const format = 'OWNER/RULESET_NAME'
58
+ const identifier = args[format]
59
+ if (!spectralIdentifierRegex.test(identifier)) {
60
+ throw new CLIError(errorMsg.argsMustMatchFormat({ format }))
61
+ }
62
+ return identifier
63
+ }
64
+
55
65
  const readConfigFile = filename => {
56
66
  if (!existsSync(filename)) {
57
67
  throw new CLIError(errorMsg.fileNotFound({ filename }))
@@ -81,6 +91,7 @@ module.exports = {
81
91
  getDomainIdentifierArg,
82
92
  getIntegrationIdentifierArg,
83
93
  getProjectIdentifierArg,
94
+ getSpectralIdentifierArg,
84
95
  readConfigFile,
85
96
  splitPathParams,
86
97
  splitFlagParams,
@@ -23,6 +23,8 @@ const errorMsg = {
23
23
 
24
24
  invalidConfig: 'Invalid configuration file. Please ensure that the file is in JSON format',
25
25
 
26
+ directoryExists: 'Directory already exists: \'{{directory}}\'',
27
+
26
28
  unknown: 'Unknown Error',
27
29
  }
28
30