Wednesday, January 13, 2016

Gulp bump minor number for ionic

If you need a full blown approach for bumping your version numbers then there is a robust set of build tools by Robert Shedd 
https://github.com/shedd/ionic_build_tools#bump-app-versions
His build tools provide more than just gulp commands, the readme alone can save you time and help you avoid mistakes.

However, I just needed something simple for bumping version numbers in package.json and config.xml.

Extra NPM packages

  • npm install gulp-xml-editor --save-dev
  • npm install gulp-json-transform --save-dev 


Requires

  • var jsonTransform = require('gulp-json-transform');
  • var xeditor = require('gulp-xml-editor');

Gulp Task
gulp.task( 'package', ['sass'], function(){
gulp.src('./package.json')
.pipe( jsonTransform(function(data){
var version = data.version.split('.');
version[2]++;
data.version = version.join('.');
return data;
},2))
.pipe(gulp.dest('.'));
gulp.src("./config.xml")
.pipe(xeditor(function(xml, xmljs) {
var version = xml.root().attr('version').value().split('.');
version[2]++;
  xml.root().attr('version',version.join('.'));
  return xml;
}))
 .pipe(gulp.dest("."));
});





No comments: