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

Release Notes Generator

Build a release notes generator that processes commit data and produces formatted changelog entries using an async iterable pattern.

Requirements

Your task is to implement a system that:

  1. Accepts an array or async iterable of commit objects
  2. Processes these commits to generate formatted release notes
  3. Returns an async generator that yields changelog entries as strings
  4. Groups commits by type (features, bug fixes, etc.)
  5. Supports customizable formatting through context and options

Commit Object Structure

Each commit object has the following properties:

{
  hash: string;           // Commit hash (e.g., "abc123def456")
  header: string;         // Full commit message header
  type: string;           // Commit type (e.g., "feat", "fix", "docs")
  scope?: string;         // Optional scope (e.g., "auth", "api")
  subject: string;        // Commit subject/summary
  body?: string | null;   // Optional commit body
  footer?: string | null; // Optional footer
  notes: Array<{         // Breaking changes or other notes
    title: string;
    text: string;
  }>;
  committerDate: string;  // Date of commit
  version?: string | null; // Version tag if present
}

Test Cases

  • Given an array of 3 commits (2 features, 1 fix), the generator yields formatted changelog entries that include all commits grouped by type @test

  • Given an async iterable of commits with different types, the generator correctly processes and yields entries in the expected format @test

  • Given context with version "2.0.0" and date "2024-01-15", the generated changelog includes this version information in the output @test

  • Given commits with custom grouping options (groupBy: "scope"), the generator organizes commits by scope instead of type @test

Implementation

@generates

API

/**
 * Creates an async generator function to generate changelog entries from commits.
 * @param context - Optional context with version, date, and repository information
 * @param options - Optional configuration for grouping and formatting
 * @returns Function that accepts commits and returns an AsyncGenerator yielding strings
 */
export function createChangelogGenerator(
  context?: {
    version?: string;
    date?: string;
    repository?: string;
    host?: string;
    owner?: string;
  },
  options?: {
    groupBy?: string;
    commitsSort?: string | string[];
  }
): (commits: Iterable<Commit> | AsyncIterable<Commit>) => AsyncGenerator<string, void>;

export interface Commit {
  hash: string;
  header: string;
  type: string;
  scope?: string;
  subject: string;
  body?: string | null;
  footer?: string | null;
  notes: Array<{
    title: string;
    text: string;
  }>;
  committerDate: string;
  version?: string | null;
}

Dependencies { .dependencies }

conventional-changelog-writer { .dependency }

Provides changelog generation from conventional commits.

@satisfied-by

Install with Tessl CLI

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

tile.json