-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Introduce suspenders:setup
generator
#1157
Conversation
b5b4412
to
ec9869b
Compare
ec9869b
to
0a01511
Compare
Replaces the [default setup script][] provided by Rails. The trade-off being that the implementation is simple, but the cost is we risk drifting from Rails. After attempting to use [gsub_file][] and [insert_into_file][], it felt simpler to just override the file completely. Uses [Homebrew Bundle][] in combination with [asdf][] to install system and tool dependencies locally. Re-introduces [dev:prime][] to seed development data on top of [seed][] data necessary for production. Allow caller to wipe the database clean by setting `WIPE_DATABASE=true` before running `bin/setup`. Additionally, we [setup the test environment][] to avoid issues with asset compilation. [default setup script]: https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/app/templates/bin/setup.tt [gsub_file]: https://rubydoc.info/gems/thor/Thor/Actions#gsub_file-instance_method [insert_into_file]: https://rubydoc.info/gems/thor/Thor/Actions#insert_into_file-instance_method [Homebrew Bundle]: https://github.com/Homebrew/homebrew-bundle [asdf]: https://asdf-vm.com [dev:prime]: https://thoughtbot.com/blog/priming-the-pump [seed]: https://guides.rubyonrails.org/active_record_migrations.html#migrations-and-seed-data [setup the test environment]: https://github.com/rails/rails/pull/47719/files
0a01511
to
c338a85
Compare
Running `dev:prime` calls `db:setup`, which appears to be wiping the database for us. I tried updating it to use `db:prepare`, but that means we will always seed the database with data from the `dev.rake` file, resulting in duplicate records. This implementation is consistent with the existing implementation.
52daa95
to
09fbfd0
Compare
Clobber and precompile assets during setup if using [Sprockets][]. This is helpful in cases where one might switch branches frequently, which can result in broken assets. [Sprockets]: https://github.com/rails/sprockets
09fbfd0
to
893ad7b
Compare
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 feels like it conflates system setup with app setup. I'm not sold on mixing the two.
(And I say that as someone who doesn't use Homebrew.)
@@ -0,0 +1,61 @@ | |||
#!/usr/bin/env ruby |
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 admit, the idea of writing this shell script in Ruby never made sense to me.
Is the concern that this setup script seems to favor Should those be the responsibility of something like Laptop |
The system setup has traditionally been the responsibility of the Laptop script, yeah. Not sure why we would duplicate it here. |
We've decided this script should not conflate system and application setup.
We'll introduce this in a separate generator.
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.
Nice!
Follow-up to #1157 Removes obsolete files and test helpers.
Relates to #1157 For now, this generator simply creates `dev.rake` which contains [dev:prime][]. Note that we'll want this generator to run **after** `suspenders:factories`. If future application specific tasks need to be added, we can use this generator. However, this should not be confused with the existing pattern of creating tasks under the suspenders namespace, such as the existing `lib/tasks/suspenders.rake`. Tasks under this namespace cannot be edited by the consumer, whereas tasks generated by `suspenders:tasks` are intended to be edited by the consumer. [dev:prime]: https://thoughtbot.com/blog/priming-the-pump
Relates to #1157 For now, this generator simply creates `dev.rake` which contains [dev:prime][]. Note that we'll want this generator to run **after** `suspenders:factories`. If future application specific tasks need to be added, we can use this generator. However, this should not be confused with the existing pattern of creating tasks under the suspenders namespace, such as the existing `lib/tasks/suspenders.rake`. Tasks under this namespace cannot be edited by the consumer, whereas tasks generated by `suspenders:tasks` are intended to be edited by the consumer. [dev:prime]: https://thoughtbot.com/blog/priming-the-pump
Replaces the [default setup script][] provided by Rails. The trade-off being that the implementation is simple, but the cost is we risk drifting from Rails. After attempting to use [gsub_file][] and [insert_into_file][], it felt simpler to just override the file completely. Conditionally call [dev:prime][] to seed development data on top of [seed][] data necessary for production. A follow-up commit will re-introduce this task. Additionally, we [setup the test environment][] to avoid issues with asset compilation. [default setup script]: https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/app/templates/bin/setup.tt [gsub_file]: https://rubydoc.info/gems/thor/Thor/Actions#gsub_file-instance_method [insert_into_file]: https://rubydoc.info/gems/thor/Thor/Actions#insert_into_file-instance_method [dev:prime]: https://thoughtbot.com/blog/priming-the-pump [seed]: https://guides.rubyonrails.org/active_record_migrations.html#migrations-and-seed-data [setup the test environment]: https://github.com/rails/rails/pull/47719/files
Relates to #1157 For now, this generator simply creates `dev.rake` which contains [dev:prime][]. Note that we'll want this generator to run **after** `suspenders:factories`. If future application specific tasks need to be added, we can use this generator. However, this should not be confused with the existing pattern of creating tasks under the suspenders namespace, such as the existing `lib/tasks/suspenders.rake`. Tasks under this namespace cannot be edited by the consumer, whereas tasks generated by `suspenders:tasks` are intended to be edited by the consumer. [dev:prime]: https://thoughtbot.com/blog/priming-the-pump
Replaces the default setup script provided by Rails. The trade-off being
that the implementation is simple, but the cost is we risk drifting from Rails.
After attempting to use gsub_file and insert_into_file, it felt simpler
to just override the file completely.
Clobber and precompile assets during setup if using Sprockets. This
is helpful in cases where one might switch branches frequently, which
can result in broken assets.
Additionally, we setup the test environment to avoid issues with asset
compilation in tests.