UNPKG

gen-jhipster

Version:

Spring Boot + Angular/React/Vue in one handy generator

79 lines (78 loc) 2.86 kB
import type CoreGenerator from '../../base-core/index.js'; import type { CascatedEditFileCallback, EditFileCallback, NeedleCallback } from '../api.js'; export type NeedleInsertion = { needle: string; /** * Content to add. */ contentToAdd: string | string[] | ((content: string, options: { needleIndent: number; indentPrefix: string; }) => string); contentToCheck?: string | RegExp; /** * check existing content ignoring white spaces and new lines. */ ignoreWhitespaces?: boolean; /** * throw error if needle was not found */ optional?: boolean; /** * Detect and apply indent */ autoIndent?: boolean; }; type NeedleFileInsertion = NeedleInsertion & { /** * Path to file. * The generator context must be passed. */ filePath?: string; /** * Common needle prefix */ needlesPrefix?: string; }; type NeedleContentInsertion = NeedleInsertion & { content: string; }; /** * Change spaces sequences and '>' to allow any number of spaces or new line prefix */ export declare const convertToPrettierExpressions: (str: string) => string; /** * Check if contentToCheck existing in content * * @param contentToCheck * @param content * @param [ignoreWhitespaces=true] */ export declare const checkContentIn: (contentToCheck: string | RegExp, content: any, ignoreWhitespaces?: boolean) => boolean; /** * Write content before needle applying indentation * * @param args * @returns null if needle was not found, new content otherwise */ export declare const insertContentBeforeNeedle: ({ content, contentToAdd, needle, autoIndent }: NeedleContentInsertion) => string | null; /** * Create an callback to insert the new content into existing content. * * A `contentToAdd` of string type will remove leading `\n`. * Leading `\n` allows a prettier template formatting. * * @param options */ export declare const createNeedleCallback: <Generator extends CoreGenerator = CoreGenerator>({ needle, contentToAdd, contentToCheck, optional, ignoreWhitespaces, autoIndent, }: NeedleInsertion) => EditFileCallback<Generator>; /** * Inject content before needle or create a needle insertion callback. * * @param this - generator if provided, editFile will be executed */ export declare function createBaseNeedle(options: Omit<NeedleFileInsertion, 'filePath' | 'needle' | 'contentToAdd'>, needles: Record<string, string>): NeedleCallback; export declare function createBaseNeedle(needles: Record<string, string>): NeedleCallback; export declare function createBaseNeedle<Generator extends CoreGenerator = CoreGenerator>(this: Generator, options: Omit<NeedleFileInsertion, 'filePath' | 'needle' | 'contentToAdd'> & { filePath: string; }, needles: Record<string, string>): CascatedEditFileCallback<Generator>; export {};