[feat] Use source file links instead of dist .d.ts in API changelog

Update changelog link generation to prefer source file locations over
generated declaration file locations. Links now point to the actual
source code where APIs are defined (e.g., src/stores/commandStore.ts)
instead of the bundled dist/index.d.ts file.

This makes the changelog much more useful as developers can click
through to see the real implementation and context.

Falls back to .d.ts location if source mapping is unavailable.

Fixes the issue where links like:
https://github.com/.../dist/index.d.ts#L1247

Are now:
https://github.com/.../src/stores/commandStore.ts#L10

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
snomiao
2025-11-05 17:22:34 +00:00
parent 98ed124b02
commit f844d3e95b

View File

@@ -40,11 +40,21 @@ const currentApi = JSON.parse(fs.readFileSync(currentPath, 'utf-8'))
/**
* Generate GitHub permalink to source code
* Prefers source file location over dist .d.ts location
*/
function generateGitHubLink(name, line) {
if (!line) return name
// Format: https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/dist/index.d.ts#L123
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/dist/index.d.ts#L${line})`
function generateGitHubLink(name, item) {
// If we have source file information, use that
if (item?.sourceFile && item?.sourceLine) {
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/${item.sourceFile}#L${item.sourceLine})`
}
// Fallback to .d.ts location if available
if (item?.line) {
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/dist/index.d.ts#L${item.line})`
}
// No location info available
return `\`${name}\``
}
/**
@@ -280,9 +290,7 @@ function formatChangelog(changes, prevVersion, currVersion) {
lines.push(`**${categoryToTitle(category)}**`)
lines.push('')
for (const item of items) {
const displayName = item.item?.line
? generateGitHubLink(item.name, item.item.line)
: `\`${item.name}\``
const displayName = generateGitHubLink(item.name, item.item)
lines.push(`- **Removed**: ${displayName}`)
}
lines.push('')
@@ -334,12 +342,10 @@ function formatChangelog(changes, prevVersion, currVersion) {
lines.push(`**${categoryToTitle(category)}**`)
lines.push('')
for (const item of items) {
// Get the current item to access line number
// Get the current item to access source location
const currItem =
currentApi[item.category] && currentApi[item.category][item.name]
const displayName = currItem?.line
? generateGitHubLink(item.name, currItem.line)
: `\`${item.name}\``
const displayName = generateGitHubLink(item.name, currItem)
lines.push(`- ${displayName}`)
for (const change of item.changes) {
const formatted = formatChange(change)