Skip to content

Commit

Permalink
feat: support Request,Response type export for pnpm use
Browse files Browse the repository at this point in the history
  • Loading branch information
liangskyli committed May 12, 2023
1 parent fc97fdf commit 5a6f931
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/http-mock-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"dependencies": {
"@liangskyli/openapi-gen-ts": "^1.0.1",
"@liangskyli/utils": "workspace:*",
"@types/express": "^4.17.17",
"@types/fs-extra": "^11.0.1",
"axios": "^1.4.0",
"commander": "^10.0.1",
Expand All @@ -49,8 +50,7 @@
"json-schema-faker": "^0.5.0-rcv.46"
},
"devDependencies": {
"@liangskyli/http-mock-gen": "workspace:*",
"@types/express": "^4.17.17"
"@liangskyli/http-mock-gen": "workspace:*"
},
"engines": {
"node": ">=16.10.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 自定义mock数据入口,文件不可删除。
import type { ICustomsData } from 'packageName';
import type { ICustomsData } from '{{packageName}}';
import { TemplateData } from './template-data';

const CustomData: ICustomsData = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ICustomsData, PartialAll, ICustomDataValue } from 'packageName';
import type { Request } from 'express';
import type { ICustomsData, PartialAll, ICustomDataValue, Request } from '{{packageName}}';
import type { IApi } from '{{IApiRelativePath}}';

export const TemplateData: ICustomsData<{
Expand Down
4 changes: 2 additions & 2 deletions packages/http-mock-gen/src/gen/file/gen-custom-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class GenCustomData {
IApiRelativePath = `./${IApiRelativePath}`;
}
return templateData
.replace('packageName', packageName)
.replace(/{{packageName}}/gi, packageName)
.replace(/{{IApiRelativePath}}/gi, winPath(IApiRelativePath))
.replace(/{{firstPath}}/gi, firstPath)
.replace(/{{responseData}}/gi, JSON.stringify(responseData));
Expand Down Expand Up @@ -74,7 +74,7 @@ export class GenCustomData {
.readFileSync(templatePath, {
encoding: 'utf-8',
})
.replace('packageName', packageName);
.replace(/{{packageName}}/gi, packageName);
const absolutePath = path.join(genCustomDataPath, 'index.ts');

writePrettierFile({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ export class GenInterfaceMockData {
}
const interfaceMockData: string[] = [];
interfaceMockData.push(`${fileTip}
import type { Request, Response } from "express";
import CustomData from "./custom-data";
import { getMockData } from "${packageName}";
import type { ICustomData, PartialAll } from "${packageName}";
import type { ICustomData, PartialAll, Request, Response } from "${packageName}";
import type { IApi } from '${IApiRelativePath}';
`);

Expand Down
4 changes: 3 additions & 1 deletion packages/http-mock-gen/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IAPIRequest, PartialAll } from '@liangskyli/openapi-gen-ts';
import type { Request } from 'express';
import type { Request, Response } from 'express';
import genMockData from './gen/index';
import type {
ICustomData,
Expand Down Expand Up @@ -47,5 +47,7 @@ export type {
ICustomsData,
IAPIRequest,
PartialAll,
Request,
Response,
};
export default genMockData;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type {
ICustomDataValue,
ICustomsData,
PartialAll,
Request,
} from '@liangskyli/http-mock-gen';
import type { Request } from 'express';
import type { IApi } from '../schema-api/interface-api';

export const TemplateData: ICustomsData<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type {
ICustomDataValue,
ICustomsData,
PartialAll,
Request,
} from '@liangskyli/http-mock-gen';
import type { Request } from 'express';
import type { IApi } from './schema-api/interface-api';

export const TemplateData: ICustomsData<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// This file is auto generated by @liangskyli/http-mock-gen, do not edit!
import type { ICustomData, PartialAll } from '@liangskyli/http-mock-gen';
import type {
ICustomData,
PartialAll,
Request,
Response,
} from '@liangskyli/http-mock-gen';
import { getMockData } from '@liangskyli/http-mock-gen';
import type { Request, Response } from 'express';
import CustomData from './custom-data';
import type { IApi } from './schema-api/interface-api';

Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a6f931

Please sign in to comment.