Write logs based on conventional commits and templates.
85
Build a release notes generator that processes commit data and produces formatted changelog entries using an async iterable pattern.
Your task is to implement a system that:
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
}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
@generates
/**
* 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;
}Provides changelog generation from conventional commits.
@satisfied-by
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