gpt4 book ai didi

NPM build with version number(带有版本号的NPM内部版本)

转载 作者:bug小助手 更新时间:2023-10-28 11:05:04 25 4
gpt4 key购买 nike



Is there a way to update the version number of my react app package.json version variable via command line? Maybe with npm build or before/after npm build?

有没有办法通过命令行更新我的React应用程序Package.json版本变量的版本号?也许使用NPM构建,或者在NPM构建之前/之后?


I have a build server that will run npm build and then deploy to production. I want to be able to update the version number of my application either during the build process or before it as part of the build pipeline. I am planning to just use the last git commit sha as the version number.

我有一个构建服务器,它将运行NPM构建,然后部署到生产中。我希望能够在构建过程中更新我的应用程序的版本号,或者在它作为构建管道的一部分之前更新。我计划只使用最后的Git Commit SHA作为版本号。


Is there a command that I am missing? I have had a look at npm version but I believe that is for just updating packages. I could be wrong.

有没有我遗漏的命令?我已经看过NPM版本了,但我相信那只是为了更新包。我可能错了。


更多回答

you mean the semver management command npm version (major|minor|patch)?

您是说Semver管理命令NPM版本(主要|次要|补丁)?

@Mike'Pomax'Kamermans does this allow me to set a unique version or just increment the semantic version?

@Mike'Pomax'Kamermans这是否允许我设置一个唯一的版本或只是增加语义版本?

If you're using npm, you should absolutely only ever use semver. If you need build numbers, that's what patch is for (and if you need build dates, that's in the tag commit and trivial to look up)

如果你在使用NPM,你绝对应该只使用Semver。如果您需要内部版本号,这就是补丁的用途(如果您需要构建日期,请在提交标记中查找)

优秀答案推荐

You can use,

您可以使用,


npm version [major|minor|patch]

to bump the version variable on package.json using cli.

使用cli在Package.json上增加版本变量。


If you want to combine it with the build, you can use;

如果您想要将其与构建相结合,您可以使用;


npm version [major|minor|patch] && react-scripts build

References



  1. npmjs.com for syntax documentation.

  2. semvar.org for version notation.


更多回答

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