@@ -36,8 +36,8 @@ class InstallGenerator < Rails::Generators::AppBase
3636 ]
3737
3838 class_option :migrate , type : :boolean , default : true , banner : 'Run Solidus migrations'
39- class_option :seed , type : :boolean , default : true , banner : 'Load seed data (migrations must be run)'
40- class_option :sample , type : :boolean , default : true , banner : 'Load sample data (migrations and seeds must be run)'
39+ class_option :seed , type : :boolean , default : true , banner : 'Run seed data task (migrations must be run)'
40+ class_option :sample , type : :boolean , default : true , banner : 'Run sample data task (migrations must be run)'
4141 class_option :active_storage , type : :boolean , default : (
4242 Rails . gem_version >= Gem ::Version . new ( "6.1.0" )
4343 ) , banner : 'Install ActiveStorage as image attachments handler for products and taxons'
@@ -63,8 +63,8 @@ def self.exit_on_failure?
6363
6464 def prepare_options
6565 @run_migrations = options [ :migrate ]
66- @load_seed_data = options [ :seed ] && @run_migrations
67- @load_sample_data = options [ :sample ] && @run_migrations && @load_seed_data
66+ @run_sample = options [ :sample ] && @run_migrations
67+ @run_seeds = options [ :seed ] && @run_migrations && ! @run_sample
6868 @selected_frontend = detect_frontend_to_install
6969 @selected_authentication = detect_authentication_to_install
7070 @selected_payment_method = detect_payment_method_to_install
@@ -172,27 +172,12 @@ def install_payment_method
172172 apply_template_for :payment_method , @selected_payment_method
173173 end
174174
175- def populate_seed_data
176- if @load_seed_data
177- say_status :loading , "seed data"
178- rake_options = [ ]
179- rake_options << "AUTO_ACCEPT=1" if options [ :auto_accept ]
180- rake_options << "ADMIN_EMAIL=#{ options [ :admin_email ] } " if options [ :admin_email ]
181- rake_options << "ADMIN_PASSWORD=#{ options [ :admin_password ] } " if options [ :admin_password ]
175+ def run_data_loaders
176+ say_status_and_run_task ( "seed and sample data" , "spree_sample:load" ) if @run_sample
177+ say_status_and_run_task ( "seed data" , "db:seed #{ seed_data_overrides . join ( ' ' ) } " ) if @run_seeds
182178
183- rake ( "db:seed #{ rake_options . join ( ' ' ) } " )
184- else
185- say_status :skipping , "seed data (you can always run rake db:seed)"
186- end
187- end
188-
189- def load_sample_data
190- if @load_sample_data
191- say_status :loading , "sample data"
192- rake 'spree_sample:load'
193- else
194- say_status :skipping , "sample data (you can always run rake spree_sample:load)"
195- end
179+ say_status :skipping , "seed data (you can always run rake db:seed)" unless @run_seeds || @run_sample
180+ say_status :skipping , "sample data (you can always run rake spree_sample:load)" unless @run_sample
196181 end
197182
198183 def complete
@@ -201,6 +186,19 @@ def complete
201186
202187 private
203188
189+ def say_status_and_run_task ( status_text , task )
190+ say_status :loading , status_text
191+ rake task
192+ end
193+
194+ def seed_data_overrides
195+ rake_options = [ ]
196+ rake_options << "AUTO_ACCEPT=1" if options [ :auto_accept ]
197+ rake_options << "ADMIN_EMAIL=#{ options [ :admin_email ] } " if options [ :admin_email ]
198+ rake_options << "ADMIN_PASSWORD=#{ options [ :admin_password ] } " if options [ :admin_password ]
199+ rake_options
200+ end
201+
204202 def generate ( what , *args , abort_on_failure : true )
205203 args << '--auto-accept' if options [ :auto_accept ]
206204 args << '--auto-run-migrations' if options [ :migrate ]
0 commit comments