Ready, Set, Go!
rsg
is an opinionated Rails application generator that scaffolds apps with the bare minimum needed to run
nicely in development and production.
Usage
# Install the executable
gem install rsg
# Generate an API application called "the-next-twitter" under `~/projects`
rsg --api ~/projects/the-next-twitter
# Generate a "traditional" web application called "the-next-tiktok" under `~/projects`
rsg ~/projects/the-next-tiktok
# Use a custom application template to generate an application
rsg -m "my-org-template.rb" ~/projects/the-next-github
The main rsg
executable assumes you have everything necessary for bootstrapping the app, like for example
having DATABASE_URL
set for automatic execution of rails db:migrate
and nodejs / yarn available for
configuration of webpacker.
Alongside the rsg
executable, the gem also provides a set of Rails generators that can be executed on top
of existing apps. You can lookup the ones that are available with rails generate --help | grep rsg
.
Background
Rails comes with lots of things by default these days and while it provides a nice experience for newbies, it is terrible for folks that would like to create micro services / apps with just the bare minimum. We also believe that some of the provided defaults are not that great for production use (like for example logging).
Sure, we can use the --minimal
flag and ignore most of the framework, or pass in --api
to cut down even
more but the meaning of --minimal
will change over time. Another option would be to run rails new --help
and go through all those 20+ --skip-*
flags (in Rails 6.1) and pass the appropriate ones to rails new
,
which is kinda boring and error prone.
Even if we provide all the --skip-*
flags, there are things that we can't customize from the CLI, like
for example, the generated README.md
or disabling Rail's encrypted secrets / credentials. The Rails Way :tm:
of doing those types of customizations are through application templates.
With those one can easily do things like add gems, create routes, etc. Application templates are simply Ruby
files that can be passed on to the -m
flag of rails new
. Those files can live anywhere, like on GitHub
repositories or Gists, or even inside other gems (like rsg
itself).
With all that in mind we've decided to create our own Rails application generator that's simplifies that
process. This project draws some inspiration from thoughtbot's suspenders
but it has a subtle difference, rsg
will do its best to hide the complexities of rails new
s by opting out
of all components it can (like active_record
or the asset pipeline) and hiding the vast majority of rails new
flags from its help just so users are not confused. Once that "barebones application" is created, the rsg
generators kick in and do their magic.
Different from suspenders, we chose to work off from application templates for "orchestration of generators"
instead of doing things from the app generator itself.
The reason for doing that is just so developers can easily customize how rsg
behaves by providing a simple ruby
file to it, instead of having to go through the process of adding extra flags, going through PRs, etc.
Finally, we want rsg
to be the basis of other application generators so we did the best we could to make
wrapping rsg
into your own internal / open source gem very simple (more on that below).
How does it work?
TODO: Write about it, with as many links as possible
Base application
TODO: Document how it'll look like
Available generators
TODO: Document, explain what they do
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests.
You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update
the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for
the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
NOTE: The gem is currently owned by @fgrehm on RubyGems so you'll jave to ask him to publish a new release, we'll automate releases from GitHub actions or CircleCI later and will transfer the gem ownership to doximity.
Running rsg
from source
git clone https://github.com/doximity/rsg && cd rsg
./bin/setup
# Scaffold a sample app under ./tmp and configure the app to use RSG from sources
./exe/rsg --path="../../" tmp/sample-app
# Or if you want an API only project
./exe/rsg --path="../../" --api tmp/sample-api
Upgrading rsg to scaffold apps for newer Rails releases
TODO: Document
Adding a new generator
TODO: Document, provide as many links as possible
Custom rsg
actions
TODO: Document, or link to file
Wrapping rsg
into your own generator
TODO: Document
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/doximity/rsg.
TODO
- [x] Generate a barebones app with a clean gemfile, pry and basic README
- [x] Hide the
rails new
flags that make sense or have a sane default - [x] Disable Rails encrypted secrets
- [x] Healthcheck endpoint
- [x]
git commit
after each generator - [x] Application template that calls generators
- [x] Accept a template, set a default
- [x] Basic documentation with placeholders of content to write later
- [x] Smoke test app generation in CI
- [ ] Switch to Rails 7 beta
- [ ] Ability to output a consolidated after install message from multiple generators
- [ ] Automated releases
- [ ] Generators
- [x] webpacker for all the things, including SASS
- [x] Productiong grade logging
- [x]
rspec-rails
- [x]
dotenv-rails
- [x] Bootstrap
- [ ] postcss to remove unused CSS (optional)
- [ ] i18n
- [ ] CI with GitHub Actions
- [ ] standardrb
- [ ] docker-compose
- [ ]
slim-rails
- [ ]
factory_bot
- [ ]
letter_opener_web
- [ ] robots.txt
- [ ] Code coverage for rspec
- [ ] CI with CircleCI
- [ ] Sidekiq with opt in support for sidekiq-pro and sidekiq-enterprise
- [ ]
action_cable
- [ ]
action_mailbox
- [ ]
action_mailer
- [ ]
action_text
- [ ]
active_job
- [x]
active_record
- [ ]
active_storage
- [ ]
test_unit