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

rails new cool_app --minimal #39282

Merged
merged 1 commit into from Jun 2, 2020
Merged

rails new cool_app --minimal #39282

merged 1 commit into from Jun 2, 2020

Conversation

hahmed
Copy link
Contributor

@hahmed hahmed commented May 14, 2020

Summary

discussion: https://discuss.rubyonrails.org/t/interactive-rails-new/74355/50

rails new cool_app --minimal

A minimal rails stack to get you started, everything that is excluded:

  • skip_action_cable
  • skip_action_mailbox
  • skip_action_mailer
  • skip_action_text
  • skip_active_job
  • skip_active_storage
  • skip_bootsnap
  • skip_jbuilder
  • skip_spring
  • skip_system_tests
  • skip_turbolinks
  • skip_webpack
  • Sprockets should have JavaScript folders by default
  • rails new --minimal webpack=react works

Rails app I created using the minimal flag:

Want to help test out this PR? here is how:

  • Pull down this branch
  • Uninstall your local rails copy using gem uninstall rails
  • Move into the root directory where you pulled down the rails code, then install: rake install
  • Run rails --version which should be Rails 6.1.0.alpha
  • In another directory create your rails app rails new cool_app --minimal

@rails-bot rails-bot bot added the railties label May 14, 2020
@ccasabona
Copy link

This is a good idea though I would suggest keeping Action Mailer. If I were just starting with Rails and had to deal with webpacker, I probably would have skipped it altogether.

@IvanShamatov
Copy link

This can be set in your .railsrc file in Home directory, like default flags for running rails new

# .railsrc
-d postgresql
--skip-action-mailbox
--skip-active-storage
--skip-action-cable
--skip-spring
--skip-sprockets
--skip-turbolinks
-T
--webpacker=react

@prathamesh-sonpatki
Copy link
Member

Instead of skipping few of the frameworks by default, making command line interactive will be good.

rails new chotu --interactive

- Install Action Cable? Yes/no?

-

@hahmed
Copy link
Contributor Author

hahmed commented May 14, 2020

Instead of skipping few of the frameworks by default, making command line interactive will be good.

@prathamesh-sonpatki sounds good, from the discussion I linked above, dhh mentioned 3 things, interactive mode, minimal mode, and add stacks back in if you left them out.

Hopefully will tackle them in separate PR's, actually I'm going to mention that in the description above. If DHH drops the minimal for interactive, I will just go ahead and do that in this PR 👍

@hahmed
Copy link
Contributor Author

hahmed commented May 14, 2020

This can be set in your .railsrc file in Home directory,

@IvanShamatov cool, this came out of the discussion linked in the description, we are going to provide an easy way to create a minimal rails app via the cli

@dhh
Copy link
Member

dhh commented May 14, 2020

I like the idea of both minimal and interactive. Minimal really should be truly minimal, though. No webpacker, no Turbolinks, no action mailer, etc. Just action pack + active record (and the dependencies, railties + active support etc).

@ccasabona
Copy link

ccasabona commented May 14, 2020 via email

@mikkovedru
Copy link

mikkovedru commented May 14, 2020

@prathamesh-sonpatki

Instead of skipping few of the frameworks by default, making command line interactive will be good.

rails new chotu --interactive
> - Install Action Cable? Yes/no?

The interactive mode would certainly benefit experienced developers, but it would help new/inexperienced people the most. Therefore instead of displaying only a module name (not necessarily previously known to a new developer), it would be good to display more information than that. And here we can have two possible solutions:

  1. Automatically explain what this specific option means and what it is used for. Short and to the point (maybe with an official documentation URL, which explains this module in more detail).
  2. In addition to "Yes/No" also allow to choose "Help", which would explain the purpose and the ramifications of enabling/disabling the module in more detail. Since the help was requested separately, it means that the user is fine with getting more text on the screen.
  3. Both. Automatically display a short description, but when requested separately, explain the module in even more detail.

@hahmed hahmed marked this pull request as ready for review May 14, 2020 21:02
@hahmed hahmed force-pushed the rails-minimal branch 2 times, most recently from 976022b to d16d1e8 Compare May 15, 2020 08:45
@hahmed hahmed changed the title rails new --minimal (a minimal rails stack) rails new cool_app --minimal (a minimal rails stack) May 15, 2020
@simi
Copy link
Contributor

simi commented May 15, 2020

What about to call it "classic" instead of "minimal?

@dhh
Copy link
Member

dhh commented May 15, 2020 via email

@hahmed hahmed changed the title rails new cool_app --minimal (a minimal rails stack) rails new cool_app --minimal May 15, 2020
@bhaibel
Copy link

bhaibel commented May 16, 2020 via email

@dhh
Copy link
Member

dhh commented May 16, 2020

I'd like us to really go minimal here, so let's add a few more skips:

  • skip_system_tests (and minimal has this on)
  • skip_jbuilder (and minimal has this on)

But then, conversely, we should consider actually preconfiguring sprockets for JavaScript in this mode.

@dhh
Copy link
Member

dhh commented May 16, 2020

We should also allow you to start from the negative --minimal base, and then add things back in. So --minimal --webpack=react should work and do the right thing.

@hahmed
Copy link
Contributor Author

hahmed commented May 16, 2020

Did you want to remove these from --minimal too?

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.2'
end

@dhh
Copy link
Member

dhh commented May 16, 2020

Let's just leave that stuff there for now. Although that listen gem looks like maybe it should have been part of skip spring? Thought that was what it was for?

@dhh
Copy link
Member

dhh commented May 16, 2020

  # Use an evented file watcher to asynchronously detect changes in source code,
  # routes, locales, etc. This feature depends on the listen gem.
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker

So no, we need the listen gem.

@dhh
Copy link
Member

dhh commented May 16, 2020

Actually, on second thought, let's remove the rack-mini-profiler and the web-console. Maybe something like skip_dev_gems or something. Point of --minimal is to pare this all the way down.

@hahmed
Copy link
Contributor Author

hahmed commented May 16, 2020

  # Use an evented file watcher to asynchronously detect changes in source code,
  # routes, locales, etc. This feature depends on the listen gem.
  <%= '# ' unless depend_on_listen? %>config.file_watcher = ActiveSupport::EventedFileUpdateChecker

We use to the EventedFileUpdateChecker when the listen gem has been added, otherwise we stay with the default FileUpdateChecker (I was digging into this a while back, so not sure about the full context if we only use the FileUpdateChecker)

Will leave the listen gem 👍

@hahmed hahmed force-pushed the rails-minimal branch 2 times, most recently from 5feb69d to f35386f Compare May 20, 2020 10:45
@hahmed
Copy link
Contributor Author

hahmed commented May 21, 2020

@dhh this is ready, let me know if there is anything I have missed?

@dhh dhh self-assigned this May 23, 2020
@dhh
Copy link
Member

dhh commented May 23, 2020

Will review and test. It looks good, just want to test.

Copy link

@KevinBongart KevinBongart left a comment

Choose a reason for hiding this comment

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

Should the rails --help text be updated as part of this PR?

railties/CHANGELOG.md Outdated Show resolved Hide resolved
@dhh
Copy link
Member

dhh commented May 31, 2020

I've been stuck testing this because rails webpacker:install no longer runs for me on master. Haven't diagnosed it fully. I'm fine on the 6.0.3 release, but running this task on master just hangs. I don't think it's specific to this PR, though. But need to figure it out before we can move forward.

@dhh
Copy link
Member

dhh commented May 31, 2020

Sorry, I was stuck due to a recursive issue with bin/yarn (it'll loop on itself if you have ./bin in your path!). Now that I've run things through, it generally seems good, but I noticed that Active Job is still included by default. Let's take that out.

@dhh
Copy link
Member

dhh commented May 31, 2020

Otherwise, I think we're good with a rebase to merge.

Your app will not include any of the following:

- action_cable
- active_storage
- action_text
- action_mailer
- action_mailbox
- bootsnap
- javascript
- jbuilder
- rack mini profiler
- spring
- system tests
- turbolinks
- webconsole
- webpack

Co-authored-by: dhh <david@loudthinking.com>
@hahmed
Copy link
Contributor Author

hahmed commented Jun 2, 2020

but I noticed that Active Job is still included by default. Let's take that out.

Cool, that's been done 👍

@dhh dhh merged commit 7a321d8 into rails:master Jun 2, 2020
@hahmed hahmed deleted the rails-minimal branch June 2, 2020 21:09
@sjayanna
Copy link

sjayanna commented Jun 8, 2020

Awesome!

@Erol
Copy link
Contributor

Erol commented Jul 28, 2020

❤️

@matheussilvasantos
Copy link

Just wondering if it's worth to add what is remaining when using minimal somewhere in the documentation, at first saw it wasn't clear for me.

@Drenmi
Copy link
Contributor

Drenmi commented Dec 21, 2020

I can confirm that attempting to use this as a base, and selectively re-enabling libraries using --no-skip-* is currently not working. Will have a look and see if I can chip in here.

$ rails -v
Rails 6.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet