diff --git a/core/db/seeds.rb b/core/db/seeds.rb index 456e8cadcc..ff43a574be 100644 --- a/core/db/seeds.rb +++ b/core/db/seeds.rb @@ -1,5 +1,18 @@ # Loads seed data out of default dir default_path = File.join(File.dirname(__FILE__), 'default') -Rake::Task['db:load_dir'].reenable -Rake::Task['db:load_dir'].invoke(default_path) +%w( + stores + store_credit + countries + return_reasons + states + stock_locations + zones + refund_reasons + roles + shipping_categories +).each do |seed| + puts "Loading seed file: #{seed}" + require_relative "default/spree/#{seed}" +end diff --git a/core/lib/generators/spree/install/install_generator.rb b/core/lib/generators/spree/install/install_generator.rb index 42c5922b9f..cc34f5db11 100644 --- a/core/lib/generators/spree/install/install_generator.rb +++ b/core/lib/generators/spree/install/install_generator.rb @@ -1,5 +1,4 @@ require 'rails/generators' -require 'highline/import' require 'bundler' require 'bundler/cli' diff --git a/core/lib/tasks/core.rake b/core/lib/tasks/core.rake index 98119fade0..194fe7eece 100644 --- a/core/lib/tasks/core.rake +++ b/core/lib/tasks/core.rake @@ -1,10 +1,16 @@ require 'active_record' +def prompt_for_agree(prompt) + print prompt + ["y", "yes"].include? STDIN.gets.strip.downcase +end + namespace :db do desc 'Loads a specified fixture file: use rake db:load_file[/absolute/path/to/sample/filename.rb]' task :load_file, [:file, :dir] => :environment do |_t, args| + Spree::Deprecation.warn("load_file has been deprecated. Please load your own file.") file = Pathname.new(args.file) puts "loading ruby #{file}" @@ -13,6 +19,7 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]' desc "Loads fixtures from the the dir you specify using rake db:load_dir[loadfrom]" task :load_dir, [:dir] => :environment do |_t, args| + Spree::Deprecation.warn("rake spree:load_dir has been deprecated and will be removed with Solidus 3.0. Please load your files directly.") dir = args.dir dir = File.join(Rails.root, "db", dir) if Pathname.new(dir).relative? @@ -32,9 +39,9 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]' desc "Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!" task remigrate: :environment do - require 'highline/import' + Spree::Deprecation.warn("remigrate has been deprecated. Please use db:reset or other db: commands instead.") - if ENV['SKIP_NAG'] || ENV['OVERWRITE'].to_s.casecmp('true') || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ") + if ENV['SKIP_NAG'] || ENV['OVERWRITE'].to_s.casecmp('true') || prompt_for_agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ") # Drop all tables ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t } @@ -45,27 +52,27 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]' # Dump the schema Rake::Task["db:schema:dump"].invoke else - say "Task cancelled." + puts "Task cancelled." exit end end desc "Bootstrap is: migrating, loading defaults, sample data and seeding (for all extensions) and load_products tasks" task :bootstrap do - require 'highline/import' + Spree::Deprecation.warn("rake bootstrap has been deprecated, please run db:setup instead.") # remigrate unless production mode (as saftey check) if %w[demo development test].include? Rails.env - if ENV['AUTO_ACCEPT'] || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ") + if ENV['AUTO_ACCEPT'] || prompt_for_agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ") ENV['SKIP_NAG'] = 'yes' Rake::Task["db:create"].invoke Rake::Task["db:remigrate"].invoke else - say "Task cancelled, exiting." + puts "Task cancelled, exiting." exit end else - say "NOTE: Bootstrap in production mode will not drop database before migration" + puts "NOTE: Bootstrap in production mode will not drop database before migration" Rake::Task["db:migrate"].invoke end @@ -73,17 +80,17 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]' load_defaults = Spree::Country.count == 0 unless load_defaults # ask if there are already Countries => default data hass been loaded - load_defaults = agree('Countries present, load sample data anyways? [y/n]: ') + load_defaults = prompt_for_agree('Countries present, load sample data anyways? [y/n]: ') end if load_defaults Rake::Task["db:seed"].invoke end if Rails.env.production? && Spree::Product.count > 0 - load_sample = agree("WARNING: In Production and products exist in database, load sample data anyways? [y/n]:" ) + load_sample = prompt_for_agree("WARNING: In Production and products exist in database, load sample data anyways? [y/n]:" ) else load_sample = true if ENV['AUTO_ACCEPT'] - load_sample = agree('Load Sample Data? [y/n]: ') unless load_sample + load_sample = prompt_for_agree('Load Sample Data? [y/n]: ') unless load_sample end if load_sample diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index 6124a20103..e8e14ddfe2 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |s| s.add_dependency 'cancancan', '~> 1.10' s.add_dependency 'ffaker', '~> 2.0' s.add_dependency 'friendly_id', '~> 5.0' - s.add_dependency 'highline', '~> 1.7' # Necessary for the install generator s.add_dependency 'kaminari', '>= 0.17', '< 2.0' s.add_dependency 'monetize', '~> 1.1' s.add_dependency 'paperclip', ['>= 4.2', '< 6']