Class: ShopifyApp::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ShopifyApp::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/shopify_app/install/install_generator.rb
Instance Method Summary collapse
- #create_and_inject_into_omniauth_initializer ⇒ Object
- #create_embedded_app_layout ⇒ Object
- #create_session_store_initializer ⇒ Object
- #create_shopify_app_initializer ⇒ Object
- #create_user_agent_initializer ⇒ Object
- #insert_hosts_into_development_config ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#create_and_inject_into_omniauth_initializer ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 28 def create_and_inject_into_omniauth_initializer unless File.exist?("config/initializers/omniauth.rb") copy_file('omniauth.rb', 'config/initializers/omniauth.rb') end return if !Rails.env.test? && shopify_provider_exists? inject_into_file( 'config/initializers/omniauth.rb', shopify_provider_template, after: "Rails.application.config.middleware.use(OmniAuth::Builder) do\n" ) end |
#create_embedded_app_layout ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 42 def return unless copy_file('embedded_app.html.erb', 'app/views/layouts/embedded_app.html.erb') copy_file('_flash_messages.html.erb', 'app/views/layouts/_flash_messages.html.erb') if ShopifyApp.use_webpacker? copy_file('shopify_app.js', 'app/javascript/shopify_app/shopify_app.js') copy_file('flash_messages.js', 'app/javascript/shopify_app/flash_messages.js') copy_file('shopify_app_index.js', 'app/javascript/shopify_app/index.js') append_to_file('app/javascript/packs/application.js', "require(\"shopify_app\")\n") elsif ShopifyApp.use_importmap? copy_file('shopify_app_importmap.js', 'app/javascript/lib/shopify_app.js') copy_file('flash_messages.js', 'app/javascript/lib/flash_messages.js') append_to_file('config/importmap.rb', "pin_all_from \"app/javascript/lib\", under: \"lib\"\n") else copy_file('shopify_app.js', 'app/assets/javascripts/shopify_app.js') copy_file('flash_messages.js', 'app/assets/javascripts/flash_messages.js') end end |
#create_session_store_initializer ⇒ Object
24 25 26 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 24 def create_session_store_initializer copy_file('session_store.rb', 'config/initializers/session_store.rb') end |
#create_shopify_app_initializer ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 16 def create_shopify_app_initializer @application_name = format_array_argument(['application_name']) @scope = format_array_argument(['scope']) @api_version = ['api_version'] || ShopifyAPI::Meta.admin_versions.find(&:latest_supported).handle template('shopify_app.rb', 'config/initializers/shopify_app.rb') end |
#create_user_agent_initializer ⇒ Object
63 64 65 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 63 def create_user_agent_initializer template('user_agent.rb', 'config/initializers/user_agent.rb') end |
#insert_hosts_into_development_config ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 71 def insert_hosts_into_development_config inject_into_file( 'config/environments/development.rb', " config.hosts = (config.hosts rescue []) << /\[-\\w]+\\.ngrok\\.io/\n", after: "Rails.application.configure do\n" ) end |
#mount_engine ⇒ Object
67 68 69 |
# File 'lib/generators/shopify_app/install/install_generator.rb', line 67 def mount_engine route("mount ShopifyApp::Engine, at: '/'") end |