sass-embedded 1.77.5 → 1.100.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +18 -17
  3. data/README.md +1 -1
  4. data/exe/sass +2 -10
  5. data/ext/sass/Rakefile +162 -385
  6. data/ext/sass/file_utils.rb +75 -0
  7. data/ext/sass/package.json +1 -1
  8. data/ext/sass/platform.rb +44 -0
  9. data/ext/sass/sass-1.100.0.tgz +0 -0
  10. data/ext/sass/sass_config.rb +183 -0
  11. data/ext/sass/utils.rb +39 -0
  12. data/lib/sass/compiler/channel.rb +6 -4
  13. data/lib/sass/compiler/connection.rb +17 -21
  14. data/lib/sass/compiler/dispatcher.rb +27 -1
  15. data/lib/sass/compiler/host/function_registry.rb +6 -6
  16. data/lib/sass/compiler/host/importer_registry.rb +17 -11
  17. data/lib/sass/compiler/host/logger_registry.rb +17 -20
  18. data/lib/sass/compiler/host/protofier.rb +59 -73
  19. data/lib/sass/compiler/host/struct.rb +36 -0
  20. data/lib/sass/compiler/host.rb +2 -2
  21. data/lib/sass/compiler.rb +4 -3
  22. data/lib/sass/elf.rb +282 -172
  23. data/lib/sass/embedded/version.rb +1 -1
  24. data/lib/sass/embedded.rb +2 -41
  25. data/lib/sass/embedded_protocol.rb +1 -1
  26. data/{ext → lib}/sass/embedded_sass_pb.rb +3 -5
  27. data/lib/sass/exception.rb +7 -2
  28. data/lib/sass/fork_tracker.rb +36 -28
  29. data/lib/sass/gem_package_importer.rb +19 -0
  30. data/lib/sass/serializer.rb +5 -11
  31. data/lib/sass/value/argument_list.rb +0 -8
  32. data/lib/sass/value/color/channel.rb +79 -0
  33. data/lib/sass/value/color/conversions.rb +473 -0
  34. data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
  35. data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
  36. data/lib/sass/value/color/gamut_map_method.rb +45 -0
  37. data/lib/sass/value/color/interpolation_method.rb +51 -0
  38. data/lib/sass/value/color/space/a98_rgb.rb +57 -0
  39. data/lib/sass/value/color/space/display_p3.rb +72 -0
  40. data/lib/sass/value/color/space/display_p3_linear.rb +72 -0
  41. data/lib/sass/value/color/space/hsl.rb +65 -0
  42. data/lib/sass/value/color/space/hwb.rb +70 -0
  43. data/lib/sass/value/color/space/lab.rb +77 -0
  44. data/lib/sass/value/color/space/lch.rb +53 -0
  45. data/lib/sass/value/color/space/lms.rb +129 -0
  46. data/lib/sass/value/color/space/oklab.rb +66 -0
  47. data/lib/sass/value/color/space/oklch.rb +54 -0
  48. data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
  49. data/lib/sass/value/color/space/rec2020.rb +69 -0
  50. data/lib/sass/value/color/space/rgb.rb +52 -0
  51. data/lib/sass/value/color/space/srgb.rb +140 -0
  52. data/lib/sass/value/color/space/srgb_linear.rb +72 -0
  53. data/lib/sass/value/color/space/utils.rb +86 -0
  54. data/lib/sass/value/color/space/xyz_d50.rb +100 -0
  55. data/lib/sass/value/color/space/xyz_d65.rb +57 -0
  56. data/lib/sass/value/color/space.rb +201 -0
  57. data/lib/sass/value/color.rb +539 -162
  58. data/lib/sass/value/function.rb +9 -6
  59. data/lib/sass/value/fuzzy_math.rb +34 -30
  60. data/lib/sass/value/mixin.rb +5 -2
  61. data/lib/sass/value/null.rb +1 -1
  62. data/lib/sass/value/number/unit.rb +5 -4
  63. data/lib/sass/value/number.rb +15 -17
  64. data/lib/sass/value/string.rb +1 -1
  65. data/lib/sass/value.rb +1 -1
  66. metadata +42 -21
  67. data/ext/sass/expand-archive.ps1 +0 -1
  68. data/lib/sass/compiler/host/structifier.rb +0 -37
data/ext/sass/Rakefile CHANGED
@@ -2,429 +2,206 @@
2
2
 
3
3
  require 'rake/clean'
4
4
 
5
- task default: %i[install clean]
6
-
7
- task install: %w[cli.rb] do
8
- Rake::Task['embedded_sass_pb.rb'].invoke unless File.exist?('embedded_sass_pb.rb')
9
- end
10
-
11
- CLEAN.include %w[protoc.exe ruby *.proto *.tar.gz *.zip]
5
+ require_relative '../../lib/sass/elf'
6
+ require_relative 'sass_config'
7
+ require_relative 'file_utils'
8
+ require_relative 'utils'
12
9
 
13
- CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb]
10
+ ARCHDIR = File.absolute_path('sass', ENV.fetch('RUBYARCHDIR', File.absolute_path('../../lib', __dir__)))
11
+ LIBDIR = File.absolute_path('sass', ENV.fetch('RUBYLIBDIR', File.absolute_path('../../lib', __dir__)))
14
12
 
15
- file 'protoc.exe' do |t|
16
- fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name)
17
- chmod 'a+x', t.name
18
- end
19
-
20
- file 'dart-sass' do |t|
21
- raise if ENV.key?('DART_SASS')
13
+ task default: %i[install clean]
22
14
 
23
- gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir|
24
- mv File.absolute_path("ext/sass/#{t.name}", dir), t.name
15
+ task install: %w[cli.rb] do
16
+ unless File.exist?(File.absolute_path('../../lib/sass/embedded_sass_pb.rb', __dir__))
17
+ Rake::Task['embedded_sass_pb.rb'].invoke
25
18
  end
26
- rescue StandardError
27
- archive = fetch(ENV.fetch('DART_SASS') { SassConfig.default_dart_sass })
28
- unarchive archive
29
- rm archive
30
- end
31
-
32
- file 'cli.rb' => %w[dart-sass] do |t|
33
- exe = 'dart-sass/sass'
34
- exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}"
35
-
36
- raise "#{exe} not found" unless File.exist?(exe)
37
-
38
- runtime = 'dart-sass/src/dart'
39
- runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}"
40
- snapshot = 'dart-sass/src/sass.snapshot'
41
-
42
- command = if File.exist?(runtime) && File.exist?(snapshot)
43
- "
44
- File.absolute_path('#{runtime}', __dir__).freeze,
45
- File.absolute_path('#{snapshot}', __dir__).freeze
46
- "
47
- else
48
- "
49
- File.absolute_path('#{exe}', __dir__).freeze
50
- "
51
- end
52
-
53
- File.write(t.name, <<~CLI_RB)
54
- # frozen_string_literal: true
55
-
56
- module Sass
57
- module CLI
58
- COMMAND = [#{command}].freeze
59
- end
60
-
61
- private_constant :CLI
62
- end
63
- CLI_RB
64
- end
65
-
66
- file 'embedded_sass.proto' => %w[cli.rb] do |t|
67
- fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { SassConfig.default_embedded_sass_protocol }, t.name)
68
- end
69
-
70
- rule '_pb.rb' => %w[.proto protoc.exe] do |t|
71
- sh './protoc.exe', '--proto_path=.', '--ruby_out=.', t.source
72
19
  end
73
20
 
74
- # This is a FileUtils extension that defines several additional commands to be
75
- # added to the FileUtils utility functions.
76
- module FileUtils
77
- # PowerShell quirks:
78
- # - `powershell -Command -`:
79
- # Arguments must be part of command, thus cannot pass arguments safely without escaping.
80
- # - `powershell -Command <script-block> [-args <arg-array>]`:
81
- # This only works when invoking powershell subshell in powershell.
82
- # - `powershell -Command <string> [<CommandParameters>]`:
83
- # CommandParameters are joined with command and then parsed, thus cannot pass arguments safely without escaping.
84
- # - `powershell -File -`:
85
- # Arguments must be part of file, thus cannot pass arguments safely without escaping.
86
- # - `powershell -File <filePath> <args>`:
87
- # This is the only way to pass arguments safely without escaping.
88
- def powershell(file, *args)
89
- sh 'powershell', '-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', file, *args
90
- end
91
-
92
- def junzip(archive, dest = '.')
93
- require 'java'
94
-
95
- Rake.rake_output_message "Archive: #{archive}" if Rake::FileUtilsExt.verbose_flag
96
-
97
- current_directory = java.nio.file.Paths.get(org.jruby.Ruby.getGlobalRuntime.getCurrentDirectory)
98
- zip_file = java.util.zip.ZipFile.new(current_directory.resolve(archive).toFile)
99
- dest_path = current_directory.resolve(dest).normalize
100
- entries = zip_file.entries
101
- while entries.hasMoreElements
102
- entry = entries.nextElement
103
- name = entry.getName
104
- path = dest_path.resolve(name).normalize
105
- raise unless path.startsWith(dest_path)
106
-
107
- Rake.rake_output_message " inflating: #{name}" if Rake::FileUtilsExt.verbose_flag
108
-
109
- if entry.isDirectory
110
- java.nio.file.Files.createDirectories(path)
111
- else
112
- java.nio.file.Files.createDirectories(path.getParent)
113
- java.nio.file.Files.copy(zip_file.getInputStream(entry), path)
114
- end
21
+ CLEAN.include %w[
22
+ protoc.exe
23
+ ruby
24
+ *.proto
25
+ *.tar.gz
26
+ *.zip
27
+ ]
28
+
29
+ CLOBBER.include(%w[
30
+ dart-sass
31
+ cli.rb
32
+ node_modules
33
+ bun.lockb
34
+ package-lock.json
35
+ pnpm-lock.yaml
36
+ yarn.lock
37
+ ].map do |file|
38
+ File.absolute_path(file, ARCHDIR)
39
+ end)
40
+
41
+ CLOBBER.include(%w[
42
+ *_pb.rb
43
+ ].map do |file|
44
+ File.absolute_path(file, LIBDIR)
45
+ end)
46
+
47
+ file File.absolute_path('dart-sass/sass', ARCHDIR) do
48
+ mkdir_p ARCHDIR
49
+
50
+ begin
51
+ gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |installer|
52
+ gh_attestation_verify(installer.gem, repo: 'sass-contrib/sass-embedded-host-ruby')
53
+ mv File.absolute_path('lib/sass/dart-sass', installer.gem_dir), File.absolute_path('dart-sass', ARCHDIR)
115
54
  end
116
- ensure
117
- zip_file&.close
55
+ rescue StandardError
56
+ archive = fetch(SassConfig.dart_sass)
57
+ gh_attestation_verify(archive, repo: 'sass/dart-sass')
58
+ unarchive archive, chdir: ARCHDIR
59
+ rm archive
118
60
  end
61
+ end
119
62
 
120
- def unarchive(archive, dest = '.')
121
- case archive.downcase
122
- when ->(name) { name.include?('.tar.') || name.end_with?('.tar') }
123
- mkdir_p dest
124
- sh 'tar', '-vxC', dest, '-f', archive, '--no-same-owner', '--no-same-permissions'
125
- when ->(name) { name.end_with?('.zip') }
126
- if RUBY_PLATFORM == 'java'
127
- junzip archive, dest
128
- elsif Gem.win_platform?
129
- powershell 'expand-archive.ps1', '-Force', '-LiteralPath', archive, '-DestinationPath', dest
130
- else
131
- sh 'unzip', '-od', dest, archive
132
- end
133
- else
134
- raise ArgumentError, "Unknown archive format #{archive}"
135
- end
136
- end
63
+ file File.absolute_path('node_modules/sass', ARCHDIR) do
64
+ mkdir_p ARCHDIR
137
65
 
138
- def fetch(source_uri, dest_path = nil)
139
- require 'rubygems/remote_fetcher'
66
+ cp File.absolute_path('package.json', __dir__), ARCHDIR
140
67
 
141
- source_uri = "/#{source_uri}" if File.absolute_path?(source_uri) && !source_uri.start_with?('/')
68
+ # TODO: remove after https://github.com/sass/dart-sass/pull/2413
69
+ cp File.absolute_path("sass-#{SassConfig.dart_sass_version}.tgz", __dir__), ARCHDIR
142
70
 
143
- source_uri = begin
144
- Gem::Uri.parse!(source_uri)
145
- rescue NoMethodError
71
+ begin
72
+ sh 'npm', 'install', chdir: ARCHDIR
73
+ rescue StandardError
74
+ begin
75
+ sh 'yarn', 'install', chdir: ARCHDIR
76
+ rescue StandardError
146
77
  begin
147
- URI.parse(source_uri)
78
+ sh 'pnpm', 'install', chdir: ARCHDIR
148
79
  rescue StandardError
149
- URI.parse(URI::DEFAULT_PARSER.escape(source_uri.to_s))
80
+ sh 'bun', 'install', chdir: ARCHDIR
150
81
  end
151
82
  end
152
-
153
- scheme = source_uri.scheme
154
- source_path = begin
155
- Gem::URI::DEFAULT_PARSER
156
- rescue NameError
157
- URI::DEFAULT_PARSER
158
- end.unescape(source_uri.path)
159
-
160
- dest_path = File.basename(source_path) if dest_path.nil?
161
-
162
- fetcher = Gem::RemoteFetcher.fetcher
163
- symbol = :"fetch_#{scheme.nil? ? 'file' : scheme}"
164
- raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol)
165
-
166
- Rake.rake_output_message "fetch #{Gem::Uri.new(source_uri).redacted}" if Rake::FileUtilsExt.verbose_flag
167
-
168
- unless Rake::FileUtilsExt.nowrite_flag
169
- data = fetcher.public_send(symbol, source_uri)
170
- Gem.write_binary(dest_path, data)
171
- end
172
-
173
- dest_path
174
- end
175
-
176
- def gem_install(name, version, platform)
177
- require 'rubygems/remote_fetcher'
178
-
179
- install_dir = File.absolute_path('ruby')
180
-
181
- if Rake::FileUtilsExt.verbose_flag
182
- Rake.rake_output_message [
183
- 'gem', 'install',
184
- '--force',
185
- '--install-dir', install_dir,
186
- '--no-document', '--ignore-dependencies',
187
- '--platform', platform,
188
- '--version', version,
189
- 'sass-embedded'
190
- ].join(' ')
191
- end
192
-
193
- dependency = Gem::Dependency.new(name, version)
194
-
195
- dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
196
-
197
- resolver_spec = Gem::Resolver::BestSet.new.find_all(dependency_request).find do |s|
198
- s.platform == platform
199
- end
200
-
201
- raise if resolver_spec.nil?
202
-
203
- options = { force: true, install_dir: }
204
- if Rake::FileUtilsExt.nowrite_flag
205
- installer = Gem::Installer.for_spec(resolver_spec.spec, options)
206
- else
207
- path = resolver_spec.download(options)
208
- installer = Gem::Installer.at(path, options)
209
- installer.install
210
- end
211
-
212
- yield installer.dir
213
- ensure
214
- rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag
215
83
  end
216
84
  end
217
85
 
218
- # The {SassConfig} module.
219
- module SassConfig
220
- module Platform
221
- OS = case RbConfig::CONFIG['host_os'].downcase
222
- when /darwin/
223
- 'darwin'
224
- when /linux-android/
225
- 'linux-android'
226
- when /linux-musl/
227
- 'linux-musl'
228
- when /linux-uclibc/
229
- 'linux-uclibc'
230
- when /linux/
231
- 'linux'
232
- when *Gem::WIN_PATTERNS
233
- 'windows'
234
- else
235
- RbConfig::CONFIG['host_os'].downcase
236
- end
237
-
238
- CPU = case RbConfig::CONFIG['host_cpu'].downcase
239
- when /amd64|x86_64|x64/
240
- 'x86_64'
241
- when /i\d86|x86|i86pc/
242
- 'x86'
243
- when /arm64|aarch64/
244
- 'aarch64'
245
- when /arm/
246
- 'arm'
247
- when /ppc64le|powerpc64le/
248
- 'powerpc64le'
249
- else
250
- RbConfig::CONFIG['host_cpu']
251
- end
252
-
253
- ARCH = "#{CPU}-#{OS}".freeze
86
+ task 'dart-sass' => (
87
+ begin
88
+ SassConfig.dart_sass
89
+ File.absolute_path('dart-sass/sass', ARCHDIR)
90
+ rescue NotImplementedError
91
+ File.absolute_path('node_modules/sass', ARCHDIR)
254
92
  end
93
+ )
94
+
95
+ file File.absolute_path('cli.rb', ARCHDIR) => %w[dart-sass] do |task|
96
+ begin
97
+ exe = 'dart-sass/sass'
98
+ exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?(File.absolute_path("#{exe}#{ext}", ARCHDIR)) }}"
99
+
100
+ raise Errno::ENOENT, exe unless File.exist?(File.absolute_path(exe, ARCHDIR))
101
+
102
+ runtime = 'dart-sass/src/dart'
103
+ runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?(File.absolute_path("#{runtime}#{ext}", ARCHDIR)) }}"
104
+ snapshot = 'dart-sass/src/sass.snapshot'
105
+
106
+ command = if File.exist?(File.absolute_path(runtime, ARCHDIR)) &&
107
+ File.exist?(File.absolute_path(snapshot, ARCHDIR))
108
+ [runtime, snapshot]
109
+ else
110
+ [exe]
111
+ end
112
+
113
+ interpreter = File.open(File.absolute_path(command[0], ARCHDIR), 'rb') do |file|
114
+ Sass.const_get(:ELF).new(file).interpreter
115
+ rescue ArgumentError
116
+ nil
117
+ end
255
118
 
256
- private_constant :Platform
257
-
258
- module_function
259
-
260
- def dart_sass_version
261
- require 'json'
119
+ command_source = command.map do |argument|
120
+ "File.absolute_path('#{argument}', __dir__).freeze"
121
+ end.join(',
122
+ ')
123
+ rescue Errno::ENOENT
124
+ package = 'node_modules/sass'
262
125
 
263
- spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__)))
126
+ script = File.join(package, SassConfig.package_json(File.absolute_path(package, ARCHDIR))['bin']['sass'])
264
127
 
265
- spec['dependencies']['sass']
266
- end
128
+ interpreter = nil
267
129
 
268
- def default_dart_sass
269
- repo = 'https://github.com/sass/dart-sass'
270
-
271
- tag_name = dart_sass_version
272
-
273
- message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
274
-
275
- env = ''
276
-
277
- os = case Platform::OS
278
- when 'darwin'
279
- 'macos'
280
- when 'linux'
281
- 'linux'
282
- when 'linux-android'
283
- 'android'
284
- when 'linux-musl'
285
- env = '-musl'
286
- 'linux'
287
- when 'windows'
288
- 'windows'
289
- else
290
- raise NotImplementedError, message
291
- end
292
-
293
- cpu = case Platform::CPU
294
- when 'x86'
295
- 'ia32'
296
- when 'x86_64'
297
- 'x64'
298
- when 'aarch64'
299
- 'arm64'
300
- when 'arm'
301
- 'arm'
302
- when 'riscv64'
303
- 'riscv64'
304
- else
305
- raise NotImplementedError, message
306
- end
307
-
308
- ext = Platform::OS == 'windows' ? 'zip' : 'tar.gz'
309
-
310
- "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}#{env}.#{ext}"
130
+ command_source = [
131
+ "'node'",
132
+ "File.absolute_path('#{script}', __dir__).freeze"
133
+ ].join(',
134
+ ')
311
135
  end
312
136
 
313
- def default_protoc
314
- require 'rubygems/remote_fetcher'
315
-
316
- repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc'
317
-
318
- dependency = Gem::Dependency.new('google-protobuf')
319
-
320
- spec = dependency.to_spec
321
-
322
- version = spec.version
137
+ if interpreter.nil?
138
+ File.write(task.name, <<~CLI_RB)
139
+ # frozen_string_literal: true
323
140
 
324
- message = "protoc for #{Platform::ARCH} not available at #{repo}/#{version}"
141
+ module Sass
142
+ module CLI
143
+ COMMAND = [
144
+ #{command_source}
145
+ ].freeze
146
+ end
325
147
 
326
- os = case Platform::OS
327
- when 'darwin'
328
- 'osx'
329
- when 'linux'
330
- 'linux'
331
- when 'windows'
332
- 'windows'
333
- else
334
- raise NotImplementedError, message
335
- end
336
-
337
- cpu = case Platform::CPU
338
- when 'x86'
339
- 'x86_32'
340
- when 'x86_64'
341
- 'x86_64'
342
- when 'aarch64'
343
- 'aarch_64'
344
- when 'powerpc64le'
345
- 'ppcle_64'
346
- when 's390x'
347
- 's390_64'
348
- else
349
- raise NotImplementedError, message
350
- end
351
-
352
- uri = "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe"
353
-
354
- Gem::RemoteFetcher.fetcher.fetch_https(Gem::Uri.new("#{uri}.sha1"))
355
-
356
- uri
357
- rescue Gem::RemoteFetcher::FetchError
358
- dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
148
+ private_constant :CLI
149
+ end
150
+ CLI_RB
151
+ else
152
+ File.write(task.name, <<~CLI_RB)
153
+ # frozen_string_literal: true
359
154
 
360
- versions = Gem::Resolver::BestSet.new.find_all(dependency_request).filter_map do |s|
361
- s.version if s.platform == Gem::Platform::RUBY
362
- end
155
+ require 'sass/elf'
363
156
 
364
- versions.sort.reverse_each do |v|
365
- uri = "#{repo}/#{v}/protoc-#{v}-#{os}-#{cpu}.exe"
157
+ module Sass
158
+ module CLI
159
+ INTERPRETER = '#{interpreter}'
366
160
 
367
- Gem::RemoteFetcher.fetcher.fetch_https(Gem::Uri.new("#{uri}.sha1"))
161
+ INTERPRETER_SUFFIX = '/#{File.basename(interpreter)}'
368
162
 
369
- return uri
370
- rescue Gem::RemoteFetcher::FetchError
371
- next
372
- end
163
+ COMMAND = [
164
+ *(ELF::INTERPRETER if ELF::INTERPRETER != INTERPRETER && ELF::INTERPRETER&.end_with?(INTERPRETER_SUFFIX)),
165
+ #{command_source}
166
+ ].freeze
167
+ end
373
168
 
374
- raise NotImplementedError, message
169
+ private_constant :CLI
170
+ end
171
+ CLI_RB
375
172
  end
173
+ end
376
174
 
377
- def default_embedded_sass_protocol
378
- require 'json'
379
- require 'open3'
380
-
381
- stdout, stderr, status = Open3.capture3(RbConfig.ruby,
382
- File.absolute_path('../../exe/sass', __dir__),
383
- '--embedded',
384
- '--version')
385
-
386
- raise stderr unless status.success?
387
-
388
- tag_name = JSON.parse(stdout)['protocolVersion']
389
-
390
- "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
175
+ task 'cli.rb' => File.absolute_path('cli.rb', ARCHDIR)
176
+
177
+ file 'protoc.exe' do |task|
178
+ begin
179
+ fetch(SassConfig.protoc, task.name)
180
+ rescue NotImplementedError
181
+ File.write(task.name, <<~PROTOC_EXE)
182
+ #!#{RbConfig.ruby}
183
+ # frozen_string_literal: true
184
+ Kernel.exec('protoc', *ARGV)
185
+ PROTOC_EXE
391
186
  end
392
187
 
393
- def development?
394
- File.exist?('../../Gemfile')
395
- end
188
+ chmod 'a+x', task.name
189
+ end
396
190
 
397
- def gem_version
398
- require_relative '../../lib/sass/embedded/version'
191
+ file 'embedded_sass.proto' => %w[cli.rb] do |task|
192
+ fetch(SassConfig.embedded_sass_protocol, task.name)
193
+ end
399
194
 
400
- development? ? dart_sass_version : Sass::Embedded::VERSION
401
- end
195
+ file File.absolute_path('embedded_sass_pb.rb', LIBDIR) => %w[embedded_sass.proto protoc.exe] do |task|
196
+ mkdir_p File.dirname(task.name)
197
+ sh './protoc.exe', '--proto_path=.', "--ruby_out=#{LIBDIR}", File.basename(task.source)
198
+ end
402
199
 
403
- def gem_platform
404
- platform = Gem::Platform.new("#{Platform::CPU}-#{RbConfig::CONFIG['host_os']}")
405
- case Platform::OS
406
- when 'darwin'
407
- case platform.cpu
408
- when 'aarch64'
409
- Gem::Platform.new(['arm64', platform.os])
410
- else
411
- platform
412
- end
413
- when 'linux'
414
- if platform.version&.start_with?('gnu')
415
- platform
416
- else
417
- Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"])
418
- end
419
- when 'windows'
420
- case platform.cpu
421
- when 'x86_64'
422
- Gem::Platform.new('x64-mingw-ucrt')
423
- else
424
- Gem::Platform.new([platform.cpu, 'mingw', 'ucrt'])
425
- end
426
- else
427
- platform
428
- end
429
- end
200
+ task 'embedded_sass_pb.rb' => File.absolute_path('embedded_sass_pb.rb', LIBDIR)
201
+
202
+ file File.absolute_path('../../sig/_sass/embedded_sass_pb.rbs', __dir__) => %w[embedded_sass.proto protoc.exe] do |task|
203
+ mkdir_p File.dirname(task.name)
204
+ sh './protoc.exe', '--proto_path=.', '--rbs_out=../../sig/_sass', File.basename(task.source)
430
205
  end
206
+
207
+ task 'embedded_sass_pb.rbs' => File.absolute_path('../../sig/_sass/embedded_sass_pb.rbs', __dir__)
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This is a FileUtils extension that defines several additional commands to be
4
+ # added to the FileUtils utility functions.
5
+ module FileUtils
6
+ def unarchive(archive, chdir: '.')
7
+ if Gem.win_platform?
8
+ sh File.absolute_path('tar.exe', Utils.windows_system_directory), '-vxf', archive, '-C', chdir
9
+ elsif archive.downcase.end_with?('.zip')
10
+ sh 'unzip', '-od', chdir, archive
11
+ else
12
+ sh 'tar', '-vxf', archive, '-C', chdir, '--no-same-owner', '--no-same-permissions'
13
+ end
14
+ end
15
+
16
+ def fetch(source_uri, dest_path = nil)
17
+ dest_path = File.basename(source_uri) if dest_path.nil?
18
+
19
+ Rake.rake_output_message "fetch #{source_uri}" if Rake::FileUtilsExt.verbose_flag
20
+
21
+ unless Rake::FileUtilsExt.nowrite_flag
22
+ data = Utils.fetch_https(source_uri)
23
+ Gem.write_binary(dest_path, data)
24
+ end
25
+
26
+ dest_path
27
+ end
28
+
29
+ def gem_install(name, version, platform)
30
+ require 'rubygems/remote_fetcher'
31
+
32
+ install_dir = File.absolute_path('ruby')
33
+
34
+ if Rake::FileUtilsExt.verbose_flag
35
+ Rake.rake_output_message [
36
+ 'gem', 'install',
37
+ '--force',
38
+ '--install-dir', install_dir,
39
+ '--no-document', '--ignore-dependencies',
40
+ '--platform', platform,
41
+ '--version', version,
42
+ 'sass-embedded'
43
+ ].join(' ')
44
+ end
45
+
46
+ dependency = Gem::Dependency.new(name, version)
47
+
48
+ dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
49
+
50
+ resolver_spec = Gem::Resolver::BestSet.new.find_all(dependency_request).find do |s|
51
+ s.platform == platform
52
+ end
53
+
54
+ raise Gem::UnsatisfiableDependencyError, dependency_request if resolver_spec.nil?
55
+
56
+ options = { force: true, install_dir: }
57
+ if Rake::FileUtilsExt.nowrite_flag
58
+ installer = Gem::Installer.for_spec(resolver_spec.spec, options)
59
+ else
60
+ path = resolver_spec.download(options)
61
+ installer = Gem::Installer.at(path, options)
62
+ installer.install
63
+ end
64
+
65
+ yield installer
66
+ ensure
67
+ rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag
68
+ end
69
+
70
+ def gh_attestation_verify(path, repo:, hostname: 'github.com')
71
+ if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', hostname, %i[out err] => File::NULL)
72
+ sh 'gh', 'attestation', 'verify', path, '--hostname', hostname, '--repo', repo
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "dependencies": {
3
- "sass": "1.77.5"
3
+ "sass": "file:sass-1.100.0.tgz"
4
4
  }
5
5
  }