alloy.jmk to bump version on build
var fs = require('fs');
var path = require('path');
task("pre:compile", function(event, logger) {
var tiappxml = path.join(event.dir.project, 'tiapp.xml');
var tiapp = fs.readFileSync(tiappxml, {
encoding : 'utf-8'
});
tiapp = tiapp.replace(/(android:versionCode=")([^"]+)(")/, function(match, before, versionCode, after) {
versionCode = parseInt(versionCode, 10) + 1;
logger.info('Bumped android:versionCode to: ' + versionCode);
return before + versionCode + after;
});
tiapp = tiapp.replace(/(<key>CFBundleVersion<\/key>\s*<string>)([^<]+)(<\/string>)/mg, function(match, before, CFBundleVersion, after) {
CFBundleVersion = parseInt(CFBundleVersion, 10) + 1;
logger.info('Bumped CFBundleVersion to: ' + CFBundleVersion);
return before + CFBundleVersion + after;
});
fs.writeFileSync(tiappxml, tiapp);
logger.info('building project at ' + event.dir.project);
});
task("post:compile", function(event, logger) {
logger.info('compile finished!');
});