2018-12-28 04:47:31 +01:00
|
|
|
require "html-proofer"
|
2018-12-28 02:36:35 +01:00
|
|
|
require "semantic"
|
|
|
|
require "yaml"
|
2013-10-12 21:49:34 +02:00
|
|
|
|
2018-12-28 02:32:59 +01:00
|
|
|
require File.dirname(__FILE__) + '/lib/raw_markdown_link'
|
|
|
|
|
2021-09-30 04:01:03 +02:00
|
|
|
task :test => [
|
|
|
|
"sass:dart:version", "sass:libsass:version", "sass:typedoc:build", :middleman,
|
|
|
|
:test_without_rebuild
|
|
|
|
]
|
2019-01-09 23:14:29 +01:00
|
|
|
|
|
|
|
task :test_without_rebuild do
|
|
|
|
HTMLProofer.check_directory("build",
|
2018-12-28 02:32:59 +01:00
|
|
|
url_ignore: [
|
|
|
|
"https://www.drupal.org/dcoc", # This doesn't allow automated requests.
|
2019-11-13 03:21:51 +01:00
|
|
|
# These are linked to from older blog posts. They redirect to updated
|
|
|
|
# pages.
|
|
|
|
%r{/documentation/file.SASS_REFERENCE.html(#.*)?},
|
|
|
|
%r{/documentation/file.SASS_CHANGELOG.html(#.*)?},
|
|
|
|
%r{/documentation/Sass/Script/Functions.html(#.*)?},
|
2019-03-09 02:57:33 +01:00
|
|
|
"#",
|
2018-12-28 02:32:59 +01:00
|
|
|
],
|
2019-01-09 23:14:29 +01:00
|
|
|
assume_extension: true,
|
2019-11-13 03:21:51 +01:00
|
|
|
# These have the same links as blog posts
|
|
|
|
file_ignore: ["blog.html", %r{blog/page/.*}],
|
2021-07-24 01:28:41 +02:00
|
|
|
# Lots of external URLs fail flakily on CI, so we just don't check them
|
2019-03-09 03:10:27 +01:00
|
|
|
# there.
|
2021-07-24 01:28:41 +02:00
|
|
|
disable_external: ENV["CI"] == "true",
|
|
|
|
# This error occurs (usually on GitHub) when the same IP requests a given
|
|
|
|
# domain too often.
|
|
|
|
http_status_ignore: [429],
|
2018-12-28 02:32:59 +01:00
|
|
|
).run
|
|
|
|
end
|
|
|
|
|
2018-03-09 22:26:45 +01:00
|
|
|
namespace :sass do
|
2018-03-16 00:04:43 +01:00
|
|
|
# Adds an implementation's version number to data/version.yml.
|
|
|
|
def add_version(impl, version)
|
|
|
|
path = 'data/version.yml'
|
|
|
|
yaml = File.exist?(path) ? YAML.load(File.read(path)) : {}
|
|
|
|
yaml[impl] = version
|
|
|
|
File.open(path, 'w') {|f| f.write(YAML.dump(yaml))}
|
|
|
|
end
|
2015-11-27 22:34:21 +01:00
|
|
|
|
2018-03-16 00:04:43 +01:00
|
|
|
# Returns the latest tag in the current Git repository that's a valid semantic
|
|
|
|
# version and is not a pre-release version *unless* only pre-release versions
|
|
|
|
# are available.
|
|
|
|
def latest_stable_tag
|
|
|
|
tags = `git tag`.strip.split("\n").map do |v|
|
|
|
|
begin
|
|
|
|
Semantic::Version.new(v)
|
|
|
|
rescue ArgumentError
|
|
|
|
nil
|
2018-03-09 22:26:45 +01:00
|
|
|
end
|
2018-03-16 00:04:43 +01:00
|
|
|
end.compact.sort.reverse
|
|
|
|
(tags.find {|t| !t.pre} || tags.first).to_s
|
2018-03-09 22:26:45 +01:00
|
|
|
end
|
2015-11-27 22:34:21 +01:00
|
|
|
|
2018-03-16 00:04:43 +01:00
|
|
|
namespace :dart do
|
|
|
|
# Check out the latest commit of Dart Sass into the .dart-sass directory.
|
|
|
|
task :checkout do
|
|
|
|
unless Dir.exists?(".dart-sass")
|
2022-03-25 23:27:21 +01:00
|
|
|
sh %{git clone https://github.com/sass/dart-sass .dart-sass}
|
2018-03-16 00:04:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(".dart-sass") do
|
|
|
|
sh %{git fetch}
|
|
|
|
if ENV["DART_SASS_REVISION"]
|
|
|
|
sh %{git checkout #{ENV["DART_SASS_REVISION"]}}
|
|
|
|
else
|
2021-07-24 01:28:41 +02:00
|
|
|
sh %{git checkout origin/main}
|
2018-03-16 00:04:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :version => :checkout do
|
|
|
|
add_version 'dart', Dir.chdir(".dart-sass") {latest_stable_tag}
|
|
|
|
end
|
2013-10-12 21:49:34 +02:00
|
|
|
end
|
|
|
|
|
2019-09-25 15:24:50 +02:00
|
|
|
namespace :migrator do
|
|
|
|
# Check out the latest commit of the Sass migrator into the .sass-migrator directory.
|
|
|
|
task :checkout do
|
|
|
|
unless Dir.exists?(".sass-migrator")
|
2022-03-25 23:27:21 +01:00
|
|
|
sh %{git clone https://github.com/sass/migrator .sass-migrator}
|
2019-09-25 15:24:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(".sass-migrator") do
|
|
|
|
sh %{git fetch}
|
|
|
|
if ENV["SASS_MIGRATOR_REVISION"]
|
|
|
|
sh %{git checkout #{ENV["SASS_MIGRATOR_REVISION"]}}
|
|
|
|
else
|
2021-07-24 01:28:41 +02:00
|
|
|
sh %{git checkout origin/main}
|
2019-09-25 15:24:50 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :version => :checkout do
|
|
|
|
add_version 'migrator', Dir.chdir(".sass-migrator") {latest_stable_tag}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-16 00:04:43 +01:00
|
|
|
namespace :libsass do
|
2021-09-30 04:01:03 +02:00
|
|
|
# Check out the latest commit of LibSass into the .libsass directory.
|
2018-03-16 00:04:43 +01:00
|
|
|
task :checkout do
|
|
|
|
unless Dir.exists?(".libsass")
|
2022-03-25 23:27:21 +01:00
|
|
|
sh %{git clone https://github.com/sass/libsass .libsass}
|
2018-03-16 00:04:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(".libsass") do
|
|
|
|
sh %{git fetch}
|
|
|
|
if ENV["LIBSASS_REVISION"]
|
|
|
|
sh %{git checkout #{ENV["LIBSASS_REVISION"]}}
|
|
|
|
else
|
|
|
|
sh %{git checkout origin/master}
|
|
|
|
end
|
|
|
|
end
|
2014-03-08 03:16:15 +01:00
|
|
|
end
|
2013-10-12 21:49:34 +02:00
|
|
|
|
2018-03-16 00:04:43 +01:00
|
|
|
task :version => :checkout do
|
|
|
|
add_version 'libsass', Dir.chdir(".libsass") {latest_stable_tag}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-30 04:01:03 +02:00
|
|
|
namespace :typedoc do
|
|
|
|
# Check out the latest commit of the Sass specification into the .language
|
|
|
|
# directory.
|
|
|
|
task :checkout do
|
|
|
|
unless Dir.exists?(".language")
|
2022-03-25 23:27:21 +01:00
|
|
|
sh %{git clone https://github.com/sass/sass .language}
|
2021-09-30 04:01:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(".language") do
|
|
|
|
sh %{git fetch}
|
|
|
|
if ENV["LANGUAGE_REVISION"]
|
|
|
|
sh %{git checkout #{ENV["LANGUAGE_REVISION"]}}
|
|
|
|
else
|
|
|
|
sh %{git checkout origin/main}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :build => :checkout do
|
|
|
|
Dir.chdir(".language") do
|
|
|
|
sh %{npm install}
|
|
|
|
sh %{ln -sf ../.language/node_modules ../tool/node_modules}
|
2023-05-09 23:44:42 +02:00
|
|
|
sh %{npm run typedoc -- \
|
2021-09-30 04:01:03 +02:00
|
|
|
--plugin ../tool/typedoc-theme.js --theme sass-site \
|
|
|
|
--out ../source/documentation/js-api \
|
2023-05-09 23:44:42 +02:00
|
|
|
--cleanOutputDir
|
2021-09-30 04:01:03 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
sh %{rm -r source/documentation/js-api/assets}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-16 00:04:43 +01:00
|
|
|
desc "Import information from Sass implementations."
|
2021-09-30 04:01:03 +02:00
|
|
|
task :import => ["dart:version", "libsass:version", "typedoc:build"]
|
2018-03-09 22:26:45 +01:00
|
|
|
end
|
2013-10-13 22:11:01 +02:00
|
|
|
|
|
|
|
desc "Build the middleman-controlled portion of the site."
|
|
|
|
task :middleman do
|
2016-01-12 19:38:22 +01:00
|
|
|
sh %{bundle exec middleman build --verbose}
|
2013-10-13 22:11:01 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build the site."
|
2018-03-09 22:36:13 +01:00
|
|
|
task "build" => ["sass:import", :middleman]
|
|
|
|
|
|
|
|
# Build the site on Heroku, then clean up unnecessary intermediate files.
|
|
|
|
task "assets:precompile" => :build do
|
|
|
|
# Clean up unneccessary files to reduce slug size.
|
2019-04-18 02:42:31 +02:00
|
|
|
sh %{rm -rf .dart-sass .libsass}
|
2018-03-09 22:36:13 +01:00
|
|
|
sh %{bundle install --without=development}
|
|
|
|
end
|