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__)
def install_javascript_dependencies
rails_command "app:update:bin", inline: true
rails_command "app:binstub:yarn", inline: true
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
end

View File

@ -100,6 +100,16 @@ module Rails
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
empty_directory "config"
@ -314,6 +324,11 @@ module Rails
end
remove_task :update_bin_files
def update_bin_yarn
build(:yarn_when_updating)
end
remove_task :update_bin_yarn
def update_active_storage
unless skip_active_storage?
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
end
end
namespace :binstub do
task :yarn do
Rails::AppUpdater.invoke_from_app_generator :update_bin_yarn
end
end
end