MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / formatJSON

Function formatJSON

utils/scripts/generate-release-notes.js:192–221  ·  view source on GitHub ↗
(tag, prevTag, sections, plain = true)

Source from the content-addressed store, hash-verified

190}
191
192function formatJSON(tag, prevTag, sections, plain = true) {
193 const lines = [
194 "",
195 flags.changelogOnly
196 ? ""
197 : `Changes since [${prevTag}](https://github.com/${owner}/${repo}/releases/tag/${prevTag})`,
198 "",
199 ];
200
201 // todo: split into function
202 for (const [type, list] of Object.entries(sections)) {
203 if (list.length === 0) continue;
204 const header = plain
205 ? `## ${type}`
206 : `## ${emojis[type]}${type[0].toUpperCase() + type.slice(1)}`;
207 lines.push(header, "", list.join("\n"), "");
208 }
209 return JSON.stringify(
210 {
211 release: tag,
212 previous: prevTag,
213 sections: Object.fromEntries(
214 Object.entries(sections).filter(([_, v]) => v.length),
215 ),
216 notes: lines.join("\n"),
217 },
218 null,
219 2,
220 );
221}
222
223async function main() {
224 log(`🔍 Generating release notes for ${owner}/${repo} @ ${currentTag}...`);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected