Added changelog generator.

This commit is contained in:
SamTV12345 2024-08-08 21:18:23 +02:00
parent b805d976e1
commit 1aef6e5a99
3 changed files with 51 additions and 92 deletions

View file

@ -0,0 +1,41 @@
import {readFileSync} from "node:fs";
const changelog = readFileSync('../changelog.md')
const changelogText = changelog.toString()
const changelogLines = changelogText.split('\n')
let cliArgs = process.argv.slice(2)
let tagVar = cliArgs[0]
if (!tagVar) {
console.error("No tag provided")
process.exit(1)
}
console.log("Tag",tagVar)
tagVar = tagVar.replace("refs/tags/v", "")
let startNum = -1
let endline = 0
let counter = 0
for (const line of changelogLines) {
if (line.trim().startsWith("#") && (line.match(new RegExp("#", "g"))||[]).length === 1) {
if (startNum !== -1) {
endline = counter-1
break
}
const sanitizedLine = line.replace("#","").trim()
if(sanitizedLine.includes(tagVar)) {
startNum = counter
}
}
counter++
}
let currentReleaseNotes = changelogLines.slice(startNum, endline).join('\n')
console.log("Generated changelog",currentReleaseNotes)

View file

@ -32,7 +32,8 @@
"rebuildPad": "node --import tsx rebuildPad.ts",
"stalePlugins": "node --import tsx ./plugins/stalePlugins.ts",
"checkPlugin": "node --import tsx ./plugins/checkPlugin.ts",
"plugins": "node --import tsx ./plugins.ts"
"plugins": "node --import tsx ./plugins.ts",
"generateChangelog": "node --import tsx generateReleaseNotes.ts"
},
"author": "",
"license": "ISC"