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-7/

Custom Changelog Formatter

Build a changelog generation tool that produces formatted changelog output from commit data using customizable templates.

Requirements

Your tool should accept an array of commit objects and generate a formatted changelog string. Each commit object has the following structure:

{
  hash: string,           // Full commit hash
  type: string,           // Commit type (e.g., "feat", "fix", "docs")
  scope: string,          // Optional scope
  subject: string,        // Commit subject line
  body: string,           // Commit body
  header: string,         // Full header line
  notes: Array<{          // Breaking changes and other notes
    title: string,
    text: string
  }>,
  references: Array<{     // Issue/PR references
    action: string,
    issue: string,
    prefix: string
  }>
}

Your solution must support:

  1. Custom template formatting - Allow users to provide custom templates that define how the changelog is rendered
  2. Template partials - Support separate template partials for header, commit entries, and footer sections
  3. Context variables - Pass metadata like version and repository information to templates

The tool should export a function generateChangelog(commits, options) that:

  • Accepts an array of commit objects and an options object
  • Returns a formatted changelog string
  • Supports custom templates via the options parameter

Test Cases

  • Given 3 commits with types "feat", "fix", "docs" and a default template, the output includes all three commits grouped by type @test
  • Given commits and a custom header template, the output uses the custom header format @test
  • Given commits and custom templates for header, commits, and footer sections, all sections use the provided templates @test

Implementation

@generates

API

/**
 * Generates a formatted changelog from commit data.
 *
 * @param {Array<Object>} commits - Array of commit objects
 * @param {Object} options - Configuration options
 * @param {string} options.mainTemplate - Main template string (optional)
 * @param {Object} options.partials - Object containing partial templates (optional)
 * @param {string} options.partials.header - Header template (optional)
 * @param {string} options.partials.commit - Commit template (optional)
 * @param {string} options.partials.footer - Footer template (optional)
 * @param {Object} options.context - Context data for templates (optional)
 * @returns {string} Formatted changelog
 */
function generateChangelog(commits, options = {});

export { generateChangelog };

Dependencies { .dependencies }

conventional-changelog-writer { .dependency }

Provides changelog generation with template-based rendering support.

@satisfied-by

Install with Tessl CLI

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

tile.json