sy-api-pro 1.0.3 → 1.0.5

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/bin/model.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface ConfigModels {
6
6
  branchId: number | undefined;
7
7
  creatBaseFile?: boolean;
8
8
  outputDirName?: string;
9
- apiBaseName?: string;
9
+ apiBaseName?: string | RegExp;
10
10
  ignoreParamsDTO?: string[];
11
11
  deleteParentDTO?: (string | RegExp)[];
12
12
  }[];
package/dist/index.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function(y,b){typeof exports=="object"&&typeof module!="undefined"?b(require("axios")):typeof define=="function"&&define.amd?define(["axios"],b):(y=typeof globalThis!="undefined"?globalThis:y||self,b(y.axios))})(this,function(y){"use strict";var v=(y,b,P)=>new Promise((A,p)=>{var h=m=>{try{N(P.next(m))}catch(j){p(j)}},a=m=>{try{N(P.throw(m))}catch(j){p(j)}},N=m=>m.done?A(m.value):Promise.resolve(m.value).then(h,a);N((P=P.apply(y,b)).next())});const b=c=>{var t;const n=(c||"").toLowerCase(),i={int:"number",integer:"number",long:"number",bigdecimal:"number",float:"number",double:"number",localdatetime:"string",date:"string",char:"string",byte:"string",short:"string",character:"string",string:"string",multipartfile:"string",boolean:"boolean",void:"void"},{listType:l}=((t=new RegExp("^list<(?<listType>.+)>$").exec(n))==null?void 0:t.groups)||{};return l?`Array<${i[l]||"any"}>`:i[n]||"any"},P=require("chalk"),A=Object.freeze({_getDesc(c){const n=(c.title||"").trim();return n?` // ${n}`:""},getInterface:function({list:c,config:{ignoreParamsDTO:n,deleteParentDTO:i}}){const l=c.map((s,o)=>s.level===0&&!n.includes(s.type)?o:null).filter(s=>s!==null);return(l.length>0?l.concat(c.length).map((s,o,r)=>c.slice(s,r[o+1])):[c]).filter(s=>s.length).map(s=>{const o=s[0];if(o.json){const r=o.json.split(`
2
- `);return r.forEach((e,d)=>{var q;const u=new RegExp('(?<space>\\s*)"(?<name>[a-zA-Z0-9]+)"\\s?:\\s*"(?<desc>[\\S\\s]*)"\\s*,?\\s*$');if(u.test(e)){const{space:x,name:B,desc:z}=((q=u.exec(e))==null?void 0:q.groups)||{},F=(B||"").trim(),L=(z||"").trim(),M=c.filter(D=>{const R=(D.name||"").trim()+(D.title||"").trim();return JSON.stringify(R).replace(/^"([\s\S]+)"$/,"$1")===F+L});if(M.length>=1){const[{type:D}]=M,R=o.required?"?":"",T=L?` // ${L}`:"";r[d]=`${x+F+R}: ${b(D)};${T}`}else console.log(P.yellowBright(`【warning】${F} 的类型错误,请手动处理`))}else r[d]=r[d].replace(/(\s*)"([a-zA-Z0-9]+)"\s?(:\s*[\S\s]+)$/,"$1$2$3").replace(/([\S\s]*)\[\s+{$/,"$1Array<{").replace(/([\S\s]*)}\s*][\S\s]*$/,"$1}>;")}),i.some(e=>{const d=Object.prototype.toString.call(e);if(d==="[object RegExp]")return e.test(o.type);if(d==="[object String]")return e===o.type})?r.slice(1,-1).join(`
3
- `):[` ${o.name}${o.required?"":"?"}: {${this._getDesc(o)}`,...r.slice(1,-1).map(e=>` ${e}`)," };"].join(`
4
- `)}else return` ${o.name}${o.required?"":"?"}: ${b(o.type)};${this._getDesc(o)}`})}}),p=require("fs"),h=require("path"),a=require("chalk");y.interceptors.response.use(c=>{var n,i;return(i=(n=c.data)==null?void 0:n.head)!=null&&i.successful?c:Promise.reject(c)},c=>{throw c});const N=class{constructor(n){this.config={api:"",customMethodName:"",projectId:void 0,branchId:void 0,methodId:void 0,outputPath:"",outputDirName:"",apiBaseName:"",ignoreParamsDTO:[],deleteParentDTO:[],apiHeaderTemplate:[]},this.apiList=[],this.enums=[],Object.assign(this.config,n),this.getApiData()}getApiData(){return v(this,null,function*(){const{api:n,branchId:i,projectId:l,outputDirName:t,outputPath:s,methodId:o}=this.config;try{const{data:r}=yield y.get(`${n}/api/project/getProjectWithBranchById?id=${l}`);this.config.outputPath=h.join(process.cwd(),s,t||r.body.name);const g=r.body.branchList.find(d=>d.id===i);if(g)console.log(a.blueBright(`【info】正在使用 branchName: ${g.name} branchId: ${i} methodId: ${o}`));else throw a.red(`【error】branchId ${i} 不存在`);const e=yield y.get(`${n}/api/method/getMethodById?id=${o}`);this.apiList=[e.data.body]}catch(r){console.log(a.red("【error】: 接口获取异常")),console.log(r);return}try{yield this.checkApiOutputDir()}catch(r){console.log(a.red("【error】: 检查输出目录异常")),console.log(r);return}try{yield this.createFile()}catch(r){console.log(a.red("【error】: createFile 异常")),console.log(r)}})}checkApiOutputDir(){const{outputPath:n}=this.config;console.log(a.blueBright(`【info】输出目录 ${n}`));try{p.statSync(n,{bigint:!0})}catch(i){p.mkdirSync(n,{recursive:!0})}}createFile(){return v(this,null,function*(){const{apiBaseName:n,outputPath:i,customMethodName:l}=this.config;this.apiList.forEach(t=>{var D,R,T;const s=f=>f.replace(/(-[a-z])|(^[a-z])/g,$=>$.replace("-","").toLocaleUpperCase()),o=t.path.startsWith("/")?t.path:`/${t.path}`,r=n.startsWith("/")?n:`/${n}`,g=new RegExp(`(${r})?(/)?(?<apiDirName>[a-zA-Z0-9_]+)/.*$`),{apiDirName:e}=((D=g.exec(o))==null?void 0:D.groups)||{},d=l||t.name,u=s(`${e}-`+d);try{p.statSync(h.join(i,e)).isDirectory()}catch(f){p.mkdirSync(h.join(i,e))}let q="";try{q=p.readFileSync(h.join(i,e,"models.ts")).toString()}catch(f){p.writeFileSync(h.join(i,`./${e}/models.ts`),"")}let x=[],B=[];try{const f=A.getInterface({list:t.paramList||[],config:this.config});x=(R=t.paramList)!=null&&R.length&&f.length?[q?"":"/* ************************************************ */",`/** ${t.title} RequestModel */`,`export interface ${u}ReqModel {`,...f,"}",""]:[];const $=A.getInterface({list:t.returnList||[],config:this.config});B=(T=t.returnList)!=null&&T.length&&$.length?[x.length?"":"/* ************************************************ */",`/** ${t.title} ResponseModel */`,`export interface ${u}ResModel {`,...$,"}",""]:[]}catch(f){throw console.log(a.red(`【error】类型生成失败 projectId: ${this.config.projectId} methodId: ${t.id} path: ${o}`)),a.red(f)}q.includes(`export interface ${u}ReqModel {`)?console.log(a.yellowBright(`【warning】./${e}/models.ts 已存在 ${u}ReqModel`)):x.length&&(p.appendFileSync(h.join(i,`./${e}/models.ts`),x.join(`
5
- `)),console.log(a.greenBright(`【success】./${e}/models.ts 成功添加 ${u}ReqModel`))),q.includes(`export interface ${u}ResModel {`)?console.log(a.yellowBright(`【warning】./${e}/models.ts 已存在 ${u}ResModel`)):B.length&&(p.appendFileSync(h.join(i,`./${e}/models.ts`),B.join(`
6
- `)),console.log(a.greenBright(`【success】./${e}/models.ts 成功添加 ${u}ResModel`)));const L=[t.title&&` /** ${t.title} */`,` ${d}(${x.length?`params: M.${u}ReqModel`:""}) {`,` return axios.${t.method.toLowerCase()}<ApiResponse<${B.length?`M.${u}ResModel`:"any"}>>(`,` \`\${ApiPrefix}${o}\`,`,x.length&&` ${["post","put","patch"].includes(t.method.toLowerCase())?"params":"{ params }"},`," );"," },"].filter(Boolean);/^[a-zA-Z]+$/.test((t.method||"").trim())||console.log(a.yellowBright(`【warning】接口请求类型异常,请手动补全 method:${t.method} path: ${o} methodId: ${this.config.methodId} projectId: ${this.config.projectId}`));const M=`${s(e)}Api`;try{const f=p.readFileSync(h.join(i,e,"api.ts")).toString(),$=f.split(`
7
- `);if(!f.includes("import"))throw Error("null");if(f.includes(` ${d}(`)){const w=$.findIndex(I=>I.includes(` ${d}(`)),_=$.findIndex((I,k)=>k>w&&I===" },");console.log(a.yellowBright([`【warning】./${e}/api.ts 已存在api`,...$.slice(w,_+1).map(I=>` ${I}`)].join(`
8
- `))),console.log(a.yellowBright(`【warning】当前需要生成的 path 为 ${o}, methodName 为 ${d}`))}else $.splice($.map(w=>w.includes("}")).lastIndexOf(!0),0,L.join(`
9
- `)),p.writeFileSync(h.join(i,`./${e}/api.ts`),$.join(`
10
- `)),console.log(a.greenBright(`【success】./${e}/api.ts 成功添加 ${M}.${d}`))}catch(f){const $=["import { axios, ApiResponse } from '../axios';","","import * as M from './models';","import { ApiPrefix } from '../apiPrefix';","","export * from './models';"],{apiHeaderTemplate:w}=this.config;p.writeFileSync(h.join(i,`./${e}/api.ts`),[...w!=null&&w.length?w:$,"",`export const ${M} = {`,...L,"};",""].join(`
11
- `)),console.log(a.greenBright(`【success】./${e}/api.ts 成功添加 ${M}.${d}`));const _=p.readFileSync(h.join(i,"index.ts")).toString();if(!_.includes(`export * from './${e}/api'`)){const I=_.split(`
12
- `);I.push(`export * from './${e}/api';`);const k=I.slice(1).filter(Boolean);k.sort((C,E)=>C.localeCompare(E)),p.writeFileSync(h.join(i,"index.ts"),[I[0]||"","",...k,""].join(`
13
- `))}}})})}},m=require("fs"),j=require("path"),{program:O}=require("commander"),S=require("chalk");O.name("sy-api-pro").version(require(j.resolve(__dirname,"../package.json")).version),O.command("init").description("初始化配置文件").option("-p, --path <char>","","./src/apis").action((c,n,i)=>{const l=j.join(process.cwd(),c.path),t=j.join(l,".api-config.ts");try{if(m.existsSync(l)||m.mkdirSync(l),m.existsSync(t))return console.log(S.yellowBright(`【warning】: ${t} 配置文件已存在`));const s=m.readFileSync(j.join(__dirname,"../template/config/.api-config.ts"));m.writeFileSync(t,s),console.log(S.greenBright(`【success】: 配置文件已生成, 路径:${t}`))}catch(s){console.log(S.red("【error】: 配置文件生成异常")),console.log(s)}}),O.command("create").description("生成api文件及类型定义").requiredOption("-i, --id <id>","methodId").option("-n, --name <name>","customMethodName").requiredOption("--config <filePath>","configFilePath").requiredOption("--project-id <id>","projectId").action((c,n,i)=>{const{id:l,name:t,config:s,projectId:o}=c;if(!l||!/^\d+$/.test(l))throw S.red("【error】请传入正确的 id");const r=require(j.resolve(process.cwd(),s)),g=(r.projects||[]).find(e=>+e.projectId==+o);if(g){if(!g.branchId)throw S.red("【error】请传入正确的 branchId");if(!r.api)throw S.red("【error】请传入正确的 api");new N({api:r.api,methodId:l,customMethodName:t,outputPath:r.outputPath||"./src/apis",projectId:g.projectId,branchId:+g.branchId,outputDirName:g.outputDirName||"",apiBaseName:g.apiBaseName||"",ignoreParamsDTO:g.ignoreParamsDTO||[],deleteParentDTO:g.deleteParentDTO||[],apiHeaderTemplate:r.apiHeaderTemplate||[]})}else console.log(S.red(`【error】config 配置文件中 projects 未包含传入的 projectId ${o}`))}),O.parse()});
1
+ (function(w,q){typeof exports=="object"&&typeof module!="undefined"?q(require("axios")):typeof define=="function"&&define.amd?define(["axios"],q):(w=typeof globalThis!="undefined"?globalThis:w||self,q(w.axios))})(this,function(w){"use strict";var v=(w,q,B)=>new Promise((A,s)=>{var d=g=>{try{N(B.next(g))}catch(I){s(I)}},c=g=>{try{N(B.throw(g))}catch(I){s(I)}},N=g=>g.done?A(g.value):Promise.resolve(g.value).then(d,c);N((B=B.apply(w,q)).next())});const q=a=>{var h;const t=(a||"").toLowerCase(),o={int:"number",integer:"number",long:"number",bigdecimal:"number",float:"number",double:"number",localdatetime:"string",date:"string",char:"string",byte:"string",short:"string",character:"string",string:"string",multipartfile:"string",boolean:"boolean",void:"void"},{listType:l}=((h=new RegExp("^list<(?<listType>.+)>$").exec(t))==null?void 0:h.groups)||{};return l?`Array<${o[l]||"any"}>`:o[t]||"any"},B=require("chalk"),A=Object.freeze({_getDesc(a){const t=(a.title||"").trim();return t?` // ${t}`:""},getInterface:function({list:a,config:{ignoreParamsDTO:t,deleteParentDTO:o}}){const l=a.map((n,i)=>n.level===0?i:null).filter(n=>n!==null);return(l.length>0?l.concat(a.length).map((n,i,e)=>a.slice(n,e[i+1])):[a]).filter(n=>n.length).filter(n=>!t.includes(n[0].type)).map(n=>{const i=n[0];if(i.json){const e=i.json.split(`
2
+ `);return e.forEach((p,y)=>{var r;const _=new RegExp('(?<space>\\s*)"(?<name>[a-zA-Z0-9]+)"\\s?:\\s*"(?<desc>[\\S\\s]*)"\\s*,?\\s*$');if(_.test(p)){const{space:b,name:$,desc:F}=((r=_.exec(p))==null?void 0:r.groups)||{},j=($||"").trim(),P=(F||"").trim(),z=n.filter(R=>{const M=(R.name||"").trim()+(R.title||"").trim();return JSON.stringify(M).replace(/^"([\s\S]+)"$/,"$1")===j+P});if(z.length>=1){const[{type:R}]=z,M=i.required?"?":"",L=P?` // ${P}`:"";e[y]=`${b+j+M}: ${q(R)};${L}`}else console.log(B.yellowBright(`【warning】${j} 的类型错误,请手动处理`))}else e[y]=e[y].replace(/(\s*)"([a-zA-Z0-9]+)"\s?(:\s*[\S\s]+)$/,"$1$2$3").replace(/([\S\s]*)\[\s+{$/,"$1Array<{").replace(/([\S\s]*)}\s*][\S\s]*$/,"$1}>;")}),o.some(p=>{const y=Object.prototype.toString.call(p);if(y==="[object RegExp]")return p.test(i.type);if(y==="[object String]")return p===i.type})?e.slice(1,-1).join(`
3
+ `):[` ${i.name}${i.required?"":"?"}: {${this._getDesc(i)}`,...e.slice(1,-1).map(p=>` ${p}`)," };"].join(`
4
+ `)}else return` ${i.name}${i.required?"":"?"}: ${q(i.type)};${this._getDesc(i)}`})}}),s=require("fs"),d=require("path"),c=require("chalk");w.interceptors.response.use(a=>{var t,o;return(o=(t=a.data)==null?void 0:t.head)!=null&&o.successful?a:Promise.reject(a)},a=>{throw a});const N=class{constructor(t){this.config={api:"",customMethodName:"",projectId:void 0,branchId:void 0,methodId:void 0,outputPath:"",outputDirName:"",apiBaseName:"",ignoreParamsDTO:[],deleteParentDTO:[],apiHeaderTemplate:[]},this.apiList=[],this.enums=[],Object.assign(this.config,t),this.getApiData()}getApiData(){return v(this,null,function*(){const{api:t,branchId:o,projectId:l,outputDirName:h,outputPath:n,methodId:i}=this.config;try{const{data:e}=yield w.get(`${t}/api/project/getProjectWithBranchById?id=${l}`);this.config.outputPath=d.join(process.cwd(),n,h||e.body.name);const m=e.body.branchList.find(y=>y.id===o);if(m)console.log(c.blueBright(`【info】正在使用 branchName: ${m.name} branchId: ${o} methodId: ${i}`));else throw c.red(`【error】branchId ${o} 不存在`);const p=yield w.get(`${t}/api/method/getMethodById?id=${i}`);this.apiList=[p.data.body]}catch(e){console.log(c.red("【error】: 接口获取异常")),console.log(e);return}try{yield this.checkApiOutputDir()}catch(e){console.log(c.red("【error】: 检查输出目录异常")),console.log(e);return}try{yield this.createFile()}catch(e){console.log(c.red("【error】: createFile 异常")),console.log(e)}})}checkApiOutputDir(){const{outputPath:t}=this.config;console.log(c.blueBright(`【info】输出目录 ${t}`));try{s.statSync(t,{bigint:!0})}catch(o){s.mkdirSync(t,{recursive:!0})}}creatBaseFile(){return v(this,null,function*(){const{outputPath:t}=this.config,o=d.join(__dirname,"../template/api"),l=s.readdirSync(o),h=s.readdirSync(t);for(const n of l)if(!h.includes(n))try{const i=s.readFileSync(d.join(o,n));s.writeFileSync(d.join(t,n),i)}catch(i){console.log(c.red("【error】: 基础文件生成异常")),console.log(i)}})}createFile(){return v(this,null,function*(){var h,n,i;const{apiBaseName:t,outputPath:o,customMethodName:l}=this.config;for(const e of this.apiList){const m=u=>u.replace(/(-[a-z])|(^[a-z])/g,f=>f.replace("-","").toLocaleUpperCase()),p=e.path.startsWith("/")?e.path:`/${e.path}`,y=typeof t=="string"?t.startsWith("/")?t:`/${t}`:t,_=p.replace(y,""),{apiDirName:r}=((h=new RegExp("(/)?(?<apiDirName>[a-zA-Z0-9_]+)/.*$").exec(_))==null?void 0:h.groups)||{},b=l||e.name,$=m(`${r}-`+b);try{s.statSync(d.join(o,r)).isDirectory()}catch(u){s.mkdirSync(d.join(o,r))}let F="";try{F=s.readFileSync(d.join(o,r,"models.ts")).toString()}catch(u){s.writeFileSync(d.join(o,`./${r}/models.ts`),"")}let j=[],P=[];try{const u=A.getInterface({list:e.paramList||[],config:this.config});j=(n=e.paramList)!=null&&n.length&&u.length?[F?"":"/* ************************************************ */",`/** ${e.title} RequestModel */`,`export interface ${$}ReqModel {`,...u,"}",""]:[];const f=A.getInterface({list:e.returnList||[],config:this.config});P=(i=e.returnList)!=null&&i.length&&f.length?[j.length?"":"/* ************************************************ */",`/** ${e.title} ResponseModel */`,`export interface ${$}ResModel {`,...f,"}",""]:[]}catch(u){throw console.log(c.red(`【error】类型生成失败 projectId: ${this.config.projectId} methodId: ${e.id} path: ${p}`)),c.red(u)}F.includes(`export interface ${$}ReqModel {`)?console.log(c.yellowBright(`【warning】./${r}/models.ts 已存在 ${$}ReqModel`)):j.length&&(s.appendFileSync(d.join(o,`./${r}/models.ts`),j.join(`
5
+ `)),console.log(c.greenBright(`【success】./${r}/models.ts 成功添加 ${$}ReqModel`))),F.includes(`export interface ${$}ResModel {`)?console.log(c.yellowBright(`【warning】./${r}/models.ts 已存在 ${$}ResModel`)):P.length&&(s.appendFileSync(d.join(o,`./${r}/models.ts`),P.join(`
6
+ `)),console.log(c.greenBright(`【success】./${r}/models.ts 成功添加 ${$}ResModel`)));const M=[e.title&&` /** ${e.title} */`,` ${b}(${j.length?`params: M.${$}ReqModel`:""}) {`,` return axios.${e.method.toLowerCase()}<ApiResponse<${P.length?`M.${$}ResModel`:"any"}>>(`,` \`\${ApiPrefix}${p}\`,`,j.length&&` ${["post","put","patch"].includes(e.method.toLowerCase())?"params":"{ params }"},`," );"," },"].filter(Boolean);/^[a-zA-Z]+$/.test((e.method||"").trim())||console.log(c.yellowBright(`【warning】接口请求类型异常,请手动补全 method:${e.method} path: ${p} methodId: ${this.config.methodId} projectId: ${this.config.projectId}`));const L=`${m(r)}Api`;try{const u=s.readFileSync(d.join(o,r,"api.ts")).toString(),f=u.split(`
7
+ `);if(!u.includes("import"))throw Error("null");if(u.includes(` ${b}(`)){const S=f.findIndex(x=>x.includes(` ${b}(`)),T=f.findIndex((x,k)=>k>S&&x===" },");console.log(c.yellowBright([`【warning】./${r}/api.ts 已存在api`,...f.slice(S,T+1).map(x=>` ${x}`)].join(`
8
+ `))),console.log(c.yellowBright(`【warning】当前需要生成的 path 为 ${p}, methodName 为 ${b}`))}else f.splice(f.map(S=>S.includes("}")).lastIndexOf(!0),0,M.join(`
9
+ `)),s.writeFileSync(d.join(o,`./${r}/api.ts`),f.join(`
10
+ `)),console.log(c.greenBright(`【success】./${r}/api.ts 成功添加 ${L}.${b}`))}catch(u){yield this.creatBaseFile();const f=["import { axios, ApiResponse } from '../axios';","","import * as M from './models';","import { ApiPrefix } from '../apiPrefix';","","export * from './models';"],{apiHeaderTemplate:S}=this.config;s.writeFileSync(d.join(o,`./${r}/api.ts`),[...S!=null&&S.length?S:f,"",`export const ${L} = {`,...M,"};",""].join(`
11
+ `)),console.log(c.greenBright(`【success】./${r}/api.ts 成功添加 ${L}.${b}`));const T=s.readFileSync(d.join(o,"index.ts")).toString();if(!T.includes(`export * from './${r}/api'`)){const x=T.split(`
12
+ `);x.push(`export * from './${r}/api';`);const k=x.slice(1).filter(Boolean);k.sort((C,E)=>C.localeCompare(E)),s.writeFileSync(d.join(o,"index.ts"),[x[0]||"","",...k,""].join(`
13
+ `))}}}})}},g=require("fs"),I=require("path"),{program:O}=require("commander"),D=require("chalk");O.name("sy-api-pro").version(require(I.resolve(__dirname,"../package.json")).version),O.command("init").description("初始化配置文件").option("-p, --path <char>","","./src/apis").action((a,t,o)=>{const l=I.join(process.cwd(),a.path),h=I.join(l,".api-config.ts");try{if(g.existsSync(l)||g.mkdirSync(l),g.existsSync(h))return console.log(D.yellowBright(`【warning】: ${h} 配置文件已存在`));const n=g.readFileSync(I.join(__dirname,"../template/config/.api-config.ts"));g.writeFileSync(h,n),console.log(D.greenBright(`【success】: 配置文件已生成, 路径:${h}`))}catch(n){console.log(D.red("【error】: 配置文件生成异常")),console.log(n)}}),O.command("create").description("生成api文件及类型定义").requiredOption("-i, --id <id>","methodId").option("-n, --name <name>","customMethodName").requiredOption("--config <filePath>","configFilePath").requiredOption("--project-id <id>","projectId").action((a,t,o)=>{const{id:l,name:h,config:n,projectId:i}=a;if(!l||!/^\d+$/.test(l))throw D.red("【error】请传入正确的 id");const e=require(I.resolve(process.cwd(),n)),m=(e.projects||[]).find(p=>+p.projectId==+i);if(m){if(!m.branchId)throw D.red("【error】请传入正确的 branchId");if(!e.api)throw D.red("【error】请传入正确的 api");new N({api:e.api,methodId:l,customMethodName:h,outputPath:e.outputPath||"./src/apis",projectId:m.projectId,branchId:+m.branchId,outputDirName:m.outputDirName||"",apiBaseName:m.apiBaseName||"",ignoreParamsDTO:m.ignoreParamsDTO||[],deleteParentDTO:m.deleteParentDTO||[],apiHeaderTemplate:e.apiHeaderTemplate||[]})}else console.log(D.red(`【error】config 配置文件中 projects 未包含传入的 projectId ${i}`))}),O.parse()});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sy-api-pro",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "main": "./bin/index.ts",
5
5
  "types": "./bin/model.d.ts",
6
6
  "bin": {
@@ -21,23 +21,26 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "build": "vite build",
24
+ "api:init": "ts-node src/index.ts init -p ./src/dist/",
25
+ "api0": "ts-node src/index.ts create --config ./src/.api-config.ts --project-id 801 -i 1885221",
24
26
  "api1": "ts-node src/index.ts create --config ./src/.api-config.ts --project-id 801 -i 1885357",
25
27
  "api2": "ts-node src/index.ts create --config ./src/.api-config.ts --project-id 801 -i 1758417",
26
28
  "api3": "ts-node src/index.ts create --config ./src/.api-config.ts --project-id 801 -i 199003",
27
- "test:dist-init": "ts-node bin/index.ts init",
28
- "test:dist-create2": "ts-node bin/index.ts create --config ./src/.api-config.ts --project-id 801"
29
+ "test:dist-init": "ts-node bin/index.ts init -p ./src/dist/",
30
+ "test:dist-create1": "ts-node bin/index.ts create --config ./src/dist/.api-config.ts --project-id 801 -i 1885221",
31
+ "test:dist-create2": "ts-node bin/index.ts create --config ./src/dist/.api-config.ts --project-id 801 -i 1885357"
29
32
  },
30
33
  "description": "...",
31
34
  "dependencies": {
32
- "@types/node": "^20.1.5",
33
- "axios": "^1.4.0",
35
+ "@types/node": "^20.12.12",
36
+ "axios": "^1.6.8",
34
37
  "chalk": "^4.1.2",
35
- "commander": "^10.0.1",
36
- "ts-node": "^10.9.1",
37
- "typescript": "^5.0.4"
38
+ "commander": "^12.0.0",
39
+ "ts-node": "^10.9.2",
40
+ "typescript": "^5.4.5"
38
41
  },
39
42
  "devDependencies": {
40
43
  "rollup-plugin-terser": "^7.0.2",
41
- "vite": "^4.3.6"
44
+ "vite": "^5.2.11"
42
45
  }
43
46
  }
@@ -20,8 +20,6 @@ axios.interceptors.request.use((config) => {
20
20
  }, error => Promise.reject(error));
21
21
 
22
22
  axios.interceptors.response.use((response: AxiosResponse) => {
23
- // if (!response.config.url?.startsWith(ApiPrefix)) return response;
24
- //
25
23
  // if (response.data?.success) {
26
24
  // return response;
27
25
  // }
@@ -1,3 +1 @@
1
1
  import './axios';
2
-
3
- export * from './index/api';