Class: RemoteSelect::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RemoteSelect::Generators::InstallGenerator
- Defined in:
- lib/generators/remote_select/install_generator.rb
Instance Method Summary collapse
Instance Method Details
#copy_javascript ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/remote_select/install_generator.rb', line 11 def copy_javascript source = RemoteSelect::Engine.root.join("app/javascript/remote_select.js") dest = File.join(destination_root, "app/javascript/remote_select.js") if File.exist?(dest) && ![:force] say_status :skip, "app/javascript/remote_select.js already exists (use --force to overwrite)", :yellow else version_comment = "// remote_select v#{RemoteSelect::VERSION} — copied by rails generate remote_select:install\n" create_file "app/javascript/remote_select.js", version_comment + source.read end end |
#copy_stylesheet ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/remote_select/install_generator.rb', line 23 def copy_stylesheet source = RemoteSelect::Engine.root.join("app/assets/stylesheets/remote_select.css") dest = File.join(destination_root, "app/assets/stylesheets/remote_select.css") if File.exist?(dest) && ![:force] say_status :skip, "app/assets/stylesheets/remote_select.css already exists (use --force to overwrite)", :yellow else version_comment = "/* remote_select v#{RemoteSelect::VERSION} — copied by rails generate remote_select:install */\n" create_file "app/assets/stylesheets/remote_select.css", version_comment + source.read end end |
#print_post_install ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/generators/remote_select/install_generator.rb', line 35 def print_post_install say "" say "remote_select files copied successfully!", :green say "" js_pipeline = detect_js_pipeline case js_pipeline when :importmap say "Importmap detected. Add to config/importmap.rb:" say ' pin "remote_select"' say "" say "And in app/javascript/application.js:" say ' import "remote_select"' when :esbuild, :rollup, :webpack say "#{js_pipeline} detected. Add to app/javascript/application.js:" say ' import "./remote_select"' else say "Add to your JS entry point:" say ' import "./remote_select"' end say "" css_pipeline = detect_css_pipeline case css_pipeline when :cssbundling say "cssbundling (sass) detected. Add to your main SCSS/CSS entry:" say ' @import "./remote_select";' when :sprockets say "Sprockets detected. Add to application.css:" say ' *= require remote_select' else say "Add to your CSS entry point:" say ' @import "./remote_select";' say ' or (Sprockets): *= require remote_select' end end |