From 56d7a0f9c5b02077af1f7fb38e7a4a595171b8cf Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Wed, 12 Apr 2023 16:32:38 +0200 Subject: [PATCH] Remove automatic propagation of generators options By removing the override of the `generate` method in this generator, we stop propagating those custom arguments to all the inner generators called by the installer. For example, at the moment, the installer is running rails generate rspec:install --auto-accept --auto-run-migrations see [1], which doesn't make sense and might also have unexpected behaviors if we (or any dependency) run a generator during their installation, which accepts those arguments. Instead of always propaging these option, we are explicitely declaring them when needed. [1]: https://github.com/solidusio/solidus_starter_frontend/issues/295 Co-authored-by: safafa --- .../install/app_templates/payment_method/bolt.rb | 2 +- .../install/app_templates/payment_method/braintree.rb | 2 +- .../install/app_templates/payment_method/paypal.rb | 11 +++++++++-- .../generators/solidus/install/install_generator.rb | 6 ------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/lib/generators/solidus/install/app_templates/payment_method/bolt.rb b/core/lib/generators/solidus/install/app_templates/payment_method/bolt.rb index fdb6d602fec..dfd96a3c913 100644 --- a/core/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +++ b/core/lib/generators/solidus/install/app_templates/payment_method/bolt.rb @@ -10,4 +10,4 @@ bundle_command 'add solidus_bolt' end -generate 'solidus_bolt:install' +generate "solidus_bolt:install --auto-run-migrations=#{options[:migrate]}" diff --git a/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb b/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb index a3bebb93132..7d6b29c891d 100644 --- a/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb +++ b/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb @@ -2,4 +2,4 @@ bundle_command 'add solidus_braintree --version "~> 3.0"' end -generate 'solidus_braintree:install' +generate "solidus_braintree:install --migrate=#{options[:migrate]}" diff --git a/core/lib/generators/solidus/install/app_templates/payment_method/paypal.rb b/core/lib/generators/solidus/install/app_templates/payment_method/paypal.rb index faf2952b32a..8b0aaf6ab36 100644 --- a/core/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +++ b/core/lib/generators/solidus/install/app_templates/payment_method/paypal.rb @@ -2,9 +2,16 @@ say_status :warning, "Support for frontends other than `solidus_frontend` by `solidus_paypal_commerce_platform` is still in progress.", :yellow end +if @selected_frontend == 'classic' + version = '< 1' + migrations_flag = options[:migrate] ? '--auto-run-migrations' : '--skip-migrations' +else + version = '~> 1.0' + migrations_flag = "--migrate=#{options[:migrate]}" +end + unless Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform'] - version = @selected_frontend == 'classic' ? '< 1' : '~> 1.0' bundle_command "add solidus_paypal_commerce_platform --version='#{version}'" end -generate 'solidus_paypal_commerce_platform:install' +generate "solidus_paypal_commerce_platform:install #{migrations_flag}" diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index fb82b5edb8f..7d6d3f14a1d 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -222,12 +222,6 @@ def complete private - def generate(what, *args, abort_on_failure: true) - args << '--auto-accept' if options[:auto_accept] - args << '--auto-run-migrations' if options[:migrate] - super(what, *args, abort_on_failure: abort_on_failure) - end - def bundle_command(command, env = {}) # Make `bundle install` less verbose by skipping the "Using ..." messages super(command, env.reverse_merge('BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES' => 'true'))