NPM - 暂存文件未添加以使用 npm 版本提交

NPM - staged files not adding to commit with npm version

目前正在尝试配置 npm,这样当我 运行 npm version 时,它会在 package.json 中设置版本,然后将当前暂存的所有内容添加到其提交中,并且npm 文档使它看起来像这是可能的,但我不断收到错误消息,指出该命令不能 运行 因为我的工作目录不干净。

理想情况下,我不想将 -f 添加到我的 npm version 命令中。

我的package.json

"scripts": {
    ...
    "nv": "node newversion.js", /*Creates a changelog and runs npm version*/
    "preversion": "git add -A",
    "version": "git add -A"
  }

npm version 1.4.1 -m "%s -> custom scrollbars"

-> npm ERR! Git working directory not clean.

在 运行 之前手动暂存 npm version 也不起作用。

有什么我想念的吗?我不是超级 npm- 或 package.json-知识渊博,所以任何帮助将不胜感激。

最后,目标是能够 运行 npm-version 并且它在工作目录中暂存任何内容并将其添加到 npm-version 所做的提交中。

另一种方法是使用 package standard-version,它会生成更新日志并更新版本。

参见“Automatically generate and release a changelog using Node.js" (Jul. 2021) from Indermohan Singh (Software Developer at Ubiq.ai | Creator of ragakosh.com)

npm run release

Running the command above will show the following message on the screen:

> changelog@1.0.0 release /home/imsingh/Develop/inder/changelog
> standard-version

✔ bumping version in package.json from 1.0.0 to 1.1.0
✔ bumping version in package-lock.json from 1.0.0 to 1.1.0
✔ created CHANGELOG.md
✔ outputting changes to CHANGELOG.md
✔ committing package-lock.json and package.json and CHANGELOG.md
✔ tagging release v1.1.0
ℹ Run `git push --follow-tags origin master && npm publish` to publish