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