mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
Ability to add the date and the version number from the command line.
This commit is contained in:
parent
7a4bf6ec26
commit
a6948ec413
@ -12,7 +12,7 @@ Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com
|
||||
# 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 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
|
||||
If you add a file in the src directory, add into the array in the Thorfile.
|
||||
|
26
Thorfile
26
Thorfile
@ -9,21 +9,23 @@ class Build < Thor
|
||||
]
|
||||
|
||||
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..."
|
||||
File.open("dist/kinetic.js", "w") do |file|
|
||||
file.puts concatenate()
|
||||
file.puts concatenate(version, options[:date])
|
||||
end
|
||||
puts " -> Done!"
|
||||
end
|
||||
|
||||
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..."
|
||||
require 'json/pure'
|
||||
require 'uglifier'
|
||||
File.open("dist/kinetic.min.js", "w") do |file|
|
||||
uglify = Uglifier.compile(concatenate())
|
||||
uglify = Uglifier.compile(concatenate(version, options[:date]))
|
||||
uglify.sub!(/\*\/ .+ \*\//xm, "*/")
|
||||
file.puts uglify
|
||||
end
|
||||
@ -31,21 +33,23 @@ class Build < Thor
|
||||
puts " -> Done!"
|
||||
end
|
||||
|
||||
desc "all", "Build the development and the production files."
|
||||
def all
|
||||
invoke :dev
|
||||
invoke :prod
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def concatenate
|
||||
def concatenate(version, date)
|
||||
date ||= Time.now.strftime("%b %d %Y")
|
||||
content = ""
|
||||
FILES.each do |file|
|
||||
content << IO.read(File.expand_path(file)) << "\n"
|
||||
end
|
||||
|
||||
# Add the version number
|
||||
content.sub!("@version", version)
|
||||
|
||||
# Add the date
|
||||
content.sub!("@date", date)
|
||||
|
||||
return content
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
1
dist/kinetic.js
vendored
1
dist/kinetic.js
vendored
@ -25,6 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Global Object
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,9 +1,9 @@
|
||||
/**
|
||||
* KineticJS JavaScript Library v3.8.3
|
||||
* KineticJS JavaScript Library v@version
|
||||
* http://www.kineticjs.com/
|
||||
* Copyright 2012, Eric Rowell
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Mar 03 2012
|
||||
* Date: @date
|
||||
*
|
||||
* Copyright (C) 2011 - 2012 by Eric Rowell
|
||||
*
|
||||
@ -24,4 +24,4 @@
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user