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

Allow control over Thor's output #2032

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Oct 4, 2024

Addresses https://github.com/Shopify/team-ruby-dx/issues/1297

See lib/tapioca/logging.rb for the important parts.

Notes:

  • We might want to introduce a RuboCop cop to prevent accidental use of puts, say, say_error etc.
  • There are still some places where the output is generated from within Thor, e.g. create_file and remove_file. I'm setting verbose: false if TAPIOCA_DEVELOPMENT is set, but this isn't ideal.
  • There were a couple of places in the tests where the whitespace had to change, need to look into why.
  • There is a type failure for argument forwarding (...) that I need still address.
  • It would be nice if the tests could help us validate that we are always outputting to the logger and never directly to stdout, but that could be tricky.

Here is an example of the output written to the logs:

# Logfile created on 2024-10-08 12:54:33 -0400 by logger.rb/v1.6.1
I, [2024-10-08T12:54:33.421152 #10336]  INFO -- : Removing RBI files of gems that have been removed:
I, [2024-10-08T12:54:33.422190 #10336]  INFO -- : Nothing to do.
I, [2024-10-08T12:54:33.422234 #10336]  INFO -- : Generating RBI files of gems that are added or updated:
I, [2024-10-08T12:54:33.422327 #10336]  INFO -- : Nothing to do.
I, [2024-10-08T12:54:33.422427 #10336]  INFO -- : Checking generated RBI files... 
I, [2024-10-08T12:54:33.805008 #10336]  INFO -- :  Done
I, [2024-10-08T12:54:33.805374 #10336]  INFO -- :   No errors found


I, [2024-10-08T12:54:33.805389 #10336]  INFO -- : All operations performed in working directory.
I, [2024-10-08T12:54:33.805397 #10336]  INFO -- : Please review changes and commit them.

lib/tapioca/gemfile.rb Outdated Show resolved Hide resolved
lib/tapioca/loaders/gem.rb Outdated Show resolved Hide resolved
require "thor"

module Tapioca
class Logger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger might be the wrong term... maybe Reporter?

@andyw8 andyw8 force-pushed the andyw8/output-control branch 2 times, most recently from 3128bb4 to b172c10 Compare October 8, 2024 16:28
@andyw8 andyw8 changed the title WIP: Allow control over Thor's output Allow control over Thor's output Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant