The Wayback Machine - http://web.archive.org/web/20201101081647/https://github.com/redwoodjs/redwood/issues/970
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnostics CLI: Add "Success" output message when no errors found #970

Open
thedavidprice opened this issue Aug 19, 2020 · 12 comments
Open

Diagnostics CLI: Add "Success" output message when no errors found #970

thedavidprice opened this issue Aug 19, 2020 · 12 comments

Comments

@thedavidprice
Copy link
Contributor

@thedavidprice thedavidprice commented Aug 19, 2020

Currently, the CLI diagnostics command does not return output when no warnings or errors are found. Example:

$ yarn rw diagnostics
yarn run v1.22.4
$ /Users/price/Repos/create-redwood-app/node_modules/.bin/rw diagnostics
✨  Done in 3.07s.

This can cause confusion as to whether anything was run at all and if the project is ok. Improved output may include:

  • count of checks run/completed
  • count of warnings found
  • count of errors found
  • 🏆 if everything is good
@aldonline
Copy link
Collaborator

@aldonline aldonline commented Aug 20, 2020

Good idea :).
Some notes here:

  • Diagnostics isn't catching all potential errors. So no diagnostics doesn't mean that everything is ok. It just means that the few tests that we have added so far are passing. This should be captured in the wording so developers don't end up with a faulty mental model, banging their head against the wall
  • There are errors that are reported by other tools (like the TS compiler, the prisma toolchain, etc). We could also call into those tools and report their errors during the diagnostics check.

When thinking about where and when the checks should happen, consider the following:

  • When using an IDE (or even webpack), tools like TSC will talk directly to the host (they already report errors somehow, regardless of the structure package). This means that we shouldn't expose those errors as part of the structure package (in other words, it would be wrong if, when running structure, it would also run TSC internally). So instead of adding TSC to the structure package, just make sure that the CLI code for redwood diagnostics calls it.

Visually, we could group errors by categories. For example:

$ rw diagnostics

summary:
- 4 redwood structure errors
- 7 typescript compilation errors
- 2 prisma errors

redwood structure errors:
- You cannot add foo to bar (Routes.js:34)
- ...

typescript compilation errors:
- cannot find name "myVariable" - (foo.ts:33)
- ...

prisma errors:
- ...

Maybe rw diagnostics could take options. So, for example, '$rw diagnostics --full` would try to cycle through all the tools, including eslint.

@aldonline aldonline mentioned this issue Aug 21, 2020

0 of 1 task complete
@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Aug 26, 2020

There are errors that are reported by other tools (like the TS compiler, the prisma toolchain, etc). We could also call into those tools and report their errors during the diagnostics check.

^^ I really like this. And it feels on target with the RW v1 goal of consolidating error messaging. If we do rename the CLI command to check, then a specific category of checks could be "Diagnostics". It could default to running ALL checks or running a specific check e.g.

  • yarn rw check runs all
  • yarn rw check diagnostics prisma runs only diagnostics and prisma (not TS per your example above)

For the Output, I like the idea of a Summary. Assuming we start with output for each check/step that's run, I could see the Summary grouping a bit tighter, e.g.:

$ rw check
... 
[task output]
[task output]
etc
...

SUMMARY
- **Redwood Core Diagnostics** [2 Warnings, 1 Error]
  - _warning_: Your env vars are missing
  - _warning_: Name your queries
  - _error_: missing redwood.toml
- **Typescript** [1 Warning]
  - _warning_: gratuitous use of 'any'
- **Prisma** [All Good]
@mojombo mojombo assigned mojombo and unassigned mojombo Sep 17, 2020
@M0nica
Copy link
Contributor

@M0nica M0nica commented Oct 16, 2020

@aldonline @thedavidprice I am interested in working on this ticket. Can you clarify if this ticket is just adding the success message when rw check is run and there are no errors triggered? Should the more robust summarization work be done within this ticket or as a separate follow-up ticket?

@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 16, 2020

@M0nica nice! This is very needed.

Can you clarify if this ticket is just adding the success message when rw check is run and there are no errors triggered?

^^ This is definitely still up for discussion. It would be very helpful if you could help outline a plan for this:

  • The next step could simply be outputting a "Nothing to see here!" message in case output == null. This is a valuable PR in and of itself.
  • I'm not even sure the example I created (above) is possible. Could you help us define a viable, ideal end state?
    • and then we could better prioritize when we want to do it
    • as well as identify the separate parts that could be individual PRs

Should the more robust summarization work be done within this ticket or as a separate follow-up ticket?

^^ I'd vote we organize here in this Issue, including the work on the next-step PR. The conversation will naturally move over to the PR, at which time we can create a new tracking Issue for next steps (if applicable). When the next-step PR is merged, this Issue can be closed and we'll have the new Issue open.


Making sense? Ideas/suggestions about improving this or other options?

@M0nica
Copy link
Contributor

@M0nica M0nica commented Oct 17, 2020

I think implementing these enhancements could be implemented between four tickets (1) improve the success state by making it more clear, 2) reformatting the CLI output, and 3 + 4)enhancing the diagnostics to include Prisma and TypeScript checks which could be worked on concurrently).

  1. updating the check/diagnostics CLI to output something along the lines of "Nothing to see here!" when there are no warnings or errors.
  2. update and reformat the current CLI output to have Redwood Core Diagnostics and then print out the individual warnings/errors. I am assuming GraphQL - but not necessarily Prisma, environment, routes, router, SDL files, service functions, TOML, the existing diagnostics in redwood/redwood all would fall under Redwood Core Diagnostics.
$ rw check
... 
[task output]
[task output]
etc
...

SUMMARY
- **Redwood Core Diagnostics** [2 Warnings, 1 Error]
  - _warning_: Your env vars are missing
  - _warning_: Name your queries
  - _error_: missing redwood.toml
  1. Update check/diagnostics CLI to integrate with TSC and output any of those errors. Would we want to also allow TSC warnings to print in addition to errors and or for the level that outputs to be configurable by the user?
$ rw check
... 
[task output]
[task output]
etc
...

SUMMARY
- **Redwood Core Diagnostics** [2 Warnings, 1 Error]
  - _warning_: Your env vars are missing
  - _warning_: Name your queries
  - _error_: missing redwood.toml
- **Typescript** [1 Warning]
  - _warning_: gratuitous use of 'any'
  1. Update check/diagnostics CLI to integrate with Prisma linting (I am not sure how straightforward this type of integration is 🤔)
... 
[task output]
[task output]
etc
...

SUMMARY
- **Redwood Core Diagnostics** [2 Warnings, 1 Error]
  - _warning_: Your env vars are missing
  - _warning_: Name your queries
  - _error_: missing redwood.toml
- **Prisma** [All Good]
@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 22, 2020

Hi @M0nica Huge thanks for moving this forward! I'll comment on plan items 2 - 4 in a next reply.

For now, I'd say go ahead with Step 1 (from above):

updating the check/diagnostics CLI to output something along the lines of "Nothing to see here!" when there are no warnings or errors.

This would be soooo helpful 😆

@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 22, 2020

Looping in @aldonline for thoughts on proposed plan items 2 - 4 (above).

  1. update and reformat the current CLI output to have Redwood Core Diagnostics and then print out the individual warnings/errors. ... the existing diagnostics in redwood/redwood all would fall under Redwood Core Diagnostics

^^ yes, I believe your understanding is correct — just focus on the diagnostics coming directly from the structure package. The current Catch 22 is that there is not a lot of diagnostic coverage yet because people don't actually know about this tool and are not yet using the VS Code extension. Once usage goes up, the kinds and quantities of diagnostics will go up. It's likely that over time there will be a natural grouping/categorization within the Core Diagnostics that emerges over time. But not yet.

In summary, I think you've outlined an appropriate approach to step 2.

  1. Update check/diagnostics CLI to integrate with TSC and output any of those errors.

I'll defer to @aldonline on specifics here as I'm not familiar enough with TSC checks. Now looking more closely, I’m wondering if it even makes sense to include TSC check along with RW Diagnostics? This feels a bit redundant to me in case of using an editor like VS Code, which will do similar checking.

Also, there a future plans to include this Diagnostics check in a GH Action workflow for Redwood Project CI. The CI will also separately run Build and Lint — maybe that's the right place to run TSC, which could also be easily removed from the runner if not needed? 🤔

  1. Update check/diagnostics CLI to integrate with Prisma linting

^^ Similar thoughts on my part here as for number 3. Also, not all Redwood projects will use Prisma (or have an API). So just not sure if it's necessary.

@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 27, 2020

Two quick ideas after seeing #1405

  • Verbose option: it could be beneficial if users could pass --verbose to see all the check being run. Maybe?
  • --help link to Structure package README: for most commands, if you view help content there's a link to the docs. (See screenshot for info --help below.) There's no doc for diagnostics. @aldonline do you see any benefit in directing people to the Structure package README — possibly for suggesting diagnostics via new Issues, examining the current diagnostics, contributing... ?

Screen Shot 2020-10-26 at 9 51 20 PM

@M0nica
Copy link
Contributor

@M0nica M0nica commented Oct 27, 2020

I think the --verbose option would be helpful for folks who are looking for more visibility into what types of diagnostics are being run. From what I am seeing the current diagnostic checks maybe we could repurpose the text that is being output in the err field 🤔 for example: yield err( this.path_literal_node!, "The 'Not Found' page cannot have a path" ) or were you thinking less granular? I am curious how substantial of a refactor implementing a verbose option will be.

@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 27, 2020

for example: yield err( this.path_literal_node!, "The 'Not Found' page cannot have a path" ) or were you thinking less granular?

^^ I was thinking to just output it all and see what indeed comes out, firehose style. Given your example, it would probably need a prefix to indicate it's just the step and not the result. Like Checking: ${this.path_literal_node!} The 'Not Found' page cannot have a path.

I didn't look at the code before adding this idea. If this requires refactoring, I'm not sure it's of high enough value. (Although there are not too many checks yet, correct?)

@M0nica
Copy link
Contributor

@M0nica M0nica commented Oct 28, 2020

Right now the structure for the diagnostic checks (at least for /routes) is such that if the condition is met that causes a check to fail then an error is thrown with a string like yield err( this.path_literal_node!, "The 'Not Found' page cannot have a path" ) so my understanding is that being able to render information about checks before they fail would require a refactor as the checks aren't explicitly named and the part of the code with the descriptive string is only encountered when a check fails and an error is thrown.

@thedavidprice
Copy link
Contributor Author

@thedavidprice thedavidprice commented Oct 29, 2020

Ah, very helpful. And in that case, I'd vote to put this idea in the proverbial hopper for now.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Structure
  
v1.0
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.