@bitstack/ng-query-codegen-openapi 0.0.34 → 0.0.35
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/lib/bin/cli.mjs +7 -7
- package/lib/bin/cli.mjs.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +4 -4
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/generators/types-generator.ts +5 -4
package/lib/bin/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var I=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var M=(r,t)=>()=>(r&&(t=r(r=0)),t);var Ae=(r,t)=>{for(var e in t)I(r,e,{get:t[e],enumerable:!0})},Ee=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!Ne.call(r,o)&&o!==e&&I(r,o,{get:()=>t[o],enumerable:!(n=Pe(t,o))||n.enumerable});return r};var Re=r=>Ee(I({},"__esModule",{value:!0}),r);import{fileURLToPath as Se}from"node:url";var qe,
|
|
2
|
+
var I=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var M=(r,t)=>()=>(r&&(t=r(r=0)),t);var Ae=(r,t)=>{for(var e in t)I(r,e,{get:t[e],enumerable:!0})},Ee=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!Ne.call(r,o)&&o!==e&&I(r,o,{get:()=>t[o],enumerable:!(n=Pe(t,o))||n.enumerable});return r};var Re=r=>Ee(I({},"__esModule",{value:!0}),r);import{fileURLToPath as Se}from"node:url";var qe,l,c=M(()=>{"use strict";qe=()=>Se(import.meta.url),l=qe()});var ne={};Ae(ne,{argumentMatches:()=>Ue,defaultIsDataResponse:()=>ke,getOperationName:()=>E,getOverrides:()=>D,getTags:()=>Ve,operationMatches:()=>re});import{getOperationName as Qe}from"oazapfts/generate";function ke(r,t){if(t&&r==="default")return!0;let e=Number(r);return!Number.isNaN(e)&&e>=200&&e<300}function E({verb:r,path:t}){return Qe(r,t,void 0)}function Ve({verb:r,pathItem:t}){return r?t[r]?.tags||[]:[]}function te(r){let t=Array.isArray(r)?r:[r];return function(n){return r?t.some(o=>typeof o=="string"?o===n:o?.test(n)):!0}}function re(r){let t=typeof r=="function"?r:te(r);return function(n){if(!r)return!0;let o=E(n);return t(o,n)}}function Ue(r){let t=typeof r=="function"?r:te(r);return function(n){if(!r||n.in==="path")return!0;let o=n.name;return t(o,n)}}function D(r,t){return t?.find(e=>re(e.pattern)(r))}var K=M(()=>{"use strict";c()});c();import j from"commander";import{createRequire as Je}from"node:module";c();import Fe from"commander";import{createRequire as we}from"node:module";import{resolve as Q}from"node:path";import{existsSync as je,rmSync as Ie,readdirSync as ut,statSync as mt,mkdirSync as lt}from"node:fs";var x=we(l);function k(r){let t=["/","/usr","/etc","/var","/home","/Users",".",".."],e=Q(r);t.some(n=>e===Q(n))&&(console.error(`Dangerous path detected: ${e}. Refusing to delete.`),process.exit(1)),je(r)&&(console.log(`Cleaning output directory: ${r}`),Ie(r,{recursive:!0,force:!0}),console.log(`Directory cleaned: ${r}`))}function V(){try{if(x.resolve("esbuild")&&x.resolve("esbuild-runner"))return x("esbuild-runner/register"),!0}catch{}try{if(x.resolve("typescript")&&x.resolve("ts-node"))return x("ts-node").register({transpileOnly:!0,compilerOptions:{target:"es6",module:"commonjs"}}),!0}catch{}return!1}function U(r){(!r||!/\.([mc]?(jsx?|tsx?)|jsonc?)?$/.test(r))&&(console.error("Please provide a valid configuration file."),Fe.help())}function W(r,t){/\.[mc]?tsx?$/.test(r)&&!t&&(console.error("Encountered a TypeScript config file, but neither esbuild-runner nor ts-node are installed."),process.exit(1))}import{dirname as Xe,resolve as et}from"node:path";c();c();import F from"node:path";import de from"typescript";c();c();function P(r){return r.replace(r[0],r[0].toUpperCase())}c();import G from"node:fs";import Ge from"node:path";c();function _(r){try{new URL(r)}catch{return!1}return!0}async function B(r,t){if(!_(r))throw new Error(`remoteFile must be a valid URL: ${r}`);try{let e=Ge.dirname(t);G.existsSync(e)||await G.promises.mkdir(e,{recursive:!0});let n=await fetch(r);if(!n.ok)throw new Error(`Failed to download schema from ${r}: ${n.statusText}`);let o=await n.text();return await G.promises.writeFile(t,o,"utf-8"),console.log(`Schema downloaded from ${r} to ${t}`),t}catch(e){throw console.error(`Error downloading schema from ${r}:`,e),e}}c();c();var L=["get","put","post","delete","options","head","patch","trace"];function z(r){return Object.entries(r.paths).flatMap(([t,e])=>e?Object.entries(e).filter(n=>L.includes(n[0])).map(([n,o])=>({path:t,verb:n,pathItem:e,operation:o})):[])}c();import De from"@apidevtools/swagger-parser";import Ke from"swagger2openapi";async function H(r,t){let e=await De.bundle(r,{resolve:{http:t}});return"openapi"in e&&e.openapi.startsWith("3")?e:(await Ke.convertObj(e,{})).openapi}c();function Z(r,t,e,n){return n?n(r,t):e?.type?e.type==="query":r==="get"}var $=class{docCache={};async getDocument(t,e){if(this.docCache[t])return this.docCache[t];let n=await H(t,e);return this.docCache[t]=n,n}async downloadSchema(t,e){return B(t,e)}getPaths(t){return Object.keys(t.paths||{})}clearCache(){this.docCache={}}};c();import Y from"lodash.camelcase";var N=class{groupPaths(t,e){let{groupKeyMatch:n,outputDir:o}=e,s=t.reduce((p,u)=>{let i=n(u),m=i?Y(i):"_common";return p[m]||(p[m]=[]),p[m].push(u),p},{}),a={};for(let[p,u]of Object.entries(s))a[p]={groupKey:p,paths:u,outputPath:`${o}/${p}/query.service.ts`};return a}createGroupFilter(t,e){return(n,o)=>{let s=o.path,a=Y(e.groupKeyMatch(s)||"");return a!==t&&(a||"_common")!==t?!1:e.filterEndpoint?e.filterEndpoint(n,s,t):!0}}};c();import ee from"node:fs";import f from"node:path";c();import Me from"node:path";import J from"node:fs";async function X(r){let t=Me.dirname(r);J.existsSync(t)||await J.promises.mkdir(t,{recursive:!0})}var A=class{async writeFile(t,e){try{let n=f.resolve(process.cwd(),t);return f.basename(n)==="enhanceEndpoints.ts"&&ee.existsSync(n)?{path:n,success:!0}:(await X(n),ee.writeFileSync(n,e),{path:n,success:!0})}catch(n){return{path:t,success:!1,error:n}}}async writeFiles(t){let e=[];for(let[n,o]of Object.entries(t)){let s=await this.writeFile(n,o);e.push(s)}return e}async writeGroupFiles(t,e){let n={};return e.types&&(n[f.join(t,"types.ts")]=e.types),e.queryService&&(n[f.join(t,"query.generated.ts")]=e.queryService),e.enhanceEndpoints&&(n[f.join(t,"enhanceEndpoints.ts")]=e.enhanceEndpoints),e.index&&(n[f.join(t,"index.ts")]=e.index),this.writeFiles(n)}async writeSharedFiles(t,e){let n={};return e.commonTypes&&(n[f.join(t,"common-types.ts")]=e.commonTypes),e.tagTypes&&(n[f.join(t,"tagTypes.ts")]=e.tagTypes),e.doNotModify&&(n[f.join(t,"DO_NOT_MODIFY.md")]=e.doNotModify),e.utils&&(n[f.join(t,"utils.ts")]=e.utils),this.writeFiles(n)}async writeSchemaFile(t,e){let n={};return n[f.join(t,"schema.ts")]=e,this.writeFiles(n)}};c();import We from"oazapfts/generate";var R=class{constructor(t,e){this.v3Doc=t;this.apiGen=new We(t,{unionUndefined:e.unionUndefined,mergeReadWriteOnly:e.mergeReadWriteOnly})}apiGen;initialize(){this.apiGen.spec.components?.schemas&&(Object.keys(this.apiGen.spec.components.schemas).forEach(t=>{let e=this.apiGen.spec.components.schemas[t];e&&typeof e=="object"&&"title"in e&&delete e.title}),this.apiGen.preprocessComponents(this.apiGen.spec.components.schemas),Object.keys(this.apiGen.spec.components.schemas).forEach(t=>{try{this.apiGen.getRefAlias({$ref:`#/components/schemas/${t}`})}catch{}}))}getOperationDefinitions(t){let{operationMatches:e}=(K(),Re(ne));return z(this.v3Doc).filter(e(t))}getApiGenerator(){return this.apiGen}getDocument(){return this.v3Doc}getSchemaTypeNames(){return new Set}};c();function oe(){return`/* eslint-disable */
|
|
3
3
|
// [Warning] Generated automatically - do not edit manually
|
|
4
4
|
|
|
5
5
|
export interface RequestOptions {
|
|
@@ -62,7 +62,7 @@ ${n.join(`
|
|
|
62
62
|
|
|
63
63
|
`)}function He(r,t,e={}){let n=[];r.queryParams&&r.queryParams.length>0&&r.queryParams.forEach(s=>{let a=s.required?"":"?",p=ae(s,e);n.push(` ${s.name}${a}: ${p};`)}),r.pathParams&&r.pathParams.length>0&&r.pathParams.forEach(s=>{let a=s.required?"":"?",p=ae(s,e);n.push(` ${s.name}${a}: ${p};`)});let o=t?.find(s=>s.operation?.operationId===r.operationName||s.operation?.operationId===r.operationName.toLowerCase()||s.verb===r.verb.toLowerCase()&&s.path===r.path);if(o?.operation?.requestBody){let a=o.operation.requestBody.content,p=a["application/json"]||a["*/*"],u=a["multipart/form-data"]||a["application/x-www-form-urlencoded"];if(p?.schema){let i=b(p.schema,e,1);n.push(` body: ${i};`)}else if(u?.schema){let i=b(u.schema,e,1);n.push(` body: ${i};`)}else{let i=Object.values(a)[0];if(i?.schema){let m=b(i.schema,e,1);n.push(` body: ${m};`)}else n.push(" body?: any; // Request body from OpenAPI")}}return n.length===0?"":n.join(`
|
|
64
64
|
`)}function Ze(r,t,e={}){let n=[],o=t?.find(s=>s.operation?.operationId===r.operationName||s.operation?.operationId===r.operationName.toLowerCase()||s.verb===r.verb.toLowerCase()&&s.path===r.path);if(o?.operation?.responses){let s=o.operation.responses[200]||o.operation.responses[201];if(s?.content){let a=s.content["application/json"]||s.content["*/*"]||Object.values(s.content)[0];if(a?.schema){let p=Ye(a.schema,e);n.push(...p)}else n.push(" // Success response from OpenAPI"),n.push(" data?: any;")}}return n.length===0?"":n.join(`
|
|
65
|
-
`)}function Ye(r,t={}){let e=[];if(r.type==="object"&&r.properties){let n=r.required||[];Object.entries(r.properties).forEach(([o,s])=>{let p=n.includes(o)?"":"?",u=b(s,t,1),m=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;s.description&&e.push(` /** ${s.description}
|
|
65
|
+
`)}function Ye(r,t={}){let e=[];if(r.type==="object"&&r.properties){let n=r.required||[];Object.entries(r.properties).forEach(([o,s])=>{let p=n.includes(o)?"":"?",u=b(s,t,1),m=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;(s.title||s.description)&&e.push(` /** ${s.title??""} ${s.description??""}*/`),e.push(` ${m}${p}: ${u};`)})}return e}function b(r,t={},e=0){if(!r)return"any";if(r.$ref){let o=r.$ref;if(o.startsWith("#/components/schemas/")){let s=o.replace("#/components/schemas/",""),a=t[s]||s,u=`Schema.${ze(a)}`;return r.nullable?`${u} | null`:u}}let n;switch(r.type){case"string":r.enum?n=r.enum.map(a=>`"${a}"`).join(" | "):r.format==="binary"?n="Blob":n="string";break;case"number":case"integer":n="number";break;case"boolean":n="boolean";break;case"array":let o=r.items?b(r.items,t,e):"any";n=o.includes("|")?`(${o})[]`:`${o}[]`;break;case"object":if(r.properties){let a=Object.entries(r.properties);if(a.length===0)r.additionalProperties?n=`Record<string, ${r.additionalProperties===!0?"any":b(r.additionalProperties,t,e)}>`:n="{}";else{let p=" ".repeat(e+1),u=" ".repeat(e),i=[];a.forEach(([m,y])=>{let T=(r.required||[]).includes(m)?"":"?",v=b(y,t,e+1),O=/[^a-zA-Z0-9_$]/.test(m)?`"${m}"`:m;(y.title||y.description)&&i.push(`${p}/** ${y.title??""} ${y.description??""}*/`),i.push(`${p}${O}${T}: ${v};`)}),n=`{
|
|
66
66
|
${i.join(`
|
|
67
67
|
`)}
|
|
68
68
|
${u}}`}}else r.additionalProperties?n=`Record<string, ${r.additionalProperties===!0?"any":b(r.additionalProperties,t,e)}>`:n="any";break;default:n="any";break}return r.nullable?`${n} | null`:n}function ae(r,t={}){return r.schema?b(r.schema,t):"any"}c();function ce(r,t){let{groupKey:e,refetchOnMountOrArgChange:n=60}=t,o=e?`${e.charAt(0).toUpperCase()+e.slice(1)}QueryService`:"QueryService",s=e?`${e.charAt(0).toUpperCase()+e.slice(1)}ApiService`:"ApiService",a=r.filter(i=>i.isQuery).map(i=>`
|
|
@@ -171,7 +171,7 @@ ${r.map(a=>{let p=a.verb.toUpperCase()==="GET",u=!a.isVoidArg,i=a.hasRequestBody
|
|
|
171
171
|
export * from "./enhanceEndpoints";
|
|
172
172
|
export * from "./query.generated";
|
|
173
173
|
export * from "./types";
|
|
174
|
-
`}};c();function
|
|
174
|
+
`}};c();function le(){return`/* eslint-disable */
|
|
175
175
|
// [Warning] Generated automatically - do not edit manually
|
|
176
176
|
|
|
177
177
|
/**
|
|
@@ -184,13 +184,13 @@ export function withoutUndefined(obj?: Record<string, any>) {
|
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
`}function
|
|
187
|
+
`}function ge(r){return r.toLowerCase().replace(/_([a-z])/g,(t,e)=>e.toUpperCase())}c();function ye(r){let t=r.reduce((n,o)=>(n[o.groupKey]||(n[o.groupKey]=[]),n[o.groupKey].push({operationName:o.operationName,queryKeyName:o.queryKeyName}),n),{});return`// [Warning] Generated automatically - do not edit manually
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Cache keys enum for all API queries
|
|
191
191
|
*/
|
|
192
192
|
export enum ECacheTagTypes {
|
|
193
|
-
${Object.entries(t).map(([n,o])=>{let s=` // ${n.charAt(0).toUpperCase()+n.slice(1)} related cache keys`,a=o.map(p=>` ${p.queryKeyName} = '${
|
|
193
|
+
${Object.entries(t).map(([n,o])=>{let s=` // ${n.charAt(0).toUpperCase()+n.slice(1)} related cache keys`,a=o.map(p=>` ${p.queryKeyName} = '${ge(p.queryKeyName)}',`).join(`
|
|
194
194
|
`);return`${s}
|
|
195
195
|
${a}`}).join(`
|
|
196
196
|
|
|
@@ -198,11 +198,11 @@ ${a}`}).join(`
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export default ECacheTagTypes;
|
|
201
|
-
`}var w=class{_options;openApiService=new $;groupService=new N;fileWriterService=new A;allEndpointCacheKeys=[];openApiDoc=null;parserService=null;schemaInterfaces={};actualSchemaFile="";generatedContent={groups:[],commonTypes:"",componentSchema:"",doNotModify:"",utils:"",tagTypes:""};allTags=new Set;constructor(t){this._options=t}async generateAll(){return await this.prepare(),await this.generateApi(),this.generateCommonTypesContent(),this.generateSchemaContent(),this.generateUtilsContent(),this.generateDoNotModifyContent(),this.generatECacheTagTypesContent(),await this.release()}async prepare(){this.actualSchemaFile=this._options.schemaFile,this._options.remoteFile&&(this.actualSchemaFile=await this.openApiService.downloadSchema(this._options.remoteFile,this._options.schemaFile)),this.openApiDoc=await this.openApiService.getDocument(this.actualSchemaFile,this._options.httpResolverOptions),this.parserService=new R(this.openApiDoc,this._options),this.parserService.initialize();let t=this.parserService.getApiGenerator();this.schemaInterfaces=t.aliases.reduce((e,n)=>{if(de.isInterfaceDeclaration(n)||de.isTypeAliasDeclaration(n)){let o=n.name.text;return{...e,[o]:n}}return e},{})}async generateApi(){if(!this.openApiDoc||!this.parserService)throw new Error("\u8ACB\u5148\u8ABF\u7528 prepare() \u65B9\u6CD5");let t=this.openApiService.getPaths(this.openApiDoc),e=this.groupService.groupPaths(t,this._options.outputFiles);for(let n of Object.values(e))try{let o=await this.generateApiGroupContent(this._options,n);o.operationNames.length>0&&(this.generatedContent.groups.push({groupKey:n.groupKey,outputPath:n.outputPath,content:o}),o.tags&&Array.isArray(o.tags)&&o.tags.forEach(s=>this.allTags.add(s)))}catch(o){throw new Error(`\u7FA4\u7D44 ${n.groupKey} \u751F\u6210\u5931\u6557: ${o}`)}}async generatECacheTagTypesContent(){this.generatedContent.tagTypes=ye(this.allEndpointCacheKeys)}async generateCommonTypesContent(){this.generatedContent.commonTypes=oe()}async generateSchemaContent(){this.generatedContent.componentSchema=ie(this.schemaInterfaces)}async generateDoNotModifyContent(){this.generatedContent.doNotModify=se()}async generateUtilsContent(){this.generatedContent.utils=
|
|
201
|
+
`}var w=class{_options;openApiService=new $;groupService=new N;fileWriterService=new A;allEndpointCacheKeys=[];openApiDoc=null;parserService=null;schemaInterfaces={};actualSchemaFile="";generatedContent={groups:[],commonTypes:"",componentSchema:"",doNotModify:"",utils:"",tagTypes:""};allTags=new Set;constructor(t){this._options=t}async generateAll(){return await this.prepare(),await this.generateApi(),this.generateCommonTypesContent(),this.generateSchemaContent(),this.generateUtilsContent(),this.generateDoNotModifyContent(),this.generatECacheTagTypesContent(),await this.release()}async prepare(){this.actualSchemaFile=this._options.schemaFile,this._options.remoteFile&&(this.actualSchemaFile=await this.openApiService.downloadSchema(this._options.remoteFile,this._options.schemaFile)),this.openApiDoc=await this.openApiService.getDocument(this.actualSchemaFile,this._options.httpResolverOptions),this.parserService=new R(this.openApiDoc,this._options),this.parserService.initialize();let t=this.parserService.getApiGenerator();this.schemaInterfaces=t.aliases.reduce((e,n)=>{if(de.isInterfaceDeclaration(n)||de.isTypeAliasDeclaration(n)){let o=n.name.text;return{...e,[o]:n}}return e},{})}async generateApi(){if(!this.openApiDoc||!this.parserService)throw new Error("\u8ACB\u5148\u8ABF\u7528 prepare() \u65B9\u6CD5");let t=this.openApiService.getPaths(this.openApiDoc),e=this.groupService.groupPaths(t,this._options.outputFiles);for(let n of Object.values(e))try{let o=await this.generateApiGroupContent(this._options,n);o.operationNames.length>0&&(this.generatedContent.groups.push({groupKey:n.groupKey,outputPath:n.outputPath,content:o}),o.tags&&Array.isArray(o.tags)&&o.tags.forEach(s=>this.allTags.add(s)))}catch(o){throw new Error(`\u7FA4\u7D44 ${n.groupKey} \u751F\u6210\u5931\u6557: ${o}`)}}async generatECacheTagTypesContent(){this.generatedContent.tagTypes=ye(this.allEndpointCacheKeys)}async generateCommonTypesContent(){this.generatedContent.commonTypes=oe()}async generateSchemaContent(){this.generatedContent.componentSchema=ie(this.schemaInterfaces)}async generateDoNotModifyContent(){this.generatedContent.doNotModify=se()}async generateUtilsContent(){this.generatedContent.utils=le()}async release(){let t=[],e=[],n=[];try{for(let p of this.generatedContent.groups)try{if(p.content?.files){let u=F.dirname(p.outputPath),i=await this.fileWriterService.writeGroupFiles(u,{types:p.content.files.types,queryService:p.content.files.queryService,enhanceEndpoints:p.content.files.enhanceEndpoints,index:p.content.files.index});t.push(...i),n.push(p.groupKey)}}catch(u){e.push(new Error(`\u5BEB\u5165\u7FA4\u7D44 ${p.groupKey} \u5931\u6557: ${u}`))}let o=this.generatedContent.groups[0]?F.dirname(F.dirname(this.generatedContent.groups[0].outputPath)):"./generated";if(this.generatedContent.tagTypes||this.generatedContent.commonTypes||this.generatedContent.doNotModify||this.generatedContent.utils){let p=await this.fileWriterService.writeSharedFiles(o,{tagTypes:this.generatedContent.tagTypes||void 0,commonTypes:this.generatedContent.commonTypes||void 0,doNotModify:this.generatedContent.doNotModify||void 0,utils:this.generatedContent.utils||void 0});t.push(...p)}if(this.generatedContent.componentSchema){let p=await this.fileWriterService.writeSchemaFile(o,this.generatedContent.componentSchema);t.push(...p)}let s=this.generateMainIndex(n),a=await this.fileWriterService.writeFile(F.join(o,"index.ts"),s);t.push(a)}catch(o){e.push(o)}return{success:e.length===0,writtenFiles:t,errors:e,generatedGroups:n}}async generateApiGroupContent(t,e){let{outputFiles:n,...o}=t,s={...o,schemaFile:this.actualSchemaFile,outputFile:e.outputPath,sharedTypesFile:`${n.outputDir}/common-types.ts`,filterEndpoints:this.groupService.createGroupFilter(e.groupKey,n),queryMatch:n.queryMatch,groupKey:e.groupKey};if(!this.openApiDoc||!this.parserService)throw new Error("OpenAPI \u6587\u6A94\u672A\u521D\u59CB\u5316\uFF0C\u8ACB\u5148\u8ABF\u7528 prepare()");let p=await new q(this.parserService,s).generate();if(p.files&&"allEndpointCacheKeys"in p.files){let u=p.files.allEndpointCacheKeys;this.allEndpointCacheKeys.push(...u)}return p}generateMainIndex(t){return`/* eslint-disable */
|
|
202
202
|
// [Warning] Generated automatically - do not edit manually
|
|
203
203
|
|
|
204
204
|
${t.map(n=>`export * from "./${n}";`).concat(`
|
|
205
205
|
export * from "./tagTypes";`).join(`
|
|
206
206
|
`)}
|
|
207
|
-
`}};async function fe(r){let e=await new w(r).generateAll();if(!e.success&&e.errors.length>0)throw e.errors[0]}var he=Je(
|
|
207
|
+
`}};async function fe(r){let e=await new w(r).generateAll();if(!e.success&&e.errors.length>0)throw e.errors[0]}var he=Je(l);async function tt(r){let t=et(process.cwd(),r);process.chdir(Xe(t));let e=he(t),n=e.default??e;"outputFiles"in n||(console.error('Configuration must include "outputFiles" property. Single file output is no longer supported.'),process.exit(1)),n.outputFiles&&n.outputFiles.outputDir&&k(n.outputFiles.outputDir);try{console.log("Generating multiple outputs..."),await fe(n),console.log("Done")}catch(o){console.error("Generation failed:",o),process.exit(1)}}async function rt(){let r=he("../../package.json"),t=V();j.version(r.version).usage("<path/to/config.js>").parse(process.argv);let e=j.args[0];if(j.args.length===0){j.help();return}U(e),W(e,t),await tt(e)}rt().catch(r=>{console.error("CLI execution failed:",r),process.exit(1)});export{tt as runGeneration};
|
|
208
208
|
//# sourceMappingURL=cli.mjs.map
|