本文共 2810 字,大约阅读时间需要 9 分钟。
npm 语义化发布
If there’s one great thing in Node.js packages, is that all agreed on using Semantic Versioning for their version numbering.
如果Node.js软件包中有一件很棒的事情,那就是所有人都同意使用语义版本控制来为其版本编号。
The Semantic Versioning concept is simple: all versions have 3 digits: x.y.z
.
语义版本控制的概念很简单:所有版本都有3位数字: xyz
。
When you make a new release, you don’t just up a number as you please, but you have rules:
发布新版本时,您不仅可以随心所欲地增加数字,还可以遵循以下规则:
The convention is adopted all across programming languages, and it is very important that every npm
package adheres to it, because the whole system depends on that.
该约定在所有编程语言中npm
,每个npm
软件包都必须遵守该约定,因为整个系统都依赖npm
,这一点非常重要。
Why is that so important?
为什么这么重要?
Because npm
set some rules we can use in the to choose which versions it can update our packages to, when we run npm update
.
因为npm
设置了一些规则,所以当我们运行npm update
时,可以在使用它来选择将软件包更新到的npm update
。
The rules use those symbols:
规则使用这些符号:
^
^
~
~
>
>
>=
>=
<
<
<=
<=
=
=
-
-
||
||
Let’s see those rules in detail:
让我们详细了解这些规则:
^
: if you write ^0.13.0
when running npm update
it can update to patch and minor releases: 0.13.1
, 0.14.0
and so on.
^
:如果你写^0.13.0
运行时, npm update
:它可以更新打补丁和次要版本0.13.1
, 0.14.0
等等。
~
: if you write ~0.13.0
, when running npm update
it can update to patch releases: 0.13.1
is ok, but 0.14.0
is not.
~
:如果编写~0.13.0
,则在运行npm update
时可以更新到补丁程序版本: 0.13.1
可以,但0.14.0
不能。
>
: you accept any version higher than the one you specify
>
:您接受比您指定的版本更高的任何版本
>=
: you accept any version equal to or higher than the one you specify
>=
:您接受等于或高于您指定的版本的任何版本
<=
: you accept any version equal or lower to the one you specify
<=
:您接受等于或低于您指定的版本的任何版本
<
: you accept any version lower to the one you specify
<
:您接受低于指定版本的任何版本
=
: you accept that exact version
=
:您接受该确切版本
-
: you accept a range of versions. Example: 2.1.0 - 2.6.2
-
:您接受各种版本。 例如: 2.1.0 - 2.6.2
||
: you combine sets. Example: < 2.1 || > 2.6
||
:您组合套。 示例: < 2.1 || > 2.6
< 2.1 || > 2.6
You can combine some of those notations, for example use 1.0.0 || >=1.1.0 <1.2.0
to either use 1.0.0 or one release from 1.1.0 up, but lower than 1.2.0.
您可以合并其中的一些符号,例如,使用1.0.0 || >=1.1.0 <1.2.0
1.0.0 || >=1.1.0 <1.2.0
,以使用1.0.0或从1.1.0起的一个发行版,但低于1.2.0。
There are other rules, too:
还有其他规则:
no symbol: you accept only that specific version you specify (1.2.1
)
无符号:您仅接受指定的特定版本( 1.2.1
)
latest
: you want to use the latest version available
latest
:您想使用可用的最新版本
翻译自:
npm 语义化发布
转载地址:http://xmqgb.baihongyu.com/