Class: Railpack::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Railpack::InstallGenerator
- Defined in:
- lib/generators/railpack/install/install_generator.rb
Instance Method Summary collapse
- #create_config ⇒ Object
- #install_dependencies ⇒ Object
- #post_install_message ⇒ Object
- #setup_procfile_dev ⇒ Object
Instance Method Details
#create_config ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/generators/railpack/install/install_generator.rb', line 4 def create_config if File.exist?(Rails.root.join("config/railpack.yml")) say "Railpack config already exists—skipping creation", :yellow else template "railpack.yml.tt", "config/railpack.yml" say "Created config/railpack.yml (Bun default—edit to switch bundlers)", :green end end |
#install_dependencies ⇒ Object
13 14 15 16 |
# File 'lib/generators/railpack/install/install_generator.rb', line 13 def install_dependencies say "Installing initial dependencies...", :green rake "railpack:install" # Safe—runs the new Rake task end |
#post_install_message ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/railpack/install/install_generator.rb', line 26 def say "\n Railpack installed successfully!\n\n Commands:\n - bin/rails railpack:install # Install/update dependencies (auto-runs on deploy)\n - bin/rails railpack:build # Build assets\n - bin/rails railpack:watch # Live reload in development\n\n Switch bundler anytime in config/railpack.yml\u2014no reinstall needed!\n Assets auto-build on deploy (hooked into assets:precompile).\n Live reload ready with bin/dev (Procfile.dev configured).\n\n Enjoy the flexibility! \u{1F680}\n MSG\nend\n", :green |
#setup_procfile_dev ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/generators/railpack/install/install_generator.rb', line 18 def setup_procfile_dev procfile_path = Rails.root.join("Procfile.dev") unless File.exist?(procfile_path) && File.read(procfile_path).include?("railpack:watch") append_to_file procfile_path, "js: bin/rails railpack:watch\n" say "Added js: bin/rails railpack:watch to Procfile.dev for live reload", :green end end |