2012-11-25 22:59:31 +04:00
|
|
|
/*global module:false*/
|
2014-09-08 22:16:30 +04:00
|
|
|
var _ = require('lodash'), path = require('path');
|
2014-09-20 18:36:15 +04:00
|
|
|
var proxy = require('html2canvas-proxy');
|
2014-08-26 21:01:15 +04:00
|
|
|
|
2012-11-25 22:59:31 +04:00
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
var meta = {
|
|
|
|
banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' +
|
|
|
|
'<%= pkg.homepage ? " <" + pkg.homepage + ">" : "" %>' + '\n' +
|
|
|
|
' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
|
|
|
|
'\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/\n',
|
|
|
|
pre: '\n(function(window, document, undefined){\n\n',
|
2014-09-04 21:50:31 +04:00
|
|
|
post: '\n})(window, document);'
|
2014-01-19 20:04:27 +04:00
|
|
|
};
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
qunit: {
|
|
|
|
files: ['tests/qunit/index.html']
|
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
dist: {
|
|
|
|
src: [
|
2014-09-14 20:32:26 +04:00
|
|
|
'src/promise.js', 'src/fallback.js', 'src/punycode/punycode.js', 'src/core.js', 'src/*.js', 'src/renderers/*.js'
|
2014-01-19 20:04:27 +04:00
|
|
|
],
|
2014-09-04 21:50:31 +04:00
|
|
|
dest: 'dist/<%= pkg.name %>.js',
|
|
|
|
options:{
|
|
|
|
banner: meta.banner + meta.pre,
|
|
|
|
footer: meta.post
|
|
|
|
}
|
2014-01-19 20:04:27 +04:00
|
|
|
},
|
2014-09-04 21:50:31 +04:00
|
|
|
svg: {
|
|
|
|
src: [
|
|
|
|
'src/fabric/dist/fabric.js'
|
|
|
|
],
|
|
|
|
dest: 'dist/<%= pkg.name %>.svg.js',
|
|
|
|
options:{
|
|
|
|
banner: meta.banner + '\n(function(window, document, exports, undefined){\n\n',
|
2014-09-14 20:32:26 +04:00
|
|
|
footer: '\n}).call({}, window, document, html2canvas);'
|
2014-09-04 21:50:31 +04:00
|
|
|
}
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
|
|
|
},
|
2014-09-20 18:36:15 +04:00
|
|
|
express: {
|
2014-01-19 20:04:27 +04:00
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 8080,
|
2014-09-20 18:36:15 +04:00
|
|
|
bases: './'
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
2014-05-18 18:39:24 +04:00
|
|
|
},
|
2014-05-18 18:40:01 +04:00
|
|
|
cors: {
|
|
|
|
options: {
|
|
|
|
port: 8081,
|
2014-09-20 18:36:15 +04:00
|
|
|
bases: './',
|
|
|
|
middleware: [
|
|
|
|
function(req, res, next) {
|
|
|
|
if (req.url !== '/tests/assets/image2.jpg') {
|
|
|
|
next();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
res.end(require("fs").readFileSync('tests/assets/image2.jpg'));
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
proxy: {
|
|
|
|
options: {
|
|
|
|
port: 8082,
|
|
|
|
middleware: [proxy()]
|
2014-05-18 18:40:01 +04:00
|
|
|
}
|
|
|
|
},
|
2014-05-18 18:39:24 +04:00
|
|
|
ci: {
|
|
|
|
options: {
|
|
|
|
port: 8080,
|
2014-09-20 18:36:15 +04:00
|
|
|
bases: './'
|
2014-05-18 18:39:24 +04:00
|
|
|
}
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
|
|
|
},
|
2014-09-08 22:16:30 +04:00
|
|
|
execute: {
|
|
|
|
fabric: {
|
|
|
|
options: {
|
|
|
|
args: ['modules=' + ['text','serialization',
|
|
|
|
'parser', 'gradient', 'pattern', 'shadow', 'freedrawing',
|
|
|
|
'image_filters', 'serialization'].join(","), 'no-es5-compat', 'dest=' + path.resolve(__dirname, 'src/fabric/dist/') + '/']
|
|
|
|
},
|
|
|
|
src: ['src/fabric/build.js']
|
|
|
|
}
|
|
|
|
},
|
2014-01-19 20:04:27 +04:00
|
|
|
uglify: {
|
|
|
|
dist: {
|
|
|
|
src: ['<%= concat.dist.dest %>'],
|
2014-09-01 21:22:56 +04:00
|
|
|
dest: 'dist/<%= pkg.name %>.min.js'
|
2014-01-19 20:04:27 +04:00
|
|
|
},
|
2014-09-04 21:50:31 +04:00
|
|
|
svg: {
|
|
|
|
src: ['<%= concat.svg.dest %>'],
|
|
|
|
dest: 'dist/<%= pkg.name %>.svg.min.js'
|
|
|
|
},
|
2014-01-19 20:04:27 +04:00
|
|
|
options: {
|
|
|
|
banner: meta.banner
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2014-09-08 22:16:30 +04:00
|
|
|
files: ['src/**/*', '!src/fabric/**/*'],
|
2014-01-26 20:10:04 +04:00
|
|
|
tasks: ['jshint', 'build']
|
2014-01-19 20:04:27 +04:00
|
|
|
},
|
|
|
|
jshint: {
|
2014-09-04 21:50:31 +04:00
|
|
|
all: ['src/*.js', 'src/renderers/*.js', '!src/promise.js'],
|
2014-01-19 20:04:27 +04:00
|
|
|
options: grunt.file.readJSON('./.jshintrc')
|
2014-08-26 21:01:15 +04:00
|
|
|
},
|
|
|
|
webdriver: {
|
|
|
|
chrome: {
|
|
|
|
browserName: "chrome",
|
|
|
|
platform: "Windows 7",
|
|
|
|
version: "34"
|
|
|
|
},
|
|
|
|
firefox: {
|
|
|
|
browserName: "firefox",
|
|
|
|
version: "15",
|
|
|
|
platform: "Windows 7"
|
|
|
|
},
|
|
|
|
ie9: {
|
|
|
|
browserName: "internet explorer",
|
|
|
|
version: "9",
|
|
|
|
platform: "Windows 7"
|
|
|
|
},
|
|
|
|
ie10: {
|
|
|
|
browserName: "internet explorer",
|
|
|
|
version: "10",
|
|
|
|
platform: "Windows 8"
|
|
|
|
},
|
|
|
|
ie11: {
|
|
|
|
browserName: "internet explorer",
|
|
|
|
version: "11",
|
|
|
|
platform: "Windows 8.1"
|
|
|
|
},
|
|
|
|
safari6: {
|
|
|
|
browserName: "safari",
|
|
|
|
version: "6",
|
|
|
|
platform: "OS X 10.8"
|
|
|
|
},
|
|
|
|
safari7:{
|
|
|
|
browserName: "safari",
|
|
|
|
platform: "OS X 10.9",
|
|
|
|
version: "7"
|
|
|
|
},
|
|
|
|
chromeOSX:{
|
|
|
|
browserName: "chrome",
|
|
|
|
platform: "OS X 10.8",
|
|
|
|
version: "34"
|
|
|
|
}
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
|
|
|
});
|
2012-11-25 22:59:31 +04:00
|
|
|
|
2014-08-26 22:03:54 +04:00
|
|
|
grunt.registerTask('webdriver', 'Browser render tests', function(browser, test) {
|
2014-01-19 20:04:27 +04:00
|
|
|
var selenium = require("./tests/selenium.js");
|
|
|
|
var done = this.async();
|
2014-08-26 22:03:54 +04:00
|
|
|
var browsers = (browser) ? [grunt.config.get(this.name + "." + browser)] : _.values(grunt.config.get(this.name));
|
2014-09-18 23:25:37 +04:00
|
|
|
selenium.tests(browsers, test).catch(function() {
|
|
|
|
done(false);
|
|
|
|
}).finally(function() {
|
2014-09-17 01:11:47 +04:00
|
|
|
console.log("Done");
|
|
|
|
done();
|
|
|
|
});
|
2014-01-19 20:04:27 +04:00
|
|
|
});
|
2012-12-29 17:02:05 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
2014-09-20 18:36:15 +04:00
|
|
|
grunt.loadNpmTasks('grunt-express');
|
2014-09-08 22:16:30 +04:00
|
|
|
grunt.loadNpmTasks('grunt-execute');
|
2013-03-22 06:40:09 +04:00
|
|
|
|
2014-09-20 18:36:15 +04:00
|
|
|
grunt.registerTask('server', ['express:cors', 'express:proxy', 'express:server', 'express-keepalive']);
|
2014-09-08 22:16:30 +04:00
|
|
|
grunt.registerTask('build', ['execute', 'concat', 'uglify']);
|
2014-09-09 00:43:00 +04:00
|
|
|
grunt.registerTask('default', ['jshint', 'build', 'qunit']);
|
2014-09-20 18:36:15 +04:00
|
|
|
grunt.registerTask('travis', ['jshint', 'build','qunit', 'express:ci', 'express:cors', 'webdriver']);
|
2012-11-25 22:59:31 +04:00
|
|
|
|
|
|
|
};
|