Generate a changelog from git metadata with Angular commit convention.
—
The StandardChangelog class provides programmatic access to changelog generation with Angular commit conventions pre-configured.
Creates a new StandardChangelog instance with Angular preset automatically configured.
/**
* Creates a StandardChangelog instance with Angular preset pre-configured
* @param cwdOrGitClient - Working directory path or ConventionalGitClient instance (required)
*/
constructor(cwdOrGitClient: string | ConventionalGitClient)Usage Examples:
import { StandardChangelog } from "standard-changelog";
// Using current working directory
const generator = new StandardChangelog(process.cwd());
// Using specific directory
const generator = new StandardChangelog("/path/to/repo");
// Using existing git client
import { ConventionalGitClient } from "@conventional-changelog/git-client";
const gitClient = new ConventionalGitClient("/path/to/repo");
const generator = new StandardChangelog(gitClient);Methods for configuring the changelog generation process.
/**
* Load configuration from a preset
* @param preset - Preset parameters
* @returns this for method chaining
*/
loadPreset<PresetCreatorParams extends UnknownPresetCreatorParams = UnknownPresetCreatorParams>(
preset: PresetParams<PresetCreatorParams>
): this;
/**
* Set configuration directly
* @param config - Configuration object or promise
* @returns this for method chaining
*/
config(config: Preset | Promise<Preset>): this;
/**
* Find and read package.json automatically
* @param transform - Optional transform function for package data
* @returns this for method chaining
*/
readPackage(transform?: PackageTransform): this;
/**
* Read package.json from specific path
* @param path - Path to package.json file
* @param transform - Optional transform function for package data
* @returns this for method chaining
*/
readPackage(path?: string, transform?: PackageTransform): this;
/**
* Set package.json data directly
* @param pkg - Package data object
* @returns this for method chaining
*/
package(pkg: Record<string, unknown>): this;
/**
* Read repository info from current git repository
* @returns this for method chaining
*/
readRepository(): this;
/**
* Set repository information
* @param infoOrGitUrl - Repository info object or git URL
* @returns this for method chaining
*/
repository(infoOrGitUrl: string | Partial<HostedGitInfo>): this;
/**
* Set changelog generation options
* @param options - Generation options
* @returns this for method chaining
*/
options(options: Options): this;
/**
* Set writer context data
* @param context - Context data for template rendering
* @returns this for method chaining
*/
context(context: Context): this;
/**
* Configure semver tag parameters
* @param params - Parameters for semver tag retrieval
* @returns this for method chaining
*/
tags(params: GetSemverTagsParams): this;
/**
* Configure commit retrieval parameters
* @param params - Parameters for commit retrieval
* @param parserOptions - Optional parser configuration
* @returns this for method chaining
*/
commits(params: GetCommitsParams, parserOptions?: ParserStreamOptions): this;
/**
* Configure writer options
* @param params - Writer configuration options
* @returns this for method chaining
*/
writer(params: WriterOptions): this;Methods for generating changelog content.
/**
* Generate changelog as string chunks
* @returns Async generator yielding string chunks
*/
write(): AsyncGenerator<string, void>;
/**
* Generate changelog with detailed data objects
* @param includeDetails - When true, returns data objects instead of strings
* @returns Async generator yielding Details objects
*/
write(includeDetails: true): AsyncGenerator<Details<Commit>, void>;
/**
* Generate changelog as readable stream
* @param includeDetails - Optional flag to include detailed data objects
* @returns Readable stream of changelog content
*/
writeStream(includeDetails?: boolean): Readable;Usage Examples:
import { StandardChangelog } from "standard-changelog";
// Basic changelog generation
const generator = new StandardChangelog()
.readPackage()
.options({ releaseCount: 1 });
// Generate as async iterator
for await (const chunk of generator.write()) {
process.stdout.write(chunk);
}
// Generate as stream
generator.writeStream().pipe(process.stdout);
// Generate with details
const detailsGenerator = generator.write(true);
for await (const details of detailsGenerator) {
console.log('Log chunk:', details.log);
console.log('Commit data:', details.data);
}
// Complex configuration example
const complexGenerator = new StandardChangelog("/path/to/repo")
.readPackage((pkg) => ({ ...pkg, name: "custom-name" }))
.options({
releaseCount: 3,
append: false,
outputUnreleased: true
})
.tags({ prefix: "v" })
.commits({ from: "v1.0.0" });interface Options {
reset?: boolean;
append?: boolean;
releaseCount?: number;
outputUnreleased?: boolean;
transformCommit?: CommitTransformFunction;
warn?: Logger;
debug?: Logger;
formatDate?(date: Date): string;
}
interface Preset {
tags?: GetSemverTagsParams;
commits?: GetCommitsParams;
parser?: ParserStreamOptions;
writer?: WriterOptions;
}
interface HostedGitInfo {
url: string;
type: 'github' | 'gitlab' | 'bitbucket' | 'sourcehut' | '';
host: string;
owner?: string;
project?: string;
}
type PackageTransform = (pkg: Package) => Package;
type CommitTransformFunction = (
commit: Commit,
params: Params
) => Partial<Commit> | null | Promise<Partial<Commit> | null>;Install with Tessl CLI
npx tessl i tessl/npm-standard-changelog