From 426b10aaf69bab0b18f225417f23c9b7d8acd1c2 Mon Sep 17 00:00:00 2001 From: tree Date: Tue, 3 May 2022 16:19:32 +0200 Subject: [PATCH] Update changelog generation --- utils/changelog.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/utils/changelog.js b/utils/changelog.js index 51cc4bc..73087e9 100644 --- a/utils/changelog.js +++ b/utils/changelog.js @@ -60,8 +60,7 @@ function checkCol(col, d, current) { } } -async function run() { - const files = ["spec/22/speakers.yaml"]; +async function generate(entry = "22") { const commits = await gitCommits(); const dates = {}; const cols = { @@ -77,7 +76,7 @@ async function run() { if (!dates[commit.date]) { dates[commit.date] = { json: null, speakers: {}, events: {} }; } - const file = await gitCommitFile(commit, "22/bundle.json"); + const file = await gitCommitFile(commit, `${entry}/bundle.json`); if (!file) { continue; } @@ -102,15 +101,19 @@ async function run() { const sitems = []; for (const col of Object.keys(cols)) { for (const type of Object.keys(types)) { + const colitems = []; if (d[col][type]) { for (const i of d[col][type]) { - sitems.push( - `* [${cols[col].title}] ${types[type].title} [${ - i[1] - }](https://utxo.cz/${cols[col].url}?id=${i[0]})`, + colitems.push( + `* ${types[type].title} [${i[1]}](https://utxo.cz/${ + cols[col].url + }?id=${i[0]})`, ); } } + if (colitems.length > 0) { + sitems.push(`### ${cols[col].title}\n\n${colitems.join("\n")}\n`); + } } } if (sitems.length > 0) { @@ -121,9 +124,9 @@ async function run() { } } const str = `# Changelog\n\n${items.join("\n")}`; - const fn = "./dist/CHANGELOG.md"; + const fn = `./dist/${entry}/CHANGELOG.md`; await Deno.writeTextFile(fn, str); console.log(`Changelog write to file: ${fn}`); } -run(); +generate();