Clean up gruntfile and package.json, use grunt for yuidocs

This commit is contained in:
Chad Engler 2013-04-03 11:16:25 -04:00
parent 41e8a6eafa
commit 066228cc33
3 changed files with 156 additions and 127 deletions

View file

@ -1,79 +1,113 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
"use strict";
var root = "src/pixi/",
debug = "bin/pixi.dev.js",
build = "bin/pixi.js";
var root = 'src/pixi/',
debug = 'bin/pixi.dev.js',
srcFiles = [
'<%= dirs.src %>/Pixi.js',
'<%= dirs.src %>/Point.js',
'<%= dirs.src %>/Rectangle.js',
'<%= dirs.src %>/DisplayObject.js',
'<%= dirs.src %>/DisplayObjectContainer.js',
'<%= dirs.src %>/Sprite.js',
'<%= dirs.src %>/MovieClip.js',
'<%= dirs.src %>/InteractionManager.js',
'<%= dirs.src %>/Stage.js',
'<%= dirs.src %>/utils/Utils.js',
'<%= dirs.src %>/utils/EventTarget.js',
'<%= dirs.src %>/utils/Matrix.js',
'<%= dirs.src %>/utils/Detector.js',
'<%= dirs.src %>/renderers/WebGLShaders.js',
'<%= dirs.src %>/renderers/WebGLRenderer.js',
'<%= dirs.src %>/renderers/WebGLBatch.js',
'<%= dirs.src %>/renderers/CanvasRenderer.js',
'<%= dirs.src %>/extras/Strip.js',
'<%= dirs.src %>/extras/Rope.js',
'<%= dirs.src %>/textures/BaseTexture.js',
'<%= dirs.src %>/textures/Texture.js',
'<%= dirs.src %>/loaders/SpriteSheetLoader.js',
'<%= dirs.src %>/loaders/AssetLoader.js'
], banner = [
'/**',
' * @license',
' * <%= pkg.name %> - v<%= pkg.version %>',
' * Copyright (c) 2012, Mat Groves',
' * <%= pkg.homepage %>',
' *',
' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>',
' *',
' * <%= pkg.name %> is licensed under the <%= pkg.license %> License.',
' * <%= pkg.licenseUrl %>',
' */',
''
].join('\n');
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
build : {
all : {
dest : debug,
src : [
"Pixi.js",
"Point.js",
"Rectangle.js",
"DisplayObject.js",
"DisplayObjectContainer.js",
"Sprite.js",
"MovieClip.js",
"InteractionManager.js",
"Stage.js",
"utils/Utils.js",
"utils/EventTarget.js",
"utils/Matrix.js",
"utils/Detector.js",
"renderers/WebGLShaders.js",
"renderers/WebGLRenderer.js",
"renderers/WebGLBatch.js",
"renderers/CanvasRenderer.js",
"extras/Strip.js",
"extras/Rope.js",
"textures/BaseTexture.js",
"textures/Texture.js",
"loaders/SpriteSheetLoader.js",
"loaders/AssetLoader.js"
]
pkg : grunt.file.readJSON('package.json'),
dirs: {
build: 'bin',
docs: 'docs',
examples: 'examples',
src: 'src/pixi',
test: 'test'
},
files: {
srcBlob: '<%= dirs.src %>/**/*.js',
testBlob: '<%= dirs.test %>/unit/**/*.js',
build: '<%= dirs.build %>/pixi.dev.js',
buildMin: '<%= dirs.build %>/pixi.js'
},
concat: {
options: {
banner: banner
},
dist: {
src: srcFiles,
dest: '<%= files.build %>'
}
},
jshint: {
dist : {
src : [debug],
beforeconcat: srcFiles,
test: ['<%= files.testBlob %>'],
options: {
asi: true,
smarttabs: true
}
}
},
uglify: {
all : {
files : {
"bin/pixi.js" : [ debug ]
}
options: {
banner: banner
},
dist: {
src: '<%= files.build %>',
dest: '<%= files.buildMin %>'
}
},
distribute: {
examples: [
"examples/example 1 - Basics",
"examples/example 2 - SpriteSheet",
"examples/example 3 - MovieClip",
"examples/example 4 - Balls",
"examples/example 5 - Morph",
"examples/example 6 - Interactivity",
'examples/example 1 - Basics',
'examples/example 2 - SpriteSheet',
'examples/example 3 - MovieClip',
'examples/example 4 - Balls',
'examples/example 5 - Morph',
'examples/example 6 - Interactivity',
]
},
connect: {
qunit: {
options: {
port: grunt.option('port-test') | 9002,
port: grunt.option('port-test') || 9002,
base: './'
}
},
test: {
options: {
port: grunt.option('port-test') | 9002,
port: grunt.option('port-test') || 9002,
base: './',
keepalive: true
}
@ -85,34 +119,25 @@ module.exports = function(grunt){
urls: ['http://localhost:' + (grunt.option('port-test') || 9002) + '/test/index.html']
}
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
logo: '<%= pkg.logo %>',
options: {
paths: '<%= dirs.src %>',
outdir: '<%= dirs.docs %>'
}
}
}
});
grunt.registerMultiTask(
"build",
"Contatenate source",
function(){
var compiled = "",
name = this.data.dest,
src = this.data.src;
src.forEach(function(filepath){
compiled += grunt.file.read( root + filepath );
});
grunt.file.write(name, compiled);
grunt.log.writeln("File '" + name + "' created.");
}
)
grunt.registerMultiTask(
"distribute",
"Copy built file to examples",
'distribute',
'Copy built file to examples',
function(){
var pixi = grunt.file.read( debug );
@ -120,21 +145,17 @@ module.exports = function(grunt){
dests.forEach(function(filepath){
grunt.file.write(filepath + "/pixi.js", pixi);
grunt.file.write(filepath + '/pixi.js', pixi);
});
grunt.log.writeln("Pixi copied to examples.");
grunt.log.writeln('Pixi copied to examples.');
}
)
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');
//grunt.registerTask("default", ["build:*:*", "jshint", "uglify"]);
grunt.registerTask("default", ["build:*:*", "uglify", "distribute:*:*"])
grunt.registerTask('default', ['concat', 'uglify', 'distribute']);
grunt.registerTask('build', ['concat', 'uglify', 'distribute']);
grunt.registerTask('test', ['build', 'connect:qunit', 'qunit']);
grunt.registerTask('docs', ['yuidoc']);
}

View file

@ -1,11 +1,29 @@
{
"name": "Pixi.JS",
"version" : "0.0.1",
"version": "1.0.0",
"description": "Pixi.js is a fast lightweight 2D library that works across all devices.",
"author": "Mat Groves",
"logo": "http://www.goodboydigital.com/pixijs/logo_small.png",
"homepage": "http://goodboydigital.com/",
"bugs": "https://github.com/GoodBoyDigital/pixi.js/issues",
"license": "MIT",
"licenseUrl": "http://www.opensource.org/licenses/mit-license.php",
"repository": {
"type": "git",
"url": "https://github.com/GoodBoyDigital/pixi.js.git"
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.x",
"grunt-contrib-jshint" : "~0.1.1",
"grunt-contrib-uglify" : "~0.2.0",
"grunt-contrib-connect" : "0.x",
"grunt-contrib-qunit" : "0.x"
"grunt-contrib-jshint": "0.3.x",
"grunt-contrib-uglify": "0.2.x",
"grunt-contrib-connect": "0.2.x",
"grunt-contrib-qunit": "0.2.x",
"grunt-contrib-yuidoc": "0.4.x",
"grunt-contrib-concat": "0.1.x"
}
}

View file

@ -1,10 +0,0 @@
{
"name": "Pixi.js API",
"logo": "http://www.goodboydigital.com/pixijs/logo_small.png",
"description": "Pixi.js is a fast lightweight 2D library that works across all devices.",
"version": "1.0",
"url": "http://goodboydigital.com/",
"options": {
"outdir": "../docs"
}
}