CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-conventional-changelog-writer

Write logs based on conventional commits and templates.

85

1.00x
Overview
Eval results
Files

task.mdevals/scenario-8/

Commit Changelog Organizer

Build a tool that processes conventional commit data and generates organized changelog output grouped by commit properties.

Requirements

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
}

Core Functionality

  1. 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)

  2. Sort commit groups: Sort the groups themselves (e.g., alphabetically by group name)

  3. Sort commits within groups: Within each group, sort commits by a specified property (e.g., alphabetically by their header field)

  4. Generate formatted output: Produce a changelog string with:

    • A section header for each commit group showing the group name
    • Individual commit entries listed under their respective group
    • Each commit showing its subject and shortened hash (first 7 characters)

Configuration Options

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 groups
  • commitsSort: Property name or comparator function to sort commits within groups (default: "header")

Implementation

@generates

API

/**
 * 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 };

Test Cases

  • 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

Dependencies { .dependencies }

conventional-changelog-writer { .dependency }

Provides changelog generation and commit processing support.

Install with Tessl CLI

npx tessl i tessl/npm-conventional-changelog-writer

tile.json