/**
* Copyright 2023 Kapeta Inc.
* SPDX-License-Identifier: MIT
*/
///
///
import { GeneratedAsset, GeneratedResult } from './types';
import FS from 'fs';
export declare const ASSETS_FILE: string;
export declare const MODE_MERGE = "merge";
export declare const MODE_CREATE_ONLY = "create-only";
export declare const MODE_WRITE_ALWAYS = "write-always";
export declare const MODE_WRITE_NEVER = "write-never";
export declare const DEFAULT_FILE_PERMISSIONS = "644";
export interface FileSystemHandler {
write: (filename: string, content: string | Buffer, permissions?: string) => void;
read: (filename: string) => Buffer;
readDir: (filename: string) => string[];
exists: (filename: string) => boolean;
removeFile: (filename: string) => void;
removeDir: (filename: string) => void;
stat: (filename: string) => FS.Stats;
mkdirp: (dirname: string) => void;
}
export interface CodeWriterOptions {
skipAssetsFile?: boolean;
fileSystemHandler?: FileSystemHandler;
}
export declare class CodeWriter {
private readonly _baseDir;
private readonly _options;
static getInternalMergePath(filename: string): string;
constructor(basedir: string, options?: CodeWriterOptions);
private get fs();
/**
* Ensures the target folder exists and returns the full path
*/
private _ensureDestinationFolder;
/**
* Get a file checksum from its contents
*/
private _getFileChecksum;
/**
* Update files using generated code - respecting the mode of the file
* and checking if the file has changed since last time we generated it
*
*/
private _updateAssetFile;
private _writeFile;
/**
* Reads the Kapeta assets bookkeeping file that allows us to
* determine whether individual assets changed
*
*/
private _readAssetsFile;
/**
* Update the assets bookkeeping file
*/
private _writeAssetsFile;
/**
* Check if an asset has manual changes since it was generated
*/
private _hasManualChanges;
/**
* Clean up assets that we no longer need and have no changes
*/
private _cleanupAssets;
private isFolderEmpty;
private deleteEmptyFolder;
/**
* Takes the output from the code generator and persists it to file
*/
write({ files, target }: GeneratedResult): GeneratedAsset[];
}