vite_ruby 3.3.4 → 3.5.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: 579d77a9b6f100195112e6ee0fc66d445f35aca1d079c24c9548ea6b708af472
4
- data.tar.gz: 13b18e4418675330c2d974b41a56b4dac97a4b4f3f10cffb1216d9370b386a52
3
+ metadata.gz: 6024067932bb5062002e46418a1861eb4193916c7454e24245fe3cf83c56795d
4
+ data.tar.gz: cfc52727b1e4cde4936254cd0025d97942e3b636c5647742dc1c809fb3a9bba4
5
5
  SHA512:
6
- metadata.gz: cf5e33d054b13211aeccbcccd96c2c03e8bae08c56c5ad52ffbac39a045b423a393b5e80fec15a7ad56929d4f8db09230b7d71260bd7fd0dd05478b0db661b54
7
- data.tar.gz: 334056f48cbf9799e3522aaf575e657b6f7c6b7d825adf59ed602a45d1654d5d97a362b80aec578a836b4bd6ad084b740c4822ba1d99dab1c6ef2ce8a1343f2d
6
+ metadata.gz: 489c44241c90ac71fd978a8142554581505e05acce6268a062738a4f1f9c5e88a2cca39778459cea3e7e79d5116bc7f8ea1b4455f65fe9d436a15164ab5704cc
7
+ data.tar.gz: 2425fb29d5151d56f2774c435eb2a5b636c765e229aff3a99936300453ec77c281fdac8c85c6885d1cc3ce900a470f3b58cb6135f0a51124ef34c965282d9b38
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [3.5.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.4.0...vite_ruby@3.5.0) (2023-11-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * prevent clean from deleting assets referenced in the manifests ([8a581c1](https://github.com/ElMassimo/vite_ruby/commit/8a581c15ff480049bbb14dab1b5a3497308521b5))
7
+
8
+
9
+ ### Features
10
+
11
+ * use vite 5 in new installations ([f063f28](https://github.com/ElMassimo/vite_ruby/commit/f063f283f939d15b3c48c1a9b6efcd589fafbaf1))
12
+
13
+
14
+
15
+ # [3.4.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.4...vite_ruby@3.4.0) (2023-11-16)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **breaking:** check for any existing manifest path before cleaning ([c450483](https://github.com/ElMassimo/vite_ruby/commit/c4504839e11006d50d6503288469cb3de0c6a9cd))
21
+
22
+
23
+ ### Features
24
+
25
+ * add support for vite 5, which changed default manifest path ([818132a](https://github.com/ElMassimo/vite_ruby/commit/818132a07af3f17ba27ae09c44fcd59029064238))
26
+
27
+
28
+
1
29
  ## [3.3.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.3...vite_ruby@3.3.4) (2023-06-27)
2
30
 
3
31
 
@@ -50,7 +50,7 @@ class ViteRuby::Commands
50
50
 
51
51
  versions
52
52
  .each_with_index
53
- .drop_while { |(mtime, _), index|
53
+ .drop_while { |(mtime, _files), index|
54
54
  max_age = [0, Time.now - Time.at(mtime)].max
55
55
  max_age < age_in_seconds || index < keep_up_to
56
56
  }
@@ -131,7 +131,7 @@ private
131
131
  def_delegators :@vite_ruby, :config, :builder, :manifest, :logger, :logger=
132
132
 
133
133
  def may_clean?
134
- config.build_output_dir.exist? && config.manifest_path.exist?
134
+ config.build_output_dir.exist? && config.manifest_paths.any?
135
135
  end
136
136
 
137
137
  def clean_files(files)
@@ -143,14 +143,16 @@ private
143
143
 
144
144
  def versions
145
145
  all_files = Dir.glob("#{ config.build_output_dir }/**/*")
146
- entries = all_files - config.manifest_paths - current_version_files
146
+ entries = all_files - config.manifest_paths - files_referenced_in_manifests
147
147
  entries.reject { |file| File.directory?(file) }
148
148
  .group_by { |file| File.mtime(file).utc.to_i }
149
149
  .sort.reverse
150
150
  end
151
151
 
152
- def current_version_files
153
- Dir.glob(manifest.refresh.values.map { |value| config.build_output_dir.join("#{ value['file'] }*") })
152
+ def files_referenced_in_manifests
153
+ config.manifest_paths.flat_map { |path|
154
+ JSON.parse(path.read).map { |_, entry| entry['file'] }
155
+ }.compact.uniq.map { |path| config.build_output_dir.join(path).to_s }
154
156
  end
155
157
 
156
158
  def with_node_env(env)
@@ -17,19 +17,24 @@ class ViteRuby::Config
17
17
  "#{ host }:#{ port }"
18
18
  end
19
19
 
20
- # Internal: Path where Vite outputs the manifest file.
21
- def manifest_path
22
- build_output_dir.join('manifest.json')
23
- end
24
-
25
- # Internal: Path where vite-plugin-ruby outputs the assets manifest file.
26
- def assets_manifest_path
27
- build_output_dir.join('manifest-assets.json')
20
+ # Internal: Path to the manifest files generated by Vite and vite-plugin-ruby.
21
+ def known_manifest_paths
22
+ [
23
+ # NOTE: Generated by Vite when `manifest: true`, which vite-plugin-ruby enables.
24
+ 'manifest.json',
25
+ # NOTE: Path where vite-plugin-ruby outputs the assets manifest file.
26
+ 'manifest-assets.json',
27
+ ].flat_map { |path|
28
+ [
29
+ build_output_dir.join(".vite/#{ path }"), # Vite 5 onwards
30
+ build_output_dir.join(path), # Vite 4 and below
31
+ ]
32
+ }
28
33
  end
29
34
 
30
35
  # Internal: Path to the manifest files generated by Vite and vite-plugin-ruby.
31
36
  def manifest_paths
32
- [manifest_path, assets_manifest_path].select(&:exist?)
37
+ known_manifest_paths.select(&:exist?)
33
38
  end
34
39
 
35
40
  # Public: The directory where Vite will store the built assets.
@@ -11,12 +11,13 @@ class ViteRuby::MissingEntrypointError < ViteRuby::Error
11
11
  def initialize(info)
12
12
  @info = info
13
13
  super <<~MSG
14
- Vite Ruby can't find #{ file_name } in #{ config.manifest_path.relative_path_from(config.root) } or #{ config.assets_manifest_path.relative_path_from(config.root) }.
14
+ Vite Ruby can't find #{ file_name } in the manifests.
15
15
 
16
16
  Possible causes:
17
17
  #{ possible_causes(last_build) }
18
18
  :troubleshooting:
19
- #{ "\nContent in your manifests:\n#{ JSON.pretty_generate(manifest) }\n" if last_build.success }
19
+ #{ "Manifest files found:\n#{ config.manifest_paths.map { |path| " #{ path.relative_path_from(config.root) }" }.join("\n") }\n" if last_build.success }
20
+ #{ "Content in your manifests:\n#{ JSON.pretty_generate(manifest) }\n" if last_build.success }
20
21
  #{ "Last build in #{ config.mode } mode:\n#{ last_build.to_json }\n" if last_build.success }
21
22
  MSG
22
23
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '3.3.4'
4
+ VERSION = '3.5.0'
5
5
 
6
6
  # Internal: Versions used by default when running `vite install`.
7
- DEFAULT_VITE_VERSION = '^4.3.0'
8
- DEFAULT_PLUGIN_VERSION = '^3.2.0'
7
+ DEFAULT_VITE_VERSION = '^5.0.0'
8
+ DEFAULT_PLUGIN_VERSION = '^5.0.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.4
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -208,8 +208,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
208
208
  licenses:
209
209
  - MIT
210
210
  metadata:
211
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.3.4/vite_ruby
212
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.3.4/vite_ruby/CHANGELOG.md
211
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.5.0/vite_ruby
212
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.5.0/vite_ruby/CHANGELOG.md
213
213
  post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
214
214
  manually, please run:\n\tbundle exec vite upgrade"
215
215
  rdoc_options: []