{"version":3,"file":"index.cjs","names":["getConfig","generate"],"sources":["../../src/index.ts"],"sourcesContent":["import { cac } from 'cac'\nimport { getConfig } from '@tanstack/router-generator'\nimport { generate } from './generate'\nimport { watch } from './watch'\n\ndeclare const __TSR_VERSION__: string\n\nmain()\n\nexport function main() {\n  const cli = cac('tsr')\n\n  cli\n    .command('generate', 'Generate the routes for a project')\n    .action(async () => {\n      const config = getConfig()\n      await generate(config, process.cwd())\n    })\n\n  cli\n    .command(\n      'watch',\n      'Continuously watch and generate the routes for a project',\n    )\n    .action(() => {\n      watch(process.cwd())\n    })\n\n  cli.help()\n  cli.version(__TSR_VERSION__)\n\n  try {\n    cli.parse()\n  } catch (err) {\n    // cac throws `CACError` for invalid usage (unknown option, extra args)\n    if (err instanceof Error && err.name === 'CACError') {\n      console.error(err.message)\n      process.exit(1)\n    }\n    throw err\n  }\n\n  if (!cli.matchedCommand && !cli.options.help && !cli.options.version) {\n    // `tsr` and `tsr help` print help; unknown commands also exit with 1\n    if (cli.args.length && cli.args[0] !== 'help') {\n      console.error(`Unknown command: ${cli.args.join(' ')}\\n`)\n      process.exitCode = 1\n    }\n    cli.outputHelp()\n  }\n}\n"],"mappings":";;;;;;AAOA,KAAK;AAEL,SAAgB,OAAO;CACrB,MAAM,OAAA,GAAM,IAAA,IAAA,CAAI,KAAK;CAErB,IACG,QAAQ,YAAY,mCAAmC,CAAC,CACxD,OAAO,YAAY;EAClB,MAAM,UAAA,GAASA,2BAAAA,UAAAA,CAAU;EACzB,MAAMC,iBAAAA,SAAS,QAAQ,QAAQ,IAAI,CAAC;CACtC,CAAC;CAEH,IACG,QACC,SACA,0DACF,CAAC,CACA,aAAa;EACZ,cAAA,MAAM,QAAQ,IAAI,CAAC;CACrB,CAAC;CAEH,IAAI,KAAK;CACT,IAAI,QAAA,UAAuB;CAE3B,IAAI;EACF,IAAI,MAAM;CACZ,SAAS,KAAK;EAEZ,IAAI,eAAe,SAAS,IAAI,SAAS,YAAY;GACnD,QAAQ,MAAM,IAAI,OAAO;GACzB,QAAQ,KAAK,CAAC;EAChB;EACA,MAAM;CACR;CAEA,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,QAAQ,QAAQ,CAAC,IAAI,QAAQ,SAAS;EAEpE,IAAI,IAAI,KAAK,UAAU,IAAI,KAAK,OAAO,QAAQ;GAC7C,QAAQ,MAAM,oBAAoB,IAAI,KAAK,KAAK,GAAG,EAAE,GAAG;GACxD,QAAQ,WAAW;EACrB;EACA,IAAI,WAAW;CACjB;AACF"}