From 8279aaaea4dfe035a1e501f10650f9b92451aa05 Mon Sep 17 00:00:00 2001 From: iuhoay Date: Mon, 27 Jul 2026 09:01:54 +0800 Subject: [PATCH] fix: update Vite Ruby gems conservatively --- test/upgrade_test.rb | 22 ++++++++++++++++++++++ vite_ruby/lib/vite_ruby/cli/upgrade.rb | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/upgrade_test.rb diff --git a/test/upgrade_test.rb b/test/upgrade_test.rb new file mode 100644 index 00000000..a204a804 --- /dev/null +++ b/test/upgrade_test.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "test_helper" + +class UpgradeTest < ViteRuby::Test + def test_updates_gems_conservatively + libraries = [ + ["rails", Struct.new(:name).new("vite_rails")], + ["rack", Struct.new(:name).new("vite_plugin_legacy")], + ] + status = MockProcessStatus.new + + ViteRuby.stub(:framework_libraries, libraries) do + ViteRuby::IO.stub(:capture, ->(*command) { + assert_equal ["bundle update --conservative vite_ruby vite_rails vite_plugin_legacy"], command + ["", "", status] + }) do + ViteRuby::CLI::Upgrade.new.send(:upgrade_ruby_gems) + end + end + end +end diff --git a/vite_ruby/lib/vite_ruby/cli/upgrade.rb b/vite_ruby/lib/vite_ruby/cli/upgrade.rb index dd42c037..25c1d2a5 100644 --- a/vite_ruby/lib/vite_ruby/cli/upgrade.rb +++ b/vite_ruby/lib/vite_ruby/cli/upgrade.rb @@ -15,7 +15,7 @@ def upgrade_ruby_gems libraries = ViteRuby.framework_libraries.map { |_f, library| library.name } - run_with_capture("bundle update #{libraries.join(" ")}") + run_with_capture("bundle update --conservative vite_ruby #{libraries.join(" ")}") end # NOTE: Spawn a new process so that it uses the updated vite_ruby.