standard-version自定义配置

介绍

本文为方便自己记住standard-version配置方式,standard-version是一款自动打标签、自动书写changelog的工具

安装

不建议全局安装

npm install standard-version
pnpm install standard-version

配置

官方文档说支持.versionrc, .versionrc.json 或者 .versionrc.js

语法

创建.versionrc.js配置文件,如果项目是 “type”: “module”,则为.versionrc.cjs

module.exports = {

}

如果是.versionrc则不需要写上面这个👆

自定义开头

终于不用在changelog看standard- version广告啦,就像vim不用拯救乌干达儿童,美滋滋

  "header": '# Changelog\n\nHello,这是项目变更日志的描述文案。\n',

图标美化

嘿嘿,支持czg的emoji啦

不想让谁出现,在那一行加上hidden": true

    "types": [
        {"type": "feat", "section": "✨ Features | 新功能"},
        {"type": "fix", "section": "🐛 Bug Fixes | Bug 修复"},
        {"type": "perf", "section":"⚡ Performance Improvements | 性能优化"},
        {"type": "revert", "section":"⏪ Reverts | 回退"},
        {"type": "chore", "section":"📦 Chores | 其他更新"},
        {"type": "docs", "section":"📝 Documentation | 文档"},
        {"type": "style", "section":"💄 Styles | 风格"},
        {"type": "refactor", "section":"♻ Code Refactoring | 代码重构"},
        {"type": "test", "section":"✅ Tests | 测试"},
        {"type": "build", "section":"👷‍ Build System | 构建"},
        {"type": "ci", "section":"🔧 Continuous Integration | CI 配置"}
    ],

跳过

请了解后再修改,避免手欠

可自定义关闭standard-version逻辑
如果全改为false,不就是原先默认的吗,折腾这干啥

 "skip": {
    "bump": true, // 缓存变化,不会看git缓存,不会重置到最近tag
    "changelog": true, // 跳过生成 changelog
    "commit": true, // 跳过提交commit
    "tag": true // 跳过生成tag
  }

自定义仓库链接

通常standard-version会从git自动获取仓库地址,但也提供了自定义配置

"commitUrlFormat":  "https://github.com/your-username/your-repo/commit/{{hash}}",
"releaseUrlFormat": "https://github.com/your-username/your-repo/releases/tag/{{tag}}",
"compareUrlFormat": "https://github.com/your-username/your-repo/compare/{{previousTag}}...{{currentTag}}",

版本发布

偷了个懒,省了前面的包管理器,执行时加上自己的包管理器(npx/pnpm/npm/yarn等),比如像这样

pnpm standard-version

第一个版本

项目新建时,执行该命令自动生成tag名0.0.1

standard-version --first-release

正式版

你也不想版本号随便生成吧

# 大版本
standard-version -release-as major

# 默认命令效果
standard-version -release-as minor

# 打补丁
standard-version -release-as patch

预发布

不保证效果100%可靠,预览版本

alpha内部测试版,验证功能逻辑

beta用户测试版,产品雏形,起码能用,存在大量的bug

rc版本,无限接近正式版,有的团队会直接跳过

命令也好记忆,pre预先release发布

# 不指定预发布类型
standard-version --prerelease

# 内部版本 1.0.0-alpha.0
standard-version --prerelease alpha 

# 公测版本 1.0.0-beta.0
standard-version --prerelease beta

# 遥测版本 1.0.0-rc.0
standard-version --prerelease rc

两个结合最好,然后在package.json里用script简写一下,以后直接调用

standard-version --release-as minor  --prerelease alpha 
standard-version --release-as minor  --prerelease beta
standard-version --release-as minor  --prerelease rc

standard-version --release-as patch  --prerelease alpha 
standard-version --release-as patch  --prerelease beta
standard-version --release-as patch  --prerelease rc
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值