Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions actions/upgrade-deps/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21573,11 +21573,14 @@ function formatType(type, scoped) {
const breaking = type.endsWith("!");
return `${breaking ? type.slice(0, -1) : type}${scoped ? "(Icon)" : ""}${breaking ? "!" : ""}`;
}
function formatCrossRepositoryLinks(text) {
return text.replace(/\[#(\d+)\]\((https:\/\/github\.com\/Tencent\/tdesign-icons\/pull\/\1)\)/g, "[icons#$1]($2)");
}
function getChangelogMarkdown(deps, targetRepo) {
const scoped = COMPONENT_REPOSITORIES.has(targetRepo);
return deps.filter((dep) => !NO_CHANGELOG_DEPENDENCIES.has(dep.name)).flatMap((dep) => {
const entries = dep.release ? parseReleaseChangelog(dep.release.body) : [];
return entries.length ? entries.map((entry) => `- ${formatType(entry.type, scoped)}: ${entry.text}`) : [`- ${formatType("chore", scoped)}: upgrade ${dep.name} to ${dep.version}`];
return entries.length ? entries.map((entry) => `- ${formatType(entry.type, scoped)}: ${formatCrossRepositoryLinks(entry.text)}`) : [`- ${formatType("chore", scoped)}: upgrade ${dep.name} to ${dep.version}`];
}).join("\n");
}
function buildNoChangelogBody(template) {
Expand Down Expand Up @@ -21607,7 +21610,7 @@ function insertChangelog(body, repo, changelog) {
return inserted ? {
body: result,
inserted
} : insertAfter(result, /更新日志|changelog|release notes/i, changelog);
} : insertAfter(result, "📝 更新日志", changelog);
}
function buildPullRequestBody(template, deps, targetRepo) {
if (deps.length && deps.every((dep) => NO_CHANGELOG_DEPENDENCIES.has(dep.name))) return buildNoChangelogBody(template);
Expand Down
8 changes: 6 additions & 2 deletions actions/upgrade-deps/src/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ function formatType(type: ChangelogType, scoped: boolean): string {
return `${base}${scoped ? '(Icon)' : ''}${breaking ? '!' : ''}`
}

function formatCrossRepositoryLinks(text: string): string {
return text.replace(/\[#(\d+)\]\((https:\/\/github\.com\/Tencent\/tdesign-icons\/pull\/\1)\)/g, '[icons#$1]($2)')
}

export function getChangelogMarkdown(deps: DependencyInfo[], targetRepo: string): string {
const scoped = COMPONENT_REPOSITORIES.has(targetRepo)
return deps.filter(dep => !NO_CHANGELOG_DEPENDENCIES.has(dep.name)).flatMap((dep) => {
const entries = dep.release ? parseReleaseChangelog(dep.release.body) : []
return entries.length ? entries.map(entry => `- ${formatType(entry.type, scoped)}: ${entry.text}`) : [`- ${formatType('chore', scoped)}: upgrade ${dep.name} to ${dep.version}`]
return entries.length ? entries.map(entry => `- ${formatType(entry.type, scoped)}: ${formatCrossRepositoryLinks(entry.text)}`) : [`- ${formatType('chore', scoped)}: upgrade ${dep.name} to ${dep.version}`]
}).join('\n')
}

Expand All @@ -129,7 +133,7 @@ function insertChangelog(body: string, repo: string, changelog: string): { body:
result = update.body
inserted ||= update.inserted
}
return inserted ? { body: result, inserted } : insertAfter(result, /更新日志|changelog|release notes/i, changelog)
return inserted ? { body: result, inserted } : insertAfter(result, '📝 更新日志', changelog)
}

export function buildPullRequestBody(template: string | undefined, deps: DependencyInfo[], targetRepo: string): string {
Expand Down
33 changes: 32 additions & 1 deletion actions/upgrade-deps/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,44 @@ catalogs:
expect(body).toContain('- `tdesign-icons-view` 升级至 `0.5.7`')
expect(body).toContain('#### [`tdesign-icons-view@0.5.7`]')
expect(body).toContain('##### 🌈 0.5.7 `2026-07-15`\n\n###### 🐞 Bug Fixes')
expect(body).toContain('### 📝 更新日志\n\n- fix: 修复 fullscreen、logo-wecom-filled、no-result-filled、tree-list、wifi-no-filled 5 个图标搜索缺失 @liweijie0812 ([#264](https://github.com/Tencent/tdesign-icons/pull/264))')
expect(body).toContain('### 📝 更新日志\n\n- fix: 修复 fullscreen、logo-wecom-filled、no-result-filled、tree-list、wifi-no-filled 5 个图标搜索缺失 @liweijie0812 ([icons#264](https://github.com/Tencent/tdesign-icons/pull/264))')
expect(body).not.toContain('fix(组件名称)')
expect(body).toContain('- [x] 其他')
expect(body).toContain('- [ ] 本条 PR 不需要纳入 Changelog')
expect(body).toContain('- [x] Changelog 已提供或无须提供')
})

it('单仓模板不将 CHANGELOG 链接误认为更新日志区块', () => {
const template = `### 💡 需求背景和解决方案

<!-- 请描述背景 -->

### 📝 更新日志

<!-- 请描述更新日志 -->

- fix(组件名称): 处理问题或特性描述 ...

- [ ] 本条 PR 不需要纳入 Changelog

### ☑️ 请求合并前的自查清单

- [ ] Changelog 已提供或无须提供`
const changelog = '- fix(Icon): 修复 usb 原始图标的图层 ID 错误 @uyarn ([icons#298](https://github.com/Tencent/tdesign-icons/pull/298))'
const body = buildPullRequestBody(template, [{
name: 'tdesign-icons-vue-next',
version: '0.4.11',
release: {
body: '## 🌈 0.4.11 `2026-08-28`\n\n### 🐞 Bug Fixes\n\n- 修复 usb 原始图标的图层 ID 错误 @uyarn ([#298](https://github.com/Tencent/tdesign-icons/pull/298))',
tag: 'tdesign-icons-vue-next@0.4.11',
url: 'https://github.com/Tencent/tdesign-icons/blob/HEAD/packages/vue-next/CHANGELOG.md',
},
}], 'tdesign-mobile-vue')

expect(body).toContain(`### 📝 更新日志\n\n${changelog}`)
expect(body).not.toContain(`CHANGELOG.md)\n\n${changelog}`)
})

it('仅升级无需 Changelog 的依赖时只勾选对应选项', () => {
const template = `### 🤔 这个 PR 的性质是?

Expand Down
Loading