export * from "./npmInstallActions";
import type { INPMDependency } from "./npmInstallActions";
/**
 * A string based URI sub-system.
 * This will be implemented using the node path module for node applications.
 * In VSCode this may be implemented using the vscode.URI
 */
export interface IPath {
    join(...path: string[]): any;
    dirname(path: string): string;
    basename(path: string): string;
    extname(path: string): string;
    resolve(...path: string[]): any;
}
/**
 * An abstraction of a file-system,
 * used by the scaffolding mechanizm.
 */
export interface IFileSystem {
    exists(path: string): Promise<boolean>;
    read(path: string): Promise<string>;
    write(path: string, content: string, encoding?: "utf8" | "base64"): Promise<void>;
    delete(path: string): Promise<void>;
}
export interface ISourceFile {
    readonly path: string;
    /**
     * Gets the current file content.
     * This operation may perform networking or disk IO.
     * Once read, it may be cached in a virtual file system and reused in subsequent calls.
     */
    getContent(): Promise<string>;
    /**
     * Sets the source file content.
     * The underlying implementation may use in-memoty branching
     * and a virtual file system, not writing directly to disc.
     *
     * Expects a string, and the file will be written as utf8.
     */
    setContent(content: string): Promise<void>;
    /**
     * Sets the source file content.
     *
     * The underlying implementation may use in-memoty branching
     * and a virtual file system, not writing directly to disc.
     *
     * Expects a Base64 encoded content string, and the file will be written as binary.
     */
    setBase64Content(content: string): Promise<void>;
    delete(): Promise<void>;
    throwIfExists(): Promise<void>;
    checkIfExits(): Promise<boolean>;
}
export interface IOpenFiles {
    type: "open-source-file";
    files: string[];
}
export declare function actionIsOpenFiles(action: IPostAction): action is IOpenFiles;
export type IPostAction = INPMDependency | IOpenFiles;
export interface IProjectEnv {
    push(action: IPostAction): any;
}
export interface IProjectTemplate {
    apply(project: INPMProject, env: IProjectEnv): any;
    options: any;
}
export interface IScaffolder {
    apply(project: INPMProject, env: IProjectEnv): any;
    options: any;
}
/**
 * A base class for project scaffolders.
 */
export declare abstract class ProjectTemplate<T> implements IProjectTemplate {
    options: undefined | T;
    abstract apply(project: INPMProject, env: IProjectEnv): Promise<void>;
}
/**
 * A base class for project item scaffolders.
 */
export declare abstract class Scaffolder<T> implements IScaffolder {
    options: undefined | T;
    abstract apply(project: INPMProject, env: IProjectEnv): Promise<void>;
}
export interface ISourceRepo {
    readonly path: IPath;
    source(...path: string[]): ISourceFile;
}
export interface IProject {
    readonly dir: string;
    /**
     * Resolve paths relative to the project dir.
     * Things like {@link IPath.resolve} will resolve relative paths as relative to the project.
     */
    resolve(...path: string[]): any;
    source(...path: string[]): ISourceFile;
}
export interface INPMProject extends IProject {
    /**
     * The path to the package.json file.
     */
    packageJsonPath: string;
    /**
     * The path of the root dir containing the project (the package.json dirname).
     */
    dir: string;
}
export declare class SourceRepo implements ISourceRepo {
    readonly path: IPath;
    readonly fs: IFileSystem;
    private readonly _sourceFiles;
    constructor(path: IPath, fs: IFileSystem);
    source(...path: string[]): ISourceFile;
    uncommitedChanges(): Generator<SourceFile, void, unknown>;
    commit(logger: ILogger): Promise<void>;
    discard(): Promise<void>;
}
export declare enum SourceFileState {
    /**
     * This source file object has been created for inspection.
     * It can provide information about the project file on disk,
     * or can be used to be created, modified or deleted at a later stage.
     */
    view = "view",
    /**
     * Similar to view, but also this file's content has been loaded and is available for code edit.
     */
    open = "open",
    /**
     * This source file contains text changes that should go to disk, creating or overwriting the system file.
     */
    edit = "edited",
    /**
     * This source file has been deleted, a system file at this file path should also be deleted when changes are applied.
     */
    delete = "delete",
    /**
     * This source file has been created, a system file at this file path should be created or overwritten when changes are applied.
     */
    create = "create"
}
export interface ILogger {
    error(e: Error): any;
}
declare class SourceFile implements ISourceFile {
    readonly path: string;
    private repo;
    private _state;
    /**
     * The current content of the file, set using {@link setContent}
     */
    private _content;
    private _type;
    private _open;
    constructor(path: string, repo: SourceRepo);
    get state(): SourceFileState;
    getOriginalContent(): Promise<string>;
    getContent(): Promise<string>;
    setContent(content: string): Promise<void>;
    setBase64Content(content: string): Promise<void>;
    delete(): Promise<void>;
    private Open;
    private OpenImpl;
    throwIfExists(): Promise<void>;
    checkIfExits(): Promise<boolean>;
    get hasUncommitedChanges(): boolean;
    discard(): Promise<void>;
    commit(logger: ILogger): Promise<void>;
}
export declare class NPMProject implements INPMProject, IProject {
    readonly packageJsonPath: string;
    readonly dir: string;
    private readonly repo;
    constructor(packageJsonPath: string, repo: ISourceRepo);
    resolve(...path: string[]): any;
    get path(): IPath;
    source(...path: string[]): ISourceFile;
    static find(dir: string, repo: ISourceRepo): Promise<NPMProject | undefined>;
}
