import { type MemFsEditor } from 'mem-fs-editor'; import type { BaseGenerator } from '../generator.js'; import type { PathOptions } from '../types.js'; type CopyOptions = NonNullable[2]>; type CopyAsyncOptions = NonNullable[2]>; type WriteOptions = NonNullable[2]>; type WriteJSONParameters = Parameters; type WriteJSONReplacer = WriteJSONParameters[2]; type WriteJSONSpace = WriteJSONParameters[3]; type WriteJSONOptions = WriteOptions & PathOptions & { replacer?: WriteJSONReplacer; space?: WriteJSONSpace; }; type DeleteOptions = NonNullable[1]>; type CopyTplOptions = NonNullable[3]>; type CopyTplAsyncOptions = NonNullable[3]>; export type Template[2]>> = { /** * Template file, relative to templatePath(), or absolute inside the source root (outside when the `allowTemplatesOutsideRoot` feature is enabled, inside the generator package when the `allowPackageTemplates` feature is enabled). */ source: string; /** * Conditional if the template should be written. * @param TemplateData * @param Generator * @returns */ when?: (data: D, generator: G) => boolean; /** * Destination, relative to destinationPath(), or absolute inside the destination root (outside when the `allowDestinationOutsideRoot` feature is enabled). */ destination?: string; /** * Mem-fs-editor copy options, `allowOutsideRoot` applies to both source and destination. */ copyOptions?: NonNullable[3]> & PathOptions; /** * Ejs data */ templateData?: string | D; }; export type Templates[2]>> = Array>; export declare class FsMixin { fs: MemFsEditor; /** * Read file from templates folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.read(this.templatePath(filepath)) */ readTemplate(this: BaseGenerator, filepath: string, options?: PathOptions): string; readTemplate(this: BaseGenerator, filepath: string, options: { raw?: false; defaults: DefaultType; } & PathOptions): string | DefaultType; readTemplate(this: BaseGenerator, filepath: string, options: { raw: true; defaults?: never; } & PathOptions): Buffer; readTemplate(this: BaseGenerator, filepath: string, options: { raw: true; defaults: DefaultType; } & PathOptions): Buffer | DefaultType; /** * Copy file from templates folder to destination folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.copy(this.templatePath(from), this.destinationPath(to)) */ copyTemplate(this: BaseGenerator, ...args: [from: string | string[], to: string, options?: CopyOptions & PathOptions]): ReturnType; /** * Copy file from templates folder to destination folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.copy(this.templatePath(from), this.destinationPath(to)) */ copyTemplateAsync(this: BaseGenerator, ...args: [from: string | string[], to: string, options?: CopyAsyncOptions & PathOptions]): ReturnType; /** * Read file from destination folder * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.read(this.destinationPath(filepath)). */ readDestination(this: BaseGenerator, filepath: string, options?: PathOptions): string; readDestination(this: BaseGenerator, filepath: string, options: { raw?: false; defaults: DefaultType; } & PathOptions): string | DefaultType; readDestination(this: BaseGenerator, filepath: string, options: { raw: true; defaults?: never; } & PathOptions): Buffer; readDestination(this: BaseGenerator, filepath: string, options: { raw: true; defaults: DefaultType; } & PathOptions): Buffer | DefaultType; /** * Read JSON file from destination folder * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.readJSON(this.destinationPath(filepath)). */ readDestinationJSON(this: BaseGenerator, filepath: string, defaults?: undefined, options?: PathOptions): object | undefined; readDestinationJSON(this: BaseGenerator, filepath: string, defaults: T, options?: PathOptions): object | T; /** * Write file to destination folder * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.write(this.destinationPath(filepath)). */ writeDestination(this: BaseGenerator, ...args: [filepath: string, contents: string | Buffer, options?: WriteOptions & PathOptions]): ReturnType; /** * Write json file to destination folder * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.writeJSON(this.destinationPath(filepath)). */ writeDestinationJSON(this: BaseGenerator, filepath: string, contents: unknown, options?: WriteJSONOptions): ReturnType; writeDestinationJSON(this: BaseGenerator, filepath: string, contents: unknown, replacer?: WriteJSONReplacer, space?: WriteJSONSpace, options?: WriteOptions & PathOptions): ReturnType; /** * Delete file from destination folder * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.delete(this.destinationPath(filepath)). */ deleteDestination(this: BaseGenerator, ...args: [paths: string | string[], options?: DeleteOptions & PathOptions]): ReturnType; /** * Copy file from destination folder to another destination folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.copy(this.destinationPath(from), this.destinationPath(to)). */ copyDestination(this: BaseGenerator, ...args: [from: string | string[], to: string, options?: CopyOptions & PathOptions]): ReturnType; /** * Move file from destination folder to another destination folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.move(this.destinationPath(from), this.destinationPath(to)). */ moveDestination(this: BaseGenerator, ...args: [from: string, to: string, options?: CopyOptions & PathOptions]): ReturnType; /** * Exists file on destination folder. * mem-fs-editor method's shortcut, for more information see [mem-fs-editor]{@link https://github.com/SBoudrias/mem-fs-editor}. * Shortcut for this.fs!.exists(this.destinationPath(filepath)). */ existsDestination(this: BaseGenerator, ...args: [filepath: string, options?: PathOptions]): ReturnType; /** * Copy a template from templates folder to the destination. * * @param source - template file, relative to templatePath(), or absolute inside the source root (outside when the `allowTemplatesOutsideRoot` feature is enabled, inside the generator package when the `allowPackageTemplates` feature is enabled). * @param destination - destination, relative to destinationPath(), or absolute inside the destination root (outside when the `allowDestinationOutsideRoot` feature is enabled). * @param templateData - ejs data * @param templateOptions - ejs options * @param copyOptions - mem-fs-editor copy options, `allowOutsideRoot` applies to both source and destination */ renderTemplate[2]>>(this: BaseGenerator, source?: string | string[], destination?: string | string[], templateData?: string | D, copyOptions?: CopyTplOptions & PathOptions): void; /** * Copy a template from templates folder to the destination. * * @param source - template file, relative to templatePath(), or absolute inside the source root (outside when the `allowTemplatesOutsideRoot` feature is enabled, inside the generator package when the `allowPackageTemplates` feature is enabled). * @param destination - destination, relative to destinationPath(), or absolute inside the destination root (outside when the `allowDestinationOutsideRoot` feature is enabled). * @param templateData - ejs data * @param templateOptions - ejs options * @param copyOptions - mem-fs-editor copy options, `allowOutsideRoot` applies to both source and destination */ renderTemplateAsync[2]>>(this: BaseGenerator, source?: string | string[], destination?: string | string[], templateData?: string | D, copyOptions?: CopyTplAsyncOptions & PathOptions): Promise; /** * Copy templates from templates folder to the destination. */ renderTemplates[2]>>(this: BaseGenerator, templates: Templates, templateData?: string | D): void; /** * Copy templates from templates folder to the destination. * * @param templates - template file, relative to templatePath(), or absolute inside the source root (outside when the `allowTemplatesOutsideRoot` feature is enabled, inside the generator package when the `allowPackageTemplates` feature is enabled). * @param templateData - ejs data */ renderTemplatesAsync[2]>>(this: BaseGenerator, templates: Templates, templateData?: string | D): Promise; /** * Utility method to get a formatted data for templates. * * @param path - path to the storage key. * @return data to be passed to the templates. */ _templateData(this: BaseGenerator, path?: string): any; } export {};