@@ -37,6 +37,9 @@ def validate_version_and_package_compatibility!
3737    def  validate_package_json_exists! 
3838      return  if  File . exist? ( node_package_version . package_json ) 
3939
40+       base_install_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( "react-on-rails" ,  gem_version ) 
41+       pro_install_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( "react-on-rails-pro" ,  gem_version ) 
42+ 
4043      raise  ReactOnRails ::Error ,  <<~MSG . strip 
4144        **ERROR** ReactOnRails: package.json file not found. 
4245
@@ -47,10 +50,10 @@ def validate_package_json_exists!
4750
4851        Fix: 
4952          1. Ensure you have a package.json in your project root 
50-           2. Run: yarn add react-on-rails@ #{ gem_version }  --exact  
53+           2. Run: #{ base_install_cmd }  
5154
5255          Or if using React on Rails Pro: 
53-           Run: yarn add react-on-rails-pro@ #{ gem_version }  --exact  
56+           Run: #{ pro_install_cmd }  
5457      MSG 
5558    end 
5659
@@ -61,6 +64,8 @@ def validate_package_gem_compatibility!
6164
6265      # Error: Both packages installed 
6366      if  has_base_package  && has_pro_package 
67+         remove_cmd  =  ReactOnRails ::Utils . package_manager_remove_command ( "react-on-rails" ) 
68+ 
6469        raise  ReactOnRails ::Error ,  <<~MSG . strip 
6570          **ERROR** ReactOnRails: Both 'react-on-rails' and 'react-on-rails-pro' packages are installed. 
6671
@@ -69,7 +74,7 @@ def validate_package_gem_compatibility!
6974
7075          Fix: 
7176            1. Remove 'react-on-rails' from your package.json dependencies 
72-             2. Run: yarn remove react-on-rails  
77+             2. Run: #{ remove_cmd }  
7378            3. Keep only: react-on-rails-pro 
7479
7580          #{ package_json_location }  
@@ -78,14 +83,17 @@ def validate_package_gem_compatibility!
7883
7984      # Error: Pro gem but using base package 
8085      if  is_pro_gem  && !has_pro_package 
86+         remove_cmd  =  ReactOnRails ::Utils . package_manager_remove_command ( "react-on-rails" ) 
87+         install_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( "react-on-rails-pro" ,  gem_version ) 
88+ 
8189        raise  ReactOnRails ::Error ,  <<~MSG . strip 
8290          **ERROR** ReactOnRails: You have the Pro gem installed but are using the base 'react-on-rails' package. 
8391
8492          When using React on Rails Pro, you must use the 'react-on-rails-pro' npm package. 
8593
8694          Fix: 
87-             1. Remove the base package: yarn remove react-on-rails  
88-             2. Install the Pro package: yarn add react-on-rails-pro@ #{ gem_version }  --exact  
95+             1. Remove the base package: #{ remove_cmd }  
96+             2. Install the Pro package: #{ install_cmd }  
8997
9098          #{ package_json_location }  
9199        MSG 
@@ -94,6 +102,9 @@ def validate_package_gem_compatibility!
94102      # Error: Pro package but not Pro gem 
95103      return  unless  !is_pro_gem  && has_pro_package 
96104
105+       remove_pro_cmd  =  ReactOnRails ::Utils . package_manager_remove_command ( "react-on-rails-pro" ) 
106+       install_base_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( "react-on-rails" ,  gem_version ) 
107+ 
97108      raise  ReactOnRails ::Error ,  <<~MSG . strip 
98109        **ERROR** ReactOnRails: You have the 'react-on-rails-pro' package installed but the Pro gem is not installed. 
99110
@@ -105,8 +116,8 @@ def validate_package_gem_compatibility!
105116          2. Run: bundle install 
106117
107118        Or if you meant to use the base version: 
108-           1. Remove the Pro package: yarn remove react-on-rails-pro  
109-           2. Install the base package: yarn add react-on-rails@ #{ gem_version }  --exact  
119+           1. Remove the Pro package: #{ remove_pro_cmd }  
120+           2. Install the base package: #{ install_base_cmd }  
110121
111122        #{ package_json_location }  
112123      MSG 
@@ -118,6 +129,8 @@ def validate_exact_version!
118129      return  unless  node_package_version . semver_wildcard? 
119130
120131      package_name  =  node_package_version . package_name 
132+       install_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( package_name ,  gem_version ) 
133+ 
121134      raise  ReactOnRails ::Error ,  <<~MSG . strip 
122135        **ERROR** ReactOnRails: The '#{ package_name }  
123136
@@ -128,7 +141,7 @@ def validate_exact_version!
128141        Do not use ^, ~, >, <, *, or other semver ranges. 
129142
130143        Fix: 
131-           Run: yarn add  #{ package_name } @ #{ gem_version }  --exact  
144+           Run: #{ install_cmd }  
132145
133146        #{ package_json_location }  
134147      MSG 
@@ -140,6 +153,8 @@ def validate_version_match!
140153      return  if  node_package_version . parts  == gem_version_parts 
141154
142155      package_name  =  node_package_version . package_name 
156+       install_cmd  =  ReactOnRails ::Utils . package_manager_install_exact_command ( package_name ,  gem_version ) 
157+ 
143158      raise  ReactOnRails ::Error ,  <<~MSG . strip 
144159        **ERROR** ReactOnRails: The '#{ package_name }  
145160
@@ -149,7 +164,7 @@ def validate_version_match!
149164        The npm package and gem versions must match exactly for compatibility. 
150165
151166        Fix: 
152-           Run: yarn add  #{ package_name } @ #{ gem_version }  --exact  
167+           Run: #{ install_cmd }  
153168
154169        #{ package_json_location }  
155170      MSG 
0 commit comments