/** * Describes the outcome of validating a changelog file. * * @public * @since 0.1.0 * @forgeIgnore E020 */ export interface ChangelogValidationResult { /** * Indicates whether the changelog satisfies all requested checks. */ valid: boolean; /** * Human-readable validation errors. */ errors: string[]; /** * Indicates whether the changelog contains an entry for the requested version. */ hasEntryForVersion: boolean; } /** * Options for changelog structure enforcement. * * @public * @since 0.7.0 */ export interface ChangelogStructureOptions { /** Validate section headers against an allowed list. */ enforceStructure?: boolean; /** Allowed section names. Defaults to Keep a Changelog standard sections. */ sections?: string[]; } /** * Validates a changelog file for release readiness. * * @public * @since 0.1.0 * @remarks * The validator checks for a top-level changelog heading, an `[Unreleased]` * section, and optionally a dated entry for the requested version. * * When `structure.enforceStructure` is `true`, section headers (`### Name`) * are validated against the allowed list and empty sections produce warnings. * * @param changelogPath - Path to the changelog file. * @param version - Version that must be present in the changelog. * @param strict - Whether to require compare links and dated release headings. * @param requireEntry - Whether the requested version must already have an entry. * @param structure - Optional structure enforcement options. * @returns The result of validating the changelog file. * @example * ```ts * import { validateChangelog } from 'versionguard'; * * const result = validateChangelog('CHANGELOG.md', '1.2.0', true, true, { * enforceStructure: true, * sections: ['Added', 'Changed', 'Fixed'], * }); * ``` */ export declare function validateChangelog(changelogPath: string, version: string, strict?: boolean, requireEntry?: boolean, structure?: ChangelogStructureOptions): ChangelogValidationResult; /** * Gets the most recent released version from a changelog. * * @public * @since 0.1.0 * @remarks * The `[Unreleased]` section is skipped so the first concrete version heading is * treated as the latest release. * * @param changelogPath - Path to the changelog file. * @returns The latest released version, or `null` when no release entry exists. * @example * ```ts * import { getLatestVersion } from 'versionguard'; * * const latest = getLatestVersion('CHANGELOG.md'); * ``` */ export declare function getLatestVersion(changelogPath: string): string | null; /** * Inserts a new version entry beneath the `[Unreleased]` section. * * @public * @since 0.1.0 * @remarks * If the changelog already contains the requested version, no changes are made. * The inserted entry includes a starter `Added` subsection for follow-up edits. * * @param changelogPath - Path to the changelog file. * @param version - Version to add. * @param date - Release date to write in `YYYY-MM-DD` format. * @example * ```ts * import { addVersionEntry } from 'versionguard'; * * addVersionEntry('CHANGELOG.md', '1.2.0', '2026-03-21'); * ``` */ export declare function addVersionEntry(changelogPath: string, version: string, date?: string): void; /** * Detects whether a changelog has been mangled by Changesets. * * @remarks * Changesets prepends version content above the Keep a Changelog preamble, * producing `## 0.4.0` (no brackets, no date) before the "All notable changes" * paragraph. This function detects that pattern. * * @param changelogPath - Path to the changelog file. * @returns `true` when the changelog appears to be mangled by Changesets. * * @example * ```ts * import { isChangesetMangled } from 'versionguard'; * * if (isChangesetMangled('CHANGELOG.md')) { * fixChangesetMangling('CHANGELOG.md'); * } * ``` * * @public * @since 0.4.0 */ export declare function isChangesetMangled(changelogPath: string): boolean; /** * Fixes a Changesets-mangled changelog into proper Keep a Changelog format. * * @remarks * This function: * 1. Extracts the version number and content prepended by Changesets * 2. Converts Changesets section names (Minor Changes, Patch Changes) to * Keep a Changelog names (Added, Fixed) * 3. Strips commit hashes from entry lines * 4. Adds the date and brackets to the version header * 5. Inserts the entry after `## [Unreleased]` in the correct position * 6. Restores the preamble to its proper location * * @param changelogPath - Path to the changelog file to fix. * @param date - Release date in `YYYY-MM-DD` format. * @returns `true` when the file was modified, `false` when no fix was needed. * * @example * ```ts * import { fixChangesetMangling } from 'versionguard'; * * const fixed = fixChangesetMangling('CHANGELOG.md'); * ``` * * @public * @since 0.4.0 */ export declare function fixChangesetMangling(changelogPath: string, date?: string): boolean; //# sourceMappingURL=changelog.d.ts.map