From 8542c1f1244899693aac780cf4cfd8416b65e48b Mon Sep 17 00:00:00 2001 From: Tim Guibord Date: Tue, 12 Dec 2023 10:25:53 -0500 Subject: [PATCH 01/14] Support sourcemap files in digested paths The regular expression for generating digested paths in propshaft is updated to accommodate sourcemap files too. This will ensure the digested sourcemaps end `-sha.ext.map` instead of `ext-sha.map`. Services like Datadog that allow sourcemap uploads look specifically for files ending with `.js.map`, so this change allows compatibility. A corresponding test has been added in asset_test.rb, verifying that sourcemap files are correctly digesting their paths. --- lib/propshaft/asset.rb | 2 +- test/fixtures/assets/first_path/file-is-a-sourcemap.js.map | 0 test/propshaft/asset_test.rb | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/assets/first_path/file-is-a-sourcemap.js.map diff --git a/lib/propshaft/asset.rb b/lib/propshaft/asset.rb index 6278df0..e6d84f4 100644 --- a/lib/propshaft/asset.rb +++ b/lib/propshaft/asset.rb @@ -28,7 +28,7 @@ def digested_path if already_digested? logical_path else - logical_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" } + logical_path.sub(/\.(\w+(\.map)?)$/) { |ext| "-#{digest}#{ext}" } end end diff --git a/test/fixtures/assets/first_path/file-is-a-sourcemap.js.map b/test/fixtures/assets/first_path/file-is-a-sourcemap.js.map new file mode 100644 index 0000000..e69de29 diff --git a/test/propshaft/asset_test.rb b/test/propshaft/asset_test.rb index 702a209..3dd31eb 100644 --- a/test/propshaft/asset_test.rb +++ b/test/propshaft/asset_test.rb @@ -40,6 +40,9 @@ class Propshaft::AssetTest < ActiveSupport::TestCase assert_equal "file-not.digested-e206c34fe404c8e2f25d60dd8303f61c02b8d381.css", find_asset("file-not.digested.css").digested_path.to_s + + assert_equal "file-is-a-sourcemap-da39a3ee5e6b4b0d3255bfef95601890afd80709.js.map", + find_asset("file-is-a-sourcemap.js.map").digested_path.to_s end test "value object equality" do From bb7c462b22ede47cc1d28867cfa4c56e33230792 Mon Sep 17 00:00:00 2001 From: Tim Guibord Date: Tue, 12 Dec 2023 10:32:25 -0500 Subject: [PATCH 02/14] update spec --- test/propshaft/compiler/source_mapping_urls_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/propshaft/compiler/source_mapping_urls_test.rb b/test/propshaft/compiler/source_mapping_urls_test.rb index 1b10e4b..d5a4f0d 100644 --- a/test/propshaft/compiler/source_mapping_urls_test.rb +++ b/test/propshaft/compiler/source_mapping_urls_test.rb @@ -14,14 +14,14 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "matching source map" do - assert_match %r{//# sourceMappingURL=/assets/source.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/assets/source-[a-z0-9]{40}\.js.map}, compile_asset(find_asset("source.js", fixture_path: "mapped")) - assert_match %r{/\*# sourceMappingURL=/assets/source.css-[a-z0-9]{40}\.map}, + assert_match %r{/\*# sourceMappingURL=/assets/source-[a-z0-9]{40}\.css.map}, compile_asset(find_asset("source.css", fixture_path: "mapped")) end test "matching nested source map" do - assert_match %r{//# sourceMappingURL=/assets/nested/another-source.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/assets/nested/another-source-[a-z0-9]{40}\.js.map}, compile_asset(find_asset("nested/another-source.js", fixture_path: "mapped")) end @@ -38,9 +38,9 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "sourceMappingURL not at the beginning of the line, but at end of file, is processed" do - assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.js.map}, compile_asset(find_asset("sourceMappingURL-not-at-start.js", fixture_path: "mapped")) - assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start.css-[a-z0-9]{40}\.map \*/}, + assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.css.map \*/}, compile_asset(find_asset("sourceMappingURL-not-at-start.css", fixture_path: "mapped")) end @@ -56,7 +56,7 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase test "relative url root" do @options.relative_url_root = "/url-root" - assert_match %r{//# sourceMappingURL=/url-root/assets/source.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/url-root/assets/source-[a-z0-9]{40}\.js.map}, compile_asset(find_asset("source.js", fixture_path: "mapped")) end From 6f91154777542123d9c13a3570fbf2412cc22a15 Mon Sep 17 00:00:00 2001 From: Erick Sasse <148989+esasse@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:15:52 -0300 Subject: [PATCH 03/14] Improve log message (#163) --- lib/propshaft/compiler/source_mapping_urls.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/propshaft/compiler/source_mapping_urls.rb b/lib/propshaft/compiler/source_mapping_urls.rb index 0a32d90..a0b678d 100644 --- a/lib/propshaft/compiler/source_mapping_urls.rb +++ b/lib/propshaft/compiler/source_mapping_urls.rb @@ -6,7 +6,7 @@ class Propshaft::Compiler::SourceMappingUrls < Propshaft::Compiler SOURCE_MAPPING_PATTERN = %r{(//|/\*)# sourceMappingURL=(.+\.map)(\s*?\*\/)?\s*?\Z} def compile(logical_path, input) - input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(asset_path($2, logical_path), $1, $3) } + input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(logical_path, asset_path($2, logical_path), $1, $3) } end private @@ -18,11 +18,11 @@ def asset_path(source_mapping_url, logical_path) end end - def source_mapping_url(resolved_path, comment_start, comment_end) + def source_mapping_url(logical_path, resolved_path, comment_start, comment_end) if asset = assembly.load_path.find(resolved_path) "#{comment_start}# sourceMappingURL=#{url_prefix}/#{asset.digested_path}#{comment_end}" else - Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{resolved_path}" + Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{logical_path}" "#{comment_start}#{comment_end}" end end From d3ddd7759af3ff148b490b4fbd59d38a02b38b2a Mon Sep 17 00:00:00 2001 From: Erick Sasse <148989+esasse@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:16:56 -0300 Subject: [PATCH 04/14] Upgrade VS Code extension to Ruby LSP (#162) --- .devcontainer/devcontainer.json | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c6bc87a..2a059da 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ "name": "Ruby", "build": { "dockerfile": "Dockerfile", - "args": { + "args": { // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6 // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. @@ -14,14 +14,17 @@ } }, - // Set *default* container specific settings.json values on container create. - "settings": {}, + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "Shopify.ruby-lsp" + ] + } + }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "rebornix.Ruby" - ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], From 6bb10f87c87dc8e39f34306bf8adac0dc33a8b5a Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Mon, 11 Dec 2023 13:20:31 -0500 Subject: [PATCH 05/14] Support base64 encoded digests to account for rollup 4.x (#168) --- lib/propshaft/asset.rb | 2 +- ... file-already-abcdefVWXYZ0123456789_-.digested.css} | 0 ...already-abcdefVWXYZ0123456789_-.digested.debug.css} | 0 test/propshaft/asset_test.rb | 10 +++++----- test/propshaft/server_test.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename test/fixtures/assets/first_path/{file-already-abcdefVWXYZ0123456789.digested.css => file-already-abcdefVWXYZ0123456789_-.digested.css} (100%) rename test/fixtures/assets/first_path/{file-already-abcdefVWXYZ0123456789.digested.debug.css => file-already-abcdefVWXYZ0123456789_-.digested.debug.css} (100%) diff --git a/lib/propshaft/asset.rb b/lib/propshaft/asset.rb index e6d84f4..4adb7dd 100644 --- a/lib/propshaft/asset.rb +++ b/lib/propshaft/asset.rb @@ -42,6 +42,6 @@ def ==(other_asset) private def already_digested? - logical_path.to_s =~ /-([0-9a-zA-Z]{7,128})\.digested/ + logical_path.to_s =~ /-([0-9a-zA-Z_-]{7,128})\.digested/ end end diff --git a/test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789.digested.css b/test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789_-.digested.css similarity index 100% rename from test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789.digested.css rename to test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789_-.digested.css diff --git a/test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789.digested.debug.css b/test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789_-.digested.debug.css similarity index 100% rename from test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789.digested.debug.css rename to test/fixtures/assets/first_path/file-already-abcdefVWXYZ0123456789_-.digested.debug.css diff --git a/test/propshaft/asset_test.rb b/test/propshaft/asset_test.rb index 3dd31eb..cd70415 100644 --- a/test/propshaft/asset_test.rb +++ b/test/propshaft/asset_test.rb @@ -25,18 +25,18 @@ class Propshaft::AssetTest < ActiveSupport::TestCase assert find_asset("one.txt").fresh?("f2e1ec14d6856e1958083094170ca6119c529a73") assert_not find_asset("one.txt").fresh?("e206c34fe404c8e2f25d60dd8303f61c02b8d381") - assert find_asset("file-already-abcdefVWXYZ0123456789.digested.css").fresh?(nil) + assert find_asset("file-already-abcdefVWXYZ0123456789_-.digested.css").fresh?(nil) end test "digested path" do assert_equal "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", find_asset("one.txt").digested_path.to_s - assert_equal "file-already-abcdefVWXYZ0123456789.digested.css", - find_asset("file-already-abcdefVWXYZ0123456789.digested.css").digested_path.to_s + assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.css", + find_asset("file-already-abcdefVWXYZ0123456789_-.digested.css").digested_path.to_s - assert_equal "file-already-abcdefVWXYZ0123456789.digested.debug.css", - find_asset("file-already-abcdefVWXYZ0123456789.digested.debug.css").digested_path.to_s + assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.debug.css", + find_asset("file-already-abcdefVWXYZ0123456789_-.digested.debug.css").digested_path.to_s assert_equal "file-not.digested-e206c34fe404c8e2f25d60dd8303f61c02b8d381.css", find_asset("file-not.digested.css").digested_path.to_s diff --git a/test/propshaft/server_test.rb b/test/propshaft/server_test.rb index c94a1e3..e213974 100644 --- a/test/propshaft/server_test.rb +++ b/test/propshaft/server_test.rb @@ -30,7 +30,7 @@ class Propshaft::ServerTest < ActiveSupport::TestCase end test "serve a predigested file" do - asset = @assembly.load_path.find("file-already-abcdefVWXYZ0123456789.digested.css") + asset = @assembly.load_path.find("file-already-abcdefVWXYZ0123456789_-.digested.css") get "/#{asset.digested_path}" assert_equal 200, last_response.status end From 031b7c02acfe32cbcdbfcc5a256dde6534b99236 Mon Sep 17 00:00:00 2001 From: Adam Rice Date: Tue, 12 Dec 2023 05:58:00 +1100 Subject: [PATCH 06/14] Fix typo in UPGRADING.md (#167) --- UPGRADING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 8f5b1c1..2609807 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -253,8 +253,8 @@ Rails.application.assets.load_path.find('logo.svg').content As Rails escapes html tags in views by default, in order to output a rendered svg you will need to specify rails not to escape the string using [html_safe](https://api.rubyonrails.org/classes/String.html#method-i-html_safe) or [raw](https://api.rubyonrails.org/classes/ActionView/Helpers/OutputSafetyHelper.html#method-i-raw). ```ruby -Rails.application.assets.load_path.find('logo.svg').html_safe -raw Rails.application.assets.load_path.find('logo.svg') +Rails.application.assets.load_path.find('logo.svg').content.html_safe +raw Rails.application.assets.load_path.find('logo.svg').content ``` **Precompilation in development** From 273b62819b29c1c16af33529bc94646f400ef732 Mon Sep 17 00:00:00 2001 From: Bill Lipa Date: Thu, 28 Dec 2023 20:41:15 -0800 Subject: [PATCH 07/14] Shorter digest length (#173) * Shorter digest length * shorten digest via first --- lib/propshaft/asset.rb | 2 +- test/fixtures/output/.manifest.json | 2 +- ...4170ca6119c529a73.txt => one-f2e1ec14.txt} | 0 test/propshaft/asset_test.rb | 10 +++--- .../propshaft/compiler/css_asset_urls_test.rb | 32 +++++++++---------- .../compiler/source_mapping_urls_test.rb | 12 +++---- test/propshaft/compilers_test.rb | 2 +- test/propshaft/load_path_test.rb | 8 ++--- test/propshaft/output_path_test.rb | 6 ++-- test/propshaft/processor_test.rb | 6 ++-- test/propshaft/resolver/dynamic_test.rb | 2 +- test/propshaft/resolver/static_test.rb | 2 +- test/propshaft/server_test.rb | 4 +-- test/propshaft_integration_test.rb | 6 ++-- 14 files changed, 47 insertions(+), 47 deletions(-) rename test/fixtures/output/{one-f2e1ec14d6856e1958083094170ca6119c529a73.txt => one-f2e1ec14.txt} (100%) diff --git a/lib/propshaft/asset.rb b/lib/propshaft/asset.rb index 4adb7dd..c9cc6bd 100644 --- a/lib/propshaft/asset.rb +++ b/lib/propshaft/asset.rb @@ -21,7 +21,7 @@ def length end def digest - @digest ||= Digest::SHA1.hexdigest("#{content}#{version}") + @digest ||= Digest::SHA1.hexdigest("#{content}#{version}").first(8) end def digested_path diff --git a/test/fixtures/output/.manifest.json b/test/fixtures/output/.manifest.json index 0b8b48a..ec2b100 100644 --- a/test/fixtures/output/.manifest.json +++ b/test/fixtures/output/.manifest.json @@ -1 +1 @@ -{ "one.txt": "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt" } +{ "one.txt": "one-f2e1ec14.txt" } diff --git a/test/fixtures/output/one-f2e1ec14d6856e1958083094170ca6119c529a73.txt b/test/fixtures/output/one-f2e1ec14.txt similarity index 100% rename from test/fixtures/output/one-f2e1ec14d6856e1958083094170ca6119c529a73.txt rename to test/fixtures/output/one-f2e1ec14.txt diff --git a/test/propshaft/asset_test.rb b/test/propshaft/asset_test.rb index cd70415..83861e8 100644 --- a/test/propshaft/asset_test.rb +++ b/test/propshaft/asset_test.rb @@ -18,18 +18,18 @@ class Propshaft::AssetTest < ActiveSupport::TestCase end test "digest" do - assert_equal "f2e1ec14d6856e1958083094170ca6119c529a73", find_asset("one.txt").digest + assert_equal "f2e1ec14", find_asset("one.txt").digest end test "fresh" do - assert find_asset("one.txt").fresh?("f2e1ec14d6856e1958083094170ca6119c529a73") - assert_not find_asset("one.txt").fresh?("e206c34fe404c8e2f25d60dd8303f61c02b8d381") + assert find_asset("one.txt").fresh?("f2e1ec14") + assert_not find_asset("one.txt").fresh?("e206c34f") assert find_asset("file-already-abcdefVWXYZ0123456789_-.digested.css").fresh?(nil) end test "digested path" do - assert_equal "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", + assert_equal "one-f2e1ec14.txt", find_asset("one.txt").digested_path.to_s assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.css", @@ -38,7 +38,7 @@ class Propshaft::AssetTest < ActiveSupport::TestCase assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.debug.css", find_asset("file-already-abcdefVWXYZ0123456789_-.digested.debug.css").digested_path.to_s - assert_equal "file-not.digested-e206c34fe404c8e2f25d60dd8303f61c02b8d381.css", + assert_equal "file-not.digested-e206c34f.css", find_asset("file-not.digested.css").digested_path.to_s assert_equal "file-is-a-sourcemap-da39a3ee5e6b4b0d3255bfef95601890afd80709.js.map", diff --git a/test/propshaft/compiler/css_asset_urls_test.rb b/test/propshaft/compiler/css_asset_urls_test.rb index 1047a2d..4187682 100644 --- a/test/propshaft/compiler/css_asset_urls_test.rb +++ b/test/propshaft/compiler/css_asset_urls_test.rb @@ -15,62 +15,62 @@ class Propshaft::Compiler::CssAssetUrlsTest < ActiveSupport::TestCase test "basic" do compiled = compile_asset_with_content(%({ background: url(file.jpg); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "blank spaces around name" do compiled = compile_asset_with_content(%({ background: url( file.jpg ); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "quotes around name" do compiled = compile_asset_with_content(%({ background: url("file.jpg"); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "single quotes around name" do compiled = compile_asset_with_content(%({ background: url('file.jpg'); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "root directory" do compiled = compile_asset_with_content(%({ background: url('/file.jpg'); })) - assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "same directory" do compiled = compile_asset_with_content(%({ background: url('./file.jpg'); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "subdirectory" do compiled = compile_asset_with_content(%({ background: url('./images/file.jpg'); })) - assert_match(/{ background: url\("\/assets\/foobar\/source\/images\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/source\/images\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "parent directory" do compiled = compile_asset_with_content(%({ background: url('../file.jpg'); })) - assert_match(/{ background: url\("\/assets\/foobar\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "grandparent directory" do compiled = compile_asset_with_content(%({ background: url('../../file.jpg'); })) - assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "sibling directory" do compiled = compile_asset_with_content(%({ background: url('../sibling/file.jpg'); })) - assert_match(/{ background: url\("\/assets\/foobar\/sibling\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/foobar\/sibling\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end test "mixed" do compiled = compile_asset_with_content(%({ mask-image: image(url(file.jpg), skyblue, linear-gradient(rgba(0, 0, 0, 1.0), transparent)); })) - assert_match(/{ mask-image: image\(url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\), skyblue, linear-gradient\(rgba\(0, 0, 0, 1.0\), transparent\)\); }/, compiled) + assert_match(/{ mask-image: image\(url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\), skyblue, linear-gradient\(rgba\(0, 0, 0, 1.0\), transparent\)\); }/, compiled) end test "multiple" do compiled = compile_asset_with_content(%({ content: url(file.svg) url(file.svg); })) - assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.svg"\) url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.svg"\); }/, compiled) + assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.svg"\) url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.svg"\); }/, compiled) end test "url" do @@ -95,12 +95,12 @@ class Propshaft::Compiler::CssAssetUrlsTest < ActiveSupport::TestCase test "fingerprint" do compiled = compile_asset_with_content(%({ background: url('/file.jpg?30af91bf14e37666a085fb8a161ff36d'); })) - assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{40}.jpg\?30af91bf14e37666a085fb8a161ff36d"\); }/, compiled) + assert_match(/{ background: url\("\/assets\/file-[a-z0-9]{8}.jpg\?30af91bf14e37666a085fb8a161ff36d"\); }/, compiled) end test "svg anchor" do compiled = compile_asset_with_content(%({ content: url(file.svg#rails); })) - assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.svg#rails"\); }/, compiled) + assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.svg#rails"\); }/, compiled) end test "svg mask encoded anchor" do @@ -110,7 +110,7 @@ class Propshaft::Compiler::CssAssetUrlsTest < ActiveSupport::TestCase test "non greedy anchors" do compiled = compile_asset_with_content(%({ content: url(file.svg#demo) url(file.svg#demo); })) - assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.svg#demo"\) url\("\/assets\/foobar\/source\/file-[a-z0-9]{40}.svg#demo"\); }/, compiled) + assert_match(/{ content: url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.svg#demo"\) url\("\/assets\/foobar\/source\/file-[a-z0-9]{8}.svg#demo"\); }/, compiled) end test "missing asset" do @@ -122,7 +122,7 @@ class Propshaft::Compiler::CssAssetUrlsTest < ActiveSupport::TestCase @options.relative_url_root = "/url-root" compiled = compile_asset_with_content(%({ background: url(file.jpg); })) - assert_match(/{ background: url\("\/url-root\/assets\/foobar\/source\/file-[a-z0-9]{40}.jpg"\); }/, compiled) + assert_match(/{ background: url\("\/url-root\/assets\/foobar\/source\/file-[a-z0-9]{8}.jpg"\); }/, compiled) end private diff --git a/test/propshaft/compiler/source_mapping_urls_test.rb b/test/propshaft/compiler/source_mapping_urls_test.rb index d5a4f0d..b10d36b 100644 --- a/test/propshaft/compiler/source_mapping_urls_test.rb +++ b/test/propshaft/compiler/source_mapping_urls_test.rb @@ -14,14 +14,14 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "matching source map" do - assert_match %r{//# sourceMappingURL=/assets/source-[a-z0-9]{40}\.js.map}, + assert_match %r{//# sourceMappingURL=/assets/source-[a-z0-9]{8}\.js.map}, compile_asset(find_asset("source.js", fixture_path: "mapped")) - assert_match %r{/\*# sourceMappingURL=/assets/source-[a-z0-9]{40}\.css.map}, + assert_match %r{/\*# sourceMappingURL=/assets/source-[a-z0-9]{8}\.css.map}, compile_asset(find_asset("source.css", fixture_path: "mapped")) end test "matching nested source map" do - assert_match %r{//# sourceMappingURL=/assets/nested/another-source-[a-z0-9]{40}\.js.map}, + assert_match %r{//# sourceMappingURL=/assets/nested/another-source-[a-z0-9]{8}\.js.map}, compile_asset(find_asset("nested/another-source.js", fixture_path: "mapped")) end @@ -38,9 +38,9 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "sourceMappingURL not at the beginning of the line, but at end of file, is processed" do - assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.js.map}, + assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{8}\.js.map}, compile_asset(find_asset("sourceMappingURL-not-at-start.js", fixture_path: "mapped")) - assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.css.map \*/}, + assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{8}\.css.map \*/}, compile_asset(find_asset("sourceMappingURL-not-at-start.css", fixture_path: "mapped")) end @@ -56,7 +56,7 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase test "relative url root" do @options.relative_url_root = "/url-root" - assert_match %r{//# sourceMappingURL=/url-root/assets/source-[a-z0-9]{40}\.js.map}, + assert_match %r{//# sourceMappingURL=/url-root/assets/source-[a-z0-9]{8}\.js.map}, compile_asset(find_asset("source.js", fixture_path: "mapped")) end diff --git a/test/propshaft/compilers_test.rb b/test/propshaft/compilers_test.rb index 83a4fb2..c604c70 100644 --- a/test/propshaft/compilers_test.rb +++ b/test/propshaft/compilers_test.rb @@ -14,7 +14,7 @@ class Propshaft::CompilersTest < ActiveSupport::TestCase test "replace asset-path function in css with digested url" do @assembly.compilers.register "text/css", Propshaft::Compiler::CssAssetUrls - assert_match(/"\/assets\/archive-[a-z0-9]{40}.svg/, @assembly.compilers.compile(find_asset("another.css"))) + assert_match(/"\/assets\/archive-[a-z0-9]{8}.svg/, @assembly.compilers.compile(find_asset("another.css"))) end private diff --git a/test/propshaft/load_path_test.rb b/test/propshaft/load_path_test.rb index 8ab8cf4..88bb003 100644 --- a/test/propshaft/load_path_test.rb +++ b/test/propshaft/load_path_test.rb @@ -38,16 +38,16 @@ class Propshaft::LoadPathTest < ActiveSupport::TestCase test "manifest" do @load_path.manifest.tap do |manifest| - assert_equal "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", manifest["one.txt"] - assert_equal "nested/three-6c2b86a0206381310375abdd9980863c2ea7b2c3.txt", manifest["nested/three.txt"] + assert_equal "one-f2e1ec14.txt", manifest["one.txt"] + assert_equal "nested/three-6c2b86a0.txt", manifest["nested/three.txt"] end end test "manifest with version" do @load_path = Propshaft::LoadPath.new(@load_path.paths, version: "1") @load_path.manifest.tap do |manifest| - assert_equal "one-c9373b685d5a63e4a1de7c6836a73239df552e2b.txt", manifest["one.txt"] - assert_equal "nested/three-a41a5d38da5afe428eca74b243f50405f28a6b54.txt", manifest["nested/three.txt"] + assert_equal "one-c9373b68.txt", manifest["one.txt"] + assert_equal "nested/three-a41a5d38.txt", manifest["nested/three.txt"] end end diff --git a/test/propshaft/output_path_test.rb b/test/propshaft/output_path_test.rb index d4af55b..b651ad3 100644 --- a/test/propshaft/output_path_test.rb +++ b/test/propshaft/output_path_test.rb @@ -8,7 +8,7 @@ class Propshaft::OutputPathTest < ActiveSupport::TestCase setup do @manifest = { ".manifest.json": ".manifest.json", - "one.txt": "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt" + "one.txt": "one-f2e1ec14.txt" }.stringify_keys @output_path = Propshaft::OutputPath.new(Pathname.new("#{__dir__}/../fixtures/output"), @manifest) end @@ -16,9 +16,9 @@ class Propshaft::OutputPathTest < ActiveSupport::TestCase test "files" do files = @output_path.files - file = files["one-f2e1ec14d6856e1958083094170ca6119c529a73.txt"] + file = files["one-f2e1ec14.txt"] assert_equal "one.txt", file[:logical_path] - assert_equal "f2e1ec14d6856e1958083094170ca6119c529a73", file[:digest] + assert_equal "f2e1ec14", file[:digest] assert file[:mtime].is_a?(Time) end diff --git a/test/propshaft/processor_test.rb b/test/propshaft/processor_test.rb index fb9a7aa..d1c5985 100644 --- a/test/propshaft/processor_test.rb +++ b/test/propshaft/processor_test.rb @@ -16,17 +16,17 @@ class Propshaft::ProcessorTest < ActiveSupport::TestCase test "manifest is written" do processed do |processor| - assert_equal "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", + assert_equal "one-f2e1ec14.txt", JSON.parse(processor.output_path.join(".manifest.json").read)["one.txt"] end end test "assets are copied" do processed do |processor| - digested_asset_name = "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt" + digested_asset_name = "one-f2e1ec14.txt" assert processor.output_path.join(digested_asset_name).exist? - nested_digested_asset_name = "nested/three-6c2b86a0206381310375abdd9980863c2ea7b2c3.txt" + nested_digested_asset_name = "nested/three-6c2b86a0.txt" assert processor.output_path.join(nested_digested_asset_name).exist? end end diff --git a/test/propshaft/resolver/dynamic_test.rb b/test/propshaft/resolver/dynamic_test.rb index 467d0e4..7cb60f1 100644 --- a/test/propshaft/resolver/dynamic_test.rb +++ b/test/propshaft/resolver/dynamic_test.rb @@ -8,7 +8,7 @@ class Propshaft::Resolver::DynamicTest < ActiveSupport::TestCase end test "resolving present asset returns uri path" do - assert_equal "/assets/one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", + assert_equal "/assets/one-f2e1ec14.txt", @resolver.resolve("one.txt") end diff --git a/test/propshaft/resolver/static_test.rb b/test/propshaft/resolver/static_test.rb index 778a47e..34e4a06 100644 --- a/test/propshaft/resolver/static_test.rb +++ b/test/propshaft/resolver/static_test.rb @@ -12,7 +12,7 @@ class Propshaft::Resolver::StaticTest < ActiveSupport::TestCase test "resolving present asset returns uri path" do assert_equal \ - "/assets/one-f2e1ec14d6856e1958083094170ca6119c529a73.txt", + "/assets/one-f2e1ec14.txt", @resolver.resolve("one.txt") end diff --git a/test/propshaft/server_test.rb b/test/propshaft/server_test.rb index e213974..82b87c3 100644 --- a/test/propshaft/server_test.rb +++ b/test/propshaft/server_test.rb @@ -20,12 +20,12 @@ class Propshaft::ServerTest < ActiveSupport::TestCase get "/#{asset.digested_path}" assert_equal 200, last_response.status - assert_equal "94", last_response.headers['content-length'] + assert_equal "62", last_response.headers['content-length'] assert_equal "text/css", last_response.headers['content-type'] assert_equal "Accept-Encoding", last_response.headers['vary'] assert_equal asset.digest, last_response.headers['etag'] assert_equal "public, max-age=31536000, immutable", last_response.headers['cache-control'] - assert_equal ".hero { background: url(\"/foobar/source/file-3e6a129785ee3caf8eff23db339997e85334bfa9.jpg\") }\n", + assert_equal ".hero { background: url(\"/foobar/source/file-3e6a1297.jpg\") }\n", last_response.body end diff --git a/test/propshaft_integration_test.rb b/test/propshaft_integration_test.rb index 6ad87a1..80205f6 100644 --- a/test/propshaft_integration_test.rb +++ b/test/propshaft_integration_test.rb @@ -6,10 +6,10 @@ class PropshaftIntegrationTest < ActionDispatch::IntegrationTest assert_response :success - assert_select 'link[href="/assets/hello_world-4137140a1298c3924d5f7135617c23e23fb167a8.css"]' - assert_select 'link[href="/assets/goodbye-b1dc9940e9800d8bc96f7434617c043e58277419.css"]' + assert_select 'link[href="/assets/hello_world-4137140a.css"]' + assert_select 'link[href="/assets/goodbye-b1dc9940.css"]' - assert_select 'script[src="/assets/hello_world-888761f849ba63a95a56f6ef898a9eb70ca4c46e.js"]' + assert_select 'script[src="/assets/hello_world-888761f8.js"]' end test "should raise an exception when resolving nonexistent assets" do From c59829099f9919e8ed7a1342a2e3004815d7a0b8 Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Wed, 10 Jan 2024 13:06:06 +0000 Subject: [PATCH 08/14] Preserve options with `stylesheet_link_tag` `:all` (#177) Ensure that we don't lose any options passed to `stylesheet_link_tag` when using the `:all` option. Previously the options were being discarded. --- lib/propshaft/helper.rb | 4 ++-- test/dummy/app/views/layouts/application.html.erb | 2 +- test/propshaft_integration_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/propshaft/helper.rb b/lib/propshaft/helper.rb index 75b54ca..f951b10 100644 --- a/lib/propshaft/helper.rb +++ b/lib/propshaft/helper.rb @@ -5,9 +5,9 @@ def compute_asset_path(path, options = {}) end # Add an option to call `stylesheet_link_tag` with `:all` to include every css file found on the load path. - def stylesheet_link_tag(*sources) + def stylesheet_link_tag(*sources, **options) if sources.first == :all - super *all_stylesheets_paths + super *all_stylesheets_paths, **options else super end diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index afec532..c412d08 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -5,7 +5,7 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> - <%= stylesheet_link_tag :all %> + <%= stylesheet_link_tag :all, data: { custom_attribute: true } %> diff --git a/test/propshaft_integration_test.rb b/test/propshaft_integration_test.rb index 80205f6..554303d 100644 --- a/test/propshaft_integration_test.rb +++ b/test/propshaft_integration_test.rb @@ -6,8 +6,8 @@ class PropshaftIntegrationTest < ActionDispatch::IntegrationTest assert_response :success - assert_select 'link[href="/assets/hello_world-4137140a.css"]' - assert_select 'link[href="/assets/goodbye-b1dc9940.css"]' + assert_select 'link[href="/assets/hello_world-4137140a.css"][data-custom-attribute="true"]' + assert_select 'link[href="/assets/goodbye-b1dc9940.css"][data-custom-attribute="true"]' assert_select 'script[src="/assets/hello_world-888761f8.js"]' end From c9b32dc55dfcc111b28a1ac36d61baa99f3eb6c3 Mon Sep 17 00:00:00 2001 From: Tim Guibord Date: Mon, 22 Jan 2024 15:13:06 -0500 Subject: [PATCH 09/14] Handle sourceMappingURL already prefixed with asset path (#170) --- lib/propshaft/compiler/source_mapping_urls.rb | 2 ++ .../sourceMappingURL-already-prefixed-nested.js | 1 + .../sourceMappingURL-already-prefixed-nested.js.map | 0 .../sourceMappingURL-already-prefixed-invalid.js | 1 + .../sourceMappingURL-already-prefixed-invalid.js.map | 0 .../mapped/sourceMappingURL-already-prefixed.js | 1 + .../mapped/sourceMappingURL-already-prefixed.js.map | 0 test/propshaft/compiler/source_mapping_urls_test.rb | 12 ++++++++++++ 8 files changed, 17 insertions(+) create mode 100644 test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js create mode 100644 test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js.map create mode 100644 test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js create mode 100644 test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js.map create mode 100644 test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js create mode 100644 test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js.map diff --git a/lib/propshaft/compiler/source_mapping_urls.rb b/lib/propshaft/compiler/source_mapping_urls.rb index a0b678d..bad3f0e 100644 --- a/lib/propshaft/compiler/source_mapping_urls.rb +++ b/lib/propshaft/compiler/source_mapping_urls.rb @@ -11,6 +11,8 @@ def compile(logical_path, input) private def asset_path(source_mapping_url, logical_path) + source_mapping_url.gsub!(/^(.+\/)?#{url_prefix}\//, "") + if logical_path.dirname.to_s == "." source_mapping_url else diff --git a/test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js b/test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js new file mode 100644 index 0000000..bd54fcb --- /dev/null +++ b/test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js @@ -0,0 +1 @@ +var fun; //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed-nested.js.map diff --git a/test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js.map b/test/fixtures/assets/mapped/nested/sourceMappingURL-already-prefixed-nested.js.map new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js new file mode 100644 index 0000000..a52b8dd --- /dev/null +++ b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js @@ -0,0 +1 @@ +var fun; //# sourceMappingURL=thisisinvalidassets/sourceMappingURL-already-prefixed-invalid.js.map diff --git a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js.map b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed-invalid.js.map new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js new file mode 100644 index 0000000..5bdf328 --- /dev/null +++ b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js @@ -0,0 +1 @@ +var fun; //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js.map diff --git a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js.map b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js.map new file mode 100644 index 0000000..e69de29 diff --git a/test/propshaft/compiler/source_mapping_urls_test.rb b/test/propshaft/compiler/source_mapping_urls_test.rb index b10d36b..194390a 100644 --- a/test/propshaft/compiler/source_mapping_urls_test.rb +++ b/test/propshaft/compiler/source_mapping_urls_test.rb @@ -53,6 +53,18 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase compile_asset(find_asset("sourceMappingURL-outside-comment.css", fixture_path: "mapped")) end + test "sourceMapURL is already prefixed with url_prefix" do + assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-[a-z0-9]{40}\.map}, + compile_asset(find_asset("sourceMappingURL-already-prefixed.js", fixture_path: "mapped")) + assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested.js-[a-z0-9]{40}\.map}, + compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested.js", fixture_path: "mapped")) + end + + test "sourceMapURL is already prefixed with an incorrect url_prefix" do + refute_match %r{//# sourceMappingURL=thisisinvalidassets/sourceMappingURL-already-prefixed-invalid.js-[a-z0-9]{40}\.map}, + compile_asset(find_asset("sourceMappingURL-already-prefixed-invalid.js", fixture_path: "mapped")) + end + test "relative url root" do @options.relative_url_root = "/url-root" From c7a43552813fd242aeefc6ed1de33ed671e3a324 Mon Sep 17 00:00:00 2001 From: Breno Gazzola Date: Mon, 22 Jan 2024 22:13:34 -0300 Subject: [PATCH 10/14] Fix broken tests after digest shortening (#179) --- .../assets/mapped/sourceMappingURL-already-prefixed.js | 2 +- test/propshaft/compiler/source_mapping_urls_test.rb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js index 5bdf328..4778ca4 100644 --- a/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js +++ b/test/fixtures/assets/mapped/sourceMappingURL-already-prefixed.js @@ -1 +1 @@ -var fun; //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js.map +var fun; //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js.map \ No newline at end of file diff --git a/test/propshaft/compiler/source_mapping_urls_test.rb b/test/propshaft/compiler/source_mapping_urls_test.rb index 194390a..1f7d5cb 100644 --- a/test/propshaft/compiler/source_mapping_urls_test.rb +++ b/test/propshaft/compiler/source_mapping_urls_test.rb @@ -54,14 +54,14 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "sourceMapURL is already prefixed with url_prefix" do - assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-[a-z0-9]{8}\.map}, compile_asset(find_asset("sourceMappingURL-already-prefixed.js", fixture_path: "mapped")) - assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested.js-[a-z0-9]{40}\.map}, + assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested.js-[a-z0-9]{8}\.map}, compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested.js", fixture_path: "mapped")) end test "sourceMapURL is already prefixed with an incorrect url_prefix" do - refute_match %r{//# sourceMappingURL=thisisinvalidassets/sourceMappingURL-already-prefixed-invalid.js-[a-z0-9]{40}\.map}, + refute_match %r{//# sourceMappingURL=thisisinvalidassets/sourceMappingURL-already-prefixed-invalid.js-[a-z0-9]{8}\.map}, compile_asset(find_asset("sourceMappingURL-already-prefixed-invalid.js", fixture_path: "mapped")) end @@ -82,3 +82,6 @@ def compile_asset(asset) assembly.compilers.compile(asset) end end + +# //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-[a-z0-9]{40}.map +# //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-da39a3ee.map From 0e082721a536841353f051971f003512d749b2cf Mon Sep 17 00:00:00 2001 From: Masato Nakamura Date: Thu, 22 Feb 2024 01:31:46 +0900 Subject: [PATCH 11/14] Add Ruby 3.3 to CI matrix (#174) * Add Ruby 3.3 to CI matrix * Remove 2.7 and 3.0 * Update Nokogiri --------- Co-authored-by: David Heinemeier Hansson Co-authored-by: Theodor Tonum --- .github/workflows/ci.yml | 3 +-- Gemfile.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d4abb7..1cc58ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,9 @@ jobs: strategy: matrix: ruby-version: - - "2.7" - - "3.0" - "3.1" - "3.2" + - "3.3" continue-on-error: [false] name: ${{ format('Tests (Ruby {0})', matrix.ruby-version) }} diff --git a/Gemfile.lock b/Gemfile.lock index e891d66..467a5c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,7 +99,7 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.8.1) + mini_portile2 (2.8.5) minitest (5.15.0) net-imap (0.2.3) digest @@ -117,16 +117,16 @@ GEM net-protocol timeout nio4r (2.5.8) - nokogiri (1.14.0) - mini_portile2 (~> 2.8.0) + nokogiri (1.16.2) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.14.0-arm64-darwin) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.14.0-x86_64-darwin) + nokogiri (1.16.2-x86_64-darwin) racc (~> 1.4) - nokogiri (1.14.0-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) - racc (1.6.2) + racc (1.7.3) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) From e435cdc370f85448e53d02b536dca0fe357d0607 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 27 Mar 2024 12:13:32 +0100 Subject: [PATCH 12/14] Fix Ruby warnings --- lib/propshaft/helper.rb | 2 +- test/test_helper.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/propshaft/helper.rb b/lib/propshaft/helper.rb index f951b10..66e8d25 100644 --- a/lib/propshaft/helper.rb +++ b/lib/propshaft/helper.rb @@ -7,7 +7,7 @@ def compute_asset_path(path, options = {}) # Add an option to call `stylesheet_link_tag` with `:all` to include every css file found on the load path. def stylesheet_link_tag(*sources, **options) if sources.first == :all - super *all_stylesheets_paths, **options + super(*all_stylesheets_paths, **options) else super end diff --git a/test/test_helper.rb b/test/test_helper.rb index 784ddc0..6d265a8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,7 @@ # Configure Rails Environment ENV["RAILS_ENV"] = "test" +Warning[:deprecated] = true +$VERBOSE = true require_relative "../test/dummy/config/environment" require "rails/test_help" From 9d73d661445b9b96217821c03831d253b289810d Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 27 Mar 2024 12:15:50 +0100 Subject: [PATCH 13/14] Update io-wait --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 467a5c1..c75fd13 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,7 +88,7 @@ GEM i18n (1.10.0) concurrent-ruby (~> 1.0) io-console (0.5.9) - io-wait (0.2.1) + io-wait (0.3.1) irb (1.3.7) reline (>= 0.2.7) loofah (2.14.0) @@ -182,4 +182,4 @@ DEPENDENCIES rake BUNDLED WITH - 2.4.1 + 2.5.3 From b00039b6d4aca0879f8c9ba95e2c8b51fa9cfce8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 15 May 2024 16:31:02 -0700 Subject: [PATCH 14/14] Fix tests --- test/propshaft/asset_test.rb | 2 +- test/propshaft/compiler/source_mapping_urls_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/propshaft/asset_test.rb b/test/propshaft/asset_test.rb index 83861e8..5c0749c 100644 --- a/test/propshaft/asset_test.rb +++ b/test/propshaft/asset_test.rb @@ -41,7 +41,7 @@ class Propshaft::AssetTest < ActiveSupport::TestCase assert_equal "file-not.digested-e206c34f.css", find_asset("file-not.digested.css").digested_path.to_s - assert_equal "file-is-a-sourcemap-da39a3ee5e6b4b0d3255bfef95601890afd80709.js.map", + assert_equal "file-is-a-sourcemap-da39a3ee.js.map", find_asset("file-is-a-sourcemap.js.map").digested_path.to_s end diff --git a/test/propshaft/compiler/source_mapping_urls_test.rb b/test/propshaft/compiler/source_mapping_urls_test.rb index 1f7d5cb..ca06d20 100644 --- a/test/propshaft/compiler/source_mapping_urls_test.rb +++ b/test/propshaft/compiler/source_mapping_urls_test.rb @@ -54,9 +54,9 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase end test "sourceMapURL is already prefixed with url_prefix" do - assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-already-prefixed.js-[a-z0-9]{8}\.map}, + assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-already-prefixed-[a-z0-9]{8}\.js\.map}, compile_asset(find_asset("sourceMappingURL-already-prefixed.js", fixture_path: "mapped")) - assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested.js-[a-z0-9]{8}\.map}, + assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-[a-z0-9]{8}\.js\.map}, compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested.js", fixture_path: "mapped")) end