forked from sass/sass-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
174 lines (153 loc) · 5.04 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
require "html-proofer"
require "semantic"
require "yaml"
require File.dirname(__FILE__) + '/lib/raw_markdown_link'
task :test => [
"sass:dart:version", "sass:libsass:version", "sass:typedoc:build", :middleman,
:test_without_rebuild
]
task :test_without_rebuild do
HTMLProofer.check_directory("build",
url_ignore: [
"https://www.drupal.org/dcoc", # This doesn't allow automated requests.
# 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(#.*)?},
"#",
],
assume_extension: true,
# These have the same links as blog posts
file_ignore: ["blog.html", %r{blog/page/.*}],
# Lots of external URLs fail flakily on CI, so we just don't check them
# there.
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],
).run
end
namespace :sass do
# 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
# 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
end
end.compact.sort.reverse
(tags.find {|t| !t.pre} || tags.first).to_s
end
namespace :dart do
# Check out the latest commit of Dart Sass into the .dart-sass directory.
task :checkout do
unless Dir.exists?(".dart-sass")
sh %{git clone https://github.com/sass/dart-sass .dart-sass}
end
Dir.chdir(".dart-sass") do
sh %{git fetch}
if ENV["DART_SASS_REVISION"]
sh %{git checkout #{ENV["DART_SASS_REVISION"]}}
else
sh %{git checkout origin/main}
end
end
end
task :version => :checkout do
add_version 'dart', Dir.chdir(".dart-sass") {latest_stable_tag}
end
end
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")
sh %{git clone https://github.com/sass/migrator .sass-migrator}
end
Dir.chdir(".sass-migrator") do
sh %{git fetch}
if ENV["SASS_MIGRATOR_REVISION"]
sh %{git checkout #{ENV["SASS_MIGRATOR_REVISION"]}}
else
sh %{git checkout origin/main}
end
end
end
task :version => :checkout do
add_version 'migrator', Dir.chdir(".sass-migrator") {latest_stable_tag}
end
end
namespace :libsass do
# Check out the latest commit of LibSass into the .libsass directory.
task :checkout do
unless Dir.exists?(".libsass")
sh %{git clone https://github.com/sass/libsass .libsass}
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
end
task :version => :checkout do
add_version 'libsass', Dir.chdir(".libsass") {latest_stable_tag}
end
end
namespace :typedoc do
# Check out the latest commit of the Sass specification into the .language
# directory.
task :checkout do
unless Dir.exists?(".language")
sh %{git clone https://github.com/sass/sass .language}
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}
sh %{npx typedoc \
--plugin ../tool/typedoc-theme.js --theme sass-site \
--out ../source/documentation/js-api \
--cleanOutputDir \
js-api-doc/index.d.ts
}
end
sh %{rm -r source/documentation/js-api/assets}
end
end
desc "Import information from Sass implementations."
task :import => ["dart:version", "libsass:version", "typedoc:build"]
end
desc "Build the middleman-controlled portion of the site."
task :middleman do
sh %{bundle exec middleman build --verbose}
end
desc "Build the site."
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.
sh %{rm -rf .dart-sass .libsass}
sh %{bundle install --without=development}
end