File tree Expand file tree Collapse file tree 1 file changed +3
-37
lines changed 
lib/generators/react_on_rails Expand file tree Collapse file tree 1 file changed +3
-37
lines changed Original file line number Diff line number Diff line change @@ -326,44 +326,10 @@ def install_typescript_dependencies
326326          @babel/preset-typescript 
327327        ] 
328328
329-         install_command  =  case  package_manager 
330-                           when  "npm" 
331-                             "npm install --save-dev #{ typescript_packages . join ( ' ' ) }  
332-                           when  "yarn" 
333-                             "yarn add --dev #{ typescript_packages . join ( ' ' ) }  
334-                           when  "pnpm" 
335-                             "pnpm add --save-dev #{ typescript_packages . join ( ' ' ) }  
336-                           when  "bun" 
337-                             "bun add --dev #{ typescript_packages . join ( ' ' ) }  
338-                           end 
339- 
340-         success  =  system ( install_command ) 
341-         unless  success 
342-           warning  =  <<~MSG . strip 
343-             ⚠️  Failed to install TypeScript dependencies automatically. 
344- 
345-             Please run manually: 
346-                 #{ install_command }  
347- 
348-             TypeScript files will still be generated. 
349-           MSG 
350-           GeneratorMessages . add_warning ( warning ) 
351-         end 
352- 
353-         # Generate tsconfig.json 
354-         create_typescript_config 
355- 
356-         puts  Rainbow ( "✅ TypeScript support configured" ) . green 
357-         puts  Rainbow ( "   Note: Shakapacker automatically detects @babel/preset-typescript" ) . blue 
358-       end 
359- 
360-       def  detect_package_manager 
361-         return  "yarn"  if  File . exist? ( "yarn.lock" ) 
362-         return  "pnpm"  if  File . exist? ( "pnpm-lock.yaml" ) 
363-         return  "bun"  if  File . exist? ( "bun.lockb" ) 
364-         return  "npm"  if  File . exist? ( "package-lock.json" )  || cli_exists? ( "npm" ) 
329+         return  if  add_npm_dependencies ( typescript_packages ,  dev : true ) 
365330
366-         nil 
331+         success  =  run  "npm install --save-dev #{ typescript_packages . join ( ' ' ) }  
332+         handle_npm_failure ( "TypeScript dependencies" ,  typescript_packages )  unless  success 
367333      end 
368334
369335      def  create_typescript_config 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments