Gruntfile.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. module.exports = function (grunt) {
  2. 'use strict';
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. uglify : {
  6. target: {
  7. files: {
  8. 'build/js/bootstrap-datetimepicker.min.js' : 'src/js/bootstrap-datetimepicker.js'
  9. }
  10. },
  11. options: {
  12. mangle: true,
  13. compress: {
  14. dead_code: false // jshint ignore:line
  15. },
  16. output: {
  17. ascii_only: true // jshint ignore:line
  18. },
  19. report: 'min',
  20. preserveComments: 'some'
  21. }
  22. },
  23. jshint: {
  24. all: [
  25. 'Gruntfile.js', 'src/js/*.js', 'test/*.js'
  26. ],
  27. options: {
  28. 'browser' : true,
  29. 'node' : true,
  30. 'jquery' : true,
  31. 'boss' : false,
  32. 'curly' : true,
  33. 'debug' : false,
  34. 'devel' : false,
  35. 'eqeqeq' : true,
  36. 'bitwise' : true,
  37. 'eqnull' : true,
  38. 'evil' : false,
  39. 'forin' : true,
  40. 'immed' : false,
  41. 'laxbreak' : false,
  42. 'newcap' : true,
  43. 'noarg' : true,
  44. 'noempty' : false,
  45. 'nonew' : false,
  46. 'onevar' : true,
  47. 'plusplus' : false,
  48. 'regexp' : false,
  49. 'undef' : true,
  50. 'sub' : true,
  51. 'strict' : true,
  52. 'unused' : true,
  53. 'white' : true,
  54. 'es3' : true,
  55. 'camelcase' : true,
  56. 'quotmark' : 'single',
  57. 'globals': {
  58. 'define': false,
  59. 'moment': false,
  60. // Jasmine
  61. 'jasmine': false,
  62. 'describe': false,
  63. 'xdescribe': false,
  64. 'expect': false,
  65. 'it': false,
  66. 'xit': false,
  67. 'spyOn': false,
  68. 'beforeEach': false,
  69. 'afterEach': false
  70. }
  71. }
  72. },
  73. jscs: {
  74. all: [
  75. 'Gruntfile.js', 'src/js/*.js', 'test/*.js'
  76. ],
  77. options: {
  78. config: '.jscs.json'
  79. }
  80. },
  81. less: {
  82. production: {
  83. options: {
  84. cleancss: true,
  85. compress: true,
  86. paths: 'node_modules'
  87. },
  88. files: {
  89. 'build/css/bootstrap-datetimepicker.min.css': 'src/less/bootstrap-datetimepicker-build.less'
  90. }
  91. },
  92. development: {
  93. options: {
  94. paths: 'node_modules'
  95. },
  96. files: {
  97. 'build/css/bootstrap-datetimepicker.css': 'src/less/bootstrap-datetimepicker-build.less'
  98. }
  99. }
  100. },
  101. jasmine: {
  102. customTemplate: {
  103. src: 'src/js/*.js',
  104. options: {
  105. specs: 'test/*Spec.js',
  106. helpers: 'test/*Helper.js',
  107. styles: [
  108. 'node_modules/bootstrap/dist/css/bootstrap.min.css',
  109. 'build/css/bootstrap-datetimepicker.min.css'
  110. ],
  111. vendor: [
  112. 'node_modules/jquery/dist/jquery.min.js',
  113. 'node_modules/moment/min/moment-with-locales.min.js',
  114. 'node_modules/bootstrap/dist/js/bootstrap.min.js'
  115. ],
  116. display: 'none',
  117. summary: 'true'
  118. }
  119. }
  120. },
  121. nugetpack: {
  122. less: {
  123. src: 'src/nuget/Bootstrap.v3.Datetimepicker.nuspec',
  124. dest: 'build/nuget',
  125. options: {
  126. version: '<%= pkg.version %>'
  127. }
  128. },
  129. css: {
  130. src: 'src/nuget/Bootstrap.v3.Datetimepicker.CSS.nuspec',
  131. dest: 'build/nuget',
  132. options: {
  133. version: '<%= pkg.version %>'
  134. }
  135. }
  136. }
  137. });
  138. grunt.loadTasks('tasks');
  139. grunt.loadNpmTasks('grunt-contrib-jasmine');
  140. grunt.loadNpmTasks('grunt-nuget');
  141. // These plugins provide necessary tasks.
  142. require('load-grunt-tasks')(grunt);
  143. // Default task.
  144. grunt.registerTask('default', ['jshint', 'jscs', 'less', 'jasmine']);
  145. // travis build task
  146. grunt.registerTask('build:travis', [
  147. // code style
  148. 'jshint', 'jscs',
  149. // build
  150. 'uglify', 'less',
  151. // tests
  152. 'jasmine'
  153. ]);
  154. // Task to be run when building
  155. grunt.registerTask('build', [
  156. 'jshint', 'jscs', 'uglify', 'less'
  157. ]);
  158. grunt.registerTask('test', ['jshint', 'jscs', 'uglify', 'less', 'jasmine']);
  159. grunt.registerTask('docs', 'Generate docs', function () {
  160. grunt.util.spawn({
  161. cmd: 'mkdocs',
  162. args: ['build', '--clean']
  163. });
  164. });
  165. grunt.registerTask('release', function (version) {
  166. if (!version || version.split('.').length !== 3) {
  167. grunt.fail.fatal('malformed version. Use grunt release:1.2.3');
  168. }
  169. grunt.task.run([
  170. 'bump_version:' + version,
  171. 'build:travis',
  172. 'docs'
  173. ]);
  174. });
  175. };