forked from videojs/video.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
203 lines (149 loc) · 5.86 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
require 'rubygems'
require 'yaml'
require 'httparty'
namespace :build do
desc "Build version for current '/c/' CDN copy and locked in version"
task :current do
Rake::Task["build:source"].execute
cdn_version_num = "#{version['major']}.#{version['minor']}"
['c', cdn_version_num].each do |vsn|
Rake::Shell["mkdir dist/#{vsn}"]
File.open("dist/#{vsn}/video.js", "w+") do |file|
file.puts File.read("dist/video.min.js").sub('GENERATED_CDN_VSN', vsn)
end
Rake::Shell["cp dist/video-js.min.css dist/#{vsn}/video-js.css"]
Rake::Shell["cp dist/video-js.swf dist/#{vsn}/video-js.swf"]
Rake::Shell["cp dist/video-js.png dist/#{vsn}/video-js.png"]
Rake::Shell["cp dist/demo.html dist/#{vsn}/demo.html"]
Rake::Shell["cp dist/captions.vtt dist/#{vsn}/captions.vtt"]
end
Rake::Shell["mkdir dist/video-js"]
File.open("dist/video-js/video.min.js", "w+") do |file|
file.puts File.read("dist/video.min.js").sub('GENERATED_CDN_VSN', cdn_version_num)
end
File.open("dist/video-js/video.js", "w+") do |file|
file.puts File.read("dist/video.js").sub('GENERATED_CDN_VSN', cdn_version_num)
end
Rake::Shell["cp dist/video-js.min.css dist/video-js/video-js.min.css"]
Rake::Shell["cp dist/video-js.css dist/video-js/video-js.css"]
Rake::Shell["cp dist/video-js.swf dist/video-js/video-js.swf"]
Rake::Shell["cp dist/video-js.png dist/video-js/video-js.png"]
Rake::Shell["cp dist/demo.html dist/video-js/demo.html"]
Rake::Shell["cp dist/captions.vtt dist/video-js/captions.vtt"]
Rake::Shell["cd dist && zip -r video-js-#{version_number}.zip video-js && cd .."]
if `git name-rev --name-only HEAD`.strip != 'stable'
Rake::Log["*** WARNING: NOT ON STABLE BRANCH!!! ***"]
end
end
desc "Build source files for packaging"
task :source do
Rake::Log["Building Version: " << version_number]
if File.exist?("dist")
Rake::Shell["rm -r dist"]
end
# Make distribution folder
Rake::Shell["mkdir dist"]
Rake::Log["Combining source files"]
combined = ""
first_files = [ '_begin.js', 'core.js', 'lib.js' ]
first_files.each do |item|
Rake::Log[item]
combined << File.read("src/#{item}")
end
Dir.foreach('src') do |item|
next if (['.', '..', '.DS_Store', 'setup.js', '_end.js'] + first_files).include? item
combined << File.read("src/#{item}")
end
# combined << File.read("flash/swfobject.js")
combined << File.read("src/setup.js")
combined << File.read("src/_end.js")
Rake::Log["Adding version number"]
combined = combined.gsub('GENERATED_AT_BUILD', version_number)
File.open('dist/video.js', "w+") do |file|
file.puts "" << combined
end
Rake::Log["Copying CSS and updated version"]
File.open('dist/video-js.css', "w+") do |file|
file.puts File.read("design/video-js.css").gsub('GENERATED_AT_BUILD', version_number)
end
Rake::Log["Copying suppporting files"]
Rake::Shell["cp design/video-js.png dist/video-js.png"]
Rake::Shell["cp flash/video-js.swf dist/video-js.swf"]
Rake::Shell["cp build/release-files/README.md dist/README.md"]
Rake::Shell["cp build/release-files/demo.html dist/demo.html"]
Rake::Shell["cp build/release-files/captions.vtt dist/captions.vtt"]
Rake::Shell["cp LGPLv3-LICENSE.txt dist/LGPLv3-LICENSE.txt"]
Rake::Log["Minimizing JavaScript"]
Rake::Shell["java -jar build/lib/yuicompressor-2.4.7.jar dist/video.js -o dist/video.min.js"]
Rake::Log["Minimizing CSS"]
Rake::Shell["java -jar build/lib/yuicompressor-2.4.7.jar dist/video-js.css -o dist/video-js.min.css"]
Rake::Log[version_number << " Built"]
end
desc "Build list of source files for easy inclusion in projects"
task :js_source do
File.open("dev/source-list.js", "w+") do |file|
file.puts "var vjsSourceList = [];"
src_array = ["src/core", "src/lib"]
last = ["src/setup"] # "flash/swfobject",
exclude = [".", "..", ".DS_Store", "_end.js", "_begin.js"]
Dir.foreach('src') do |item|
next if exclude.include? item
item_name = "src/" << item.sub(".js", "")
next if (src_array + last).include? item_name
src_array << item_name
end
src_array = src_array + last
src_array.each do |item|
file.puts "vjsSourceList.push('#{item}')"
end
# file.puts "vjsSourceList.push('src/#{item.sub(".js", "")}')"
# file.puts "vjsSourceList.push('flash/swfobject.js')"
end
end
desc "Build list of source files for easy inclusion in projects"
task :source_html do
File.open("dev/source-list.html", "w+") do |file|
file.puts "<!-- Video.js Source Files -->"
src_array = ["src/core", "src/lib"]
last = ["src/setup"] # "flash/swfobject",
exclude = [".", "..", ".DS_Store", "_end.js", "_begin.js"]
Dir.foreach('src') do |item|
next if exclude.include? item
item_name = "src/" << item.sub(".js", "")
next if (src_array + last).include? item_name
src_array << item_name
end
src_array = src_array + last
src_array.each do |item|
file.puts "<script src='#{item}.js'></script>"
end
# file.puts "vjsSourceList.push('src/#{item.sub(".js", "")}')"
# file.puts "vjsSourceList.push('flash/swfobject.js')"
file.puts "<!-- END Video.js Source Files -->"
end
end
end
def version
YAML.load(File.read("VERSION.yml"))
end
def version_number
"#{version['major']}.#{version['minor']}.#{version['patch']}"
end
module Rake
class Shell
def self.[](command)
output = %x[#{command}]
if $?.to_i > 0
puts "-----> Process aborted"
puts " Exit status: #{$?}"
exit($?.to_i)
end
puts output
end
end
class Log
def self.[](message)
puts "-----> #{message.split("\n").join("\n ")}"
end
end
end