Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. env: {
  102. paris: {
  103. TZ: 'Europe/Paris' // sets env for phantomJS https://github.com/ariya/phantomjs/issues/10379#issuecomment-36058589
  104. }
  105. },
  106. connect: {
  107. server: {
  108. options: {
  109. port: 8099
  110. }
  111. }
  112. },
  113. jasmine: {
  114. customTemplate: {
  115. src: 'src/js/*.js',
  116. options: {
  117. specs: 'test/*Spec.js',
  118. helpers: 'test/*Helper.js',
  119. host: 'http://127.0.0.1:8099',
  120. styles: [
  121. 'node_modules/bootstrap/dist/css/bootstrap.min.css',
  122. 'build/css/bootstrap-datetimepicker.min.css'
  123. ],
  124. vendor: [
  125. 'node_modules/jquery/dist/jquery.min.js',
  126. 'node_modules/moment/min/moment-with-locales.min.js',
  127. 'node_modules/moment-timezone/moment-timezone.js',
  128. 'node_modules/bootstrap/dist/js/bootstrap.min.js'
  129. ],
  130. display: 'none',
  131. summary: 'true'
  132. }
  133. }
  134. },
  135. nugetpack: {
  136. less: {
  137. src: 'src/nuget/Bootstrap.v3.Datetimepicker.nuspec',
  138. dest: 'build/nuget',
  139. options: {
  140. version: '<%= pkg.version %>'
  141. }
  142. },
  143. css: {
  144. src: 'src/nuget/Bootstrap.v3.Datetimepicker.CSS.nuspec',
  145. dest: 'build/nuget',
  146. options: {
  147. version: '<%= pkg.version %>'
  148. }
  149. }
  150. }
  151. });
  152. grunt.loadTasks('tasks');
  153. grunt.loadNpmTasks('grunt-env');
  154. grunt.loadNpmTasks('grunt-contrib-connect');
  155. grunt.loadNpmTasks('grunt-contrib-jasmine');
  156. grunt.loadNpmTasks('grunt-nuget');
  157. require('load-grunt-tasks')(grunt);
  158. grunt.registerTask('default', ['jshint', 'jscs', 'less', 'env:paris', 'connect', 'jasmine']);
  159. grunt.registerTask('build:travis', [
  160. // code style
  161. 'jshint', 'jscs',
  162. // build
  163. 'uglify', 'less',
  164. // tests
  165. 'env:paris', 'connect', 'jasmine'
  166. ]);
  167. // Task to be run when building
  168. grunt.registerTask('build', ['jshint', 'jscs', 'uglify', 'less']);
  169. grunt.registerTask('test', ['jshint', 'jscs', 'uglify', 'less', 'env:paris', 'connect', 'jasmine']);
  170. grunt.registerTask('docs', 'Generate docs', function () {
  171. grunt.util.spawn({
  172. cmd: 'mkdocs',
  173. args: ['build', '--clean']
  174. });
  175. });
  176. grunt.registerTask('release', function (version) {
  177. if (!version || version.split('.').length !== 3) {
  178. grunt.fail.fatal('malformed version. Use grunt release:1.2.3');
  179. }
  180. grunt.task.run([
  181. 'bump_version:' + version,
  182. 'build:travis',
  183. 'docs',
  184. 'nugetpack'
  185. ]);
  186. });
  187. };