-
Notifications
You must be signed in to change notification settings - Fork 268
/
Rakefile
86 lines (74 loc) · 2.28 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
require "json"
require "uglifier"
def package_info
JSON.parse(File.read('package.json'))
end
def update_json(file_path, updates)
json = JSON.parse(File.read(file_path))
json.merge!(updates)
File.write(file_path, JSON.pretty_generate(json) + "\n")
end
def format_options(options)
options.map { |key, value| "--#{key} #{value}" }.join(" ")
end
desc "Concat and uglify JavaScript"
task :build => [ 'lazy.js', 'lazy.browser.js' ] do |task|
version = package_info['version']
File.open('lazy.min.js', 'w') { |f|
content = task.prerequisites.map { |prereq|
if File.exist?(prereq)
File.read(prereq)
elsif Rake::Task[prereq].nil?
raise "Prerequisite #{prereq} does not exist."
end
}.compact.join("\n")
header = "/*! lazy.js #{version} (c)#{Time.now.year} Dan Tao @license MIT */"
minified = Uglifier.new.compile(content)
f.write(header + "\n" + minified + "\n")
}
end
desc "Update the library version in package.json and component.json"
task :update_version do
if (version = ENV['VERSION']).nil?
puts "Set the VERSION environment variable for this Rake task."
exit
end
update_json('package.json', { 'version' => version })
update_json('component.json', { 'version' => version })
end
desc "Setup symbolic links to lazy.js, etc. for project site"
task :symlinks do
sh <<-BASH
cd site/source/javascripts/lib
ln -s ../../../../lazy.js lazy.js
ln -s ../../../../lazy.browser.js lazy.browser.js
ln -s ../../../../lazy.min.js lazy.min.js
ln -s ../../../../experimental/lazy.json.js lazy.json.js
ln -s ../../../../experimental/lazy.es6.js lazy.es6.js
ln -s ../../../../spec spec
BASH
end
desc "Generate documentation using Autodoc"
task :generate_docs do
sequence_types = [
"Lazy",
"Sequence",
"ArrayLikeSequence",
"ObjectLikeSequence",
"StringLikeSequence",
"StreamLikeSequence",
"GeneratedSequence",
"AsyncSequence",
"Iterator",
"AsyncHandle"
]
options = {
:namespaces => sequence_types.join(","),
:template => "autodoc/index.html.mustache",
:handlers => "autodoc/handlers.js",
:partials => "autodoc/",
:output => "site/build/docs",
:'template-data' => "version:#{package_info['version']}"
}
sh "autodoc #{format_options(options)} lazy.js"
end