Ability to add the date and the version number from the command line.

This commit is contained in:
Antoine Proulx 2012-03-07 09:55:07 -05:00
parent 7a4bf6ec26
commit a6948ec413
4 changed files with 20 additions and 15 deletions

View File

@ -12,7 +12,7 @@ Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com
# Building the library # Building the library
To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`. To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`.
To build a development version of the library, run `thor build:dev`. To build a minify version of the library, run `thor build:prod`. To build a development version of the library, run `thor build:dev VERSION`, where VERSION is in the format MAJOR.MINOR.PATCH. To build a minify version of the library, run `thor build:prod VERSION`. If you want to add a release date other than the current day, use `-d="DATE"` (e.g. `-d="Mar 07 2012`).
# Adding a new file in the src directory # Adding a new file in the src directory
If you add a file in the src directory, add into the array in the Thorfile. If you add a file in the src directory, add into the array in the Thorfile.

View File

@ -9,21 +9,23 @@ class Build < Thor
] ]
desc "dev", "Concatenate all the js files into /dist/kinetic.js." desc "dev", "Concatenate all the js files into /dist/kinetic.js."
def dev method_option :date, aliases: "-d", required: false, type: :string, desc: "The release date"
def dev(version)
puts ":: Building the file /dist/kinetic.js..." puts ":: Building the file /dist/kinetic.js..."
File.open("dist/kinetic.js", "w") do |file| File.open("dist/kinetic.js", "w") do |file|
file.puts concatenate() file.puts concatenate(version, options[:date])
end end
puts " -> Done!" puts " -> Done!"
end end
desc "prod", "Concatenate all the js files in into /dist/kinetic.min.js and minify it." desc "prod", "Concatenate all the js files in into /dist/kinetic.min.js and minify it."
def prod method_option :date, aliases: "-d", required: false, type: :string, desc: "The release date"
def prod(version)
puts ":: Building the file /dist/kinetic.min.js..." puts ":: Building the file /dist/kinetic.min.js..."
require 'json/pure' require 'json/pure'
require 'uglifier' require 'uglifier'
File.open("dist/kinetic.min.js", "w") do |file| File.open("dist/kinetic.min.js", "w") do |file|
uglify = Uglifier.compile(concatenate()) uglify = Uglifier.compile(concatenate(version, options[:date]))
uglify.sub!(/\*\/ .+ \*\//xm, "*/") uglify.sub!(/\*\/ .+ \*\//xm, "*/")
file.puts uglify file.puts uglify
end end
@ -31,21 +33,23 @@ class Build < Thor
puts " -> Done!" puts " -> Done!"
end end
desc "all", "Build the development and the production files."
def all
invoke :dev
invoke :prod
end
private private
def concatenate def concatenate(version, date)
date ||= Time.now.strftime("%b %d %Y")
content = "" content = ""
FILES.each do |file| FILES.each do |file|
content << IO.read(File.expand_path(file)) << "\n" content << IO.read(File.expand_path(file)) << "\n"
end end
# Add the version number
content.sub!("@version", version)
# Add the date
content.sub!("@date", date)
return content return content
end end
end end

1
dist/kinetic.js vendored
View File

@ -25,6 +25,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// Global Object // Global Object
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,9 @@
/** /**
* KineticJS JavaScript Library v3.8.3 * KineticJS JavaScript Library v@version
* http://www.kineticjs.com/ * http://www.kineticjs.com/
* Copyright 2012, Eric Rowell * Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses. * Licensed under the MIT or GPL Version 2 licenses.
* Date: Mar 03 2012 * Date: @date
* *
* Copyright (C) 2011 - 2012 by Eric Rowell * Copyright (C) 2011 - 2012 by Eric Rowell
* *