import { Project } from 'ts-morph'; import type { SourceFile } from 'ts-morph'; export interface CodemodSession { project: Project; filePaths: string[]; /** * Latest text of files edited by `runTextTransform`, keyed by path, so a * later transform builds on an earlier one's edits even in a dry run. */ texts: Map; } export interface CodemodRunOptions { /** Root directory containing the application source. */ projectRoot: string; /** Inspect changes without saving files. */ dryRun: boolean; /** Shared parser and inventory when running multiple transforms. */ session?: CodemodSession; } export interface CodemodRunResult { totalFiles: number; changedFiles: { filePath: string; operations: number; summaries: string[]; before?: string; after?: string; }[]; errors: { filePath: string; error: string; }[]; /** Things the codemod skipped on purpose and the user should check. */ warnings?: { filePath: string; message: string; }[]; } /** Collect files with these extensions in a stable order without following symlinks. */ export declare const collectFiles: (root: string, extensions: ReadonlySet) => Promise; /** Collect application sources in a stable order without following symlinks. */ export declare const collectSourceFiles: (root: string) => Promise; /** Reuse source parsing across a sequence of migration transforms. */ export declare const createCodemodSession: (projectRoot: string) => Promise; /** Apply one transform and report exact before/after source for review. */ export declare const runTransform: (options: CodemodRunOptions, transform: (sourceFile: SourceFile) => { changed: boolean; operations: number; summaries: string[]; }) => Promise; /** * Apply a text transform to files the TypeScript parser does not read, such * as stylesheets. Reports the same before/after shape as `runTransform`. */ export declare const runTextTransform: (options: CodemodRunOptions, extensions: ReadonlySet, transform: (text: string, filePath: string) => { text: string; operations: number; summaries: string[]; }) => Promise; /** Combine the results of transforms that scanned different file sets. */ export declare const mergeResults: (...results: CodemodRunResult[]) => CodemodRunResult;