NPM standard-version patch version problem

1.3k views Asked by At

I'm trying to use standard-version in my javascript project. I added the release script to my package.json:

"scripts": {
    ...
    "release": "standard-version"
}

My problem is that I added a commit to my git repo with the following message:

feat: test

I run npm run release and it increased the patch version of the project.

So my initial version was 0.2.1 (tag: v0.2.1), and it generated 0.2.2 with this commit message

chore(release): 0.2.2

Why didn't it increase the minor version?

2

There are 2 answers

0
whoisYeshua On

I think it would be very useful to specify explicitly that it’s either x.y.z, 0.x.y, or 0.0.x, and x is semver-major, y semver-minor, z semver-patch (this is how the npm ecosystem tends to treat it) — ljharb

Caret ^ match Minor releases (It is also the default value for save-prefix in npm config), but it work different for 0.0.X, 0.X.X and X.X.X

So, for example ^0.0.1 will work like this

[✓] 0.0.1
[x] 0.0.2
[x] 0.0.3
[x] 0.1.0

for ^0.1.0 will work like this

[✓] 0.1.0
[✓] 0.1.1
[✓] 0.1.2
[x] 0.2.0
[x] 0.2.1
[x] 0.3.0

and for ^1.0.0 like normal:

[✓] 1.0.0
[✓] 1.0.1
[✓] 1.1.0
[✓] 1.2.1
[x] 2.0.0

Tilde ~ match Patch releases, doesn't have exceptions in it behavior for 0.0.X, 0.X.X and X.X.X (Perhaps because it is not a default value in npm config, idk really). It has the same behavior everywhere:

~0.0.1

[✓] 0.0.1
[✓] 0.0.2
[✓] 0.0.3
[x] 0.1.0

~0.1.0

[✓] 0.1.0
[✓] 0.1.1
[✓] 0.1.2
[x] 0.2.0
[x] 0.2.1
[x] 0.3.0

~1.0.0

[✓] 1.0.0
[✓] 1.0.1
[x] 1.1.0
[x] 1.2.1
[x] 2.0.0

You can check the behavior here

1
J Krbaio On

Until you publish your first release, the bumping of the package.json is going to be that way. In the package documentation, it is better explained

https://github.com/conventional-changelog/standard-version#first-release