diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index f02771b467ff8..d42e5f30398e2 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,9 @@ +* bin/setup uses `bun` instead of `yarn` when generated an app with bun + + Use `bun install` on `bin/setup` when using `bun`. + + *Cadu Ribeiro* + * `config/application.rb` now includes ```ruby diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index c5a8dc28250ac..68356da0da1da 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -467,10 +467,16 @@ def hotwire_gemfile_entry end def using_node? + return if using_bun? + (options[:javascript] && !%w[importmap].include?(options[:javascript])) || (options[:css] && !%w[tailwind sass].include?(options[:css])) end + def using_bun? + options[:javascript] == "bun" + end + def node_version if using_node? ENV.fetch("NODE_VERSION") do @@ -569,12 +575,12 @@ def dockerfile_deploy_packages def css_gemfile_entry return unless options[:css] - if !using_node? && options[:css] == "tailwind" + if using_node? || using_bun? + GemfileEntry.floats "cssbundling-rails", "Bundle and process CSS [https://github.com/rails/cssbundling-rails]" + elsif options[:css] == "tailwind" GemfileEntry.floats "tailwindcss-rails", "Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]" - elsif !using_node? && options[:css] == "sass" + elsif options[:css] == "sass" GemfileEntry.floats "dartsass-rails", "Use Dart SASS [https://github.com/rails/dartsass-rails]" - else - GemfileEntry.floats "cssbundling-rails", "Bundle and process CSS [https://github.com/rails/cssbundling-rails]" end end @@ -684,12 +690,12 @@ def run_hotwire def run_css return if !options[:css] || !bundle_install? - if !using_node? && options[:css] == "tailwind" + if using_bun? || using_node? + rails_command "css:install:#{options[:css]}" + elsif options[:css] == "tailwind" rails_command "tailwindcss:install" - elsif !using_node? && options[:css] == "sass" + elsif options[:css] == "sass" rails_command "dartsass:install" - else - rails_command "css:install:#{options[:css]}" end end diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt index 1cf6fe38a6b5c..3625f9c94ac2d 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt @@ -19,6 +19,10 @@ FileUtils.chdir APP_ROOT do # Install JavaScript dependencies system("yarn check --check-files") || system!("yarn install") +<% elsif using_bun? %> + # Install JavaScript dependencies + + system("bun install") <% end -%> <% unless options.skip_active_record? -%>