-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add CLI - Integrate fakerbot 🤖 #1507
Conversation
We won’t bump the version as part of this PR. The version bump will be separate. |
Sounds good! 👍🏾 |
The module dir `faker` houses the main "faker" namespaces; and it should remain that way. Best to have the CLI live outside the directory; similar to helpers
- Add integration test to cover that
Hi @vbrazo , had a chance to review this PR? 🙂 |
The Reflector was doing too much; handling Search and List reflections which made it a tad harder to follow. This commit defines a Reflection interface and the correspoding subclasses.
Apologies for the slowness. This week has been busy. I started reading the files, but I still need more time to pull the code and check the work. I'll do that over the next days. |
No worries Vitor, totally understand 💯 . Please shout if you have any questions. 🙂 |
There's an erroneous 'null byte' error in the CI which could be caused by the bundler version. Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to install it ourselves
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and liked what I saw
test/test_determinism.rb
Outdated
@@ -45,7 +45,7 @@ def all_methods | |||
|
|||
def subclasses | |||
Faker.constants.delete_if do |subclass| | |||
%i[Base Bank Books Cat Char Base58 ChileRut Config Creature Date Dog DragonBall Dota ElderScrolls Fallout Games GamesHalfLife HeroesOfTheStorm Internet JapaneseMedia LeagueOfLegends Movies Myst Overwatch OnePiece Pokemon SwordArtOnline TvShows Time VERSION Witcher WorldOfWarcraft Zelda].include?(subclass) | |||
%i[Base Bank Books Cat Char Base58 ChileRut CLI Config Creature Date Dog DragonBall Dota ElderScrolls Fallout Games GamesHalfLife HeroesOfTheStorm Internet JapaneseMedia LeagueOfLegends Movies Myst Overwatch OnePiece Pokemon SwordArtOnline TvShows Time VERSION Witcher WorldOfWarcraft Zelda].include?(subclass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should get rid of this big array and think about a better way to check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, do we want to mark that as a separate piece of work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should raise that as a separate issue? At present, I'm afraid I don't think I have enough background to raise the issue for this case. 🙂
README.md
Outdated
@@ -62,6 +62,14 @@ Faker::Name.name #=> "Christophe Bartell" | |||
Faker::Internet.email #=> "[email protected]" | |||
``` | |||
|
|||
### CLI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should go in our unreleased_README.md
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout. 👍
lib/cli.rb
Outdated
class Base < Thor | ||
Error = Class.new(StandardError) | ||
# Do not print depracation warnings; the CLI will do that | ||
Gem::Deprecate.skip = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to turn this false
after executing the operations?
I'm asking you because we're using namespaces and there are a lot of deprecation warnings. Are we assuming that users will always use the cli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to turn this
false
after executing the operations?
Thanks! This makes perfect sense to me, I had missed that. I'll make the change. ⭐️
Background
Good call here, the intention was to disable the default deprecation warnings only in the context of the CLI
. since it checks for deprecated methods and marks them.
Previously, we'd see the full default deprecation print out after the CLI exited as capture in https://github.com/akabiru/fakerbot/issues/7 - thus the need to gracefully handle the deprecation warnings (in the context of the CLI)
spec.add_dependency('thor', '~> 0.20.0') | ||
spec.add_dependency('tty-pager', '~> 0.12.0') | ||
spec.add_dependency('tty-screen', '~> 0.6.5') | ||
spec.add_dependency('tty-tree', '~> 0.2.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these dependencies is a pretty big deal. Are we comfortable with them? I saw the terminal response. It's pretty cool.
Thoughts? @stympy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a valid concern, from my POV, these libraries go a long way in making the CLI interface easier to work with. 🙂 The alternative would be to write it all ourselves which I'm not sure about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I find all these dependencies to be a big deal. I opened an issue about it (#1642) and plan to stay on 1.9.3 for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@myronmarston your concern is valid.
@akabiru would you agree to remove these dependencies and just show a formatted list of searched results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey folks, apologies for the very delayed response (on vacation). I think the move to a separate gem is the sensible approach. And allows users to opt-in into using the gem.
It did start as a separate gem , no strong objections on this one. 🙂
@vbrazo I'm happy to assist with the extraction &/migration as well.
* move cli doc to unreleased * Reinstate rubygems deprecation warnings
class Base < Thor | ||
Error = Class.new(StandardError) | ||
# Skip default deprecation warning output; the CLI will display that. | ||
Gem::Deprecate.skip_during do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping the CLI
methods in Gem::Deprecate.skip_during
block ensures we safely skip the warnings only in the CLI. Although it's intended for use in tests only, it seems like a sensible solution to me. Ref. https://ruby-doc.org/stdlib-1.9.3/libdoc/rubygems/rdoc/Gem/Deprecate.html
Thank you Vitor. Looking forward to continuously making it even better as a community. 🙂 |
* feat(cli): Pull in fakerbot gem logic * chore(cli): Extract module outside of `faker` dir The module dir `faker` houses the main "faker" namespaces; and it should remain that way. Best to have the CLI live outside the directory; similar to helpers * feat(cli): Add `faker` excecutable * feat(cli): Add renderer; reflector unit tests * feat(cli): Add commands tests * feat(cli): Add integration tests * feat(cli): Add documentation 📖 * chore(cli): Extract constructor to base command * fix(cli): Amend faker version load path - Add integration test to cover that * fix(cli): Skip default deprecation warning output in the CLI * chore(cli): Amend var names * chore(reflectors): Distribute Reflector responsibilities The Reflector was doing too much; handling Search and List reflections which made it a tad harder to follow. This commit defines a Reflection interface and the correspoding subclasses. * chore: Don't specify bunlder version There's an erroneous 'null byte' error in the CI which could be caused by the bundler version. Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to install it ourselves * chore: Address review comments * move cli doc to unreleased * Reinstate rubygems deprecation warnings * chore: Skip Gem::Deprecate warning output in CLI
* feat(cli): Pull in fakerbot gem logic * chore(cli): Extract module outside of `faker` dir The module dir `faker` houses the main "faker" namespaces; and it should remain that way. Best to have the CLI live outside the directory; similar to helpers * feat(cli): Add `faker` excecutable * feat(cli): Add renderer; reflector unit tests * feat(cli): Add commands tests * feat(cli): Add integration tests * feat(cli): Add documentation 📖 * chore(cli): Extract constructor to base command * fix(cli): Amend faker version load path - Add integration test to cover that * fix(cli): Skip default deprecation warning output in the CLI * chore(cli): Amend var names * chore(reflectors): Distribute Reflector responsibilities The Reflector was doing too much; handling Search and List reflections which made it a tad harder to follow. This commit defines a Reflection interface and the correspoding subclasses. * chore: Don't specify bunlder version There's an erroneous 'null byte' error in the CI which could be caused by the bundler version. Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to install it ourselves * chore: Address review comments * move cli doc to unreleased * Reinstate rubygems deprecation warnings * chore: Skip Gem::Deprecate warning output in CLI
What does this PR do?
Integrates the fakerbot gem into Faker as it's CLI
How should this be manually tested?
What are the relevant GitHub issues?
Closes #1505
Questions:
Screenshots