diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index ba0a4ab99aa..281f1d52f4c 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -111,14 +111,20 @@ def configure_application end end - def install_default_plugins + def plugin_install_preparation + @plugins_to_be_installed = [] + @plugin_generators_to_run = [] + end + + def install_auth_plugin if options[:with_authentication] && (options[:auto_accept] || !no?(" - Solidus has a default authentication extension that uses Devise. - You can find more info at https://github.com/solidusio/solidus_auth_devise. + Solidus has a default authentication extension that uses Devise. + You can find more info at https://github.com/solidusio/solidus_auth_devise. - Would you like to install it? (y/n)")) + Would you like to install it? (y/n)")) - gem 'solidus_auth_devise' + @plugins_to_be_installed << 'solidus_auth_devise' + @plugin_generators_to_run << 'solidus:auth:install' end end @@ -135,7 +141,10 @@ def install_payment_method gem_name = PAYMENT_METHODS.fetch(name) - gem gem_name if gem_name + if gem_name + @plugins_to_be_installed << gem_name + @plugin_generators_to_run << "#{gem_name}:install" + end end def include_seed_data @@ -156,6 +165,19 @@ def create_database rake 'db:create' end + def run_bundle_install_if_needed_by_plugins + @plugins_to_be_installed.each do |plugin_name| + gem plugin_name + end + + bundle_cleanly{ run "bundle install" } if @plugins_to_be_installed.any? + run "spring stop" + + @plugin_generators_to_run.each do |plugin_generator_name| + generate "#{plugin_generator_name} --skip_migrations=false" + end + end + def run_migrations if @run_migrations say_status :running, "migrations" @@ -221,5 +243,11 @@ def complete puts "Enjoy!" end end + + private + + def bundle_cleanly(&block) + Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&block) : Bundler.with_clean_env(&block) + end end end