Last active
December 14, 2015 04:39
-
-
Save kevinohara80/5030097 to your computer and use it in GitHub Desktop.
Gruntifle from my demo video for static resource deployment
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({ | |
pkg: grunt.file.readJSON('package.json'), | |
jshint: { | |
options: { | |
globals: { | |
jQuery: true, | |
console: true, | |
module: true, | |
document: true | |
} | |
}, | |
build: ['gruntfile.js', 'src/**/*.js'] | |
}, | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
build: { | |
src: ['src/**/*.js'], | |
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 %>'] | |
} | |
} | |
}, | |
zip: { | |
// example build target for static resources | |
build: { | |
options: { | |
base: 'tmp/' | |
}, | |
src: ['tmp'], | |
dest: 'build/staticresources/<%= pkg.name %>.resource' | |
} | |
}, | |
copy: { | |
main: { | |
files: [ | |
{ expand: true, cwd: 'src/', src: ['img/*'], dest: 'tmp/' } | |
] | |
} | |
}, | |
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: process.env.DEV1USER, // storing my un/pw as env vars for security | |
pass: process.env.DEV1PASS, // storing my un/pw as env vars for security | |
}, | |
pkg: { | |
staticresource: ['*'] | |
} | |
} | |
}, | |
clean: { | |
build: ['tmp', 'build/package.xml'] | |
} | |
}); | |
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-zipstream'); | |
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>', | |
' <contentType>application/zip</contentType>', | |
' <description>MyTest Description</description>', | |
'</StaticResource>' | |
]; | |
var dest = grunt.template.process('<%= zip.build.dest %>') + '-meta.xml'; | |
grunt.file.write(dest, sr.join('\n')); | |
}); | |
// default task (no deploy) | |
grunt.registerTask('default', ['clean', 'jshint', 'concat', 'uglify', 'copy', 'zip', 'write-meta' ]); | |
// 'all' task including deploy | |
grunt.registerTask('all', ['default', 'antdeploy']); | |
}; |
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
{ | |
"name": "mytest", | |
"version": "0.0.0", | |
"author": "Kevin O'Hara", | |
"license": "BSD", | |
"devDependencies": { | |
"grunt": "*", | |
"grunt-contrib-jshint": "*", | |
"grunt-contrib-uglify": "*", | |
"grunt-contrib-concat": "*", | |
"grunt-contrib-clean": "*", | |
"grunt-zipstream": "*", | |
"grunt-contrib-copy": "~0.4.0", | |
"grunt-ant-sfdc": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment