From befafade31288d2ff15f1e17ee851cccf496a560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 22 Jan 2018 22:50:26 -0500 Subject: [PATCH] Slightly improve the changelog script, by splitting uncategorized items I have more substantial ideas for future changelogs, but this already helped me for v2.7.0 changelog, and it is as far as I can go without editing the changelogs themselves. Stay tuned. --- scripts/changelog.js | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index 8bdd5859..4f809a2a 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -166,9 +166,7 @@ ${printDependencyList(items.devDependencies)}`} @@@@@@@@@@@@@@@@@@@ @@ UNCATEGORIZED @@ @@@@@@@@@@@@@@@@@@@ - -${printList(items.uncategorized)} -`; +${printUncategorizedList(items.uncategorized)}`; } // Returns true if the given version is a pre-release (i.e. 2.0.0-pre.3, @@ -467,6 +465,22 @@ function printDependencyList(dependencies) { ).join("\n"); } +function printUncategorizedList(uncategorized) { + return Object.entries(uncategorized).reduce((memo, [label, items]) => { + if (items.length === 0) { + return memo; + } + + memo += ` +@@@@@ ${label.toUpperCase()} + +${printList(items)} +`; + + return memo; + }, ""); +} + const dependencies = Object.keys(packageJson.dependencies); const devDependencies = Object.keys(packageJson.devDependencies); @@ -522,6 +536,14 @@ function isInternal(entry) { return hasLabelOrAnnotatedComment(entry, "Meta: Internal"); } +function isBug({labels}) { + return hasLabel(labels, "Type: Bug"); +} + +function isFeature({labels}) { + return hasLabel(labels, "Type: Feature"); +} + // Examples: // Update webpack to the latest version // Update `stylelint` to v1.2.3 @@ -561,7 +583,13 @@ function parse(entries) { } else if (isInternal(entry)) { result.internals.push(entry); } else { - result.uncategorized.push(entry); + if (isFeature(entry)) { + result.uncategorized.feature.push(entry); + } else if (isBug(entry)) { + result.uncategorized.bug.push(entry); + } else { + result.uncategorized.other.push(entry); + } } return result; }, { @@ -572,7 +600,11 @@ function parse(entries) { documentation: [], internals: [], security: [], - uncategorized: [], + uncategorized: { + feature: [], + bug: [], + other: [], + }, unknownDependencies: new Set(), }); } @@ -684,7 +716,7 @@ async function addToChangelog(newEntry) { // Step 3 (optional): Print a list of skipped entries if there are any if (skipped.length > 0) { const pad = Math.max(...skipped.map((entry) => (entry.title || entry.messageHeadline).length)); - log.warn(`${skipped.length} entries were skipped:`); + log.warn(`${skipped.length} ${skipped.length > 1 ? "entries were" : "entry was"} skipped:`); skipped.forEach((entry) => { log.warn(`- ${(entry.title || entry.messageHeadline).padEnd(pad)} ${colors.gray(entry.url)}`); });