import path from "path";
import fs from "fs";

export function createGitIgnoreFile(appPath: string) {
  const gitIgnorePath = path.join(appPath, ".gitignore");

  const gitIgnoreContent = `
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory
coverage
*.lcov

# TypeScript cache
*.tsbuildinfo

# Dependency directories
node_modules/
jspm_packages/

# dotenv environment variable files
# .env
.env.development.local
.env.test.local
.env.production.local
.env.local

# Next.js build output
.next
out

# ordino specific
allure-report
allure-results
ordino-report
playwright-report
`;

  if (fs.existsSync(gitIgnorePath)) {
    console.log(".gitignore file already exists, skipping creation.");
  } else {
    fs.writeFileSync(gitIgnorePath, gitIgnoreContent.trim(), "utf8");
    console.log(".gitignore file created successfully.");
  }
}