@timothy-spaceman/multitrack-vcs
Version:
Version Control System for musicians
70 lines (69 loc) • 2.6 kB
TypeScript
import { IStorageProvider } from "../storage/index.js";
import { BranchList, Commit, CommitList, Difference, Item, ItemList } from "./types.js";
export declare const PROJECT_DIR = ".mvcs";
export declare const CONTENT_DIR = "contents";
export type ProjectDump = {
id: string;
authorId: string;
title: string;
description?: string;
branches: {
[k: string]: string;
};
defaultBranch?: string;
currentBranch?: string;
commits: {
[k: string]: Commit;
};
rootCommitId?: string;
currentCommitId?: string;
items: {
[k: string]: Item;
};
};
export type ProjectDumpKey = keyof ProjectDump;
export declare const PROJECT_DUMP_KEYS: ProjectDumpKey[];
export declare class Project {
sp: IStorageProvider;
id: string;
authorId: string;
title: string;
description?: string;
workingDir: string;
branches: BranchList;
defaultBranch?: string;
currentBranch?: string;
commits: CommitList;
rootCommitId?: string;
currentCommitId?: string;
items: ItemList;
private constructor();
static fromFile(dirPath: string, sp: IStorageProvider): Promise<Project>;
static create(sp: IStorageProvider, workingDir: string, authorId: string, title: string, description?: string): Promise<Project>;
toJSON(): ProjectDump;
fromJSON(dump: ProjectDump): void;
load(): Promise<void>;
save(): Promise<void>;
getProjectFilePath(): string;
getContentPath(content: string): string;
addContent(sourcePath: string): Promise<string>;
matchCommitId(idPart: string): string;
getCurrentCommit(): Commit | undefined;
getCommitItems(commitId: string): Promise<ItemList>;
buildCommitChain(targetCommit: Commit): Commit[];
applyCommitChanges(commit: Commit, resultItems: ItemList): void;
getCurrentFiles(): Promise<string[]>;
filesToItems(files: string[]): Promise<ItemList>;
status(files?: string[] | undefined): Promise<Difference>;
diff(beforeItems: ItemList, afterItems: ItemList): Promise<Difference>;
commit(files: string[], authorId: string, title: string, description?: string): Promise<Commit>;
ensureValidBranchForCommit(): void;
checkout(commitId: string): Promise<void>;
checkoutBranch(branchName: string): Promise<void>;
createBranch(branchName: string): void;
deleteBranch(branchName: string): void;
renameBranch(oldName: string, newName: string): void;
setDefaultBranch(branchName: string): void;
throwIfBranchNotFound(branchName: string): void;
throwIfBranchFound(branchName: string): void;
}