Giter VIP home page Giter VIP logo

gulp-bump's People

Contributors

coliff avatar crea1 avatar dawsbot avatar edgarnadal avatar geminorum avatar kingdutch avatar knpwrs avatar mgcrea avatar mikaelbr avatar pgilad avatar pioug avatar scamden avatar stephenlacy avatar stevelacy avatar tomchentw avatar yocontra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-bump's Issues

Incorrect work with nested keys

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:

  • when I set version explicitly it's writing to dotted property instead of nested one:
{
   AppSettings: {
      Version: "0.1.0"
   }, 
   ...
   "AppSettings.Version": "0.1.1"
}
  • when it checking with semver it's always invalid because of undefined

It's need to replace plain content[opts.key] to something more intellectual like Object.byString from this example.

Custom setters for fields other than version

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() :)

increment the version of other keys

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');

Additional xml support

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

Chrome Extension manifest.json

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.

Feature Request: Git Bump

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?

return new version?

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'));

Bad versión bumped

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.

Properties File support

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.

Specify version to bump to

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)

Missing support for option version

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?

Bumping version in non-json files?

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.

npm is out of date

Looks like the package was published to npm when const was used for PLUGIN_NAME. I have to use the old version for now

Nested properties don't work with version property

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.

Feature Request(s): Tag version and create HISTORY.md

  1. It'd be awesome if there was a boolean flag for creating a git tag with the current version too. That way you could have a git tag created for every version bump you do too.
  2. Use the history and top level commits messages to build out a HISTORY.md or some sort of change log that is auto generated. I'd probably just use it as a starting point to write my own change log, but with open source dev most of the things that are merged to master tend to be either feature branches or bug fixes. Having a list of the merges auto created would be amazing!

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.

Ability to bump versions in PHP files for WordPress

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?

Rename options.bump to options.type

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? :)

operation not permitted,

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.

Bump is stripping out build info from tag

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. 👍

Buildmeta support

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 :)

How can I ensure the same version between several packages?

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.

Inconsistent bumping with Gulp 4

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))

Prerelease bump not working in conjunction with NuGet

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.

Add an alias to npm named gulp-version

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

1.2.3 is not a valid semver version

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?

Returns version number twice

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 ...

bump works on package.json but git doesn't see the change!

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:

video link

I suspect it may be down to bump-npm not modifying the file's date.

Define multiple keys

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.

Choose version via terminal

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?

Bump version in child objects.

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;
});

Bump patch automatically increments SNAPSHOT to next patch version

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"
...
}

Bump version x.x.10 is .1

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.