From 1ec3fef131eb188a95d0ce38c4088e3ab3e688d9 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 30 Jul 2013 21:41:55 +0200 Subject: [PATCH] Add Grunt tasks to help with creating releases. --- Gruntfile.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++- build.js | 26 ------------------- package.json | 4 ++- 3 files changed, 73 insertions(+), 28 deletions(-) delete mode 100644 build.js diff --git a/Gruntfile.js b/Gruntfile.js index 229f396aa..b969b268b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,9 +13,56 @@ module.exports = function(grunt) { 'spec/*.js' ] } + }, + cssmin: { + options: { + banner: "/*"+ + "* Converse.js (Web-based XMPP instant messaging client) \n"+ + "* http://conversejs.org \n"+ + "* Copyright (c) 2012, Jan-Carel Brand \n"+ + "* Dual licensed under the MIT and GPL Licenses \n"+ + "*/" + }, + minify: { + dest: 'converse.min.css', + src: ['converse.css'] + } + }, + requirejs: { + compile: { + options: { + baseUrl: ".", + name: "main", + out: "converse.min.js", + paths: { + "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", + "sjcl": "components/sjcl/sjcl", + "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" + } + } + } } }); + grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-requirejs'); + grunt.registerTask('test', 'Run Tests', function () { var done = this.async(); var child_process = require('child_process'); @@ -33,7 +80,7 @@ module.exports = function(grunt) { }); }); - grunt.registerTask('build', 'Set up the development environment', function () { + grunt.registerTask('fetch', 'Set up the development environment', function () { var done = this.async(); var child_process = require('child_process'); var exec = child_process.exec; @@ -48,6 +95,28 @@ module.exports = function(grunt) { }); }); + grunt.registerTask('minify', 'Minify JC and CSS files', ['requirejs', 'cssmin']); + + grunt.registerTask('rename', 'Rename minified files to include version number', function () { + var cfg = require('./package.json'); + grunt.log.write('The release version is '+cfg.version); + var done = this.async(); + var child_process = require('child_process'); + var exec = child_process.exec; + exec('mv converse.min.js converse-'+cfg.version+'.min.js &&'+ + 'mv converse.min.css converse-'+cfg.version+'.min.css', + function (err, stdout, stderr) { + if (err) { + grunt.log.write('rename failed with error code '+err.code); + grunt.log.write(stderr); + } + grunt.log.write(stdout); + done(); + }); + }); + + grunt.registerTask('release', 'Create a new release', ['minify', 'rename']); + grunt.registerTask('check', 'Perform all checks (e.g. before releasing)', function () { grunt.task.run('jshint', 'test'); }); diff --git a/build.js b/build.js deleted file mode 100644 index f86415639..000000000 --- a/build.js +++ /dev/null @@ -1,26 +0,0 @@ -({ - baseUrl: ".", - paths: { - "jquery": "Libraries/require-jquery", - "jed": "Libraries/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", - "sjcl": "Libraries/sjcl", - "tinysort": "Libraries/jquery.tinysort", - "underscore": "Libraries/underscore", - "backbone": "Libraries/backbone", - "localstorage": "Libraries/backbone.localStorage", - "strophe": "Libraries/strophe", - "strophe.muc": "Libraries/strophe.muc", - "strophe.roster": "Libraries/strophe.roster", - "strophe.vcard": "Libraries/strophe.vcard", - "strophe.disco": "Libraries/strophe.disco" - }, - name: "main", - out: "converse.min.js" -}) diff --git a/package.json b/package.json index 93cf0fded..7786fd926 100755 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "grunt-contrib-jshint": "~0.6.0", "phantomjs": "~1.9.1-0", "jasmine-reporters": "~0.2.1", - "bower": "~1.0.0" + "bower": "~1.0.0", + "grunt-contrib-requirejs": "~0.4.1", + "grunt-contrib-cssmin": "~0.6.1" } }