@nxworker/workspace
Version:
Nx plugin providing generators for managing workspace files, including the move-file generator for safely moving files between projects while updating all imports
42 lines (41 loc) • 1.35 kB
TypeScript
import { Tree } from '@nx/devkit';
import * as jscodeshift from 'jscodeshift';
import type { Collection } from 'jscodeshift';
declare const j: jscodeshift.JSCodeshift;
/**
* Cache for storing parsed ASTs to avoid re-parsing files during a move operation.
* This is particularly beneficial when multiple update operations touch the same files.
*/
declare class ASTCache {
private contentCache;
private astCache;
private parseAttempts;
/**
* Gets the file content, using cache if available.
*/
getContent(tree: Tree, filePath: string): string | null;
/**
* Gets the parsed AST for a file, using cache if available.
* Returns null if the file cannot be parsed or doesn't exist.
*/
getAST(tree: Tree, filePath: string): Collection | null;
/**
* Invalidates the cache entry for a file after it has been modified.
* This ensures subsequent reads get the updated content.
*/
invalidate(filePath: string): void;
/**
* Clears all cached data. Useful when starting a new move operation.
*/
clear(): void;
/**
* Returns cache statistics for monitoring/debugging.
*/
getStats(): {
contentCacheSize: number;
astCacheSize: number;
failedParseCount: number;
};
}
export declare const astCache: ASTCache;
export { j };