diff --git a/README.md b/README.md index b24ff45..8a48ed0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,24 @@ This module contains the following services: For more information on Restangular refer to its [documentation](https://github.com/mgonto/restangular) +## Build and release a new version of this library + +> Note: this section is for library's developers only. + +1) set the VERSION number in **gulpfile.js** then + +``` +gulp build +``` + +The [gulp-bump](https://www.npmjs.com/package/gulp-bump) plugin automatically updates the version number in both **bower.json** and **package.json**. + +2) `git tag` with the same VERSION + +3) `git push` the new release. + +4) Increase the VERSION number to the next one and run `gulp build' again, so that it's ready for the successive release. + ## Installation ### Bower @@ -38,9 +56,9 @@ Inject the two services into your Controller. ```javascript .controller('MyCtrl', ['RhAuth', 'Rh', function (RhAuth, Rh) { - + // here your logic - + } }); ``` @@ -58,15 +76,15 @@ You have to configure angular-restheart before using it. `onUnauthenticated(callback)` to set the callback function the be called on `401 - Unauthorized` -`onTokenExpired(callback)` to set the callback function the be called on `401 - Unauthorized` due to token expiration +`onTokenExpired(callback)` to set the callback function the be called on `401 - Unauthorized` due to token expiration -The callback functions are passed two arguments: `$location` and `$state`, that can be used for redirection. +The callback functions are passed two arguments: `$location` and `$state`, that can be used for redirection. Also, in case of errors the `rh_error` varible is set in the local storage: ``` rh_error: {"why": ["forbidded" | "expired" "not_authenticated"], "path": , "state": , "params": } -``` +``` ### Configuration Example ```javascript @@ -139,7 +157,7 @@ The two main public methods are `signin()` and `signout()`. console.log("Not Authorized"); } }) - + } }]) ``` @@ -167,10 +185,9 @@ The two main public methods are `signin()` and `signout()`. function (Rh) { $scope.simpleRestangularRequest = function () { Rh.all('/db/coll').getList().then(function (documents) { // returns a list of the collection documents - console.log(documents); + console.log(documents); }) } }]) ``` - diff --git a/gulpfile.js b/gulpfile.js index 45af4b2..40d4515 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,37 +1,57 @@ +/** + * IMPORTANT: set the version number here when ready for a new release + * then run the 'gulp build' task to update both bower.json and package.json + * See the README.md file for more information. + */ +var VERSION = '1.1.5'; + var gulp = require('gulp'), - del = require('del'), - runSequence = require('run-sequence'), - concat = require('gulp-concat'), - uglify = require('gulp-uglify'); + del = require('del'), + runSequence = require('run-sequence'), + concat = require('gulp-concat'), + uglify = require('gulp-uglify'), + bump = require('gulp-bump'); + +// Update bower, component, npm at once: +gulp.task('bump', function() { + gulp.src(['./bower.json', './component.json', './package.json']) + .pipe(bump({ + version: VERSION + })) + .pipe(gulp.dest('./')); +}); gulp.task('default', function(callback) { - runSequence('build', callback); + runSequence('build', callback); }); -gulp.task('build', function (callback) { - runSequence( - 'clean', - 'copy-build', - callback); +gulp.task('build', function(callback) { + runSequence( + 'clean', + 'bump', + 'copy-build', + callback); }); -gulp.task('clean', function () { - return del(['./dist'], {force: true}); +gulp.task('clean', function() { + return del(['./dist'], { + force: true + }); }); -gulp.task('copy-build', [ 'concat-js','concat-min-js']); +gulp.task('copy-build', ['concat-js', 'concat-min-js']); -gulp.task('concat-js', function () { - return gulp.src(['./angular-restheart.module.js','./angular-restheart.config.js','./services/**/*.js','!node_modules{,/**}','!example/{,/**}','!gulpfile.js']) - .pipe(concat('angular-restheart.js')) - .pipe(gulp.dest('./dist')); +gulp.task('concat-js', function() { + return gulp.src(['./angular-restheart.module.js', './angular-restheart.config.js', './services/**/*.js', '!node_modules{,/**}', '!example/{,/**}', '!gulpfile.js']) + .pipe(concat('angular-restheart.js')) + .pipe(gulp.dest('./dist')); }); -gulp.task('concat-min-js', function () { - return gulp.src(['./angular-restheart.module.js','./angular-restheart.config.js','./services/**/*.js','!node_modules{,/**}','!example/{,/**}','!gulpfile.js']) - .pipe(concat('angular-restheart.min.js')) - .pipe(uglify()) - .pipe(gulp.dest('./dist')); +gulp.task('concat-min-js', function() { + return gulp.src(['./angular-restheart.module.js', './angular-restheart.config.js', './services/**/*.js', '!node_modules{,/**}', '!example/{,/**}', '!gulpfile.js']) + .pipe(concat('angular-restheart.min.js')) + .pipe(uglify()) + .pipe(gulp.dest('./dist')); }); diff --git a/package.json b/package.json index aa103e1..73a697f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "del": "^2.2.0", "gulp": "^3.9.1", "gulp-angular-filesort": "^1.1.1", + "gulp-bump": "^2.0.1", "gulp-concat": "^2.6.0", "gulp-inject": "^3.0.0", "gulp-uglify": "^1.5.3",