Path: blob/main/tests/smoke/use/template-ai-config.test.ts
12921 views
/*1* template-ai-config.test.ts2*3* Verifies that AI assistant configuration files (CLAUDE.md, AGENTS.md)4* are properly excluded from extension templates when using "quarto use template".5*6* Copyright (C) 2020-2025 Posit Software, PBC7*/89import { testQuartoCmd } from "../../test.ts";10import { fileExists, noErrorsOrWarnings, pathDoNotExists } from "../../verify.ts";11import { join } from "../../../src/deno_ral/path.ts";12import { ensureDirSync } from "../../../src/deno_ral/fs.ts";1314const tempDir = Deno.makeTempDirSync();1516// Create a mock template source with AI config files17const templateSourceDir = join(tempDir, "template-source");18ensureDirSync(templateSourceDir);19Deno.writeTextFileSync(20join(templateSourceDir, "template.qmd"),21"---\ntitle: Template Document\n---\n\nThis is a template document."22);23Deno.writeTextFileSync(24join(templateSourceDir, "CLAUDE.md"),25"# Claude Configuration\n\nThis should be excluded."26);27Deno.writeTextFileSync(28join(templateSourceDir, "AGENTS.md"),29"# Agents Configuration\n\nThis should be excluded."30);31Deno.writeTextFileSync(32join(templateSourceDir, "CLAUDE.local.md"),33"# Claude Local Configuration\n\nThis should be excluded."34);35Deno.writeTextFileSync(36join(templateSourceDir, "AGENTS.local.md"),37"# Agents Local Configuration\n\nThis should be excluded."38);39Deno.writeTextFileSync(40join(templateSourceDir, "README.md"),41"# Template README\n\nThis should also be excluded."42);4344const templateFolder = "test-ai-config-template";45const workingDir = join(tempDir, templateFolder);46ensureDirSync(workingDir);4748testQuartoCmd(49"use",50["template", templateSourceDir, "--no-prompt"],51[52noErrorsOrWarnings,53fileExists(`${templateFolder}.qmd`), // Template file should be copied and renamed54pathDoNotExists(join(workingDir, "CLAUDE.md")), // CLAUDE.md should be excluded55pathDoNotExists(join(workingDir, "AGENTS.md")), // AGENTS.md should be excluded56pathDoNotExists(join(workingDir, "CLAUDE.local.md")), // CLAUDE.local.md should be excluded57pathDoNotExists(join(workingDir, "AGENTS.local.md")), // AGENTS.local.md should be excluded58pathDoNotExists(join(workingDir, "README.md")), // README.md should also be excluded (sanity check)59],60{61cwd: () => {62return workingDir;63},64teardown: () => {65try {66Deno.removeSync(tempDir, { recursive: true });67} catch {68// Ignore cleanup errors69}70return Promise.resolve();71}72}73);747576