Skip to content

Commit 026c633

Browse files
erunionkanadgupta
andauthored
fix: quirks with version commands and config retrieval (#423)
* fix: quirks with version commands not always handling errors properly * fix: use the right accessor for getting config data * fix: pr feedback * fix: pr feedback * fix: pr feedback * fix: pr feedback * Update __tests__/cmds/whoami.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/versions.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/login.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * Update __tests__/cmds/login.test.js Co-authored-by: Kanad Gupta <kanad@readme.io> * fix: prettier * fix: test adjustments * fix: one more test update * fix: disabling color in all tests due to snapshot issues Co-authored-by: Kanad Gupta <kanad@readme.io>
1 parent f842480 commit 026c633

28 files changed

+350
-359
lines changed

__tests__/__snapshots__/index.test.js.snap

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ exports[`cli --help should not surface args that are designated as hidden 1`] =
44
"
55
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
66
7-
[4m[1mUsage[22m[24m
7+
Usage
88
99
rdme openapi [file] [options]
1010
11-
[4m[1mOptions[22m[24m
11+
Options
1212
13-
[1m--key[22m [4mstring[24m Project API key
14-
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
13+
--key string Project API key
14+
--id string Unique identifier for your API definition. Use this if you're re-uploading an
1515
existing API definition
16-
[1m--version[22m [4mstring[24m Project version
17-
[1m-h[22m, [1m--help[22m Display this usage guide
16+
--version string Project version
17+
-h, --help Display this usage guide
1818
19-
[4m[1mRelated commands[22m[24m
19+
Related commands
2020
21-
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
22-
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
21+
$ rdme validate Validate your OpenAPI/Swagger definition.
22+
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
2323
"
2424
`;
2525

2626
exports[`cli --help should print help 1`] = `
2727
"
28-
📖 [34m[1mrdme[22m[39m
28+
📖 rdme
2929
30-
[1ma utlity for interacting with ReadMe[22m
30+
a utlity for interacting with ReadMe
3131
.
3232
.\\\\ /.
3333
’ ‘ ‘ ‘
@@ -51,56 +51,56 @@ exports[`cli --help should print help 1`] = `
5151
‘READn’ \\\\._./ \\\\__./ \\\\.../ ‘MEE*’
5252
* /*
5353
54-
[4m[1mUsage[22m[24m
54+
Usage
5555
5656
rdme <command> [arguments]
5757
58-
[4m[1mOptions[22m[24m
58+
Options
5959
60-
[1m-h[22m, [1m--help[22m Display this usage guide
61-
[1m-v[22m, [1m--version[22m Show the current rdme version
60+
-h, --help Display this usage guide
61+
-v, --version Show the current rdme version
6262
63-
[4m[1mAdministration[22m[24m
63+
Administration
6464
65-
[90m$[39m rdme login Login to a ReadMe project.
66-
[90m$[39m rdme logout Logs the currently authenticated user out of ReadMe.
67-
[90m$[39m rdme whoami Displays the current user and project authenticated with ReadMe.
65+
$ rdme login Login to a ReadMe project.
66+
$ rdme logout Logs the currently authenticated user out of ReadMe.
67+
$ rdme whoami Displays the current user and project authenticated with ReadMe.
6868
69-
[4m[1mUpload OpenAPI/Swagger definitions[22m[24m
69+
Upload OpenAPI/Swagger definitions
7070
71-
[90m$[39m rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
72-
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
73-
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
71+
$ rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
72+
$ rdme validate Validate your OpenAPI/Swagger definition.
73+
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
7474
75-
[4m[1mDocumentation[22m[24m
75+
Documentation
7676
77-
[90m$[39m rdme docs Sync a folder of markdown files to your ReadMe project.
78-
[90m$[39m rdme docs:edit Edit a single file from your ReadMe project without saving locally.
77+
$ rdme docs Sync a folder of markdown files to your ReadMe project.
78+
$ rdme docs:edit Edit a single file from your ReadMe project without saving locally.
7979
80-
[4m[1mVersions[22m[24m
80+
Versions
8181
82-
[90m$[39m rdme versions List versions available in your project or get a version by SemVer
82+
$ rdme versions List versions available in your project or get a version by SemVer
8383
(https://semver.org/).
84-
[90m$[39m rdme versions:create Create a new version for your project.
85-
[90m$[39m rdme versions:update Update an existing version for your project.
86-
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
84+
$ rdme versions:create Create a new version for your project.
85+
$ rdme versions:update Update an existing version for your project.
86+
$ rdme versions:delete Delete a version associated with your ReadMe project.
8787
88-
[4m[1mOther useful commands[22m[24m
88+
Other useful commands
8989
90-
[90m$[39m rdme oas Helpful OpenAPI generation tooling.
91-
[90m$[39m rdme open Open your current ReadMe project in the browser.
90+
$ rdme oas Helpful OpenAPI generation tooling.
91+
$ rdme open Open your current ReadMe project in the browser.
9292
93-
Run [2mrdme help <command>[22m for help with a specific command.
93+
Run rdme help <command> for help with a specific command.
9494
9595
To get more help with ReadMe, check out our docs at https://docs.readme.com.
9696
"
9797
`;
9898
9999
exports[`cli --help should print help for the \`-H\` alias 1`] = `
100100
"
101-
📖 [34m[1mrdme[22m[39m
101+
📖 rdme
102102
103-
[1ma utlity for interacting with ReadMe[22m
103+
a utlity for interacting with ReadMe
104104
.
105105
.\\\\ /.
106106
’ ‘ ‘ ‘
@@ -124,46 +124,46 @@ exports[`cli --help should print help for the \`-H\` alias 1`] = `
124124
‘READn’ \\\\._./ \\\\__./ \\\\.../ ‘MEE*’
125125
* /*
126126
127-
[4m[1mUsage[22m[24m
127+
Usage
128128
129129
rdme <command> [arguments]
130130
131-
[4m[1mOptions[22m[24m
131+
Options
132132
133-
[1m-h[22m, [1m--help[22m Display this usage guide
134-
[1m-v[22m, [1m--version[22m Show the current rdme version
133+
-h, --help Display this usage guide
134+
-v, --version Show the current rdme version
135135
136-
[4m[1mAdministration[22m[24m
136+
Administration
137137
138-
[90m$[39m rdme login Login to a ReadMe project.
139-
[90m$[39m rdme logout Logs the currently authenticated user out of ReadMe.
140-
[90m$[39m rdme whoami Displays the current user and project authenticated with ReadMe.
138+
$ rdme login Login to a ReadMe project.
139+
$ rdme logout Logs the currently authenticated user out of ReadMe.
140+
$ rdme whoami Displays the current user and project authenticated with ReadMe.
141141
142-
[4m[1mUpload OpenAPI/Swagger definitions[22m[24m
142+
Upload OpenAPI/Swagger definitions
143143
144-
[90m$[39m rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
145-
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
146-
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
144+
$ rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
145+
$ rdme validate Validate your OpenAPI/Swagger definition.
146+
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
147147
148-
[4m[1mDocumentation[22m[24m
148+
Documentation
149149
150-
[90m$[39m rdme docs Sync a folder of markdown files to your ReadMe project.
151-
[90m$[39m rdme docs:edit Edit a single file from your ReadMe project without saving locally.
150+
$ rdme docs Sync a folder of markdown files to your ReadMe project.
151+
$ rdme docs:edit Edit a single file from your ReadMe project without saving locally.
152152
153-
[4m[1mVersions[22m[24m
153+
Versions
154154
155-
[90m$[39m rdme versions List versions available in your project or get a version by SemVer
155+
$ rdme versions List versions available in your project or get a version by SemVer
156156
(https://semver.org/).
157-
[90m$[39m rdme versions:create Create a new version for your project.
158-
[90m$[39m rdme versions:update Update an existing version for your project.
159-
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
157+
$ rdme versions:create Create a new version for your project.
158+
$ rdme versions:update Update an existing version for your project.
159+
$ rdme versions:delete Delete a version associated with your ReadMe project.
160160
161-
[4m[1mOther useful commands[22m[24m
161+
Other useful commands
162162
163-
[90m$[39m rdme oas Helpful OpenAPI generation tooling.
164-
[90m$[39m rdme open Open your current ReadMe project in the browser.
163+
$ rdme oas Helpful OpenAPI generation tooling.
164+
$ rdme open Open your current ReadMe project in the browser.
165165
166-
Run [2mrdme help <command>[22m for help with a specific command.
166+
Run rdme help <command> for help with a specific command.
167167
168168
To get more help with ReadMe, check out our docs at https://docs.readme.com.
169169
"
@@ -173,67 +173,67 @@ exports[`cli --help should print usage for a given command 1`] = `
173173
"
174174
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
175175
176-
[4m[1mUsage[22m[24m
176+
Usage
177177
178178
rdme openapi [file] [options]
179179
180-
[4m[1mOptions[22m[24m
180+
Options
181181
182-
[1m--key[22m [4mstring[24m Project API key
183-
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
182+
--key string Project API key
183+
--id string Unique identifier for your API definition. Use this if you're re-uploading an
184184
existing API definition
185-
[1m--version[22m [4mstring[24m Project version
186-
[1m-h[22m, [1m--help[22m Display this usage guide
185+
--version string Project version
186+
-h, --help Display this usage guide
187187
188-
[4m[1mRelated commands[22m[24m
188+
Related commands
189189
190-
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
191-
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
190+
$ rdme validate Validate your OpenAPI/Swagger definition.
191+
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
192192
"
193193
`;
194194
195195
exports[`cli --help should print usage for a given command if supplied as \`help <command>\` 1`] = `
196196
"
197197
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
198198
199-
[4m[1mUsage[22m[24m
199+
Usage
200200
201201
rdme openapi [file] [options]
202202
203-
[4m[1mOptions[22m[24m
203+
Options
204204
205-
[1m--key[22m [4mstring[24m Project API key
206-
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
205+
--key string Project API key
206+
--id string Unique identifier for your API definition. Use this if you're re-uploading an
207207
existing API definition
208-
[1m--version[22m [4mstring[24m Project version
209-
[1m-h[22m, [1m--help[22m Display this usage guide
208+
--version string Project version
209+
-h, --help Display this usage guide
210210
211-
[4m[1mRelated commands[22m[24m
211+
Related commands
212212
213-
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
214-
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
213+
$ rdme validate Validate your OpenAPI/Swagger definition.
214+
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
215215
"
216216
`;
217217
218218
exports[`cli --help should show related commands for a subcommands help menu 1`] = `
219219
"
220220
List versions available in your project or get a version by SemVer (https://semver.org/).
221221
222-
[4m[1mUsage[22m[24m
222+
Usage
223223
224224
rdme versions [options]
225225
226-
[4m[1mOptions[22m[24m
226+
Options
227227
228-
[1m--key[22m [4mstring[24m Project API key
229-
[1m--version[22m [4mstring[24m A specific project version to view
230-
[1m--raw[22m Return raw output from the API instead of in a \\"pretty\\" format.
231-
[1m-h[22m, [1m--help[22m Display this usage guide
228+
--key string Project API key
229+
--version string A specific project version to view
230+
--raw Return raw output from the API instead of in a \\"pretty\\" format.
231+
-h, --help Display this usage guide
232232
233-
[4m[1mRelated commands[22m[24m
233+
Related commands
234234
235-
[90m$[39m rdme versions:create Create a new version for your project.
236-
[90m$[39m rdme versions:update Update an existing version for your project.
237-
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
235+
$ rdme versions:create Create a new version for your project.
236+
$ rdme versions:update Update an existing version for your project.
237+
$ rdme versions:delete Delete a version associated with your ReadMe project.
238238
"
239239
`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`rdme login should post to /login on the API 1`] = `"Successfully logged in as user@example.com to the subdomain project."`;
4+
5+
exports[`rdme login should send 2fa token if provided 1`] = `"Successfully logged in as user@example.com to the subdomain project."`;

__tests__/cmds/__snapshots__/openapi.test.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
exports[`rdme openapi error handling should throw an error if an invalid OpenAPI 3.1 definition is supplied 1`] = `
44
[SyntaxError: OpenAPI schema validation failed.
55
6-
[31m[1mREQUIRED[22m[39m[31m must have required property 'name'[39m
6+
REQUIRED must have required property 'name'
77
8-
[0m [90m 24 |[39m [32m"components"[39m[33m:[39m {[0m
9-
[0m [90m 25 |[39m [32m"securitySchemes"[39m[33m:[39m {[0m
10-
[0m[31m[1m>[22m[39m[90m 26 |[39m [32m"tlsAuth"[39m[33m:[39m {[0m
11-
[0m [90m |[39m [31m[1m^[22m[39m [31m[1m☹️ [95mname[31m is missing here![22m[39m[0m
12-
[0m [90m 27 |[39m [32m"type"[39m[33m:[39m [32m"mutualTLS"[39m[0m
13-
[0m [90m 28 |[39m }[0m
14-
[0m [90m 29 |[39m }[0m]
8+
24 | "components": {
9+
25 | "securitySchemes": {
10+
> 26 | "tlsAuth": {
11+
| ^ ☹️ name is missing here!
12+
27 | "type": "mutualTLS"
13+
28 | }
14+
29 | }]
1515
`;
1616
1717
exports[`rdme openapi should bundle and upload the expected content 1`] = `

__tests__/cmds/__snapshots__/validate.test.js.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
exports[`rdme validate error handling should throw an error if an in valid Swagger definition is supplied 1`] = `
44
[Error: Swagger schema validation failed.
55
6-
[31m[1mADDITIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m
6+
ADDITIONAL PROPERTY must NOT have additional properties
77
8-
[0m [90m 23 |[39m [32m"description"[39m[33m:[39m [32m"Find out more"[39m[33m,[39m[0m
9-
[0m [90m 24 |[39m [32m"url"[39m[33m:[39m [32m"http://swagger.io"[39m[33m,[39m[0m
10-
[0m[31m[1m>[22m[39m[90m 25 |[39m [32m"this-shouldnt-be-here"[39m[33m:[39m [36mtrue[39m[0m
11-
[0m [90m |[39m [31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m [31m[1m😲 [95mthis-shouldnt-be-here[31m is not expected to be here![22m[39m[0m
12-
[0m [90m 26 |[39m }[0m
13-
[0m [90m 27 |[39m }[0m
14-
[0m [90m 28 |[39m ][33m,[39m[0m]
8+
23 | "description": "Find out more",
9+
24 | "url": "http://swagger.io",
10+
> 25 | "this-shouldnt-be-here": true
11+
| ^^^^^^^^^^^^^^^^^^^^^^^ 😲 this-shouldnt-be-here is not expected to be here!
12+
26 | }
13+
27 | }
14+
28 | ],]
1515
`;
1616

1717
exports[`rdme validate error handling should throw an error if an invalid OpenAPI 3.1 definition is supplied 1`] = `
1818
[Error: OpenAPI schema validation failed.
1919
20-
[31m[1mREQUIRED[22m[39m[31m must have required property 'name'[39m
20+
REQUIRED must have required property 'name'
2121
22-
[0m [90m 24 |[39m [32m"components"[39m[33m:[39m {[0m
23-
[0m [90m 25 |[39m [32m"securitySchemes"[39m[33m:[39m {[0m
24-
[0m[31m[1m>[22m[39m[90m 26 |[39m [32m"tlsAuth"[39m[33m:[39m {[0m
25-
[0m [90m |[39m [31m[1m^[22m[39m [31m[1m☹️ [95mname[31m is missing here![22m[39m[0m
26-
[0m [90m 27 |[39m [32m"type"[39m[33m:[39m [32m"mutualTLS"[39m[0m
27-
[0m [90m 28 |[39m }[0m
28-
[0m [90m 29 |[39m }[0m]
22+
24 | "components": {
23+
25 | "securitySchemes": {
24+
> 26 | "tlsAuth": {
25+
| ^ ☹️ name is missing here!
26+
27 | "type": "mutualTLS"
27+
28 | }
28+
29 | }]
2929
`;

0 commit comments

Comments
 (0)