import { Mode } from 'fs'; export type JsonArray = Array; export interface JsonObject { [prop: string]: JsonValue; } export type JsonValue = boolean | string | number | JsonArray | JsonObject | null; /** * Determines if a given value is a valid JSON object. * * This function checks if the provided value is an object, ensuring it is neither `null` nor an array. * It is useful for type-guarding purposes, allowing TypeScript to infer the correct type based on the check. * * @param value The `JsonValue` to be checked. * @returns `true` if the value is a non-null object and not an array, otherwise `false`. * * @example * IsJsonObject({ key: "value" }); // returns true * IsJsonObject([1, 2, 3]); // returns false * IsJsonObject("I am not an object"); // returns false * IsJsonObject(null); // returns false */ export declare function IsJsonObject(value: JsonValue): value is JsonObject; /** * Determines if the provided `JsonValue` is a `JsonArray`. * * This function checks if the given `value` is both truthy and an array. It utilizes the `Array.isArray` method * to ensure that the `value` conforms to the `JsonArray` type, which is an array structure in JSON format. * * @param value - The `JsonValue` to be checked. * @returns `true` if `value` is a non-null array, otherwise `false`. * * @example * IsJsonArray([1, 2, 3]); // returns true * IsJsonArray({ key: 'value' }); // returns false * IsJsonArray(null); // returns false */ export declare function IsJsonArray(value: JsonValue): value is JsonArray; export interface TreeLike { delete(path: string): void; rename(from: string, to: string): void; exists(path: string): boolean; } /** * Checks if the provided object adheres to the `TreeLike` interface. * * A `TreeLike` object is expected to have the following methods: * - `delete`: A function to remove an element from the tree. * - `rename`: A function to rename an element in the tree. * - `exists`: A function to check the existence of an element in the tree. * * @param tree - The object to be checked. * @returns `true` if the object has all the required `TreeLike` methods, otherwise `false`. * @template TreeLike - An interface or type that the `tree` parameter is expected to conform to. */ export declare function IsTreeLike(tree: any): tree is TreeLike; export interface SchematicTreeLike extends TreeLike { read(filePath: string): Buffer | null; overwrite(path: string, content: Buffer | string): void; create(path: string, content: Buffer | string): void; readText(path: string): string; readJson(path: string): JsonValue; root: FakeDirEntry; get(path: string): FileEntryLike | null; getDir(path: string): DirEntryLike; } export interface TreeWriteOptions { /** * Permission to be granted on the file, given as a string (e.g `755`) or octal integer (e.g `0o755`). * The logical OR operator can be used to separate multiple permissions. * See https://nodejs.org/api/fs.html#fs_file_modes */ mode?: Mode; } export interface FileChange { /** * Path relative to the workspace root */ path: string; /** * Type of change: 'CREATE' | 'DELETE' | 'UPDATE' */ type: 'CREATE' | 'DELETE' | 'UPDATE'; /** * The content of the file or null in case of delete. */ content: Buffer | null; /** * Options to set on the file being created or updated. */ options?: TreeWriteOptions; } export interface GeneratorTreeLike extends TreeLike { read(filePath: string): Buffer | null; read(filePath: string, encoding: BufferEncoding): string | null; write(filePath: string, content: Buffer | string, options?: TreeWriteOptions): void; isFile(filePath: string): boolean; children(dirPath: string): string[]; listChanges(): FileChange[]; changePermissions(filePath: string, mode: Mode): void; root: string; } /** * Determines if a given `tree` object conforms to the `SchematicTreeLike` interface. * * This function checks if the `tree` object has all the necessary methods and properties * defined in the `SchematicTreeLike` interface. It verifies the existence and correct type * of several methods and properties that are essential for interacting with a schematic tree structure. * * @param tree - The tree object to check. * @returns `true` if the `tree` object matches the `SchematicTreeLike` interface, otherwise `false`. */ export declare function IsSchematicTreeLike(tree: TreeLike): tree is SchematicTreeLike; /** * Checks if a given tree-like structure conforms to the `GeneratorTreeLike` interface. * * This function determines if the provided `tree` object is not a `SchematicTreeLike` and has a `root` property of type string, which are the characteristics of a `GeneratorTreeLike`. * * @param tree - The tree-like object to check. * @returns `true` if the `tree` is a `GeneratorTreeLike`, otherwise `false`. * * @example * * const tree = { root: 'rootNode', nodes: [] }; * console.log(IsGeneratorTreeLike(tree)); // Output: true or false based on the structure of `tree` * ``` */ export declare function IsGeneratorTreeLike(tree: TreeLike): tree is GeneratorTreeLike; export declare function IsFsTreeLike(tree: TreeLike): tree is FsTree; export interface FileEntryLike { path: string; content: Buffer; } export interface DirEntryLike { path: string; subdirs: string[]; subfiles: string[]; parent: DirEntryLike | null; dir(name: string): DirEntryLike; file(name: string): FileEntryLike | null; visit(visitor: any): void; } export declare class FakeDirEntry implements DirEntryLike { readonly path: string; private readonly tree; constructor(path: string, tree: GeneratorTreeLike | FsTree); get parent(): FakeDirEntry | null; get subdirs(): string[]; get subfiles(): string[]; dir(name: string): FakeDirEntry; file(name: string): FileEntryLike | null; visit(visitor: any): void; } export declare class FsTree implements TreeLike { readonly root: string; constructor(root: string); delete(path: string): void; rename(from: string, to: string): void; exists(path: string): boolean; read(path: string, encoding: BufferEncoding): string | null; read(path: string): Buffer | null; write(filePath: string, content: Buffer | string, options?: TreeWriteOptions): void; isFile(filePath: string): boolean; children(dirPath: string): string[]; } export declare class TreeAdapter implements TreeLike, GeneratorTreeLike, SchematicTreeLike { readonly wrapped: TreeLike; /** * @deprecated dont use this property */ get root(): any; constructor(wrapped: TreeLike); delete(path: string): void; rename(from: string, to: string): void; exists(path: string): boolean; read(filePath: string, encoding: BufferEncoding): string | null; read(filePath: string): Buffer | null; write(filePath: string, content: Buffer | string, options?: TreeWriteOptions): void; isFile(filePath: string): boolean; children(dirPath: string): string[]; listChanges(): FileChange[]; changePermissions(filePath: string, mode: Mode): void; overwrite(path: string, content: Buffer | string): void; create(path: string, content: Buffer | string): void; readText(path: string): string; readJson(path: string): T; get(path: string): FileEntryLike | null; getDir(path: string): DirEntryLike; }