Class: ActionMosaico::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActionMosaico::Generators::InstallGenerator
- Defined in:
- lib/generators/action_mosaico/install/install_generator.rb
Instance Method Summary collapse
- #append_javascript_dependencies ⇒ Object
- #create_actionmosaico_files ⇒ Object
- #create_migrations ⇒ Object
- #enable_image_processing_gem ⇒ Object
- #install_javascript_dependencies ⇒ Object
Instance Method Details
#append_javascript_dependencies ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/action_mosaico/install/install_generator.rb', line 18 def append_javascript_dependencies destination = Pathname(destination_root) if (application_javascript_path = destination.join('app/javascript/application.js')).exist? insert_into_file application_javascript_path.to_s, %(import "mosaico"\nimport actionmosaico"\n) else say <<~INSTRUCTIONS, :green You must import the actionmosaico and mosaico JavaScript modules in your application entrypoint. INSTRUCTIONS end if (importmap_path = destination.join('config/importmap.rb')).exist? append_to_file importmap_path.to_s, %(pin "mosaico"\npin "actionmosaico", to: "actionmosaico.js"\n) end end |
#create_actionmosaico_files ⇒ Object
34 35 |
# File 'lib/generators/action_mosaico/install/install_generator.rb', line 34 def create_actionmosaico_files end |
#create_migrations ⇒ Object
44 45 46 |
# File 'lib/generators/action_mosaico/install/install_generator.rb', line 44 def create_migrations rails_command 'railties:install:migrations FROM=active_storage,action_mosaico', inline: true end |
#enable_image_processing_gem ⇒ Object
37 38 39 40 41 42 |
# File 'lib/generators/action_mosaico/install/install_generator.rb', line 37 def enable_image_processing_gem if (gemfile_path = Pathname(destination_root).join('Gemfile')).exist? say 'Ensure image_processing gem has been enabled so image uploads will work (remember to bundle!)' uncomment_lines gemfile_path, /gem "image_processing"/ end end |
#install_javascript_dependencies ⇒ Object
11 12 13 14 15 16 |
# File 'lib/generators/action_mosaico/install/install_generator.rb', line 11 def install_javascript_dependencies if Pathname(destination_root).join('package.json').exist? say 'Installing JavaScript dependencies', :green run 'yarn add action_mosaico mosaico' end end |