Skip to content

Commit 0281811

Browse files
justin808claude
andcommitted
Revert "Auto-remove default gem files" feature
Remove the entire feature that attempted to auto-delete default bin/dev and config/shakapacker.yml files. This feature was causing more problems than it solved: - Difficulty detecting when Shakapacker was truly pre-configured - Race conditions and timing issues during installation - Complexity in determining which files were safe to delete The original goal was to avoid interactive prompts during installation, but the feature introduced too many edge cases and test failures. Users can manually handle any conflicts if they arise during installation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1d39a02 commit 0281811

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ class InstallGenerator < Rails::Generators::Base
3838

3939
def run_generators
4040
if installation_prerequisites_met? || options.ignore_warnings?
41-
# Check if Shakapacker is configured BEFORE we run any generators
42-
# This way we know if it existed before React on Rails installation
43-
shakapacker_was_preconfigured = shakapacker_configured?
44-
45-
# Only remove default files if Shakapacker was already configured before we started
46-
# If it wasn't configured, we'll install it ourselves and shouldn't delete those files
47-
remove_default_gem_files if shakapacker_was_preconfigured
48-
4941
invoke_generators
5042
add_bin_scripts
5143
# Only add the post install message if not using Redux
@@ -74,62 +66,6 @@ def print_generator_messages
7466
GeneratorMessages.messages.each { |message| puts message }
7567
end
7668

77-
def remove_default_gem_files
78-
remove_default_bin_dev
79-
remove_default_shakapacker_yml
80-
end
81-
82-
def remove_default_bin_dev
83-
bin_dev_path = File.join(destination_root, "bin/dev")
84-
return unless File.exist?(bin_dev_path)
85-
return unless File.writable?(bin_dev_path)
86-
87-
current_content = File.read(bin_dev_path).strip
88-
return unless bin_dev_matches_rails_default?(current_content)
89-
90-
puts Rainbow("🗑️ Removing default bin/dev file to avoid conflicts...").yellow
91-
FileUtils.rm_f(bin_dev_path)
92-
end
93-
94-
def bin_dev_matches_rails_default?(content)
95-
# Rails 7+ simple bin/dev content
96-
# Note: Rails doesn't have a bin/dev template in its generators, but this is the
97-
# common simple default that many Rails apps use. We check against this known
98-
# default to avoid conflicts during installation.
99-
rails_simple_default = <<~RUBY.strip
100-
#!/usr/bin/env ruby
101-
exec "./bin/rails", "server", *ARGV
102-
RUBY
103-
104-
content == rails_simple_default
105-
end
106-
107-
def remove_default_shakapacker_yml
108-
config_path = File.join(destination_root, "config/shakapacker.yml")
109-
return unless File.exist?(config_path)
110-
return unless File.writable?(config_path)
111-
return unless shakapacker_yml_matches_default?(config_path)
112-
113-
puts Rainbow("🗑️ Removing default config/shakapacker.yml file to avoid conflicts...").yellow
114-
FileUtils.rm_f(config_path)
115-
end
116-
117-
def shakapacker_yml_matches_default?(config_path)
118-
shakapacker_gem_path = Gem.loaded_specs["shakapacker"]&.full_gem_path
119-
return false unless shakapacker_gem_path
120-
121-
default_config_path = File.join(shakapacker_gem_path, "lib/install/config/shakapacker.yml")
122-
return false unless File.exist?(default_config_path)
123-
124-
default_content = File.read(default_config_path)
125-
current_content = File.read(config_path)
126-
127-
current_content == default_content
128-
rescue StandardError
129-
# If we can't compare, don't delete - better safe than sorry
130-
false
131-
end
132-
13369
def invoke_generators
13470
ensure_shakapacker_installed
13571
if options.typescript?

0 commit comments

Comments
 (0)