2013-07-25 09:46:03 +02:00
|
|
|
module.exports = function(grunt) {
|
2013-07-30 22:28:26 +02:00
|
|
|
var cfg = require('./package.json');
|
2013-07-25 09:46:03 +02:00
|
|
|
grunt.initConfig({
|
|
|
|
jshint: {
|
2013-07-28 22:51:25 +02:00
|
|
|
options: {
|
|
|
|
trailing: true
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
src : [
|
|
|
|
'converse.js',
|
|
|
|
'mock.js',
|
|
|
|
'main.js',
|
|
|
|
'tests_main.js',
|
|
|
|
'spec/*.js'
|
|
|
|
]
|
|
|
|
}
|
2013-07-30 21:41:55 +02:00
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
options: {
|
|
|
|
banner: "/*"+
|
|
|
|
"* Converse.js (Web-based XMPP instant messaging client) \n"+
|
|
|
|
"* http://conversejs.org \n"+
|
|
|
|
"* Copyright (c) 2012, Jan-Carel Brand <jc@opkode.com> \n"+
|
|
|
|
"* Dual licensed under the MIT and GPL Licenses \n"+
|
|
|
|
"*/"
|
|
|
|
},
|
|
|
|
minify: {
|
2013-08-04 18:43:55 +02:00
|
|
|
dest: 'converse.min.css',
|
2013-07-30 21:41:55 +02:00
|
|
|
src: ['converse.css']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
requirejs: {
|
|
|
|
compile: {
|
|
|
|
options: {
|
|
|
|
baseUrl: ".",
|
|
|
|
name: "main",
|
2013-08-04 18:43:55 +02:00
|
|
|
out: "converse.min.js",
|
2013-07-30 21:41:55 +02:00
|
|
|
paths: {
|
2013-07-30 22:28:26 +02:00
|
|
|
"require": "components/requirejs/require",
|
2013-07-30 21:41:55 +02:00
|
|
|
"jquery": "components/jquery/jquery",
|
|
|
|
"jed": "components/jed/jed",
|
|
|
|
"locales": "locale/locales",
|
|
|
|
"af": "locale/af/LC_MESSAGES/af",
|
|
|
|
"en": "locale/en/LC_MESSAGES/en",
|
|
|
|
"de": "locale/de/LC_MESSAGES/de",
|
|
|
|
"es": "locale/es/LC_MESSAGES/es",
|
|
|
|
"it": "locale/it/LC_MESSAGES/it",
|
|
|
|
"pt_BR": "locale/pt_BR/LC_MESSAGES/pt_BR",
|
|
|
|
"tinysort": "components/tinysort/src/jquery.tinysort",
|
|
|
|
"underscore": "components/underscore/underscore",
|
|
|
|
"backbone": "components/backbone/backbone",
|
|
|
|
"localstorage": "components/backbone.localStorage/backbone.localStorage",
|
|
|
|
"strophe": "components/strophe/strophe",
|
|
|
|
"strophe.muc": "components/strophe.muc/index",
|
|
|
|
"strophe.roster": "components/strophe.roster/index",
|
|
|
|
"strophe.vcard": "components/strophe.vcard/index",
|
|
|
|
"strophe.disco": "components/strophe.disco/index"
|
2013-07-30 22:28:26 +02:00
|
|
|
},
|
|
|
|
done: function(done, output) {
|
|
|
|
var duplicates = require('rjs-build-analysis').duplicates(output);
|
|
|
|
if (duplicates.length > 0) {
|
|
|
|
grunt.log.subhead('Duplicates found in requirejs build:');
|
|
|
|
grunt.log.warn(duplicates);
|
|
|
|
done(new Error('r.js built duplicate modules, please check the excludes option.'));
|
|
|
|
}
|
|
|
|
done();
|
2013-07-30 21:41:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-25 09:46:03 +02:00
|
|
|
}
|
|
|
|
});
|
2013-07-30 21:41:55 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
2013-07-25 09:46:03 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
2013-07-30 21:41:55 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
|
|
|
|
2013-07-28 22:51:25 +02:00
|
|
|
grunt.registerTask('test', 'Run Tests', function () {
|
|
|
|
var done = this.async();
|
|
|
|
var child_process = require('child_process');
|
|
|
|
var exec = child_process.exec;
|
2013-07-30 23:39:24 +02:00
|
|
|
exec('./node_modules/.bin/phantomjs '+
|
2013-07-28 22:51:25 +02:00
|
|
|
'node_modules/jasmine-reporters/test/phantomjs-testrunner.js '+
|
|
|
|
__dirname+'/tests.html',
|
|
|
|
function (err, stdout, stderr) {
|
|
|
|
if (err) {
|
|
|
|
grunt.log.write('Tests failed with error code '+err.code);
|
|
|
|
grunt.log.write(stderr);
|
|
|
|
}
|
|
|
|
grunt.log.write(stdout);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2013-07-29 23:13:31 +02:00
|
|
|
|
2013-07-30 21:41:55 +02:00
|
|
|
grunt.registerTask('fetch', 'Set up the development environment', function () {
|
2013-07-29 23:13:31 +02:00
|
|
|
var done = this.async();
|
|
|
|
var child_process = require('child_process');
|
|
|
|
var exec = child_process.exec;
|
2013-08-21 23:57:39 +02:00
|
|
|
exec('./node_modules/.bin/bower update && cd ./components/strophe && make normal',
|
2013-07-29 23:13:31 +02:00
|
|
|
function (err, stdout, stderr) {
|
|
|
|
if (err) {
|
|
|
|
grunt.log.write('build failed with error code '+err.code);
|
|
|
|
grunt.log.write(stderr);
|
|
|
|
}
|
|
|
|
grunt.log.write(stdout);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-08-20 22:53:19 +02:00
|
|
|
grunt.registerTask('minify', 'Create a new release', ['cssmin', 'requirejs']);
|
2013-07-30 21:41:55 +02:00
|
|
|
|
2013-07-29 23:13:31 +02:00
|
|
|
grunt.registerTask('check', 'Perform all checks (e.g. before releasing)', function () {
|
2013-07-28 22:51:25 +02:00
|
|
|
grunt.task.run('jshint', 'test');
|
|
|
|
});
|
2013-07-25 09:46:03 +02:00
|
|
|
};
|