forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
140 lines (115 loc) · 3.22 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
abort "Please use Ruby 1.9 to build Ember.js!" if RUBY_VERSION !~ /^1\.9/
require "bundler/setup"
require "erb"
require 'rake-pipeline'
require "colored"
def pipeline
Rake::Pipeline::Project.new("Assetfile")
end
def setup_uploader
require 'github_downloads'
uploader = GithubDownloads::Uploader.new
uploader.authorize
uploader
end
def upload_file(uploader, filename, description, file)
print "Uploading #{filename}..."
if uploader.upload_file(filename, description, file)
puts "Success"
else
puts "Failure"
end
end
def git_update
end
directory "tmp"
file "tmp/ember.js" => "tmp" do
cd "tmp" do
sh "git clone https://github.com/emberjs/ember.js.git"
end
end
task :update_ember_git => ["tmp/ember.js"] do
cd "tmp/ember.js" do
sh "git fetch origin"
sh "git reset --hard origin/master"
end
end
file "tmp/ember.js/dist/ember.js"
file "packages/ember/lib/main.js" => [:update_ember_git, "tmp/ember.js/dist/ember.js"] do
cd "tmp/ember.js" do
sh "rake dist"
cp "dist/ember.js", "../../packages/ember/lib/main.js"
end
end
namespace :ember do
desc "Update Ember.js to master (packages/ember/lib/main.js)"
task :update => "packages/ember/lib/main.js"
end
desc "Strip trailing whitespace for JavaScript files in packages"
task :strip_whitespace do
Dir["packages/**/*.js"].each do |name|
body = File.read(name)
File.open(name, "w") do |file|
file.write body.gsub(/ +\n/, "\n")
end
end
end
desc "Build ember-data.js"
task :dist do
puts "Building Ember Data..."
pipeline.invoke
puts "Done"
end
desc "Clean build artifacts from previous builds"
task :clean do
puts "Cleaning build..."
pipeline.clean
puts "Done"
end
desc "Upload latest Ember Data build to GitHub repository"
task :upload_latest => :dist do
uploader = setup_uploader
# Upload minified first, so non-minified shows up on top
upload_file(uploader, 'ember-data-latest.min.js', "Ember Data Master (minified)", "dist/ember-data.min.js")
upload_file(uploader, 'ember-data-latest.js', "Ember Data Master", "dist/ember-data.js")
end
desc "Run tests with phantomjs"
task :test, [:suite] => :dist do |t, args|
unless system("which phantomjs > /dev/null 2>&1")
abort "PhantomJS is not installed. Download from http://phantomjs.org"
end
suites = {
:default => ["package=all"],
:all => ["package=all",
"package=all&jquery=1.7.2&nojshint=true",
"package=all&extendprototypes=true&nojshint=true",
"package=all&extendprototypes=true&jquery=1.7.2&nojshint=true",
"package=all&dist=build&nojshint=true"]
}
if ENV['TEST']
opts = [ENV['TEST']]
else
suite = args[:suite] || :default
opts = suites[suite.to_sym]
end
unless opts
abort "No suite named: #{suite}"
end
cmd = opts.map do |opt|
"phantomjs tests/qunit/run-qunit.js \"file://localhost#{File.dirname(__FILE__)}/tests/index.html?#{opt}\""
end.join(' && ')
# Run the tests
puts "Running: #{opts.join(", ")}"
success = system(cmd)
if success
puts "Tests Passed".green
else
puts "Tests Failed".red
exit(1)
end
end
desc "Automatically run tests (Mac OS X only)"
task :autotest do
system("kicker -e 'rake test' packages")
end
task :default => :dist