Gruntfile.coffee 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. 'use strict'
  2. module.exports = (grunt)->
  3. # project configuration
  4. grunt.initConfig
  5. # load package information
  6. pkg: grunt.file.readJSON 'package.json'
  7. meta:
  8. banner: "/* ===========================================================\n" +
  9. "# <%= pkg.name %> - v<%= pkg.version %>\n" +
  10. "# <%= pkg.homepage %>\n" +
  11. "# ==============================================================\n" +
  12. "# Copyright 2012-2013 <%= pkg.author.name %>\n" +
  13. "#\n" +
  14. "# Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
  15. "# you may not use this file except in compliance with the License.\n" +
  16. "# You may obtain a copy of the License at\n" +
  17. "#\n" +
  18. "# http://www.apache.org/licenses/LICENSE-2.0\n" +
  19. "#\n" +
  20. "# Unless required by applicable law or agreed to in writing, software\n" +
  21. "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
  22. "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
  23. "# See the License for the specific language governing permissions and\n" +
  24. "# limitations under the License.\n" +
  25. "*/\n"
  26. coffeelint:
  27. options:
  28. indentation:
  29. value: 2
  30. level: "error"
  31. no_trailing_semicolons:
  32. level: "error"
  33. no_trailing_whitespace:
  34. level: "error"
  35. max_line_length:
  36. level: "ignore"
  37. default: ["Gruntfile.coffee", "src/**/*.coffee"]
  38. doc: ["Gruntfile.coffee", "docs/*.coffee"]
  39. clean:
  40. default: "build"
  41. test: "test"
  42. coffee:
  43. options:
  44. bare: true
  45. default:
  46. expand: true
  47. flatten: true
  48. cwd: "src/coffee"
  49. src: ["*.coffee"]
  50. dest: "build/js"
  51. ext: ".js"
  52. test:
  53. expand: true
  54. flatten: true
  55. cwd: "src/spec"
  56. src: ["*.spec.coffee"]
  57. dest: "test"
  58. ext: ".spec.js"
  59. doc:
  60. src: "docs/index.coffee"
  61. dest: "docs/assets/js/index.js"
  62. concat:
  63. options:
  64. banner: "<%= meta.banner %>"
  65. default:
  66. expand: true
  67. flatten: true
  68. cwd: "build/js"
  69. src: ["*.js"]
  70. dest: "build/js"
  71. ext: ".js"
  72. style:
  73. expand: true
  74. flatten: true
  75. cwd: "build/css"
  76. src: ["*.css", "!*.min.css"]
  77. dest: "build/css"
  78. ext: ".css"
  79. style_min:
  80. expand: true
  81. flatten: true
  82. cwd: "build/css"
  83. src: ["*.min.css"]
  84. dest: "build/css"
  85. ext: ".min.css"
  86. less:
  87. default:
  88. src: "src/less/<%= pkg.name %>.less"
  89. dest: "build/css/<%= pkg.name %>.css"
  90. min:
  91. options:
  92. compress: true
  93. cleancss: true
  94. src: "src/less/<%= pkg.name %>.less"
  95. dest: "build/css/<%= pkg.name %>.min.css"
  96. uglify:
  97. options:
  98. banner: "<%= meta.banner %>"
  99. default:
  100. expand: true
  101. flatten: true
  102. cwd: "build/js"
  103. src: ["*.js"]
  104. dest: "build/js"
  105. ext: ".min.js"
  106. watch:
  107. default:
  108. files: ["src/coffee/*.coffee"]
  109. tasks: ["build"]
  110. test:
  111. files: ["src/spec/*.coffee"]
  112. tasks: ["test"]
  113. doc:
  114. files: ["docs/*.coffee"]
  115. tasks: ["coffeelint:doc", "coffee:doc"]
  116. options:
  117. livereload: true
  118. jasmine:
  119. options:
  120. keepRunner: true
  121. vendor: [
  122. "docs/assets/vendor/jquery.js"
  123. "docs/assets/vendor/bootstrap.js"
  124. ]
  125. specs: "test/*.spec.js"
  126. src: "build/js/<%= pkg.name %>.js"
  127. copy:
  128. default:
  129. files: [
  130. expand: true
  131. cwd: "build/js"
  132. dest: "docs/assets/js"
  133. src: ["*.js"]
  134. ,
  135. expand: true
  136. cwd: "build/css"
  137. dest: "docs/assets/css"
  138. src: ["*.css"]
  139. ]
  140. connect:
  141. default:
  142. options:
  143. port: 3000
  144. base: "docs"
  145. open:
  146. default:
  147. path: "http://localhost:<%= connect.default.options.port %>"
  148. bump:
  149. options:
  150. files: ["package.json", "bower.json"]
  151. updateConfigs: ["pkg"]
  152. commit: true
  153. commitMessage: "Bump version to %VERSION%"
  154. commitFiles: ["-a"]
  155. createTag: true
  156. tagName: "v%VERSION%"
  157. tagMessage: "Version %VERSION%"
  158. push: true
  159. pushTo: "origin"
  160. gitDescribeOptions: "--tags --always --abbrev=1 --dirty=-d"
  161. replace:
  162. options:
  163. patterns: [
  164. {
  165. match: "/Version \\d+\\.\\d+\\.\\d+/g"
  166. replacement: "Version <%= pkg.version %>"
  167. expression: true
  168. }
  169. ]
  170. default:
  171. files: [
  172. {
  173. expand: true
  174. flatten: true
  175. src: ["docs/index.html"]
  176. dest: "docs/"
  177. }
  178. ]
  179. # load plugins that provide the tasks defined in the config
  180. grunt.loadNpmTasks "grunt-bump"
  181. grunt.loadNpmTasks "grunt-coffeelint"
  182. grunt.loadNpmTasks "grunt-contrib-clean"
  183. grunt.loadNpmTasks "grunt-contrib-coffee"
  184. grunt.loadNpmTasks "grunt-contrib-concat"
  185. grunt.loadNpmTasks "grunt-contrib-connect"
  186. grunt.loadNpmTasks "grunt-contrib-copy"
  187. grunt.loadNpmTasks "grunt-contrib-jasmine"
  188. grunt.loadNpmTasks "grunt-contrib-less"
  189. grunt.loadNpmTasks "grunt-contrib-uglify"
  190. grunt.loadNpmTasks "grunt-contrib-watch"
  191. grunt.loadNpmTasks "grunt-notify"
  192. grunt.loadNpmTasks "grunt-open"
  193. grunt.loadNpmTasks "grunt-replace"
  194. # register tasks
  195. grunt.registerTask "default", ["run"]
  196. grunt.registerTask "run", ["build", "connect", "open", "watch:doc"]
  197. grunt.registerTask "build", ["clean", "coffeelint", "coffee", "less", "concat", "uglify", "copy"]
  198. grunt.registerTask "test", ["build", "jasmine"]
  199. grunt.registerTask "release", "Release a new version, push it and publish it", (target)->
  200. target = "patch" unless target
  201. grunt.task.run "bump-only:#{target}", "test", "replace", "bump-commit"