Skip to content

Commit

Permalink
fix(修改文件路径错误): 修改文件路径引入错误
Browse files Browse the repository at this point in the history
  • Loading branch information
袁金林 committed Apr 2, 2024
1 parent 4c9fd20 commit 98e1423
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# gen-api

[![gen-api-v1.0.0](https://img.shields.io/npm/dependency-version/%40yuanjinlin%2Fgen-api/%40yuanjinlin%2Fgen-api)](https://www.npmjs.com/package/@yuanjinlin/gen-api) ![Node Current](https://img.shields.io/node/v/%40yuanjinlin%2Fgen-api?logo=nodedotjs&color=blue)
![NPM Version](https://img.shields.io/npm/v/%40yuanjinlin%2Fgen-api?logo=npm) ![NPM License](https://img.shields.io/npm/l/%40yuanjinlin%2Fgen-api)

[![NPM Version](https://img.shields.io/npm/v/%40yuanjinlin%2Fgen-api?logo=npm)](https://www.npmjs.com/package/@yuanjinlin/gen-api) ![Node Current](https://img.shields.io/node/v/%40yuanjinlin%2Fgen-api?logo=nodedotjs&color=blue)
![NPM License](https://img.shields.io/npm/l/%40yuanjinlin%2Fgen-api)

## 介绍

Expand Down
33 changes: 33 additions & 0 deletions api.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
// api账户信息
users: {
userName: "",
passWord: "",
},
// 需要生成在线文档的网站
genApiName: "",
// api内网域名
domain: "",
// 生成api的文件夹
// apiFilePath: "api",
// 自定义apiName函数名
// getRequestFunctionName(apiName) {

// },
// 请求文件的路径
// importRequestName: "",
/* {
函数入参参数 可以函数配置
paramsName:'',
注释
annotation:'',
自定义的请求函数
requestFunc:
} */
// requestOpt: {

// },
// api项目配置项
// 配置选项:如果传的是{catIds:xxx,projectId:xxx}生成不同的分类接口,如果要生成当前项目下所有的接口只需要传项目id过来即可 projectId 是必填项
projects: [],
};
7 changes: 4 additions & 3 deletions bin/gen-api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const path = require("path");
const GenApi = require("../src/index");

const {
getFileData,
createfolderFile
Expand All @@ -10,15 +11,15 @@ const fs = require("fs");
let docsWebs = [];

docsWebs = fs
.readdirSync(path.join(process.cwd(), "src", "core"))
.readdirSync(path.join(__dirname, "../src", "core"))
.map((file) => {
return file.replace(".js", "")
});

// 获取配置文件的数据
const [configData, axiosData] = getFileData(
"src/config/api.config.js",
"src/config/axios.js"
"../config/api.config.js",
"../config/axios.js"
);

switch (process.argv[2]) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yuanjinlin/gen-api",
"version": "1.0.2",
"version": "1.0.3",
"description": "轻量化简易一键生成在线文档api接口,告别人力的copy",
"bin": {
"gen-api": "./bin/gen-api.js"
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require("path");
require("./utils/Generator");
const Yapi = require("./core/yapi");
const Yapi = require(path.join(__dirname,'core/yapi'));

module.exports = class GenApi {
constructor() {}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = {
},
getFileData(...args) {
return args.map((_path) => {
return fs.readFileSync(path.join(process.cwd(), _path), "utf-8");
return fs.readFileSync(path.join(__dirname, _path), "utf-8");
});
},
};

0 comments on commit 98e1423

Please sign in to comment.