如何用ts搭建一个vue3通用项目底座 | 第二篇(6):release-it 自动管理版本号

前言

上一篇自动生成CHANGELOG,想了一下,还是把release-it完善上去吧。

12、release-it 自动管理版本号

安装release-it相关的插件

// package.json
"release-it": "^15.11.0",
"@release-it/conventional-changelog": "^5.1.1",

根目录添加 .release-it.json 配置文件,可以去release-it明细配置

// .release-it.json
{
  "plugins": {
    "@release-it/conventional-changelog": {
      "preset": {
        "name": "conventionalcommits",
        "types": [
          { "type": "feat", "section": "✨ Features | 新功能" },
          { "type": "fix", "section": "🐛 Bug Fixes | Bug 修复" },
          { "type": "chore", "section": "🎫 Chores | 其他更新" },
          { "type": "docs", "section": "📝 Documentation | 文档" },
          { "type": "style", "section": "💄 Styles | 风格" },
          { "type": "refactor", "section": "♻ Code Refactoring | 代码重构" },
          { "type": "perf", "section": "⚡ Performance Improvements | 性能优化" },
          { "type": "test", "section": "✅ Tests | 测试" },
          { "type": "revert", "section": "⏪ Reverts | 回退" },
          { "type": "build", "section": "👷‍ Build System | 构建" },
          { "type": "ci", "section": "🔧 Continuous Integration | CI 配置" },
          { "type": "config", "section": "🔨 CONFIG | 配置" }
        ]
      },
      "infile": "CHANGELOG.md",
      "ignoreRecommendedBump": true,
      "strictSemVer": true
    }
  },
  "git": {
    "commitMessage": "chore: release v${version}"
  }
}

本文并没有发布到 npm ,需要的可自己配置
package.json 的 scripts 中添加脚本

// package.json
"release": "release-it"

上面命令默认更新次版本号,如果想更新主版本号可以参考下面的脚本

# 更新主版本号
pnpm release major

# 更新次版本号
pnpm release minor

# 更新修订号
pnpm release patch

pnpm commit之后,执行对应的脚本命令更新版本号。
在这里插入图片描述
最终效果如上图。

结语

这样就可以妥善更新项目的版本号和changelog文档了。未完待续…

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值