markmv
Version:
TypeScript CLI for markdown file operations with intelligent link refactoring
142 lines • 4.81 kB
TypeScript
import type { LinkType } from '../types/links.js';
import type { BrokenLink } from '../types/config.js';
import type { OperationOptions } from '../types/operations.js';
/**
* Configuration options for link validation operations.
*
* Controls how broken link detection is performed across markdown files.
*
* @category Commands
*/
export interface ValidateOperationOptions extends OperationOptions {
/** Types of links to validate (default: all types) */
linkTypes?: LinkType[];
/** Enable external HTTP/HTTPS link validation */
checkExternal: boolean;
/** Timeout for external link validation in milliseconds */
externalTimeout: number;
/** Treat missing internal files as errors */
strictInternal: boolean;
/** Validate Claude import paths */
checkClaudeImports: boolean;
/** Check for circular references in file dependencies */
checkCircular: boolean;
/** Maximum depth to traverse subdirectories when using glob patterns */
maxDepth?: number | undefined;
/** Show only broken links, not all validation results */
onlyBroken: boolean;
/** Group results by file or by link type */
groupBy: 'file' | 'type';
/** Include line numbers and context in output */
includeContext: boolean;
}
/**
* CLI-specific options for the validate command.
*
* @category Commands
*/
export interface ValidateCliOptions extends Omit<ValidateOperationOptions, 'linkTypes'> {
/** Comma-separated list of link types to validate */
linkTypes?: string;
/** Output results in JSON format */
json?: boolean;
}
/**
* Extended broken link interface with additional validation context.
*
* @category Commands
*/
export interface ExtendedBrokenLink extends BrokenLink {
/** Link type for grouping */
type: LinkType;
/** Link URL for display */
url: string;
/** Line number where the link was found */
line?: number;
/** File path (for context when grouping by type) */
filePath?: string | undefined;
}
/**
* Result of a validation operation containing all broken links found.
*
* @category Commands
*/
export interface ValidateResult {
/** Total number of files processed */
filesProcessed: number;
/** Total number of links found */
totalLinks: number;
/** Total number of broken links found */
brokenLinks: number;
/** Broken links grouped by file */
brokenLinksByFile: Record<string, ExtendedBrokenLink[]>;
/** Broken links grouped by type */
brokenLinksByType: Partial<Record<LinkType, ExtendedBrokenLink[]>>;
/** Files that had processing errors */
fileErrors: Array<{
file: string;
error: string;
}>;
/** Whether circular references were detected */
hasCircularReferences: boolean;
/** Circular reference details if found */
circularReferences?: string[];
/** Processing time in milliseconds */
processingTime: number;
}
/**
* Validates markdown files for broken links of all types.
*
* Searches through markdown files to find broken internal links, external HTTP/HTTPS links, missing
* images, invalid anchors, and other link integrity issues.
*
* @example
* Basic validation
* ```typescript
* const result = await validateLinks(['**\/*.md'], {
* checkExternal: true,
* onlyBroken: true
* });
*
* console.log('Found ' + result.brokenLinks + ' broken links in ' + result.filesProcessed + ' files');
* ```
*
* @example
* Validate specific link types only
* ```typescript
* const result = await validateLinks(['docs\/*.md'], {
* linkTypes: ['internal', 'image'],
* strictInternal: true,
* includeContext: true
* });
* ```
*
* @param patterns - File patterns to validate (supports globs)
* @param options - Validation configuration options
*
* @returns Promise resolving to validation results
*/
export declare function validateLinks(patterns: string[], options?: Partial<ValidateOperationOptions>): Promise<ValidateResult>;
/**
* CLI command handler for validate operations.
*
* Processes markdown files to find broken links of all types. Supports various output formats and
* filtering options.
*
* @example
* ```bash
* # Validate all markdown files including external links
* markmv validate "**\/*.md" --check-external --verbose
*
* # Check only internal links and images
* markmv validate docs/ --link-types internal,image --strict-internal
*
* # Find broken links with context information
* markmv validate README.md --include-context --group-by type
* ```;
*
* @param patterns - File patterns to validate
* @param cliOptions - CLI-specific options
*/
export declare function validateCommand(patterns: string[], cliOptions: ValidateCliOptions): Promise<void>;
//# sourceMappingURL=validate.d.ts.map