Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the install generator #3777

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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