@hey-api/openapi-ts 0.90.7 → 0.90.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/run.cjs CHANGED
@@ -1,65 +1,57 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
 
4
- const require_openApi = require('./openApi-BZ7m5ia5.cjs');
5
- const require_src = require('./src-BkOFTEi8.cjs');
4
+ const require_openApi = require('./openApi-BaGlRfMs.cjs');
5
+ const require_src = require('./src-CO2t0IHm.cjs');
6
6
  let commander = require("commander");
7
7
 
8
8
  //#region package.json
9
- var version = "0.90.7";
9
+ var version = "0.90.9";
10
10
  var bin = { "openapi-ts": "./bin/run.js" };
11
11
 
12
12
  //#endregion
13
- //#region src/cli.ts
14
- const stringToBoolean = (value) => {
15
- if (value === "true") return true;
16
- if (value === "false") return false;
17
- return value;
13
+ //#region src/cli/adapter.ts
14
+ const cliToConfig = (cli) => {
15
+ const config = {};
16
+ if (cli.input) config.input = cli.input;
17
+ if (cli.output) config.output = cli.output;
18
+ if (cli.file) config.configFile = cli.file;
19
+ if (cli.dryRun !== void 0) config.dryRun = cli.dryRun;
20
+ const plugins = [];
21
+ if (cli.plugins instanceof Array && cli.plugins.length > 0) plugins.push(...cli.plugins);
22
+ if (cli.client) plugins.push(cli.client);
23
+ if (plugins.length > 0) config.plugins = plugins;
24
+ if (cli.debug || cli.silent || cli.logs || cli.logFile !== void 0) config.logs = {
25
+ ...cli.logs && { path: cli.logs },
26
+ ...cli.debug && { level: "debug" },
27
+ ...cli.silent && { level: "silent" },
28
+ ...cli.logFile !== void 0 && { file: cli.logFile }
29
+ };
30
+ if (cli.watch !== void 0) if (typeof cli.watch === "string") config.watch = Number.parseInt(cli.watch, 10);
31
+ else config.watch = cli.watch;
32
+ return config;
18
33
  };
19
- const processParams = (obj, booleanKeys) => {
20
- for (const key of booleanKeys) {
21
- const value = obj[key];
22
- if (typeof value === "string") {
23
- const parsedValue = stringToBoolean(value);
24
- delete obj[key];
25
- obj[key] = parsedValue;
26
- }
27
- }
28
- return obj;
29
- };
30
- const runCli = async () => {
31
- const params = new commander.Command().name(Object.keys(bin)[0]).usage("[options]").version(version).option("-c, --client <value>", "HTTP client to generate").option("-d, --debug", "Set log level to debug").option("--dry-run [value]", "Skip writing files to disk?").option("-f, --file [value]", "Path to the config file").option("-i, --input <value>", "OpenAPI specification (path, url, or string content)").option("-l, --logs [value]", "Logs folder").option("-o, --output <value>", "Output folder").option("-p, --plugins [value...]", "List of plugins you'd like to use").option("-s, --silent", "Set log level to silent").option("--no-log-file", "Disable writing a log file. Works like --silent but without suppressing console output").option("-w, --watch [value]", "Regenerate the client when the input file changes?").parse(process.argv).opts();
32
- let userConfig;
34
+
35
+ //#endregion
36
+ //#region src/cli/index.ts
37
+ const binName = Object.keys(bin)[0];
38
+ const program = new commander.Command().name(binName).description("Generate TypeScript code from OpenAPI specifications").version(version);
39
+ program.option("-i, --input <path...>", "OpenAPI specification (path, URL, or string)").option("-o, --output <path...>", "Output folder(s)").option("-c, --client <name>", "HTTP client to generate").option("-p, --plugins [names...]", "Plugins to use").option("-f, --file <path>", "Path to config file").option("-d, --debug", "Enable debug logging").option("-s, --silent", "Suppress all output").option("-l, --logs <path>", "Logs folder path").option("--no-log-file", "Disable log file output").option("--dry-run", "Skip writing files").option("-w, --watch [interval]", "Watch for changes").action(async (options) => {
40
+ if (!(await require_src.createClient(cliToConfig(options)))[0]?.config.input.some((input) => input.watch?.enabled)) process.exit(0);
41
+ });
42
+ async function runCli() {
33
43
  try {
34
- userConfig = processParams(params, ["dryRun", "logFile"]);
35
- if (userConfig.file) {
36
- userConfig.configFile = userConfig.file;
37
- delete userConfig.file;
38
- }
39
- if (params.plugins === true) userConfig.plugins = [];
40
- else if (params.plugins) userConfig.plugins = params.plugins;
41
- else if (userConfig.client) userConfig.plugins = ["@hey-api/typescript", "@hey-api/sdk"];
42
- if (userConfig.client) {
43
- userConfig.plugins.push(userConfig.client);
44
- delete userConfig.client;
44
+ await program.parseAsync(process.argv);
45
+ } catch (error) {
46
+ if (error instanceof commander.CommanderError && "code" in error) {
47
+ if (error.code === "commander.optionMissingArgument") console.error(`\nMissing required argument. Run '${binName} --help' for usage.\n`);
48
+ else if (error.code === "commander.unknownOption") console.error(`\nUnknown option. Run '${binName} --help' for available options.\n`);
49
+ process.exit(error.exitCode);
45
50
  }
46
- userConfig.logs = userConfig.logs ? { path: userConfig.logs } : {};
47
- if (userConfig.debug) {
48
- userConfig.logs.level = "debug";
49
- delete userConfig.debug;
50
- } else if (userConfig.silent) {
51
- userConfig.logs.level = "silent";
52
- delete userConfig.silent;
53
- }
54
- userConfig.logs.file = userConfig.logFile;
55
- delete userConfig.logFile;
56
- if (typeof params.watch === "string") userConfig.watch = Number.parseInt(params.watch, 10);
57
- if (!Object.keys(userConfig.logs).length) delete userConfig.logs;
58
- if (!(await require_src.createClient(userConfig))[0]?.config.input.some((input) => input.watch && input.watch.enabled)) process.exit(0);
59
- } catch {
51
+ console.error("Unexpected error:", error);
60
52
  process.exit(1);
61
53
  }
62
- };
54
+ }
63
55
 
64
56
  //#endregion
65
57
  //#region src/run.ts
package/dist/run.cjs.map CHANGED
@@ -1 +1 @@
1
- {"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":["","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":";;;;;;;;;;;;;;ACOA,MAAM,mBACJ,UACiC;AACjC,KAAI,UAAU,OAAQ,QAAO;AAC7B,KAAI,UAAU,QAAS,QAAO;AAC9B,QAAO;;AAGT,MAAM,iBACJ,KACA,gBACiB;AACjB,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,QAAQ,IAAI;AAClB,MAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,cAAc,gBAAgB,MAAM;AAC1C,UAAO,IAAI;AACX,OAAI,OAAO;;;AAGf,QAAO;;AAGT,MAAa,SAAS,YAA2B;CAC/C,MAAM,SAAS,IAAIA,mBAAS,CACzB,KAAK,OAAO,KAAKC,IAAQ,CAAC,GAAI,CAC9B,MAAM,YAAY,CAClB,QAAQC,QAAY,CACpB,OAAO,wBAAwB,0BAA0B,CACzD,OAAO,eAAe,yBAAyB,CAC/C,OAAO,qBAAqB,8BAA8B,CAC1D,OAAO,sBAAsB,0BAA0B,CACvD,OACC,uBACA,uDACD,CACA,OAAO,sBAAsB,cAAc,CAC3C,OAAO,wBAAwB,gBAAgB,CAC/C,OAAO,4BAA4B,oCAAoC,CACvE,OAAO,gBAAgB,0BAA0B,CACjD,OACC,iBACA,yFACD,CACA,OACC,uBACA,qDACD,CACA,MAAM,QAAQ,KAAK,CACnB,MAAM;CAET,IAAIC;AAEJ,KAAI;AACF,eAAa,cAAc,QAAQ,CAAC,UAAU,UAAU,CAAC;AAEzD,MAAI,WAAW,MAAM;AACnB,cAAW,aAAa,WAAW;AACnC,UAAO,WAAW;;AAGpB,MAAI,OAAO,YAAY,KACrB,YAAW,UAAU,EAAE;WACd,OAAO,QAChB,YAAW,UAAU,OAAO;WACnB,WAAW,OACpB,YAAW,UAAU,CAAC,uBAAuB,eAAe;AAG9D,MAAI,WAAW,QAAQ;AACrB,GAAC,WAAW,QAA0B,KAAK,WAAW,OAAiB;AACvE,UAAO,WAAW;;AAGpB,aAAW,OAAO,WAAW,OACzB,EACE,MAAM,WAAW,MAClB,GACD,EAAE;AAEN,MAAI,WAAW,OAAO;AACpB,GAAC,WAAW,KAAiC,QAAQ;AACrD,UAAO,WAAW;aACT,WAAW,QAAQ;AAC5B,GAAC,WAAW,KAAiC,QAAQ;AACrD,UAAO,WAAW;;AAGpB,EAAC,WAAW,KAAiC,OAAO,WAAW;AAC/D,SAAO,WAAW;AAElB,MAAI,OAAO,OAAO,UAAU,SAC1B,YAAW,QAAQ,OAAO,SAAS,OAAO,OAAO,GAAG;AAGtD,MAAI,CAAC,OAAO,KAAK,WAAW,KAAgC,CAAC,OAC3D,QAAO,WAAW;AAMpB,MACE,EAJc,MAAMC,yBACpB,WACD,EAEU,IAAI,OAAO,MAAM,MACvB,UAAU,MAAM,SAAS,MAAM,MAAM,QACvC,CAED,SAAQ,KAAK,EAAE;SAEX;AACN,UAAQ,KAAK,EAAE;;;;;;ACjHnB,QAAQ"}
1
+ {"version":3,"file":"run.cjs","names":["config: Partial<UserConfig>","plugins: ToArray<UserConfig['plugins']>","pkg.bin","Command","pkg.version","createClient","CommanderError"],"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';\n\nimport type { CliOptions } from './schema';\n\nexport const 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 > 0) {\n plugins.push(...cli.plugins);\n }\n if (cli.client) plugins.push(cli.client);\n if (plugins.length > 0) config.plugins = plugins;\n\n if (cli.debug || cli.silent || cli.logs || cli.logFile !== undefined) {\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 !== undefined && { file: cli.logFile }),\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 { Command, CommanderError } from 'commander';\n\nimport { createClient } from '~/index';\n\nimport pkg from '../../package.json' assert { type: 'json' };\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(pkg.version);\n\nprogram\n .option(\n '-i, --input <path...>',\n 'OpenAPI specification (path, URL, or string)',\n )\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(\n config as Parameters<typeof createClient>[0],\n );\n\n const hasActiveWatch = context[0]?.config.input.some(\n (input) => input.watch?.enabled,\n );\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(\n `\\nMissing required argument. Run '${binName} --help' for usage.\\n`,\n );\n } else if (error.code === 'commander.unknownOption') {\n console.error(\n `\\nUnknown option. Run '${binName} --help' for available options.\\n`,\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":";;;;;;;;;;;;;;ACMA,MAAa,eAAe,QAAyC;CACnE,MAAMA,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,OAAW,QAAO,SAAS,IAAI;CAElD,MAAMC,UAA0C,EAAE;AAClD,KAAI,IAAI,mBAAmB,SAAS,IAAI,QAAQ,SAAS,EACvD,SAAQ,KAAK,GAAG,IAAI,QAAQ;AAE9B,KAAI,IAAI,OAAQ,SAAQ,KAAK,IAAI,OAAO;AACxC,KAAI,QAAQ,SAAS,EAAG,QAAO,UAAU;AAEzC,KAAI,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,OACzD,QAAO,OAAO;EACZ,GAAI,IAAI,QAAQ,EAAE,MAAM,IAAI,MAAM;EAClC,GAAI,IAAI,SAAS,EAAE,OAAO,SAAkB;EAC5C,GAAI,IAAI,UAAU,EAAE,OAAO,UAAmB;EAC9C,GAAI,IAAI,YAAY,UAAa,EAAE,MAAM,IAAI,SAAS;EACvD;AAGH,KAAI,IAAI,UAAU,OAChB,KAAI,OAAO,IAAI,UAAU,SACvB,QAAO,QAAQ,OAAO,SAAS,IAAI,OAAO,GAAG;KAE7C,QAAO,QAAQ,IAAI;AAIvB,QAAO;;;;;AC/BT,MAAM,UAAU,OAAO,KAAKC,IAAQ,CAAC;AAErC,MAAM,UAAU,IAAIC,mBAAS,CAC1B,KAAK,QAAQ,CACb,YAAY,uDAAuD,CACnE,QAAQC,QAAY;AAEvB,QACG,OACC,yBACA,+CACD,CACA,OAAO,0BAA0B,mBAAmB,CACpD,OAAO,uBAAuB,0BAA0B,CACxD,OAAO,4BAA4B,iBAAiB,CACpD,OAAO,qBAAqB,sBAAsB,CAClD,OAAO,eAAe,uBAAuB,CAC7C,OAAO,gBAAgB,sBAAsB,CAC7C,OAAO,qBAAqB,mBAAmB,CAC/C,OAAO,iBAAiB,0BAA0B,CAClD,OAAO,aAAa,qBAAqB,CACzC,OAAO,0BAA0B,oBAAoB,CACrD,OAAO,OAAO,YAAY;AAWzB,KAAI,EARY,MAAMC,yBAFP,YAAY,QAAQ,CAIlC,EAE8B,IAAI,OAAO,MAAM,MAC7C,UAAU,MAAM,OAAO,QACzB,CAGC,SAAQ,KAAK,EAAE;EAEjB;AAEJ,eAAsB,SAAwB;AAC5C,KAAI;AACF,QAAM,QAAQ,WAAW,QAAQ,KAAK;UAC/B,OAAO;AACd,MAAI,iBAAiBC,4BAAkB,UAAU,OAAO;AACtD,OAAI,MAAM,SAAS,kCACjB,SAAQ,MACN,qCAAqC,QAAQ,uBAC9C;YACQ,MAAM,SAAS,0BACxB,SAAQ,MACN,0BAA0B,QAAQ,mCACnC;AAGH,WAAQ,KAAK,MAAM,SAAS;;AAG9B,UAAQ,MAAM,qBAAqB,MAAM;AACzC,UAAQ,KAAK,EAAE;;;;;;AC5DnB,QAAQ"}
package/dist/run.mjs CHANGED
@@ -1,65 +1,57 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
 
4
- import "./openApi-B6J9qPwL.mjs";
5
- import { r as createClient } from "./src-BehyjtZ7.mjs";
6
- import { Command } from "commander";
4
+ import "./openApi-CE_z8tev.mjs";
5
+ import { i as createClient } from "./src-DqFHTOrs.mjs";
6
+ import { Command, CommanderError } from "commander";
7
7
 
8
8
  //#region package.json
9
- var version = "0.90.7";
9
+ var version = "0.90.9";
10
10
  var bin = { "openapi-ts": "./bin/run.js" };
11
11
 
12
12
  //#endregion
13
- //#region src/cli.ts
14
- const stringToBoolean = (value) => {
15
- if (value === "true") return true;
16
- if (value === "false") return false;
17
- return value;
13
+ //#region src/cli/adapter.ts
14
+ const cliToConfig = (cli) => {
15
+ const config = {};
16
+ if (cli.input) config.input = cli.input;
17
+ if (cli.output) config.output = cli.output;
18
+ if (cli.file) config.configFile = cli.file;
19
+ if (cli.dryRun !== void 0) config.dryRun = cli.dryRun;
20
+ const plugins = [];
21
+ if (cli.plugins instanceof Array && cli.plugins.length > 0) plugins.push(...cli.plugins);
22
+ if (cli.client) plugins.push(cli.client);
23
+ if (plugins.length > 0) config.plugins = plugins;
24
+ if (cli.debug || cli.silent || cli.logs || cli.logFile !== void 0) config.logs = {
25
+ ...cli.logs && { path: cli.logs },
26
+ ...cli.debug && { level: "debug" },
27
+ ...cli.silent && { level: "silent" },
28
+ ...cli.logFile !== void 0 && { file: cli.logFile }
29
+ };
30
+ if (cli.watch !== void 0) if (typeof cli.watch === "string") config.watch = Number.parseInt(cli.watch, 10);
31
+ else config.watch = cli.watch;
32
+ return config;
18
33
  };
19
- const processParams = (obj, booleanKeys) => {
20
- for (const key of booleanKeys) {
21
- const value = obj[key];
22
- if (typeof value === "string") {
23
- const parsedValue = stringToBoolean(value);
24
- delete obj[key];
25
- obj[key] = parsedValue;
26
- }
27
- }
28
- return obj;
29
- };
30
- const runCli = async () => {
31
- const params = new Command().name(Object.keys(bin)[0]).usage("[options]").version(version).option("-c, --client <value>", "HTTP client to generate").option("-d, --debug", "Set log level to debug").option("--dry-run [value]", "Skip writing files to disk?").option("-f, --file [value]", "Path to the config file").option("-i, --input <value>", "OpenAPI specification (path, url, or string content)").option("-l, --logs [value]", "Logs folder").option("-o, --output <value>", "Output folder").option("-p, --plugins [value...]", "List of plugins you'd like to use").option("-s, --silent", "Set log level to silent").option("--no-log-file", "Disable writing a log file. Works like --silent but without suppressing console output").option("-w, --watch [value]", "Regenerate the client when the input file changes?").parse(process.argv).opts();
32
- let userConfig;
34
+
35
+ //#endregion
36
+ //#region src/cli/index.ts
37
+ const binName = Object.keys(bin)[0];
38
+ const program = new Command().name(binName).description("Generate TypeScript code from OpenAPI specifications").version(version);
39
+ program.option("-i, --input <path...>", "OpenAPI specification (path, URL, or string)").option("-o, --output <path...>", "Output folder(s)").option("-c, --client <name>", "HTTP client to generate").option("-p, --plugins [names...]", "Plugins to use").option("-f, --file <path>", "Path to config file").option("-d, --debug", "Enable debug logging").option("-s, --silent", "Suppress all output").option("-l, --logs <path>", "Logs folder path").option("--no-log-file", "Disable log file output").option("--dry-run", "Skip writing files").option("-w, --watch [interval]", "Watch for changes").action(async (options) => {
40
+ if (!(await createClient(cliToConfig(options)))[0]?.config.input.some((input) => input.watch?.enabled)) process.exit(0);
41
+ });
42
+ async function runCli() {
33
43
  try {
34
- userConfig = processParams(params, ["dryRun", "logFile"]);
35
- if (userConfig.file) {
36
- userConfig.configFile = userConfig.file;
37
- delete userConfig.file;
38
- }
39
- if (params.plugins === true) userConfig.plugins = [];
40
- else if (params.plugins) userConfig.plugins = params.plugins;
41
- else if (userConfig.client) userConfig.plugins = ["@hey-api/typescript", "@hey-api/sdk"];
42
- if (userConfig.client) {
43
- userConfig.plugins.push(userConfig.client);
44
- delete userConfig.client;
44
+ await program.parseAsync(process.argv);
45
+ } catch (error) {
46
+ if (error instanceof CommanderError && "code" in error) {
47
+ if (error.code === "commander.optionMissingArgument") console.error(`\nMissing required argument. Run '${binName} --help' for usage.\n`);
48
+ else if (error.code === "commander.unknownOption") console.error(`\nUnknown option. Run '${binName} --help' for available options.\n`);
49
+ process.exit(error.exitCode);
45
50
  }
46
- userConfig.logs = userConfig.logs ? { path: userConfig.logs } : {};
47
- if (userConfig.debug) {
48
- userConfig.logs.level = "debug";
49
- delete userConfig.debug;
50
- } else if (userConfig.silent) {
51
- userConfig.logs.level = "silent";
52
- delete userConfig.silent;
53
- }
54
- userConfig.logs.file = userConfig.logFile;
55
- delete userConfig.logFile;
56
- if (typeof params.watch === "string") userConfig.watch = Number.parseInt(params.watch, 10);
57
- if (!Object.keys(userConfig.logs).length) delete userConfig.logs;
58
- if (!(await createClient(userConfig))[0]?.config.input.some((input) => input.watch && input.watch.enabled)) process.exit(0);
59
- } catch {
51
+ console.error("Unexpected error:", error);
60
52
  process.exit(1);
61
53
  }
62
- };
54
+ }
63
55
 
64
56
  //#endregion
65
57
  //#region src/run.ts
package/dist/run.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.mjs","names":["pkg.bin","pkg.version","userConfig: Record<string, unknown>"],"sources":["../package.json","../src/cli.ts","../src/run.ts"],"sourcesContent":["","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":";;;;;;;;;;;;;;ACOA,MAAM,mBACJ,UACiC;AACjC,KAAI,UAAU,OAAQ,QAAO;AAC7B,KAAI,UAAU,QAAS,QAAO;AAC9B,QAAO;;AAGT,MAAM,iBACJ,KACA,gBACiB;AACjB,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,QAAQ,IAAI;AAClB,MAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,cAAc,gBAAgB,MAAM;AAC1C,UAAO,IAAI;AACX,OAAI,OAAO;;;AAGf,QAAO;;AAGT,MAAa,SAAS,YAA2B;CAC/C,MAAM,SAAS,IAAI,SAAS,CACzB,KAAK,OAAO,KAAKA,IAAQ,CAAC,GAAI,CAC9B,MAAM,YAAY,CAClB,QAAQC,QAAY,CACpB,OAAO,wBAAwB,0BAA0B,CACzD,OAAO,eAAe,yBAAyB,CAC/C,OAAO,qBAAqB,8BAA8B,CAC1D,OAAO,sBAAsB,0BAA0B,CACvD,OACC,uBACA,uDACD,CACA,OAAO,sBAAsB,cAAc,CAC3C,OAAO,wBAAwB,gBAAgB,CAC/C,OAAO,4BAA4B,oCAAoC,CACvE,OAAO,gBAAgB,0BAA0B,CACjD,OACC,iBACA,yFACD,CACA,OACC,uBACA,qDACD,CACA,MAAM,QAAQ,KAAK,CACnB,MAAM;CAET,IAAIC;AAEJ,KAAI;AACF,eAAa,cAAc,QAAQ,CAAC,UAAU,UAAU,CAAC;AAEzD,MAAI,WAAW,MAAM;AACnB,cAAW,aAAa,WAAW;AACnC,UAAO,WAAW;;AAGpB,MAAI,OAAO,YAAY,KACrB,YAAW,UAAU,EAAE;WACd,OAAO,QAChB,YAAW,UAAU,OAAO;WACnB,WAAW,OACpB,YAAW,UAAU,CAAC,uBAAuB,eAAe;AAG9D,MAAI,WAAW,QAAQ;AACrB,GAAC,WAAW,QAA0B,KAAK,WAAW,OAAiB;AACvE,UAAO,WAAW;;AAGpB,aAAW,OAAO,WAAW,OACzB,EACE,MAAM,WAAW,MAClB,GACD,EAAE;AAEN,MAAI,WAAW,OAAO;AACpB,GAAC,WAAW,KAAiC,QAAQ;AACrD,UAAO,WAAW;aACT,WAAW,QAAQ;AAC5B,GAAC,WAAW,KAAiC,QAAQ;AACrD,UAAO,WAAW;;AAGpB,EAAC,WAAW,KAAiC,OAAO,WAAW;AAC/D,SAAO,WAAW;AAElB,MAAI,OAAO,OAAO,UAAU,SAC1B,YAAW,QAAQ,OAAO,SAAS,OAAO,OAAO,GAAG;AAGtD,MAAI,CAAC,OAAO,KAAK,WAAW,KAAgC,CAAC,OAC3D,QAAO,WAAW;AAMpB,MACE,EAJc,MAAM,aACpB,WACD,EAEU,IAAI,OAAO,MAAM,MACvB,UAAU,MAAM,SAAS,MAAM,MAAM,QACvC,CAED,SAAQ,KAAK,EAAE;SAEX;AACN,UAAQ,KAAK,EAAE;;;;;;ACjHnB,QAAQ"}
1
+ {"version":3,"file":"run.mjs","names":["config: Partial<UserConfig>","plugins: ToArray<UserConfig['plugins']>","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';\n\nimport type { CliOptions } from './schema';\n\nexport const 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 > 0) {\n plugins.push(...cli.plugins);\n }\n if (cli.client) plugins.push(cli.client);\n if (plugins.length > 0) config.plugins = plugins;\n\n if (cli.debug || cli.silent || cli.logs || cli.logFile !== undefined) {\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 !== undefined && { file: cli.logFile }),\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 { Command, CommanderError } from 'commander';\n\nimport { createClient } from '~/index';\n\nimport pkg from '../../package.json' assert { type: 'json' };\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(pkg.version);\n\nprogram\n .option(\n '-i, --input <path...>',\n 'OpenAPI specification (path, URL, or string)',\n )\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(\n config as Parameters<typeof createClient>[0],\n );\n\n const hasActiveWatch = context[0]?.config.input.some(\n (input) => input.watch?.enabled,\n );\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(\n `\\nMissing required argument. Run '${binName} --help' for usage.\\n`,\n );\n } else if (error.code === 'commander.unknownOption') {\n console.error(\n `\\nUnknown option. Run '${binName} --help' for available options.\\n`,\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":";;;;;;;;;;;;;;ACMA,MAAa,eAAe,QAAyC;CACnE,MAAMA,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,OAAW,QAAO,SAAS,IAAI;CAElD,MAAMC,UAA0C,EAAE;AAClD,KAAI,IAAI,mBAAmB,SAAS,IAAI,QAAQ,SAAS,EACvD,SAAQ,KAAK,GAAG,IAAI,QAAQ;AAE9B,KAAI,IAAI,OAAQ,SAAQ,KAAK,IAAI,OAAO;AACxC,KAAI,QAAQ,SAAS,EAAG,QAAO,UAAU;AAEzC,KAAI,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,OACzD,QAAO,OAAO;EACZ,GAAI,IAAI,QAAQ,EAAE,MAAM,IAAI,MAAM;EAClC,GAAI,IAAI,SAAS,EAAE,OAAO,SAAkB;EAC5C,GAAI,IAAI,UAAU,EAAE,OAAO,UAAmB;EAC9C,GAAI,IAAI,YAAY,UAAa,EAAE,MAAM,IAAI,SAAS;EACvD;AAGH,KAAI,IAAI,UAAU,OAChB,KAAI,OAAO,IAAI,UAAU,SACvB,QAAO,QAAQ,OAAO,SAAS,IAAI,OAAO,GAAG;KAE7C,QAAO,QAAQ,IAAI;AAIvB,QAAO;;;;;AC/BT,MAAM,UAAU,OAAO,KAAKC,IAAQ,CAAC;AAErC,MAAM,UAAU,IAAI,SAAS,CAC1B,KAAK,QAAQ,CACb,YAAY,uDAAuD,CACnE,QAAQC,QAAY;AAEvB,QACG,OACC,yBACA,+CACD,CACA,OAAO,0BAA0B,mBAAmB,CACpD,OAAO,uBAAuB,0BAA0B,CACxD,OAAO,4BAA4B,iBAAiB,CACpD,OAAO,qBAAqB,sBAAsB,CAClD,OAAO,eAAe,uBAAuB,CAC7C,OAAO,gBAAgB,sBAAsB,CAC7C,OAAO,qBAAqB,mBAAmB,CAC/C,OAAO,iBAAiB,0BAA0B,CAClD,OAAO,aAAa,qBAAqB,CACzC,OAAO,0BAA0B,oBAAoB,CACrD,OAAO,OAAO,YAAY;AAWzB,KAAI,EARY,MAAM,aAFP,YAAY,QAAQ,CAIlC,EAE8B,IAAI,OAAO,MAAM,MAC7C,UAAU,MAAM,OAAO,QACzB,CAGC,SAAQ,KAAK,EAAE;EAEjB;AAEJ,eAAsB,SAAwB;AAC5C,KAAI;AACF,QAAM,QAAQ,WAAW,QAAQ,KAAK;UAC/B,OAAO;AACd,MAAI,iBAAiB,kBAAkB,UAAU,OAAO;AACtD,OAAI,MAAM,SAAS,kCACjB,SAAQ,MACN,qCAAqC,QAAQ,uBAC9C;YACQ,MAAM,SAAS,0BACxB,SAAQ,MACN,0BAA0B,QAAQ,mCACnC;AAGH,WAAQ,KAAK,MAAM,SAAS;;AAG9B,UAAQ,MAAM,qBAAqB,MAAM;AACzC,UAAQ,KAAK,EAAE;;;;;;AC5DnB,QAAQ"}
@@ -1,5 +1,5 @@
1
1
 
2
- const require_openApi = require('./openApi-BZ7m5ia5.cjs');
2
+ const require_openApi = require('./openApi-BaGlRfMs.cjs');
3
3
  let _hey_api_codegen_core = require("@hey-api/codegen-core");
4
4
  let ansi_colors = require("ansi-colors");
5
5
  ansi_colors = require_openApi.__toESM(ansi_colors);
@@ -356,152 +356,16 @@ const asciiToLines = (ascii, options) => {
356
356
  maxLineLength
357
357
  };
358
358
  };
359
- function printCliIntro() {
359
+ function printCliIntro(showLogo = false) {
360
360
  const packageJson = require_openApi.loadPackageJson();
361
- const text = asciiToLines(textAscii, { padding: 1 });
362
- for (const line of text.lines) console.log(ansi_colors.default.cyan(line));
361
+ if (showLogo) {
362
+ const text = asciiToLines(textAscii, { padding: 1 });
363
+ for (const line of text.lines) console.log(ansi_colors.default.cyan(line));
364
+ }
363
365
  console.log(ansi_colors.default.gray(`${packageJson.name} v${packageJson.version}`));
364
366
  console.log("");
365
367
  }
366
368
 
367
- //#endregion
368
- //#region src/utils/logger.ts
369
- let loggerCounter = 0;
370
- const nameToId = (name) => `${name}-${loggerCounter++}`;
371
- const idEnd = (id) => `${id}-end`;
372
- const idLength = (id) => `${id}-length`;
373
- const idStart = (id) => `${id}-start`;
374
- const getSeverity = (duration, percentage) => {
375
- if (duration > 200) return {
376
- color: ansi_colors.default.red,
377
- type: "duration"
378
- };
379
- if (percentage > 30) return {
380
- color: ansi_colors.default.red,
381
- type: "percentage"
382
- };
383
- if (duration > 50) return {
384
- color: ansi_colors.default.yellow,
385
- type: "duration"
386
- };
387
- if (percentage > 10) return {
388
- color: ansi_colors.default.yellow,
389
- type: "percentage"
390
- };
391
- };
392
- var Logger = class {
393
- events = [];
394
- end(result) {
395
- let event;
396
- let events = this.events;
397
- for (const index of result.position) {
398
- event = events[index];
399
- if (event?.events) events = event.events;
400
- }
401
- if (event && !event.end) event.end = performance.mark(idEnd(event.id));
402
- }
403
- /**
404
- * Recursively end all unended events in the event tree.
405
- * This ensures all events have end marks before measuring.
406
- */
407
- endAllEvents(events) {
408
- for (const event of events) {
409
- if (!event.end) event.end = performance.mark(idEnd(event.id));
410
- if (event.events.length > 0) this.endAllEvents(event.events);
411
- }
412
- }
413
- report(print = true) {
414
- const firstEvent = this.events[0];
415
- if (!firstEvent) return;
416
- this.endAllEvents(this.events);
417
- const lastEvent = this.events[this.events.length - 1];
418
- const name = "root";
419
- const id = nameToId(name);
420
- try {
421
- const measure = performance.measure(idLength(id), idStart(firstEvent.id), idEnd(lastEvent.id));
422
- if (print) this.reportEvent({
423
- end: lastEvent.end,
424
- events: this.events,
425
- id,
426
- indent: 0,
427
- measure,
428
- name,
429
- start: firstEvent.start
430
- });
431
- return measure;
432
- } catch {
433
- return;
434
- }
435
- }
436
- reportEvent({ indent, ...parent }) {
437
- const color = !indent ? ansi_colors.default.cyan : ansi_colors.default.gray;
438
- const lastIndex = parent.events.length - 1;
439
- parent.events.forEach((event, index) => {
440
- try {
441
- const measure = performance.measure(idLength(event.id), idStart(event.id), idEnd(event.id));
442
- const duration = Math.ceil(measure.duration * 100) / 100;
443
- const percentage = Math.ceil(measure.duration / parent.measure.duration * 100 * 100) / 100;
444
- const severity = indent ? getSeverity(duration, percentage) : void 0;
445
- let durationLabel = `${duration.toFixed(2).padStart(8)}ms`;
446
- if (severity?.type === "duration") durationLabel = severity.color(durationLabel);
447
- const branch = index === lastIndex ? "└─ " : "├─ ";
448
- const prefix = !indent ? "" : "│ ".repeat(indent - 1) + branch;
449
- const maxLength = 38 - prefix.length;
450
- const percentageBranch = !indent ? "" : "↳ ";
451
- let percentageLabel = `${indent ? " ".repeat(indent - 1) + percentageBranch : ""}${percentage.toFixed(2)}%`;
452
- if (severity?.type === "percentage") percentageLabel = severity.color(percentageLabel);
453
- const jobPrefix = ansi_colors.default.gray("[root] ");
454
- console.log(`${jobPrefix}${ansi_colors.default.gray(prefix)}${color(`${event.name.padEnd(maxLength)} ${durationLabel} (${percentageLabel})`)}`);
455
- this.reportEvent({
456
- ...event,
457
- indent: indent + 1,
458
- measure
459
- });
460
- } catch {}
461
- });
462
- }
463
- start(id) {
464
- return performance.mark(idStart(id));
465
- }
466
- storeEvent({ result, ...event }) {
467
- const lastEventIndex = event.events.length - 1;
468
- const lastEvent = event.events[lastEventIndex];
469
- if (lastEvent && !lastEvent.end) {
470
- result.position = [...result.position, lastEventIndex];
471
- this.storeEvent({
472
- ...event,
473
- events: lastEvent.events,
474
- result
475
- });
476
- return;
477
- }
478
- const length = event.events.push({
479
- ...event,
480
- events: []
481
- });
482
- result.position = [...result.position, length - 1];
483
- }
484
- timeEvent(name) {
485
- const id = nameToId(name);
486
- const start = this.start(id);
487
- const event = {
488
- events: this.events,
489
- id,
490
- name,
491
- start
492
- };
493
- const result = { position: [] };
494
- this.storeEvent({
495
- ...event,
496
- result
497
- });
498
- return {
499
- mark: start,
500
- timeEnd: () => this.end(result)
501
- };
502
- }
503
- };
504
-
505
369
  //#endregion
506
370
  //#region src/generate.ts
507
371
  /**
@@ -509,50 +373,50 @@ var Logger = class {
509
373
  *
510
374
  * @param userConfig User provided {@link UserConfig} configuration(s).
511
375
  */
512
- const createClient = async (userConfig, logger = new Logger()) => {
376
+ async function createClient(userConfig, logger = new _hey_api_codegen_core.Logger()) {
513
377
  const resolvedConfig = typeof userConfig === "function" ? await userConfig() : userConfig;
514
378
  const userConfigs = resolvedConfig ? resolvedConfig instanceof Array ? resolvedConfig : [resolvedConfig] : [];
515
379
  let rawLogs = userConfigs.find((config) => require_openApi.getLogs(config).level !== "silent")?.logs;
516
380
  if (typeof rawLogs === "string") rawLogs = require_openApi.getLogs({ logs: rawLogs });
517
- let configs;
381
+ let jobs = [];
518
382
  try {
519
383
  checkNodeVersion();
520
384
  const eventCreateClient = logger.timeEvent("createClient");
521
385
  const eventConfig = logger.timeEvent("config");
522
- configs = await require_openApi.initConfigs({
386
+ const resolved = await require_openApi.resolveJobs({
523
387
  logger,
524
388
  userConfigs
525
389
  });
526
- if (configs.results.some((result$1) => result$1.config.logs.level !== "silent")) printCliIntro();
390
+ const dependencies = resolved.dependencies;
391
+ jobs = resolved.jobs;
392
+ if (jobs.some((job) => job.config.logs.level !== "silent")) printCliIntro();
527
393
  eventConfig.timeEnd();
528
- const allConfigErrors = configs.results.flatMap((result$1) => result$1.errors.map((error) => ({
394
+ const configErrors = jobs.flatMap((job) => job.errors.map((error) => ({
529
395
  error,
530
- jobIndex: result$1.jobIndex
396
+ jobIndex: job.index
531
397
  })));
532
- if (allConfigErrors.length) throw new require_openApi.ConfigValidationError(allConfigErrors);
533
- const result = (await Promise.all(configs.results.map(async (result$1) => {
398
+ if (configErrors.length > 0) throw new require_openApi.ConfigValidationError(configErrors);
399
+ const contexts = (await Promise.all(jobs.map(async (job) => {
534
400
  try {
535
401
  return await createClient$1({
536
- config: result$1.config,
537
- dependencies: configs.dependencies,
538
- jobIndex: result$1.jobIndex,
402
+ config: job.config,
403
+ dependencies,
404
+ jobIndex: job.index,
539
405
  logger
540
406
  });
541
407
  } catch (error) {
542
408
  throw new require_openApi.JobError("", {
543
409
  error,
544
- jobIndex: result$1.jobIndex
410
+ jobIndex: job.index
545
411
  });
546
412
  }
547
- }))).filter((client) => Boolean(client));
413
+ }))).filter((ctx) => ctx !== void 0);
548
414
  eventCreateClient.timeEnd();
549
- const printLogs = configs.results.some((result$1) => result$1.config.logs.level === "debug");
550
- logger.report(printLogs);
551
- return result;
415
+ logger.report(jobs.some((job) => job.config.logs.level === "debug"));
416
+ return contexts;
552
417
  } catch (error) {
553
- const results = configs?.results ?? [];
554
- const logs = results.find((result) => result.config.logs.level !== "silent")?.config.logs ?? results[0]?.config.logs ?? rawLogs;
555
- const dryRun = results.some((result) => result.config.dryRun) ?? userConfigs.some((config) => config.dryRun) ?? false;
418
+ const logs = jobs.find((job) => job.config.logs.level !== "silent")?.config.logs ?? jobs[0]?.config.logs ?? rawLogs;
419
+ const dryRun = jobs.some((job) => job.config.dryRun) ?? userConfigs.some((config) => config.dryRun) ?? false;
556
420
  const logPath = logs?.file && !dryRun ? require_openApi.logCrashReport(error, logs.path ?? "") : void 0;
557
421
  if (!logs || logs.level !== "silent") {
558
422
  require_openApi.printCrashReport({
@@ -561,12 +425,12 @@ const createClient = async (userConfig, logger = new Logger()) => {
561
425
  });
562
426
  if (await require_openApi.shouldReportCrash({
563
427
  error,
564
- isInteractive: results.some((result) => result.config.interactive) ?? userConfigs.some((config) => config.interactive) ?? false
428
+ isInteractive: jobs.some((job) => job.config.interactive) ?? userConfigs.some((config) => config.interactive) ?? false
565
429
  })) await require_openApi.openGitHubIssueWithCrashReport(error);
566
430
  }
567
431
  throw error;
568
432
  }
569
- };
433
+ }
570
434
 
571
435
  //#endregion
572
436
  //#region src/utils/exports.ts
@@ -584,17 +448,13 @@ const utils = {
584
448
  //#region src/index.ts
585
449
  ansi_colors.default.enabled = (0, color_support.default)().hasBasic;
586
450
  /**
587
- * Type helper for openapi-ts.config.ts, returns {@link MaybeArray<UserConfig>} object(s)
451
+ * Type helper for configuration object, returns {@link MaybeArray<UserConfig>} object(s)
588
452
  */
589
- const defineConfig = async (config) => typeof config === "function" ? await config() : config;
453
+ async function defineConfig(config) {
454
+ return typeof config === "function" ? await config() : config;
455
+ }
590
456
 
591
457
  //#endregion
592
- Object.defineProperty(exports, 'Logger', {
593
- enumerable: true,
594
- get: function () {
595
- return Logger;
596
- }
597
- });
598
458
  Object.defineProperty(exports, 'createClient', {
599
459
  enumerable: true,
600
460
  get: function () {
@@ -613,4 +473,4 @@ Object.defineProperty(exports, 'utils', {
613
473
  return utils;
614
474
  }
615
475
  });
616
- //# sourceMappingURL=src-BkOFTEi8.cjs.map
476
+ //# sourceMappingURL=src-CO2t0IHm.cjs.map