solidus_core 3.2.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +4 -0
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/country.rb +1 -1
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/line_item.rb +2 -2
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +4 -3
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_updater.rb +11 -2
- data/app/models/spree/payment/processing.rb +58 -55
- data/app/models/spree/payment_method/bogus_credit_card.rb +6 -7
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +16 -10
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product.rb +3 -3
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/promotion_code.rb +1 -1
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipment.rb +2 -2
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_rate.rb +9 -3
- data/app/models/spree/taxon.rb +1 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant.rb +25 -5
- data/app/models/spree/zone.rb +1 -1
- data/config/locales/en.yml +17 -2
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +11 -9
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +8 -9
- data/lib/generators/solidus/install/install_generator.rb +213 -190
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -4
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +10 -8
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -12
- data/lib/spree/app_configuration.rb +23 -0
- data/lib/spree/core/controller_helpers/current_host.rb +5 -1
- data/lib/spree/core/engine.rb +1 -0
- data/lib/spree/core/search/base.rb +17 -8
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +1 -20
- data/lib/spree/migrations.rb +12 -10
- data/lib/spree/permitted_attributes.rb +4 -1
- data/lib/spree/preferences/static_model_preferences.rb +25 -8
- data/lib/spree/rails_compatibility.rb +0 -17
- data/lib/spree/testing_support/common_rake.rb +7 -6
- data/lib/spree/testing_support/dummy_app.rb +2 -2
- data/lib/spree/testing_support/factories/address_factory.rb +9 -11
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factory_bot.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +1 -1
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/solidus_core.gemspec +2 -2
- metadata +33 -22
- data/lib/generators/solidus/install/install_generator/bundler_context.rb +0 -105
- data/lib/generators/solidus/install/install_generator/install_frontend.rb +0 -61
- data/lib/generators/solidus/install/install_generator/support_solidus_frontend_extraction.rb +0 -48
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
unless Bundler.locked_gems.dependencies['solidus_frontend']
|
2
|
+
say_status :warning, "Support for frontends other than `solidus_frontend` by `solidus_bolt` is still in progress.", :yellow
|
3
|
+
end
|
4
|
+
|
5
|
+
unless Bundler.locked_gems.dependencies['solidus_auth_devise']
|
6
|
+
say_status :warning, "Running solidus_bolt without solidus_auth_devise is not supported.", :yellow
|
7
|
+
end
|
3
8
|
|
4
|
-
|
5
|
-
|
6
|
-
else
|
7
|
-
gem plugin_name
|
8
|
-
run_bundle
|
9
|
-
run "spring stop" if defined?(Spring)
|
10
|
-
generate "#{plugin_generator_name} --skip_migrations=true"
|
9
|
+
unless Bundler.locked_gems.dependencies['solidus_bolt']
|
10
|
+
bundle_command 'add solidus_bolt'
|
11
11
|
end
|
12
|
+
|
13
|
+
generate 'solidus_bolt:install'
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
unless Bundler.locked_gems.dependencies['solidus_frontend']
|
2
|
+
say_status :warning, "Support for frontends other than `solidus_frontend` by `solidus_paypal_commerce_platform` is still in progress.", :yellow
|
3
|
+
end
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gem plugin_name, @selected_frontend == 'solidus_frontend' ? '< 1' : '>= 1.a'
|
8
|
-
run_bundle
|
9
|
-
run "spring stop" if defined?(Spring)
|
10
|
-
generate "#{plugin_generator_name} --skip_migrations=true"
|
5
|
+
unless Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
|
6
|
+
version = @selected_frontend == 'classic' ? '< 1' : '~> 1.0'
|
7
|
+
bundle_command "add solidus_paypal_commerce_platform --version='#{version}'"
|
11
8
|
end
|
9
|
+
|
10
|
+
generate 'solidus_paypal_commerce_platform:install'
|
@@ -1,11 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rails/version'
|
3
4
|
require 'rails/generators'
|
4
5
|
require 'rails/generators/app_base'
|
5
|
-
require 'rails/version'
|
6
|
-
require_relative 'install_generator/bundler_context'
|
7
|
-
require_relative 'install_generator/support_solidus_frontend_extraction'
|
8
|
-
require_relative 'install_generator/install_frontend'
|
9
6
|
|
10
7
|
module Solidus
|
11
8
|
# @private
|
@@ -14,58 +11,80 @@ module Solidus
|
|
14
11
|
|
15
12
|
CORE_MOUNT_ROUTE = "mount Spree::Core::Engine"
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
FRONTENDS = %w[
|
15
|
+
none
|
16
|
+
classic
|
17
|
+
starter
|
18
|
+
]
|
19
|
+
|
20
|
+
LEGACY_FRONTENDS = %w[
|
21
|
+
solidus_starter_frontend
|
22
|
+
solidus_frontend
|
23
|
+
]
|
24
|
+
|
25
|
+
AUTHENTICATIONS = %w[
|
26
|
+
devise
|
27
|
+
existing
|
28
|
+
custom
|
29
|
+
none
|
30
|
+
]
|
31
|
+
|
32
|
+
PAYMENT_METHODS = %w[
|
33
|
+
paypal
|
34
|
+
bolt
|
35
|
+
none
|
36
|
+
]
|
30
37
|
|
31
38
|
class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
|
32
39
|
class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
|
33
|
-
class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations must be run)'
|
34
|
-
class_option :active_storage, type: :boolean, default:
|
40
|
+
class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations and seeds must be run)'
|
41
|
+
class_option :active_storage, type: :boolean, default: (
|
42
|
+
Rails.gem_version >= Gem::Version.new("6.1.0")
|
43
|
+
), banner: 'Install ActiveStorage as image attachments handler for products and taxons'
|
35
44
|
class_option :auto_accept, type: :boolean
|
36
45
|
class_option :user_class, type: :string
|
37
46
|
class_option :admin_email, type: :string
|
38
47
|
class_option :admin_password, type: :string
|
39
|
-
|
40
|
-
class_option :
|
41
|
-
class_option :
|
42
|
-
class_option :
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
class_option :
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def self.source_paths
|
54
|
-
paths = superclass.source_paths
|
55
|
-
paths << File.expand_path('../templates', "../../#{__FILE__}")
|
56
|
-
paths << File.expand_path('../templates', "../#{__FILE__}")
|
57
|
-
paths << File.expand_path('templates', __dir__)
|
58
|
-
paths.flatten
|
48
|
+
|
49
|
+
class_option :frontend, type: :string, enum: FRONTENDS + LEGACY_FRONTENDS, default: nil, desc: "Indicates which frontend to install."
|
50
|
+
class_option :authentication, type: :string, enum: AUTHENTICATIONS, default: nil, desc: "Indicates which authentication system to install."
|
51
|
+
class_option :payment_method, type: :string, enum: PAYMENT_METHODS, default: nil, desc: "Indicates which payment method to install."
|
52
|
+
|
53
|
+
# DEPRECATED
|
54
|
+
class_option :with_authentication, type: :boolean, hide: true, default: nil
|
55
|
+
class_option :enforce_available_locales, type: :boolean, hide: true, default: nil
|
56
|
+
class_option :lib_name, type: :string, hide: true, default: nil
|
57
|
+
|
58
|
+
source_root "#{__dir__}/templates"
|
59
|
+
|
60
|
+
def self.exit_on_failure?
|
61
|
+
true
|
59
62
|
end
|
60
63
|
|
61
64
|
def prepare_options
|
62
65
|
@run_migrations = options[:migrate]
|
63
|
-
@load_seed_data = options[:seed]
|
64
|
-
@load_sample_data = options[:sample]
|
66
|
+
@load_seed_data = options[:seed] && @run_migrations
|
67
|
+
@load_sample_data = options[:sample] && @run_migrations && @load_seed_data
|
68
|
+
@selected_frontend = detect_frontend_to_install
|
69
|
+
@selected_authentication = detect_authentication_to_install
|
70
|
+
@selected_payment_method = detect_payment_method_to_install
|
71
|
+
|
72
|
+
# Silence verbose output (e.g. Rails migrations will rely on this environment variable)
|
73
|
+
ENV['VERBOSE'] = 'false'
|
74
|
+
|
75
|
+
# No reason to check for their presence if we're about to install them
|
76
|
+
ENV['SOLIDUS_SKIP_MIGRATIONS_CHECK'] = 'true'
|
65
77
|
|
66
|
-
|
67
|
-
|
68
|
-
|
78
|
+
if options[:enforce_available_locales] != nil
|
79
|
+
warn \
|
80
|
+
"DEPRECATION WARNING: using `solidus:install --enforce-available-locales` is now deprecated and has no effect. " \
|
81
|
+
"Since Rails 4.1 the default is `true` so we no longer need to explicitly set a value."
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:lib_name] != nil
|
85
|
+
warn \
|
86
|
+
"DEPRECATION WARNING: using `solidus:install --lib-name` is now deprecated and has no effect. " \
|
87
|
+
"The option is legacy and should be removed from scripts still using it."
|
69
88
|
end
|
70
89
|
end
|
71
90
|
|
@@ -75,32 +94,15 @@ module Solidus
|
|
75
94
|
|
76
95
|
def install_file_attachment
|
77
96
|
if options[:active_storage]
|
78
|
-
|
97
|
+
say_status :assets, "Active Storage", :green
|
79
98
|
rake 'active_storage:install'
|
80
99
|
else
|
81
|
-
|
100
|
+
say_status :assets, "Paperclip", :green
|
82
101
|
gsub_file 'config/initializers/spree.rb', "ActiveStorageAttachment", "PaperclipAttachment"
|
83
102
|
end
|
84
103
|
end
|
85
104
|
|
86
|
-
def additional_tweaks
|
87
|
-
return unless File.exist? 'public/robots.txt'
|
88
|
-
|
89
|
-
append_file "public/robots.txt", <<-ROBOTS.strip_heredoc
|
90
|
-
User-agent: *
|
91
|
-
Disallow: /checkout
|
92
|
-
Disallow: /cart
|
93
|
-
Disallow: /orders
|
94
|
-
Disallow: /user
|
95
|
-
Disallow: /account
|
96
|
-
Disallow: /api
|
97
|
-
Disallow: /password
|
98
|
-
ROBOTS
|
99
|
-
end
|
100
|
-
|
101
105
|
def setup_assets
|
102
|
-
@lib_name = 'spree'
|
103
|
-
|
104
106
|
empty_directory 'app/assets/images'
|
105
107
|
|
106
108
|
%w{javascripts stylesheets images}.each do |path|
|
@@ -117,51 +119,15 @@ module Solidus
|
|
117
119
|
empty_directory "app/overrides"
|
118
120
|
end
|
119
121
|
|
120
|
-
def configure_application
|
121
|
-
if !options[:enforce_available_locales].nil?
|
122
|
-
application <<-RUBY
|
123
|
-
# Prevent this deprecation message: https://github.com/svenfuchs/i18n/commit/3b6e56e
|
124
|
-
I18n.enforce_available_locales = #{options[:enforce_available_locales]}
|
125
|
-
RUBY
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def select_auth_plugin
|
130
|
-
@with_authentication = options[:with_authentication]
|
131
|
-
@with_authentication.nil? and @with_authentication = (options[:auto_accept] || !no?("
|
132
|
-
Solidus has a default authentication extension that uses Devise.
|
133
|
-
You can find more info at https://github.com/solidusio/solidus_auth_devise.
|
134
|
-
|
135
|
-
Regardless of what you answer here, it'll be installed if you choose
|
136
|
-
solidus_starter_frontend as your storefront in a later step.
|
137
|
-
|
138
|
-
Would you like to install it? (Y/n)"))
|
139
|
-
end
|
140
|
-
|
141
|
-
def select_payment_method
|
142
|
-
say_status :warning, set_color(
|
143
|
-
"Selecting a payment along with `solidus_starter_frontend` might require manual integration.",
|
144
|
-
:yellow
|
145
|
-
), :yellow
|
146
|
-
|
147
|
-
@selected_payment_method = options[:payment_method]
|
148
|
-
@selected_payment_method ||= PAYMENT_METHODS.keys.first if options[:auto_accept]
|
149
|
-
@selected_payment_method ||= ask("
|
150
|
-
You can select a payment method to be included in the installation process.
|
151
|
-
Please select a payment method name:", limited_to: PAYMENT_METHODS.keys, default: PAYMENT_METHODS.keys.first)
|
152
|
-
end
|
153
|
-
|
154
122
|
def include_seed_data
|
155
|
-
append_file "db/seeds.rb",
|
156
|
-
|
157
|
-
Spree::Core::Engine.load_seed if defined?(Spree::Core)
|
158
|
-
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
123
|
+
append_file "db/seeds.rb", <<~RUBY
|
124
|
+
Spree::Core::Engine.load_seed
|
159
125
|
RUBY
|
160
126
|
end
|
161
127
|
|
162
128
|
def install_migrations
|
163
129
|
say_status :copying, "migrations"
|
164
|
-
|
130
|
+
rake 'railties:install:migrations'
|
165
131
|
end
|
166
132
|
|
167
133
|
def create_database
|
@@ -169,51 +135,46 @@ module Solidus
|
|
169
135
|
rake 'db:create'
|
170
136
|
end
|
171
137
|
|
172
|
-
def
|
173
|
-
|
174
|
-
|
175
|
-
if @selected_frontend == 'none'
|
176
|
-
support_solidus_frontend_extraction
|
138
|
+
def install_routes
|
139
|
+
if Pathname(app_path).join('config', 'routes.rb').read.include? CORE_MOUNT_ROUTE
|
140
|
+
say_status :route_exist, CORE_MOUNT_ROUTE, :blue
|
177
141
|
else
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
# The DEFAULT_FRONTEND installation makes changes to the
|
187
|
-
# bundle without updating the bundler context. As such, we need to
|
188
|
-
# reset the bundler context to get the latest dependencies from the
|
189
|
-
# context.
|
190
|
-
reset_bundler_context if @selected_frontend == DEFAULT_FRONTEND
|
142
|
+
route <<~RUBY
|
143
|
+
# This line mounts Solidus's routes at the root of your application.
|
144
|
+
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
|
145
|
+
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
146
|
+
#
|
147
|
+
# We ask that you don't use the :as option here, as Solidus relies on it being the default of "spree"
|
148
|
+
#{CORE_MOUNT_ROUTE}, at: '/'
|
149
|
+
RUBY
|
191
150
|
end
|
192
151
|
end
|
193
152
|
|
194
|
-
def install_authentication_plugin
|
195
|
-
return unless @with_authentication
|
196
|
-
|
197
|
-
install_plugin(plugin_name: 'solidus_auth_devise', plugin_generator_name: 'solidus:auth:install')
|
198
|
-
end
|
199
|
-
|
200
|
-
def install_payment_method
|
201
|
-
apply_template_for :payment_method, @selected_payment_method
|
202
|
-
end
|
203
|
-
|
204
153
|
def run_migrations
|
205
154
|
if @run_migrations
|
206
155
|
say_status :running, "migrations"
|
207
156
|
|
208
|
-
rake 'db:migrate
|
157
|
+
rake 'db:migrate'
|
209
158
|
else
|
210
159
|
say_status :skipping, "migrations (don't forget to run rake db:migrate)"
|
211
160
|
end
|
212
161
|
end
|
213
162
|
|
163
|
+
def install_authentication
|
164
|
+
apply_template_for :authentication, @selected_authentication
|
165
|
+
end
|
166
|
+
|
167
|
+
def install_frontend
|
168
|
+
apply_template_for :frontend, @selected_frontend
|
169
|
+
end
|
170
|
+
|
171
|
+
def install_payment_method
|
172
|
+
apply_template_for :payment_method, @selected_payment_method
|
173
|
+
end
|
174
|
+
|
214
175
|
def populate_seed_data
|
215
176
|
if @load_seed_data
|
216
|
-
say_status :loading,
|
177
|
+
say_status :loading, "seed data"
|
217
178
|
rake_options = []
|
218
179
|
rake_options << "AUTO_ACCEPT=1" if options[:auto_accept]
|
219
180
|
rake_options << "ADMIN_EMAIL=#{options[:admin_email]}" if options[:admin_email]
|
@@ -234,40 +195,41 @@ module Solidus
|
|
234
195
|
end
|
235
196
|
end
|
236
197
|
|
237
|
-
def
|
238
|
-
|
239
|
-
|
240
|
-
insert_into_file routes_file_path, after: "Rails.application.routes.draw do\n" do
|
241
|
-
<<-RUBY
|
242
|
-
# This line mounts Solidus's routes at the root of your application.
|
243
|
-
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
|
244
|
-
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
245
|
-
#
|
246
|
-
# We ask that you don't use the :as option here, as Solidus relies on it being the default of "spree"
|
247
|
-
#{CORE_MOUNT_ROUTE}, at: '/'
|
248
|
-
|
249
|
-
RUBY
|
250
|
-
end
|
251
|
-
end
|
198
|
+
def complete
|
199
|
+
say_status :complete, "Solidus has been installed successfully. Enjoy!"
|
200
|
+
end
|
252
201
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
202
|
+
private
|
203
|
+
|
204
|
+
def generate(what, *args, abort_on_failure: true)
|
205
|
+
args << '--auto-accept' if options[:auto_accept]
|
206
|
+
args << '--auto-run-migrations' if options[:migrate]
|
207
|
+
super(what, *args, abort_on_failure: abort_on_failure)
|
259
208
|
end
|
260
209
|
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
puts "Enjoy!"
|
267
|
-
end
|
210
|
+
def bundle_command(command, env = {})
|
211
|
+
# Make `bundle install` less verbose by skipping the "Using ..." messages
|
212
|
+
super(command, env.reverse_merge('BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES' => 'true'))
|
213
|
+
ensure
|
214
|
+
Bundler.reset_paths!
|
268
215
|
end
|
269
216
|
|
270
|
-
|
217
|
+
def ask_with_description(desc:, limited_to:, default:)
|
218
|
+
loop do
|
219
|
+
say_status :question, desc, :yellow
|
220
|
+
answer = ask(set_color("answer:".rjust(13), :blue, :bold)).to_s.downcase.presence
|
221
|
+
|
222
|
+
case answer
|
223
|
+
when nil
|
224
|
+
say_status :using, "#{default} (default)"
|
225
|
+
break default
|
226
|
+
when *limited_to.map(&:to_s)
|
227
|
+
say_status :using, answer
|
228
|
+
break answer
|
229
|
+
else say_status :error, "Please select a valid answer:", :red
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
271
233
|
|
272
234
|
def apply_template_for(topic, selected)
|
273
235
|
template_path = Dir["#{__dir__}/app_templates/#{topic}/*.rb"].find do |path|
|
@@ -283,46 +245,107 @@ module Solidus
|
|
283
245
|
apply template_path
|
284
246
|
end
|
285
247
|
|
286
|
-
def
|
287
|
-
ENV
|
288
|
-
|
289
|
-
(bundler_context.component_in_gemfile?(:frontend) && LEGACY_FRONTEND) ||
|
290
|
-
(options[:auto_accept] && DEFAULT_FRONTEND) ||
|
291
|
-
ask(<<~MSG.indent(8), limited_to: FRONTENDS, default: DEFAULT_FRONTEND)
|
248
|
+
def with_env(vars)
|
249
|
+
original = ENV.to_hash
|
250
|
+
vars.each { |k, v| ENV[k] = v }
|
292
251
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
252
|
+
begin
|
253
|
+
yield
|
254
|
+
ensure
|
255
|
+
ENV.replace(original)
|
256
|
+
end
|
298
257
|
end
|
299
258
|
|
300
|
-
def
|
301
|
-
|
259
|
+
def detect_frontend_to_install
|
260
|
+
# We need to support names that were available in v3.2
|
261
|
+
selected_frontend = 'starter' if options[:frontend] == 'solidus_starter_frontend'
|
262
|
+
selected_frontend = 'classic' if options[:frontend] == 'solidus_frontend'
|
263
|
+
selected_frontend ||= options[:frontend]
|
302
264
|
|
303
|
-
|
304
|
-
|
305
|
-
|
265
|
+
ENV['FRONTEND'] ||
|
266
|
+
selected_frontend ||
|
267
|
+
(Bundler.locked_gems.dependencies['solidus_frontend'] && 'classic') ||
|
268
|
+
(options[:auto_accept] && 'starter') ||
|
269
|
+
ask_with_description(
|
270
|
+
default: 'starter',
|
271
|
+
limited_to: FRONTENDS,
|
272
|
+
desc: <<~TEXT
|
273
|
+
Which frontend would you like to use?
|
274
|
+
|
275
|
+
- [#{set_color 'starter', :bold}] Generate all necessary controllers and views directly in your Rails app (#{set_color :default, :bold}).
|
276
|
+
- [#{set_color 'classic', :bold}] Install `solidus_frontend`, was the default in previous solidus versions (#{set_color :deprecated, :bold}).
|
277
|
+
- [#{set_color 'none', :bold}] Skip installing a frontend.
|
278
|
+
|
279
|
+
Selecting `starter` is recommended, however, some extensions are still only compatible with `classic`.
|
280
|
+
TEXT
|
281
|
+
)
|
306
282
|
end
|
307
283
|
|
308
|
-
def
|
309
|
-
if
|
310
|
-
|
311
|
-
|
284
|
+
def detect_authentication_to_install
|
285
|
+
return 'devise' if @selected_frontend == 'starter'
|
286
|
+
|
287
|
+
if options[:with_authentication] != nil
|
288
|
+
say_status :warning, \
|
289
|
+
"Using `solidus:install --with-authentication` is now deprecated. " \
|
290
|
+
"Please use `--authentication` instead (see --help for the full list of options).",
|
291
|
+
:red
|
292
|
+
|
293
|
+
if options[:with_authentication] == 'false'
|
294
|
+
# Don't use the default authentication if the user explicitly
|
295
|
+
# requested no authentication system.
|
296
|
+
return 'none'
|
297
|
+
else
|
298
|
+
return 'devise'
|
299
|
+
end
|
312
300
|
end
|
313
301
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
302
|
+
ENV['AUTHENTICATION'] ||
|
303
|
+
options[:authentication] ||
|
304
|
+
(Bundler.locked_gems.dependencies['solidus_auth_devise'] && 'devise') ||
|
305
|
+
(options[:auto_accept] && 'devise') ||
|
306
|
+
ask_with_description(
|
307
|
+
default: 'devise',
|
308
|
+
limited_to: AUTHENTICATIONS,
|
309
|
+
desc: <<~TEXT
|
310
|
+
Which authentication would you like to use?
|
311
|
+
|
312
|
+
- [#{set_color 'devise', :bold}] Install and configure the standard `devise` integration. (#{set_color :default, :bold}).
|
313
|
+
- [#{set_color 'existing', :bold}] Integrate and configure an existing `devise` setup.
|
314
|
+
- [#{set_color 'custom', :bold}] A starter configuration for rolling your own authentication system.
|
315
|
+
- [#{set_color 'none', :bold}] Don't add any configuration for authentication.
|
316
|
+
|
317
|
+
Selecting `devise` is recommended.
|
318
|
+
TEXT
|
319
|
+
)
|
318
320
|
end
|
319
321
|
|
320
|
-
def
|
321
|
-
|
322
|
-
|
322
|
+
def detect_payment_method_to_install
|
323
|
+
return 'paypal' if Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
|
324
|
+
return 'bolt' if Bundler.locked_gems.dependencies['solidus_bolt']
|
325
|
+
|
326
|
+
descriptions = {
|
327
|
+
paypal: "- [#{set_color 'paypal', :bold}] Install `solidus_paypal_commerce_platform` (#{set_color :default, :bold}).",
|
328
|
+
bolt: "- [#{set_color 'bolt', :bold}] Install `solidus_bolt`.",
|
329
|
+
none: "- [#{set_color 'none', :bold}] Skip installing a payment method.",
|
330
|
+
}
|
331
|
+
|
332
|
+
payment_methods = PAYMENT_METHODS
|
333
|
+
|
334
|
+
if @selected_frontend != 'classic'
|
335
|
+
payment_methods -= ['bolt']
|
336
|
+
descriptions.delete(:bolt)
|
337
|
+
end
|
338
|
+
|
339
|
+
selected = options[:payment_method] || (options[:auto_accept] && 'paypal') ||
|
340
|
+
ask_with_description(
|
341
|
+
default: 'paypal',
|
342
|
+
limited_to: payment_methods,
|
343
|
+
desc: <<~TEXT
|
344
|
+
Which payment method would you like to use?
|
323
345
|
|
324
|
-
|
325
|
-
|
346
|
+
#{descriptions.values.join("\n")}
|
347
|
+
TEXT
|
348
|
+
)
|
326
349
|
end
|
327
350
|
end
|
328
351
|
end
|
@@ -9,9 +9,6 @@ Spree.config do |config|
|
|
9
9
|
# Default currency for new sites
|
10
10
|
config.currency = "USD"
|
11
11
|
|
12
|
-
# from address for transactional emails
|
13
|
-
config.mails_from = "store@example.com"
|
14
|
-
|
15
12
|
# Uncomment to stop tracking inventory levels in the application
|
16
13
|
# config.track_inventory_levels = false
|
17
14
|
|
@@ -79,7 +76,9 @@ Spree::Api::Config.configure do |config|
|
|
79
76
|
end
|
80
77
|
<% end -%>
|
81
78
|
|
82
|
-
|
79
|
+
<% if options[:user_class].present? -%>
|
80
|
+
Spree.user_class = <%= options[:user_class].inspect %>
|
81
|
+
<% end -%>
|
83
82
|
|
84
83
|
# Rules for avoiding to store the current path into session for redirects
|
85
84
|
# When at least one rule is matched, the request path will not be stored
|
@@ -22,10 +22,12 @@ module Spree
|
|
22
22
|
migration_template 'migration.rb.tt', "db/migrate/add_spree_fields_to_custom_user_table.rb"
|
23
23
|
template 'authentication_helpers.rb.tt', "lib/spree/authentication_helpers.rb"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
initializer 'solidus_authentication', <<~RUBY
|
26
|
+
Rails.application.config.to_prepare do
|
27
|
+
ApplicationController.include Spree::AuthenticationHelpers, Spree::CurrentUserHelpers
|
28
|
+
Spree::Api::BaseController.include Spree::CurrentUserHelpers if defined? Spree::Api
|
29
|
+
end
|
30
|
+
RUBY
|
29
31
|
|
30
32
|
gsub_file 'config/initializers/spree.rb', /Spree\.user_class.?=.?.+$/, %{Spree.user_class = "#{class_name}"}
|
31
33
|
end
|
@@ -9,7 +9,8 @@ module Spree
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def spree_current_user
|
12
|
-
|
12
|
+
# TODO: Replace this with your implementation for retrieving the current user
|
13
|
+
Spree.user_class.new
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -33,8 +34,3 @@ module Spree
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
36
|
-
|
37
|
-
ApplicationController.send :include, Spree::AuthenticationHelpers
|
38
|
-
ApplicationController.send :include, Spree::CurrentUserHelpers
|
39
|
-
|
40
|
-
Spree::Api::BaseController.send :include, Spree::CurrentUserHelpers
|
@@ -1,7 +1,11 @@
|
|
1
1
|
class AddSpreeFieldsToCustomUserTable < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if table_exists?(<%= table_name.inspect %>)
|
4
|
+
add_column <%= table_name.inspect %>, :spree_api_key, :string, :limit => 48 unless column_exists?(<%= table_name.inspect %>, :spree_api_key)
|
5
|
+
add_column <%= table_name.inspect %>, :ship_address_id, :integer unless column_exists?(<%= table_name.inspect %>, :ship_address_id)
|
6
|
+
add_column <%= table_name.inspect %>, :bill_address_id, :integer unless column_exists?(<%= table_name.inspect %>, :bill_address_id)
|
7
|
+
add_column <%= table_name.inspect %>, :deleted_at, :datetime unless column_exists?(<%= table_name.inspect %>, :deleted_at)
|
8
|
+
add_index <%= table_name.inspect %>, :deleted_at unless column_exists?(<%= table_name.inspect %>, :deleted_at)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|