Class: Rails::Worktrees::PostCreateRunner
- Inherits:
-
Object
- Object
- Rails::Worktrees::PostCreateRunner
- Defined in:
- lib/rails/worktrees/post_create_runner.rb
Overview
Runs post-create setup steps in a newly created worktree. Steps run in order: credential linking, bundle install, yarn install, db:prepare (development), db:prepare (test), assets:precompile (test), assets:clobber. rubocop:disable Metrics/ClassLength
Constant Summary collapse
- STEPS =
[ { id: :bundle, argv: %w[bundle install], header: '๐ฆ Installing gems...' }, { id: :yarn, argv: %w[yarn install], header: '๐งถ Installing JS dependencies...' }, { id: :db_prepare, argv: %w[bin/rails db:prepare], header: '๐๏ธ Preparing development database...', env: { 'RAILS_ENV' => 'development' } }, { id: :test_db_prepare, argv: %w[bin/rails db:prepare], header: '๐๏ธ Preparing test database...', env: { 'RAILS_ENV' => 'test' } }, { id: :test_assets_precompile, argv: %w[bin/rails assets:precompile], header: '๐จ Precompiling test assets...', env: { 'RAILS_ENV' => 'test' } }, { id: :assets_clobber, argv: %w[bin/rails assets:clobber], header: '๐งน Clobbering compiled assets...' } ].freeze
- STEP_CONFIG =
{ bundle: :run_bundle_install, yarn: :run_yarn_install, db_prepare: :run_db_prepare, test_db_prepare: :run_test_db_prepare, test_assets_precompile: :run_test_assets_precompile, assets_clobber: :run_test_assets_precompile }.freeze
Instance Method Summary collapse
- #call(dry_run: false) ⇒ Object
-
#initialize(target_dir:, peer_roots:, configuration:, io:, bootstrapped_env: nil) ⇒ PostCreateRunner
constructor
A new instance of PostCreateRunner.
Constructor Details
#initialize(target_dir:, peer_roots:, configuration:, io:, bootstrapped_env: nil) ⇒ PostCreateRunner
Returns a new instance of PostCreateRunner.
34 35 36 37 38 39 40 41 |
# File 'lib/rails/worktrees/post_create_runner.rb', line 34 def initialize(target_dir:, peer_roots:, configuration:, io:, bootstrapped_env: nil) @target_dir = target_dir @peer_roots = peer_roots @configuration = configuration @bootstrapped_env = (bootstrapped_env || {}).transform_values(&:to_s) @stdout = io.fetch(:stdout) @stderr = io.fetch(:stderr) end |
Instance Method Details
#call(dry_run: false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rails/worktrees/post_create_runner.rb', line 43 def call(dry_run: false) return 0 if @configuration.post_create_command == false @runtime_env = resolved_runtime_env(dry_run: dry_run) return run_custom_command(dry_run: dry_run) if custom_command? run_built_in_steps(dry_run: dry_run) rescue Error => e @stderr.puts("โ #{e.}") 1 end |