diff options
| author | Igor Minar | 2010-10-19 21:19:28 -0700 |
|---|---|---|
| committer | Igor Minar | 2010-10-20 14:48:35 -0700 |
| commit | 2e687ee56fb81e96c0f45b2655a1a723331e2d20 (patch) | |
| tree | e4019a9c621438178247994388bb5347fd36bd62 | |
| parent | 7530eea7035e26a0bcc358c8ef94c79debabddf4 (diff) | |
| download | angular.js-2e687ee56fb81e96c0f45b2655a1a723331e2d20.tar.bz2 | |
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
| -rw-r--r-- | .gitignore | 7 | ||||
| -rw-r--r-- | Rakefile | 68 | ||||
| -rw-r--r-- | version.yaml | 4 |
3 files changed, 44 insertions, 35 deletions
@@ -1,8 +1,3 @@ -angular-minified.map -angular.js -angular-minified.js -angular-debug.js -angular-ie-compat.js -angular-scenario.js +build/ angularjs.netrc jstd.log @@ -34,20 +34,15 @@ ANGULAR_SCENARIO = [ 'src/scenario/matchers.js', ] -GENERATED_FILES = [ - 'angular-debug.js', - 'angular-minified.js', - 'angular-minified.map', - 'angular-ie-compat.js', - 'angular-scenario.js', -] +BUILD_DIR = 'build' task :default => [:compile, :test] desc 'Clean Generated Files' task :clean do - FileUtils.rm(GENERATED_FILES, :force => true) + FileUtils.rm_r(BUILD_DIR, :force => true) + FileUtils.mkdir(BUILD_DIR) end @@ -64,7 +59,7 @@ task :compile_scenario do concat = 'cat ' + deps.flatten.join(' ') - File.open('angular-scenario.js', 'w') do |f| + File.open(path_to('angular-scenario.js'), 'w') do |f| f.write(%x{#{concat}}) f.write(gen_css('css/angular.css') + "\n") f.write(gen_css('css/angular-scenario.css')) @@ -87,10 +82,11 @@ task :generate_ie_compat do # create a js file with multipart header containing the extracted images. the entire file *must* # be CRLF (\r\n) delimited - File.open('angular-ie-compat.js', 'w') do |f| + File.open(path_to('angular-ie-compat.js'), 'w') do |f| f.write("/*\r\n" + "Content-Type: multipart/related; boundary=\"_\"\r\n" + "\r\n") + images.each_index do |idx| f.write("--_\r\n" + "Content-Location:img#{idx}\r\n" + @@ -139,7 +135,7 @@ task :compile => [:compile_scenario, :generate_ie_compat] do 'src/angular.suffix', ] - File.open('angular-debug.js', 'w') do |f| + File.open(path_to('angular.js'), 'w') do |f| concat = 'cat ' + deps.flatten.join(' ') f.write(%x{#{concat}}) f.write(gen_css('css/angular.css', true)) @@ -147,30 +143,36 @@ task :compile => [:compile_scenario, :generate_ie_compat] do %x(java -jar lib/compiler-closure/compiler.jar \ --compilation_level SIMPLE_OPTIMIZATIONS \ - --js angular-debug.js \ - --create_source_map ./angular-minified.map \ - --js_output_file angular-minified.js) + --js #{path_to('angular.js')} \ + --js_output_file #{path_to('angular.min.js')}) end desc 'Create angular distribution' task :package => :compile do - date = Time.now.strftime('%y%m%d_%H%M') - sha = %x(git rev-parse HEAD)[0..7] - filename = "angular-#{date}-#{sha}.tgz" - - %x(cp test/angular-mocks.js ./) - - %x(tar -czf #{filename} \ - angular-debug.js \ - angular-minified.js \ - angular-scenario.js \ - angular-mocks.js \ - angular-ie-compat.js ) + v = YAML::load( File.open( 'version.yaml' ) )['version'] + match = v.match(/^([^-]*)(-snapshot)?$/) + version = match[1] + (match[2] ? ('-' + %x(git rev-parse HEAD)[0..7]) : '') + + tarball = "angular-#{version}.tgz" + + pkg_dir = path_to("pkg/angular-#{version}") + FileUtils.rm_r(path_to('pkg'), :force => true) + FileUtils.mkdir_p(pkg_dir) + + ['test/angular-mocks.js', + path_to('angular.js'), + path_to('angular.min.js'), + path_to('angular-ie-compat.js'), + path_to('angular-scenario.js') + ].each do |src| + dest = src.gsub(/^[^\/]+\//, '').gsub(/((\.min)?\.js)$/, "-#{version}\\1") + FileUtils.cp(src, pkg_dir + '/' + dest) + end - %x( rm angular-mocks.js) + %x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .) - puts "Package created: #{filename}" + puts "Package created: #{path_to(tarball)}" end @@ -239,4 +241,12 @@ def gen_css(cssFile, minify = false) css.gsub! /\n/, "\\n" return %Q{document.write('<style type="text/css">#{css}</style>');} -end
\ No newline at end of file +end + + +## +# returns path to the file in the build directory +# +def path_to(filename) + return File.join(BUILD_DIR, filename) +end diff --git a/version.yaml b/version.yaml new file mode 100644 index 00000000..59c3c054 --- /dev/null +++ b/version.yaml @@ -0,0 +1,4 @@ +# <angular/> build config file +--- +version: 0.9.0-snapshot +codename: dragonbreath |
