每次我通过 git 更新可用的包时,我都需要发布到 npm 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13507763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:47:37  来源:igfitidea点击:

Do I need to publish to npm every time I update a package available via git?

gitpublishnpm

提问by hurrymaplelad

Say I maintain an incredible crab-seasonpackage. I've npm published version 0.1.0 with a package.jsoncontaining:

假设我维护了一个令人难以置信的crab-season包。我已经npm publish编辑了 0.1.0 版,其中package.json包含:

"repository": {
  "type": "git",
  "url": "https://github.com/example/crab-season.git"
}

When I add awesome new features, bump the version to 0.2.0, and push to github will the npmjs registry notice my new version or do I need to npm publisheach time?

当我添加很棒的新功能,将版本提升到 0.2.0,然后推送到 github 时,npmjs 注册表会注意到我的新版本还是npm publish每次都需要?

采纳答案by hurrymaplelad

After publishing a few modules, the answer is yes, you need to npm publishto get new versions on npmjs.

发布了几个模块后,答案是肯定的,你需要npm publish在 npmjs 上获取新版本。

This gives the module author the flexibility to bump their version number as soon as they start work on the next version, or any time before the version is finished.

这使模块作者可以在下一个版本开始工作时或在版本完成之前的任何时间灵活地增加他们的版本号。

npm versionhandily speeds up this flow by detecting a git repository, bumping the version in package.json, committing the change, and tagging the change with the version number.

npm version通过检测 git 存储库、插入版本package.json、提交更改并使用版本号标记更改,可以轻松加快此流程。

回答by hurrymaplelad

Travis CI can publish to npm when you push a version tag to reduce the overhead of releasing a change. Enable in your .travis.ymlwith:

Travis CI 可以在推送版本标签时发布到 npm 以减少发布更改的开销。启用您.travis.yml的:

deploy: 
  provider: npm
  api_key: "YOUR API KEY"
  on:
    - tags: true

Check the travis docsfor details. There's also a step-by-step guide in this post.

查看travis 文档以获取详细信息。这篇文章中还有一个分步指南。