Skip to content

Commit e8614b2

Browse files
Update lib/generators/react_on_rails/install_generator.rb
Co-authored-by: Alexey Romanov <alexey.romanov+ci5@shakacode.com>
1 parent edbe88c commit e8614b2

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)