Skip to content

Instantly share code, notes, and snippets.

@RhinoLance
Created December 3, 2013 22:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save RhinoLance/7778487 to your computer and use it in GitHub Desktop.
Save RhinoLance/7778487 to your computer and use it in GitHub Desktop.
Gruntfile for automated Cordova builds.
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*! <%= pkg.name || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['www/js/**/*.js'],
dest: 'www/js/<%= pkg.name %>.concat.js'
}
},
uglify: {
options: {
banner: '<%= banner %>',
mangle: true,
beautify: false
},
dist: {
src: 'www/js/<%= pkg.name %>.js',
dest: 'www/js/<%= pkg.name %>.min.js'
}
},
bumpup: ['package.json', 'www/js/build.json'],
shell: {
options: {
failOnError: true,
stdout: false,
stderr: true
},
build: {
command: 'cordova build ios android'
},
prepare: {
command: 'cordova prepare'
},
buildIpa: {
command: '/usr/bin/xcrun -sdk iphoneos PackageApplication -v "/<projectPath>/platforms/ios/build/Crocpad.app" -o "/<projectPath>/platforms/ios/build/CrocPad.ipa" --sign "iPhone Distribution: Rhino Software Pty Ltd (F86TA6JRXE)" --embed "/<projectPath>/Dev/Keys/iOS/Rhino_Software_AdHoc.mobileprovision"'
}
},
jshint: {
options: {
curly: true,
eqeqeq: false,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
devel: true,
eqnull: true,
browser: true,
smarttabs: true,
jquery: true
},
all: ['Gruntfile.js', 'www/js/*.js']
},
copy: {
main: {
files: [
{
expand: true, flatten: true, filer: 'isFile',
src: ['platforms/ios/build/CrocPad.ipa'],
dest: '/<projectPath>/Dev/Client/buid/ios/'
},
{
expand: true, flatten: true,
src: ['platforms/android/bin/CrocPad-debug.apk'],
dest: '/<projectPath>/Dev/Client/buid/android/'
},
{
expand: true, flatten: true,
src: ['package.json'],
dest: '/<projectPath>/Dev/Client/buid/'
}
]
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bumpup');
// Default task
grunt.registerTask('default', ['bumpup:build', 'jshint', 'shell:build', 'shell:buildIpa', 'copy']);
// Custom tasks
grunt.registerTask('prepare', ['jshint', 'shell:prepare']);
// Custom tasks
grunt.registerTask('ipa', ['shell:buildIpa', 'copy']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment