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 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

ccasabona commented May 14, 2020

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

IvanShamatov commented May 14, 2020

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

prathamesh-sonpatki commented May 14, 2020

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

@hahmed hahmed force-pushed the hahmed:rails-minimal branch from 85de37b to e2d3220 May 14, 2020
@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

@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 force-pushed the hahmed:rails-minimal branch from e2d3220 to ea6ddb7 May 14, 2020
@hahmed hahmed marked this pull request as ready for review May 14, 2020
@hahmed hahmed force-pushed the hahmed:rails-minimal branch 2 times, most recently from 976022b to d16d1e8 May 14, 2020
@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

@hahmed hahmed force-pushed the hahmed:rails-minimal branch from d16d1e8 to 44c6afe May 15, 2020
@hahmed hahmed changed the title rails new cool_app --minimal (a minimal rails stack) rails new cool_app --minimal May 15, 2020
@hahmed hahmed requested a review from jonathanhefner May 15, 2020
@bhaibel
Copy link

bhaibel commented May 16, 2020

@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 hahmed:rails-minimal branch from 81ac4df to ac2688b May 19, 2020
@hahmed
Copy link
Contributor Author

hahmed commented May 20, 2020

👀 into that failed test

@hahmed hahmed force-pushed the hahmed:rails-minimal branch from ac2688b to 0fe3f1f May 20, 2020
@rails-bot rails-bot bot added the activejob label May 20, 2020
@hahmed hahmed force-pushed the hahmed:rails-minimal branch 3 times, most recently from 5feb69d to f35386f May 20, 2020
@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 left a comment

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.

@hahmed hahmed force-pushed the hahmed:rails-minimal branch from 53ae27a to b0d8438 Jun 1, 2020
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 hahmed force-pushed the hahmed:rails-minimal branch from b0d8438 to b406b7e Jun 1, 2020
@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
2 checks passed
2 checks passed
build
Details
buildkite/rails Build #69759 passed (10 minutes, 50 seconds)
Details
@hahmed hahmed deleted the hahmed:rails-minimal branch Jun 2, 2020
@sjayanna
Copy link

sjayanna commented Jun 8, 2020

Awesome!

alipman88 added a commit to alipman88/rails that referenced this pull request Jun 14, 2020
@Erol
Copy link
Contributor

Erol commented Jul 28, 2020

❤️

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

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.