UNPKG

@coat/cli

Version:

TODO: See #3

66 lines (65 loc) 3.35 kB
import { CoatContext } from "../types/coat-context"; import { CoatLockfileContinuousFileEntryStrict } from "../types/coat-lockfiles"; import { PolishedFile } from "./polish-files"; export declare enum UpdatePrompt { Update = 0, FirstUpdate = 1 } export declare enum FileOperationType { Delete = 0, DeleteSkipped = 1, Place = 2, Update = 3, UpdateWithPrompt = 4 } interface FileOperationBase { type: FileOperationType; local: boolean; relativePath: string; absolutePath: string; } interface FileOperationWithoutContent extends FileOperationBase { type: FileOperationType.Delete | FileOperationType.DeleteSkipped; } interface FileOperationWithContent extends FileOperationBase { type: FileOperationType.Place | FileOperationType.Update; content: string; } export interface FileOperationWithPrompt extends FileOperationBase { type: FileOperationType.UpdateWithPrompt; content: string; prompt: UpdatePrompt; } export type FileOperation = FileOperationWithoutContent | FileOperationWithContent | FileOperationWithPrompt; interface FileToRemoveParameter extends CoatLockfileContinuousFileEntryStrict { local: boolean; } /** * Writes updates from coat sync to the disk. * * The top priority is to prevent accidental loss of data, * therefore coat sync should prompt the user in certain situations, * or automatically skip the creation / deletion. * * The following table presents the situations where the user shall be prompted: * * | Scenario / Disk context | In lockfile (N) On disk (N) | In lockfile (N) Different disk content | In lockfile (N) On disk (Y) | In lockfile (Y) On disk (N) | In lockfile (Y) Different disk content | In lockfile (Y) On disk (Y) | * |--------------------------|-----------------------------|----------------------------------------|-----------------------------|-----------------------------|----------------------------------------|-----------------------------| * | Once File - Place | Place | / | / | / | / | / | * | Continuous File - Place | Place | Prompt | Don't place | Place | Prompt | Don't place | * | Continuous File - Delete | / | / | / | Don't delete | Don't delete | Delete | * * TODO: See #55 * It could be possible to offer automatic customization file placement * if the detected change in a file can be easily refactored by * using a customization file. * * @param allFilesToPlace All files that should be created or updated * @param allFilesToRemove All files that should be deleted * @param currentFiles The current content of the files on disk * @param context The context of the current coat project */ export declare function getFileOperations(allFilesToPlace: PolishedFile[], allFilesToRemove: FileToRemoveParameter[], currentFiles: { [filePath: string]: string | undefined; }, context: CoatContext): FileOperation[]; export {};