Skip to content

@neosjs/conventional-changelog-neosjs ​

遵循 Conventional Commits 规范的 conventional-changelog 预设(preset)。基于提交类型将变更分组到带 emoji 的章节(✨ Features、🐛 Bug Fixes 等),并按约定计算版本提升级别:BREAKING CHANGE 提升大版本、feat 提升小版本。

环境要求

Node.js >= 18。

安装 ​

sh
pnpm add -D @neosjs/conventional-changelog-neosjs
sh
npm i -D @neosjs/conventional-changelog-neosjs
sh
yarn add -D @neosjs/conventional-changelog-neosjs

快速上手 ​

作为 conventional-changelog 预设使用 ​

配合 conventional-changelog CLI 生成变更日志,用 -p 指定本包完整包名作为预设:

sh
npx conventional-changelog-cli -p @neosjs/conventional-changelog-neosjs -i CHANGELOG.md -s

编程式使用 ​

包的默认导出是 createPreset(config) 异步工厂函数,返回包含 commits、parser、writer、whatBump 的预设对象:

js
import neosPreset from '@neosjs/conventional-changelog-neosjs'

const preset = await neosPreset({
  // 忽略指定提交
  ignoreCommits: [/^chore/],
  // 自定义提交类型与章节(见下表默认值)
  // types: [...],
  // 0.x 阶段:BREAKING CHANGE / feat 不再提升大版本
  // preMajor: true
})

同时具名导出 DEFAULT_COMMIT_TYPES(默认提交类型表)。

默认提交类型 ​

typeCHANGELOG 章节是否显示
feat / feature✨ Features显示
fix🐛 Bug Fixes显示
perf🚀 Performance Improvements显示
revert🗑 Reverts显示
docs📚 Documentation显示
style🎨 Styles显示
chore♻️ Miscellaneous Chores显示
build🛠 Build System显示
refactorCode Refactoring隐藏
testTests隐藏
ciContinuous Integration隐藏

解析与版本提升规则 ​

  • 提交头按 type(scope)!: subject 解析,noteKeywords 为 BREAKING CHANGE / BREAKING-CHANGE,issue 前缀默认 #(可通过 issuePrefixes 配置);
  • 提交信息含 release-as: x.y.z 时可覆盖版本;
  • 版本提升(whatBump):出现 BREAKING CHANGE 或 ! 标记为大版本(level 0),存在 feat / feature 为小版本(level 1),其余为补丁(level 2);preMajor: true 时 level 上调一档(0.x 阶段防止误升 major);
  • 写入 CHANGELOG 的链接格式(commitUrlFormat、compareUrlFormat、issueUrlFormat、userUrlFormat)均可通过配置覆盖。