woocommerce/packages/js/zh-cn/CLAUDE.md
2026-04-15 10:18:01 +08:00

111 lines
No EOL
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WooCommerce JS 包的 Claude 代码文档
**位置**: `packages/js/`
## 更新日志快速参考
**对包的每个功能变更都需添加条目。**
```bash
# 快速添加(交互式)
cd packages/js/[package-name]
pnpm changelog add
# 手动创建
# 创建: packages/js/[package-name]/changelog/[type-brief-description]
# 格式:
Significance: <patch|minor|major>
Type: <type>
<一行描述变更内容>
```
**重要性 (语义化版本):**
- `patch` → 错误修复,无 API 变更 (0.0.X)
- `minor` → 新功能,非破坏性变更 (0.X.0)
- `major` → 破坏性变更 (X.0.0)
**类型:**
- `fix` → 修复错误
- `add` → 添加功能
- `update` → 更新现有功能
- `dev` → 开发/工具任务
- `tweak` → 微小调整
- `performance` → 性能改进
- `enhancement` → 改进现有功能
## 常见样板与决策树
**类型与重要性快速查询:**
| 变更类型 | 类型 | 重要性 |
|------------|------|--------------|
| 错误修复 | `fix` | `patch` |
| 新功能/选择器/操作 | `add` | `minor` |
| 新 TS 类型/接口属性 | `add` | `minor` |
| 更新现有功能(非破坏性) | `update` | `minor` |
| 破坏性 API 变更 | `update` | `major` |
| 测试/构建/工具 | `dev` | `patch` |
| 性能改进 | `performance` | `minor` |
**示例:**
```text
# 错误修复
Significance: patch
Type: fix
修复支付设置数据加载器中的竞态条件
```
```text
# 新功能
Significance: minor
Type: add
向 PaymentGateway 接口添加 `onboardingSupported` 属性
```
```text
# 破坏性变更
Significance: major
Type: update
移除已弃用的 `getPaymentMethods` 选择器
```
```text
# 开发/工具
Significance: patch
Type: dev
更新测试桩以包含新的网关属性
```
## 重要:@woocommerce/data 包
**核心数据层** - 进行更改时务必添加更新日志。更新顺序:
1. `src/[module]/types.ts` 中的类型
2. `src/[module]/test/helpers/` 中的测试桩
3. 实现
4. 添加更新日志条目
## 故障排除
**`changelogger: command not found`** → 在包目录中运行 `composer install`
**没有 composer.json** → 在 `changelog/` 目录中手动创建更新日志文件
**不确定重要性?** → 功能默认为 `minor`,修复默认为 `patch`
**CI 因更新日志失败?** → 推送前运行 `pnpm changelog validate`
## 注意事项
- 更新日志文件与代码变更一同提交(同一提交/PR
- 每个逻辑变更一个文件
- 文件位置:`packages/js/[package]/changelog/[entry-name]`
- 工具:`automattic/jetpack-changelogger`(在 `composer.json` 中配置)