feat: allow project files to be excluded before analysis

This commit is contained in:
muena
2026-10-19 10:35:41 +02:00
parent 19434c6c0b
commit 031eaa978f
3 changed files with 193 additions and 29 deletions

View File

@@ -103,6 +103,35 @@ describe("Velum-Projektstände", () => {
expect(await project.loadProjectEntityTypes(other, support)).toBeNull();
});
it("behält abgewählte Dateien pro Projekt und gibt sie nicht an die Analyse weiter", async () => {
const root = await fs.mkdtemp(join(tmpdir(), "velum-file-selection-test-"));
roots.push(root);
const source = join(root, "Quelle");
const other = join(root, "Anderes Projekt");
const support = join(root, "Raycast");
await fs.mkdir(join(source, "Unterordner"), { recursive: true });
await fs.mkdir(other);
await fs.writeFile(join(source, "Behalten.txt"), "Künstlicher Testtext");
await fs.writeFile(join(source, "Unterordner", "Auslassen.md"), "Künstlicher Testtext");
expect(await project.loadProjectFileExclusions(source, support)).toEqual([]);
await project.saveProjectFileExclusions(`${source}/`, ["Unterordner/Auslassen.md", "Unterordner/Auslassen.md"], support);
expect(await project.loadProjectFileExclusions(source, support)).toEqual(["Unterordner/Auslassen.md"]);
expect(await project.loadProjectFileExclusions(other, support)).toEqual([]);
const scan = await project.scanProjectFiles(source, undefined, false);
const chosen = project.withoutExcludedProjectFiles(scan.files, await project.loadProjectFileExclusions(source, support));
expect(chosen.map((file) => file.relPath)).toEqual(["Behalten.txt"]);
const run = await project.createRun(source, support);
await fs.writeFile(join(run.directory, "files", "Behalten.txt"), "PERSON_01");
await project.replaceProjectFilesInPlace(source, run.directory,
chosen.map((file) => ({ source: file.relPath, output: file.relPath, kind: file.kind })));
expect(await fs.readFile(join(source, "Behalten.txt"), "utf8")).toBe("PERSON_01");
expect(await fs.readFile(join(source, "Unterordner", "Auslassen.md"), "utf8"))
.toBe("Künstlicher Testtext");
await expect(project.saveProjectFileExclusions(source, ["../Anderes Projekt/Datei.txt"], support))
.rejects.toThrow("Ungültiger Dateipfad");
});
it("überspringt temporäre und falsch benannte Office-Dateien vor der API-Analyse", async () => {
const root = await fs.mkdtemp(join(tmpdir(), "velum-office-scan-test-"));
roots.push(root);