MrSeaWave / blogs

✍🏻 个人博客,记录、分享一写随笔和技术知识
https://hailangya.com
3 stars 0 forks source link

使用 np 快速发布 npm 包 #75

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

使用 np 快速发布 npm 包 - Sea's Blog

在之前的文章中 《怎么发布 NPM 包》中,已经介绍了如何使用 npm 进行发包,本文将会介绍一款发包工具 np ,它是由 sindresorhus 大神所创造的一套 npm published 工具,比 npm 原生的 npm publish 多了更多方便的功能!

https://mrseawave.github.io/blogs/articles/2022/01/27/np-publish/

MrSeaWave commented 2 years ago

如果只是想要 版本选择提示,这里推荐 version-bump-prompt

img

MrSeaWave commented 2 years ago

如果想要 CHANGELOG.md 和 package.json 一起发布

如果 CHANGELOG 是符合 Keep a Changelog ,那么利用 version-changelog 在 package.json中 增加 version script也不失为一种好的方式,参考示例

{
  "scripts": {
    "release": "np --no-2fa --message \"chore(release): v%s \"",
    "version:tips": "---------- 在运行release时,会运行version脚本,更新 CHANGELOG 并随着release脚本一起提交",
    "version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md"
  },
  "devDependencies": {
    "changelog-verify": "^1.1.2",
    "np": "^7.6.0",
    "version-changelog": "^3.1.1"
  }  
}