forked from jinzhu/vrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
64 lines (55 loc) · 2.01 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
require 'rake'
require 'rubygems'
require 'builder'
require 'crxmake'
require 'json'
desc 'preinstall'
task :preinstall do
file = File.join(File.dirname(__FILE__),'preinstall.sh')
`sh #{file}` if File.exist?(file)
end
desc 'build extension'
task :build => [:build_xml,:build_readme] do
CrxMake.make(
:ex_dir => "src",
:pkey => "vrome.pem",
:crx_output => "vrome.crx",
:ignoredir => /\.git/
)
end
task :build_readme do
system("bluecloth README.mkd > ./src/README.html")
end
task :build_manifest do
file = File.join(File.dirname(__FILE__),'src','manifest.json')
json = JSON.parse(File.read(file))
json["version"] = File.read('Version').strip
Dir.chdir('src')
json["content_scripts"][0]["js"] = Dir['shared/*.js'].concat(Dir['frontend/modules/*.js']).concat(["frontend/main.js" ])
json["content_scripts"][0]["css"] = ['styles/main.css']
# json["content_scripts"][1]["js"] = Dir['shared/*.js'].concat(Dir['frontend/modules/*.js']).concat(["frontend/main.js" ])
# json["content_scripts"][1]["css"] = ['styles/main.css']
Dir.chdir('..')
File.open(file,'w+') do |f|
f << json.to_json
end
end
desc "build xml"
task :build_xml => [:build_manifest] do
file = File.join(File.dirname(__FILE__),'src','manifest.json')
version = JSON.parse(File.read(file))['version']
xml = Builder::XmlMarkup.new(:target => File.open('../vrome-updates.xml','w+'), :indent => 2)
xml.instruct!
xml.gupdate(:xmlns => 'http://www.google.com/update2/response',:protocol => '2.0') do |x|
x.app(:appid => 'iiffmolbankaonfoniihhpbpclcenokk') do |y|
y.updatecheck(:codebase => 'http://github.com/jinzhu/vrome/raw/master/vrome.crx',:version => version)
end
end
end
desc 'install extension'
task :install => [:preinstall,:build] do
system("chromium-browser #{File.join(File.dirname(__FILE__),'vrome.crx')}") || \
system("chromium-bin #{File.join(File.dirname(__FILE__),'vrome.crx')}") || \
system("chromium #{File.join(File.dirname(__FILE__),'vrome.crx')}")
end
task :default => [:install]