module.exports = function(grunt) { basicPath = 'static/js/threeJsHelper/'; sshServers = {}; sshServers['compute3'] = 'ipepdvcompute3.ipe.kit.edu'; sshServers['anka'] = 'anka-visualize.anka.kit.edu'; username = 'visualization'; tarName = '<%= pkg.name %>.tar'; deployCommand = function(env, server) { var command = 'ssh ' + username + '@' + sshServers[server] + ' "cd /usr/local/www/;' + 'rm -rf <%= pkg.name %>;' + 'tar -xf ' + tarName + ';' + 'cp -r <%= pkg.name %>/* visualization-' + env + '/;"' + 'cp visualization-' + env + '/visualization/settings_env.py.' + env + '.' + server + ' visualization-' + env + '/visualization/settings_env.py;'; return command; } var env = grunt.option('env') || 'staging'; var server = grunt.option('server') || 'compute3'; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), files : { dest: basicPath + 'dist/<%= pkg.jsname %>.js', destMin: basicPath + 'dist/<%= pkg.jsname %>.min.js' }, concat: { options: { separator: ';' }, dist: { src: [ basicPath + 'src/**/*.js' ], dest: '<%= files.dest %>' } }, shell: { pkg: { command: 'tar -cf ' + tarName + ' ../<%= pkg.name %>/* --exclude=settings_env.py --exclude=node_modules --exclude=__pycache__ --exclude=Gruntfile.js --exclude=startDev.sh --exclude=manage.py' }, rmPkg: { command: 'rm ' + tarName }, scp: { command: 'scp ' + tarName + ' visualization@' + sshServers[server] + ':/usr/local/www/' }, deploy: { command: deployCommand(env, server) }, bumbVersion: { command: 'npm version patch' } }, watch: { scripts: { files: [ basicPath + 'src/**/*.js' ], tasks: ['dev-watch'], options : { interrupt: true } } }, uglify: { options: { // the banner is inserted at the top of the output banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' }, dist: { files: { '<%= files.destMin %>': ['<%= files.dest %>'] } } } }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['concat', 'uglify']); grunt.registerTask('dev-watch', ['concat', 'uglify' ]); grunt.registerTask('update-version', ['shell:bumbVersion']); grunt.registerTask('deploy', ['concat', 'uglify', 'shell:pkg', 'shell:scp', 'shell:rmPkg', 'shell:deploy']); };