Skip to content

Commit afb8f79

Browse files
ElMassimoSDRACK
authored andcommitted
fix(breaking): check for any existing manifest path before cleaning
1 parent cce6e0e commit afb8f79

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ GEM
9797
tzinfo (~> 2.0)
9898
ansi (1.5.0)
9999
ast (2.4.2)
100-
base64 (0.1.1)
100+
base64 (0.2.0)
101101
benchmark-ips (2.12.0)
102102
bigdecimal (3.1.4)
103103
builder (3.2.4)
@@ -108,7 +108,7 @@ GEM
108108
crass (1.0.6)
109109
date (3.3.3)
110110
docile (1.4.0)
111-
drb (2.1.1)
111+
drb (2.2.0)
112112
ruby2_keywords
113113
dry-cli (1.0.0)
114114
erubi (1.12.0)
@@ -117,11 +117,11 @@ GEM
117117
i18n (1.14.1)
118118
concurrent-ruby (~> 1.0)
119119
io-console (0.6.0)
120-
irb (1.8.1)
120+
irb (1.9.0)
121121
rdoc
122122
reline (>= 0.3.8)
123123
json (2.6.3)
124-
loofah (2.21.3)
124+
loofah (2.22.0)
125125
crass (~> 1.0.2)
126126
nokogiri (>= 1.12.0)
127127
m (1.6.2)
@@ -135,15 +135,15 @@ GEM
135135
marcel (1.0.2)
136136
method_source (1.0.0)
137137
mini_mime (1.1.5)
138-
mini_portile2 (2.8.4)
138+
mini_portile2 (2.8.5)
139139
minitest (5.20.0)
140140
minitest-reporters (1.6.1)
141141
ansi
142142
builder
143143
minitest (>= 5.0)
144144
ruby-progressbar
145145
minitest-stub_any_instance (1.0.3)
146-
mutex_m (0.1.2)
146+
mutex_m (0.2.0)
147147
net-imap (0.4.0)
148148
date
149149
net-protocol
@@ -167,9 +167,9 @@ GEM
167167
pry-byebug (3.10.1)
168168
byebug (~> 11.0)
169169
pry (>= 0.13, < 0.15)
170-
psych (5.1.0)
170+
psych (5.1.1.1)
171171
stringio
172-
racc (1.7.1)
172+
racc (1.7.3)
173173
rack (3.0.8)
174174
rack-proxy (0.7.7)
175175
rack
@@ -210,11 +210,11 @@ GEM
210210
thor (~> 1.0, >= 1.2.2)
211211
zeitwerk (~> 2.6)
212212
rainbow (3.1.1)
213-
rake (13.0.6)
214-
rdoc (6.5.0)
213+
rake (13.1.0)
214+
rdoc (6.6.0)
215215
psych (>= 4.0.0)
216216
regexp_parser (2.8.1)
217-
reline (0.3.9)
217+
reline (0.4.0)
218218
io-console (~> 0.5)
219219
rexml (3.2.6)
220220
rubocop (1.24.1)
@@ -241,8 +241,8 @@ GEM
241241
simplecov-html (~> 0.10.0)
242242
simplecov-html (0.10.2)
243243
spring (2.1.1)
244-
stringio (3.0.8)
245-
thor (1.2.2)
244+
stringio (3.0.9)
245+
thor (1.3.0)
246246
timeout (0.4.0)
247247
tzinfo (2.0.6)
248248
concurrent-ruby (~> 1.0)

test/config_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_ruby_config_file
6161
end
6262

6363
def test_manifest_path
64-
assert_path 'test_app/public/vite-production/manifest.json', @config.manifest_path
64+
assert_path 'test_app/public/vite-production/.vite/manifest.json', @config.manifest_paths.first
6565
end
6666

6767
def test_build_cache_dir

test/manifest_test.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,22 @@ def test_lookup_exception!
5252
stub_builder(build_successful: true) {
5353
asset_file = 'calendar.js'
5454
error = assert_raises_manifest_missing_entry_error { path_for(asset_file) }
55-
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in #{ manifest_path }", error.message
55+
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in the manifests", error.message
5656
assert_match '"autoBuild" is set to `false`', error.message
5757

5858
asset_file = 'images/logo.gif'
5959
error = assert_raises_manifest_missing_entry_error { path_for(asset_file) }
60-
assert_match "Vite Ruby can't find #{ asset_file } in #{ manifest_path }", error.message
60+
assert_match "Vite Ruby can't find #{ asset_file } in the manifests", error.message
6161

6262
asset_file = '/app/styles/theme.css'
6363
error = assert_raises_manifest_missing_entry_error { path_for(asset_file) }
64-
assert_match "Vite Ruby can't find ../styles/theme.css in #{ manifest_path }", error.message
64+
assert_match "Vite Ruby can't find ../styles/theme.css in the manifests", error.message
6565

6666
asset_file = '~/favicon.ico'
6767
error = assert_raises_manifest_missing_entry_error { path_for(asset_file) }
68-
assert_match "Vite Ruby can't find favicon.ico in #{ manifest_path }", error.message
68+
assert_match "Vite Ruby can't find favicon.ico in the manifests", error.message
69+
70+
assert_match "Manifest files found:\n #{ manifest_path }", error.message
6971
}
7072
end
7173

@@ -77,7 +79,7 @@ def test_lookup_exception_when_auto_build
7779
path_for(asset_file)
7880
end
7981

80-
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in #{ manifest_path }", error.message
82+
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in the manifests", error.message
8183
assert_match 'The file path is incorrect.', error.message
8284
}
8385
end
@@ -94,7 +96,7 @@ def test_lookup_exception_when_build_failed
9496
path_for(asset_file)
9597
end
9698

97-
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in #{ manifest_path }", error.message
99+
assert_match "Vite Ruby can't find entrypoints/#{ asset_file } in the manifests", error.message
98100
assert_match 'The last build failed.', error.message
99101
assert_match " #{ error_lines[0] }", error.message
100102
assert_match " #{ error_lines[1] }", error.message
@@ -108,7 +110,7 @@ def test_lookup_with_type_exception!
108110
path_for(asset_file, type: :javascript)
109111
end
110112

111-
assert_match "Vite Ruby can't find entrypoints/#{ asset_file }.js in #{ manifest_path }", error.message
113+
assert_match "Vite Ruby can't find entrypoints/#{ asset_file }.js in the manifests", error.message
112114
end
113115

114116
def test_lookup_success!
@@ -229,7 +231,7 @@ def assert_raises_manifest_missing_entry_error(auto_build: false, &block)
229231
end
230232

231233
def manifest_path
232-
'public/vite-production/manifest.json'
234+
'public/vite-production/.vite/manifest.json'
233235
end
234236

235237
def prefixed(file)

test/test_app/public/vite-production/manifest-assets.json renamed to test/test_app/public/vite-production/.vite/manifest-assets.json

File renamed without changes.
File renamed without changes.

vite_ruby/lib/vite_ruby/commands.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def print_info
131131
def_delegators :@vite_ruby, :config, :builder, :manifest, :logger, :logger=
132132

133133
def may_clean?
134-
config.build_output_dir.exist? && config.manifest_path.exist?
134+
config.build_output_dir.exist? && config.manifest_paths.any?
135135
end
136136

137137
def clean_files(files)

0 commit comments

Comments
 (0)