1 | # gulp-bump
|
2 | [![Build Status](https://travis-ci.org/stevelacy/gulp-bump.svg?branch=master)](https://travis-ci.org/stevelacy/gulp-bump)
|
3 | [![NPM version](https://badge.fury.io/js/gulp-bump.svg)](http://badge.fury.io/js/gulp-bump)
|
4 |
|
5 | > Bump any version in any file which supports [semver](http://semver.org/) versioning
|
6 |
|
7 | ## Information
|
8 |
|
9 | <table>
|
10 | <tr>
|
11 | <td>Package</td><td>gulp-bump</td>
|
12 | </tr>
|
13 | <tr>
|
14 | <td>Description</td>
|
15 | <td>Bump any Semver version in any file
|
16 | with gulp (gulpjs.com)</td>
|
17 | </tr>
|
18 | <tr>
|
19 | <td>Node Version</td>
|
20 | <td>>= 0.9</td>
|
21 | </tr>
|
22 | <tr>
|
23 | <td>Gulp Version</td>
|
24 | <td>3.x</td>
|
25 | </tr>
|
26 | </table>
|
27 |
|
28 | ## Usage
|
29 |
|
30 | If you are just requiring a bump for npm, consider using [npm version](https://docs.npmjs.com/cli/version)
|
31 |
|
32 | #### Install
|
33 |
|
34 | ```bash
|
35 | $ npm install gulp-bump --save
|
36 | ```
|
37 | #### Breaking changes
|
38 |
|
39 | `gulp-bump` v2 supports Any valid semver in any filetype.
|
40 | - v2 no longer creates the version [key] if it does not exist.
|
41 |
|
42 | ## Example
|
43 |
|
44 | ```js
|
45 | var gulp = require('gulp');
|
46 | var bump = require('gulp-bump');
|
47 |
|
48 | // Basic usage:
|
49 | // Will patch the version
|
50 | gulp.task('bump', function(){
|
51 | gulp.src('./component.json')
|
52 | .pipe(bump())
|
53 | .pipe(gulp.dest('./'));
|
54 | });
|
55 |
|
56 | // Defined method of updating:
|
57 | // Semantic
|
58 | gulp.task('bump', function(){
|
59 | gulp.src('./*.json')
|
60 | .pipe(bump({type:'minor'}))
|
61 | .pipe(gulp.dest('./'));
|
62 | });
|
63 |
|
64 | // Defined method of updating:
|
65 | // Semantic major
|
66 | gulp.task('bump', function(){
|
67 | gulp.src('./package.yml')
|
68 | .pipe(bump({type:'major'}))
|
69 | .pipe(gulp.dest('./'));
|
70 | });
|
71 |
|
72 | // Defined method of updating:
|
73 | // Set a specific version
|
74 | gulp.task('bump', function(){
|
75 | gulp.src('./*.json')
|
76 | .pipe(bump({version: '1.2.3'}))
|
77 | .pipe(gulp.dest('./'));
|
78 | });
|
79 |
|
80 | // Update bower, component, npm at once:
|
81 | gulp.task('bump', function(){
|
82 | gulp.src(['./bower.json', './component.json', './package.json'])
|
83 | .pipe(bump({type:'major'}))
|
84 | .pipe(gulp.dest('./'));
|
85 | });
|
86 |
|
87 | // Define the key for versioning off
|
88 | gulp.task('bump', function(){
|
89 | gulp.src('./package.json')
|
90 | .pipe(bump({key: "appversion"}))
|
91 | .pipe(gulp.dest('./'));
|
92 | });
|
93 |
|
94 |
|
95 | ```
|
96 | #### Bumping version and outputting different files
|
97 | ```js
|
98 | // `fs` is used instead of require to prevent caching in watch (require caches)
|
99 | var fs = require('fs');
|
100 | var semver = require('semver');
|
101 |
|
102 | var getPackageJson = function () {
|
103 | return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
104 | };
|
105 |
|
106 | // bump versions on package/bower/manifest
|
107 | gulp.task('bump', function () {
|
108 | // reget package
|
109 | var pkg = getPackageJson();
|
110 | // increment version
|
111 | var newVer = semver.inc(pkg.version, 'patch');
|
112 |
|
113 | // uses gulp-filter
|
114 | var manifestFilter = tasks.filter(['manifest.json']);
|
115 | var regularJsons = tasks.filter(['!manifest.json']);
|
116 |
|
117 | return gulp.src(['./bower.json', './package.json', './src/manifest.json'])
|
118 | .pipe(tasks.bump({
|
119 | version: newVer
|
120 | }))
|
121 | .pipe(manifestFilter)
|
122 | .pipe(gulp.dest('./src'))
|
123 | .pipe(manifestFilter.restore())
|
124 | .pipe(regularJsons)
|
125 | .pipe(gulp.dest('./'));
|
126 | });
|
127 |
|
128 | // Run the gulp tasks
|
129 | gulp.task('default', function(){
|
130 | gulp.run('bump');
|
131 | });
|
132 | ```
|
133 |
|
134 | #### You can view more examples in the [example folder.](https://github.com/stevelacy/gulp-bump/tree/master/examples)
|
135 |
|
136 | ## Options
|
137 |
|
138 | All options are passed to [bump-regex](https://github.com/stevelacy/bump-regex)
|
139 |
|
140 | ## Versioning
|
141 | #### Versioning Used: [Semantic](http://semver.org/)
|
142 | #### String, lowercase
|
143 |
|
144 | - MAJOR ("major") version when you make incompatible API changes
|
145 | - MINOR ("minor") version when you add functionality in a backwards-compatible manner
|
146 | - PATCH ("patch") version when you make backwards-compatible bug fixes.
|
147 | - PRERELEASE ("prerelease") a pre-release version
|
148 |
|
149 | #### Version example
|
150 |
|
151 | major: 1.0.0
|
152 | minor: 0.1.0
|
153 | patch: 0.0.2
|
154 | prerelease: 0.0.1-2
|
155 |
|
156 |
|
157 |
|
158 | ## LICENSE
|
159 |
|
160 | (MIT License)
|
161 |
|
162 | Copyright (c) 2015 Steve Lacy <me@slacy.me> slacy.me
|
163 |
|
164 | Permission is hereby granted, free of charge, to any person obtaining
|
165 | a copy of this software and associated documentation files (the
|
166 | "Software"), to deal in the Software without restriction, including
|
167 | without limitation the rights to use, copy, modify, merge, publish,
|
168 | distribute, sublicense, and/or sell copies of the Software, and to
|
169 | permit persons to whom the Software is furnished to do so, subject to
|
170 | the following conditions:
|
171 |
|
172 | The above copyright notice and this permission notice shall be
|
173 | included in all copies or substantial portions of the Software.
|
174 |
|
175 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
176 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
177 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
178 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
179 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
180 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
181 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|