Gruntfile.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. module.exports = function(grunt) {
  2. basicPath = 'static/js/threeJsHelper/';
  3. sshServers = {};
  4. sshServers['compute3'] = 'ipepdvcompute3.ipe.kit.edu';
  5. sshServers['anka'] = 'anka-visualize.anka.kit.edu';
  6. username = 'visualization';
  7. tarName = '<%= pkg.name %>.tar';
  8. deployCommand = function(env, server) {
  9. var command = 'ssh ' + username + '@' + sshServers[server]
  10. + ' "cd /usr/local/www/;'
  11. + 'rm -rf <%= pkg.name %>;'
  12. + 'tar -xf ' + tarName + ';'
  13. + 'cp -r <%= pkg.name %>/* visualization-' + env + '/;"'
  14. + 'cp visualization-' + env + '/visualization/settings_env.py.' + env + '.' + server + ' visualization-' + env + '/visualization/settings_env.py;';
  15. return command;
  16. }
  17. var env = grunt.option('env') || 'staging';
  18. var server = grunt.option('server') || 'compute3';
  19. grunt.initConfig({
  20. pkg: grunt.file.readJSON('package.json'),
  21. concat: {
  22. options: {
  23. separator: ';'
  24. },
  25. dist: {
  26. src: [ basicPath + 'src/**/*.js' ],
  27. dest: basicPath + 'dist/<%= pkg.jsname %>.js'
  28. }
  29. },
  30. shell: {
  31. pkg: {
  32. command: 'tar -cf ' + tarName + ' ../<%= pkg.name %>/* --exclude=settings_env.py --exclude=node_modules --exclude=__pycache__ --exclude=Gruntfile.js --exclude=startDev.sh --exclude=manage.py'
  33. },
  34. rmPkg: {
  35. command: 'rm ' + tarName
  36. },
  37. scp: {
  38. command: 'scp ' + tarName + ' visualization@' + sshServers[server] + ':/usr/local/www/'
  39. },
  40. deploy: {
  41. command: deployCommand(env, server)
  42. },
  43. bumbVersion: {
  44. command: 'npm version patch'
  45. }
  46. },
  47. watch: {
  48. scripts: {
  49. files: [ basicPath + 'src/**/*.js' ],
  50. tasks: ['dev-watch'],
  51. options : {
  52. interrupt: true
  53. }
  54. }
  55. },
  56. uglify: {
  57. options: {
  58. // the banner is inserted at the top of the output
  59. banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
  60. },
  61. dist: {
  62. files: {
  63. 'static/js/threeJsHelper/dist/<%= pkg.jsname %>.min.js': ['<%= concat.dist.dest %>']
  64. }
  65. }
  66. }
  67. });
  68. grunt.loadNpmTasks('grunt-contrib-concat');
  69. grunt.loadNpmTasks('grunt-contrib-watch');
  70. grunt.loadNpmTasks('grunt-shell');
  71. grunt.loadNpmTasks('grunt-contrib-uglify');
  72. grunt.registerTask('default', ['concat', 'uglify']);
  73. grunt.registerTask('dev-watch', ['concat:dist']);
  74. grunt.registerTask('update-version', ['shell:bumbVersion']);
  75. grunt.registerTask('deploy', ['concat', 'shell:pkg', 'shell:scp', 'shell:rmPkg', 'shell:deploy']);
  76. };