From: Nick Downie Date: Sun, 27 Jul 2014 20:41:49 +0000 (+0100) Subject: Create a task to bump + write version numbers X-Git-Tag: v1.0.1-beta.3~2^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F490%2Fhead;p=thirdparty%2FChart.js.git Create a task to bump + write version numbers Also run `gulp release` to tag the latest release. --- diff --git a/bower.json b/bower.json index 4faae686c..8cc78f29e 100644 --- a/bower.json +++ b/bower.json @@ -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": {} } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 7ffa80758..8a971dbca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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/'; /* @@ -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')) @@ -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()) diff --git a/package.json b/package.json index b86b6a1ea..90bb97424 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 3484ae223..877f49949 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1,6 +1,7 @@ /*! * Chart.js * http://chartjs.org/ + * Version: {{ version }} * * Copyright 2014 Nick Downie * Released under the MIT license