Skip to content

Commit 2e687ee

Browse files
committed
Add support for version numbers in the Rakefile
* version number is stored in version.yaml - work in progress is marked with version number that ends with '-snapshot' * all compiled files are stored in the './build/' directory without version numbers * :package task creates a tarball in the build directory - if version number contains '-snapshot', this substring is replaced with sha of the head - tarball contains version number in the filename - all js files contain version number in the filename * .gitignore was updated to reflect all these changes * the .map file is not created by the closure compiler any more
1 parent 7530eea commit 2e687ee

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
angular-minified.map
2-
angular.js
3-
angular-minified.js
4-
angular-debug.js
5-
angular-ie-compat.js
6-
angular-scenario.js
1+
build/
72
angularjs.netrc
83
jstd.log

Rakefile

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,15 @@ ANGULAR_SCENARIO = [
3434
'src/scenario/matchers.js',
3535
]
3636

37-
GENERATED_FILES = [
38-
'angular-debug.js',
39-
'angular-minified.js',
40-
'angular-minified.map',
41-
'angular-ie-compat.js',
42-
'angular-scenario.js',
43-
]
37+
BUILD_DIR = 'build'
4438

4539
task :default => [:compile, :test]
4640

4741

4842
desc 'Clean Generated Files'
4943
task :clean do
50-
FileUtils.rm(GENERATED_FILES, :force => true)
44+
FileUtils.rm_r(BUILD_DIR, :force => true)
45+
FileUtils.mkdir(BUILD_DIR)
5146
end
5247

5348

@@ -64,7 +59,7 @@ task :compile_scenario do
6459

6560
concat = 'cat ' + deps.flatten.join(' ')
6661

67-
File.open('angular-scenario.js', 'w') do |f|
62+
File.open(path_to('angular-scenario.js'), 'w') do |f|
6863
f.write(%x{#{concat}})
6964
f.write(gen_css('css/angular.css') + "\n")
7065
f.write(gen_css('css/angular-scenario.css'))
@@ -87,10 +82,11 @@ task :generate_ie_compat do
8782

8883
# create a js file with multipart header containing the extracted images. the entire file *must*
8984
# be CRLF (\r\n) delimited
90-
File.open('angular-ie-compat.js', 'w') do |f|
85+
File.open(path_to('angular-ie-compat.js'), 'w') do |f|
9186
f.write("/*\r\n" +
9287
"Content-Type: multipart/related; boundary=\"_\"\r\n" +
9388
"\r\n")
89+
9490
images.each_index do |idx|
9591
f.write("--_\r\n" +
9692
"Content-Location:img#{idx}\r\n" +
@@ -139,38 +135,44 @@ task :compile => [:compile_scenario, :generate_ie_compat] do
139135
'src/angular.suffix',
140136
]
141137

142-
File.open('angular-debug.js', 'w') do |f|
138+
File.open(path_to('angular.js'), 'w') do |f|
143139
concat = 'cat ' + deps.flatten.join(' ')
144140
f.write(%x{#{concat}})
145141
f.write(gen_css('css/angular.css', true))
146142
end
147143

148144
%x(java -jar lib/compiler-closure/compiler.jar \
149145
--compilation_level SIMPLE_OPTIMIZATIONS \
150-
--js angular-debug.js \
151-
--create_source_map ./angular-minified.map \
152-
--js_output_file angular-minified.js)
146+
--js #{path_to('angular.js')} \
147+
--js_output_file #{path_to('angular.min.js')})
153148
end
154149

155150

156151
desc 'Create angular distribution'
157152
task :package => :compile do
158-
date = Time.now.strftime('%y%m%d_%H%M')
159-
sha = %x(git rev-parse HEAD)[0..7]
160-
filename = "angular-#{date}-#{sha}.tgz"
161-
162-
%x(cp test/angular-mocks.js ./)
163-
164-
%x(tar -czf #{filename} \
165-
angular-debug.js \
166-
angular-minified.js \
167-
angular-scenario.js \
168-
angular-mocks.js \
169-
angular-ie-compat.js )
153+
v = YAML::load( File.open( 'version.yaml' ) )['version']
154+
match = v.match(/^([^-]*)(-snapshot)?$/)
155+
version = match[1] + (match[2] ? ('-' + %x(git rev-parse HEAD)[0..7]) : '')
156+
157+
tarball = "angular-#{version}.tgz"
158+
159+
pkg_dir = path_to("pkg/angular-#{version}")
160+
FileUtils.rm_r(path_to('pkg'), :force => true)
161+
FileUtils.mkdir_p(pkg_dir)
162+
163+
['test/angular-mocks.js',
164+
path_to('angular.js'),
165+
path_to('angular.min.js'),
166+
path_to('angular-ie-compat.js'),
167+
path_to('angular-scenario.js')
168+
].each do |src|
169+
dest = src.gsub(/^[^\/]+\//, '').gsub(/((\.min)?\.js)$/, "-#{version}\\1")
170+
FileUtils.cp(src, pkg_dir + '/' + dest)
171+
end
170172

171-
%x( rm angular-mocks.js)
173+
%x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .)
172174

173-
puts "Package created: #{filename}"
175+
puts "Package created: #{path_to(tarball)}"
174176
end
175177

176178

@@ -239,4 +241,12 @@ def gen_css(cssFile, minify = false)
239241
css.gsub! /\n/, "\\n"
240242

241243
return %Q{document.write('<style type="text/css">#{css}</style>');}
242-
end
244+
end
245+
246+
247+
##
248+
# returns path to the file in the build directory
249+
#
250+
def path_to(filename)
251+
return File.join(BUILD_DIR, filename)
252+
end

version.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# <angular/> build config file
2+
---
3+
version: 0.9.0-snapshot
4+
codename: dragonbreath

0 commit comments

Comments
 (0)