Class: Worktrees::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Worktrees::Generators::InstallGenerator
- Defined in:
- lib/generators/worktrees/install/install_generator.rb
Overview
Installs the wt wrapper, configuration, and safe database.yml updates. rubocop:disable Metrics/ClassLength
Constant Summary collapse
- FILE_ENCODING =
'UTF-8'.freeze
- FOLLOW_UP_TEMPLATE =
<<~TEXT.freeze ============================================ rails-worktrees installed successfully! 🚂 Installed: %<installed>s Get started: $ bin/wt $ bin/wt my-feature Configure: config/initializers/rails_worktrees.rb %<notes>s ============================================ TEXT
Instance Method Summary collapse
- #apply_yolo_follow_ups ⇒ Object
- #create_bin_wrapper ⇒ Object
- #create_browser_wrapper ⇒ Object
- #create_initializer ⇒ Object
- #create_procfile_worktree_example ⇒ Object
- #show_follow_up ⇒ Object
- #update_database_configuration ⇒ Object
- #verify_installation ⇒ Object
Instance Method Details
#apply_yolo_follow_ups ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 80 def apply_yolo_follow_ups return unless [:yolo] update_procfile update_puma_config update_mise_toml end |
#create_bin_wrapper ⇒ Object
58 59 60 61 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 58 def create_bin_wrapper template('bin/wt', 'bin/wt') chmod('bin/wt', 0o755) end |
#create_browser_wrapper ⇒ Object
63 64 65 66 67 68 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 63 def create_browser_wrapper return unless install_browser_wrapper? template('bin/ob', 'bin/ob') chmod('bin/ob', 0o755) end |
#create_initializer ⇒ Object
70 71 72 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 70 def create_initializer template('rails_worktrees.rb.tt', 'config/initializers/rails_worktrees.rb') end |
#create_procfile_worktree_example ⇒ Object
74 75 76 77 78 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 74 def create_procfile_worktree_example return if [:yolo] template('Procfile.dev.worktree.example.tt', 'Procfile.dev.worktree.example') end |
#show_follow_up ⇒ Object
108 109 110 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 108 def show_follow_up say() end |
#update_database_configuration ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 88 def update_database_configuration unless File.exist?(database_config_path) say_status(:skip, 'config/database.yml not found', :yellow) @database_outcome = :not_found return end result = database_update_result @database_outcome = result.changed? ? :updated : :identical announce_database_update(result) end |
#verify_installation ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/generators/worktrees/install/install_generator.rb', line 100 def verify_installation if git_repo? say_status(:ok, 'git repository detected', :green) else say_status(:warning, 'run inside a git repository for bin/wt to work', :yellow) end end |