Skip to content

Commit 97e8f85

Browse files
justin808claude
andcommitted
Implement comprehensive doctor improvements based on user feedback
Major enhancements: - Package manager shows actual version and deprecation status (yarn 1.22.22 + v1 deprecation note) - Remove duplicate React on Rails gem version reporting - Replace static configuration messages with actual shakapacker:info output - Remove unnecessary "Server bundle configuration found" message - Replace webpack version display with actionable inspection commands - Add Open3-based package manager version detection with error handling - Improve Shakapacker configuration section with real runtime data Output improvements: - Clean, non-redundant version information - Actionable command suggestions (bin/shakapacker --print-config, ANALYZE=true) - Comprehensive system information from shakapacker:info - Better organization and reduced noise in recommendations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 144dfc6 commit 97e8f85

File tree

2 files changed

+55
-17
lines changed

2 files changed

+55
-17
lines changed

lib/react_on_rails/doctor.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,12 @@ def check_environment
116116
end
117117

118118
def check_react_on_rails_versions
119-
check_gem_version
120-
check_npm_package_version
119+
# Use system_checker for comprehensive package validation instead of duplicating
120+
checker.check_react_on_rails_packages
121121
check_version_wildcards
122122
end
123123

124124
def check_packages
125-
checker.check_react_on_rails_packages
126125
checker.check_shakapacker_configuration
127126
end
128127

@@ -522,15 +521,36 @@ def check_key_configuration_files
522521
end
523522
end
524523

524+
# rubocop:disable Metrics/CyclomaticComplexity
525525
def check_shakapacker_configuration_details
526526
return unless File.exist?("config/shakapacker.yml")
527527

528-
# For now, just indicate that the configuration file exists
529-
# TODO: Parse YAML directly or improve Shakapacker integration
530528
checker.add_info("📋 Shakapacker Configuration:")
531-
checker.add_info(" Configuration file: config/shakapacker.yml")
532-
checker.add_info(" ℹ️ Run 'rake shakapacker:info' for detailed configuration")
529+
530+
begin
531+
# Run shakapacker:info to get detailed configuration
532+
stdout, stderr, status = Open3.capture3("bundle", "exec", "rake", "shakapacker:info")
533+
534+
if status.success?
535+
# Parse and display relevant info from shakapacker:info
536+
lines = stdout.lines.map(&:strip)
537+
538+
lines.each do |line|
539+
next if line.empty?
540+
541+
# Show key configuration lines
542+
checker.add_info(" #{line}") if line.match?(%r{^(Ruby|Rails|Shakapacker|Node|yarn|Is bin/shakapacker)})
543+
end
544+
else
545+
checker.add_info(" Configuration file: config/shakapacker.yml")
546+
checker.add_warning(" ⚠️ Could not run 'rake shakapacker:info': #{stderr.strip}")
547+
end
548+
rescue StandardError => e
549+
checker.add_info(" Configuration file: config/shakapacker.yml")
550+
checker.add_warning(" ⚠️ Could not run 'rake shakapacker:info': #{e.message}")
551+
end
533552
end
553+
# rubocop:enable Metrics/CyclomaticComplexity
534554

535555
def check_react_on_rails_configuration_details
536556
config_path = "config/initializers/react_on_rails.rb"

lib/react_on_rails/system_checker.rb

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def check_package_manager
110110
# Detect which package manager is actually being used
111111
used_manager = detect_used_package_manager
112112
if used_manager
113-
add_success("✅ Package manager in use: #{used_manager}")
113+
version_info = get_package_manager_version(used_manager)
114+
deprecation_note = get_deprecation_note(used_manager, version_info)
115+
message = "✅ Package manager in use: #{used_manager} #{version_info}"
116+
message += deprecation_note if deprecation_note
117+
add_success(message)
114118
else
115119
add_success("✅ Package managers available: #{available_managers.join(', ')}")
116120
add_info("ℹ️ No lock file detected - run npm/yarn/pnpm install to establish which manager is used")
@@ -251,14 +255,6 @@ def check_react_on_rails_initializer
251255
initializer_path = "config/initializers/react_on_rails.rb"
252256
if File.exist?(initializer_path)
253257
add_success("✅ React on Rails initializer exists")
254-
255-
# Check for common configuration
256-
content = File.read(initializer_path)
257-
if content.include?("config.server_bundle_js_file")
258-
add_success("✅ Server bundle configuration found")
259-
else
260-
add_info("ℹ️ Consider configuring server_bundle_js_file in initializer")
261-
end
262258
else
263259
add_warning(<<~MSG.strip)
264260
⚠️ React on Rails initializer not found.
@@ -275,7 +271,7 @@ def check_webpack_configuration
275271
if File.exist?(webpack_config_path)
276272
add_success("✅ Webpack configuration exists")
277273
check_webpack_config_content
278-
report_webpack_version
274+
suggest_webpack_inspection
279275
else
280276
add_error(<<~MSG.strip)
281277
🚫 Webpack configuration not found.
@@ -286,6 +282,11 @@ def check_webpack_configuration
286282
end
287283
end
288284

285+
def suggest_webpack_inspection
286+
add_info("💡 To inspect webpack configuration: bin/shakapacker --print-config")
287+
add_info("💡 To analyze bundle size: ANALYZE=true bin/shakapacker")
288+
end
289+
289290
def check_webpack_config_content
290291
webpack_config_path = "config/webpack/webpack.config.js"
291292
content = File.read(webpack_config_path)
@@ -331,6 +332,23 @@ def detect_used_package_manager
331332
end
332333
end
333334

335+
def get_package_manager_version(manager)
336+
begin
337+
stdout, _stderr, status = Open3.capture3(manager, "--version")
338+
return stdout.strip if status.success? && !stdout.strip.empty?
339+
rescue StandardError
340+
# Ignore errors
341+
end
342+
"(version unknown)"
343+
end
344+
345+
def get_deprecation_note(manager, version)
346+
case manager
347+
when "yarn"
348+
" (Classic Yarn v1 - consider upgrading to Yarn Modern)" if /^1\./.match?(version)
349+
end
350+
end
351+
334352
def shakapacker_configured?
335353
File.exist?("bin/shakapacker") &&
336354
File.exist?("bin/shakapacker-dev-server") &&

0 commit comments

Comments
 (0)