gruntfile.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. module.exports = function (grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. pkgFile: 'package.json',
  5. files: {
  6. server: ['lib/**/*.js'],
  7. client: ['client/**/*.js'],
  8. common: ['common/**/*.js'],
  9. context: ['context/**/*.js'],
  10. grunt: ['grunt.js', 'tasks/*.js'],
  11. scripts: ['scripts/init-dev-env.js']
  12. },
  13. browserify: {
  14. client: {
  15. files: {
  16. 'static/karma.js': ['client/main.js'],
  17. 'static/context.js': ['context/main.js']
  18. }
  19. }
  20. },
  21. test: {
  22. unit: 'mochaTest:unit',
  23. client: 'test/client/karma.conf.js',
  24. e2e: 'cucumberjs:ci'
  25. },
  26. watch: {
  27. client: {
  28. files: '<%= files.client %>',
  29. tasks: 'browserify:client'
  30. }
  31. },
  32. mochaTest: {
  33. options: {
  34. reporter: 'dot',
  35. ui: 'bdd',
  36. quiet: false,
  37. colors: true
  38. },
  39. unit: {
  40. src: [
  41. 'test/unit/mocha-globals.js',
  42. 'test/unit/**/*.spec.js'
  43. ]
  44. }
  45. },
  46. cucumberjs: {
  47. options: {
  48. steps: 'test/e2e/step_definitions',
  49. format: 'progress',
  50. require: ['test/e2e/support/env.js', 'test/e2e/support/world.js']
  51. },
  52. all: 'test/e2e/*.feature',
  53. current: {
  54. files: {
  55. src: 'test/e2e/*.feature'
  56. },
  57. options: {
  58. tags: '@current'
  59. }
  60. },
  61. ci: {
  62. files: {
  63. src: 'test/e2e/*.feature'
  64. },
  65. options: {
  66. tags: 'not @not-jenkins'
  67. }
  68. }
  69. },
  70. eslint: {
  71. options: {
  72. quiet: true
  73. },
  74. target: [
  75. '<%= files.server %>',
  76. '<%= files.grunt %>',
  77. '<%= files.scripts %>',
  78. '<%= files.client %>',
  79. '<%= files.common %>',
  80. '<%= files.context %>',
  81. 'static/debug.js',
  82. 'test/**/*.js',
  83. 'gruntfile.js'
  84. ]
  85. },
  86. 'npm-publish': {
  87. options: {
  88. requires: ['build'],
  89. abortIfDirty: true,
  90. tag: 'latest'
  91. }
  92. },
  93. 'npm-contributors': {
  94. options: {
  95. commitMessage: 'chore: update contributors'
  96. }
  97. },
  98. conventionalChangelog: {
  99. release: {
  100. options: {
  101. changelogOpts: {
  102. preset: 'angular'
  103. }
  104. },
  105. src: 'CHANGELOG.md'
  106. }
  107. },
  108. conventionalGithubReleaser: {
  109. release: {
  110. options: {
  111. auth: {
  112. type: 'oauth',
  113. token: process.env.GH_TOKEN
  114. },
  115. changelogOpts: {
  116. preset: 'angular'
  117. }
  118. }
  119. }
  120. },
  121. bump: {
  122. options: {
  123. updateConfigs: ['pkg'],
  124. commitFiles: [
  125. 'package.json',
  126. 'CHANGELOG.md'
  127. ],
  128. commitMessage: 'chore: release v%VERSION%',
  129. prereleaseName: 'rc'
  130. }
  131. }
  132. })
  133. grunt.loadNpmTasks('grunt-check-clean')
  134. grunt.loadTasks('tasks')
  135. require('load-grunt-tasks')(grunt)
  136. grunt.registerTask('lint', ['eslint'])
  137. grunt.registerTask('build', ['browserify:client'])
  138. grunt.registerTask('default', ['build', 'lint', 'test'])
  139. grunt.registerTask('test-appveyor', ['test:unit', 'test:client'])
  140. grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {
  141. grunt.task.run([
  142. 'check_clean',
  143. 'npm-contributors',
  144. 'bump:' + (type || 'patch') + ':bump-only',
  145. 'build',
  146. 'conventionalChangelog',
  147. 'bump-commit',
  148. 'conventionalGithubReleaser',
  149. 'npm-publish'
  150. ])
  151. })
  152. }