Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request chartjs#490 from nnnick/feature/version-bump
Browse files Browse the repository at this point in the history
Create a task to bump + write version numbers
  • Loading branch information
nnnick committed Jul 27, 2014
2 parents ebc955f + adf6f3a commit 92e73bd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
7 changes: 4 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Simple HTML5 Charts using the canvas element",
"homepage": "https://github.com/nnnick/Chart.js",
"author": "nnnick",
"main": ["Chart.min.js"],
"dependencies": {
}
"main": [
"Chart.min.js"
],
"dependencies": {}
}
46 changes: 45 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ var gulp = require('gulp'),
jshint = require('gulp-jshint'),
size = require('gulp-size'),
connect = require('gulp-connect'),
exec = require('child_process').exec;
replace = require('gulp-replace'),
inquirer = require('inquirer'),
semver = require('semver'),
exec = require('child_process').exec,
fs = require('fs'),
package = require('./package.json'),
bower = require('./bower.json');

var srcDir = './src/';
/*
Expand All @@ -28,8 +34,10 @@ gulp.task('build', function(){
// So we can use this to sort out dependency order - aka include Core first!
srcFiles.push(srcDir+'*');
}

return gulp.src(srcFiles)
.pipe(concat('Chart.js'))
.pipe(replace('{{ version }}', package.version))
.pipe(gulp.dest(outputDir))
.pipe(uglify({preserveComments:'some'}))
.pipe(concat('Chart.min.js'))
Expand All @@ -40,6 +48,42 @@ gulp.task('build', function(){
};
});

/*
* Usage : gulp bump
* Prompts: Version increment to bump
* Output: - New version number written into package.json & bower.json
*/

gulp.task('bump', function(complete){
util.log('Current version:', util.colors.cyan(package.version));
var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType){
return versionType + ' (v' + semver.inc(package.version, versionType) + ')';
});
inquirer.prompt({
type: 'list',
name: 'version',
message: 'What version update would you like?',
choices: choices
}, function(res){
var increment = res.version.split(' ')[0],
newVersion = semver.inc(package.version, increment);

// Set the new versions into the bower/package object
package.version = newVersion;
bower.version = newVersion;

// Write these to their own files, then build the output
fs.writeFileSync('package.json', JSON.stringify(package, null, 2));
fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2));

complete();
});
});

gulp.task('release', ['build'], function(){
exec('git tag -a v' + newVersion);
});

gulp.task('jshint', function(){
return gulp.src(srcDir + '*.js')
.pipe(jshint())
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
"devDependencies": {
"gulp": "3.5.x",
"gulp-concat": "~2.1.x",
"gulp-uglify": "~0.2.x",
"gulp-util": "~2.2.x",
"gulp-connect": "~2.0.5",
"gulp-jshint": "~1.5.1",
"gulp-replace": "^0.4.0",
"gulp-size": "~0.4.0",
"gulp-connect": "~2.0.5"
"gulp-uglify": "~0.2.x",
"gulp-util": "~2.2.x",
"inquirer": "^0.5.1",
"semver": "^3.0.1"
}
}
1 change: 1 addition & 0 deletions src/Chart.Core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* Chart.js
* http://chartjs.org/
* Version: {{ version }}
*
* Copyright 2014 Nick Downie
* Released under the MIT license
Expand Down

0 comments on commit 92e73bd

Please sign in to comment.