{"version":3,"file":"run.mjs","names":["pkg.bin","pkg.version"],"sources":["../package.json","../src/cli/adapter.ts","../src/cli/index.ts","../src/run.ts"],"sourcesContent":["","import type { ToArray } from '@hey-api/types';\n\nimport type { UserConfig } from '../config/types';\nimport type { CliOptions } from './schema';\n\nexport function cliToConfig(cli: CliOptions): Partial<UserConfig> {\n  const config: Partial<UserConfig> = {};\n\n  if (cli.input) config.input = cli.input;\n  if (cli.output) config.output = cli.output;\n  if (cli.file) config.configFile = cli.file;\n  if (cli.dryRun !== undefined) config.dryRun = cli.dryRun;\n\n  const plugins: ToArray<UserConfig['plugins']> = [];\n  if (cli.plugins instanceof Array && cli.plugins.length) {\n    plugins.push(...cli.plugins);\n  }\n  if (cli.client) plugins.push(cli.client);\n  if (plugins.length) config.plugins = plugins;\n\n  if (cli.debug || cli.silent || cli.logs || cli.logFile === false) {\n    config.logs = {\n      ...(cli.logs && { path: cli.logs }),\n      ...(cli.debug && { level: 'debug' as const }),\n      ...(cli.silent && { level: 'silent' as const }),\n      ...(cli.logFile === false && { file: false }),\n    };\n  }\n\n  if (cli.watch !== undefined) {\n    if (typeof cli.watch === 'string') {\n      config.watch = Number.parseInt(cli.watch, 10);\n    } else {\n      config.watch = cli.watch;\n    }\n  }\n\n  return config;\n}\n","import { isEnvironment } from '@hey-api/shared';\nimport { Command, CommanderError } from 'commander';\n\nimport pkg from '../../package.json';\nimport { createClient } from '../index';\nimport { cliToConfig } from './adapter';\n\nconst binName = Object.keys(pkg.bin)[0]!;\n\nconst program = new Command()\n  .name(binName)\n  .description('Generate TypeScript code from OpenAPI specifications')\n  .version(isEnvironment('development') ? '[DEVELOPMENT]' : pkg.version);\n\nprogram\n  .option('-i, --input <path...>', 'OpenAPI specification (path, URL, or string)')\n  .option('-o, --output <path...>', 'Output folder(s)')\n  .option('-c, --client <name>', 'HTTP client to generate')\n  .option('-p, --plugins [names...]', 'Plugins to use')\n  .option('-f, --file <path>', 'Path to config file')\n  .option('-d, --debug', 'Enable debug logging')\n  .option('-s, --silent', 'Suppress all output')\n  .option('-l, --logs <path>', 'Logs folder path')\n  .option('--no-log-file', 'Disable log file output')\n  .option('--dry-run', 'Skip writing files')\n  .option('-w, --watch [interval]', 'Watch for changes')\n  .action(async (options) => {\n    const config = cliToConfig(options);\n\n    const context = await createClient(config as Parameters<typeof createClient>[0]);\n\n    const hasActiveWatch = context[0]?.config.input.some((input) => input.watch?.enabled);\n\n    if (!hasActiveWatch) {\n      process.exit(0);\n    }\n  });\n\nexport async function runCli(): Promise<void> {\n  try {\n    await program.parseAsync(process.argv);\n  } catch (error) {\n    if (error instanceof CommanderError && 'code' in error) {\n      if (error.code === 'commander.optionMissingArgument') {\n        console.error(`\\nMissing required argument. Run '${binName} --help' for usage.\\n`);\n      } else if (error.code === 'commander.unknownOption') {\n        console.error(`\\nUnknown option. Run '${binName} --help' for available options.\\n`);\n      }\n\n      process.exit(error.exitCode);\n    }\n\n    console.error('Unexpected error:', error);\n    process.exit(1);\n  }\n}\n","#!/usr/bin/env node\n\nimport { runCli } from './cli';\n\nrunCli();\n"],"mappings":";;;;;;;;;ACKA,SAAgB,YAAY,KAAsC;CAChE,MAAM,SAA8B,EAAE;AAEtC,KAAI,IAAI,MAAO,QAAO,QAAQ,IAAI;AAClC,KAAI,IAAI,OAAQ,QAAO,SAAS,IAAI;AACpC,KAAI,IAAI,KAAM,QAAO,aAAa,IAAI;AACtC,KAAI,IAAI,WAAW,KAAA,EAAW,QAAO,SAAS,IAAI;CAElD,MAAM,UAA0C,EAAE;AAClD,KAAI,IAAI,mBAAmB,SAAS,IAAI,QAAQ,OAC9C,SAAQ,KAAK,GAAG,IAAI,QAAQ;AAE9B,KAAI,IAAI,OAAQ,SAAQ,KAAK,IAAI,OAAO;AACxC,KAAI,QAAQ,OAAQ,QAAO,UAAU;AAErC,KAAI,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,MACzD,QAAO,OAAO;EACZ,GAAI,IAAI,QAAQ,EAAE,MAAM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