Skip to content

Commit

Permalink
Merge pull request #5047 from solidusio/waiting-for-dev/remove_solidu…
Browse files Browse the repository at this point in the history
…s_frontend_from_the_installer

Remove solidus_frontend option from the installer
  • Loading branch information
waiting-for-dev committed Apr 26, 2023
2 parents 4cbccac + 1fe0925 commit 3ee976d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 101 deletions.
9 changes: 2 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,8 @@ jobs:
- install_solidus: { flags: "--sample=false --frontend=none --authentication=none" }
- test_page: { expected_text: "<title>Ruby on Rails" }

- install_solidus: { flags: "--sample=false --frontend=classic --authentication=custom" }
- test_page: { expected_text: "data-hook=" }
- run:
name: Ensure the correct PayPal is installed for SSF
command: |
cd /tmp/my_app
bundle list | grep 'solidus_paypal_commerce_platform (0.'
- install_solidus: { flags: "--sample=false --frontend=starter --authentication=custom" }
- test_page: { expected_text: "The only eCommerce platform you’ll ever need." }

- run:
name: "Test `rake task: extensions:test_app`"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
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']
bundle_command "add solidus_paypal_commerce_platform --version='#{version}'"
bundle_command "add solidus_paypal_commerce_platform --version='~> 1.0'"
end

generate "solidus_paypal_commerce_platform:install #{migrations_flag}"
generate "solidus_paypal_commerce_platform:install --migrate=#{options[:migrate]}"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
unless Bundler.locked_gems.dependencies['solidus_stripe']
bundle_options = @selected_frontend == 'classic' ? "--version='< 5'" : "--version='~> 5.a'"
bundle_command "add solidus_stripe #{bundle_options}"
bundle_command "add solidus_stripe --version '~> 5.a'"
end

generate 'solidus_stripe:install'
41 changes: 6 additions & 35 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class InstallGenerator < Rails::Generators::AppBase

FRONTENDS = [
{ name: 'starter', description: 'Generate all necessary controllers and views directly in your Rails app', default: true },
{ name: 'classic', description: 'Install `solidus_frontend`, was the default in previous solidus versions (DEPRECATED)' },
{ name: 'none', description: 'Skip installing a frontend' }
]

Expand All @@ -25,36 +24,10 @@ class InstallGenerator < Rails::Generators::AppBase
]

PAYMENT_METHODS = [
{
name: 'paypal',
frontends: %w[none classic starter],
description: 'Install `solidus_paypal_commerce_platform`',
default: true,
},
{
name: 'bolt',
frontends: %w[classic],
description: 'Install `solidus_bolt`',
default: false,
},
{
name: 'stripe',
frontends: %w[none classic starter],
description: 'Install `solidus_stripe`',
default: false,
},
{
name: 'braintree',
frontends: %w[none starter],
description: 'Install `solidus_braintree`',
default: false,
},
{
name: 'none',
frontends: %w[none classic starter],
description: 'Skip installing a payment method',
default: false,
},
{ name: 'paypal', description: 'Install `solidus_paypal_commerce_platform`', default: true },
{ name: 'stripe', description: 'Install `solidus_stripe`', default: false },
{ name: 'braintree', description: 'Install `solidus_braintree`', default: false },
{ name: 'none', description: 'Skip installing a payment method', default: false }
]

class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
Expand Down Expand Up @@ -83,9 +56,7 @@ def prepare_options

@selected_frontend = selected_option_for(
'frontend',
selected:
('classic' if has_gem?('solidus_frontend')) ||
ENV['FRONTEND'] || options[:frontend],
selected: ENV['FRONTEND'] || options[:frontend],
available_options: FRONTENDS,
)

Expand All @@ -105,7 +76,7 @@ def prepare_options
('stripe' if has_gem?('solidus_stripe')) ||
('bolt' if has_gem?('solidus_bolt')) ||
ENV['PAYMENT_METHOD'] || options[:payment_method],
available_options: PAYMENT_METHODS.select { _1[:frontends].include?(@selected_frontend) },
available_options: PAYMENT_METHODS,
)

# Silence verbose output (e.g. Rails migrations will rely on this environment variable)
Expand Down
6 changes: 5 additions & 1 deletion core/lib/spree/testing_support/common_rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize
# While the dummy app is generated the current directory
# within ruby is changed to that of the dummy app.
sh({
'FRONTEND' => ENV['FRONTEND'] || 'classic',
'FRONTEND' => ENV['FRONTEND'] || 'none',
}, [
'bin/rails',
'generate',
Expand All @@ -40,6 +40,10 @@ def initialize
"--quiet",
].shelljoin)

# TODO: Our extensions ecosystem expects the legacy frontend when the
# env FRONTEND variable is not given
ENV['FRONTEND'] || sh("bundle add solidus_frontend")

puts "Setting up dummy database..."

sh "bin/rails db:environment:set RAILS_ENV=test"
Expand Down
23 changes: 3 additions & 20 deletions core/spec/generators/solidus/install/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
end
end

it 'defaults to "paypal" for payments when frontend is "classic"' do
generator = described_class.new([], ['--auto-accept', '--frontend=classic'])
it 'defaults to "paypal" for payments when frontend is "starter"' do
generator = described_class.new([], ['--auto-accept', '--frontend=starter'])
generator.prepare_options

aggregate_failures do
expect(generator.instance_variable_get(:@selected_frontend)).to eq("classic")
expect(generator.instance_variable_get(:@selected_frontend)).to eq("starter")
expect(generator.instance_variable_get(:@selected_authentication)).to eq("devise")
expect(generator.instance_variable_get(:@selected_payment_method)).to eq("paypal")
end
Expand Down Expand Up @@ -60,23 +60,6 @@
end

context 'when asked interactively' do
it 'presents different options for the "classic"' do
questions = []
generator = described_class.new([], ['--frontend=classic', '--authentication=devise'])
allow(generator).to receive(:ask_with_description) { |**args| questions << args }

generator.prepare_options

expect(questions.size).to eq(1)
expect(questions.first[:limited_to]).to eq(['paypal', 'bolt', 'stripe', 'none'])
expect(questions.first[:default]).to eq('paypal')
expect(strip_ansi questions.first[:desc]).to include('[paypal]')
expect(strip_ansi questions.first[:desc]).to include('[stripe]')
expect(strip_ansi questions.first[:desc]).to include('[bolt]')
expect(strip_ansi questions.first[:desc]).to_not include('[braintree]')
expect(strip_ansi questions.first[:desc]).to include('[none]')
end

it 'presents different options for the "starter"' do
questions = []
generator = described_class.new([], ['--frontend=starter', '--authentication=devise'])
Expand Down

0 comments on commit 3ee976d

Please sign in to comment.