import { Tree } from '@nrwl/devkit'; import { TSQueryStringTransformer } from '@phenomnomnominal/tsquery/dist/src/tsquery-types'; import { TSQuerySourceTransformer } from './replace'; import { Node, SourceFile } from 'typescript'; export declare type GetDefaultNodeFn = (node: SourceFile) => Node; export declare type FindNodeFn = (node: SourceFile) => Node | Node[] | undefined; export declare type CheckFn = (node: SourceFile) => boolean; export interface ModifyOptions { code?: string; selector?: string; checkFn?: CheckFn; findNodeFn?: FindNodeFn; getDefaultNodeFn?: GetDefaultNodeFn; [key: string]: any; } export interface ModifyFileOptions extends ModifyOptions { modifyFn?: ModifyFn; } export interface ModifySrcOptions extends ModifyOptions { modifySrcFn?: ModifySrcFn; } export interface ModifyTreeOptions extends ModifyFileOptions { projectRoot: string; relTargetFilePath: string; format?: boolean; } export declare type AnyOpts = { [key: string]: any; }; declare type TSSourceFileStringTransformer = (node: Node) => string | null | undefined; export declare type ModifyFn = (opts: AnyOpts) => TSQueryStringTransformer | TSSourceFileStringTransformer; export declare type ModifySrcFn = (opts: AnyOpts) => TSQuerySourceTransformer; export declare function replaceNodeContents(source: string, node: Node, opts: ModifyFileOptions): string | undefined; export declare function replaceSrcContents(source: string, opts: ModifySrcOptions): string | undefined; export declare function findAndReplaceNodeContents(targetFile: string, ast: SourceFile, opts: ModifyOptions): string | undefined; export declare function replaceContentInSrc(source: string, ast: SourceFile, opts: ModifyFileOptions): string | undefined; export declare function replaceInFile(filePath: string, opts: ModifyFileOptions): string | undefined; export interface ReplaceOpts { ast: SourceFile; sourceCode: string; opts: ModifyFileOptions; } export declare function replaceInSource(sourceCode: string, opts: ModifyFileOptions): string | undefined; declare type SaveTreeOpts = { tree: Tree; source?: string; filePath: string; fileContent: string; }; interface SaveAndFormatTreeOpts extends SaveTreeOpts { format?: boolean; } export declare const saveTree: ({ tree, source, filePath, fileContent, }: SaveTreeOpts) => void; export declare const saveAndFormatTree: (opts: SaveAndFormatTreeOpts) => Promise; export interface ReadNxSourceFileOpts { projectRoot: string; relTargetFilePath: string; } export declare const readNxSourceFile: (opts: ReadNxSourceFileOpts) => string; export declare function modifyTree(tree: Tree, opts: ModifyTreeOptions): Promise; export {};