Skip to content

Commit c088ba1

Browse files
justin808claude
andcommitted
Skip version validation when package.json doesn't exist
The version checker was failing during `rake shakapacker:install` because it runs before package.json is created. This broke the generator examples in CI with error: "package.json file not found". This commit updates the engine initializer to skip validation when package.json doesn't exist yet, allowing installation tasks to complete successfully. The validation will still run normally once package.json exists, ensuring version compatibility in production apps. Fixes generator test failures: - examples (3.2, minimum) - examples (3.4, latest) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 80bb694 commit c088ba1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/react_on_rails/engine.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ module ReactOnRails
66
class Engine < ::Rails::Engine
77
# Validate package versions and compatibility on Rails startup
88
# This ensures the application fails fast if versions don't match or packages are misconfigured
9+
# Skip validation during installation tasks (e.g., shakapacker:install)
910
initializer "react_on_rails.validate_version_and_package_compatibility" do
1011
config.after_initialize do
12+
# Skip validation if package.json doesn't exist yet (during initial setup)
13+
package_json = VersionChecker::NodePackageVersion.package_json_path
14+
next unless File.exist?(package_json)
15+
1116
Rails.logger.info "[React on Rails] Validating package version and compatibility..."
1217
VersionChecker.build.validate_version_and_package_compatibility!
1318
Rails.logger.info "[React on Rails] Package validation successful"

0 commit comments

Comments
 (0)