sass-embedded 1.99.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2fa2097bc6d26c80f27cef3adba105789dd61c075fff7542adfb5d064779314
4
- data.tar.gz: cf0dd5db690ee17cd6cda52bec0645f906f1089e49c70292b7c4767c9f2ac456
3
+ metadata.gz: c9528441bd2201383e83042dd654227c74e7163095e950d2412d055649386dcf
4
+ data.tar.gz: 4f92b875e3c3bb56e5abf21b966a1ee4da60f9c2a0b7eb08eed7cb46feb0422a
5
5
  SHA512:
6
- metadata.gz: bbbeee628df7d7a00d7f0214986c2ae82702dd4c095be43e351b07aade7fefcebd5de4eb3493db03389f59ddef6910f314a0b2d13025985849dc446d9f3c92a1
7
- data.tar.gz: 18f26d8213ff75f3a7a59d0c77e743af9012c81859095875bff942b00945be0807083d5e7ca38ed3206f498ed971c5598de23308738294792f966d537fbffab8
6
+ metadata.gz: 5fa53e22297ad64bcb4c462e5fbc7e202bf4f8eab03d829c36bbdb9c46dd9607e9e7ce1782bd9b64dc23fb0728c448b3367ca3d8fdcf717cba85572b817e85d7
7
+ data.tar.gz: 7e0f8ba6cd0852965143fecbef6fc39549edd195022a37eff1a5c6c396067bbd1892bd6500532e6e8944965fba8adfe601e7e669766ac579ea20bc6bc4c51f34
data/ext/sass/Rakefile CHANGED
@@ -1,18 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- dest = File.absolute_path('sass', ENV.fetch('RUBYARCHDIR', File.absolute_path('../../lib', __dir__)))
4
- FileUtils.mkdir_p(dest)
5
- Dir.chdir(dest)
6
-
7
3
  require 'rake/clean'
8
4
 
9
5
  require_relative '../../lib/sass/elf'
6
+ require_relative 'sass_config'
7
+ require_relative 'file_utils'
8
+ require_relative 'utils'
10
9
 
11
- ELF = Sass.const_get(:ELF)
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__)))
12
12
 
13
13
  task default: %i[install clean]
14
14
 
15
- task install: %w[cli.rb]
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
18
+ end
19
+ end
16
20
 
17
21
  CLEAN.include %w[
18
22
  protoc.exe
@@ -22,87 +26,92 @@ CLEAN.include %w[
22
26
  *.zip
23
27
  ]
24
28
 
25
- CLOBBER.include %w[
29
+ CLOBBER.include(%w[
26
30
  dart-sass
27
31
  cli.rb
28
- embedded_sass_pb.rb
29
32
  node_modules
30
33
  bun.lockb
31
34
  package-lock.json
32
35
  pnpm-lock.yaml
33
36
  yarn.lock
34
- ]
37
+ ].map do |file|
38
+ File.absolute_path(file, ARCHDIR)
39
+ end)
35
40
 
36
- file 'protoc.exe' do |t|
37
- fetch(SassConfig.protoc, t.name)
38
- chmod 'a+x', t.name
39
- rescue NotImplementedError
40
- File.write(t.name, <<~PROTOC_EXE)
41
- #!#{RbConfig.ruby}
42
- # frozen_string_literal: true
43
- Kernel.exec('protoc', *ARGV)
44
- PROTOC_EXE
45
- chmod 'a+x', t.name
46
- end
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
47
49
 
48
- file 'dart-sass/sass' do
49
- gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |installer|
50
- gh_attestation_verify(installer.gem, repo: 'sass-contrib/sass-embedded-host-ruby')
51
- mv File.absolute_path('lib/sass/dart-sass', installer.gem_dir), 'dart-sass'
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)
54
+ end
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
52
60
  end
53
- rescue StandardError
54
- archive = fetch(SassConfig.dart_sass)
55
- gh_attestation_verify(archive, repo: 'sass/dart-sass')
56
- unarchive archive
57
- rm archive
58
61
  end
59
62
 
60
- file 'node_modules/sass' do
61
- cp File.absolute_path('package.json', __dir__), './'
63
+ file File.absolute_path('node_modules/sass', ARCHDIR) do
64
+ mkdir_p ARCHDIR
65
+
66
+ cp File.absolute_path('package.json', __dir__), ARCHDIR
62
67
 
63
68
  # TODO: remove after https://github.com/sass/dart-sass/pull/2413
64
- cp File.absolute_path("sass-#{SassConfig.dart_sass_version}.tgz", __dir__), './'
69
+ cp File.absolute_path("sass-#{SassConfig.dart_sass_version}.tgz", __dir__), ARCHDIR
65
70
 
66
71
  begin
67
- sh 'npm', 'install'
72
+ sh 'npm', 'install', chdir: ARCHDIR
68
73
  rescue StandardError
69
74
  begin
70
- sh 'yarn', 'install'
75
+ sh 'yarn', 'install', chdir: ARCHDIR
71
76
  rescue StandardError
72
77
  begin
73
- sh 'pnpm', 'install'
78
+ sh 'pnpm', 'install', chdir: ARCHDIR
74
79
  rescue StandardError
75
- sh 'bun', 'install'
80
+ sh 'bun', 'install', chdir: ARCHDIR
76
81
  end
77
82
  end
78
83
  end
79
84
  end
80
85
 
81
- task 'dart-sass' do
82
- Rake::Task['dart-sass/sass'].invoke
83
- rescue NotImplementedError
84
- Rake::Task['node_modules/sass'].invoke
85
- end
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)
92
+ end
93
+ )
86
94
 
87
- file 'cli.rb' => %w[dart-sass] do |t|
95
+ file File.absolute_path('cli.rb', ARCHDIR) => %w[dart-sass] do |task|
88
96
  begin
89
97
  exe = 'dart-sass/sass'
90
- exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}"
98
+ exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?(File.absolute_path("#{exe}#{ext}", ARCHDIR)) }}"
91
99
 
92
- raise Errno::ENOENT, exe unless File.exist?(exe)
100
+ raise Errno::ENOENT, exe unless File.exist?(File.absolute_path(exe, ARCHDIR))
93
101
 
94
102
  runtime = 'dart-sass/src/dart'
95
- runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}"
103
+ runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?(File.absolute_path("#{runtime}#{ext}", ARCHDIR)) }}"
96
104
  snapshot = 'dart-sass/src/sass.snapshot'
97
105
 
98
- command = if File.exist?(runtime) && File.exist?(snapshot)
106
+ command = if File.exist?(File.absolute_path(runtime, ARCHDIR)) &&
107
+ File.exist?(File.absolute_path(snapshot, ARCHDIR))
99
108
  [runtime, snapshot]
100
109
  else
101
110
  [exe]
102
111
  end
103
112
 
104
- interpreter = File.open(command[0], 'rb') do |file|
105
- ELF.new(file).interpreter
113
+ interpreter = File.open(File.absolute_path(command[0], ARCHDIR), 'rb') do |file|
114
+ Sass.const_get(:ELF).new(file).interpreter
106
115
  rescue ArgumentError
107
116
  nil
108
117
  end
@@ -114,7 +123,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
114
123
  rescue Errno::ENOENT
115
124
  package = 'node_modules/sass'
116
125
 
117
- script = File.join(package, SassConfig.package_json(package)['bin']['sass'])
126
+ script = File.join(package, SassConfig.package_json(File.absolute_path(package, ARCHDIR))['bin']['sass'])
118
127
 
119
128
  interpreter = nil
120
129
 
@@ -126,7 +135,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
126
135
  end
127
136
 
128
137
  if interpreter.nil?
129
- File.write(t.name, <<~CLI_RB)
138
+ File.write(task.name, <<~CLI_RB)
130
139
  # frozen_string_literal: true
131
140
 
132
141
  module Sass
@@ -140,7 +149,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
140
149
  end
141
150
  CLI_RB
142
151
  else
143
- File.write(t.name, <<~CLI_RB)
152
+ File.write(task.name, <<~CLI_RB)
144
153
  # frozen_string_literal: true
145
154
 
146
155
  require 'sass/elf'
@@ -163,346 +172,36 @@ file 'cli.rb' => %w[dart-sass] do |t|
163
172
  end
164
173
  end
165
174
 
166
- file 'embedded_sass.proto' => %w[cli.rb] do |t|
167
- fetch(SassConfig.embedded_sass_protocol, t.name)
168
- end
169
-
170
- rule '_pb.rb' => %w[.proto protoc.exe] do |t|
171
- sh './protoc.exe', '--proto_path=.', '--ruby_out=.', t.source
172
- end
173
-
174
- rule '_pb.rbs' => %w[.proto protoc.exe] do |t|
175
- sh './protoc.exe', '--proto_path=.', '--rbs_out=../../sig/sass', t.source
176
- end
177
-
178
- # rubocop:disable Style/OneClassPerFile
179
-
180
- # This is a FileUtils extension that defines several additional commands to be
181
- # added to the FileUtils utility functions.
182
- module FileUtils
183
- def unarchive(archive)
184
- if Gem.win_platform?
185
- sh File.absolute_path('tar.exe', Utils.windows_system_directory), '-vxf', archive
186
- elsif archive.downcase.end_with?('.zip')
187
- sh 'unzip', '-o', archive
188
- else
189
- sh 'tar', '-vxf', archive, '--no-same-owner', '--no-same-permissions'
190
- end
191
- end
192
-
193
- def fetch(source_uri, dest_path = nil)
194
- dest_path = File.basename(source_uri) if dest_path.nil?
175
+ task 'cli.rb' => File.absolute_path('cli.rb', ARCHDIR)
195
176
 
196
- Rake.rake_output_message "fetch #{source_uri}" if Rake::FileUtilsExt.verbose_flag
197
-
198
- unless Rake::FileUtilsExt.nowrite_flag
199
- data = Utils.fetch_https(source_uri)
200
- Gem.write_binary(dest_path, data)
201
- end
202
-
203
- dest_path
204
- end
205
-
206
- def gem_install(name, version, platform)
207
- require 'rubygems/remote_fetcher'
208
-
209
- install_dir = File.absolute_path('ruby')
210
-
211
- if Rake::FileUtilsExt.verbose_flag
212
- Rake.rake_output_message [
213
- 'gem', 'install',
214
- '--force',
215
- '--install-dir', install_dir,
216
- '--no-document', '--ignore-dependencies',
217
- '--platform', platform,
218
- '--version', version,
219
- 'sass-embedded'
220
- ].join(' ')
221
- end
222
-
223
- dependency = Gem::Dependency.new(name, version)
224
-
225
- dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
226
-
227
- resolver_spec = Gem::Resolver::BestSet.new.find_all(dependency_request).find do |s|
228
- s.platform == platform
229
- end
230
-
231
- raise Gem::UnsatisfiableDependencyError, dependency_request if resolver_spec.nil?
232
-
233
- options = { force: true, install_dir: }
234
- if Rake::FileUtilsExt.nowrite_flag
235
- installer = Gem::Installer.for_spec(resolver_spec.spec, options)
236
- else
237
- path = resolver_spec.download(options)
238
- installer = Gem::Installer.at(path, options)
239
- installer.install
240
- end
241
-
242
- yield installer
243
- ensure
244
- rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag
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
245
186
  end
246
187
 
247
- def gh_attestation_verify(path, repo:, hostname: 'github.com')
248
- if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', hostname, %i[out err] => File::NULL)
249
- sh 'gh', 'attestation', 'verify', path, '--hostname', hostname, '--repo', repo
250
- end
251
- end
188
+ chmod 'a+x', task.name
252
189
  end
253
190
 
254
- # The {Platform} module.
255
- module Platform
256
- HOST_CPU = RbConfig::CONFIG['host_cpu'].downcase
257
-
258
- CPU = case HOST_CPU
259
- when /amd64|x86_64|x64/
260
- 'x86_64'
261
- when /i\d86|x86|i86pc/
262
- 'i386'
263
- when /arm64|aarch64/
264
- 'aarch64'
265
- when /arm/
266
- 'arm'
267
- when /ppc64le|powerpc64le/
268
- 'ppc64le'
269
- else
270
- HOST_CPU
271
- end
272
-
273
- HOST_OS = RbConfig::CONFIG['host_os'].downcase
274
-
275
- OS = case HOST_OS
276
- when /darwin/
277
- 'darwin'
278
- when /linux-android/
279
- 'linux-android'
280
- when /linux-musl/
281
- 'linux-musl'
282
- when /linux-none/
283
- 'linux-none'
284
- when /linux-uclibc/
285
- 'linux-uclibc'
286
- when /linux/
287
- 'linux'
288
- when *Gem::WIN_PATTERNS
289
- 'windows'
290
- else
291
- HOST_OS
292
- end
293
-
294
- ARCH = "#{CPU}-#{OS}".freeze
191
+ file 'embedded_sass.proto' => %w[cli.rb] do |task|
192
+ fetch(SassConfig.embedded_sass_protocol, task.name)
295
193
  end
296
194
 
297
- # The {SassConfig} module.
298
- module SassConfig
299
- module_function
300
-
301
- def package_json(path = '.')
302
- require 'json'
303
-
304
- JSON.parse(File.read(File.absolute_path('package.json', path)))
305
- end
306
-
307
- def dart_sass_version
308
- package_json(__dir__)['dependencies']['sass']
309
- # TODO: remove after https://github.com/sass/dart-sass/pull/2413
310
- .delete_prefix('file:sass-').delete_suffix('.tgz')
311
- end
312
-
313
- def dart_sass
314
- repo = 'https://github.com/sass/dart-sass'
315
-
316
- tag_name = dart_sass_version
317
-
318
- message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
319
-
320
- env = ''
321
-
322
- os = case Platform::OS
323
- when 'darwin'
324
- 'macos'
325
- when 'linux'
326
- 'linux'
327
- when 'linux-android'
328
- 'android'
329
- when 'linux-musl'
330
- env = '-musl'
331
- 'linux'
332
- when 'windows'
333
- 'windows'
334
- else
335
- raise NotImplementedError, message
336
- end
337
-
338
- cpu = case Platform::CPU
339
- when 'x86_64'
340
- 'x64'
341
- when 'aarch64'
342
- 'arm64'
343
- when 'arm'
344
- 'arm'
345
- when 'riscv64'
346
- 'riscv64'
347
- else
348
- raise NotImplementedError, message
349
- end
350
-
351
- ext = Platform::OS == 'windows' ? 'zip' : 'tar.gz'
352
-
353
- "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}#{env}.#{ext}"
354
- end
355
-
356
- def protoc
357
- repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc'
358
-
359
- dependency = Gem::Dependency.new('google-protobuf')
360
-
361
- spec = dependency.to_spec
362
-
363
- version = spec.version
364
-
365
- message = "protoc for #{Platform::ARCH} not available at #{repo}/#{version}"
366
-
367
- os = case Platform::OS
368
- when 'darwin'
369
- 'osx'
370
- when 'linux', 'linux-android', 'linux-musl', 'linux-none', 'linux-uclibc'
371
- 'linux'
372
- when 'windows'
373
- 'windows'
374
- else
375
- raise NotImplementedError, message
376
- end
377
-
378
- cpu = case Platform::CPU
379
- when 'i386'
380
- 'x86_32'
381
- when 'x86_64'
382
- 'x86_64'
383
- when 'aarch64'
384
- Platform::OS == 'windows' ? 'x86_64' : 'aarch_64'
385
- when 'ppc64le'
386
- 'ppcle_64'
387
- when 's390x'
388
- 's390_64'
389
- else
390
- raise NotImplementedError, message
391
- end
392
-
393
- uri = "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe"
394
-
395
- Utils.fetch_https("#{uri}.sha1")
396
-
397
- uri
398
- rescue Gem::RemoteFetcher::FetchError
399
- dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
400
-
401
- versions = Gem::Resolver::BestSet.new.find_all(dependency_request).filter_map do |s|
402
- s.version if s.platform == Gem::Platform::RUBY
403
- end
404
-
405
- versions.sort.reverse_each do |v|
406
- uri = "#{repo}/#{v}/protoc-#{v}-#{os}-#{cpu}.exe"
407
-
408
- Utils.fetch_https("#{uri}.sha1")
409
-
410
- return uri
411
- rescue Gem::RemoteFetcher::FetchError
412
- next
413
- end
414
-
415
- raise NotImplementedError, message
416
- end
417
-
418
- def embedded_sass_protocol
419
- require 'json'
420
-
421
- version = Utils.capture(RbConfig.ruby,
422
- File.absolute_path('../../exe/sass', __dir__),
423
- '--embedded',
424
- '--version')
425
-
426
- tag_name = JSON.parse(version)['protocolVersion']
427
-
428
- "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
429
- end
430
-
431
- def development?
432
- File.exist?('../../Gemfile')
433
- end
434
-
435
- def gem_version
436
- require_relative '../../lib/sass/embedded/version'
437
-
438
- development? ? dart_sass_version : Sass::Embedded::VERSION
439
- end
440
-
441
- def gem_platform
442
- platform = Gem::Platform.new("#{Platform::CPU}-#{Platform::HOST_OS}")
443
- case Platform::OS
444
- when 'darwin'
445
- case platform.cpu
446
- when 'aarch64'
447
- Gem::Platform.new(['arm64', platform.os])
448
- else
449
- platform
450
- end
451
- when 'linux'
452
- if platform.version&.start_with?('gnu')
453
- platform
454
- else
455
- Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"])
456
- end
457
- when 'windows'
458
- case platform.cpu
459
- when 'x86_64'
460
- Gem::Platform.new('x64-mingw-ucrt')
461
- else
462
- Gem::Platform.new([platform.cpu, 'mingw', 'ucrt'])
463
- end
464
- else
465
- platform
466
- end
467
- 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)
468
198
  end
469
199
 
470
- # The {Utils} module.
471
- module Utils
472
- module_function
473
-
474
- def capture(...)
475
- require 'open3'
476
-
477
- stdout, stderr, status = Open3.capture3(...)
200
+ task 'embedded_sass_pb.rb' => File.absolute_path('embedded_sass_pb.rb', LIBDIR)
478
201
 
479
- raise stderr unless status.success?
480
-
481
- stdout
482
- end
483
-
484
- def fetch_https(source_uri)
485
- require 'rubygems/remote_fetcher'
486
-
487
- source_uri = begin
488
- Gem::Uri.parse!(source_uri)
489
- rescue NoMethodError
490
- URI.parse(source_uri)
491
- end
492
-
493
- Gem::RemoteFetcher.fetcher.fetch_https(source_uri)
494
- end
495
-
496
- def windows_system_directory
497
- path = capture('powershell.exe',
498
- '-NoLogo',
499
- '-NoProfile',
500
- '-NonInteractive',
501
- '-Command',
502
- '[Environment]::GetFolderPath([Environment+SpecialFolder]::System) | Write-Host -NoNewline')
503
-
504
- File.absolute_path(path)
505
- end
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)
506
205
  end
507
206
 
508
- # rubocop:enable Style/OneClassPerFile
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": "file:sass-1.99.0.tgz"
3
+ "sass": "file:sass-1.100.0.tgz"
4
4
  }
5
5
  }
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The {Platform} module.
4
+ module Platform
5
+ HOST_CPU = RbConfig::CONFIG['host_cpu'].downcase
6
+
7
+ CPU = case HOST_CPU
8
+ when /amd64|x86_64|x64/
9
+ 'x86_64'
10
+ when /i\d86|x86|i86pc/
11
+ 'i386'
12
+ when /arm64|aarch64/
13
+ 'aarch64'
14
+ when /arm/
15
+ 'arm'
16
+ when /ppc64le|powerpc64le/
17
+ 'ppc64le'
18
+ else
19
+ HOST_CPU
20
+ end
21
+
22
+ HOST_OS = RbConfig::CONFIG['host_os'].downcase
23
+
24
+ OS = case HOST_OS
25
+ when /darwin/
26
+ 'darwin'
27
+ when /linux-android/
28
+ 'linux-android'
29
+ when /linux-musl/
30
+ 'linux-musl'
31
+ when /linux-none/
32
+ 'linux-none'
33
+ when /linux-uclibc/
34
+ 'linux-uclibc'
35
+ when /linux/
36
+ 'linux'
37
+ when *Gem::WIN_PATTERNS
38
+ 'windows'
39
+ else
40
+ HOST_OS
41
+ end
42
+
43
+ ARCH = "#{CPU}-#{OS}".freeze
44
+ end
Binary file
@@ -0,0 +1,183 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'platform'
4
+
5
+ # The {SassConfig} module.
6
+ module SassConfig
7
+ module_function
8
+
9
+ def package_json(path = '.')
10
+ require 'json'
11
+
12
+ JSON.parse(File.read(File.absolute_path('package.json', path)))
13
+ end
14
+
15
+ def dart_sass_version
16
+ package_json(__dir__)['dependencies']['sass']
17
+ # TODO: remove after https://github.com/sass/dart-sass/pull/2413
18
+ .delete_prefix('file:sass-').delete_suffix('.tgz')
19
+ end
20
+
21
+ def dart_sass
22
+ repo = 'https://github.com/sass/dart-sass'
23
+
24
+ tag_name = dart_sass_version
25
+
26
+ message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
27
+
28
+ env = ''
29
+
30
+ os = case Platform::OS
31
+ when 'darwin'
32
+ 'macos'
33
+ when 'linux'
34
+ 'linux'
35
+ when 'linux-android'
36
+ 'android'
37
+ when 'linux-musl'
38
+ env = '-musl'
39
+ 'linux'
40
+ when 'windows'
41
+ 'windows'
42
+ else
43
+ raise NotImplementedError, message
44
+ end
45
+
46
+ cpu = case Platform::CPU
47
+ when 'x86_64'
48
+ 'x64'
49
+ when 'aarch64'
50
+ 'arm64'
51
+ when 'arm'
52
+ 'arm'
53
+ when 'riscv64'
54
+ 'riscv64'
55
+ else
56
+ raise NotImplementedError, message
57
+ end
58
+
59
+ ext = Platform::OS == 'windows' ? 'zip' : 'tar.gz'
60
+
61
+ "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}#{env}.#{ext}"
62
+ end
63
+
64
+ def protoc
65
+ repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc'
66
+
67
+ dependency = Gem::Dependency.new('google-protobuf')
68
+
69
+ spec = dependency.to_spec
70
+
71
+ version = spec.version
72
+
73
+ message = "protoc for #{Platform::ARCH} not available at #{repo}/#{version}"
74
+
75
+ os = case Platform::OS
76
+ when 'darwin'
77
+ 'osx'
78
+ when 'linux', 'linux-android', 'linux-musl', 'linux-none', 'linux-uclibc'
79
+ 'linux'
80
+ when 'windows'
81
+ 'windows'
82
+ else
83
+ raise NotImplementedError, message
84
+ end
85
+
86
+ cpu = case Platform::CPU
87
+ when 'i386'
88
+ 'x86_32'
89
+ when 'x86_64'
90
+ 'x86_64'
91
+ when 'aarch64'
92
+ Platform::OS == 'windows' ? 'x86_64' : 'aarch_64'
93
+ when 'ppc64le'
94
+ 'ppcle_64'
95
+ when 's390x'
96
+ 's390_64'
97
+ else
98
+ raise NotImplementedError, message
99
+ end
100
+
101
+ uri = "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe"
102
+
103
+ Utils.fetch_https("#{uri}.sha1")
104
+
105
+ uri
106
+ rescue Gem::RemoteFetcher::FetchError
107
+ dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
108
+
109
+ versions = Gem::Resolver::BestSet.new.find_all(dependency_request).filter_map do |s|
110
+ s.version if s.platform == Gem::Platform::RUBY
111
+ end
112
+
113
+ versions.sort.reverse_each do |v|
114
+ uri = "#{repo}/#{v}/protoc-#{v}-#{os}-#{cpu}.exe"
115
+
116
+ Utils.fetch_https("#{uri}.sha1")
117
+
118
+ return uri
119
+ rescue Gem::RemoteFetcher::FetchError
120
+ next
121
+ end
122
+
123
+ raise NotImplementedError, message
124
+ end
125
+
126
+ def embedded_sass_protocol
127
+ require 'json'
128
+
129
+ rubyarchdir = ENV.fetch('RUBYARCHDIR', nil)
130
+
131
+ rubylibdir = ENV.fetch('RUBYLIBDIR', nil)
132
+
133
+ version = Utils.capture(RbConfig.ruby,
134
+ "-I#{File.absolute_path('../../lib', __dir__)}",
135
+ *("-I#{rubyarchdir}" if rubyarchdir),
136
+ *("-I#{rubylibdir}" if rubylibdir),
137
+ File.absolute_path('../../exe/sass', __dir__),
138
+ '--embedded',
139
+ '--version')
140
+
141
+ tag_name = JSON.parse(version)['protocolVersion']
142
+
143
+ "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
144
+ end
145
+
146
+ def development?
147
+ File.exist?('../../Gemfile')
148
+ end
149
+
150
+ def gem_version
151
+ require_relative '../../lib/sass/embedded/version'
152
+
153
+ development? ? dart_sass_version : Sass::Embedded::VERSION
154
+ end
155
+
156
+ def gem_platform
157
+ platform = Gem::Platform.new("#{Platform::CPU}-#{Platform::HOST_OS}")
158
+ case Platform::OS
159
+ when 'darwin'
160
+ case platform.cpu
161
+ when 'aarch64'
162
+ Gem::Platform.new(['arm64', platform.os])
163
+ else
164
+ platform
165
+ end
166
+ when 'linux'
167
+ if platform.version&.start_with?('gnu')
168
+ platform
169
+ else
170
+ Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"])
171
+ end
172
+ when 'windows'
173
+ case platform.cpu
174
+ when 'x86_64'
175
+ Gem::Platform.new('x64-mingw-ucrt')
176
+ else
177
+ Gem::Platform.new([platform.cpu, 'mingw', 'ucrt'])
178
+ end
179
+ else
180
+ platform
181
+ end
182
+ end
183
+ end
data/ext/sass/utils.rb ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The {Utils} module.
4
+ module Utils
5
+ module_function
6
+
7
+ def capture(...)
8
+ require 'open3'
9
+
10
+ stdout, stderr, status = Open3.capture3(...)
11
+
12
+ raise stderr unless status.success?
13
+
14
+ stdout
15
+ end
16
+
17
+ def fetch_https(source_uri)
18
+ require 'rubygems/remote_fetcher'
19
+
20
+ source_uri = begin
21
+ Gem::Uri.parse!(source_uri)
22
+ rescue NoMethodError
23
+ URI.parse(source_uri)
24
+ end
25
+
26
+ Gem::RemoteFetcher.fetcher.fetch_https(source_uri)
27
+ end
28
+
29
+ def windows_system_directory
30
+ path = capture('powershell.exe',
31
+ '-NoLogo',
32
+ '-NoProfile',
33
+ '-NonInteractive',
34
+ '-Command',
35
+ '[Environment]::GetFolderPath([Environment+SpecialFolder]::System) | Write-Host -NoNewline')
36
+
37
+ File.absolute_path(path)
38
+ end
39
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  module Embedded
5
- VERSION = '1.99.0'
5
+ VERSION = '1.100.0'
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  module Sass
4
4
  # @see https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md
5
5
  module EmbeddedProtocol
6
- require_relative 'embedded_sass_pb'
6
+ require 'sass/embedded_sass_pb'
7
7
  end
8
8
 
9
9
  private_constant :EmbeddedProtocol
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.0
4
+ version: 1.100.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
@@ -51,8 +51,12 @@ files:
51
51
  - README.md
52
52
  - exe/sass
53
53
  - ext/sass/Rakefile
54
+ - ext/sass/file_utils.rb
54
55
  - ext/sass/package.json
55
- - ext/sass/sass-1.99.0.tgz
56
+ - ext/sass/platform.rb
57
+ - ext/sass/sass-1.100.0.tgz
58
+ - ext/sass/sass_config.rb
59
+ - ext/sass/utils.rb
56
60
  - lib/sass-embedded.rb
57
61
  - lib/sass/calculation_value.rb
58
62
  - lib/sass/calculation_value/calculation_operation.rb
@@ -126,8 +130,8 @@ licenses:
126
130
  - MIT
127
131
  metadata:
128
132
  bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
129
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.99.0
130
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.99.0
133
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.100.0
134
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.100.0
131
135
  funding_uri: https://github.com/sponsors/ntkme
132
136
  rubygems_mfa_required: 'true'
133
137
  rdoc_options: []
@@ -144,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
148
  - !ruby/object:Gem::Version
145
149
  version: '0'
146
150
  requirements: []
147
- rubygems_version: 4.0.9
151
+ rubygems_version: 4.0.12
148
152
  specification_version: 4
149
153
  summary: Use dart-sass with Ruby!
150
154
  test_files: []
Binary file