sass-embedded 1.99.0 → 1.101.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 +4 -4
- data/ext/sass/Rakefile +80 -382
- data/ext/sass/file_utils.rb +77 -0
- data/ext/sass/package.json +1 -1
- data/ext/sass/platform.rb +46 -0
- data/ext/sass/sass-1.101.0.tgz +0 -0
- data/ext/sass/sass_config.rb +190 -0
- data/ext/sass/utils.rb +41 -0
- data/lib/sass/compiler/channel.rb +6 -6
- data/lib/sass/compiler/dispatcher.rb +1 -1
- data/lib/sass/compiler/{host → session}/function_registry.rb +9 -4
- data/lib/sass/compiler/{host → session}/importer_registry.rb +21 -6
- data/lib/sass/compiler/{host → session}/logger_registry.rb +3 -3
- data/lib/sass/compiler/session/path.rb +34 -0
- data/lib/sass/compiler/{host → session}/protofier.rb +1 -1
- data/lib/sass/compiler/session/stack_trace.rb +46 -0
- data/lib/sass/compiler/{host → session}/struct.rb +1 -1
- data/lib/sass/compiler/{host.rb → session.rb} +19 -12
- data/lib/sass/compiler.rb +5 -4
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded_protocol.rb +1 -1
- data/lib/sass/exception.rb +69 -17
- data/lib/sass/gem_package_importer.rb +14 -5
- data/lib/sass/uri.rb +56 -0
- data/lib/sass/value/color/space/utils.rb +2 -2
- metadata +18 -11
- data/ext/sass/sass-1.99.0.tgz +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c1150457b872cc21b565ce1443f9a27ebd8381827cb817ba4f7c9e0cb0d4a1b
|
|
4
|
+
data.tar.gz: 2bac705032c8c0c1d1e17f5b94e3c0d21590a9c07d8be51fe132ee3f6c7a318e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44730a3d0a601297d15e30b234497b89c0959732c60ff108165bfb664f1c53524c61d07be05451560d6d3cedc34fd3cd3ea322b9701519f9d0f88076af3ee6ac
|
|
7
|
+
data.tar.gz: 10f8eb4867f4669407d8f64b8f31b998d37eb9eaa2fb3cd93d7cd04c33b4c99ef8715483303b71167919c0b477e151157b9d643b1dda5cea191c6e6187672a51
|
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
|
-
|
|
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,91 @@ CLEAN.include %w[
|
|
|
22
26
|
*.zip
|
|
23
27
|
]
|
|
24
28
|
|
|
25
|
-
CLOBBER.include
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
task 'dart-sass' => (
|
|
87
|
+
if SassConfig.dart_support?
|
|
88
|
+
File.absolute_path('dart-sass/sass', ARCHDIR)
|
|
89
|
+
else
|
|
90
|
+
File.absolute_path('node_modules/sass', ARCHDIR)
|
|
91
|
+
end
|
|
92
|
+
)
|
|
86
93
|
|
|
87
|
-
file 'cli.rb' => %w[dart-sass] do |
|
|
94
|
+
file File.absolute_path('cli.rb', ARCHDIR) => %w[dart-sass] do |task|
|
|
88
95
|
begin
|
|
89
96
|
exe = 'dart-sass/sass'
|
|
90
|
-
exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}"
|
|
97
|
+
exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?(File.absolute_path("#{exe}#{ext}", ARCHDIR)) }}"
|
|
91
98
|
|
|
92
|
-
raise Errno::ENOENT, exe unless File.exist?(exe)
|
|
99
|
+
raise Errno::ENOENT, exe unless File.exist?(File.absolute_path(exe, ARCHDIR))
|
|
93
100
|
|
|
94
101
|
runtime = 'dart-sass/src/dart'
|
|
95
|
-
runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}"
|
|
102
|
+
runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?(File.absolute_path("#{runtime}#{ext}", ARCHDIR)) }}"
|
|
96
103
|
snapshot = 'dart-sass/src/sass.snapshot'
|
|
97
104
|
|
|
98
|
-
command = if File.exist?(runtime) &&
|
|
105
|
+
command = if File.exist?(File.absolute_path(runtime, ARCHDIR)) &&
|
|
106
|
+
File.exist?(File.absolute_path(snapshot, ARCHDIR))
|
|
99
107
|
[runtime, snapshot]
|
|
100
108
|
else
|
|
101
109
|
[exe]
|
|
102
110
|
end
|
|
103
111
|
|
|
104
|
-
interpreter = File.open(command[0], 'rb') do |file|
|
|
105
|
-
ELF.new(file).interpreter
|
|
112
|
+
interpreter = File.open(File.absolute_path(command[0], ARCHDIR), 'rb') do |file|
|
|
113
|
+
Sass.const_get(:ELF).new(file).interpreter
|
|
106
114
|
rescue ArgumentError
|
|
107
115
|
nil
|
|
108
116
|
end
|
|
@@ -114,7 +122,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
|
|
|
114
122
|
rescue Errno::ENOENT
|
|
115
123
|
package = 'node_modules/sass'
|
|
116
124
|
|
|
117
|
-
script = File.join(package, SassConfig.package_json(package)['bin']['sass'])
|
|
125
|
+
script = File.join(package, SassConfig.package_json(File.absolute_path(package, ARCHDIR))['bin']['sass'])
|
|
118
126
|
|
|
119
127
|
interpreter = nil
|
|
120
128
|
|
|
@@ -126,7 +134,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
|
|
|
126
134
|
end
|
|
127
135
|
|
|
128
136
|
if interpreter.nil?
|
|
129
|
-
File.write(
|
|
137
|
+
File.write(task.name, <<~CLI_RB)
|
|
130
138
|
# frozen_string_literal: true
|
|
131
139
|
|
|
132
140
|
module Sass
|
|
@@ -140,7 +148,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
|
|
|
140
148
|
end
|
|
141
149
|
CLI_RB
|
|
142
150
|
else
|
|
143
|
-
File.write(
|
|
151
|
+
File.write(task.name, <<~CLI_RB)
|
|
144
152
|
# frozen_string_literal: true
|
|
145
153
|
|
|
146
154
|
require 'sass/elf'
|
|
@@ -163,346 +171,36 @@ file 'cli.rb' => %w[dart-sass] do |t|
|
|
|
163
171
|
end
|
|
164
172
|
end
|
|
165
173
|
|
|
166
|
-
|
|
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?
|
|
174
|
+
task 'cli.rb' => File.absolute_path('cli.rb', ARCHDIR)
|
|
195
175
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
|
176
|
+
file 'protoc.exe' do |task|
|
|
177
|
+
begin
|
|
178
|
+
fetch(SassConfig.protoc, task.name)
|
|
179
|
+
rescue NotImplementedError
|
|
180
|
+
File.write(task.name, <<~PROTOC_EXE)
|
|
181
|
+
#!#{RbConfig.ruby}
|
|
182
|
+
# frozen_string_literal: true
|
|
183
|
+
Kernel.exec('protoc', *ARGV)
|
|
184
|
+
PROTOC_EXE
|
|
245
185
|
end
|
|
246
186
|
|
|
247
|
-
|
|
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
|
|
187
|
+
chmod 'a+x', task.name
|
|
252
188
|
end
|
|
253
189
|
|
|
254
|
-
|
|
255
|
-
|
|
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
|
|
190
|
+
file 'embedded_sass.proto' => %w[cli.rb] do |task|
|
|
191
|
+
fetch(SassConfig.embedded_sass_protocol, task.name)
|
|
295
192
|
end
|
|
296
193
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
|
194
|
+
file File.absolute_path('embedded_sass_pb.rb', LIBDIR) => %w[embedded_sass.proto protoc.exe] do |task|
|
|
195
|
+
mkdir_p File.dirname(task.name)
|
|
196
|
+
sh './protoc.exe', '--proto_path=.', "--ruby_out=#{LIBDIR}", File.basename(task.source)
|
|
468
197
|
end
|
|
469
198
|
|
|
470
|
-
|
|
471
|
-
module Utils
|
|
472
|
-
module_function
|
|
473
|
-
|
|
474
|
-
def capture(...)
|
|
475
|
-
require 'open3'
|
|
476
|
-
|
|
477
|
-
stdout, stderr, status = Open3.capture3(...)
|
|
199
|
+
task 'embedded_sass_pb.rb' => File.absolute_path('embedded_sass_pb.rb', LIBDIR)
|
|
478
200
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
|
201
|
+
file File.absolute_path('../../sig/_sass/embedded_sass_pb.rbs', __dir__) => %w[embedded_sass.proto protoc.exe] do |task|
|
|
202
|
+
mkdir_p File.dirname(task.name)
|
|
203
|
+
sh './protoc.exe', '--proto_path=.', '--rbs_out=../../sig/_sass', File.basename(task.source)
|
|
506
204
|
end
|
|
507
205
|
|
|
508
|
-
|
|
206
|
+
task 'embedded_sass_pb.rbs' => File.absolute_path('../../sig/_sass/embedded_sass_pb.rbs', __dir__)
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
#
|
|
6
|
+
# @!visibility private
|
|
7
|
+
module FileUtils
|
|
8
|
+
def unarchive(archive, chdir: '.')
|
|
9
|
+
if Gem.win_platform?
|
|
10
|
+
sh File.absolute_path('tar.exe', Utils.windows_system_directory), '-vxf', archive, '-C', chdir
|
|
11
|
+
elsif archive.downcase.end_with?('.zip')
|
|
12
|
+
sh 'unzip', '-od', chdir, archive
|
|
13
|
+
else
|
|
14
|
+
sh 'tar', '-vxf', archive, '-C', chdir, '--no-same-owner', '--no-same-permissions'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def fetch(source_uri, dest_path = nil)
|
|
19
|
+
dest_path = File.basename(source_uri) if dest_path.nil?
|
|
20
|
+
|
|
21
|
+
Rake.rake_output_message "fetch #{source_uri}" if Rake::FileUtilsExt.verbose_flag
|
|
22
|
+
|
|
23
|
+
unless Rake::FileUtilsExt.nowrite_flag
|
|
24
|
+
data = Utils.fetch_https(source_uri)
|
|
25
|
+
Gem.write_binary(dest_path, data)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
dest_path
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def gem_install(name, version, platform)
|
|
32
|
+
require 'rubygems/remote_fetcher'
|
|
33
|
+
|
|
34
|
+
install_dir = File.absolute_path('ruby')
|
|
35
|
+
|
|
36
|
+
if Rake::FileUtilsExt.verbose_flag
|
|
37
|
+
Rake.rake_output_message [
|
|
38
|
+
'gem', 'install',
|
|
39
|
+
'--force',
|
|
40
|
+
'--install-dir', install_dir,
|
|
41
|
+
'--no-document', '--ignore-dependencies',
|
|
42
|
+
'--platform', platform,
|
|
43
|
+
'--version', version,
|
|
44
|
+
'sass-embedded'
|
|
45
|
+
].join(' ')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
dependency = Gem::Dependency.new(name, version)
|
|
49
|
+
|
|
50
|
+
dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil)
|
|
51
|
+
|
|
52
|
+
resolver_spec = Gem::Resolver::BestSet.new.find_all(dependency_request).find do |s|
|
|
53
|
+
s.platform == platform
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
raise Gem::UnsatisfiableDependencyError, dependency_request if resolver_spec.nil?
|
|
57
|
+
|
|
58
|
+
options = { force: true, install_dir: }
|
|
59
|
+
if Rake::FileUtilsExt.nowrite_flag
|
|
60
|
+
installer = Gem::Installer.for_spec(resolver_spec.spec, options)
|
|
61
|
+
else
|
|
62
|
+
path = resolver_spec.download(options)
|
|
63
|
+
installer = Gem::Installer.at(path, options)
|
|
64
|
+
installer.install
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
yield installer
|
|
68
|
+
ensure
|
|
69
|
+
rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def gh_attestation_verify(path, repo:, hostname: 'github.com')
|
|
73
|
+
if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', hostname, %i[out err] => File::NULL)
|
|
74
|
+
sh 'gh', 'attestation', 'verify', path, '--hostname', hostname, '--repo', repo
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
data/ext/sass/package.json
CHANGED