diff --git a/src/App.vue b/src/App.vue index 8d0dd3935ec..7f5e4070f1c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1092,7 +1092,7 @@ export default { log.error(error) } }, - async getChangelogs(project, lastVersion, nextVersion, parseChangelog) { + async getChangelogs(project, prevTag, nextTag, parseChangelog) { const changelogs = [] try { @@ -1102,13 +1102,14 @@ export default { const data = await response.json() let start = false + let maxParse = 10 for (const release of data) { - if (release.tag_name === lastVersion) { + if (release.tag_name === prevTag) { break } - if (release.tag_name === nextVersion) { + if (release.tag_name === nextTag) { start = true } @@ -1116,10 +1117,12 @@ export default { if (release.draft || release.prerelease) continue - changelogs.push(parseChangelog(release)) + changelogs.push(parseChangelog(release, changelogs.length)) + + if (--maxParse === 0) break // if last version is not defined just print the last - if (!lastVersion) break + if (!prevTag) break } } catch (error) { log.error(error) @@ -1159,7 +1162,7 @@ export default { 'zwave-js-ui', versions?.app ? 'v' + versions?.app : null, 'v' + currentVersion, - (release) => { + (release, i) => { release.body = release.body.replace( new RegExp( `#+ \\[${release.tag_name.replace( @@ -1168,12 +1171,25 @@ export default { )}\\]\\([^\\)]+\\)`, 'g' ), - `## UI [${release.tag_name}](https://github.com/zwave-js/zwave-js-ui/releases/tag/${release.tag_name})` + `${i === 0 ? '# UI\n---\n' : ''}## [${ + release.tag_name + }](https://github.com/zwave-js/zwave-js-ui/releases/tag/${ + release.tag_name + })` ) - return md() + let changelog = md() .render(release.body) - .replace('', '
') + .replace('', '
') + + if (i === 0) { + changelog = changelog.replace( + '

', + '

' + ) + } + + return changelog } ) @@ -1184,7 +1200,7 @@ export default { 'node-zwave-js', versions?.driver ? 'v' + versions?.driver : null, 'v' + this.appInfo.zwaveVersion, - (release) => { + (release, i) => { const changelog = md() .render(release.body) .replace( @@ -1192,7 +1208,15 @@ export default { '#$1' ) - return `

Driver ${release.tag_name}


${changelog}` + return `${ + i === 0 + ? '

Driver



' + : '' + }

${ + release.tag_name + }


${changelog}
` } ) @@ -1204,7 +1228,7 @@ export default { 'zwave-js-server', versions?.server || null, this.appInfo.serverVersion, - (release) => { + (release, i) => { const changelog = md() .render(release.body) .replace( @@ -1216,7 +1240,15 @@ export default { '#$1' ) - return `

Server v${release.tag_name}


${changelog}` + return `${ + i === 0 + ? '

Server



' + : '' + }

v${ + release.tag_name + }


${changelog}
` } )