@ahoo-wang/wow-generator 9.8.0 → 9.9.0

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/README.md CHANGED
@@ -23,7 +23,8 @@ second the generator and TypeScript. The generator's peers (`fetcher`,
23
23
  packages of the first line; `wow-client` has to be on the generator's minor
24
24
  version. Node 22.12 or later is required, and TypeScript 6 or later: CI tests
25
25
  6.0 through the latest 7.x. The command
26
- used to be `fetcher-generator`; that name stays as an alias until v10.
26
+ used to be `fetcher-generator`; that name stays as an alias until v10 and
27
+ prints a deprecation notice to stderr before it runs.
27
28
 
28
29
  Generated clients are decorator classes, so the project that compiles them
29
30
  needs `"experimentalDecorators": true` in its `tsconfig.json`. Released with
package/README.zh-CN.md CHANGED
@@ -21,7 +21,7 @@ pnpm exec wow-generator generate \
21
21
  `fetcher-decorator`、`fetcher-eventstream`、`wow-client`)就是第一行的运行时包;`wow-client`
22
22
  须与生成器的次版本一致。需要 Node 22.12 或更高版本,以及 TypeScript 6 或更高版本:CI 测试
23
23
  6.0 到最新的 7.x。命令原名
24
- `fetcher-generator`,这个名字作为别名保留到 v10。
24
+ `fetcher-generator`,这个名字作为别名保留到 v10,运行前会向 stderr 打印一行弃用提示。
25
25
 
26
26
  生成的客户端是装饰器类,编译它们的项目需要在 `tsconfig.json` 中设置
27
27
  `"experimentalDecorators": true`。随 Wow 9.2.0 发布,与 Wow 同一个 tag、同一个版本号。
@@ -1,4 +1,11 @@
1
1
  import { Command, CommanderError } from 'commander';
2
+ /** The exit codes `generate --help` lists, as the README's table does. */
3
+ export declare const EXIT_CODE_HELP: string;
4
+ /**
5
+ * What the `fetcher-generator` bin prints to stderr before it runs: the name
6
+ * still works, and goes in v10.
7
+ */
8
+ export declare const DEPRECATED_BIN_NOTICE = "fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.";
2
9
  /** Collects the values of an option given more than once, such as `--header`. */
3
10
  export declare function collect(value: string, previous?: string[]): string[];
4
11
  /**
@@ -1,4 +1,11 @@
1
1
  import { Command, CommanderError } from 'commander';
2
+ /** The exit codes `generate --help` lists, as the README's table does. */
3
+ export declare const EXIT_CODE_HELP: string;
4
+ /**
5
+ * What the `fetcher-generator` bin prints to stderr before it runs: the name
6
+ * still works, and goes in v10.
7
+ */
8
+ export declare const DEPRECATED_BIN_NOTICE = "fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.";
2
9
  /** Collects the values of an option given more than once, such as `--header`. */
3
10
  export declare function collect(value: string, previous?: string[]): string[];
4
11
  /**
package/dist/cli.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-BMyiC0tW.cjs");let t=require("path"),n=require("commander");var r=`9.8.0`;function i(e){if(!e)return!1;let t;try{t=new URL(e)}catch{return!0}return/^[a-z]:$/i.test(t.protocol)?!0:t.protocol===`http:`||t.protocol===`https:`}function a(t=[]){let n={};for(let r of t){let t=r.indexOf(`:`),i=t>0?r.slice(0,t).trim():``;if(!i)throw new e.s(`input`,`Invalid --header "${r}": expected "Name: value".`);n[i]=r.slice(t+1).trim()}return n}function o(t){if(t===void 0)return;let n=Number(t);if(!Number.isInteger(n)||n<=0)throw new e.s(`input`,`Invalid --timeout "${t}": expected a positive number of milliseconds.`);return n}function s(t){if(t===void 0||t===`summary`)return`summary`;if(t===`full`)return`full`;throw new e.s(`input`,`Invalid --schema-docs "${t}": expected "summary" or "full".`)}function c(e){return e.verbose?`verbose`:e.quiet?`quiet`:`normal`}function l(t,n,r){if(n instanceof e.s)return t.error(n.message),r&&n.cause!==void 0&&t.error(`Caused by:`,n.cause),n.exitCode;let i=n instanceof Error?n.message:String(n);return t.error(`Code generation failed: ${i}`),r?t.error(``,n):t.error(`Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.`),e.o.internal}async function u(n,u=new e.i({level:c(n)}),d={}){if(!i(n.input))return u.error(`Invalid input "${n.input}": expected a file path or an http(s) URL.`),e.o.input;try{u.debug(`wow-generator v${r}`);let i={...d,inputPath:n.input,outputDir:n.output,configPath:n.config,tsConfigFilePath:n.tsConfigFilePath,headers:a(n.header),timeoutMs:o(n.timeout),schemaDocs:s(n.schemaDocs),logger:u},c=await new e.t(i).generate(),l=c.warnings?`, ${c.warnings} warning${c.warnings===1?``:`s`}`:``,f=c.configPath?` with ${(0,t.relative)(process.cwd(),c.configPath)||c.configPath}`:``;return u.info(`Generated ${c.files.length} files into ${n.output}${f}${l}`),n.strict&&c.warnings>0?(u.error(`--strict: the run logged ${c.warnings} warning${c.warnings===1?``:`s`}.`),e.o.specification):e.o.success}catch(t){return d[e.n]?.aborted?e.o.interrupted:l(u,t,!!n.verbose)}}async function d(t){let n=new AbortController;process.once(`SIGINT`,()=>{console.error(`Generation interrupted by user`),n.abort()}),process.exitCode=await u(t,void 0,{[e.n]:n.signal})}function f(e,t=[]){return[...t,e]}function p(t=n.program){return t.exitOverride(),t.name(`wow-generator`).description(`OpenAPI Specification TypeScript code generator for Wow`).version(r,`-v, --version`),t.command(`generate`).description(`Generate TypeScript code from OpenAPI specification`).requiredOption(`-i, --input <file>`,`Input OpenAPI specification file path or URL (http/https)`).option(`-o, --output <path>`,`Output directory path`,`src/generated`).option(`-c, --config <file>`,`Configuration file path (default: ${e.c})`).option(`-t, --ts-config-file-path <file>`,`TypeScript configuration file path`).option(`-H, --header <header>`,`Request header for an http(s) input or configuration, as "Name: value"; repeatable`,f).option(`--timeout <ms>`,`Milliseconds before fetching an http(s) input is abandoned (default: ${e.r})`).option(`--schema-docs <mode>`,`What model doc comments carry: "summary" (title, description, constraints) or "full" (also the JSON schema)`,`summary`).option(`--strict`,`Exit with code 4 when the run logs a warning`).option(`--verbose`,`Log every step, and the stack trace of a failure`).option(`--quiet`,`Log only warnings and errors`).action(d),t}function m(t){return t.exitCode===0?e.o.success:e.o.input}async function h(e,t=p()){try{e===void 0?await t.parseAsync():await t.parseAsync(e,{from:`user`})}catch(e){if(!(e instanceof n.CommanderError))throw e;process.exitCode=m(e)}}h(),exports.collect=f,exports.runCLI=h,exports.setupCLI=p;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./program-DWjbTSVJ.cjs");e.r(),exports.collect=e.n,exports.runCLI=e.r,exports.setupCLI=e.i;
3
3
  //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","names":["GeneratorError","EXIT_CODES","ConsoleLogger","CodeGenerator","relative","SIGNAL_SEAM","program","DEFAULT_CONFIG_PATH","DEFAULT_HTTP_TIMEOUT_MS","EXIT_CODES","CommanderError","require_codeGenerator","path","commander","VERSION","validateInput","input","url","parseHeaders","parsed","header","headers","separator","name","parseTimeout","timeout","value","parseSchemaDocs","schemaDocs","logLevel","options","reportFailure","error","logger","verbose","message","runGenerate","generatorOptions","seams","result","warnings","config","generateAction","interruption","collect","previous","setupCLI","target","commanderExitCode","runCLI","args"],"sources":["../src/version.ts","../src/cli/runGenerate.ts","../src/cli/program.ts","../src/cli.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Replaced at build time with the `version` of this package's package.json\n// (`define` in vite.config.ts, which Vitest shares), so only the version string\n// reaches dist, not the manifest with its dependencies and workspace ranges.\ndeclare const __WOW_GENERATOR_VERSION__: string;\n\n/** The version of this package, as its package.json named it at build time. */\nexport const VERSION: string = __WOW_GENERATOR_VERSION__;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative } from 'path';\nimport { VERSION } from '../version';\nimport { EXIT_CODES, GeneratorError } from '../api/errors';\nimport { CodeGenerator } from '../pipeline/codeGenerator';\nimport type { Logger, LogLevel } from '../api/logger';\nimport { ConsoleLogger } from '../api/logger';\nimport type { SchemaDocs } from '../api/options';\nimport type { SeamOptions, Seams } from '../pipeline/seams';\nimport { SIGNAL_SEAM } from '../pipeline/seams';\n\n/**\n * Options of the `generate` command, as commander parses them.\n */\nexport interface GenerateCommandOptions {\n input: string;\n output: string;\n config?: string;\n tsConfigFilePath?: string;\n /** `Name: value` request headers for an http(s) input or configuration. */\n header?: string[];\n /** Milliseconds, as typed on the command line. */\n timeout?: string;\n /** `summary` or `full`. */\n schemaDocs?: string;\n /** Exit with a non-zero code when the run logged a warning. */\n strict?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n}\n\n/**\n * Validates the input path or URL.\n *\n * Any file path is accepted here and checked when it is read. A URL must use\n * http or https; its host is not restricted, because the generator runs on\n * the developer's own machine against a document they chose, and fetching an\n * intranet service's `/v3/api-docs` is the common case.\n *\n * @param input - Input path or URL\n * @returns true if valid\n */\nexport function validateInput(input: string): boolean {\n if (!input) return false;\n let url: URL;\n try {\n url = new URL(input);\n } catch {\n // Not a URL: a file path, which parseOpenAPI reads.\n return true;\n }\n // A Windows path such as C:\\spec.json parses as a URL with scheme \"c:\".\n if (/^[a-z]:$/i.test(url.protocol)) return true;\n return url.protocol === 'http:' || url.protocol === 'https:';\n}\n\n/**\n * Parses `Name: value` header arguments.\n *\n * @param headers - The raw `--header` values\n * @returns The headers by name\n * @throws GeneratorError of kind `input` for a value without a name\n */\nexport function parseHeaders(\n headers: readonly string[] = [],\n): Record<string, string> {\n const parsed: Record<string, string> = {};\n for (const header of headers) {\n const separator = header.indexOf(':');\n const name = separator > 0 ? header.slice(0, separator).trim() : '';\n if (!name) {\n throw new GeneratorError(\n 'input',\n `Invalid --header \"${header}\": expected \"Name: value\".`,\n );\n }\n parsed[name] = header.slice(separator + 1).trim();\n }\n return parsed;\n}\n\nfunction parseTimeout(timeout: string | undefined): number | undefined {\n if (timeout === undefined) return undefined;\n const value = Number(timeout);\n if (!Number.isInteger(value) || value <= 0) {\n throw new GeneratorError(\n 'input',\n `Invalid --timeout \"${timeout}\": expected a positive number of milliseconds.`,\n );\n }\n return value;\n}\n\nfunction parseSchemaDocs(schemaDocs: string | undefined): SchemaDocs {\n if (schemaDocs === undefined || schemaDocs === 'summary') return 'summary';\n if (schemaDocs === 'full') return 'full';\n throw new GeneratorError(\n 'input',\n `Invalid --schema-docs \"${schemaDocs}\": expected \"summary\" or \"full\".`,\n );\n}\n\nfunction logLevel(options: GenerateCommandOptions): LogLevel {\n if (options.verbose) return 'verbose';\n if (options.quiet) return 'quiet';\n return 'normal';\n}\n\n/**\n * Reports a failure as one actionable line; the stack and the causes only\n * with `--verbose`.\n *\n * @returns The exit code the failure maps to\n */\nfunction reportFailure(\n logger: Logger,\n error: unknown,\n verbose: boolean,\n): number {\n if (error instanceof GeneratorError) {\n logger.error(error.message);\n if (verbose && error.cause !== undefined) {\n logger.error('Caused by:', error.cause);\n }\n return error.exitCode;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Code generation failed: ${message}`);\n if (verbose) {\n logger.error('', error);\n } else {\n logger.error(\n 'Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.',\n );\n }\n return EXIT_CODES.internal;\n}\n\n/**\n * Runs the `generate` command.\n *\n * @param options - The parsed command options\n * @param logger - Where to report; a console logger at the level the options ask for by default\n * @param seams - What the package hands the generator beyond the options;\n * a run stopped by the {@link SIGNAL_SEAM} exits with\n * {@link EXIT_CODES.interrupted}\n * @returns The exit code: see {@link EXIT_CODES}\n */\nexport async function runGenerate(\n options: GenerateCommandOptions,\n logger: Logger = new ConsoleLogger({ level: logLevel(options) }),\n seams: Seams = {},\n): Promise<number> {\n if (!validateInput(options.input)) {\n logger.error(\n `Invalid input \"${options.input}\": expected a file path or an http(s) URL.`,\n );\n return EXIT_CODES.input;\n }\n try {\n logger.debug(`wow-generator v${VERSION}`);\n const generatorOptions: SeamOptions = {\n ...seams,\n inputPath: options.input,\n outputDir: options.output,\n configPath: options.config,\n tsConfigFilePath: options.tsConfigFilePath,\n headers: parseHeaders(options.header),\n timeoutMs: parseTimeout(options.timeout),\n schemaDocs: parseSchemaDocs(options.schemaDocs),\n logger,\n };\n const result = await new CodeGenerator(generatorOptions).generate();\n const warnings = result.warnings\n ? `, ${result.warnings} warning${result.warnings === 1 ? '' : 's'}`\n : '';\n const config = result.configPath\n ? ` with ${relative(process.cwd(), result.configPath) || result.configPath}`\n : '';\n logger.info(\n `Generated ${result.files.length} files into ${options.output}${config}${warnings}`,\n );\n if (options.strict && result.warnings > 0) {\n logger.error(\n `--strict: the run logged ${result.warnings} warning${result.warnings === 1 ? '' : 's'}.`,\n );\n return EXIT_CODES.specification;\n }\n return EXIT_CODES.success;\n } catch (error) {\n if (seams[SIGNAL_SEAM]?.aborted) return EXIT_CODES.interrupted;\n return reportFailure(logger, error, !!options.verbose);\n }\n}\n\n/**\n * Action handler for the generate command: runs it and sets the process exit\n * code.\n *\n * Ctrl-C stops the run at its next step and exits with\n * {@link EXIT_CODES.interrupted}. A run that has begun writing finishes\n * writing its files, then stops: it removes no stale file and leaves the\n * manifest as the last complete run wrote it, so the manifest never records\n * a run that did not finish. A second Ctrl-C ends the process at once.\n *\n * @param options - Command options\n */\nexport async function generateAction(options: GenerateCommandOptions) {\n const interruption = new AbortController();\n process.once('SIGINT', () => {\n console.error('Generation interrupted by user');\n interruption.abort();\n });\n process.exitCode = await runGenerate(options, undefined, {\n [SIGNAL_SEAM]: interruption.signal,\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Command } from 'commander';\nimport { CommanderError, program } from 'commander';\nimport { VERSION } from '../version';\nimport { DEFAULT_CONFIG_PATH } from '../api/configuration';\nimport { EXIT_CODES } from '../api/errors';\nimport { DEFAULT_HTTP_TIMEOUT_MS } from '../input/resources';\nimport { generateAction } from './runGenerate';\n\n/** Collects the values of an option given more than once, such as `--header`. */\nexport function collect(value: string, previous: string[] = []): string[] {\n return [...previous, value];\n}\n\n/**\n * Sets up the CLI program with all commands and options.\n *\n * Commander does not exit the process: a usage error (a missing required\n * option, an unknown option or command, a missing argument, no command at\n * all) is thrown as a `CommanderError`, which {@link runCLI} maps to an exit\n * code.\n *\n * @param target - The program to set up; commander's global one by default.\n * Settings made on it before this call, such as `configureOutput`, reach the\n * `generate` command too.\n * @returns The configured commander program instance\n */\nexport function setupCLI(target: Command = program): Command {\n // Before `command()`: a subcommand copies the exit override when it is\n // created.\n target.exitOverride();\n // compat(fetcher): package.json also installs this CLI as `fetcher-generator`, the\n // name existing scripts call; drop that bin alias in v10.\n target\n .name('wow-generator')\n .description('OpenAPI Specification TypeScript code generator for Wow')\n .version(VERSION, '-v, --version');\n\n target\n .command('generate')\n .description('Generate TypeScript code from OpenAPI specification')\n .requiredOption(\n '-i, --input <file>',\n 'Input OpenAPI specification file path or URL (http/https)',\n )\n .option('-o, --output <path>', 'Output directory path', 'src/generated')\n // No commander default: an omitted -c falls back to DEFAULT_CONFIG_PATH,\n // which may be absent, while a path the user named has to exist.\n .option(\n '-c, --config <file>',\n `Configuration file path (default: ${DEFAULT_CONFIG_PATH})`,\n )\n .option(\n '-t, --ts-config-file-path <file>',\n 'TypeScript configuration file path',\n )\n .option(\n '-H, --header <header>',\n 'Request header for an http(s) input or configuration, as \"Name: value\"; repeatable',\n collect,\n )\n .option(\n '--timeout <ms>',\n `Milliseconds before fetching an http(s) input is abandoned (default: ${DEFAULT_HTTP_TIMEOUT_MS})`,\n )\n .option(\n '--schema-docs <mode>',\n 'What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)',\n 'summary',\n )\n .option('--strict', 'Exit with code 4 when the run logs a warning')\n .option('--verbose', 'Log every step, and the stack trace of a failure')\n .option('--quiet', 'Log only warnings and errors')\n .action(generateAction);\n\n return target;\n}\n\n/**\n * The exit code of a command line commander stopped at: 0 for `--help`,\n * `help` and `--version`; {@link EXIT_CODES.input} for a usage error, which\n * commander has already reported. A usage error is an invalid command line,\n * the same category as an invalid option value such as `--timeout abc`.\n */\nexport function commanderExitCode(error: CommanderError): number {\n return error.exitCode === 0 ? EXIT_CODES.success : EXIT_CODES.input;\n}\n\n/**\n * Parses the command line and runs the command it names. The `generate`\n * command sets the process exit code itself; a command line commander stops\n * at sets it to {@link commanderExitCode}.\n *\n * @param args - The arguments after the executable and script;\n * `process.argv` by default\n * @param target - The program to run; {@link setupCLI} on commander's global\n * one by default\n */\nexport async function runCLI(\n args?: readonly string[],\n target: Command = setupCLI(),\n): Promise<void> {\n try {\n if (args === undefined) {\n await target.parseAsync();\n } else {\n await target.parseAsync(args, { from: 'user' });\n }\n } catch (error) {\n if (!(error instanceof CommanderError)) throw error;\n process.exitCode = commanderExitCode(error);\n }\n}\n","#!/usr/bin/env node\n\n/**\n * CLI entry point of wow-generator: runs the program `cli/program.ts` sets\n * up on the process's command line.\n */\n\nimport { runCLI } from './cli/program';\n\nexport { collect, runCLI, setupCLI } from './cli/program';\n\nvoid runCLI();\n"],"mappings":";gKAmBA,IAAac,EAAA,QCmCb,SAAgBC,EAAc,EAAwB,CACpD,GAAI,CAACC,EAAO,MAAO,GACnB,IAAIC,EACJ,GAAI,CACF,EAAM,IAAI,IAAID,CAAK,CACrB,MAAQ,CAEN,MAAO,EACT,CAGA,MADI,YAAY,KAAKC,EAAI,QAAQ,EAAU,GACpCA,EAAI,WAAa,SAAWA,EAAI,WAAa,QACtD,CASA,SAAgBC,EACd,EAA6B,CAAC,EACN,CACxB,IAAMC,EAAiC,CAAC,EACxC,IAAK,IAAMC,KAAUC,EAAS,CAC5B,IAAMC,EAAYF,EAAO,QAAQ,GAAG,EAC9BG,EAAOD,EAAY,EAAIF,EAAO,MAAM,EAAGE,CAAS,CAAC,CAAC,KAAK,EAAI,GACjE,GAAI,CAACC,EACH,MAAM,IAAIvB,EAAAA,EACR,QACA,qBAAqBoB,EAAO,2BAC9B,EAEF,EAAOG,GAAQH,EAAO,MAAME,EAAY,CAAC,CAAC,CAAC,KAAK,CAClD,CACA,OAAOH,CACT,CAEA,SAASK,EAAa,EAAiD,CACrE,GAAIC,IAAY,IAAA,GAAW,OAC3B,IAAMC,EAAQ,OAAOD,CAAO,EAC5B,GAAI,CAAC,OAAO,UAAUC,CAAK,GAAKA,GAAS,EACvC,MAAM,IAAI1B,EAAAA,EACR,QACA,sBAAsByB,EAAQ,+CAChC,EAEF,OAAOC,CACT,CAEA,SAASC,EAAgB,EAA4C,CACnE,GAAIC,IAAe,IAAA,IAAaA,IAAe,UAAW,MAAO,UACjE,GAAIA,IAAe,OAAQ,MAAO,OAClC,MAAM,IAAI5B,EAAAA,EACR,QACA,0BAA0B4B,EAAW,iCACvC,CACF,CAEA,SAASC,EAAS,EAA2C,CAG3D,OAFIC,EAAQ,QAAgB,UACxBA,EAAQ,MAAc,QACnB,QACT,CAQA,SAASC,EACP,EACA,EACA,E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,EAEjBK,CACT,CAQA,SAAgBC,EAAkB,EAA+B,CAC/D,OAAOhB,EAAM,WAAa,EAAIvB,EAAAA,EAAW,QAAUA,EAAAA,EAAW,KAChE,CAYA,eAAsBwC,EACpB,EACA,EAAkBH,EAAS,EACZ,CACf,GAAI,CACEI,IAAS,IAAA,GACX,MAAMH,EAAO,WAAW,EAExB,MAAMA,EAAO,WAAWG,EAAM,CAAE,KAAM,MAAO,CAAC,CAElD,OAASlB,EAAO,CACd,GAAI,EAAEA,aAAiBtB,EAAAA,gBAAiB,MAAMsB,EAC9C,QAAQ,SAAWgB,EAAkBhB,CAAK,CAC5C,CACF,CCjHKiB,EAAO"}
1
+ {"version":3,"file":"cli.cjs","names":["runCLI","require_program"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point of wow-generator: runs the program `cli/program.ts` sets\n * up on the process's command line.\n */\n\nimport { runCLI } from './cli/program';\n\nexport { collect, runCLI, setupCLI } from './cli/program';\n\nvoid runCLI();\n"],"mappings":";6GAWKA,EAAAA,EAAO"}
package/dist/cli.js CHANGED
@@ -1,98 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { c as e, i as t, n, o as r, r as i, s as a, t as o } from "./codeGenerator-CsWf0pZy.js";
3
- import { relative as s } from "path";
4
- import { CommanderError as c, program as l } from "commander";
5
- //#region src/version.ts
6
- var u = "9.8.0";
7
- //#endregion
8
- //#region src/cli/runGenerate.ts
9
- function d(e) {
10
- if (!e) return !1;
11
- let t;
12
- try {
13
- t = new URL(e);
14
- } catch {
15
- return !0;
16
- }
17
- return /^[a-z]:$/i.test(t.protocol) ? !0 : t.protocol === "http:" || t.protocol === "https:";
18
- }
19
- function f(e = []) {
20
- let t = {};
21
- for (let n of e) {
22
- let e = n.indexOf(":"), r = e > 0 ? n.slice(0, e).trim() : "";
23
- if (!r) throw new a("input", `Invalid --header "${n}": expected "Name: value".`);
24
- t[r] = n.slice(e + 1).trim();
25
- }
26
- return t;
27
- }
28
- function p(e) {
29
- if (e === void 0) return;
30
- let t = Number(e);
31
- if (!Number.isInteger(t) || t <= 0) throw new a("input", `Invalid --timeout "${e}": expected a positive number of milliseconds.`);
32
- return t;
33
- }
34
- function m(e) {
35
- if (e === void 0 || e === "summary") return "summary";
36
- if (e === "full") return "full";
37
- throw new a("input", `Invalid --schema-docs "${e}": expected "summary" or "full".`);
38
- }
39
- function h(e) {
40
- return e.verbose ? "verbose" : e.quiet ? "quiet" : "normal";
41
- }
42
- function g(e, t, n) {
43
- if (t instanceof a) return e.error(t.message), n && t.cause !== void 0 && e.error("Caused by:", t.cause), t.exitCode;
44
- let i = t instanceof Error ? t.message : String(t);
45
- return e.error(`Code generation failed: ${i}`), n ? e.error("", t) : e.error("Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid."), r.internal;
46
- }
47
- async function _(e, i = new t({ level: h(e) }), a = {}) {
48
- if (!d(e.input)) return i.error(`Invalid input "${e.input}": expected a file path or an http(s) URL.`), r.input;
49
- try {
50
- i.debug(`wow-generator v${u}`);
51
- let t = {
52
- ...a,
53
- inputPath: e.input,
54
- outputDir: e.output,
55
- configPath: e.config,
56
- tsConfigFilePath: e.tsConfigFilePath,
57
- headers: f(e.header),
58
- timeoutMs: p(e.timeout),
59
- schemaDocs: m(e.schemaDocs),
60
- logger: i
61
- }, n = await new o(t).generate(), c = n.warnings ? `, ${n.warnings} warning${n.warnings === 1 ? "" : "s"}` : "", l = n.configPath ? ` with ${s(process.cwd(), n.configPath) || n.configPath}` : "";
62
- return i.info(`Generated ${n.files.length} files into ${e.output}${l}${c}`), e.strict && n.warnings > 0 ? (i.error(`--strict: the run logged ${n.warnings} warning${n.warnings === 1 ? "" : "s"}.`), r.specification) : r.success;
63
- } catch (t) {
64
- return a[n]?.aborted ? r.interrupted : g(i, t, !!e.verbose);
65
- }
66
- }
67
- async function v(e) {
68
- let t = new AbortController();
69
- process.once("SIGINT", () => {
70
- console.error("Generation interrupted by user"), t.abort();
71
- }), process.exitCode = await _(e, void 0, { [n]: t.signal });
72
- }
73
- //#endregion
74
- //#region src/cli/program.ts
75
- function y(e, t = []) {
76
- return [...t, e];
77
- }
78
- function b(t = l) {
79
- return t.exitOverride(), t.name("wow-generator").description("OpenAPI Specification TypeScript code generator for Wow").version(u, "-v, --version"), t.command("generate").description("Generate TypeScript code from OpenAPI specification").requiredOption("-i, --input <file>", "Input OpenAPI specification file path or URL (http/https)").option("-o, --output <path>", "Output directory path", "src/generated").option("-c, --config <file>", `Configuration file path (default: ${e})`).option("-t, --ts-config-file-path <file>", "TypeScript configuration file path").option("-H, --header <header>", "Request header for an http(s) input or configuration, as \"Name: value\"; repeatable", y).option("--timeout <ms>", `Milliseconds before fetching an http(s) input is abandoned (default: ${i})`).option("--schema-docs <mode>", "What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)", "summary").option("--strict", "Exit with code 4 when the run logs a warning").option("--verbose", "Log every step, and the stack trace of a failure").option("--quiet", "Log only warnings and errors").action(v), t;
80
- }
81
- function x(e) {
82
- return e.exitCode === 0 ? r.success : r.input;
83
- }
84
- async function S(e, t = b()) {
85
- try {
86
- e === void 0 ? await t.parseAsync() : await t.parseAsync(e, { from: "user" });
87
- } catch (e) {
88
- if (!(e instanceof c)) throw e;
89
- process.exitCode = x(e);
90
- }
91
- }
92
- //#endregion
2
+ import { i as e, n as t, r as n } from "./program-64WQvLq1.js";
93
3
  //#region src/cli.ts
94
- S();
4
+ n();
95
5
  //#endregion
96
- export { y as collect, S as runCLI, b as setupCLI };
6
+ export { t as collect, n as runCLI, e as setupCLI };
97
7
 
98
8
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["DEFAULT_CONFIG_PATH","ConsoleLogger","EXIT_CODES","DEFAULT_HTTP_TIMEOUT_MS","GeneratorError","CodeGenerator","VERSION","validateInput","input","url","parseHeaders","parsed","header","headers","separator","name","parseTimeout","timeout","value","parseSchemaDocs","schemaDocs","logLevel","options","reportFailure","error","logger","verbose","message","runGenerate","generatorOptions","seams","result","warnings","config","relative","SIGNAL_SEAM","generateAction","interruption","collect","previous","setupCLI","program","target","commanderExitCode","runCLI","args","CommanderError"],"sources":["../src/version.ts","../src/cli/runGenerate.ts","../src/cli/program.ts","../src/cli.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Replaced at build time with the `version` of this package's package.json\n// (`define` in vite.config.ts, which Vitest shares), so only the version string\n// reaches dist, not the manifest with its dependencies and workspace ranges.\ndeclare const __WOW_GENERATOR_VERSION__: string;\n\n/** The version of this package, as its package.json named it at build time. */\nexport const VERSION: string = __WOW_GENERATOR_VERSION__;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative } from 'path';\nimport { VERSION } from '../version';\nimport { EXIT_CODES, GeneratorError } from '../api/errors';\nimport { CodeGenerator } from '../pipeline/codeGenerator';\nimport type { Logger, LogLevel } from '../api/logger';\nimport { ConsoleLogger } from '../api/logger';\nimport type { SchemaDocs } from '../api/options';\nimport type { SeamOptions, Seams } from '../pipeline/seams';\nimport { SIGNAL_SEAM } from '../pipeline/seams';\n\n/**\n * Options of the `generate` command, as commander parses them.\n */\nexport interface GenerateCommandOptions {\n input: string;\n output: string;\n config?: string;\n tsConfigFilePath?: string;\n /** `Name: value` request headers for an http(s) input or configuration. */\n header?: string[];\n /** Milliseconds, as typed on the command line. */\n timeout?: string;\n /** `summary` or `full`. */\n schemaDocs?: string;\n /** Exit with a non-zero code when the run logged a warning. */\n strict?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n}\n\n/**\n * Validates the input path or URL.\n *\n * Any file path is accepted here and checked when it is read. A URL must use\n * http or https; its host is not restricted, because the generator runs on\n * the developer's own machine against a document they chose, and fetching an\n * intranet service's `/v3/api-docs` is the common case.\n *\n * @param input - Input path or URL\n * @returns true if valid\n */\nexport function validateInput(input: string): boolean {\n if (!input) return false;\n let url: URL;\n try {\n url = new URL(input);\n } catch {\n // Not a URL: a file path, which parseOpenAPI reads.\n return true;\n }\n // A Windows path such as C:\\spec.json parses as a URL with scheme \"c:\".\n if (/^[a-z]:$/i.test(url.protocol)) return true;\n return url.protocol === 'http:' || url.protocol === 'https:';\n}\n\n/**\n * Parses `Name: value` header arguments.\n *\n * @param headers - The raw `--header` values\n * @returns The headers by name\n * @throws GeneratorError of kind `input` for a value without a name\n */\nexport function parseHeaders(\n headers: readonly string[] = [],\n): Record<string, string> {\n const parsed: Record<string, string> = {};\n for (const header of headers) {\n const separator = header.indexOf(':');\n const name = separator > 0 ? header.slice(0, separator).trim() : '';\n if (!name) {\n throw new GeneratorError(\n 'input',\n `Invalid --header \"${header}\": expected \"Name: value\".`,\n );\n }\n parsed[name] = header.slice(separator + 1).trim();\n }\n return parsed;\n}\n\nfunction parseTimeout(timeout: string | undefined): number | undefined {\n if (timeout === undefined) return undefined;\n const value = Number(timeout);\n if (!Number.isInteger(value) || value <= 0) {\n throw new GeneratorError(\n 'input',\n `Invalid --timeout \"${timeout}\": expected a positive number of milliseconds.`,\n );\n }\n return value;\n}\n\nfunction parseSchemaDocs(schemaDocs: string | undefined): SchemaDocs {\n if (schemaDocs === undefined || schemaDocs === 'summary') return 'summary';\n if (schemaDocs === 'full') return 'full';\n throw new GeneratorError(\n 'input',\n `Invalid --schema-docs \"${schemaDocs}\": expected \"summary\" or \"full\".`,\n );\n}\n\nfunction logLevel(options: GenerateCommandOptions): LogLevel {\n if (options.verbose) return 'verbose';\n if (options.quiet) return 'quiet';\n return 'normal';\n}\n\n/**\n * Reports a failure as one actionable line; the stack and the causes only\n * with `--verbose`.\n *\n * @returns The exit code the failure maps to\n */\nfunction reportFailure(\n logger: Logger,\n error: unknown,\n verbose: boolean,\n): number {\n if (error instanceof GeneratorError) {\n logger.error(error.message);\n if (verbose && error.cause !== undefined) {\n logger.error('Caused by:', error.cause);\n }\n return error.exitCode;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Code generation failed: ${message}`);\n if (verbose) {\n logger.error('', error);\n } else {\n logger.error(\n 'Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.',\n );\n }\n return EXIT_CODES.internal;\n}\n\n/**\n * Runs the `generate` command.\n *\n * @param options - The parsed command options\n * @param logger - Where to report; a console logger at the level the options ask for by default\n * @param seams - What the package hands the generator beyond the options;\n * a run stopped by the {@link SIGNAL_SEAM} exits with\n * {@link EXIT_CODES.interrupted}\n * @returns The exit code: see {@link EXIT_CODES}\n */\nexport async function runGenerate(\n options: GenerateCommandOptions,\n logger: Logger = new ConsoleLogger({ level: logLevel(options) }),\n seams: Seams = {},\n): Promise<number> {\n if (!validateInput(options.input)) {\n logger.error(\n `Invalid input \"${options.input}\": expected a file path or an http(s) URL.`,\n );\n return EXIT_CODES.input;\n }\n try {\n logger.debug(`wow-generator v${VERSION}`);\n const generatorOptions: SeamOptions = {\n ...seams,\n inputPath: options.input,\n outputDir: options.output,\n configPath: options.config,\n tsConfigFilePath: options.tsConfigFilePath,\n headers: parseHeaders(options.header),\n timeoutMs: parseTimeout(options.timeout),\n schemaDocs: parseSchemaDocs(options.schemaDocs),\n logger,\n };\n const result = await new CodeGenerator(generatorOptions).generate();\n const warnings = result.warnings\n ? `, ${result.warnings} warning${result.warnings === 1 ? '' : 's'}`\n : '';\n const config = result.configPath\n ? ` with ${relative(process.cwd(), result.configPath) || result.configPath}`\n : '';\n logger.info(\n `Generated ${result.files.length} files into ${options.output}${config}${warnings}`,\n );\n if (options.strict && result.warnings > 0) {\n logger.error(\n `--strict: the run logged ${result.warnings} warning${result.warnings === 1 ? '' : 's'}.`,\n );\n return EXIT_CODES.specification;\n }\n return EXIT_CODES.success;\n } catch (error) {\n if (seams[SIGNAL_SEAM]?.aborted) return EXIT_CODES.interrupted;\n return reportFailure(logger, error, !!options.verbose);\n }\n}\n\n/**\n * Action handler for the generate command: runs it and sets the process exit\n * code.\n *\n * Ctrl-C stops the run at its next step and exits with\n * {@link EXIT_CODES.interrupted}. A run that has begun writing finishes\n * writing its files, then stops: it removes no stale file and leaves the\n * manifest as the last complete run wrote it, so the manifest never records\n * a run that did not finish. A second Ctrl-C ends the process at once.\n *\n * @param options - Command options\n */\nexport async function generateAction(options: GenerateCommandOptions) {\n const interruption = new AbortController();\n process.once('SIGINT', () => {\n console.error('Generation interrupted by user');\n interruption.abort();\n });\n process.exitCode = await runGenerate(options, undefined, {\n [SIGNAL_SEAM]: interruption.signal,\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Command } from 'commander';\nimport { CommanderError, program } from 'commander';\nimport { VERSION } from '../version';\nimport { DEFAULT_CONFIG_PATH } from '../api/configuration';\nimport { EXIT_CODES } from '../api/errors';\nimport { DEFAULT_HTTP_TIMEOUT_MS } from '../input/resources';\nimport { generateAction } from './runGenerate';\n\n/** Collects the values of an option given more than once, such as `--header`. */\nexport function collect(value: string, previous: string[] = []): string[] {\n return [...previous, value];\n}\n\n/**\n * Sets up the CLI program with all commands and options.\n *\n * Commander does not exit the process: a usage error (a missing required\n * option, an unknown option or command, a missing argument, no command at\n * all) is thrown as a `CommanderError`, which {@link runCLI} maps to an exit\n * code.\n *\n * @param target - The program to set up; commander's global one by default.\n * Settings made on it before this call, such as `configureOutput`, reach the\n * `generate` command too.\n * @returns The configured commander program instance\n */\nexport function setupCLI(target: Command = program): Command {\n // Before `command()`: a subcommand copies the exit override when it is\n // created.\n target.exitOverride();\n // compat(fetcher): package.json also installs this CLI as `fetcher-generator`, the\n // name existing scripts call; drop that bin alias in v10.\n target\n .name('wow-generator')\n .description('OpenAPI Specification TypeScript code generator for Wow')\n .version(VERSION, '-v, --version');\n\n target\n .command('generate')\n .description('Generate TypeScript code from OpenAPI specification')\n .requiredOption(\n '-i, --input <file>',\n 'Input OpenAPI specification file path or URL (http/https)',\n )\n .option('-o, --output <path>', 'Output directory path', 'src/generated')\n // No commander default: an omitted -c falls back to DEFAULT_CONFIG_PATH,\n // which may be absent, while a path the user named has to exist.\n .option(\n '-c, --config <file>',\n `Configuration file path (default: ${DEFAULT_CONFIG_PATH})`,\n )\n .option(\n '-t, --ts-config-file-path <file>',\n 'TypeScript configuration file path',\n )\n .option(\n '-H, --header <header>',\n 'Request header for an http(s) input or configuration, as \"Name: value\"; repeatable',\n collect,\n )\n .option(\n '--timeout <ms>',\n `Milliseconds before fetching an http(s) input is abandoned (default: ${DEFAULT_HTTP_TIMEOUT_MS})`,\n )\n .option(\n '--schema-docs <mode>',\n 'What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)',\n 'summary',\n )\n .option('--strict', 'Exit with code 4 when the run logs a warning')\n .option('--verbose', 'Log every step, and the stack trace of a failure')\n .option('--quiet', 'Log only warnings and errors')\n .action(generateAction);\n\n return target;\n}\n\n/**\n * The exit code of a command line commander stopped at: 0 for `--help`,\n * `help` and `--version`; {@link EXIT_CODES.input} for a usage error, which\n * commander has already reported. A usage error is an invalid command line,\n * the same category as an invalid option value such as `--timeout abc`.\n */\nexport function commanderExitCode(error: CommanderError): number {\n return error.exitCode === 0 ? EXIT_CODES.success : EXIT_CODES.input;\n}\n\n/**\n * Parses the command line and runs the command it names. The `generate`\n * command sets the process exit code itself; a command line commander stops\n * at sets it to {@link commanderExitCode}.\n *\n * @param args - The arguments after the executable and script;\n * `process.argv` by default\n * @param target - The program to run; {@link setupCLI} on commander's global\n * one by default\n */\nexport async function runCLI(\n args?: readonly string[],\n target: Command = setupCLI(),\n): Promise<void> {\n try {\n if (args === undefined) {\n await target.parseAsync();\n } else {\n await target.parseAsync(args, { from: 'user' });\n }\n } catch (error) {\n if (!(error instanceof CommanderError)) throw error;\n process.exitCode = commanderExitCode(error);\n }\n}\n","#!/usr/bin/env node\n\n/**\n * CLI entry point of wow-generator: runs the program `cli/program.ts` sets\n * up on the process's command line.\n */\n\nimport { runCLI } from './cli/program';\n\nexport { collect, runCLI, setupCLI } from './cli/program';\n\nvoid runCLI();\n"],"mappings":";;;;;AAmBA,IAAaM,IAAA;;;ACmCb,SAAgBC,EAAc,GAAwB;CACpD,IAAI,CAACC,GAAO,OAAO;CACnB,IAAIC;CACJ,IAAI;EACF,IAAM,IAAI,IAAID,CAAK;CACrB,QAAQ;EAEN,OAAO;CACT;CAGA,OADI,YAAY,KAAKC,EAAI,QAAQ,IAAU,KACpCA,EAAI,aAAa,WAAWA,EAAI,aAAa;AACtD;AASA,SAAgBC,EACd,IAA6B,CAAC,GACN;CACxB,IAAMC,IAAiC,CAAC;CACxC,KAAK,IAAMC,KAAUC,GAAS;EAC5B,IAAMC,IAAYF,EAAO,QAAQ,GA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xE,OAAO,CAAC,GAAGC,GAAUrB,CAAK;AAC5B;AAeA,SAAgBsB,EAAS,IAAkBC,GAAkB;CAgD3D,OA7CAC,EAAO,aAAa,GAGpBA,EACG,KAAK,eAAe,CAAC,CACrB,YAAY,yDAAyD,CAAC,CACtE,QAAQpC,GAAS,eAAe,GAEnCoC,EACG,QAAQ,UAAU,CAAC,CACnB,YAAY,qDAAqD,CAAC,CAClE,eACC,sBACA,2DACF,CAAC,CACA,OAAO,uBAAuB,yBAAyB,eAAe,CAAC,CAGvE,OACC,uBACA,qCAAqC1C,EAAoB,EAC3D,CAAC,CACA,OACC,oCACA,oCACF,CAAC,CACA,OACC,yBACA,wFACAsC,CACF,CAAC,CACA,OACC,kBACA,wEAAwEnC,EAAwB,EAClG,CAAC,CACA,OACC,wBACA,mHACA,SACF,CAAC,CACA,OAAO,YAAY,8CAA8C,CAAC,CAClE,OAAO,aAAa,kDAAkD,CAAC,CACvE,OAAO,WAAW,8BAA8B,CAAC,CACjD,OAAOiC,CAAc,GAEjBM;AACT;AAQA,SAAgBC,EAAkB,GAA+B;CAC/D,OAAOnB,EAAM,aAAa,IAAItB,EAAW,UAAUA,EAAW;AAChE;AAYA,eAAsB0C,EACpB,GACA,IAAkBJ,EAAS,GACZ;CACf,IAAI;EACF,AAAIK,MAAS,KAAA,IACX,MAAMH,EAAO,WAAW,IAExB,MAAMA,EAAO,WAAWG,GAAM,EAAE,MAAM,OAAO,CAAC;CAElD,SAASrB,GAAO;EACd,IAAI,EAAEA,aAAiBsB,IAAiB,MAAMtB;EAC9C,QAAQ,WAAWmB,EAAkBnB,CAAK;CAC5C;AACF;;;ACjHKoB,EAAO"}
1
+ {"version":3,"file":"cli.js","names":["setupCLI","collect","runCLI"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point of wow-generator: runs the program `cli/program.ts` sets\n * up on the process's command line.\n */\n\nimport { runCLI } from './cli/program';\n\nexport { collect, runCLI, setupCLI } from './cli/program';\n\nvoid runCLI();\n"],"mappings":";;;AAWKE,EAAO"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ const e=require("./program-DWjbTSVJ.cjs");process.stderr.write(`${e.t}\n`),e.r();
3
+ //# sourceMappingURL=fetcherGeneratorCli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcherGeneratorCli.cjs","names":["DEPRECATED_BIN_NOTICE","runCLI","require_program"],"sources":["../src/fetcherGeneratorCli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It\n * says on stderr that the name is deprecated, then runs as `wow-generator`;\n * stdout stays the same, so `fetcher-generator --version` still prints only\n * the version.\n */\n\nimport { DEPRECATED_BIN_NOTICE, runCLI } from './cli/program';\n\n// compat(fetcher): the `fetcher-generator` bin of package.json; delete this\n// file and that bin entry in v10.\nprocess.stderr.write(`${DEPRECATED_BIN_NOTICE}\\n`);\nvoid runCLI();\n"],"mappings":";0CAaA,QAAQ,OAAO,MAAM,GAAGA,EAAAA,EAAsB,GAAG,EAC5CC,EAAAA,EAAO"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It
4
+ * says on stderr that the name is deprecated, then runs as `wow-generator`;
5
+ * stdout stays the same, so `fetcher-generator --version` still prints only
6
+ * the version.
7
+ */
8
+ export {};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It
4
+ * says on stderr that the name is deprecated, then runs as `wow-generator`;
5
+ * stdout stays the same, so `fetcher-generator --version` still prints only
6
+ * the version.
7
+ */
8
+ export {};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { r as e, t } from "./program-64WQvLq1.js";
3
+ process.stderr.write(`${t}\n`), e();
4
+ //#endregion
5
+
6
+ //# sourceMappingURL=fetcherGeneratorCli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcherGeneratorCli.js","names":["runCLI","DEPRECATED_BIN_NOTICE"],"sources":["../src/fetcherGeneratorCli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It\n * says on stderr that the name is deprecated, then runs as `wow-generator`;\n * stdout stays the same, so `fetcher-generator --version` still prints only\n * the version.\n */\n\nimport { DEPRECATED_BIN_NOTICE, runCLI } from './cli/program';\n\n// compat(fetcher): the `fetcher-generator` bin of package.json; delete this\n// file and that bin entry in v10.\nprocess.stderr.write(`${DEPRECATED_BIN_NOTICE}\\n`);\nvoid runCLI();\n"],"mappings":";;AAaA,QAAQ,OAAO,MAAM,GAAGC,EAAsB,GAAG,GAC5CD,EAAO"}
package/dist/index.d.cts CHANGED
@@ -4,5 +4,5 @@ export type { GeneratorErrorKind } from './api/errors.cjs';
4
4
  export { EXIT_CODES, GeneratorError } from './api/errors.cjs';
5
5
  export type { ConsoleLoggerOptions, LogLevel, Logger } from './api/logger.cjs';
6
6
  export { ConsoleLogger, SilentLogger } from './api/logger.cjs';
7
- export type { GenerationResult, GeneratorOptions } from './api/options.cjs';
7
+ export type { GenerationResult, GeneratorOptions, SchemaDocs, } from './api/options.cjs';
8
8
  export { CodeGenerator } from './pipeline/codeGenerator.cjs';
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export type { GeneratorErrorKind } from './api/errors.js';
4
4
  export { EXIT_CODES, GeneratorError } from './api/errors.js';
5
5
  export type { ConsoleLoggerOptions, LogLevel, Logger } from './api/logger.js';
6
6
  export { ConsoleLogger, SilentLogger } from './api/logger.js';
7
- export type { GenerationResult, GeneratorOptions } from './api/options.js';
7
+ export type { GenerationResult, GeneratorOptions, SchemaDocs, } from './api/options.js';
8
8
  export { CodeGenerator } from './pipeline/codeGenerator.js';
@@ -0,0 +1,103 @@
1
+ import { c as e, i as t, n, o as r, r as i, s as a, t as o } from "./codeGenerator-CsWf0pZy.js";
2
+ import { relative as s } from "path";
3
+ import { CommanderError as c, program as l } from "commander";
4
+ //#region src/version.ts
5
+ var u = "9.9.0";
6
+ //#endregion
7
+ //#region src/cli/runGenerate.ts
8
+ function d(e) {
9
+ if (!e) return !1;
10
+ let t;
11
+ try {
12
+ t = new URL(e);
13
+ } catch {
14
+ return !0;
15
+ }
16
+ return /^[a-z]:$/i.test(t.protocol) ? !0 : t.protocol === "http:" || t.protocol === "https:";
17
+ }
18
+ function f(e = []) {
19
+ let t = {};
20
+ for (let n of e) {
21
+ let e = n.indexOf(":"), r = e > 0 ? n.slice(0, e).trim() : "";
22
+ if (!r) throw new a("input", `Invalid --header "${n}": expected "Name: value".`);
23
+ t[r] = n.slice(e + 1).trim();
24
+ }
25
+ return t;
26
+ }
27
+ function p(e) {
28
+ if (e === void 0) return;
29
+ let t = Number(e);
30
+ if (!Number.isInteger(t) || t <= 0) throw new a("input", `Invalid --timeout "${e}": expected a positive number of milliseconds.`);
31
+ return t;
32
+ }
33
+ function m(e) {
34
+ if (e === void 0 || e === "summary") return "summary";
35
+ if (e === "full") return "full";
36
+ throw new a("input", `Invalid --schema-docs "${e}": expected "summary" or "full".`);
37
+ }
38
+ function h(e) {
39
+ return e.verbose ? "verbose" : e.quiet ? "quiet" : "normal";
40
+ }
41
+ function g(e, t, n) {
42
+ if (t instanceof a) return e.error(t.message), n && t.cause !== void 0 && e.error("Caused by:", t.cause), t.exitCode;
43
+ let i = t instanceof Error ? t.message : String(t);
44
+ return e.error(`Code generation failed: ${i}`), n ? e.error("", t) : e.error("Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid."), r.internal;
45
+ }
46
+ async function _(e, i = new t({ level: h(e) }), a = {}) {
47
+ if (!d(e.input)) return i.error(`Invalid input "${e.input}": expected a file path or an http(s) URL.`), r.input;
48
+ try {
49
+ i.debug(`wow-generator v${u}`);
50
+ let t = {
51
+ ...a,
52
+ inputPath: e.input,
53
+ outputDir: e.output,
54
+ configPath: e.config,
55
+ tsConfigFilePath: e.tsConfigFilePath,
56
+ headers: f(e.header),
57
+ timeoutMs: p(e.timeout),
58
+ schemaDocs: m(e.schemaDocs),
59
+ logger: i
60
+ }, n = await new o(t).generate(), c = n.warnings ? `, ${n.warnings} warning${n.warnings === 1 ? "" : "s"}` : "", l = n.configPath ? ` with ${s(process.cwd(), n.configPath) || n.configPath}` : "";
61
+ return i.info(`Generated ${n.files.length} files into ${e.output}${l}${c}`), e.strict && n.warnings > 0 ? (i.error(`--strict: the run logged ${n.warnings} warning${n.warnings === 1 ? "" : "s"}.`), r.specification) : r.success;
62
+ } catch (t) {
63
+ return a[n]?.aborted ? r.interrupted : g(i, t, !!e.verbose);
64
+ }
65
+ }
66
+ async function v(e) {
67
+ let t = new AbortController();
68
+ process.once("SIGINT", () => {
69
+ console.error("Generation interrupted by user"), t.abort();
70
+ }), process.exitCode = await _(e, void 0, { [n]: t.signal });
71
+ }
72
+ //#endregion
73
+ //#region src/cli/program.ts
74
+ var y = `
75
+ Exit codes:
76
+ ${r.success} generated; or --help, help or --version printed
77
+ ${r.internal} internal error; rerun with --verbose for the stack trace
78
+ ${r.input} input or usage: unreadable, unfetchable or not OpenAPI 3.x; an invalid option
79
+ ${r.configuration} configuration: cannot be read, parsed or validated
80
+ ${r.specification} specification: cannot be generated, or --strict and the run had warnings
81
+ ${r.output} output: the manifest, a path outside the output, or a failed write
82
+ ${r.interrupted} interrupted (Ctrl-C)`, b = "fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.";
83
+ function x(e, t = []) {
84
+ return [...t, e];
85
+ }
86
+ function S(t = l) {
87
+ return t.exitOverride(), t.name("wow-generator").description("OpenAPI Specification TypeScript code generator for Wow").version(u, "-v, --version"), t.command("generate").description("Generate TypeScript code from OpenAPI specification").requiredOption("-i, --input <file>", "Input OpenAPI specification file path or URL (http/https)").option("-o, --output <path>", "Output directory path", "src/generated").option("-c, --config <file>", `Configuration file path (default: ${e})`).option("-t, --ts-config-file-path <file>", "TypeScript configuration file path").option("-H, --header <header>", "Request header for an http(s) input or configuration, as \"Name: value\"; repeatable", x).option("--timeout <ms>", `Milliseconds before fetching an http(s) input is abandoned (default: ${i})`).option("--schema-docs <mode>", "What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)", "summary").option("--strict", "Exit with code 4 when the run logs a warning").option("--verbose", "Log every step, and the stack trace of a failure").option("--quiet", "Log only warnings and errors").addHelpText("after", y).action(v), t;
88
+ }
89
+ function C(e) {
90
+ return e.exitCode === 0 ? r.success : r.input;
91
+ }
92
+ async function w(e, t = S()) {
93
+ try {
94
+ e === void 0 ? await t.parseAsync() : await t.parseAsync(e, { from: "user" });
95
+ } catch (e) {
96
+ if (!(e instanceof c)) throw e;
97
+ process.exitCode = C(e);
98
+ }
99
+ }
100
+ //#endregion
101
+ export { S as i, x as n, w as r, b as t };
102
+
103
+ //# sourceMappingURL=program-64WQvLq1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program-64WQvLq1.js","names":["DEFAULT_CONFIG_PATH","ConsoleLogger","EXIT_CODES","DEFAULT_HTTP_TIMEOUT_MS","GeneratorError","CodeGenerator","VERSION","validateInput","input","url","parseHeaders","parsed","header","headers","separator","name","parseTimeout","timeout","value","parseSchemaDocs","schemaDocs","logLevel","options","reportFailure","error","logger","verbose","message","runGenerate","generatorOptions","seams","result","warnings","config","relative","SIGNAL_SEAM","generateAction","interruption","EXIT_CODE_HELP","DEPRECATED_BIN_NOTICE","collect","previous","setupCLI","program","target","commanderExitCode","runCLI","args","CommanderError"],"sources":["../src/version.ts","../src/cli/runGenerate.ts","../src/cli/program.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Replaced at build time with the `version` of this package's package.json\n// (`define` in vite.config.ts, which Vitest shares), so only the version string\n// reaches dist, not the manifest with its dependencies and workspace ranges.\ndeclare const __WOW_GENERATOR_VERSION__: string;\n\n/** The version of this package, as its package.json named it at build time. */\nexport const VERSION: string = __WOW_GENERATOR_VERSION__;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative } from 'path';\nimport { VERSION } from '../version';\nimport { EXIT_CODES, GeneratorError } from '../api/errors';\nimport { CodeGenerator } from '../pipeline/codeGenerator';\nimport type { Logger, LogLevel } from '../api/logger';\nimport { ConsoleLogger } from '../api/logger';\nimport type { SchemaDocs } from '../api/options';\nimport type { SeamOptions, Seams } from '../pipeline/seams';\nimport { SIGNAL_SEAM } from '../pipeline/seams';\n\n/**\n * Options of the `generate` command, as commander parses them.\n */\nexport interface GenerateCommandOptions {\n input: string;\n output: string;\n config?: string;\n tsConfigFilePath?: string;\n /** `Name: value` request headers for an http(s) input or configuration. */\n header?: string[];\n /** Milliseconds, as typed on the command line. */\n timeout?: string;\n /** `summary` or `full`. */\n schemaDocs?: string;\n /** Exit with a non-zero code when the run logged a warning. */\n strict?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n}\n\n/**\n * Validates the input path or URL.\n *\n * Any file path is accepted here and checked when it is read. A URL must use\n * http or https; its host is not restricted, because the generator runs on\n * the developer's own machine against a document they chose, and fetching an\n * intranet service's `/v3/api-docs` is the common case.\n *\n * @param input - Input path or URL\n * @returns true if valid\n */\nexport function validateInput(input: string): boolean {\n if (!input) return false;\n let url: URL;\n try {\n url = new URL(input);\n } catch {\n // Not a URL: a file path, which parseOpenAPI reads.\n return true;\n }\n // A Windows path such as C:\\spec.json parses as a URL with scheme \"c:\".\n if (/^[a-z]:$/i.test(url.protocol)) return true;\n return url.protocol === 'http:' || url.protocol === 'https:';\n}\n\n/**\n * Parses `Name: value` header arguments.\n *\n * @param headers - The raw `--header` values\n * @returns The headers by name\n * @throws GeneratorError of kind `input` for a value without a name\n */\nexport function parseHeaders(\n headers: readonly string[] = [],\n): Record<string, string> {\n const parsed: Record<string, string> = {};\n for (const header of headers) {\n const separator = header.indexOf(':');\n const name = separator > 0 ? header.slice(0, separator).trim() : '';\n if (!name) {\n throw new GeneratorError(\n 'input',\n `Invalid --header \"${header}\": expected \"Name: value\".`,\n );\n }\n parsed[name] = header.slice(separator + 1).trim();\n }\n return parsed;\n}\n\nfunction parseTimeout(timeout: string | undefined): number | undefined {\n if (timeout === undefined) return undefined;\n const value = Number(timeout);\n if (!Number.isInteger(value) || value <= 0) {\n throw new GeneratorError(\n 'input',\n `Invalid --timeout \"${timeout}\": expected a positive number of milliseconds.`,\n );\n }\n return value;\n}\n\nfunction parseSchemaDocs(schemaDocs: string | undefined): SchemaDocs {\n if (schemaDocs === undefined || schemaDocs === 'summary') return 'summary';\n if (schemaDocs === 'full') return 'full';\n throw new GeneratorError(\n 'input',\n `Invalid --schema-docs \"${schemaDocs}\": expected \"summary\" or \"full\".`,\n );\n}\n\nfunction logLevel(options: GenerateCommandOptions): LogLevel {\n if (options.verbose) return 'verbose';\n if (options.quiet) return 'quiet';\n return 'normal';\n}\n\n/**\n * Reports a failure as one actionable line; the stack and the causes only\n * with `--verbose`.\n *\n * @returns The exit code the failure maps to\n */\nfunction reportFailure(\n logger: Logger,\n error: unknown,\n verbose: boolean,\n): number {\n if (error instanceof GeneratorError) {\n logger.error(error.message);\n if (verbose && error.cause !== undefined) {\n logger.error('Caused by:', error.cause);\n }\n return error.exitCode;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Code generation failed: ${message}`);\n if (verbose) {\n logger.error('', error);\n } else {\n logger.error(\n 'Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.',\n );\n }\n return EXIT_CODES.internal;\n}\n\n/**\n * Runs the `generate` command.\n *\n * @param options - The parsed command options\n * @param logger - Where to report; a console logger at the level the options ask for by default\n * @param seams - What the package hands the generator beyond the options;\n * a run stopped by the {@link SIGNAL_SEAM} exits with\n * {@link EXIT_CODES.interrupted}\n * @returns The exit code: see {@link EXIT_CODES}\n */\nexport async function runGenerate(\n options: GenerateCommandOptions,\n logger: Logger = new ConsoleLogger({ level: logLevel(options) }),\n seams: Seams = {},\n): Promise<number> {\n if (!validateInput(options.input)) {\n logger.error(\n `Invalid input \"${options.input}\": expected a file path or an http(s) URL.`,\n );\n return EXIT_CODES.input;\n }\n try {\n logger.debug(`wow-generator v${VERSION}`);\n const generatorOptions: SeamOptions = {\n ...seams,\n inputPath: options.input,\n outputDir: options.output,\n configPath: options.config,\n tsConfigFilePath: options.tsConfigFilePath,\n headers: parseHeaders(options.header),\n timeoutMs: parseTimeout(options.timeout),\n schemaDocs: parseSchemaDocs(options.schemaDocs),\n logger,\n };\n const result = await new CodeGenerator(generatorOptions).generate();\n const warnings = result.warnings\n ? `, ${result.warnings} warning${result.warnings === 1 ? '' : 's'}`\n : '';\n const config = result.configPath\n ? ` with ${relative(process.cwd(), result.configPath) || result.configPath}`\n : '';\n logger.info(\n `Generated ${result.files.length} files into ${options.output}${config}${warnings}`,\n );\n if (options.strict && result.warnings > 0) {\n logger.error(\n `--strict: the run logged ${result.warnings} warning${result.warnings === 1 ? '' : 's'}.`,\n );\n return EXIT_CODES.specification;\n }\n return EXIT_CODES.success;\n } catch (error) {\n if (seams[SIGNAL_SEAM]?.aborted) return EXIT_CODES.interrupted;\n return reportFailure(logger, error, !!options.verbose);\n }\n}\n\n/**\n * Action handler for the generate command: runs it and sets the process exit\n * code.\n *\n * Ctrl-C stops the run at its next step and exits with\n * {@link EXIT_CODES.interrupted}. A run that has begun writing finishes\n * writing its files, then stops: it removes no stale file and leaves the\n * manifest as the last complete run wrote it, so the manifest never records\n * a run that did not finish. A second Ctrl-C ends the process at once.\n *\n * @param options - Command options\n */\nexport async function generateAction(options: GenerateCommandOptions) {\n const interruption = new AbortController();\n process.once('SIGINT', () => {\n console.error('Generation interrupted by user');\n interruption.abort();\n });\n process.exitCode = await runGenerate(options, undefined, {\n [SIGNAL_SEAM]: interruption.signal,\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Command } from 'commander';\nimport { CommanderError, program } from 'commander';\nimport { VERSION } from '../version';\nimport { DEFAULT_CONFIG_PATH } from '../api/configuration';\nimport { EXIT_CODES } from '../api/errors';\nimport { DEFAULT_HTTP_TIMEOUT_MS } from '../input/resources';\nimport { generateAction } from './runGenerate';\n\n/** The exit codes `generate --help` lists, as the README's table does. */\nexport const EXIT_CODE_HELP = `\nExit codes:\n ${EXIT_CODES.success} generated; or --help, help or --version printed\n ${EXIT_CODES.internal} internal error; rerun with --verbose for the stack trace\n ${EXIT_CODES.input} input or usage: unreadable, unfetchable or not OpenAPI 3.x; an invalid option\n ${EXIT_CODES.configuration} configuration: cannot be read, parsed or validated\n ${EXIT_CODES.specification} specification: cannot be generated, or --strict and the run had warnings\n ${EXIT_CODES.output} output: the manifest, a path outside the output, or a failed write\n ${EXIT_CODES.interrupted} interrupted (Ctrl-C)`;\n\n/**\n * What the `fetcher-generator` bin prints to stderr before it runs: the name\n * still works, and goes in v10.\n */\nexport const DEPRECATED_BIN_NOTICE =\n 'fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.';\n\n/** Collects the values of an option given more than once, such as `--header`. */\nexport function collect(value: string, previous: string[] = []): string[] {\n return [...previous, value];\n}\n\n/**\n * Sets up the CLI program with all commands and options.\n *\n * Commander does not exit the process: a usage error (a missing required\n * option, an unknown option or command, a missing argument, no command at\n * all) is thrown as a `CommanderError`, which {@link runCLI} maps to an exit\n * code.\n *\n * @param target - The program to set up; commander's global one by default.\n * Settings made on it before this call, such as `configureOutput`, reach the\n * `generate` command too.\n * @returns The configured commander program instance\n */\nexport function setupCLI(target: Command = program): Command {\n // Before `command()`: a subcommand copies the exit override when it is\n // created.\n target.exitOverride();\n // compat(fetcher): package.json also installs this CLI as `fetcher-generator`\n // (src/fetcherGeneratorCli.ts), the name existing scripts call; drop that\n // bin alias in v10.\n target\n .name('wow-generator')\n .description('OpenAPI Specification TypeScript code generator for Wow')\n .version(VERSION, '-v, --version');\n\n target\n .command('generate')\n .description('Generate TypeScript code from OpenAPI specification')\n .requiredOption(\n '-i, --input <file>',\n 'Input OpenAPI specification file path or URL (http/https)',\n )\n .option('-o, --output <path>', 'Output directory path', 'src/generated')\n // No commander default: an omitted -c falls back to DEFAULT_CONFIG_PATH,\n // which may be absent, while a path the user named has to exist.\n .option(\n '-c, --config <file>',\n `Configuration file path (default: ${DEFAULT_CONFIG_PATH})`,\n )\n .option(\n '-t, --ts-config-file-path <file>',\n 'TypeScript configuration file path',\n )\n .option(\n '-H, --header <header>',\n 'Request header for an http(s) input or configuration, as \"Name: value\"; repeatable',\n collect,\n )\n .option(\n '--timeout <ms>',\n `Milliseconds before fetching an http(s) input is abandoned (default: ${DEFAULT_HTTP_TIMEOUT_MS})`,\n )\n .option(\n '--schema-docs <mode>',\n 'What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)',\n 'summary',\n )\n .option('--strict', 'Exit with code 4 when the run logs a warning')\n .option('--verbose', 'Log every step, and the stack trace of a failure')\n .option('--quiet', 'Log only warnings and errors')\n .addHelpText('after', EXIT_CODE_HELP)\n .action(generateAction);\n\n return target;\n}\n\n/**\n * The exit code of a command line commander stopped at: 0 for `--help`,\n * `help` and `--version`; {@link EXIT_CODES.input} for a usage error, which\n * commander has already reported. A usage error is an invalid command line,\n * the same category as an invalid option value such as `--timeout abc`.\n */\nexport function commanderExitCode(error: CommanderError): number {\n return error.exitCode === 0 ? EXIT_CODES.success : EXIT_CODES.input;\n}\n\n/**\n * Parses the command line and runs the command it names. The `generate`\n * command sets the process exit code itself; a command line commander stops\n * at sets it to {@link commanderExitCode}.\n *\n * @param args - The arguments after the executable and script;\n * `process.argv` by default\n * @param target - The program to run; {@link setupCLI} on commander's global\n * one by default\n */\nexport async function runCLI(\n args?: readonly string[],\n target: Command = setupCLI(),\n): Promise<void> {\n try {\n if (args === undefined) {\n await target.parseAsync();\n } else {\n await target.parseAsync(args, { from: 'user' });\n }\n } catch (error) {\n if (!(error instanceof CommanderError)) throw error;\n process.exitCode = commanderExitCode(error);\n }\n}\n"],"mappings":";;;;AAmBA,IAAaM,IAAA;;;ACmCb,SAAgBC,EAAc,GAAwB;CACpD,IAAI,CAACC,GAAO,OAAO;CACnB,IAAIC;CACJ,IAAI;EACF,IAAM,IAAI,IAAID,CAAK;CACrB,QAAQ;EAEN,OAAO;CACT;CAGA,OADI,YAAY,KAAKC,EAAI,QAAQ,IAAU,KACpCA,EAAI,aAAa,WAAWA,EAAI,aAAa;AACtD;AASA,SAAgBC,EACd,IAA6B,CAAC,GACN;CACxB,IAAMC,IAAiC,CAAC;CACxC,KAAK,IAAMC,KAAUC,GAAS;EAC5B,IAAMC,IAAYF,EAAO,QAAQ,GAAG,GAC9BG,IAAOD,IAAY,IAAIF,EA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cjs");let t=require("path"),n=require("commander");var r=`9.9.0`;function i(e){if(!e)return!1;let t;try{t=new URL(e)}catch{return!0}return/^[a-z]:$/i.test(t.protocol)?!0:t.protocol===`http:`||t.protocol===`https:`}function a(t=[]){let n={};for(let r of t){let t=r.indexOf(`:`),i=t>0?r.slice(0,t).trim():``;if(!i)throw new e.s(`input`,`Invalid --header "${r}": expected "Name: value".`);n[i]=r.slice(t+1).trim()}return n}function o(t){if(t===void 0)return;let n=Number(t);if(!Number.isInteger(n)||n<=0)throw new e.s(`input`,`Invalid --timeout "${t}": expected a positive number of milliseconds.`);return n}function s(t){if(t===void 0||t===`summary`)return`summary`;if(t===`full`)return`full`;throw new e.s(`input`,`Invalid --schema-docs "${t}": expected "summary" or "full".`)}function c(e){return e.verbose?`verbose`:e.quiet?`quiet`:`normal`}function l(t,n,r){if(n instanceof e.s)return t.error(n.message),r&&n.cause!==void 0&&t.error(`Caused by:`,n.cause),n.exitCode;let i=n instanceof Error?n.message:String(n);return t.error(`Code generation failed: ${i}`),r?t.error(``,n):t.error(`Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.`),e.o.internal}async function u(n,u=new e.i({level:c(n)}),d={}){if(!i(n.input))return u.error(`Invalid input "${n.input}": expected a file path or an http(s) URL.`),e.o.input;try{u.debug(`wow-generator v${r}`);let i={...d,inputPath:n.input,outputDir:n.output,configPath:n.config,tsConfigFilePath:n.tsConfigFilePath,headers:a(n.header),timeoutMs:o(n.timeout),schemaDocs:s(n.schemaDocs),logger:u},c=await new e.t(i).generate(),l=c.warnings?`, ${c.warnings} warning${c.warnings===1?``:`s`}`:``,f=c.configPath?` with ${(0,t.relative)(process.cwd(),c.configPath)||c.configPath}`:``;return u.info(`Generated ${c.files.length} files into ${n.output}${f}${l}`),n.strict&&c.warnings>0?(u.error(`--strict: the run logged ${c.warnings} warning${c.warnings===1?``:`s`}.`),e.o.specification):e.o.success}catch(t){return d[e.n]?.aborted?e.o.interrupted:l(u,t,!!n.verbose)}}async function d(t){let n=new AbortController;process.once(`SIGINT`,()=>{console.error(`Generation interrupted by user`),n.abort()}),process.exitCode=await u(t,void 0,{[e.n]:n.signal})}var f=`
2
+ Exit codes:
3
+ ${e.o.success} generated; or --help, help or --version printed
4
+ ${e.o.internal} internal error; rerun with --verbose for the stack trace
5
+ ${e.o.input} input or usage: unreadable, unfetchable or not OpenAPI 3.x; an invalid option
6
+ ${e.o.configuration} configuration: cannot be read, parsed or validated
7
+ ${e.o.specification} specification: cannot be generated, or --strict and the run had warnings
8
+ ${e.o.output} output: the manifest, a path outside the output, or a failed write
9
+ ${e.o.interrupted} interrupted (Ctrl-C)`,p=`fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.`;function m(e,t=[]){return[...t,e]}function h(t=n.program){return t.exitOverride(),t.name(`wow-generator`).description(`OpenAPI Specification TypeScript code generator for Wow`).version(r,`-v, --version`),t.command(`generate`).description(`Generate TypeScript code from OpenAPI specification`).requiredOption(`-i, --input <file>`,`Input OpenAPI specification file path or URL (http/https)`).option(`-o, --output <path>`,`Output directory path`,`src/generated`).option(`-c, --config <file>`,`Configuration file path (default: ${e.c})`).option(`-t, --ts-config-file-path <file>`,`TypeScript configuration file path`).option(`-H, --header <header>`,`Request header for an http(s) input or configuration, as "Name: value"; repeatable`,m).option(`--timeout <ms>`,`Milliseconds before fetching an http(s) input is abandoned (default: ${e.r})`).option(`--schema-docs <mode>`,`What model doc comments carry: "summary" (title, description, constraints) or "full" (also the JSON schema)`,`summary`).option(`--strict`,`Exit with code 4 when the run logs a warning`).option(`--verbose`,`Log every step, and the stack trace of a failure`).option(`--quiet`,`Log only warnings and errors`).addHelpText(`after`,f).action(d),t}function g(t){return t.exitCode===0?e.o.success:e.o.input}async function _(e,t=h()){try{e===void 0?await t.parseAsync():await t.parseAsync(e,{from:`user`})}catch(e){if(!(e instanceof n.CommanderError))throw e;process.exitCode=g(e)}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
10
+ //# sourceMappingURL=program-DWjbTSVJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program-DWjbTSVJ.cjs","names":["GeneratorError","EXIT_CODES","ConsoleLogger","CodeGenerator","relative","SIGNAL_SEAM","EXIT_CODES","program","DEFAULT_CONFIG_PATH","DEFAULT_HTTP_TIMEOUT_MS","CommanderError","require_codeGenerator","path","commander","VERSION","validateInput","input","url","parseHeaders","parsed","header","headers","separator","name","parseTimeout","timeout","value","parseSchemaDocs","schemaDocs","logLevel","options","reportFailure","error","logger","verbose","message","runGenerate","generatorOptions","seams","result","warnings","config","generateAction","interruption","EXIT_CODE_HELP","DEPRECATED_BIN_NOTICE","collect","previous","setupCLI","target","commanderExitCode","runCLI","args"],"sources":["../src/version.ts","../src/cli/runGenerate.ts","../src/cli/program.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Replaced at build time with the `version` of this package's package.json\n// (`define` in vite.config.ts, which Vitest shares), so only the version string\n// reaches dist, not the manifest with its dependencies and workspace ranges.\ndeclare const __WOW_GENERATOR_VERSION__: string;\n\n/** The version of this package, as its package.json named it at build time. */\nexport const VERSION: string = __WOW_GENERATOR_VERSION__;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative } from 'path';\nimport { VERSION } from '../version';\nimport { EXIT_CODES, GeneratorError } from '../api/errors';\nimport { CodeGenerator } from '../pipeline/codeGenerator';\nimport type { Logger, LogLevel } from '../api/logger';\nimport { ConsoleLogger } from '../api/logger';\nimport type { SchemaDocs } from '../api/options';\nimport type { SeamOptions, Seams } from '../pipeline/seams';\nimport { SIGNAL_SEAM } from '../pipeline/seams';\n\n/**\n * Options of the `generate` command, as commander parses them.\n */\nexport interface GenerateCommandOptions {\n input: string;\n output: string;\n config?: string;\n tsConfigFilePath?: string;\n /** `Name: value` request headers for an http(s) input or configuration. */\n header?: string[];\n /** Milliseconds, as typed on the command line. */\n timeout?: string;\n /** `summary` or `full`. */\n schemaDocs?: string;\n /** Exit with a non-zero code when the run logged a warning. */\n strict?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n}\n\n/**\n * Validates the input path or URL.\n *\n * Any file path is accepted here and checked when it is read. A URL must use\n * http or https; its host is not restricted, because the generator runs on\n * the developer's own machine against a document they chose, and fetching an\n * intranet service's `/v3/api-docs` is the common case.\n *\n * @param input - Input path or URL\n * @returns true if valid\n */\nexport function validateInput(input: string): boolean {\n if (!input) return false;\n let url: URL;\n try {\n url = new URL(input);\n } catch {\n // Not a URL: a file path, which parseOpenAPI reads.\n return true;\n }\n // A Windows path such as C:\\spec.json parses as a URL with scheme \"c:\".\n if (/^[a-z]:$/i.test(url.protocol)) return true;\n return url.protocol === 'http:' || url.protocol === 'https:';\n}\n\n/**\n * Parses `Name: value` header arguments.\n *\n * @param headers - The raw `--header` values\n * @returns The headers by name\n * @throws GeneratorError of kind `input` for a value without a name\n */\nexport function parseHeaders(\n headers: readonly string[] = [],\n): Record<string, string> {\n const parsed: Record<string, string> = {};\n for (const header of headers) {\n const separator = header.indexOf(':');\n const name = separator > 0 ? header.slice(0, separator).trim() : '';\n if (!name) {\n throw new GeneratorError(\n 'input',\n `Invalid --header \"${header}\": expected \"Name: value\".`,\n );\n }\n parsed[name] = header.slice(separator + 1).trim();\n }\n return parsed;\n}\n\nfunction parseTimeout(timeout: string | undefined): number | undefined {\n if (timeout === undefined) return undefined;\n const value = Number(timeout);\n if (!Number.isInteger(value) || value <= 0) {\n throw new GeneratorError(\n 'input',\n `Invalid --timeout \"${timeout}\": expected a positive number of milliseconds.`,\n );\n }\n return value;\n}\n\nfunction parseSchemaDocs(schemaDocs: string | undefined): SchemaDocs {\n if (schemaDocs === undefined || schemaDocs === 'summary') return 'summary';\n if (schemaDocs === 'full') return 'full';\n throw new GeneratorError(\n 'input',\n `Invalid --schema-docs \"${schemaDocs}\": expected \"summary\" or \"full\".`,\n );\n}\n\nfunction logLevel(options: GenerateCommandOptions): LogLevel {\n if (options.verbose) return 'verbose';\n if (options.quiet) return 'quiet';\n return 'normal';\n}\n\n/**\n * Reports a failure as one actionable line; the stack and the causes only\n * with `--verbose`.\n *\n * @returns The exit code the failure maps to\n */\nfunction reportFailure(\n logger: Logger,\n error: unknown,\n verbose: boolean,\n): number {\n if (error instanceof GeneratorError) {\n logger.error(error.message);\n if (verbose && error.cause !== undefined) {\n logger.error('Caused by:', error.cause);\n }\n return error.exitCode;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Code generation failed: ${message}`);\n if (verbose) {\n logger.error('', error);\n } else {\n logger.error(\n 'Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.',\n );\n }\n return EXIT_CODES.internal;\n}\n\n/**\n * Runs the `generate` command.\n *\n * @param options - The parsed command options\n * @param logger - Where to report; a console logger at the level the options ask for by default\n * @param seams - What the package hands the generator beyond the options;\n * a run stopped by the {@link SIGNAL_SEAM} exits with\n * {@link EXIT_CODES.interrupted}\n * @returns The exit code: see {@link EXIT_CODES}\n */\nexport async function runGenerate(\n options: GenerateCommandOptions,\n logger: Logger = new ConsoleLogger({ level: logLevel(options) }),\n seams: Seams = {},\n): Promise<number> {\n if (!validateInput(options.input)) {\n logger.error(\n `Invalid input \"${options.input}\": expected a file path or an http(s) URL.`,\n );\n return EXIT_CODES.input;\n }\n try {\n logger.debug(`wow-generator v${VERSION}`);\n const generatorOptions: SeamOptions = {\n ...seams,\n inputPath: options.input,\n outputDir: options.output,\n configPath: options.config,\n tsConfigFilePath: options.tsConfigFilePath,\n headers: parseHeaders(options.header),\n timeoutMs: parseTimeout(options.timeout),\n schemaDocs: parseSchemaDocs(options.schemaDocs),\n logger,\n };\n const result = await new CodeGenerator(generatorOptions).generate();\n const warnings = result.warnings\n ? `, ${result.warnings} warning${result.warnings === 1 ? '' : 's'}`\n : '';\n const config = result.configPath\n ? ` with ${relative(process.cwd(), result.configPath) || result.configPath}`\n : '';\n logger.info(\n `Generated ${result.files.length} files into ${options.output}${config}${warnings}`,\n );\n if (options.strict && result.warnings > 0) {\n logger.error(\n `--strict: the run logged ${result.warnings} warning${result.warnings === 1 ? '' : 's'}.`,\n );\n return EXIT_CODES.specification;\n }\n return EXIT_CODES.success;\n } catch (error) {\n if (seams[SIGNAL_SEAM]?.aborted) return EXIT_CODES.interrupted;\n return reportFailure(logger, error, !!options.verbose);\n }\n}\n\n/**\n * Action handler for the generate command: runs it and sets the process exit\n * code.\n *\n * Ctrl-C stops the run at its next step and exits with\n * {@link EXIT_CODES.interrupted}. A run that has begun writing finishes\n * writing its files, then stops: it removes no stale file and leaves the\n * manifest as the last complete run wrote it, so the manifest never records\n * a run that did not finish. A second Ctrl-C ends the process at once.\n *\n * @param options - Command options\n */\nexport async function generateAction(options: GenerateCommandOptions) {\n const interruption = new AbortController();\n process.once('SIGINT', () => {\n console.error('Generation interrupted by user');\n interruption.abort();\n });\n process.exitCode = await runGenerate(options, undefined, {\n [SIGNAL_SEAM]: interruption.signal,\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Command } from 'commander';\nimport { CommanderError, program } from 'commander';\nimport { VERSION } from '../version';\nimport { DEFAULT_CONFIG_PATH } from '../api/configuration';\nimport { EXIT_CODES } from '../api/errors';\nimport { DEFAULT_HTTP_TIMEOUT_MS } from '../input/resources';\nimport { generateAction } from './runGenerate';\n\n/** The exit codes `generate --help` lists, as the README's table does. */\nexport const EXIT_CODE_HELP = `\nExit codes:\n ${EXIT_CODES.success} generated; or --help, help or --version printed\n ${EXIT_CODES.internal} internal error; rerun with --verbose for the stack trace\n ${EXIT_CODES.input} input or usage: unreadable, unfetchable or not OpenAPI 3.x; an invalid option\n ${EXIT_CODES.configuration} configuration: cannot be read, parsed or validated\n ${EXIT_CODES.specification} specification: cannot be generated, or --strict and the run had warnings\n ${EXIT_CODES.output} output: the manifest, a path outside the output, or a failed write\n ${EXIT_CODES.interrupted} interrupted (Ctrl-C)`;\n\n/**\n * What the `fetcher-generator` bin prints to stderr before it runs: the name\n * still works, and goes in v10.\n */\nexport const DEPRECATED_BIN_NOTICE =\n 'fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.';\n\n/** Collects the values of an option given more than once, such as `--header`. */\nexport function collect(value: string, previous: string[] = []): string[] {\n return [...previous, value];\n}\n\n/**\n * Sets up the CLI program with all commands and options.\n *\n * Commander does not exit the process: a usage error (a missing required\n * option, an unknown option or command, a missing argument, no command at\n * all) is thrown as a `CommanderError`, which {@link runCLI} maps to an exit\n * code.\n *\n * @param target - The program to set up; commander's global one by default.\n * Settings made on it before this call, such as `configureOutput`, reach the\n * `generate` command too.\n * @returns The configured commander program instance\n */\nexport function setupCLI(target: Command = program): Command {\n // Before `command()`: a subcommand copies the exit override when it is\n // created.\n target.exitOverride();\n // compat(fetcher): package.json also installs this CLI as `fetcher-generator`\n // (src/fetcherGeneratorCli.ts), the name existing scripts call; drop that\n // bin alias in v10.\n target\n .name('wow-generator')\n .description('OpenAPI Specification TypeScript code generator for Wow')\n .version(VERSION, '-v, --version');\n\n target\n .command('generate')\n .description('Generate TypeScript code from OpenAPI specification')\n .requiredOption(\n '-i, --input <file>',\n 'Input OpenAPI specification file path or URL (http/https)',\n )\n .option('-o, --output <path>', 'Output directory path', 'src/generated')\n // No commander default: an omitted -c falls back to DEFAULT_CONFIG_PATH,\n // which may be absent, while a path the user named has to exist.\n .option(\n '-c, --config <file>',\n `Configuration file path (default: ${DEFAULT_CONFIG_PATH})`,\n )\n .option(\n '-t, --ts-config-file-path <file>',\n 'TypeScript configuration file path',\n )\n .option(\n '-H, --header <header>',\n 'Request header for an http(s) input or configuration, as \"Name: value\"; repeatable',\n collect,\n )\n .option(\n '--timeout <ms>',\n `Milliseconds before fetching an http(s) input is abandoned (default: ${DEFAULT_HTTP_TIMEOUT_MS})`,\n )\n .option(\n '--schema-docs <mode>',\n 'What model doc comments carry: \"summary\" (title, description, constraints) or \"full\" (also the JSON schema)',\n 'summary',\n )\n .option('--strict', 'Exit with code 4 when the run logs a warning')\n .option('--verbose', 'Log every step, and the stack trace of a failure')\n .option('--quiet', 'Log only warnings and errors')\n .addHelpText('after', EXIT_CODE_HELP)\n .action(generateAction);\n\n return target;\n}\n\n/**\n * The exit code of a command line commander stopped at: 0 for `--help`,\n * `help` and `--version`; {@link EXIT_CODES.input} for a usage error, which\n * commander has already reported. A usage error is an invalid command line,\n * the same category as an invalid option value such as `--timeout abc`.\n */\nexport function commanderExitCode(error: CommanderError): number {\n return error.exitCode === 0 ? EXIT_CODES.success : EXIT_CODES.input;\n}\n\n/**\n * Parses the command line and runs the command it names. The `generate`\n * command sets the process exit code itself; a command line commander stops\n * at sets it to {@link commanderExitCode}.\n *\n * @param args - The arguments after the executable and script;\n * `process.argv` by default\n * @param target - The program to run; {@link setupCLI} on commander's global\n * one by default\n */\nexport async function runCLI(\n args?: readonly string[],\n target: Command = setupCLI(),\n): Promise<void> {\n try {\n if (args === undefined) {\n await target.parseAsync();\n } else {\n await target.parseAsync(args, { from: 'user' });\n }\n } catch (error) {\n if (!(error instanceof CommanderError)) throw error;\n process.exitCode = commanderExitCode(error);\n }\n}\n"],"mappings":"6FAmBA,IAAac,EAAA,QCmCb,SAAgBC,EAAc,EAAwB,CACpD,GAAI,CAACC,EAAO,MAAO,GACnB,IAAIC,EACJ,GAAI,CACF,EAAM,IAAI,IAAID,CAAK,CACrB,MAAQ,CAEN,MAAO,EACT,CAGA,MADI,YAAY,KAAKC,EAAI,QAAQ,EAAU,GACpCA,EAAI,WAAa,SAAWA,EAAI,WAAa,QACtD,CASA,SAAgBC,EACd,EAA6B,CAAC,EACN,CACxB,IAAMC,EAAiC,CAAC,EACxC,IAAK,IAAMC,KAAUC,EAAS,CAC5B,IAAMC,EAAYF,EAAO,QAAQ,GAAG,EAC9BG,EAAOD,EAAY,EAAIF,EAAO,MAAM,EAAGE,CAAS,CAAC,CAAC,KAAK,EAAI,GACjE,GAAI,CAACC,EACH,MAAM,IAAIvB,EAAAA,EACR,QACA,qBAAqBoB,EAAO,2BAC9B,EAEF,EAAOG,GAAQH,EAAO,MAAME,EAAY,CAAC,CAAC,CAAC,KAAK,CAClD,CACA,OAAOH,CACT,CAEA,SAASK,EAAa,EAAiD,CACrE,GAAIC,IAAY,IAAA,GAAW,OAC3B,IAAMC,EAAQ,OAAOD,CAAO,EAC5B,GAAI,CAAC,OAAO,UAAUC,CAAK,GAAKA,GAAS,EACvC,MAAM,IAAI1B,EAAAA,EACR,QACA,sBAAsByB,E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EAAO,aAAa,EAIpBA,EACG,KAAK,eAAe,CAAC,CACrB,YAAY,yDAAyD,CAAC,CACtE,QAAQnC,EAAS,eAAe,EAEnCmC,EACG,QAAQ,UAAU,CAAC,CACnB,YAAY,qDAAqD,CAAC,CAClE,eACC,qBACA,2DACF,CAAC,CACA,OAAO,sBAAuB,wBAAyB,eAAe,CAAC,CAGvE,OACC,sBACA,qCAAqCzC,EAAAA,EAAoB,EAC3D,CAAC,CACA,OACC,mCACA,oCACF,CAAC,CACA,OACC,wBACA,qFACAsC,CACF,CAAC,CACA,OACC,iBACA,wEAAwErC,EAAAA,EAAwB,EAClG,CAAC,CACA,OACC,uBACA,8GACA,SACF,CAAC,CACA,OAAO,WAAY,8CAA8C,CAAC,CAClE,OAAO,YAAa,kDAAkD,CAAC,CACvE,OAAO,UAAW,8BAA8B,CAAC,CACjD,YAAY,QAASmC,CAAc,CAAC,CACpC,OAAOF,CAAc,EAEjBO,CACT,CAQA,SAAgBC,EAAkB,EAA+B,CAC/D,OAAOlB,EAAM,WAAa,EAAI1B,EAAAA,EAAW,QAAUA,EAAAA,EAAW,KAChE,CAYA,eAAsB6C,EACpB,EACA,EAAkBH,EAAS,EACZ,CACf,GAAI,CACEI,IAAS,IAAA,GACX,MAAMH,EAAO,WAAW,EAExB,MAAMA,EAAO,WAAWG,EAAM,CAAE,KAAM,MAAO,CAAC,CAElD,OAASpB,EAAO,CACd,GAAI,EAAEA,aAAiBtB,EAAAA,gBAAiB,MAAMsB,EAC9C,QAAQ,SAAWkB,EAAkBlB,CAAK,CAC5C,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/wow-generator",
3
- "version": "9.8.0",
3
+ "version": "9.9.0",
4
4
  "description": "Generates TypeScript models, Fetcher decorator clients and Wow command and query clients from a local or remote OpenAPI 3 document. The Wow clients follow the CQRS model of the Wow DDD framework (https://github.com/Ahoo-Wang/Wow).",
5
5
  "keywords": [
6
6
  "wow",
@@ -39,7 +39,7 @@
39
39
  "types": "./dist/index.d.ts",
40
40
  "bin": {
41
41
  "wow-generator": "./dist/cli.js",
42
- "fetcher-generator": "./dist/cli.js"
42
+ "fetcher-generator": "./dist/fetcherGeneratorCli.js"
43
43
  },
44
44
  "exports": {
45
45
  ".": {
@@ -64,7 +64,7 @@
64
64
  "@ahoo-wang/fetcher": "^5.1.5 || ^6.0.0",
65
65
  "@ahoo-wang/fetcher-decorator": "^5.1.5 || ^6.0.0",
66
66
  "@ahoo-wang/fetcher-eventstream": "^5.1.5 || ^6.0.0",
67
- "@ahoo-wang/wow-client": "~9.8.0"
67
+ "@ahoo-wang/wow-client": "~9.9.0"
68
68
  },
69
69
  "dependencies": {
70
70
  "ts-morph": "^28.0.0",
@@ -77,7 +77,7 @@
77
77
  "@ahoo-wang/fetcher-eventstream": "^6.0.1",
78
78
  "@ahoo-wang/fetcher-openapi": "^6.0.1",
79
79
  "@eslint/js": "^10.0.1",
80
- "@types/node": "^26.6.4",
80
+ "@types/node": "^26.6.5",
81
81
  "@vitest/coverage-v8": "4.1.11",
82
82
  "@vitest/ui": "^4.1.11",
83
83
  "eslint": "^10.12.0",
@@ -90,7 +90,7 @@
90
90
  "vite": "8.3.4",
91
91
  "vite-bundle-analyzer": "^1.3.9",
92
92
  "vitest": "^4.1.11",
93
- "@ahoo-wang/wow-client": "~9.8.0"
93
+ "@ahoo-wang/wow-client": "~9.9.0"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "vite build && pnpm test:package",