{"version":3,"file":"run.cjs","names":["Command","pkg.bin","pkg.version","userConfig: Record<string, unknown>","createClient"],"sources":["../package.json","../src/cli.ts","../src/run.ts"],"sourcesContent":["{\n  \"name\": \"@esdmr/hey-api-openapi-ts\",\n  \"version\": \"0.89.1-valibot-all-responses\",\n  \"description\": \"🌀 OpenAPI to TypeScript code generator. Generate API clients, SDKs, validators, and more.\",\n  \"homepage\": \"https://heyapi.dev/\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/esdmr/hey-api-openapi-ts.git#valibot-all-responses\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/esdmr/hey-api-openapi-ts/issues\"\n  },\n  \"license\": \"MIT\",\n  \"author\": {\n    \"email\": \"lubos@heyapi.dev\",\n    \"name\": \"Hey API\",\n    \"url\": \"https://heyapi.dev\"\n  },\n  \"funding\": \"https://github.com/sponsors/hey-api\",\n  \"keywords\": [\n    \"angular\",\n    \"axios\",\n    \"codegen\",\n    \"fetch\",\n    \"generator\",\n    \"http\",\n    \"javascript\",\n    \"json\",\n    \"next\",\n    \"next.js\",\n    \"node\",\n    \"nuxt\",\n    \"ofetch\",\n    \"openapi\",\n    \"rest\",\n    \"swagger\",\n    \"typescript\",\n    \"xhr\",\n    \"yaml\"\n  ],\n  \"type\": \"module\",\n  \"main\": \"./dist/index.cjs\",\n  \"module\": \"./dist/index.mjs\",\n  \"types\": \"./dist/index.d.mts\",\n  \"exports\": {\n    \".\": {\n      \"import\": {\n        \"types\": \"./dist/index.d.mts\",\n        \"default\": \"./dist/index.mjs\"\n      },\n      \"require\": {\n        \"types\": \"./dist/index.d.cts\",\n        \"default\": \"./dist/index.cjs\"\n      }\n    },\n    \"./internal\": {\n      \"import\": {\n        \"types\": \"./dist/internal.d.mts\",\n        \"default\": \"./dist/internal.mjs\"\n      },\n      \"require\": {\n        \"types\": \"./dist/internal.d.cts\",\n        \"default\": \"./dist/internal.cjs\"\n      }\n    },\n    \"./package.json\": \"./package.json\"\n  },\n  \"bin\": {\n    \"openapi-ts\": \"./bin/run.js\"\n  },\n  \"files\": [\n    \"bin\",\n    \"dist\",\n    \"LICENSE.md\",\n    \"README.md\"\n  ],\n  \"scripts\": {\n    \"build\": \"tsdown && pnpm check-exports\",\n    \"check-exports\": \"attw --pack . --profile node16\",\n    \"dev\": \"tsdown --watch\",\n    \"prepublishOnly\": \"pnpm build\",\n    \"test:coverage\": \"vitest run --coverage\",\n    \"test:update\": \"vitest watch --update\",\n    \"test:watch\": \"vitest watch\",\n    \"test\": \"vitest run\",\n    \"typecheck\": \"tsc --noEmit\"\n  },\n  \"engines\": {\n    \"node\": \">=20.19.0\"\n  },\n  \"dependencies\": {\n    \"@hey-api/codegen-core\": \"workspace:^0.4.0\",\n    \"@hey-api/json-schema-ref-parser\": \"1.2.2\",\n    \"ansi-colors\": \"4.1.3\",\n    \"c12\": \"3.3.2\",\n    \"color-support\": \"1.1.3\",\n    \"commander\": \"14.0.2\",\n    \"open\": \"11.0.0\",\n    \"semver\": \"7.7.3\"\n  },\n  \"peerDependencies\": {\n    \"typescript\": \">=5.5.3\"\n  },\n  \"devDependencies\": {\n    \"@angular/common\": \"19.2.17\",\n    \"@angular/compiler\": \"19.2.17\",\n    \"@angular/compiler-cli\": \"19.2.17\",\n    \"@angular/core\": \"19.2.17\",\n    \"@angular/platform-browser\": \"19.2.17\",\n    \"@angular/platform-browser-dynamic\": \"19.2.17\",\n    \"@angular/router\": \"19.2.17\",\n    \"@config/vite-base\": \"workspace:*\",\n    \"@types/bun\": \"1.3.4\",\n    \"@types/cross-spawn\": \"6.0.6\",\n    \"@types/semver\": \"7.7.1\",\n    \"axios\": \"1.13.2\",\n    \"cross-spawn\": \"7.0.6\",\n    \"eslint\": \"9.39.1\",\n    \"ky\": \"1.14.1\",\n    \"nuxt\": \"3.14.1592\",\n    \"ofetch\": \"1.5.1\",\n    \"prettier\": \"3.4.2\",\n    \"rxjs\": \"7.8.2\",\n    \"typescript\": \"5.9.3\",\n    \"vue\": \"3.5.25\",\n    \"yaml\": \"2.8.2\",\n    \"zone.js\": \"0.16.0\"\n  }\n}\n","import type { OptionValues } from 'commander';\nimport { Command } from 'commander';\n\nimport { createClient } from '~/index';\n\nimport pkg from '../package.json' assert { type: 'json' };\n\nconst stringToBoolean = (\n  value: string | undefined,\n): boolean | string | undefined => {\n  if (value === 'true') return true;\n  if (value === 'false') return false;\n  return value;\n};\n\nconst processParams = (\n  obj: OptionValues,\n  booleanKeys: ReadonlyArray<string>,\n): OptionValues => {\n  for (const key of booleanKeys) {\n    const value = obj[key];\n    if (typeof value === 'string') {\n      const parsedValue = stringToBoolean(value);\n      delete obj[key];\n      obj[key] = parsedValue;\n    }\n  }\n  return obj;\n};\n\nexport const runCli = async (): Promise<void> => {\n  const params = new Command()\n    .name(Object.keys(pkg.bin)[0]!)\n    .usage('[options]')\n    .version(pkg.version)\n    .option('-c, --client <value>', 'HTTP client to generate')\n    .option('-d, --debug', 'Set log level to debug')\n    .option('--dry-run [value]', 'Skip writing files to disk?')\n    .option('-f, --file [value]', 'Path to the config file')\n    .option(\n      '-i, --input <value>',\n      'OpenAPI specification (path, url, or string content)',\n    )\n    .option('-l, --logs [value]', 'Logs folder')\n    .option('-o, --output <value>', 'Output folder')\n    .option('-p, --plugins [value...]', \"List of plugins you'd like to use\")\n    .option('-s, --silent', 'Set log level to silent')\n    .option(\n      '--no-log-file',\n      'Disable writing a log file. Works like --silent but without suppressing console output',\n    )\n    .option(\n      '-w, --watch [value]',\n      'Regenerate the client when the input file changes?',\n    )\n    .parse(process.argv)\n    .opts();\n\n  let userConfig: Record<string, unknown>;\n\n  try {\n    userConfig = processParams(params, ['dryRun', 'logFile']);\n\n    if (userConfig.file) {\n      userConfig.configFile = userConfig.file;\n      delete userConfig.file;\n    }\n\n    if (params.plugins === true) {\n      userConfig.plugins = [];\n    } else if (params.plugins) {\n      userConfig.plugins = params.plugins;\n    } else if (userConfig.client) {\n      userConfig.plugins = ['@hey-api/typescript', '@hey-api/sdk'];\n    }\n\n    if (userConfig.client) {\n      (userConfig.plugins as Array<string>).push(userConfig.client as string);\n      delete userConfig.client;\n    }\n\n    userConfig.logs = userConfig.logs\n      ? {\n          path: userConfig.logs,\n        }\n      : {};\n\n    if (userConfig.debug) {\n      (userConfig.logs as Record<string, unknown>).level = 'debug';\n      delete userConfig.debug;\n    } else if (userConfig.silent) {\n      (userConfig.logs as Record<string, unknown>).level = 'silent';\n      delete userConfig.silent;\n    }\n\n    (userConfig.logs as Record<string, unknown>).file = userConfig.logFile;\n    delete userConfig.logFile;\n\n    if (typeof params.watch === 'string') {\n      userConfig.watch = Number.parseInt(params.watch, 10);\n    }\n\n    if (!Object.keys(userConfig.logs as Record<string, unknown>).length) {\n      delete userConfig.logs;\n    }\n\n    const context = await createClient(\n      userConfig as unknown as Required<Parameters<typeof createClient>>[0],\n    );\n    if (\n      !context[0]?.config.input.some(\n        (input) => input.watch && input.watch.enabled,\n      )\n    ) {\n      process.exit(0);\n    }\n  } catch {\n    process.exit(1);\n  }\n};\n","#!/usr/bin/env node\n\nimport { runCli } from '~/cli';\n\nrunCli();\n"],"mappings":";2GAEa,iCAiEJ,CACL,aAAc,eACf,CC9DH,MAAM,EACJ,GAEI,IAAU,OAAe,GACzB,IAAU,QAAgB,GACvB,EAGH,GACJ,EACA,IACiB,CACjB,IAAK,IAAM,KAAO,EAAa,CAC7B,IAAM,EAAQ,EAAI,GAClB,GAAI,OAAO,GAAU,SAAU,CAC7B,IAAM,EAAc,EAAgB,EAAM,CAC1C,OAAO,EAAI,GACX,EAAI,GAAO,GAGf,OAAO,GAGI,EAAS,SAA2B,CAC/C,IAAM,EAAS,IAAIA,EAAAA,SAAS,CACzB,KAAK,OAAO,KAAKC,EAAQ,CAAC,GAAI,CAC9B,MAAM,YAAY,CAClB,QAAQC,EAAY,CACpB,OAAO,uBAAwB,0BAA0B,CACzD,OAAO,cAAe,yBAAyB,CAC/C,OAAO,oBAAqB,8BAA8B,CAC1D,OAAO,qBAAsB,0BAA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