Write logs based on conventional commits and templates.
85
Build a tool that processes conventional commit data and generates organized changelog output grouped by commit properties.
Your tool should accept an array of commit objects and generate a formatted changelog string. Each commit object has the following structure:
{
type: string, // e.g., "feat", "fix", "docs"
scope: string, // e.g., "api", "ui", "core" (optional)
subject: string, // short description
hash: string, // commit hash
header: string // full commit header
}Group commits by a property: Organize commits into sections based on a specified property (e.g., group by "type" field to put all "feat" commits together, all "fix" commits together)
Sort commit groups: Sort the groups themselves (e.g., alphabetically by group name)
Sort commits within groups: Within each group, sort commits by a specified property (e.g., alphabetically by their header field)
Generate formatted output: Produce a changelog string with:
Your tool should accept an options object with:
groupBy: Property name to group commits by (default: "type")commitGroupsSort: Property name or comparator function to sort groupscommitsSort: Property name or comparator function to sort commits within groups (default: "header")@generates
/**
* Generates a formatted changelog from an array of commits.
*
* @param {Array} commits - Array of commit objects
* @param {Object} options - Configuration options
* @param {string} options.groupBy - Property to group commits by (default: "type")
* @param {string|Function} options.commitGroupsSort - How to sort commit groups
* @param {string|Function} options.commitsSort - How to sort commits within groups (default: "header")
* @returns {string} Formatted changelog string
*/
function generateChangelog(commits, options) {
// IMPLEMENTATION HERE
}
module.exports = { generateChangelog };Given an array of commits with different types (feat, fix, docs), generates a changelog grouped by type @test
Given commits with the same type, sorts them alphabetically by header within their group @test
When groupBy option is set to "scope", groups commits by their scope property instead of type @test
When commitGroupsSort is set to a property name, sorts the groups by that property @test
Provides changelog generation and commit processing support.
Install with Tessl CLI
npx tessl i tessl/npm-conventional-changelog-writerevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10