Gruntfile.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. module.exports = function(grunt) {
  2. var L = grunt.log.writeln;
  3. var BANNER = '/**\n' +
  4. ' * Open Sheet Music Display library <%= pkg.version %> built on <%= grunt.template.today("yyyy-mm-dd") %>.\n' +
  5. ' * Copyright (c) 2016 PhonicScore\n' +
  6. ' *\n' +
  7. ' * https://github.com/opensheetmusicdisplay/opensheetmusicdisplay\n' +
  8. ' */\n';
  9. var BUILD_DIR = 'build';
  10. var RELEASE_DIR = 'releases';
  11. var TARGET_RAW = BUILD_DIR + '/osmd.js';
  12. var TARGET_MIN = BUILD_DIR + '/osmd-min.js';
  13. var SOURCES = [ "src/source.js",
  14. "src/*.js", "!src/header.js", "!src/container.js"];
  15. grunt.initConfig({
  16. pkg: grunt.file.readJSON('package.json'),
  17. concat: {
  18. options: {
  19. banner: BANNER
  20. },
  21. build: {
  22. src: SOURCES,
  23. dest: TARGET_RAW
  24. }
  25. },
  26. uglify: {
  27. options: {
  28. banner: BANNER,
  29. sourceMap: true
  30. },
  31. build: {
  32. src: SOURCES,
  33. dest: TARGET_MIN
  34. }
  35. },
  36. jshint: {
  37. files: SOURCES,
  38. options: {
  39. eqnull: true, // allow == and ~= for nulls
  40. sub: true, // don't enforce dot notation
  41. trailing: true, // no more trailing spaces
  42. globals: {
  43. "Vex": false,
  44. "Raphael": false
  45. }
  46. }
  47. },
  48. watch: {
  49. scripts: {
  50. files: ['src/*', 'Gruntfile.js'],
  51. tasks: ['concat', 'jshint'],
  52. options: {
  53. interrupt: true
  54. }
  55. }
  56. },
  57. copy: {
  58. release: {
  59. files: [
  60. {
  61. expand: true,
  62. dest: RELEASE_DIR,
  63. cwd: BUILD_DIR,
  64. src : ['*.js', 'docs/**', '*.map']
  65. }
  66. ]
  67. }
  68. },
  69. docco: {
  70. src: SOURCES,
  71. options: {
  72. layout: 'linear',
  73. output: 'build/docs'
  74. }
  75. },
  76. gitcommit: {
  77. releases: {
  78. options: {
  79. message: "Committing release binaries for new version: <%= pkg.version %>",
  80. verbose: true
  81. },
  82. files: [
  83. {
  84. src: [RELEASE_DIR + "/*.js", RELEASE_DIR + "/*.map"],
  85. expand: true
  86. }
  87. ]
  88. }
  89. },
  90. bump: {
  91. options: {
  92. files: ['package.json', 'component.json'],
  93. commitFiles: ['package.json', 'component.json'],
  94. updateConfigs: ['pkg'],
  95. createTag: false,
  96. push: false
  97. }
  98. },
  99. release: {
  100. options: {
  101. bump: false,
  102. commit: false
  103. }
  104. },
  105. clean: [BUILD_DIR, RELEASE_DIR],
  106. });
  107. // Load the plugin that provides the "uglify" task.
  108. grunt.loadNpmTasks('grunt-contrib-concat');
  109. grunt.loadNpmTasks('grunt-contrib-uglify');
  110. grunt.loadNpmTasks('grunt-contrib-jshint');
  111. grunt.loadNpmTasks('grunt-contrib-watch');
  112. grunt.loadNpmTasks('grunt-contrib-qunit');
  113. grunt.loadNpmTasks('grunt-contrib-copy');
  114. grunt.loadNpmTasks('grunt-contrib-clean');
  115. grunt.loadNpmTasks('grunt-docco');
  116. grunt.loadNpmTasks('grunt-release');
  117. grunt.loadNpmTasks('grunt-bump');
  118. grunt.loadNpmTasks('grunt-git');
  119. // Default task(s).
  120. grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'docco']);
  121. grunt.registerTask('test', 'Run qunit tests.', function() {
  122. grunt.task.run('qunit');
  123. });
  124. // Release current build.
  125. grunt.registerTask('stage', 'Stage current binaries to releases/.', function() {
  126. grunt.task.run('default');
  127. grunt.task.run('copy:release');
  128. });
  129. };