Sha256: 1a0980049e16e7da7850f68f0635acfa3c303fa8a5c8e6eaf995835e10c0b6d5

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module SolidusStripe
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option :auto_run_migrations, type: :boolean, default: false

      def add_javascripts
        append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_stripe\n"
      end

      def add_migrations
        run 'bin/rails railties:install:migrations FROM=solidus_stripe'
      end

      def run_migrations
        run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
        if run_migrations
          run 'bin/rails db:migrate'
        else
          puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
        end
      end

      def populate_seed_data
        return unless options.auto_run_seeds?

        say_status :loading, 'stripe seed data'
        rake('db:seed:solidus_stripe')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_stripe-4.4.0 lib/generators/solidus_stripe/install/install_generator.rb
solidus_stripe-4.3.0 lib/generators/solidus_stripe/install/install_generator.rb