From 155b7570fa63e40c1d134d4038cfbb58dea1d260 Mon Sep 17 00:00:00 2001 From: Cadu Ribeiro Date: Tue, 18 Jan 2022 00:38:58 -0300 Subject: [PATCH] Add yarn install into bin/setup when not using importmap After af7428c4acd0fcf9eed5c7215856594a078f23b7 the yarn install instructions was dropped from bin/setup. This commmit adds it into the setup script again if the user is not using importmap. --- railties/CHANGELOG.md | 6 ++++++ .../lib/rails/generators/rails/app/templates/bin/setup.tt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index bad374cd13c..284e066fee8 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,9 @@ +* Add JavaScript dependencies installation on bin/setup + + Add `yarn install` to bin/setup when using esbuild, webpack, or rollout. + + *Carlos Ribeiro* + * Use `controller_class_path` in `Rails::Generators::NamedBase#route_url` The `route_url` method now returns the correct path when generating 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 1979f248a61..7eb63f83d72 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt @@ -15,6 +15,12 @@ FileUtils.chdir APP_ROOT do puts "== Installing dependencies ==" system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") +<% if ["webpack", "esbuild", "rollup"].include?(options.javascript) -%> + + # Install JavaScript dependencies + system("yarn check --check-files") || system!("yarn install") +<% end -%> + <% unless options.skip_active_record? -%> # puts "\n== Copying sample files =="