-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathtemplate-ai-config.test.ts
More file actions
74 lines (69 loc) · 2.44 KB
/
template-ai-config.test.ts
File metadata and controls
74 lines (69 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* template-ai-config.test.ts
*
* Verifies that AI assistant configuration files (CLAUDE.md, AGENTS.md)
* are properly excluded from extension templates when using "quarto use template".
*
* Copyright (C) 2020-2025 Posit Software, PBC
*/
import { testQuartoCmd } from "../../test.ts";
import { fileExists, noErrorsOrWarnings, pathDoNotExists } from "../../verify.ts";
import { join } from "../../../src/deno_ral/path.ts";
import { ensureDirSync } from "../../../src/deno_ral/fs.ts";
const tempDir = Deno.makeTempDirSync();
// Create a mock template source with AI config files
const templateSourceDir = join(tempDir, "template-source");
ensureDirSync(templateSourceDir);
Deno.writeTextFileSync(
join(templateSourceDir, "template.qmd"),
"---\ntitle: Template Document\n---\n\nThis is a template document."
);
Deno.writeTextFileSync(
join(templateSourceDir, "CLAUDE.md"),
"# Claude Configuration\n\nThis should be excluded."
);
Deno.writeTextFileSync(
join(templateSourceDir, "AGENTS.md"),
"# Agents Configuration\n\nThis should be excluded."
);
Deno.writeTextFileSync(
join(templateSourceDir, "CLAUDE.local.md"),
"# Claude Local Configuration\n\nThis should be excluded."
);
Deno.writeTextFileSync(
join(templateSourceDir, "AGENTS.local.md"),
"# Agents Local Configuration\n\nThis should be excluded."
);
Deno.writeTextFileSync(
join(templateSourceDir, "README.md"),
"# Template README\n\nThis should also be excluded."
);
const templateFolder = "test-ai-config-template";
const workingDir = join(tempDir, templateFolder);
ensureDirSync(workingDir);
testQuartoCmd(
"use",
["template", templateSourceDir, "--no-prompt"],
[
noErrorsOrWarnings,
fileExists(`${templateFolder}.qmd`), // Template file should be copied and renamed
pathDoNotExists(join(workingDir, "CLAUDE.md")), // CLAUDE.md should be excluded
pathDoNotExists(join(workingDir, "AGENTS.md")), // AGENTS.md should be excluded
pathDoNotExists(join(workingDir, "CLAUDE.local.md")), // CLAUDE.local.md should be excluded
pathDoNotExists(join(workingDir, "AGENTS.local.md")), // AGENTS.local.md should be excluded
pathDoNotExists(join(workingDir, "README.md")), // README.md should also be excluded (sanity check)
],
{
cwd: () => {
return workingDir;
},
teardown: () => {
try {
Deno.removeSync(tempDir, { recursive: true });
} catch {
// Ignore cleanup errors
}
return Promise.resolve();
}
}
);