Skip to content

Commit

Permalink
fix: quirks with version commands and config retrieval (#423)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/versions.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/login.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* Update __tests__/cmds/login.test.js

Co-authored-by: Kanad Gupta <[email protected]>

* 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 <[email protected]>
  • Loading branch information
erunion and kanadgupta authored Jan 11, 2022
1 parent f842480 commit 026c633
Show file tree
Hide file tree
Showing 28 changed files with 350 additions and 359 deletions.
178 changes: 89 additions & 89 deletions __tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ exports[`cli --help should not surface args that are designated as hidden 1`] =
"
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
[4m[1mUsage[22m[24m
Usage
rdme openapi [file] [options]
[4m[1mOptions[22m[24m
Options
[1m--key[22m [4mstring[24m Project API key
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
--key string Project API key
--id string Unique identifier for your API definition. Use this if you're re-uploading an
existing API definition
[1m--version[22m [4mstring[24m Project version
[1m-h[22m, [1m--help[22m Display this usage guide
--version string Project version
-h, --help Display this usage guide
[4m[1mRelated commands[22m[24m
Related commands
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
$ rdme validate Validate your OpenAPI/Swagger definition.
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
"
`;

exports[`cli --help should print help 1`] = `
"
📖 [34m[1mrdme[22m[39m
📖 rdme
[1ma utlity for interacting with ReadMe[22m
a utlity for interacting with ReadMe
.
.\\\\ /.
’ ‘ ‘ ‘
Expand All @@ -51,56 +51,56 @@ exports[`cli --help should print help 1`] = `
‘READn’ \\\\._./ \\\\__./ \\\\.../ ‘MEE*’
* /*
[4m[1mUsage[22m[24m
Usage
rdme <command> [arguments]
[4m[1mOptions[22m[24m
Options
[1m-h[22m, [1m--help[22m Display this usage guide
[1m-v[22m, [1m--version[22m Show the current rdme version
-h, --help Display this usage guide
-v, --version Show the current rdme version
[4m[1mAdministration[22m[24m
Administration
[90m$[39m rdme login Login to a ReadMe project.
[90m$[39m rdme logout Logs the currently authenticated user out of ReadMe.
[90m$[39m rdme whoami Displays the current user and project authenticated with ReadMe.
$ rdme login Login to a ReadMe project.
$ rdme logout Logs the currently authenticated user out of ReadMe.
$ rdme whoami Displays the current user and project authenticated with ReadMe.
[4m[1mUpload OpenAPI/Swagger definitions[22m[24m
Upload OpenAPI/Swagger definitions
[90m$[39m rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
$ rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
$ rdme validate Validate your OpenAPI/Swagger definition.
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
[4m[1mDocumentation[22m[24m
Documentation
[90m$[39m rdme docs Sync a folder of markdown files to your ReadMe project.
[90m$[39m rdme docs:edit Edit a single file from your ReadMe project without saving locally.
$ rdme docs Sync a folder of markdown files to your ReadMe project.
$ rdme docs:edit Edit a single file from your ReadMe project without saving locally.
[4m[1mVersions[22m[24m
Versions
[90m$[39m rdme versions List versions available in your project or get a version by SemVer
$ rdme versions List versions available in your project or get a version by SemVer
(https://semver.org/).
[90m$[39m rdme versions:create Create a new version for your project.
[90m$[39m rdme versions:update Update an existing version for your project.
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
$ rdme versions:create Create a new version for your project.
$ rdme versions:update Update an existing version for your project.
$ rdme versions:delete Delete a version associated with your ReadMe project.
[4m[1mOther useful commands[22m[24m
Other useful commands
[90m$[39m rdme oas Helpful OpenAPI generation tooling.
[90m$[39m rdme open Open your current ReadMe project in the browser.
$ rdme oas Helpful OpenAPI generation tooling.
$ rdme open Open your current ReadMe project in the browser.
Run [2mrdme help <command>[22m for help with a specific command.
Run rdme help <command> for help with a specific command.
To get more help with ReadMe, check out our docs at https://docs.readme.com.
"
`;
exports[`cli --help should print help for the \`-H\` alias 1`] = `
"
📖 [34m[1mrdme[22m[39m
📖 rdme
[1ma utlity for interacting with ReadMe[22m
a utlity for interacting with ReadMe
.
.\\\\ /.
’ ‘ ‘ ‘
Expand All @@ -124,46 +124,46 @@ exports[`cli --help should print help for the \`-H\` alias 1`] = `
‘READn’ \\\\._./ \\\\__./ \\\\.../ ‘MEE*’
* /*
[4m[1mUsage[22m[24m
Usage
rdme <command> [arguments]
[4m[1mOptions[22m[24m
Options
[1m-h[22m, [1m--help[22m Display this usage guide
[1m-v[22m, [1m--version[22m Show the current rdme version
-h, --help Display this usage guide
-v, --version Show the current rdme version
[4m[1mAdministration[22m[24m
Administration
[90m$[39m rdme login Login to a ReadMe project.
[90m$[39m rdme logout Logs the currently authenticated user out of ReadMe.
[90m$[39m rdme whoami Displays the current user and project authenticated with ReadMe.
$ rdme login Login to a ReadMe project.
$ rdme logout Logs the currently authenticated user out of ReadMe.
$ rdme whoami Displays the current user and project authenticated with ReadMe.
[4m[1mUpload OpenAPI/Swagger definitions[22m[24m
Upload OpenAPI/Swagger definitions
[90m$[39m rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
$ rdme openapi Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
$ rdme validate Validate your OpenAPI/Swagger definition.
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
[4m[1mDocumentation[22m[24m
Documentation
[90m$[39m rdme docs Sync a folder of markdown files to your ReadMe project.
[90m$[39m rdme docs:edit Edit a single file from your ReadMe project without saving locally.
$ rdme docs Sync a folder of markdown files to your ReadMe project.
$ rdme docs:edit Edit a single file from your ReadMe project without saving locally.
[4m[1mVersions[22m[24m
Versions
[90m$[39m rdme versions List versions available in your project or get a version by SemVer
$ rdme versions List versions available in your project or get a version by SemVer
(https://semver.org/).
[90m$[39m rdme versions:create Create a new version for your project.
[90m$[39m rdme versions:update Update an existing version for your project.
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
$ rdme versions:create Create a new version for your project.
$ rdme versions:update Update an existing version for your project.
$ rdme versions:delete Delete a version associated with your ReadMe project.
[4m[1mOther useful commands[22m[24m
Other useful commands
[90m$[39m rdme oas Helpful OpenAPI generation tooling.
[90m$[39m rdme open Open your current ReadMe project in the browser.
$ rdme oas Helpful OpenAPI generation tooling.
$ rdme open Open your current ReadMe project in the browser.
Run [2mrdme help <command>[22m for help with a specific command.
Run rdme help <command> for help with a specific command.
To get more help with ReadMe, check out our docs at https://docs.readme.com.
"
Expand All @@ -173,67 +173,67 @@ exports[`cli --help should print usage for a given command 1`] = `
"
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
[4m[1mUsage[22m[24m
Usage
rdme openapi [file] [options]
[4m[1mOptions[22m[24m
Options
[1m--key[22m [4mstring[24m Project API key
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
--key string Project API key
--id string Unique identifier for your API definition. Use this if you're re-uploading an
existing API definition
[1m--version[22m [4mstring[24m Project version
[1m-h[22m, [1m--help[22m Display this usage guide
--version string Project version
-h, --help Display this usage guide
[4m[1mRelated commands[22m[24m
Related commands
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
$ rdme validate Validate your OpenAPI/Swagger definition.
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
"
`;
exports[`cli --help should print usage for a given command if supplied as \`help <command>\` 1`] = `
"
Upload, or resync, your OpenAPI/Swagger definition to ReadMe.
[4m[1mUsage[22m[24m
Usage
rdme openapi [file] [options]
[4m[1mOptions[22m[24m
Options
[1m--key[22m [4mstring[24m Project API key
[1m--id[22m [4mstring[24m Unique identifier for your API definition. Use this if you're re-uploading an
--key string Project API key
--id string Unique identifier for your API definition. Use this if you're re-uploading an
existing API definition
[1m--version[22m [4mstring[24m Project version
[1m-h[22m, [1m--help[22m Display this usage guide
--version string Project version
-h, --help Display this usage guide
[4m[1mRelated commands[22m[24m
Related commands
[90m$[39m rdme validate Validate your OpenAPI/Swagger definition.
[90m$[39m rdme swagger Alias for \`rdme openapi\`. [deprecated]
$ rdme validate Validate your OpenAPI/Swagger definition.
$ rdme swagger Alias for \`rdme openapi\`. [deprecated]
"
`;
exports[`cli --help should show related commands for a subcommands help menu 1`] = `
"
List versions available in your project or get a version by SemVer (https://semver.org/).
[4m[1mUsage[22m[24m
Usage
rdme versions [options]
[4m[1mOptions[22m[24m
Options
[1m--key[22m [4mstring[24m Project API key
[1m--version[22m [4mstring[24m A specific project version to view
[1m--raw[22m Return raw output from the API instead of in a \\"pretty\\" format.
[1m-h[22m, [1m--help[22m Display this usage guide
--key string Project API key
--version string A specific project version to view
--raw Return raw output from the API instead of in a \\"pretty\\" format.
-h, --help Display this usage guide
[4m[1mRelated commands[22m[24m
Related commands
[90m$[39m rdme versions:create Create a new version for your project.
[90m$[39m rdme versions:update Update an existing version for your project.
[90m$[39m rdme versions:delete Delete a version associated with your ReadMe project.
$ rdme versions:create Create a new version for your project.
$ rdme versions:update Update an existing version for your project.
$ rdme versions:delete Delete a version associated with your ReadMe project.
"
`;
5 changes: 5 additions & 0 deletions __tests__/cmds/__snapshots__/login.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rdme login should post to /login on the API 1`] = `"Successfully logged in as [email protected] to the subdomain project."`;

exports[`rdme login should send 2fa token if provided 1`] = `"Successfully logged in as [email protected] to the subdomain project."`;
16 changes: 8 additions & 8 deletions __tests__/cmds/__snapshots__/openapi.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
exports[`rdme openapi error handling should throw an error if an invalid OpenAPI 3.1 definition is supplied 1`] = `
[SyntaxError: OpenAPI schema validation failed.
[31m[1mREQUIRED[22m[39m[31m must have required property 'name'[39m
REQUIRED must have required property 'name'
[0m [90m 24 |[39m [32m"components"[39m[33m:[39m {[0m
[0m [90m 25 |[39m [32m"securitySchemes"[39m[33m:[39m {[0m
[0m[31m[1m>[22m[39m[90m 26 |[39m [32m"tlsAuth"[39m[33m:[39m {[0m
[0m [90m |[39m [31m[1m^[22m[39m [31m[1m☹️ [95mname[31m is missing here![22m[39m[0m
[0m [90m 27 |[39m [32m"type"[39m[33m:[39m [32m"mutualTLS"[39m[0m
[0m [90m 28 |[39m }[0m
[0m [90m 29 |[39m }[0m]
24 | "components": {
25 | "securitySchemes": {
> 26 | "tlsAuth": {
| ^ ☹️ name is missing here!
27 | "type": "mutualTLS"
28 | }
29 | }]
`;
exports[`rdme openapi should bundle and upload the expected content 1`] = `
Expand Down
32 changes: 16 additions & 16 deletions __tests__/cmds/__snapshots__/validate.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
exports[`rdme validate error handling should throw an error if an in valid Swagger definition is supplied 1`] = `
[Error: Swagger schema validation failed.
[31m[1mADDITIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m
ADDITIONAL PROPERTY must NOT have additional properties
[0m [90m 23 |[39m [32m"description"[39m[33m:[39m [32m"Find out more"[39m[33m,[39m[0m
[0m [90m 24 |[39m [32m"url"[39m[33m:[39m [32m"http://swagger.io"[39m[33m,[39m[0m
[0m[31m[1m>[22m[39m[90m 25 |[39m [32m"this-shouldnt-be-here"[39m[33m:[39m [36mtrue[39m[0m
[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
[0m [90m 26 |[39m }[0m
[0m [90m 27 |[39m }[0m
[0m [90m 28 |[39m ][33m,[39m[0m]
23 | "description": "Find out more",
24 | "url": "http://swagger.io",
> 25 | "this-shouldnt-be-here": true
| ^^^^^^^^^^^^^^^^^^^^^^^ 😲 this-shouldnt-be-here is not expected to be here!
26 | }
27 | }
28 | ],]
`;

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

0 comments on commit 026c633

Please sign in to comment.