{"version":3,"file":"detect.mjs","names":[],"sources":["../../../../../src/init/frameworkSetup/nextAppRouter/detect.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { exists } from '../../utils/fileSystem';\n\n/** Script extensions probed when locating an App Router convention file. */\nconst SCRIPT_EXTENSIONS = ['tsx', 'jsx', 'ts', 'js'] as const;\n\n/** Location of the Next.js App Router directory within the project. */\nexport type NextAppDirInfo = {\n  /** App Router directory relative to the root, e.g. `src/app` or `app`. */\n  appDir: string;\n  /** `src` when the project uses a `src/` directory, otherwise `''`. */\n  srcDir: string;\n};\n\n/**\n * Detects the Next.js App Router directory, preferring `src/app` over `app`.\n * Returns `null` when neither exists (e.g. a Pages Router project).\n */\nexport const detectNextAppDir = async (\n  rootDir: string\n): Promise<NextAppDirInfo | null> => {\n  if (await exists(rootDir, join('src', 'app'))) {\n    return { appDir: join('src', 'app'), srcDir: 'src' };\n  }\n  if (await exists(rootDir, 'app')) {\n    return { appDir: 'app', srcDir: '' };\n  }\n  return null;\n};\n\n/**\n * Finds an existing App Router convention file (e.g. `layout`, `page`) within\n * `dir`, trying each known script extension. Returns the matching relative path\n * or `null`.\n */\nexport const findAppFile = async (\n  rootDir: string,\n  dir: string,\n  baseName: string\n): Promise<string | null> => {\n  for (const extension of SCRIPT_EXTENSIONS) {\n    const candidate = join(dir, `${baseName}.${extension}`);\n    if (await exists(rootDir, candidate)) {\n      return candidate;\n    }\n  }\n  return null;\n};\n\nexport { isVersionAtLeast } from '../../utils/version';\n"],"mappings":";;;;;;AAIA,MAAM,oBAAoB;CAAC;CAAO;CAAO;CAAM;AAAI;;;;;AAcnD,MAAa,mBAAmB,OAC9B,YACmC;CACnC,IAAI,MAAM,OAAO,SAAS,KAAK,OAAO,KAAK,CAAC,GAC1C,OAAO;EAAE,QAAQ,KAAK,OAAO,KAAK;EAAG,QAAQ;CAAM;CAErD,IAAI,MAAM,OAAO,SAAS,KAAK,GAC7B,OAAO;EAAE,QAAQ;EAAO,QAAQ;CAAG;CAErC,OAAO;AACT;;;;;;AAOA,MAAa,cAAc,OACzB,SACA,KACA,aAC2B;CAC3B,KAAK,MAAM,aAAa,mBAAmB;EACzC,MAAM,YAAY,KAAK,KAAK,GAAG,SAAS,GAAG,WAAW;EACtD,IAAI,MAAM,OAAO,SAAS,SAAS,GACjC,OAAO;CAEX;CACA,OAAO;AACT"}