Maintenance: Update to Sprockets v4

This commit is contained in:
Mantas Masalskis
2026-04-17 12:15:49 +03:00
parent c76dd68bef
commit c6e38d1888
21 changed files with 69 additions and 283 deletions

View File

@@ -576,3 +576,7 @@ Rails/Exit:
RSpec/Output:
Enabled: false
Style/StderrPuts:
Exclude:
- "lib/tasks/**/*"

4
.gitignore vendored
View File

@@ -128,3 +128,7 @@ schema.graphql
!/.devcontainer/with-mailserver/certs/.gitkeep
/.devcontainer/with-ldap/ldap/certs/*
!/.devcontainer/with-ldap/ldap/certs/.gitkeep
# Dart Sass compiled output (dartsass-rails)
/app/assets/builds/*
!/app/assets/builds/.keep

View File

@@ -79,11 +79,11 @@ group :assets do
# We cannot use sassc-rails, as it can lead to crashes on modern platforms like CentOS 9.
# See https://jcmaciel.com/apple-silicon-ruby-on-rails-crash-segfault-sassc/
# https://github.com/sass/sassc-ruby/issues/197
# Pin to v5 which does not use sassc internally.
gem 'sass-rails', '~> 5', require: false
# Use dartsass-rails which uses Dart Sass (no sassc dependency).
gem 'dartsass-rails', require: false
# asset handling - pipeline
gem 'sprockets', '~> 3.7.2', require: false
gem 'sprockets', '~> 4', require: false
gem 'terser', require: false
gem 'autoprefixer-rails', require: false

View File

@@ -204,6 +204,9 @@ GEM
daemons (1.4.1)
dalli (5.0.2)
logger
dartsass-rails (0.5.1)
railties (>= 6.0.0)
sass-embedded (~> 1.63)
date (3.5.1)
debug_inspector (1.2.0)
deprecation_toolkit (2.3.0)
@@ -291,6 +294,9 @@ GEM
ostruct
globalid (1.3.0)
activesupport (>= 6.1)
google-protobuf (4.34.1)
bigdecimal
rake (~> 13.3)
graphql (2.5.23)
base64
fiber-storage
@@ -706,17 +712,9 @@ GEM
rubyzip (3.2.2)
safety_net_attestation (0.5.0)
jwt (>= 2.0, < 4.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.1.0)
railties (>= 5.2.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sass-embedded (1.99.0)
google-protobuf (~> 4.31)
rake (>= 13)
securerandom (0.4.1)
selenium-webdriver (4.43.0)
base64 (~> 0.2)
@@ -739,10 +737,10 @@ GEM
snaky_hash (2.0.3)
hashie (>= 0.1.0, < 6)
version_gem (>= 1.1.8, < 3)
sprockets (3.7.5)
base64
sprockets (4.2.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
logger
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
@@ -768,7 +766,6 @@ GEM
test-unit (3.7.7)
power_assert
thor (1.5.0)
tilt (2.7.0)
timeout (0.6.1)
tpm-key_attestation (0.14.1)
bindata (~> 2.4)
@@ -882,6 +879,7 @@ DEPENDENCIES
csv
daemons
dalli
dartsass-rails
delayed_job!
delayed_job_active_record!
deprecation_toolkit
@@ -963,12 +961,11 @@ DEPENDENCIES
rubocop-rspec
rubocop-rspec_rails
ruby-keycloak-admin
sass-rails (~> 5)
selenium-webdriver
shoulda-matchers
simpleidn
slack-ruby-client
sprockets (~> 3.7.2)
sprockets (~> 4)
sprockets-rails
tcr
telegram-bot-ruby

0
app/assets/builds/.keep Normal file
View File

View File

@@ -0,0 +1,11 @@
// Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
//= link_directory ../javascripts .js
//= link_directory ../builds .css
//= link application.js
//= link application.css
//= link application-print.css
//= link print.css
//= link knowledge_base.css
//= link knowledge_base_public.js
//= link knowledge_base_public_polyfills.js
//= link ie11CustomProperties.min.js

View File

@@ -3,7 +3,7 @@
#= require_self
#= require_tree ./lib/app_init
#= require_tree ./lib/mixins
#= require ./config.coffee
#= require ./config
#= require_tree ./models
#= require_tree ./controllers/_application_controller
#= require_tree ./controllers

View File

@@ -13,10 +13,10 @@
//= require ./app/lib/animations/velocity.ui.js
//not_used= require_tree ./app/lib/spine
//= require ./app/lib/spine/spine.coffee
//= require ./app/lib/spine/ajax.coffee
//= require ./app/lib/spine/local.coffee
//= require ./app/lib/spine/route.coffee
//= require ./app/lib/spine/spine
//= require ./app/lib/spine/ajax
//= require ./app/lib/spine/local
//= require ./app/lib/spine/route
//= require ./app/lib/flot/jquery.flot.js
//= require ./app/lib/flot/jquery.flot.selection.js
@@ -44,7 +44,7 @@
//= require_tree ./app/lib/base
//= require ./app/index.coffee
//= require ./app/index
// IE8 workaround for missing console.log
if (!window.console) {

View File

@@ -1,4 +1,4 @@
/*
*= require_self
*= require ./print.scss
*= require print
*/

View File

@@ -12,7 +12,7 @@
*= require ./svg-dimensions.css
*= require ./highlighter-github.css
*= require ./jquery.enableObjectResizingShim.css
*= require ./zammad.scss
*= require zammad
*
*= require_tree ./addons/
*= require_tree ./custom/

View File

@@ -1,3 +1,6 @@
@use 'sass:list';
@use 'sass:string';
$high-priority-color: hsl(360, 71%, 60%);
$low-priority-color: hsl(200, 68%, 73%);
$minWidth: 1024px;
@@ -14399,7 +14402,7 @@ output {
$rainbow: ();
@while $i <= 360 {
$rainbow: append($rainbow, unquote('hsl(#{$i},100%,50%)'), comma);
$rainbow: list.append($rainbow, string.unquote('hsl(#{$i},100%,50%)'), comma);
$i: $i + 60;
}

View File

@@ -5,16 +5,17 @@
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
# Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Configure Dart Sass (dartsass-rails) entry points.
# Maps source .scss files to their compiled .css output in app/assets/builds/.
# Add dartsass output directory to Sprockets load path so compiled CSS is found.
Rails.application.config.assets.paths << Rails.root.join('app/assets/builds')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w[application-print.css]
Rails.application.config.assets.precompile += %w[print.css]
Rails.application.config.assets.precompile += %w[knowledge_base.css knowledge_base_public.js knowledge_base_public_polyfills.js]
Rails.application.config.assets.precompile += %w[ie11CustomProperties.min.js]
# Setup DartSASS only if the gem is loaded.
# Otherwise config.dartsass does not exist
if defined?(Dartsass)
Rails.application.config.dartsass.builds = {
'zammad.scss' => 'zammad.css',
'print.scss' => 'print.css',
'knowledge_base.scss' => 'knowledge_base.css',
}
end

View File

@@ -1,45 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Layout/HeredocIndentation
# rubocop:disable Style/StringLiterals
# rubocop:disable Style/HashSyntax
# rubocop:disable Metrics/AbcSize
module Sass::Script::Tree
class Interpolation < Node
def _perform(environment)
res = +""
res << @before.perform(environment).to_s if @before
res << " " if @before && @whitespace_before
val = @mid.perform(environment)
if @warn_for_color && val.is_a?(Sass::Script::Value::Color) && val.name
alternative = Operation.new(Sass::Script::Value::String.new("", :string), @mid, :plus)
Sass::Util.sass_warn <<MESSAGE
WARNING on line #{line}, column #{source_range.start_pos.offset}#{" of #{filename}" if filename}:
You probably don't mean to use the color value `#{val}' in interpolation here.
It may end up represented as #{val.inspect}, which will likely produce invalid CSS.
Always quote color names when using them as strings (for example, "#{val}").
If you really want to use the color value here, use `#{alternative.to_sass}'.
MESSAGE
end
res << val.to_s(:quote => :none)
res << " " if @after && @whitespace_after
res << @after.perform(environment).to_s if @after
str = Sass::Script::Value::String.new(
res, :identifier,
(to_quoted_equivalent.to_sass if deprecation == :potential)
)
str.source_range = source_range
opts(str)
end
end
end

View File

@@ -1,46 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Layout/EmptyLineAfterGuardClause
# rubocop:disable Style/RegexpLiteral
# rubocop:disable Style/NumericPredicate
# rubocop:disable Style/CharacterLiteral
# rubocop:disable Style/StringLiterals
# rubocop:disable Zammad/PreferNegatedIfOverUnless
module Sass
module Script
class Lexer
def special_fun_body(parens, prefix = nil)
str = prefix || +''
while (scanned = scan(/.*?([()]|\#\{)/m))
str << scanned
if scanned[-1] == ?(
parens += 1
next
elsif scanned[-1] == ?)
parens -= 1
next unless parens == 0
else
raise "[BUG] Unreachable" unless @scanner[1] == '#{' # '
str.slice!(-2..-1)
@interpolation_stack << [:special_fun, parens]
start_pos = Sass::Source::Position.new(@line, @offset - 2)
@next_tok = Token.new(:string_interpolation, range(start_pos), @scanner.pos - 2)
end
return [:special_fun, Sass::Script::Value::String.new(str)]
end
scan(/.*/)
expected!('")"')
end
end
end
end

View File

@@ -1,42 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Zammad/PreferNegatedIfOverUnless
# rubocop:disable Layout/SpaceInsideBlockBraces
module Sass::Media
class Query
def to_css
css = +''
css << resolved_modifier
css << ' ' unless resolved_modifier.empty?
css << resolved_type
css << ' and ' unless resolved_type.empty? || expressions.empty?
css << expressions.map do |e|
# It's possible for there to be script nodes in Expressions even when
# we're converting to CSS in the case where we parsed the document as
# CSS originally (as in css_test.rb).
e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.to_sass : c.to_s}.join
end.join(' and ')
css
end
def to_src(options)
src = +''
src << Sass::Media._interp_to_src(modifier, options)
src << ' ' unless modifier.empty?
src << Sass::Media._interp_to_src(type, options)
src << ' and ' unless type.empty? || expressions.empty?
src << expressions.map do |e|
Sass::Media._interp_to_src(e, options)
end.join(' and ')
src
end
end
end

View File

@@ -1,26 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Style/StringLiterals
# rubocop:disable Lint/UnusedMethodArgument
module Sass
module Selector
class Attribute < Simple
def to_s(opts = {})
res = +"["
res << @namespace << "|" if @namespace
res << @name
res << @operator << @value if @value
res << " " << @flags if @flags
res << "]"
end
end
end
end

View File

@@ -1,37 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Layout/EmptyLineAfterGuardClause
# rubocop:disable Zammad/PreferNegatedIfOverUnless
# rubocop:disable Style/RegexpLiteral
# rubocop:disable Layout/SpaceInsideBlockBraces
# rubocop:disable Performance/CollectionLiteralInLoop
module Sass
module SCSS
class StaticParser < Parser
def selector_comma_sequence
sel = selector
return unless sel
selectors = [sel]
ws = +''
while tok(/,/)
ws << str {ss}
next unless (sel = selector)
selectors << sel
if ws.include?("\n")
selectors[-1] = Selector::Sequence.new(["\n"] + selectors.last.members)
end
ws = +''
end
Selector::CommaSequence.new(selectors)
end
end
end
end

View File

@@ -1,38 +0,0 @@
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
# Monkey patch for frozen literal string warning
require 'sass'
$VERBOSE = false
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Style/StringLiterals
# rubocop:disable Style/HashSyntax
module Sass::Script::Tree
class StringInterpolation < Node
def to_sass(opts = {})
quote = type == :string ? opts[:quote] || quote_for(self) || '"' : :none
opts = opts.merge(:quote => quote)
res = +""
res << quote if quote != :none
res << _to_sass(before, opts)
res << '#{' << @mid.to_sass(opts.merge(:quote => nil)) << '}'
res << _to_sass(after, opts)
res << quote if quote != :none
res
end
def _perform(environment)
res = +""
before = @before.perform(environment)
res << before.value
mid = @mid.perform(environment)
res << (mid.is_a?(Sass::Script::Value::String) ? mid.value : mid.to_s(:quote => :none))
res << @after.perform(environment).value
opts(Sass::Script::Value::String.new(res, before.type))
end
end
end

View File

@@ -37,9 +37,9 @@ module Tasks
def self.print_orphaned_errors(orphaned_gems, age)
return if orphaned_gems.none?
warn "\nThe following bundled gems were released more than #{age} year(s) ago:"
$stderr.puts "\nThe following bundled gems were released more than #{age} year(s) ago:"
orphaned_gems.each do |s|
warn " #{s.name}:#{s.version} #{s.date.strftime('%F')}"
$stderr.puts " #{s.name}:#{s.version} #{s.date.strftime('%F')}"
print_dependencies_of(s.name)
end
end
@@ -47,9 +47,9 @@ module Tasks
def self.print_unreleased_errors(unreleased_gems)
return if unreleased_gems.none?
warn "\nThe following bundled gems are installed from git sources and not from official releases:"
$stderr.puts "\nThe following bundled gems are installed from git sources and not from official releases:"
unreleased_gems.each do |s|
warn " #{s.name}:#{s.version} #{s.source}"
$stderr.puts " #{s.name}:#{s.version} #{s.source}"
print_dependencies_of(s.name)
end
end
@@ -67,7 +67,7 @@ module Tasks
return if !deps
deps.each do |dep|
warn " #{' ' * level} - #{dep}"
$stderr.puts " #{' ' * level} - #{dep}"
print_dependencies_of(dep, level + 1)
end
end

View File

@@ -19,7 +19,7 @@ module Tasks
begin
"Store::Provider::#{provider}".constantize
rescue NameError
warn "Store provider '#{provider}' not found."
$stderr.puts "Store provider '#{provider}' not found."
exit 1
end
end
@@ -41,7 +41,7 @@ module Tasks
puts 'Done.'
return if status
warn 'One or more files could not be moved. For further information, please check the logs.'
$stderr.puts 'One or more files could not be moved. For further information, please check the logs.'
exit 1
end
end

View File

@@ -18,7 +18,7 @@ module Tasks
puts 'Done.'
return if status
warn 'One or more files could not be verified. For further information, please check the logs.'
$stderr.puts 'One or more files could not be verified. For further information, please check the logs.'
exit 1
end
end