Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Bumping version in non-json files? #40

Closed
ospatil opened this issue Jun 13, 2015 · 13 comments
Closed

Bumping version in non-json files? #40

ospatil opened this issue Jun 13, 2015 · 13 comments

Comments

@ospatil
Copy link

ospatil commented Jun 13, 2015

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.

@dalelotts
Copy link

+1 - looking forward to supporting non-json file

@stephenlacy
Copy link
Owner

We started out with using a regex just parsing the version string. It was changed to support only pure semver and json.

Parsing with regex is messy, especially with Windows/Mac style quotes found in non-json files.
Grunt-bump also only supports json versions unless you provide your own regex in options.regExp

I am open to adding a regex option to gulp-bump while parsing json by default.

@joshuahiggins
Copy link

You could look to grunt-bump for pattern matching. They seem to handle version bumping in any file type without issue.

var VERSION_REGEXP = opts.regExp || new RegExp(
  '([\'|\"]?version[\'|\"]?[ ]*:[ ]*[\'|\"]?)(\\d+\\.\\d+\\.\\d+(-' +
  opts.prereleaseName +
  '\\.\\d+)?(-\\d+)?)[\\d||A-a|.|-]*([\'|\"]?)', 'i'
);
if (opts.globalReplace) {
  VERSION_REGEXP = new RegExp(VERSION_REGEXP.source, 'gi');
}

regExp - Allows user to set their own regex pattern
prereleaseName - To set an 'alpha', 'rc', etc prerelease name
globalReplace - Tells script to find once per file or not

@stephenlacy
Copy link
Owner

Yes, as I have already mentioned we did originally do that.

I will not remove the current support for JSON only files.
I am open to a PR adding a new option for regex alongside the current support.

@joshuahiggins
Copy link

I guess I was confused as you stated "Grunt-bump also only supports json versions unless you provide your own regex" which isn't true. That or I have no clue what you mean by JSON versions, since I have no problem swapping versions on any files with grunt-bump.

@stephenlacy
Copy link
Owner

The regex they provide will only operate on: "version": " " parameters which is JSON, unless you provide your own regex.

This is going off topic though...

@joshuahiggins
Copy link

The regex they provide will only operate on: "version": " " parameters which is JSON, unless you provide your own regex.

This is not correct. I have no problem's bumping a comment block like so:

/****
* Package: Blah
* Version: 1.0.2-dev.1
* Whatever else
****/

This is why I brought up their RegEx in the first place. Hardly off-topic, considering it's directly related to the topic of bumping non-JSON files, as @ospatil reported.

The reality is that many users of Grunt will come from grunt-bump to gulp-bump and expect similar behavior as found in many other Gulp packages that share a name with their Grunt counterparts. It's not unreasonable in my opinion to mention how a Grunt package handles said functionality.

@lucientaylor
Copy link

the option to bump non-json by providing our own regex patterns would be a good thing

@stephenlacy
Copy link
Owner

Anyone want to take this on and merge it with #39? Both are options for regex
I'm rather busy as of late.

Cheers

@tomalec
Copy link

tomalec commented Dec 7, 2015

👍 for bumping non-JSON files.
Unfortunately I feel too newbie in gulp, to handle PR

@stephenlacy
Copy link
Owner

@ospatil
https://github.com/stevelacy/gulp-bump/releases/tag/2.0.1
Added full support for versions in any file - using the regex from grunt-bump

@stephenlacy
Copy link
Owner

Now returns new and old version bumped via bumpData

@easyfrog
Copy link

Now returns new and old version bumped via bumpData

@stevelacy
But how to get this bumpData parameter?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants