Class: SolidusGraphqlApi::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SolidusGraphqlApi::Generators::InstallGenerator
- Defined in:
- lib/generators/solidus_graphql_api/install/install_generator.rb
Constant Summary collapse
- MOUNT_GRAPHQL_ENGINE =
"mount SolidusGraphqlApi::Engine, at: '/graphql'"
Instance Method Summary collapse
- #add_migrations ⇒ Object
- #copy_initializer ⇒ Object
- #install_routes ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_migrations ⇒ Object
16 17 18 |
# File 'lib/generators/solidus_graphql_api/install/install_generator.rb', line 16 def add_migrations run 'bin/rails railties:install:migrations FROM=solidus_graphql_api' end |
#copy_initializer ⇒ Object
12 13 14 |
# File 'lib/generators/solidus_graphql_api/install/install_generator.rb', line 12 def copy_initializer template 'initializer.rb', 'config/initializers/solidus_graphql_api.rb' end |
#install_routes ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/solidus_graphql_api/install/install_generator.rb', line 29 def install_routes if Pathname(app_path).join('config', 'routes.rb').read.include? MOUNT_GRAPHQL_ENGINE say_status :route_exist, MOUNT_GRAPHQL_ENGINE, :blue else route <<~RUBY # This line installs graphql's main route to execute queries mount SolidusGraphqlApi::Engine, at: '/graphql' RUBY end end |
#run_migrations ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/generators/solidus_graphql_api/install/install_generator.rb', line 20 def run_migrations run_migrations = [: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 |