Skip to content

Commit

Permalink
Fix the install generator
Browse files Browse the repository at this point in the history
ref #3775

Fixes the issues with the install generator by bundling after adding the
extensions to the gemfile, stopping spring, and then running the install
generators for each of the installed extensions.

Currently this works a bit wonky as the extensions will ask if you want
to run migrations, and that's not desirable as migrations are already run
after these extensions are installed. Will fix and update shortly, just
wanted to get this into a PR!
  • Loading branch information
seand7565 committed Oct 5, 2020
1 parent 10a1199 commit 6f6bd2e
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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

0 comments on commit 6f6bd2e

Please sign in to comment.