@morodomi/ait3
Version:
AIT³ Development Platform - AI + Ticket + Test + Tool driven development methodology
49 lines (48 loc) • 1.74 kB
TypeScript
/**
* Common file operations utilities
* Reduces code duplication for directory creation and file handling
*/
export interface FileOperationResult {
success: boolean;
directoryCreated: boolean;
fileOverwritten: boolean;
message?: string;
}
/**
* Ensure directory exists, creating it if necessary
*/
export declare function ensureDirectoryExists(dirPath: string): Promise<boolean>;
/**
* Check if file exists and handle force overwrite logic
*/
export declare function checkFileExists(filePath: string, force?: boolean): Promise<{
exists: boolean;
shouldWrite: boolean;
message?: string;
}>;
/**
* Write file with directory creation and error handling
*/
export declare function writeFileWithDirectoryCreation(filePath: string, content: string, force?: boolean): Promise<FileOperationResult>;
/**
* Create multiple directories in parallel
*/
export declare function ensureMultipleDirectories(dirPaths: string[]): Promise<{
success: boolean;
createdDirectories: string[];
message?: string;
}>;
/**
* Generate success message for file operations
*/
export declare function generateFileOperationMessage(filePath: string, result: FileOperationResult, nextActionText?: string): string;
/**
* Write file atomically using write-then-rename pattern
* Ensures that concurrent reads never see partial content
*/
export declare function atomicWriteFile(filePath: string, content: string): Promise<void>;
/**
* Write file atomically with directory creation and force overwrite logic
* Combines atomic write with existing directory creation patterns
*/
export declare function atomicWriteFileWithDirectoryCreation(filePath: string, content: string, force?: boolean): Promise<FileOperationResult>;