javascript - npm标准版补丁版本问题

标签 javascript git npm semantic-versioning conventional-commits

我正在尝试使用 standard-version在我的 javascript 项目中。我将 release 脚本添加到我的 package.json 中:

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

我的问题是我使用以下消息向我的 git 存储库添加了一个提交:

feat: test

我运行npm run release,它增加了项目的补丁版本。

所以我的初始版本是 0.2.1(标签:v0.2.1),它生成了带有此提交消息的 0.2.2

chore(release): 0.2.2

为什么不增加小版本?

最佳答案

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

插入符 ^ 匹配 Minor releases (它也是 npm 配置中 save-prefix 的默认值),但它对 0.0.X0.X.XX.X.X

因此,例如 ^0.0.1 将像这样工作

[✓] 0.0.1
[x] 0.0.2
[x] 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
[✓] 1.1.0
[✓] 1.2.1
[x] 2.0.0

波浪号 ~ 匹配 Patch releases , 0.0.X0.X.XX.X.X 的行为没有异常(可能是因为它不是npm 配置中的默认值,idk really)。它在任何地方都有相同的行为:

~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

您可以检查行为 here

关于javascript - npm标准版补丁版本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62890719/

相关文章:

javascript - 单选按钮填充颜色

javascript - 无法安装 Node 模块,因为 'This is related to npm not being able to find a file.'

node.js - 无法使用 Windows 10 安装 firebase 工具 cli

javascript - document.location.hash 在 Safari 中不起作用

javascript - 如果客户端先运行,asp.net mvc 5 应该运行服务器端验证

javascript - 如何创建一个网页,具有固定的背景图像,顶部的 div 滚动,但也平滑地滚动底部固定的 bg 图像?

git - 在所有 Git 分支中搜索关键字

Git的本地仓库和远程仓库——容易混淆的概念

git - 使用 revert 多次回滚到旧提交

Node.js 找不到模块 - 干扰 Windows 上的 cygwin