{"version":3,"sources":["../../src/lib/profiles-dir.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\n/**\n * Name of the directory at the project root where profiling output (CPU\n * profiles and Turbopack traces) is written when profiling is enabled (see the\n * `--experimental-cpu-prof` and `--internal-trace` CLI flags). It is a\n * fixed-name sibling of `distDir`, not configurable.\n *\n * Keep this in sync with `DIST_PROFILES_DIR_NAME` in\n * `crates/next-core/src/next_config.rs`.\n */\nexport const PROFILES_DIR_NAME = '.next-profiles'\n\nconst GITIGNORE_CONTENTS = `# Created automatically by Next.js. Profiling output should not be committed.\n*\n`\n\n/**\n * Create the `.next-profiles` directory under `dir` and return its absolute\n * path. This is the single place that creates the directory — the Rust trace\n * writer relies on it already existing.\n *\n * Also writes a `.gitignore` containing `*` (if one isn't already there) so the\n * potentially large profiling output is excluded from git and gitignore-aware\n * tools (Tailwind, Turborepo, ...) skip the subtree instead of reading it and\n * hanging/OOMing.\n */\nexport function ensureProfilesDir(dir: string): string {\n  const profilesDir = join(dir, PROFILES_DIR_NAME)\n  mkdirSync(profilesDir, { recursive: true })\n  const gitignorePath = join(profilesDir, '.gitignore')\n  if (!existsSync(gitignorePath)) {\n    try {\n      writeFileSync(gitignorePath, GITIGNORE_CONTENTS)\n    } catch {\n      // A missing .gitignore must not abort a profiling run.\n    }\n  }\n  return profilesDir\n}\n"],"names":["PROFILES_DIR_NAME","ensureProfilesDir","GITIGNORE_CONTENTS","dir","profilesDir","join","mkdirSync","recursive","gitignorePath","existsSync","writeFileSync"],"mappings":";;;;;;;;;;;;;;;IAYaA,iBAAiB;eAAjBA;;IAgBGC,iBAAiB;eAAjBA;;;oBA5BqC;sBAChC;AAWd,MAAMD,oBAAoB;AAEjC,MAAME,qBAAqB,CAAC;;AAE5B,CAAC;AAYM,SAASD,kBAAkBE,GAAW;IAC3C,MAAMC,cAAcC,IAAAA,UAAI,EAACF,KAAKH;IAC9BM,IAAAA,aAAS,EAACF,aAAa;QAAEG,WAAW;IAAK;IACzC,MAAMC,gBAAgBH,IAAAA,UAAI,EAACD,aAAa;IACxC,IAAI,CAACK,IAAAA,cAAU,EAACD,gBAAgB;QAC9B,IAAI;YACFE,IAAAA,iBAAa,EAACF,eAAeN;QAC/B,EAAE,OAAM;QACN,uDAAuD;QACzD;IACF;IACA,OAAOE;AACT","ignoreList":[0]}