vite_ruby 3.10.6 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 129b1982f425d4c3b67385c93b43f7eccd1cd177db7f13197cfb843f10248852
4
- data.tar.gz: 6e16251499ae23bc413ff671dc95e6a390d9ba241073d9e93326a3f140326e2d
3
+ metadata.gz: 8349aea6809e111e73935d71ab1bd256abb988a20207b155f44efc86f99af61a
4
+ data.tar.gz: 8c43f3fc3bd96ae6ceea8c47f57c5807ff282a1055c84ae0be2c3763f80b5527
5
5
  SHA512:
6
- metadata.gz: f02fdbab75740f5d0c510eddbae774120cd06b44c99d7cabfbed7a1e5ca18120b5a0b55ba6e5e35eea6129087052255255e07bc199f8f855825c01fd17e920d8
7
- data.tar.gz: 56ee4a35214aadc548c538ee13898df54c91f95349f58f8008465afcd3e74d186df05d82badd7af562192947369859e3bcf3461c25e0c7f3beaeae782821d1aa
6
+ metadata.gz: 8d92c2da929fa6664b2f08427606daf86dea0eae6d068d8cd527fb947f4083068e5f6fa8327b8d505d51316d502df60538a8b9adeec4d62d67eaeb1126d62bca
7
+ data.tar.gz: e9425003b0d0b8a6c7d29e72a65d9a529ee4035f23228b31f28e35ea5ccb905e5e47e9d63d276111f9aa2e3b1167a0077a25675c93449f8dc863c38e1cef2c50
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [3.11.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.6...vite_ruby@3.11.0) (2026-09-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * detect if dev server is running using a local file (close [#391](https://github.com/ElMassimo/vite_ruby/issues/391)) ([#621](https://github.com/ElMassimo/vite_ruby/issues/621)) ([d424fbf](https://github.com/ElMassimo/vite_ruby/commit/d424fbf5fbd3782c4446c4c357331320e3512352))
7
+
8
+
9
+
1
10
  ## [3.10.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.5...vite_ruby@3.10.6) (2026-09-16)
2
11
 
3
12
 
data/default.vite.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "buildCacheDir": "tmp/cache/vite",
7
7
  "publicOutputDir": "vite",
8
8
  "configPath": "config/vite.json",
9
+ "devServerConnectionCheck": false,
9
10
  "devServerConnectTimeout": 0.01,
10
11
  "packageManager": null,
11
12
  "publicDir": "public",
@@ -5,6 +5,9 @@ require "json"
5
5
  # Public: Allows to resolve configuration sourced from `config/vite.json` and
6
6
  # environment variables, combining them with the default options.
7
7
  class ViteRuby::Config
8
+ # Internal: Name of the metadata file written by the Vite dev server.
9
+ DEV_SERVER_META_FILENAME = "vite-ruby.json"
10
+
8
11
  def origin
9
12
  "#{protocol}://#{host_with_port}"
10
13
  end
@@ -38,6 +41,11 @@ class ViteRuby::Config
38
41
  root.join(public_dir, public_output_dir)
39
42
  end
40
43
 
44
+ # Internal: Path to the metadata file written by the Vite dev server.
45
+ def dev_server_meta_path
46
+ root.join("tmp", DEV_SERVER_META_FILENAME)
47
+ end
48
+
41
49
  # Public: The directory where the entries are located.
42
50
  def resolved_entrypoints_dir
43
51
  vite_root_dir.join(entrypoints_dir)
@@ -96,7 +104,7 @@ private
96
104
  config["build_cache_dir"] = root.join(config["build_cache_dir"])
97
105
  config["ssr_output_dir"] = root.join(config["ssr_output_dir"])
98
106
  config["dev_server_connect_timeout"] = config["dev_server_connect_timeout"].to_f
99
- coerce_booleans(config, "auto_build", "hide_build_console_output", "https", "skip_compatibility_check", "skip_proxy")
107
+ coerce_booleans(config, "auto_build", "dev_server_connection_check", "hide_build_console_output", "https", "skip_compatibility_check", "skip_proxy")
100
108
  config["package_manager"] ||= detect_package_manager(root)
101
109
  end
102
110
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = "3.10.6"
4
+ VERSION = "3.11.0"
5
5
 
6
6
  # Internal: Versions used by default when running `vite install`.
7
7
  DEFAULT_VITE_VERSION = "^8.0.0"
data/lib/vite_ruby.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
3
4
  require "logger"
4
5
  require "forwardable"
5
6
  require "pathname"
@@ -82,19 +83,11 @@ class ViteRuby
82
83
  end
83
84
 
84
85
  # Public: Returns true if the Vite development server is currently running.
85
- # NOTE: Checks only once every second since every lookup calls this method.
86
86
  def dev_server_running?
87
- return false unless run_proxy?
88
- return @running if defined?(@running) && Time.now - @running_checked_at < 1
87
+ return false unless dev_mode?
88
+ return dev_server_connected? if config.dev_server_connection_check
89
89
 
90
- begin
91
- Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
92
- @running = true
93
- rescue
94
- @running = false
95
- ensure
96
- @running_checked_at = Time.now
97
- end
90
+ !dev_server_meta.nil?
98
91
  end
99
92
 
100
93
  # Public: Additional environment variables to pass to Vite.
@@ -105,13 +98,15 @@ class ViteRuby
105
98
  @env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
106
99
  end
107
100
 
108
- # Public: The proxy for assets should only run in development mode.
109
- def run_proxy?
101
+ # Public: Whether we are in an environment that might run the Vite dev server.
102
+ def dev_mode?
110
103
  config.mode == "development" || (config.mode == "test" && !ENV["CI"])
111
104
  rescue => error
112
105
  logger.error("Failed to check mode for Vite: #{error.message}")
113
106
  false
114
107
  end
108
+ # Public: The proxy for assets should only run in development mode.
109
+ alias_method :run_proxy?, :dev_mode?
115
110
 
116
111
  # Internal: Executes the vite binary.
117
112
  def run(argv, **options)
@@ -147,6 +142,34 @@ class ViteRuby
147
142
  def manifest
148
143
  @manifest ||= ViteRuby::Manifest.new(self)
149
144
  end
145
+
146
+ private
147
+
148
+ # Internal: Returns true if a TCP connection to the dev server can be opened.
149
+ def dev_server_connected?
150
+ return @running if defined?(@running) && Time.now - @running_checked_at < 1
151
+
152
+ begin
153
+ Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
154
+ @running = true
155
+ rescue
156
+ @running = false
157
+ ensure
158
+ @running_checked_at = Time.now
159
+ end
160
+ end
161
+
162
+ # Internal: Metadata written by the running Vite dev server, or nil when stopped.
163
+ def dev_server_meta
164
+ return @dev_server_meta if defined?(@dev_server_meta) && Time.now - @dev_server_meta_checked_at < 1
165
+
166
+ path = config.dev_server_meta_path
167
+ @dev_server_meta = (JSON.parse(path.read) if path.exist?)
168
+ rescue JSON::ParserError, SystemCallError
169
+ @dev_server_meta = nil
170
+ ensure
171
+ @dev_server_meta_checked_at = Time.now
172
+ end
150
173
  end
151
174
 
152
175
  require "vite_ruby/version"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.6
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
@@ -228,8 +228,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
228
228
  licenses:
229
229
  - MIT
230
230
  metadata:
231
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.10.6/vite_ruby
232
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.10.6/vite_ruby/CHANGELOG.md
231
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.11.0/vite_ruby
232
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.11.0/vite_ruby/CHANGELOG.md
233
233
  rubygems_mfa_required: 'true'
234
234
  post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
235
235
  manually, please run:\n\tbundle exec vite upgrade"