@@ -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
4539task :default => [ :compile , :test ]
4640
4741
4842desc 'Clean Generated Files'
4943task :clean do
50- FileUtils . rm ( GENERATED_FILES , :force => true )
44+ FileUtils . rm_r ( BUILD_DIR , :force => true )
45+ FileUtils . mkdir ( BUILD_DIR )
5146end
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' ) } )
153148end
154149
155150
156151desc 'Create angular distribution'
157152task :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 ) } "
174176end
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
0 commit comments