class Solidus::UpdateGenerator
@private
Constants
- FROM
Public Instance Methods
create_new_defaults_initializer()
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 40 def create_new_defaults_initializer previous_version_prompt = options[:previous_version_prompt] return if previous_version_prompt && !yes?(<<~MSG, :red) The update process is only supported if you are coming from version #{FROM}. If this is not the case, please, skip it and update your application to use Solidus #{FROM} before retrying. If you are confident you want to upgrade from a previous version, you must rerun the generator with the "--from={OLD_VERSION}" argument. Are you sure you want to continue? (y/N) MSG from = options[:from] to = options[:to] @from = from @core_changes = core_changes_template(from, to) @frontend_changes = frontend_changes_template(from, to) @backend_changes = backend_changes_template(from, to) @api_changes = api_changes_template(from, to) template 'config/initializers/new_solidus_defaults.rb.tt', File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb") end
print_message()
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 60 def print_message say <<~MSG *********************************************************************** Other tasks may be needed to update to the new Solidus version. Please, check https://github.com/solidusio/solidus/blob/v#{options[:to]}/CHANGELOG.md for details. Thanks for using Solidus! *********************************************************************** MSG end
Private Instance Methods
api_changes_template(from, to)
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 94 def api_changes_template(from, to) return '' unless defined?(Spree::Api::Engine) changes_template_for(Spree::ApiConfiguration, from, to) end
backend_changes_template(from, to)
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 88 def backend_changes_template(from, to) return '' unless defined?(Spree::Backend::Engine) changes_template_for(Spree::BackendConfiguration, from, to) end
changes_template_for(klass, from, to)
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 100 def changes_template_for(klass, from, to) changes = Spree::Preferences::PreferenceDifferentiator.new(klass).call(from: from, to: to) return '# No changes' if changes.empty? [ ["config.load_defaults('#{from}')"] + changes.map do |pref_key, change| " # config.#{pref_key} = #{change[:to]}" end.flatten ].join("\n") end
core_changes_template(from, to)
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 78 def core_changes_template(from, to) changes_template_for(Spree::AppConfiguration, from, to) end
frontend_changes_template(from, to)
click to toggle source
# File lib/generators/solidus/update/update_generator.rb, line 82 def frontend_changes_template(from, to) return '' unless defined?(Spree::Frontend::Engine) changes_template_for(Spree::FrontendConfiguration, from, to) end