stephenlacy / gulp-bump Goto Github PK
View Code? Open in Web Editor NEWBump any version in any file which supports semver with gulp (gulpjs.com)
License: MIT License
Bump any version in any file which supports semver with gulp (gulpjs.com)
License: MIT License
When I use dotted key (e.g. 'AppSettings.Version') the script can't read actual version from json because content[opts.key]
works wrong with nested properties.
It affects in some places:
{
AppSettings: {
Version: "0.1.0"
},
...
"AppSettings.Version": "0.1.1"
}
undefined
It's need to replace plain content[opts.key]
to something more intellectual like Object.byString
from this example.
It is an object with functions mapped to property names that accept old property values and return new ones. Could work something like this:
gulp.task('bump', function () {
var options = {
bump: 'minor'
};
var setters = {
date: function (oldDate) {
return new Date().toISOString();
}
};
gulp.src('./package.json')
.pipe(bump(options, setters))
.pipe(gulp.dest('./'));
});
This will, apart of the version
, also update the date
property.
As setter could return objects/arrays, doing this with regex probably isn't enough, and JSON.parse()
, JSON.stringify()
must be used, in which case I'd like to ask you to detect the indentation of the original file so you can pass it to .stringify()
:)
Maybe I don't read enough, but couldn't find how to do that
For example I have some keys as "appversion:"0.9.2" and "libversion:"0.9.4" in the package.json that I am referencing.
I needed a way to bump this version when I do a deployment
So I added an option
vers:['appversion','libversion']
which should be an array with all the keys to be bumped
The changed code is
var vers = opts.vers || [];
var json = JSON.parse(file.contents.toString());
if(vers.length > 0)
vers.forEach(function(v) {
json[v] = semver.valid(opts.version) || semver.inc(json[v], opts.type || 'patch');
})
else
json.version = semver.valid(opts.version) || semver.inc(json.version, opts.type || 'patch');
We use a pom.xml to generate a war artifact and would appreciate support for bumping a version in an xml file with the following format:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<name>myProject</name>
<packaging>war</packaging>
<version>1.0.0</version>
</project>
Currently this errors with
Message:
Invalid semver: version key "version" is not found in file
When the source version is incorrect, preid value is ignored.
Probably use a *.json
glob and explain how it would bump both versions, thus keeping them in sync.
My thoughts went to a bower.json
and package.json
that would need to be kept in sync.
Is there a way to change prerelease from 0.0.1-2 format to be formated like 0.0.1.2?
Google states that a manifest.json versionnumber must be between 1-4 dot-separated integers each between 0 and 65536.
If this is outside the scope of this project, I completely understand.
Gulp lacks a task at current that not only bumps packages, but commits, tags and pushes in git.
Thoughts?
I have an ionic project which have a config.xml containing version number. The version is not found with bump. Is xml file supported or not?
Is there a change to access the version directly after it got changes?
would like to do the following and use the version in the commit message:
gulp.src('./package.json')
.pipe(bump({type:'minor'}))
.pipe(gulp.dest('./'));
.pipe(git.commit('bumps package version'));
Hi everyone,
its seems that the last versión of the gulp-bump not support version like "2016.0.1-SNAPSHOT". We discussed this issue in nfantone/gulp-release#20.
This version number is accepted by semver and not long time ago that i released projects with this versioned without problems.
i.e. premajor, minor, preminor and prepatch.
Unless there's a reason why it's not there 😄
Bump any semvar JSON version with gulp (gulpjs.com)
semvar -> semver
It would be totally awesome if this plugin also handled *.properties
files. Yes I know, JSON is better, but I'm stuck using Sonar and would like to bump that version at the same time as my bower and npm versions.
Hey,
I just ran into this interesting bug. I had a new version 11.1.0
and an old version in package.json
, of 11.0.1
. When I ran bump({version: '11.1.0'})
, it ended up with 111.1.0
in the package.json
[email protected]
[email protected]
cc @diasdavid
As mentioned in #7, it would be great if you could do:
$ gulp bump --ver=1.2.0
where the ver
argument would fix all configs to this version (--version
is used by gulp itself).
I'm happy to send in a PR if you agree.
(in this case keeping the plugin's current name might make more sense)
the option version
appears in the readme but no in the actual code.
You mind if I redo this entire plugin to use through2
and add try/catch for the JSON parse as well?
Wouldn't it be a good idea to support bumping version in non-json files too? For example - markdown files like readme. I have been primarily a grunt user so far and the grunt-bump plugin allows it. Looking at code, I see grunt-bump uses regex search and replace while gulp-bump uses JSON.parse.
Adding such support shouldn't be too difficult and I would be happy to submit a pull request. Let me know.
for example, my current version number is 1.12.84 and when I do a major release I want to increment the major version number but also make the minor and patch numbers to '0', which is something like this '2.0.0'. how to achieve that ?
Looks like the package was published to npm when const
was used for PLUGIN_NAME
. I have to use the old version for now
Hi guys,
What if the version in package.json has a prefix like v1.6.1?
When I try the gulp-bump it says that this is invalid semver .. but actually it is so important to support prefixes?
Any workaround?
Thanks.
Hello,
Great plugin! Thanks for your work on it.
I've run into an issue when using nested properties via dot notation. We develop in-house NPM packages that are included via devDependencies in package.json. When ready to issue a PR, and then subsequently send to QA, we want to bump the version for any NPM packages we worked on with the change, and then update the referenced version in the main application's package.json file.
In the below example, I already have access to the dependent package's new version number and am trying to apply it to the app's reference in the devDependencies section of package.json:
package.json
{
"name": "my-app",
"version": "0.1.0",
...,
"devDependencies": {
...,
"my-custom-package": "1.0.1",
...
}
}
gulp task
gulp.task('bumpAppVersionTest', function () {
var pkgLoc = 'devDependencies.my-custom-package';
var pkgVer = '1.0.2';
return gulp.src('./package.json')
.pipe(bump({key: pkgLoc, version: pkgVer}))
.pipe(gulp.dest('./'));
});
When the task is run, the following is the result:
Console output
...
[09:09:56] Creating key devDependencies.my-custom-package with version: 1.0.2
[09:09:56] Bumped 'package.json' devDependencies.my-custom-package to: 1.0.2
...
This results in a new key being added at the root level to package.json:
package.json - after the task has run
{
"name": "my-app",
"version": "0.1.0",
...,
"devDependencies": {
...,
"my-custom-package": "1.0.1",
...
},
...,
"devDependencies.my-custom-package": "1.0.2"
}
If I modify the task to not include the version property the nesting works as expected:
gulp task
gulp.task('bumpAppVersionTest', function () {
var pkgLoc = 'devDependencies.my-custom-package';
var pkgVer = '1.0.2';
return gulp.src('./package.json')
.pipe(bump({key: pkgLoc}))
.pipe(gulp.dest('./'));
});
Console output
[09:15:22] Bumped 'package.json' devDependencies.my-custom-package to: 1.0.2
package.json - after the task has run
{
"name": "my-app",
"version": "0.1.0",
...,
"devDependencies": {
...,
"my-custom-package": "1.0.2",
...
}
}
Seems that the inclusion of the version property is fouling things up. I didn't test adding other properties, just version.
Granted, these are both pretty specific to git, but i think you could do either of them with mercurial or svn too, but I think most people are using github to host their open source projects.
That would be so cool.
Something like this
gulp.src('./index.php') // entry point of a certain wordpress plugin
.pipe(bump({versionNew: '1.2.3', versionCurrent: '1.2.2'}))
.pipe(gulp.dest('./'));
Reason we need current and new version is because each WordPress plugin uses different formats/variables to store them. Hence search occurences for current version and change that. Or have a better idea?
Semantically way more fitting. Even in semver docs it is clasified as "release type".
And:
bump({ type: 'minor' }); // bump type minor
Looks/Sounds way more sensible than:
bump({ bump: 'minor' }); // bump bump minor
Please? While it's still time? :)
Error: EPERM: operation not permitted, I am getting this error after I run bump even though the package.json file has full access [09:54:21] Bumped 3.2.13 to 3.2.14 with type: patch and the package.json file is updating.
I've got a similar script like this one https://github.com/nicksrandall/gulp-release-tasks/blob/master/tasks/release.js which relies on the output of gulp-bump
to figure out the next version. With your latest version v2 this is breaking.
Can you put back the gutil.log like this one?
https://github.com/stevelacy/gulp-bump/blob/4385850bb490c358f5bc3b16fe99c476c48ddd59/index.js#L87
Thanks!
Hey,
Semver describes the ability to add addition of prerelease and build metadata at the end of a version string. Currently if I pass 1.0.6-1+build-623
to the version option it will only output 1.0.6-1
.
Im hoping to use this to output to a constants file for a angular app, allowing me to log errors against a build version in the running app with Sentry. We deploy new builds without updating the version for refactors of the code. We only use patch for bugs.
Not sure if its would help with the internals of gulp bump but Im using semver-utils to parse the string and increment before passing it to bump.
Thanks for the great lib. Currently using it for tagging builds and its working great. 👍
Semver supports/recognizes the buildmeta suffix, so there should be a way how to add it. Buildmeta is the +[meta]
part in semver:
1.0.0-rc.1+4321
1.0.0+4321
The command line implementation isn't doable right now (at least not in any sensible way), but I've already opened an orchestrator issue requesting passable parameters that should make it possible.
It could than be implemented like:
gulp.task('bump:{type=patch}:{buildmeta}', function (params) {
gulp.src('package.json')
.pipe(bump({ type: params.type }, params.buildmeta))
.pipe(gulp.dest('./'));
});
And called like:
gulp bump:build:[buildmeta] // doesn't change anything, only appends the buildmeta
gulp bump:minor:[buildmeta] // bumps minor and appends buildmeta
gulp bump:minor // only bumps minor
I personally don't need it, but there have been requests for it in grunt-bumpup and I had to implement it, so warning beforehand :)
If version
is not set it will bypass creating it.
https://github.com/stevelacy/gulp-bump/blob/master/index.js#L49-L63
Ideas:
If possible, could you publish 0.1.4 to npm? Thank you!
For example:
gulp.task('bump', function(){
gulp.src(['./bower.json', './component.json', './package.json'])
.pipe(bump({type:SOME_CONSOLE_VALUE'}))
.pipe(gulp.dest('./'));
});
And used like this:
gulp bump --type="major"
currently example suggest:
// Update bower, component, npm at once:
gulp.task('bump', function(){
gulp.src(['./bower.json', './component.json', './package.json'])
.pipe(bump({type:'major'}))
.pipe(gulp.dest('./'));
});
but this would bump each version separately. What if I want to keep the same version throughout the jsons?
what I currently use:
var newVer = semver.inc(pkg.version, 'patch');
gutil.log('Bumping version', gutil.colors.cyan(pkg.version), '=>', gutil.colors.blue(newVer));
gulp.src(['./bower.json', './package.json'])
.pipe(bump({
version: newVer
}))
.pipe(gulp.dest('./'));
But this could be incorporated into the plugin in order to ensure the same version. Perhaps maybe using the first's file version or maybe specifying a file to use it's version.
Using the hello world example from the docs, my bower.json
updates inconsistently. I always receive the output that the bump was successful, but frequently my bower.json
file isn't updated.
I'm using Gulp 4 - maybe my issues are related to the new version?
return gulp.src('./bower.json')
.pipe(bump( { type: bumpType } ))
.pipe(gulp.dest(config.package.dest))
It would be nice to have the version bumped from/to printed to the console.
Cheers
Great library.
I am having some issues interoperating with NuGet because NuGet expects the pre-release format to be something like.
1.2.3-alpha00003
1.5.9-beta00005
2.8.7-RC1
According to SemVer these are supposed to be supported.
A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
But there is a twist with using them in NuGet - you cannot put a .
in the pre-release part of the version. I found that you have a preid option that allows you to specify "alpha", etc. but there doesn't seem to be any way to remove the period after the identifier. I guess NuGet is leveraging the fact that the part after the period is optional and the identifier must be alphanumeric (meaning it can contain a version number).
It is also a NuGet convention to pad the number with leading zeros so the version comparison logic works right. Otherwise 1.0.0-alpha9
will be a higher version than 1.0.0-alpha10
.
There also seems to be an issue with the way you implemented the preid - if it is not supplied to the command, but it does exist in the .json
file it will be removed instead of bumping the version. But according to the spec it is required during pre-release, so this logic is invalid.
It would be nice if you could fix this. Fortunately other than the pre-release stage it works great. Thanks.
I can already see someone creating a gulp-version
because they don't use the term bump and don't find this in search. Should these be a gulp-version
package that just depends on this and exports it?
/cc @contra
After upgrading from 1.0.0 to 2.x.x and while setting an arbitrary version like this:
bump({
version: '1.2.3'
})
gulp bump always throw an invalid semver
which wasn't thrown in 1.0.0
Is that related to the fact that opts.type is always set to 'patch' or am I doing something wrong?
When you have a task like this
gulp.task('bumpVersion', () => {
const bumpOptions = {}
if (options.version) {
bumpOptions.version = options.version
} else if (options.importance) {
bumpOptions.type = options.importance
}
return gulp.src(['./package.json', './src/ninja-forms-videomail.php'])
.pipe(plugins.bump(bumpOptions))
.pipe(plugins.if(options.write, gulp.dest(function (file) {
return path.dirname(file.path)
})))
.on('error', plugins.util.log)
})
and use something like this in a bash script
read VERSION <<< $(gulp bumpVersion --importance=$IMPORTANCE | awk '/to/ {print $5}')
then $VERSION will have the number twice like this 3.3.1 3.3.1
and is invalid.
I think a function inside gulp-bump should return the number only once. Not sure ...
I have a task called bump-npm
:
gulp.task('bump-npm', function() {
return gulp.src('./package.json')
.pipe(bump())
.pipe(gulp.dest('./'));
});
it works in so far as it bumps the version from 0.0.x to 0.0.x+1. Unfortunately it must be doing it in some sort of "sneaky" way as my git status remains unchanged even though the package (not surprisingly is NOT in .gitignore
).
Here's a video demonstrating this:
I suspect it may be down to bump-npm not modifying the file's date.
Currently version
is the default key for changing versions. But in WordPress plugins there is also Stable tag
for versioning inside readme.txt.
That said, when having package.json and readme.txt both, how can a gulp-bump task bump both in one go? Something like key: ['version', 'Stable tag']
would be cool.
I think it would be great when gulp-bump is so great, that we can insert in terminal something like:
gulp bump --major
After this gulp-bump change the correct number based on the value, which the user insert after the task. Do you know what I mean?
I have a version.txt file that is currently being bumped by grunt-bump. The contents of the file are below:
{
versionInfo: {
version: 0.0.1
}
}
Can the "key" parameter be dot separated so that any key in the structure can be bumped, without affecting the overall structure?
The workaround that I've developed is here, but it's a synchronous task in an asynchronous process so it also requires Q:
gulp.task('bump', function(){
var version = null;
var deferred = Q.defer();
gulp.src(['package.json', 'bower.json'])
.pipe(bump())
.pipe(tap(function(file){
if(version){ return; }
var json = JSON.parse(String(file.contents));
version = json.version;
}))
.pipe(gulp.dest('./test'))
.on('end', function(){
gulp.src(['version.txt'])
.pipe(jeditor(function(json){
json.versionInfo.version = version;
return json;
}))
.pipe(gulp.dest('./'))
.pipe(function(){
deferred.resolve();
});
});
return deferred.promise;
});
I can't figure out how to get there from here. If I do bump minor i get my 1.1.0, then if i do bump prerelease I get 1.1.1-RC1.
At the moment, gulp-bump automatically bumps SNAPSHOT to the next patch version. For example, commanding bump({type:'patch'})
for 1.0.0-SNAPSHOT is patch bumped to 1.0.1 . It would be really helpful if instead it matched what npm version patch
does, which is bump the snapshot to 1.0.0 instead:
package.json before version bump
{
...
"version": "1.0.0-SNAPSHOT"
...
}
Bump version:
npm version patch
package.json after version bump (Desired output)
{
...
"version": "1.0.0"
...
}
Just noticed, that a version with a patch .10 is reduce to .1 thus overwriting the original .1 tag
Is this typical semversion or a bug?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.