DEV: clear asset cache when plugins add/remove client.*.yml files (#29468)

Our sprockets-based locale pipeline correctly `depends_on` client.*.yml files which already exist. But sprockets does not provide a way to watch for the creation of new files matching a certain path. This commit works around that limitation by adding the set of client.*.yml files to our global cache-clearing logic
This commit is contained in:
David Taylor 2024-10-29 15:17:59 +00:00 committed by GitHub
parent 2f334964f2
commit 1706e87e9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,7 +23,10 @@ def ensure_cache_clean!
_all_plugin_directories = Pathname.new(RAILS_ROOT + '/plugins').children.select(&:directory?)
core_git_sha = `git rev-parse HEAD`.strip
plugins_combined_git_sha = `git ls-files -s plugins | git hash-object --stdin`.strip
super_sha = Digest::SHA1.hexdigest(core_git_sha + plugins_combined_git_sha)
client_locale_paths_digest =
Digest::SHA1.hexdigest(Dir.glob("#{RAILS_ROOT}/plugins/*/config/locales/client.*.yml").join)
super_sha =
Digest::SHA1.hexdigest(core_git_sha + plugins_combined_git_sha + client_locale_paths_digest)
hash_file = "#{RAILS_ROOT}/tmp/plugin-hash"
old_hash = File.exist?(hash_file) ? File.read(hash_file) : nil