UNPKG

markmv

Version:

TypeScript CLI for markdown file operations with intelligent link refactoring

246 lines 8.56 kB
/** * Markmv - TypeScript library for markdown file operations with intelligent link refactoring * * This library provides programmatic access to all markmv functionality for use in scripts, build * processes, and other Node.js applications. * * @example * Basic usage * ```typescript * import { FileOperations } from 'markmv'; * * const fileOps = new FileOperations(); * const result = await fileOps.moveFile('old.md', 'new.md'); * console.log(`Moved file successfully: ${result.success}`); * ``` * * @example * Advanced usage with options * ```typescript * import { FileOperations, type MoveOperationOptions } from 'markmv'; * * const fileOps = new FileOperations(); * const options: MoveOperationOptions = { * dryRun: true, * verbose: true * }; * * const result = await fileOps.moveFile('docs/old.md', 'docs/new.md', options); * if (result.success) { * console.log(`Would modify ${result.modifiedFiles.length} files`); * result.changes.forEach(change => { * console.log(`${change.type}: ${change.filePath}`); * }); * } * ``` */ import { FileOperations } from './core/file-operations.js'; import type { MoveOperationOptions, OperationResult } from './types/operations.js'; export { FileOperations }; export { LinkParser } from './core/link-parser.js'; export { LinkRefactorer } from './core/link-refactorer.js'; export { LinkValidator } from './core/link-validator.js'; export { LinkConverter } from './core/link-converter.js'; export { DependencyGraph } from './core/dependency-graph.js'; export { ContentJoiner } from './core/content-joiner.js'; export { ContentSplitter } from './core/content-splitter.js'; export { FileUtils } from './utils/file-utils.js'; export { PathUtils } from './utils/path-utils.js'; export { TransactionManager } from './utils/transaction-manager.js'; export { TocGenerator } from './utils/toc-generator.js'; export { BaseJoinStrategy, DependencyOrderJoinStrategy, AlphabeticalJoinStrategy, ManualOrderJoinStrategy, ChronologicalJoinStrategy, } from './strategies/join-strategies.js'; export { BaseMergeStrategy, AppendMergeStrategy, PrependMergeStrategy, InteractiveMergeStrategy, } from './strategies/merge-strategies.js'; export { BaseSplitStrategy, HeaderBasedSplitStrategy, SizeBasedSplitStrategy, ManualSplitStrategy, LineBasedSplitStrategy, } from './strategies/split-strategies.js'; export { convertCommand } from './commands/convert.js'; export { indexCommand } from './commands/index.js'; export { tocCommand, generateToc as generateTocForFiles } from './commands/toc.js'; export { validateCommand, validateLinks } from './commands/validate.js'; export type { MarkdownLink, ParsedMarkdownFile, LinkType, LinkStyle, } from './types/links.js'; export type { OperationResult, OperationChange, MoveOperationOptions, OperationOptions, SplitOperationOptions, JoinOperationOptions, MergeOperationOptions, ConvertOperationOptions, BarrelOperationOptions, } from './types/operations.js'; export type { IndexOptions, FileMetadata, IndexableFile } from './commands/index.js'; export type { TocOperationOptions, TocCliOptions, TocResult } from './commands/toc.js'; export type { TocOptions, TocResult as TocGeneratorResult, MarkdownHeading, } from './utils/toc-generator.js'; export type { JoinSection, JoinResult, JoinConflict, JoinStrategyOptions, } from './strategies/join-strategies.js'; export type { MergeSection, MergeResult, MergeConflict, MergeStrategyOptions, } from './strategies/merge-strategies.js'; export type { SplitSection, SplitResult, SplitStrategyOptions, } from './strategies/split-strategies.js'; /** * Main entry point for the markmv library * * Creates a new FileOperations instance for performing markdown file operations. This is the * recommended way to get started with the library. * * @example * ```typescript * import { createMarkMv } from 'markmv'; * * const markmv = createMarkMv(); * const result = await markmv.moveFile('old.md', 'new.md'); * ```; * * @returns A new FileOperations instance * * @group Core API */ export declare function createMarkMv(): FileOperations; /** * Convenience function for moving a single markdown file * * @example * ```typescript * import { moveFile } from 'markmv'; * * const result = await moveFile('docs/old.md', 'docs/new.md', { * dryRun: true * }); * ```; * * @param sourcePath - The current file path * @param destinationPath - The target file path * @param options - Optional configuration * * @returns Promise resolving to operation result * * @group Core API */ export declare function moveFile(sourcePath: string, destinationPath: string, options?: MoveOperationOptions): Promise<OperationResult>; /** * Convenience function for moving multiple markdown files * * @example * ```typescript * import { moveFiles } from 'markmv'; * * const result = await moveFiles([ * { source: 'old1.md', destination: 'new1.md' }, * { source: 'old2.md', destination: 'new2.md' } * ]); * ```; * * @param moves - Array of source/destination pairs * @param options - Optional configuration * * @returns Promise resolving to operation result * * @group Core API */ export declare function moveFiles(moves: Array<{ source: string; destination: string; }>, options?: MoveOperationOptions): Promise<OperationResult>; /** * Convenience function for validating markdown file operations * * @example * ```typescript * import { moveFile, validateOperation } from 'markmv'; * * const result = await moveFile('old.md', 'new.md'); * const validation = await validateOperation(result); * * if (!validation.valid) { * console.error(`Found ${validation.brokenLinks} broken links`); * } * ``` * * @param result - The operation result to validate * * @returns Promise resolving to validation result * * @group Core API */ export declare function validateOperation(result: OperationResult): Promise<{ valid: boolean; brokenLinks: number; errors: string[]; }>; /** * Generate table of contents for markdown content * * @example * ```typescript * import { generateToc } from 'markmv'; * * const content = '# Title\n## Section 1\n### Subsection'; * const result = await generateToc(content, { minDepth: 2 }); * console.log(result.toc); * ```; * * @param content - Markdown content to analyze * @param options - TOC generation options * * @returns Promise resolving to TOC result * * @group Utilities */ export declare function generateToc(content: string, options?: import('./utils/toc-generator.js').TocOptions): Promise<import('./utils/toc-generator.js').TocResult>; /** * Generate index files with optional table of contents * * @example * ```typescript * import { generateIndex } from 'markmv'; * * const options = { * type: 'links', * strategy: 'directory', * generateToc: true, * tocOptions: { minDepth: 2 } * }; * await generateIndex('.', options); * ```; * * @param directory - Directory to generate index for * @param options - Index generation options * * @returns Promise resolving when index generation is complete * * @group Commands */ export declare function generateIndex(directory: string, options: import('./commands/index.js').IndexOptions): Promise<void>; /** * Generate barrel files for themed content aggregation (alias for generateIndex) * * @example * ```typescript * import { generateBarrel } from 'markmv'; * * const options = { * type: 'links', * strategy: 'directory', * name: 'api-docs.md', * generateToc: true * }; * await generateBarrel('docs/', options); * ```; * * @param directory - Directory to generate barrel files for * @param options - Barrel generation options (same as IndexOptions) * * @returns Promise resolving when barrel generation is complete * * @group Commands */ export declare const generateBarrel: typeof generateIndex; /** * Test function to demonstrate auto-exposure pattern * * @example * ```typescript * import { testAutoExposure } from 'markmv'; * * const result = await testAutoExposure('Hello World'); * console.log(result.message); // "Echo: Hello World" * ```; * * @param input - The input message to echo * * @returns Promise resolving to echo result * * @group Testing */ export declare function testAutoExposure(input: string): Promise<{ message: string; timestamp: string; success: boolean; }>; //# sourceMappingURL=index.d.ts.map