solidus_core 3.4.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/spree/base_controller.rb +0 -2
- data/app/helpers/spree/products_helper.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -17
- data/app/models/concerns/spree/default_price.rb +0 -15
- data/app/models/concerns/spree/ransackable_attributes.rb +0 -21
- data/app/models/spree/adjustment.rb +0 -13
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/fulfilment_changer.rb +2 -14
- data/app/models/spree/option_value.rb +2 -11
- data/app/models/spree/order.rb +23 -39
- data/app/models/spree/order_contents.rb +2 -2
- data/app/models/spree/order_merger.rb +2 -4
- data/app/models/spree/order_updater.rb +3 -30
- data/app/models/spree/payment.rb +5 -37
- data/app/models/spree/product/scopes.rb +0 -5
- data/app/models/spree/product.rb +3 -10
- data/app/models/spree/promotion/rules/item_total.rb +0 -11
- data/app/models/spree/promotion.rb +7 -30
- data/app/models/spree/promotion_rule.rb +0 -5
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/taxon/paperclip_attachment.rb +1 -1
- data/app/models/spree/taxon.rb +2 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +1 -14
- data/app/models/spree/variant.rb +1 -17
- data/bin/rails +13 -0
- data/config/locales/en.yml +0 -1
- data/db/migrate/20210815004823_add_unique_index_to_option_values_variants.rb +16 -0
- data/db/migrate/20230321161854_change_column_null_option_values_option_type_id.rb +5 -0
- data/db/migrate/20230322085416_remove_match_policy_from_spree_promotion.rb +5 -0
- data/db/migrate/20230325132905_remove_unused_columns_from_promotion_rules.rb +6 -0
- data/db/migrate/20230325161633_drop_unused_promo_action_line_items.rb +13 -0
- data/db/migrate/20230425103509_remove_taxon_position.rb +5 -0
- data/db/migrate/20230427095534_drop_deprecated_address_id_from_shipments.rb +11 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +1 -2
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -3
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +2 -14
- data/lib/generators/solidus/install/app_templates/payment_method/stripe.rb +5 -0
- data/lib/generators/solidus/install/install_generator.rb +59 -153
- data/lib/spree/app_configuration.rb +10 -82
- data/lib/spree/bus.rb +2 -11
- data/lib/spree/core/controller_helpers/auth.rb +0 -16
- data/lib/spree/core/engine.rb +11 -31
- data/lib/spree/core/importer/order.rb +1 -1
- data/lib/spree/core/validators/email.rb +0 -4
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +0 -2
- data/lib/spree/migration_helpers.rb +3 -3
- data/lib/spree/permission_sets/configuration_display.rb +19 -1
- data/lib/spree/permission_sets/configuration_management.rb +18 -1
- data/lib/spree/permission_sets/dashboard_display.rb +5 -0
- data/lib/spree/permission_sets/default_customer.rb +29 -0
- data/lib/spree/permission_sets/order_display.rb +19 -0
- data/lib/spree/permission_sets/order_management.rb +18 -0
- data/lib/spree/permission_sets/product_display.rb +14 -0
- data/lib/spree/permission_sets/product_management.rb +16 -0
- data/lib/spree/permission_sets/promotion_display.rb +10 -0
- data/lib/spree/permission_sets/promotion_management.rb +10 -0
- data/lib/spree/permission_sets/restricted_stock_display.rb +5 -0
- data/lib/spree/permission_sets/restricted_stock_management.rb +5 -0
- data/lib/spree/permission_sets/stock_display.rb +4 -0
- data/lib/spree/permission_sets/stock_management.rb +4 -0
- data/lib/spree/permission_sets/super_user.rb +5 -0
- data/lib/spree/permission_sets/user_display.rb +4 -0
- data/lib/spree/permission_sets/user_management.rb +9 -0
- data/lib/spree/preferences/preferable_class_methods.rb +1 -25
- data/lib/spree/testing_support/common_rake.rb +5 -1
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +4 -8
- data/lib/spree/testing_support/dummy_app.rb +1 -7
- data/lib/spree/testing_support/factories/address_factory.rb +0 -7
- data/lib/spree/testing_support/factories/adjustment_factory.rb +0 -11
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/calculator_factory.rb +0 -5
- data/lib/spree/testing_support/factories/carton_factory.rb +0 -8
- data/lib/spree/testing_support/factories/country_factory.rb +0 -5
- data/lib/spree/testing_support/factories/credit_card_factory.rb +0 -5
- data/lib/spree/testing_support/factories/customer_return_factory.rb +0 -9
- data/lib/spree/testing_support/factories/image_factory.rb +0 -5
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +0 -10
- data/lib/spree/testing_support/factories/line_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_value_factory.rb +0 -5
- data/lib/spree/testing_support/factories/order_factory.rb +0 -12
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/payment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -5
- data/lib/spree/testing_support/factories/price_factory.rb +0 -7
- data/lib/spree/testing_support/factories/product_factory.rb +0 -11
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/product_property_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/property_factory.rb +0 -5
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -8
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_item_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/role_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +0 -9
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +0 -8
- data/lib/spree/testing_support/factories/state_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_location_factory.rb +0 -9
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/stock_package_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_factory.rb +0 -9
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_factory.rb +0 -5
- data/lib/spree/testing_support/factories/tax_category_factory.rb +0 -8
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +0 -9
- data/lib/spree/testing_support/factories/taxon_factory.rb +0 -7
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +0 -5
- data/lib/spree/testing_support/factories/user_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_factory.rb +0 -10
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +0 -8
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +0 -8
- data/lib/spree/testing_support/factories/zone_factory.rb +0 -8
- data/lib/spree/testing_support/factory_bot.rb +4 -28
- data/lib/spree/testing_support/sequences.rb +0 -5
- data/solidus_core.gemspec +3 -3
- metadata +48 -58
- data/app/subscribers/spree/mailer_subscriber.rb +0 -29
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +0 -54
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +0 -16
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +0 -13
- data/lib/spree/core/controller_helpers/current_host.rb +0 -19
- data/lib/spree/event/adapters/active_support_notifications.rb +0 -67
- data/lib/spree/event/configuration.rb +0 -25
- data/lib/spree/event/subscriber.rb +0 -86
- data/lib/spree/event/subscriber_registry.rb +0 -92
- data/lib/spree/event.rb +0 -119
- data/lib/spree/promotion/match_policies.rb +0 -2
- data/lib/spree/rails_compatibility.rb +0 -106
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/spree/testing_support/dummy_app/assets/stylesheets/spree/frontend/all.css +0 -9
- data/lib/spree/testing_support/dummy_app/views/layouts/application.html.erb +0 -1
- data/lib/spree/testing_support/factories.rb +0 -11
- data/lib/spree/testing_support.rb +0 -36
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +0 -33
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
class Promotion < Spree::Base
|
5
|
-
|
6
|
-
autoload(:MATCH_POLICIES, "spree/promotion/match_policies")
|
7
|
-
|
8
5
|
UNACTIVATABLE_ORDER_STATES = ["complete", "awaiting_return", "returned"]
|
9
6
|
|
10
7
|
attr_reader :eligibility_errors
|
@@ -167,27 +164,13 @@ module Spree
|
|
167
164
|
specific_rules = rules.select { |rule| rule.applicable?(promotable) }
|
168
165
|
return [] if specific_rules.none?
|
169
166
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
return nil
|
176
|
-
end
|
177
|
-
specific_rules
|
178
|
-
else
|
179
|
-
Spree::Deprecation.warn(
|
180
|
-
<<~WARN
|
181
|
-
Your promotion "#{name}" with ID #{id} has a match_policy of 'any'.
|
182
|
-
This is deprecated, please split the promotion into separate promotions for each rule.
|
183
|
-
WARN
|
184
|
-
)
|
185
|
-
unless specific_rules.any?(&eligible)
|
186
|
-
@eligibility_errors = specific_rules.map(&:eligibility_errors).detect(&:present?)
|
187
|
-
return nil
|
188
|
-
end
|
189
|
-
specific_rules.select(&eligible)
|
167
|
+
# If there are rules for this promotion, but no rules for this
|
168
|
+
# particular promotable, then the promotion is ineligible by default.
|
169
|
+
unless specific_rules.all?(&eligible)
|
170
|
+
@eligibility_errors = specific_rules.map(&:eligibility_errors).detect(&:present?)
|
171
|
+
return nil
|
190
172
|
end
|
173
|
+
specific_rules
|
191
174
|
end
|
192
175
|
|
193
176
|
def products
|
@@ -224,9 +207,7 @@ module Spree
|
|
224
207
|
if rules.blank?
|
225
208
|
true
|
226
209
|
else
|
227
|
-
rules.
|
228
|
-
rule.actionable? line_item
|
229
|
-
end
|
210
|
+
rules.all? { |rule| rule.actionable? line_item }
|
230
211
|
end
|
231
212
|
else
|
232
213
|
false
|
@@ -271,10 +252,6 @@ module Spree
|
|
271
252
|
self[:path] = nil if self[:path].blank?
|
272
253
|
end
|
273
254
|
|
274
|
-
def match_all?
|
275
|
-
match_policy == "all"
|
276
|
-
end
|
277
|
-
|
278
255
|
def apply_automatically_disallowed_with_paths
|
279
256
|
return unless apply_automatically
|
280
257
|
|
@@ -18,11 +18,6 @@ module Spree
|
|
18
18
|
[]
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.for(promotable)
|
22
|
-
all.select { |rule| rule.applicable?(promotable) }
|
23
|
-
end
|
24
|
-
deprecate :for, "Please select promotion rules by their applicable status on the promotable instead."
|
25
|
-
|
26
21
|
def applicable?(_promotable)
|
27
22
|
raise NotImplementedError, "applicable? should be implemented in a sub-class of Spree::PromotionRule"
|
28
23
|
end
|
data/app/models/spree/refund.rb
CHANGED
data/app/models/spree/taxon.rb
CHANGED
@@ -18,11 +18,11 @@ module Spree
|
|
18
18
|
after_update :update_child_permalinks, if: :saved_change_to_permalink?
|
19
19
|
|
20
20
|
validates :name, presence: true
|
21
|
-
validates :name, uniqueness: { scope: :parent_id, message: :must_be_unique_under_same_parent }
|
21
|
+
validates :name, uniqueness: { scope: :parent_id, message: :must_be_unique_under_same_parent }
|
22
22
|
validates :meta_keywords, length: { maximum: 255 }
|
23
23
|
validates :meta_description, length: { maximum: 255 }
|
24
24
|
validates :meta_title, length: { maximum: 255 }
|
25
|
-
validates :taxonomy_id, uniqueness: { message: :can_have_only_one_root }, if: -> {
|
25
|
+
validates :taxonomy_id, uniqueness: { scope: :parent_id, message: :can_have_only_one_root }, if: -> { root? }
|
26
26
|
|
27
27
|
after_save :touch_ancestors_and_taxonomy
|
28
28
|
after_touch :touch_ancestors_and_taxonomy
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
acts_as_list
|
6
6
|
|
7
7
|
validates :name, presence: true
|
8
|
-
validates :name, uniqueness: true
|
8
|
+
validates :name, uniqueness: true
|
9
9
|
|
10
10
|
has_many :taxons, inverse_of: :taxonomy
|
11
11
|
has_one :root, -> { where parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Spree
|
4
4
|
class Variant < Spree::Base
|
5
5
|
# This class is responsible for selecting a price for a variant given certain pricing options.
|
6
|
-
# A variant can have multiple or even dynamic prices. The `
|
6
|
+
# A variant can have multiple or even dynamic prices. The `price_for_options`
|
7
7
|
# method determines which price applies under the given circumstances.
|
8
8
|
#
|
9
9
|
class PriceSelector
|
@@ -22,19 +22,6 @@ module Spree
|
|
22
22
|
@variant = variant
|
23
23
|
end
|
24
24
|
|
25
|
-
# The variant's price, given a set of pricing options
|
26
|
-
# @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
|
27
|
-
# @return [Spree::Money, nil] The most specific price for this set of pricing options.
|
28
|
-
def price_for(price_options)
|
29
|
-
Spree::Deprecation.warn(
|
30
|
-
"price_for is deprecated and will be removed. The price_for method
|
31
|
-
should return a Spree::Price as described. Please use
|
32
|
-
#price_for_options and adjust your frontend code to explicitly call
|
33
|
-
&.money where required"
|
34
|
-
)
|
35
|
-
price_for_options(price_options)&.money
|
36
|
-
end
|
37
|
-
|
38
25
|
# The variant's Spree::Price record, given a set of pricing options
|
39
26
|
# @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
|
40
27
|
# @return [Spree::Price, nil] The most specific price for this set of pricing options.
|
data/app/models/spree/variant.rb
CHANGED
@@ -39,6 +39,7 @@ module Spree
|
|
39
39
|
delegate :shipping_category, :shipping_category_id,
|
40
40
|
to: :product, prefix: true
|
41
41
|
delegate :tax_rates, to: :tax_category
|
42
|
+
delegate :price_for_options, to: :price_selector
|
42
43
|
|
43
44
|
has_many :inventory_units, inverse_of: :variant
|
44
45
|
has_many :line_items, inverse_of: :variant
|
@@ -287,12 +288,6 @@ module Spree
|
|
287
288
|
@price_selector ||= Spree::Config.variant_price_selector_class.new(self)
|
288
289
|
end
|
289
290
|
|
290
|
-
# Chooses an appropriate price for the given pricing options
|
291
|
-
# This has been deprecated in favor of #price_for_options.
|
292
|
-
#
|
293
|
-
# @see Spree::Variant::PriceSelector#price_for_options
|
294
|
-
delegate :price_for, to: :price_selector
|
295
|
-
|
296
291
|
# Returns the difference in price from the master variant
|
297
292
|
def price_difference_from_master(pricing_options = Spree::Config.default_pricing_options)
|
298
293
|
master_price = product.master.price_for_options(pricing_options)
|
@@ -306,17 +301,6 @@ module Spree
|
|
306
301
|
diff && diff.zero?
|
307
302
|
end
|
308
303
|
|
309
|
-
def price_for_options(price_options)
|
310
|
-
if price_selector.respond_to?(:price_for_options)
|
311
|
-
price_selector.price_for_options(price_options)
|
312
|
-
else
|
313
|
-
money = price_for(price_options)
|
314
|
-
return if money.nil?
|
315
|
-
|
316
|
-
Spree::Price.new(amount: money.to_d, variant: self, currency: price_options.currency)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
304
|
# Generates a friendly name and sku string.
|
321
305
|
#
|
322
306
|
# @return [String]
|
data/bin/rails
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/spree/core/engine', __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __dir__)
|
10
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
11
|
+
|
12
|
+
require "rails/all"
|
13
|
+
require "rails/engine/commands"
|
data/config/locales/en.yml
CHANGED
@@ -1598,7 +1598,6 @@ en:
|
|
1598
1598
|
gateway_config_unavailable: Gateway unavailable for environment
|
1599
1599
|
gateway_error: Gateway Error
|
1600
1600
|
general: General
|
1601
|
-
general_settings: Store
|
1602
1601
|
google_analytics: Google Analytics
|
1603
1602
|
google_analytics_id: Analytics ID
|
1604
1603
|
group_size: Group size
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddUniqueIndexToOptionValuesVariants < ActiveRecord::Migration[5.2]
|
4
|
+
def up
|
5
|
+
remove_index :spree_option_values_variants, [:variant_id, :option_value_id]
|
6
|
+
add_index :spree_option_values_variants, [:variant_id, :option_value_id],
|
7
|
+
name: "index_option_values_variants_on_variant_id_and_option_value_id",
|
8
|
+
unique: true
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
remove_index :spree_option_values_variants, [:variant_id, :option_value_id]
|
13
|
+
add_index :spree_option_values_variants, [:variant_id, :option_value_id],
|
14
|
+
name: "index_option_values_variants_on_variant_id_and_option_value_id"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class DropUnusedPromoActionLineItems < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
drop_table :spree_promotion_action_line_items, force: :cascade do |t|
|
4
|
+
t.integer "promotion_action_id"
|
5
|
+
t.integer "variant_id"
|
6
|
+
t.integer "quantity", default: 1
|
7
|
+
t.datetime "created_at", precision: 6
|
8
|
+
t.datetime "updated_at", precision: 6
|
9
|
+
t.index ["promotion_action_id"], name: "index_spree_promotion_action_line_items_on_promotion_action_id"
|
10
|
+
t.index ["variant_id"], name: "index_spree_promotion_action_line_items_on_variant_id"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class DropDeprecatedAddressIdFromShipments < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
remove_index :spree_shipments, column: [:deprecated_address_id], name: :index_spree_shipments_on_deprecated_address_id
|
4
|
+
remove_column :spree_shipments, :deprecated_address_id
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
add_column :spree_shipments, :deprecated_address_id
|
9
|
+
add_index :spree_shipments, :deprecated_address_id, name: :index_spree_shipments_on_deprecated_address_id
|
10
|
+
end
|
11
|
+
end
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
run_bundle
|
1
|
+
# noop
|
@@ -1,17 +1,5 @@
|
|
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
|
4
|
-
|
5
|
-
if @selected_frontend == 'classic'
|
6
|
-
version = '< 1'
|
7
|
-
migrations_flag = options[:migrate] ? '--auto-run-migrations' : '--skip-migrations'
|
8
|
-
else
|
9
|
-
version = '~> 1.0'
|
10
|
-
migrations_flag = "--migrate=#{options[:migrate]}"
|
11
|
-
end
|
12
|
-
|
13
1
|
unless Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
|
14
|
-
bundle_command "add solidus_paypal_commerce_platform --version='
|
2
|
+
bundle_command "add solidus_paypal_commerce_platform --version='~> 1.0'"
|
15
3
|
end
|
16
4
|
|
17
|
-
generate "solidus_paypal_commerce_platform:install
|
5
|
+
generate "solidus_paypal_commerce_platform:install --migrate=#{options[:migrate]}"
|
@@ -11,70 +11,37 @@ module Solidus
|
|
11
11
|
|
12
12
|
CORE_MOUNT_ROUTE = "mount Spree::Core::Engine"
|
13
13
|
|
14
|
-
FRONTENDS =
|
15
|
-
|
16
|
-
|
17
|
-
starter
|
14
|
+
FRONTENDS = [
|
15
|
+
{ name: 'starter', description: 'Generate all necessary controllers and views directly in your Rails app', default: true },
|
16
|
+
{ name: 'none', description: 'Skip installing a frontend' }
|
18
17
|
]
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
AUTHENTICATIONS = %w[
|
26
|
-
devise
|
27
|
-
existing
|
28
|
-
custom
|
29
|
-
none
|
19
|
+
AUTHENTICATIONS = [
|
20
|
+
{ name: 'devise', description: 'Install and configure the standard `devise` integration', default: true },
|
21
|
+
{ name: 'existing', description: 'Integrate and configure an existing `devise` setup' },
|
22
|
+
{ name: 'custom', description: 'A starter configuration for rolling your own authentication system' },
|
23
|
+
{ name: 'none', description: 'Don\'t add any configuration for authentication' }
|
30
24
|
]
|
31
25
|
|
32
26
|
PAYMENT_METHODS = [
|
33
|
-
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
default: true,
|
38
|
-
},
|
39
|
-
{
|
40
|
-
name: 'bolt',
|
41
|
-
frontends: %w[classic],
|
42
|
-
description: 'Install `solidus_bolt`',
|
43
|
-
default: false,
|
44
|
-
},
|
45
|
-
{
|
46
|
-
name: 'braintree',
|
47
|
-
frontends: %w[none starter],
|
48
|
-
description: 'Install `solidus_braintree`',
|
49
|
-
default: false,
|
50
|
-
},
|
51
|
-
{
|
52
|
-
name: 'none',
|
53
|
-
frontends: %w[none classic starter],
|
54
|
-
description: 'Skip installing a payment method',
|
55
|
-
default: false,
|
56
|
-
},
|
27
|
+
{ name: 'paypal', description: 'Install `solidus_paypal_commerce_platform`', default: true },
|
28
|
+
{ name: 'stripe', description: 'Install `solidus_stripe`', default: false },
|
29
|
+
{ name: 'braintree', description: 'Install `solidus_braintree`', default: false },
|
30
|
+
{ name: 'none', description: 'Skip installing a payment method', default: false }
|
57
31
|
]
|
58
32
|
|
59
33
|
class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
|
60
34
|
class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
|
61
35
|
class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations and seeds must be run)'
|
62
|
-
class_option :active_storage, type: :boolean, default:
|
63
|
-
Rails.gem_version >= Gem::Version.new("6.1.0")
|
64
|
-
), banner: 'Install ActiveStorage as image attachments handler for products and taxons'
|
36
|
+
class_option :active_storage, type: :boolean, default: true, banner: 'Install ActiveStorage as image attachments handler for products and taxons'
|
65
37
|
class_option :auto_accept, type: :boolean
|
66
38
|
class_option :user_class, type: :string
|
67
39
|
class_option :admin_email, type: :string
|
68
40
|
class_option :admin_password, type: :string
|
69
41
|
|
70
|
-
class_option :frontend, type: :string, enum: FRONTENDS
|
71
|
-
class_option :authentication, type: :string, enum: AUTHENTICATIONS, default: nil, desc: "Indicates which authentication system to install."
|
72
|
-
class_option :payment_method, type: :string, enum: PAYMENT_METHODS.map {
|
73
|
-
|
74
|
-
# DEPRECATED
|
75
|
-
class_option :with_authentication, type: :boolean, hide: true, default: nil
|
76
|
-
class_option :enforce_available_locales, type: :boolean, hide: true, default: nil
|
77
|
-
class_option :lib_name, type: :string, hide: true, default: nil
|
42
|
+
class_option :frontend, type: :string, enum: FRONTENDS.map { _1[:name] }, default: nil, desc: "Indicates which frontend to install."
|
43
|
+
class_option :authentication, type: :string, enum: AUTHENTICATIONS.map { _1[:name] }, default: nil, desc: "Indicates which authentication system to install."
|
44
|
+
class_option :payment_method, type: :string, enum: PAYMENT_METHODS.map { _1[:name] }, default: nil, desc: "Indicates which payment method to install."
|
78
45
|
|
79
46
|
source_root "#{__dir__}/templates"
|
80
47
|
|
@@ -86,27 +53,37 @@ module Solidus
|
|
86
53
|
@run_migrations = options[:migrate]
|
87
54
|
@load_seed_data = options[:seed] && @run_migrations
|
88
55
|
@load_sample_data = options[:sample] && @run_migrations && @load_seed_data
|
89
|
-
|
90
|
-
@
|
91
|
-
|
56
|
+
|
57
|
+
@selected_frontend = selected_option_for(
|
58
|
+
'frontend',
|
59
|
+
selected: ENV['FRONTEND'] || options[:frontend],
|
60
|
+
available_options: FRONTENDS,
|
61
|
+
)
|
62
|
+
|
63
|
+
@selected_authentication = selected_option_for(
|
64
|
+
'authentication',
|
65
|
+
selected:
|
66
|
+
('devise' if @selected_frontend == 'starter') ||
|
67
|
+
('devise' if has_gem?('solidus_auth_devise')) ||
|
68
|
+
ENV['AUTHENTICATION'] || options[:authentication],
|
69
|
+
available_options: AUTHENTICATIONS,
|
70
|
+
)
|
71
|
+
|
72
|
+
@selected_payment_method = selected_option_for(
|
73
|
+
'payment method',
|
74
|
+
selected:
|
75
|
+
('paypal' if has_gem?('solidus_paypal_commerce_platform')) ||
|
76
|
+
('stripe' if has_gem?('solidus_stripe')) ||
|
77
|
+
('bolt' if has_gem?('solidus_bolt')) ||
|
78
|
+
ENV['PAYMENT_METHOD'] || options[:payment_method],
|
79
|
+
available_options: PAYMENT_METHODS,
|
80
|
+
)
|
92
81
|
|
93
82
|
# Silence verbose output (e.g. Rails migrations will rely on this environment variable)
|
94
83
|
ENV['VERBOSE'] = 'false'
|
95
84
|
|
96
85
|
# No reason to check for their presence if we're about to install them
|
97
86
|
ENV['SOLIDUS_SKIP_MIGRATIONS_CHECK'] = 'true'
|
98
|
-
|
99
|
-
if options[:enforce_available_locales] != nil
|
100
|
-
warn \
|
101
|
-
"DEPRECATION WARNING: using `solidus:install --enforce-available-locales` is now deprecated and has no effect. " \
|
102
|
-
"Since Rails 4.1 the default is `true` so we no longer need to explicitly set a value."
|
103
|
-
end
|
104
|
-
|
105
|
-
if options[:lib_name] != nil
|
106
|
-
warn \
|
107
|
-
"DEPRECATION WARNING: using `solidus:install --lib-name` is now deprecated and has no effect. " \
|
108
|
-
"The option is legacy and should be removed from scripts still using it."
|
109
|
-
end
|
110
87
|
end
|
111
88
|
|
112
89
|
def add_files
|
@@ -119,7 +96,7 @@ module Solidus
|
|
119
96
|
rake 'active_storage:install'
|
120
97
|
else
|
121
98
|
say_status :assets, "Paperclip", :green
|
122
|
-
gsub_file 'config/initializers/spree.rb', "ActiveStorageAttachment", "PaperclipAttachment"
|
99
|
+
gsub_file 'config/initializers/spree.rb', "::ActiveStorageAttachment", "::PaperclipAttachment"
|
123
100
|
end
|
124
101
|
end
|
125
102
|
|
@@ -181,15 +158,9 @@ module Solidus
|
|
181
158
|
end
|
182
159
|
end
|
183
160
|
|
184
|
-
def
|
161
|
+
def install_subcomponents
|
185
162
|
apply_template_for :authentication, @selected_authentication
|
186
|
-
end
|
187
|
-
|
188
|
-
def install_frontend
|
189
163
|
apply_template_for :frontend, @selected_frontend
|
190
|
-
end
|
191
|
-
|
192
|
-
def install_payment_method
|
193
164
|
apply_template_for :payment_method, @selected_payment_method
|
194
165
|
end
|
195
166
|
|
@@ -271,93 +242,28 @@ module Solidus
|
|
271
242
|
end
|
272
243
|
end
|
273
244
|
|
274
|
-
def
|
275
|
-
|
276
|
-
selected_frontend = 'starter' if options[:frontend] == 'solidus_starter_frontend'
|
277
|
-
selected_frontend = 'classic' if options[:frontend] == 'solidus_frontend'
|
278
|
-
selected_frontend ||= options[:frontend]
|
279
|
-
|
280
|
-
ENV['FRONTEND'] ||
|
281
|
-
selected_frontend ||
|
282
|
-
(Bundler.locked_gems.dependencies['solidus_frontend'] && 'classic') ||
|
283
|
-
(options[:auto_accept] && 'starter') ||
|
284
|
-
ask_with_description(
|
285
|
-
default: 'starter',
|
286
|
-
limited_to: FRONTENDS,
|
287
|
-
desc: <<~TEXT
|
288
|
-
Which frontend would you like to use?
|
289
|
-
|
290
|
-
- [#{set_color 'starter', :bold}] Generate all necessary controllers and views directly in your Rails app (#{set_color :default, :bold}).
|
291
|
-
- [#{set_color 'classic', :bold}] Install `solidus_frontend`, was the default in previous solidus versions (#{set_color :deprecated, :bold}).
|
292
|
-
- [#{set_color 'none', :bold}] Skip installing a frontend.
|
293
|
-
|
294
|
-
Selecting `starter` is recommended, however, some extensions are still only compatible with `classic`.
|
295
|
-
TEXT
|
296
|
-
)
|
245
|
+
def has_gem?(name)
|
246
|
+
Bundler.locked_gems.dependencies[name]
|
297
247
|
end
|
298
248
|
|
299
|
-
def
|
300
|
-
return
|
301
|
-
|
302
|
-
if options[:with_authentication] != nil
|
303
|
-
say_status :warning, \
|
304
|
-
"Using `solidus:install --with-authentication` is now deprecated. " \
|
305
|
-
"Please use `--authentication` instead (see --help for the full list of options).",
|
306
|
-
:red
|
307
|
-
|
308
|
-
if options[:with_authentication] == 'false'
|
309
|
-
# Don't use the default authentication if the user explicitly
|
310
|
-
# requested no authentication system.
|
311
|
-
return 'none'
|
312
|
-
else
|
313
|
-
return 'devise'
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
ENV['AUTHENTICATION'] ||
|
318
|
-
options[:authentication] ||
|
319
|
-
(Bundler.locked_gems.dependencies['solidus_auth_devise'] && 'devise') ||
|
320
|
-
(options[:auto_accept] && 'devise') ||
|
321
|
-
ask_with_description(
|
322
|
-
default: 'devise',
|
323
|
-
limited_to: AUTHENTICATIONS,
|
324
|
-
desc: <<~TEXT
|
325
|
-
Which authentication would you like to use?
|
326
|
-
|
327
|
-
- [#{set_color 'devise', :bold}] Install and configure the standard `devise` integration. (#{set_color :default, :bold}).
|
328
|
-
- [#{set_color 'existing', :bold}] Integrate and configure an existing `devise` setup.
|
329
|
-
- [#{set_color 'custom', :bold}] A starter configuration for rolling your own authentication system.
|
330
|
-
- [#{set_color 'none', :bold}] Don't add any configuration for authentication.
|
331
|
-
|
332
|
-
Selecting `devise` is recommended.
|
333
|
-
TEXT
|
334
|
-
)
|
335
|
-
end
|
249
|
+
def selected_option_for(name, selected:, available_options:)
|
250
|
+
return selected if selected
|
336
251
|
|
337
|
-
|
338
|
-
|
339
|
-
return 'bolt' if Bundler.locked_gems.dependencies['solidus_bolt']
|
252
|
+
option_description = ->(name:, description:, default: false, **) do
|
253
|
+
default_label = " (#{set_color :default, :bold})" if default
|
340
254
|
|
341
|
-
|
342
|
-
payment_method[:frontends].include?(@selected_frontend)
|
255
|
+
"- [#{set_color name, :bold}] #{description}#{default_label}."
|
343
256
|
end
|
344
257
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
)
|
355
|
-
end
|
356
|
-
|
357
|
-
def formatted_payment_method_description(payment_method)
|
358
|
-
default_label = " (#{set_color :default, :bold})" if payment_method[:default]
|
359
|
-
|
360
|
-
"- [#{set_color payment_method[:name], :bold}] #{payment_method[:description]}#{default_label}."
|
258
|
+
default = available_options.find { _1[:default] }
|
259
|
+
(options[:auto_accept] && default[:name]) || ask_with_description(
|
260
|
+
default: default[:name],
|
261
|
+
limited_to: available_options.map { _1[:name] },
|
262
|
+
desc: <<~TEXT
|
263
|
+
Which #{name} would you like to use?
|
264
|
+
#{available_options.map { option_description[**_1] }.join("\n")}
|
265
|
+
TEXT
|
266
|
+
)
|
361
267
|
end
|
362
268
|
end
|
363
269
|
end
|