// hooks/after.ts
import { readFile, rename, unlink, writeFile } from "node:fs/promises";
import { join } from "node:path";

// const.ts
var todoIntro = "Follow the steps below to finish setting up your application.";

// hooks/after.ts
async function cleanupMarkdown(cwd, filename) {
  const content = await readFile(join(cwd, filename), "utf8");
  const trimmed = content.replaceAll(/<!--bati:.*-->/g, "").replaceAll(/\n\n+/g, "\n\n").trimStart();
  await writeFile(join(cwd, filename), trimmed, "utf-8");
  return trimmed;
}
async function renameGitIgnore(cwd) {
  await rename(join(cwd, "gitignore"), join(cwd, ".gitignore"));
}
async function onafter(cwd, _meta) {
  await cleanupMarkdown(cwd, "README.md");
  const content = await cleanupMarkdown(cwd, "TODO.md");
  if (content.trim() === todoIntro) {
    await unlink(join(cwd, "TODO.md"));
  }
  await renameGitIgnore(cwd);
}
export {
  onafter as default
};
