lib/vite_ruby/cli/install.rb in vite_ruby-1.2.13 vs lib/vite_ruby/cli/install.rb in vite_ruby-1.2.14

- old
+ new

@@ -26,10 +26,18 @@ say "\nVite ⚡️ Ruby successfully installed! 🎉" end protected + # Internal: The JS packages that should be added to the app. + def js_dependencies + [ + "vite@#{ ViteRuby::DEFAULT_VITE_VERSION }", + "vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }", + ] + end + # Internal: Setup for a plain Rack application. def setup_app_files copy_template 'config/vite.json', to: config.config_path if (rackup_file = root.join('config.ru')).exist? @@ -71,11 +79,11 @@ def install_js_dependencies package_json = root.join('package.json') write(package_json, '{}') unless package_json.exist? Dir.chdir(root) do - deps = "vite@#{ ViteRuby::DEFAULT_VITE_VERSION } vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }" + deps = js_dependencies.join(' ') _, stderr, status = ViteRuby::IO.capture("npx --package @antfu/ni -- ni -D #{ deps }", stdin_data: "\n") _, stderr, = ViteRuby::IO.capture("yarn add -D #{ deps }") unless status.success? say("Could not install JS dependencies.\n", stderr) unless stderr.to_s.empty? end end @@ -115,7 +123,7 @@ end end # NOTE: This allows framework-specific variants to extend the installation. ViteRuby.framework_libraries.each do |_framework, library| - require "#{ library.name }/installation" + require "#{ library.name.tr('-', '/') }/installation" end