Last active
June 1, 2016 01:21
-
-
Save dieffrei/7875f2c4628180988cc854090019a5b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// project configuration. | |
grunt.initConfig({ | |
git_deploy: { | |
deploy_to_repo_target: { | |
options: { | |
url: 'dieffrei@bitbucket.org/dieffrei/sample-repo.git' | |
}, | |
src: 'build/staticresources' | |
} | |
}, | |
pkg: grunt.file.readJSON('package.json'), | |
jshint: { | |
options: { | |
globals: { | |
jQuery: true, | |
console: true, | |
module: true, | |
document: true | |
} | |
}, | |
build: ['gruntfile.js', 'js/*.js'] | |
}, | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
build: { | |
src: ['js/order/order-app.js', 'js/**/*.js', '!js/lib/**'], | |
dest: 'tmp/js/<%= pkg.name %>.js' | |
} | |
}, | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy */\n' | |
}, | |
build: { | |
files: { | |
'tmp/js/<%= pkg.name %>.min.js': ['<%= concat.build.dest %>'] | |
} | |
} | |
}, | |
compress: { | |
main: { | |
options: { | |
mode: 'zip', | |
archive : 'build/staticresources/<%= pkg.name %>.resource' | |
}, | |
files: [ | |
{src: ['tmp/js/*.js'], dest: '/'}, // includes files in path | |
{src: ['tmp/partials/**'], dest: '/'}, // includes files in path | |
{src: ['tmp/css/**'], dest: '/'}, // includes files in path | |
{src: ['tmp/img/**'], dest: '/'} // includes files in path | |
] | |
} | |
}, | |
copy: { | |
main: { | |
files: [ | |
{ expand: true, src: ['partials/**'], dest: 'tmp/' }, | |
{ expand: true, src: ['css/**'], dest: 'tmp/' }, | |
{ expand: true, src: ['img/**'], dest: 'tmp/' } | |
] | |
} | |
}, | |
/*shell: { | |
notifyRollbar: { | |
command: '' + | |
'curl https://api.rollbar.com/api/1/deploy/ \ ' + | |
' -F access_token=123456 \ ' + | |
' -F environment=production \ ' + | |
' -F revision= \ ' + | |
' -F local_username=dieffrei' | |
command: '/notify-rollbar-deploy.sh' | |
} | |
}, | |
exec: { | |
notifyrollbar: 'sh notify-rollbar-deploy.sh' | |
},*/ | |
antdeploy: { | |
// define global options for all deploys | |
options: { | |
root: 'build/', | |
version: '27.0' | |
}, | |
// create individual deploy targets. these can be | |
// individual orgs or even the same org with different packages | |
dev1: { | |
options: { | |
user: '', | |
pass: '', | |
serverurl: 'https://test.salesforce.com' | |
}, | |
pkg: { | |
staticresource: ['*'] | |
} | |
} | |
}, | |
clean: { | |
build: ['tmp'/*, 'build', 'build/package.xml'*/] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-exec'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.loadNpmTasks('grunt-ant-sfdc'); | |
// custom task to write the -meta.xml file for the metadata deployment | |
grunt.registerTask('write-meta', 'Write the required salesforce metadata', function() { | |
grunt.log.writeln('Writing metadata...'); | |
var sr = [ | |
'<?xml version="1.0" encoding="UTF-8"?>', | |
'<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">', | |
' <cacheControl>Public</cacheControl>', | |
' <description>All static resources for ORD module.</description>', | |
'<contentType>application/x-zip-compressed</contentType>', | |
'</StaticResource>' | |
]; | |
var dest = grunt.template.process('build/staticresources/<%= pkg.name %>.resource') + '-meta.xml'; | |
grunt.file.write(dest, sr.join('\n')); | |
}); | |
// default task (no deploy) | |
grunt.registerTask('default', ['clean', /*'jshint',*/ 'concat', 'uglify', 'copy', 'compress', 'write-meta']); | |
// 'all' task including deploy | |
grunt.registerTask('all', ['default', 'antdeploy'/*, 'exec:notifyrollbar'*/]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment