@regele/devtools
Version:
A collection of developer utilities for code processing and text analysis
87 lines (86 loc) • 2.46 kB
TypeScript
import { FileType } from '../utils';
/**
* Result of a file operation
*/
export interface FileResult {
path: string;
success: boolean;
error?: string;
fileType?: FileType;
originalSize?: number;
newSize?: number;
diffSize?: number;
diffPercentage?: number;
}
/**
* Options for file operations
*/
export interface FileOptions {
write?: boolean;
silent?: boolean;
ignore?: string[];
config?: string;
}
/**
* Default patterns to ignore
*/
export declare const DEFAULT_IGNORE_PATTERNS: string[];
/**
* Find files matching the given patterns
*
* @param patterns - Glob patterns to match
* @param options - File options
* @returns Array of file paths
*/
export declare function findFiles(patterns: string | string[], options?: FileOptions): Promise<string[]>;
/**
* Read a file and detect its type
*
* @param filePath - Path to the file
* @returns File content and type
*/
export declare function readFile(filePath: string): {
content: string;
fileType: FileType;
};
/**
* Write content to a file
*
* @param filePath - Path to the file
* @param content - Content to write
* @returns Success status
*/
export declare function writeFile(filePath: string, content: string): boolean;
/**
* Process a file with the given processor function
*
* @param filePath - Path to the file
* @param processor - Function to process the file content
* @param options - File options
* @returns Result of the operation
*/
export declare function processFile(filePath: string, processor: (content: string, fileType: FileType) => Promise<string>, options?: FileOptions): Promise<FileResult>;
/**
* Process multiple files with the given processor function
*
* @param patterns - Glob patterns to match
* @param processor - Function to process file content
* @param options - File options
* @returns Results of the operations
*/
export declare function processFiles(patterns: string | string[], processor: (content: string, fileType: FileType) => Promise<string>, options?: FileOptions): Promise<FileResult[]>;
/**
* Get a summary of file processing results
*
* @param results - File processing results
* @returns Summary statistics
*/
export declare function getSummary(results: FileResult[]): {
totalFiles: number;
successCount: number;
errorCount: number;
totalOriginalSize: number;
totalNewSize: number;
totalDiffSize: number;
averageDiffPercentage: number;
};