forked from jinzhu/vrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (59 loc) · 2.3 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
require 'bundler/setup'
require 'json'
def build_scss_files
`find coffee -type f -iname '*scss'`.split("\n").each do |file|
css_file = file.sub(/scss$/, 'css').sub(/coffee/, 'src')
system "mkdir -p #{File.dirname(css_file)}"
`scss #{file} > #{css_file}`
puts "Generated css file #{css_file}"
end
end
desc 'Init Development Environment'
task :init_development_env do
# Install CoffeeScript
`find coffee -type f -iname '*coffee'`.split("\n").each do |file|
js_file = file.sub(/coffee$/, "js").sub(/coffee/, 'src')
`coffee -m -o #{File.dirname(js_file)} -c #{file}`
puts "Generated js file #{js_file}"
end
build_scss_files
end
desc 'Build Vrome'
task :build do
`find coffee -type f -iname '*coffee'`.split("\n").each do |file|
js_file = file.sub(/coffee$/, 'js').sub(/coffee/, 'src')
`coffee -o #{File.dirname(js_file)} -c #{file}`
puts "Generated js file #{js_file}"
end
build_scss_files
system('bundle exec bluecloth README.mkd > ./src/README.html')
system('bundle exec bluecloth Features.mkd > ./src/background/html/features.html')
system('bundle exec bluecloth ChangeLog.mkd > ./src/background/html/changelog.html')
system('bundle exec bluecloth Thanks.mkd > ./src/background/html/thanks.html')
file = File.join(File.dirname(__FILE__), 'src', 'manifest_pretty.json')
json = JSON.parse(File.read(file))
json['version'] = File.read('Version').strip
Dir.chdir('src') do
json['content_scripts'][0]['js'] =
['shared/vendor/jquery.js', 'shared/vendor/jquery.scrollable.js', 'shared/vendor/jquery.highlight.js']
.concat(Dir['shared/*.js'])
.concat(Dir['frontend/modules/*.js'])
.concat(Dir['frontend/*.js'])
json['content_scripts'][0]['css'] = ['styles/main.css']
json['background']['scripts'] =
['shared/vendor/jquery.js', 'shared/vendor/FileSaver.js']
.concat(Dir['shared/*.js'])
.concat(Dir['background/*.js'])
.concat(Dir['background/modules/*.js'])
.concat(Dir['oauth/*.js'])
end
File.open(File.join(File.dirname(__FILE__), 'src', 'manifest.json'), 'w+') do |f|
f << json.to_json
end
end
task :zip do
# TODO: minify JS files?
system('find -iname "*map" | xargs rm')
system('rm vrome.zip; zip -r vrome.zip src/; cp vrome.zip ~')
end
task :default => [:build, :zip]