From 489b7825c33c8c42ec80025bf8737e31c5931970 Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Sat, 1 Jun 2013 00:53:32 -0700 Subject: [PATCH] first pass at migrating the old Ruby build to Grunt --- .gitignore | 1 + Gruntfile.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 28 +++++++++++++++ src/Global.js | 8 ++--- 4 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 Gruntfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index d8269c24..6fcb6d37 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ jsdoc-master dist tests/js/unitTests.js analysis +node_modules # Numerous always-ignore extensions *.diff diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..63d02eab --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,94 @@ +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + concat: { + options: { + separator: ';' + }, + dist: { + src: [ + // core / anim + tween + dd + 'src/Global.js', + 'src/Util.js', + 'src/Canvas.js', + 'src/Node.js', + 'src/Animation.js', + 'src/Tween.js', + 'src/DragAndDrop.js', + 'src/Container.js', + 'src/Shape.js', + 'src/Stage.js', + 'src/Layer.js', + 'src/Group.js', + + // shapes + 'src/shapes/Rect.js', + 'src/shapes/Circle.js', + 'src/shapes/Wedge.js', + 'src/shapes/Image.js', + 'src/shapes/Polygon.js', + 'src/shapes/Text.js', + 'src/shapes/Line.js', + 'src/shapes/Spline.js', + 'src/shapes/Blob.js', + 'src/shapes/Sprite.js', + + // plugins + 'src/plugins/Path.js', + 'src/plugins/TextPath.js', + 'src/plugins/RegularPolygon.js', + 'src/plugins/Star.js', + 'src/plugins/Label.js', + + // filters + 'src/filters/Grayscale.js', + 'src/filters/Brighten.js', + 'src/filters/Invert.js', + 'src/filters/Blur.js', + 'src/filters/Mask.js' + ], + dest: 'dist/kinetic-v<%= pkg.version %>.js' + } + }, + replace: { + dist: { + options: { + variables: { + 'version': '<%= pkg.version %>', + 'date': '<%= grunt.template.today("yyyy-mm-dd") %>' + }, + prefix: '@@' + }, + files: [ + { + expand: true, + flatten: true, + src: ['dist/kinetic-v<%= pkg.version %>.js'], + dest: 'dist/' + } + ] + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> http://www.kineticjs.com - MIT License https://github.com/ericdrowell/KineticJS/wiki/License*/\n' + }, + build: { + src: 'dist/kinetic-v<%= pkg.version %>.js', + dest: 'dist/kinetic-v<%= pkg.version %>.min.js' + } + } + }); + + // Load plugins + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-replace'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + + // Tasks + grunt.registerTask('dev', ['concat', 'replace']); + grunt.registerTask('prod', ['concat', 'replace', 'uglify']); + +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..ef0af5f7 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "KineticJS", + "version": "4.5.4", + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.1.1", + "grunt-contrib-nodeunit": "~0.1.2", + "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-concat": "~0.3.0", + "grunt-replace": "~0.4.4" + }, + "readmeFilename": "README.md", + "gitHead": "7b9322c15c08b3ff78f64f5cfd3e9f88850dcadc", + "description": "To build the framework, you need to have Ruby and Rubygems installed. After that, run `gem install thor`, `gem install json_pure`, and `gem install uglifier` to install the dependencies.", + "main": "Gruntfile.js", + "directories": { + "test": "tests" + }, + "scripts": { + "test": "test" + }, + "repository": { + "type": "git", + "url": "git://github.com/ericdrowell/KineticJS.git" + }, + "author": "Eric Rowell", + "license": "MIT" +} diff --git a/src/Global.js b/src/Global.js index 755b24eb..c447373d 100644 --- a/src/Global.js +++ b/src/Global.js @@ -1,9 +1,9 @@ -/** - * KineticJS JavaScript Framework v{{version}} +/* + * KineticJS JavaScript Framework v@@version * http://www.kineticjs.com/ * Copyright 2013, Eric Rowell * Licensed under the MIT or GPL Version 2 licenses. - * Date: {{date}} + * Date: @@date * * Copyright (C) 2011 - 2013 by Eric Rowell * @@ -30,7 +30,7 @@ */ var Kinetic = {}; (function() { - Kinetic.version = '{{version}}'; + Kinetic.version = '@@version'; /** * @namespace Filters