@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
90 lines (89 loc) • 2.67 kB
TypeScript
import * as crypto from 'crypto';
export interface FileHash {
path: string;
hash: string;
size: number;
mtime: number;
ctime: number;
type: 'file' | 'directory';
}
export interface ChangeDetectionResult {
added: string[];
modified: string[];
deleted: string[];
moved: Array<{
from: string;
to: string;
}>;
totalChanges: number;
scanTime: number;
hashingTime: number;
}
export interface HashingOptions {
algorithm: string;
encoding: crypto.BinaryToTextEncoding;
chunkSize: number;
skipBinary: boolean;
includeMetadata: boolean;
excludePatterns: RegExp[];
maxFileSize: number;
}
export interface ChangeDetectionOptions {
useContentHashing?: boolean;
useMetadataOnly?: boolean;
recursiveDepth?: number;
followSymlinks?: boolean;
trackMoves?: boolean;
hashingOptions?: Partial<HashingOptions>;
cacheLocation?: string;
enableCache?: boolean;
}
export interface FileChangeEvent {
type: 'added' | 'modified' | 'deleted' | 'moved';
path: string;
oldPath?: string;
hash?: string;
oldHash?: string;
size?: number;
timestamp: number;
metadata?: {
mtime: number;
ctime: number;
mode: number;
};
}
export declare class ChangeDetector {
private hashCache;
private previousScan;
private rootPath;
private options;
private cacheFile;
constructor(rootPath: string, options?: ChangeDetectionOptions);
initialize(): Promise<void>;
detectChanges(scanPath?: string): Promise<ChangeDetectionResult>;
getFileHash(filePath: string): Promise<FileHash | null>;
hasFileChanged(filePath: string): Promise<boolean>;
getFileChanges(filePath: string): Promise<FileChangeEvent | null>;
clearCache(): Promise<void>;
getCacheStats(): {
cacheSize: number;
totalFiles: number;
memoryUsage: string;
hitRate: number;
};
private scanDirectory;
private calculateFileHash;
private calculateContentHash;
private calculateMetadataHash;
private isBinaryFile;
private isHashValid;
private compareScans;
private detectMoves;
private shouldExclude;
private loadCache;
private saveCache;
private formatBytes;
}
export declare function createChangeDetector(rootPath: string, options?: ChangeDetectionOptions): Promise<ChangeDetector>;
export declare function detectChanges(rootPath: string, options?: ChangeDetectionOptions): Promise<ChangeDetectionResult>;
export declare function hasFileChanged(rootPath: string, filePath: string, options?: ChangeDetectionOptions): Promise<boolean>;