]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Create a task to bump + write version numbers 490/head
authorNick Downie <hello@nickdownie.com>
Sun, 27 Jul 2014 20:41:49 +0000 (21:41 +0100)
committerNick Downie <hello@nickdownie.com>
Sun, 27 Jul 2014 20:41:49 +0000 (21:41 +0100)
Also run `gulp release` to tag the latest release.

bower.json
gulpfile.js
package.json
src/Chart.Core.js

index 4faae686cb09b830ca25e7125d1a89a865c40640..8cc78f29e14f6d936d064f0730fb44a4e0bbc676 100644 (file)
@@ -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
index 7ffa807581cb037dd20da981fdda84136d55e00d..8a971dbcaa5bfd7fd9820261e3b901f0c31c1f17 100644 (file)
@@ -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())
index b86b6a1ead169d1511d35fa7f05b24877042a3af..90bb9742407795ac67ebb6800e9aa32e2698c1a4 100644 (file)
   "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"
   }
 }
index 3484ae22354019c43bba9a7425efb60ef51abd93..877f49949768e29ec8cafe089e9ac84949683f35 100755 (executable)
@@ -1,6 +1,7 @@
 /*!
  * Chart.js
  * http://chartjs.org/
+ * Version: {{ version }}
  *
  * Copyright 2014 Nick Downie
  * Released under the MIT license