1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Create update yarn task (#39314)

* Use app:binstub:yarn in Action Text install generator
This commit is contained in:
Vinicius Stock 2020-05-17 13:51:32 -04:00 committed by GitHub
parent 12bfc8d9a6
commit 98a3644be0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View file

@ -9,10 +9,10 @@ module ActionText
source_root File.expand_path("templates", __dir__) source_root File.expand_path("templates", __dir__)
def install_javascript_dependencies def install_javascript_dependencies
rails_command "app:update:bin", inline: true rails_command "app:binstub:yarn", inline: true
say "Installing JavaScript dependencies", :green say "Installing JavaScript dependencies", :green
run "yarn add #{js_dependencies.map { |name, version| "#{name}@#{version}" }.join(" ")}", run "bin/yarn add #{js_dependencies.map { |name, version| "#{name}@#{version}" }.join(" ")}",
abort_on_failure: true, capture: true abort_on_failure: true, capture: true
end end

View file

@ -100,6 +100,16 @@ module Rails
end end
end end
def yarn_when_updating
return if File.exist?("bin/yarn")
template "bin/yarn" do |content|
"#{shebang}\n" + content
end
chmod "bin", 0755 & ~File.umask, verbose: false
end
def config def config
empty_directory "config" empty_directory "config"
@ -314,6 +324,11 @@ module Rails
end end
remove_task :update_bin_files remove_task :update_bin_files
def update_bin_yarn
build(:yarn_when_updating)
end
remove_task :update_bin_yarn
def update_active_storage def update_active_storage
unless skip_active_storage? unless skip_active_storage?
rails_command "active_storage:update", inline: true rails_command "active_storage:update", inline: true

View file

@ -59,4 +59,10 @@ namespace :app do
Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info
end end
end end
namespace :binstub do
task :yarn do
Rails::AppUpdater.invoke_from_app_generator :update_bin_yarn
end
end
end end