feat: add vitest, vite, move to tdd

This commit is contained in:
2026-07-13 07:07:44 +05:00
parent 4704a1d5a0
commit 62862beb06
18 changed files with 2043 additions and 346 deletions
+42
View File
@@ -0,0 +1,42 @@
import { IFileSystem } from "@/ports";
export class InMemoryFileSystem implements IFileSystem {
private files = new Map<string, string>();
reset(): void {
this.files.clear();
}
async readFile(path: string): Promise<string> {
const content = this.files.get(path);
if (content === undefined) {
throw new Error(`ENOENT: no such file: ${path}`);
}
return content;
}
async writeFile(path: string, content: string): Promise<void> {
this.files.set(path, content);
}
async deleteFile(path: string): Promise<void> {
this.files.delete(path);
}
async readdir(path: string): Promise<string[]> {
const prefix = path.endsWith("/") || path.endsWith("\\") ? path : path + "/";
const seen = new Set<string>();
for (const key of this.files.keys()) {
if (key.startsWith(prefix)) {
const relative = key.slice(prefix.length);
const top = relative.split(/[/\\]/)[0];
if (top) seen.add(top);
}
}
return [...seen];
}
async mkdir(_path: string): Promise<void> {
// no-op for in-memory
}
}