gpt4 book ai didi

npm - 如何生成 NPM 发布候选版本

转载 作者:行者123 更新时间:2023-12-04 10:34:05 29 4
gpt4 key购买 nike

假设我想生成一个预发布的 NPM 版本。

原来我有这个:

   "version": "0.0.1"

我试过:
npm version prepatch
npm version prepatch
npm version preminor
npm version preminor

这给了我这个:
v0.0.2-0
v0.0.3-0
v0.1.0-0
v0.2.0-0

那些对我来说看起来没什么用,因为它们总是增加实际版本号,意思是 npm version patchnpm version prepatch似乎没有太大区别。

所以我的问题是 - 是否有官方方法可以在命令行中使用 npm 生成 alpha/beta 版本?
npm version minor-alpha
npm version minor-beta
npm version minor-rc

类似的东西?

最佳答案

更新
截至 npm 6.3.0-next.0您现在可以使用 --preid使用 version 标记预发布版本时.

npm version prerelease --preid=next
NPM 链接: https://docs.npmjs.com/cli/version

原答案
可悲的是(有点讽刺)npm 并不完全支持 semver 的所有功能!
您需要的是名为 pre-id 的功能,可在 semver spec #9 中找到。 .我已经向 npm 提交了一个 PR 来修复它,但它被拒绝了。 https://github.com/npm/npm/pull/13794
preids 基本上允许您为预发布指定一个 id,例如:
1.0.0-alpha or 1.0.0-alpha.1
Forrest 在 comment 中拒绝了这个提议写这个:

After some further consideration, and discussion within the team, I've decided that this isn't a change the CLI team is going to land. Working with prerelease versions is tricky, and this feature is enough of an edge case that I think it increases, rather than decreases, the number of opportunities for prerelease versions to be a footgun.

My concern about footguns is connected to the decision, in semver@^4, to make prerelease versions fall outside the range matching for ~ and ^. Were semver's behavior to change, it might make more sense to have a way to opt into (and then increment within) a given prerelease identifier. After watching the travails of the React community in using prerelease versions with peerDependencies and other interrelated suites of packages, it's pretty clear that the current behavior of semver with respect to prerelease versions is of pretty limited usefulness. That means there's a substantial possibility that that behavior may change.

As it stands, though, I think users who want to use prerelease versions are better off using third-party tools like npmversion, or build scripts that use npm version "x.y.z-prealpha.2" (or whatever suits your use case) instead. Thanks for your time, and my apologies for the delay!


正如他所建议的那样,要使其正常工作,您应该使用支持完整 semver 版本控制的工具。我个人推荐 semver 包,在 npm 文档中找到这里 https://docs.npmjs.com/misc/semver

关于npm - 如何生成 NPM 发布候选版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50846170/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com