Changeset
为 Astro 单体仓库创建 changeset 文件。Changeset 声明哪些包发生了变更,semver 版本升级类型,以及面向用户的、会成为 CHANGELOG 条目的消息。
每个修改包的 PR 都需要一个 changeset。仅有 examples/* 的变更可以豁免。
创建文件
在仓库根目录运行 pnpm changeset --empty。这会在 .changeset/ 目录下创建一个名称随机的 .md 文件,其中包含空的前置元数据——无需自己发明文件名或检查目录。然后编辑生成的文件,添加包版本升级信息和消息。
格式
---
'<package-name>': patch
---
<changeset message>
- 包名必须与包的
package.json中的name字段完全匹配(例如'astro'、'@astrojs/node') - 版本升级类型:
patch、minor或major - 单个 changeset 文件可以覆盖多个包
- 对核心
astro包的major和minor版本升级会被 CI 阻止,需要维护者审核
编写消息
Changeset 消息是公开的 CHANGELOG 条目。请面向 Astro 用户 编写,而不是面向代码审查者。
以 现在时动词 开头,补全句子“此 PR...”:
- Adds, Removes, Fixes, Updates, Refactors, Improves, Deprecates
从 构建 Astro 网站的用户将会体验到什么 的角度来描述变更,而不是在内部如何实现:
// 过于关注实现
Logs helpful errors if content is invalid
// 更好——面向用户的影响
Adds logging for content collections configuration errors.
补丁更新
一行通常就足够了。除非写多个句子,否则不需要结尾标点。
---
'astro': patch
---
Fixes a bug where the toolbar audit would incorrectly flag images as above the fold
---
'astro': patch
---
Refactors internal handling of styles and scripts for content collections to improve build performance
帮助读者判断变更是否与他们相关。如果变更与某个可识别的选项或函数相关,请包含具体的 API 名称(使用反引号格式化)。当 API 不是面向用户的时,请改而描述使用案例或最终结果:
// 模糊
Improves automatic fallbacks generation
// 清晰——读者可以判断是否影响他们
Improves automatic `fallbacks` generation for the experimental Fonts API
新特性(次要版本)
以 "Adds" 开头,命名新的 API,并描述用户现在可以做什么。如果对读者有帮助,请包含代码示例:
---
'astro': minor
---
Adds a new, optional property `timeout` for the `client:idle` directive
This value allows you to specify a maximum time to wait, in milliseconds, before hydrating a UI framework component.
```astro
<Button client:idle={{ timeout: 500 }} />
```
新特性是编写更丰富描述的契机,这些描述可以用于博客文章。关于更长条目的指导,请参阅 Astro changeset 文档。
破坏性变更(主版本)
使用 "Removes"、"Changes" 或 "Deprecates" 等动词。必须包含迁移指南。适时使用 diff 代码示例:
---
'astro': major
---
Removes support for Shiki custom language's `path` property. The language JSON file must now be imported and passed to the option instead.
```diff
// astro.config.js
+ import customLang from './custom.tmLanguage.json'
export default defineConfig({
markdown: {
shikiConfig: {
langs: [
- { path: './custom.tmLanguage.json' },
+ customLang,
],
},
},
})
```
更改默认值时必须提到旧默认值、新默认值以及如何恢复之前的行为。
较长的 Changeset
对于较长的描述,使用 #### 和更深层的标题(绝不使用 ## 或 ###)来划分章节。当你的条目被整合时,这能使 CHANGELOG 保持可读性:
---
'astro': minor
---
Adds a new Sessions API to store user state between requests for on-demand rendered pages.
#### Configuring session storage
<!-- ... -->
#### Using sessions
<!-- ... -->