Gruntfile.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. module.exports = function(grunt) {
  2. var cfg = require('./package.json');
  3. grunt.initConfig({
  4. jshint: {
  5. options: {
  6. trailing: true
  7. },
  8. target: {
  9. src : [
  10. 'converse.js',
  11. 'mock.js',
  12. 'main.js',
  13. 'tests_main.js',
  14. 'spec/*.js'
  15. ]
  16. }
  17. },
  18. cssmin: {
  19. options: {
  20. banner: "/*"+
  21. "* Converse.js (Web-based XMPP instant messaging client) \n"+
  22. "* http://conversejs.org \n"+
  23. "* Copyright (c) 2012, Jan-Carel Brand <jc@opkode.com> \n"+
  24. "* Dual licensed under the MIT and GPL Licenses \n"+
  25. "*/"
  26. },
  27. minify: {
  28. dest: 'converse.min.css',
  29. src: ['converse.css']
  30. }
  31. },
  32. requirejs: {
  33. compile: {
  34. options: {
  35. baseUrl: ".",
  36. name: "main",
  37. out: "converse.min.js",
  38. paths: {
  39. "require": "components/requirejs/require",
  40. "jquery": "components/jquery/jquery",
  41. "jed": "components/jed/jed",
  42. "locales": "locale/locales",
  43. "af": "locale/af/LC_MESSAGES/af",
  44. "en": "locale/en/LC_MESSAGES/en",
  45. "de": "locale/de/LC_MESSAGES/de",
  46. "es": "locale/es/LC_MESSAGES/es",
  47. "it": "locale/it/LC_MESSAGES/it",
  48. "ru": "locale/ru/LC_MESSAGES/ru",
  49. "pt_BR": "locale/pt_BR/LC_MESSAGES/pt_BR",
  50. "tinysort": "components/tinysort/src/jquery.tinysort",
  51. "underscore": "components/underscore/underscore",
  52. "backbone": "components/backbone/backbone",
  53. "localstorage": "components/backbone.localStorage/backbone.localStorage",
  54. "strophe": "components/strophe/strophe",
  55. "strophe.muc": "components/strophe.muc/index",
  56. "strophe.roster": "components/strophe.roster/index",
  57. "strophe.vcard": "components/strophe.vcard/index",
  58. "strophe.disco": "components/strophe.disco/index"
  59. },
  60. done: function(done, output) {
  61. var duplicates = require('rjs-build-analysis').duplicates(output);
  62. if (duplicates.length > 0) {
  63. grunt.log.subhead('Duplicates found in requirejs build:');
  64. grunt.log.warn(duplicates);
  65. done(new Error('r.js built duplicate modules, please check the excludes option.'));
  66. }
  67. done();
  68. }
  69. }
  70. }
  71. }
  72. });
  73. grunt.loadNpmTasks('grunt-contrib-cssmin');
  74. grunt.loadNpmTasks('grunt-contrib-jshint');
  75. grunt.loadNpmTasks('grunt-contrib-requirejs');
  76. grunt.registerTask('test', 'Run Tests', function () {
  77. var done = this.async();
  78. var child_process = require('child_process');
  79. var exec = child_process.exec;
  80. exec('./node_modules/.bin/phantomjs '+
  81. 'node_modules/jasmine-reporters/test/phantomjs-testrunner.js '+
  82. __dirname+'/tests.html',
  83. function (err, stdout, stderr) {
  84. if (err) {
  85. grunt.log.write('Tests failed with error code '+err.code);
  86. grunt.log.write(stderr);
  87. }
  88. grunt.log.write(stdout);
  89. done();
  90. });
  91. });
  92. grunt.registerTask('fetch', 'Set up the development environment', function () {
  93. var done = this.async();
  94. var child_process = require('child_process');
  95. var exec = child_process.exec;
  96. exec('./node_modules/.bin/bower update && cd ./components/strophe && make normal',
  97. function (err, stdout, stderr) {
  98. if (err) {
  99. grunt.log.write('build failed with error code '+err.code);
  100. grunt.log.write(stderr);
  101. }
  102. grunt.log.write(stdout);
  103. done();
  104. });
  105. });
  106. grunt.registerTask('minify', 'Create a new release', ['cssmin', 'requirejs']);
  107. grunt.registerTask('check', 'Perform all checks (e.g. before releasing)', function () {
  108. grunt.task.run('jshint', 'test');
  109. });
  110. };