Semantic-Versioning 语义化版本控制

一个标准的版本号必须是X.Y.Z的形式,X是主版本,Y是副版本,Z是补丁版本。

  • X: 代表发生了不兼容的API改变

  • Y: 代表向后兼容的功能性变化

  • Z: 代表向后兼容bug fixes

语义化版本号规则

        X.Y.Z - A.B.C 连字符范围

        1.2.3 - 2.3.4 等价于 >=1.2.3 <=2.3.4
        1.2.3 - 2 等价于 >=1.2.3 <3.0.0

~1.2.3 波浪线范围

        ~1.2.3 等价于 >=1.2.3 <1.(2+1).0 等价于="">=1.2.3 <1.3.0
        ~1.2 等价于 >=1.2.0 <1.(2+1).0 等价于="">=1.2.0 <1.3.0 (Same as 1.2.x)
        ~1 等价于 >=1.0.0 <(1+1).0.0 等价于 >=1.0.0 <2.0.0 (Same as 1.x)

        ~0.2.3 等价于 >=0.2.3 <0.(2+1).0 等价于="">=0.2.3 <0.3.0
        ~0.2 等价于 >=0.2.0 <0.(2+1).0 等价于="">=0.2.0 <0.3.0 (Same as 0.2.x)
        ~0 等价于 >=0.0.0 <(0+1).0.0 等价于 >=0.0.0 <1.0.0 (Same as 0.x)

^1.2.3 脱字符范围

        脱字符范围之后指定从左面起第一个非零位置的范围。

        ^1.2.3 等价于 >=1.2.3 <2.0.0
        ^0.2.3 等价于 >=0.2.3 <0.3.0
        ^0.0.3 等价于 >=0.0.3 <0.0.4,即等价于0.0.3

        当然如果最后一位省略了或为通配符x,X,*,则指定前一位字符的范围,如

        ^1.2.x 等价于 >=1.2.0 <2.0.0
        ^0.0.x 等价于 >=0.0.0 <0.1.0
        ^0.0 等价于 >=0.0.0 <0.1.0

简单来讲

  • < Less than

  • <= Less than or equal to

  • > Greater than

  • >= Greater than or equal to

  • = Equal. If no operator is specified, then equality is assumed, so this operator is optional, but MAY be included.

  • * := >=0.0.0 (Any version satisfies)

  • 1.x := >=1.0.0 <2.0.0 (Matching major version)

  • 1.2.x := >=1.2.0 <1.3.0 (Matching major and minor versions)

参考文档

        https://semver.org/

        https://docs.npmjs.com/misc/semver

猜你喜欢

转载自my.oschina.net/u/3705266/blog/1810849