chapanda-mock-service 2.0.0-beta.2
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/dist/app.cjs +90 -0
- package/dist/app.d.cts +1 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +93 -0
- package/dist/app.js.map +1 -0
- package/dist/chunk.cjs +34 -0
- package/dist/index.cjs +50 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.cts +34 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vite.cjs +57 -0
- package/dist/vite.d.cts +7 -0
- package/dist/vite.d.cts.map +1 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +53 -0
- package/dist/vite.js.map +1 -0
- package/package.json +61 -0
package/dist/app.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const require_chunk = require('./chunk.cjs');
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
fs = require_chunk.__toESM(fs, 1);
|
|
4
|
+
let express = require("express");
|
|
5
|
+
express = require_chunk.__toESM(express, 1);
|
|
6
|
+
let body_parser = require("body-parser");
|
|
7
|
+
body_parser = require_chunk.__toESM(body_parser, 1);
|
|
8
|
+
|
|
9
|
+
//#region src/utils.ts
|
|
10
|
+
const METHODS_MAP = {
|
|
11
|
+
POST: "post",
|
|
12
|
+
GET: "get",
|
|
13
|
+
DELETE: "delete",
|
|
14
|
+
PUT: "put"
|
|
15
|
+
};
|
|
16
|
+
function handleResult(router, result) {
|
|
17
|
+
const { path, data } = result;
|
|
18
|
+
const methods = result.method || result.methods;
|
|
19
|
+
if (!methods) {
|
|
20
|
+
console.error(`Methods did not exist. Please make sure your method is one of ${Object.keys(METHODS_MAP).join(" ")}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!data) {
|
|
24
|
+
console.error(`Data did not exists. Please make sure your data is correct`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const method = METHODS_MAP[methods];
|
|
28
|
+
if (!method) {
|
|
29
|
+
console.error(`Unknown method: ${methods}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
router[method](path, (req, res) => {
|
|
33
|
+
if (typeof data === "function") res.json(data(req));
|
|
34
|
+
else res.json(data);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function createRoutes(router, p) {
|
|
38
|
+
const stats = fs.default.statSync(p);
|
|
39
|
+
if (stats.isDirectory()) fs.default.readdirSync(p).forEach((item) => {
|
|
40
|
+
createRoutes(router, `${p}/${item}`);
|
|
41
|
+
});
|
|
42
|
+
else if (stats.isFile()) {
|
|
43
|
+
delete require.cache[require.resolve(p)];
|
|
44
|
+
let results = require(p);
|
|
45
|
+
if (results && typeof results === "object" && "default" in results) results = results.default;
|
|
46
|
+
if (Array.isArray(results)) results.forEach((result) => {
|
|
47
|
+
handleResult(router, result);
|
|
48
|
+
});
|
|
49
|
+
else if (results && typeof results === "object") handleResult(router, results);
|
|
50
|
+
else throw new Error(`Mock File Content Error...`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/app.ts
|
|
56
|
+
const app = (0, express.default)();
|
|
57
|
+
const router = express.default.Router();
|
|
58
|
+
app.use(body_parser.default.json());
|
|
59
|
+
app.use(body_parser.default.urlencoded({ extended: false }));
|
|
60
|
+
app.use((req, res, next) => {
|
|
61
|
+
res.header("Access-Control-Allow-Origin", "*");
|
|
62
|
+
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH");
|
|
63
|
+
res.header("Access-Control-Allow-Headers", req.headers["access-control-request-headers"] || "");
|
|
64
|
+
res.header("Access-Control-Allow-Credentials", "true");
|
|
65
|
+
res.header("Access-Control-Max-Age", "3600");
|
|
66
|
+
next();
|
|
67
|
+
});
|
|
68
|
+
app.options("*", (req, res) => {
|
|
69
|
+
res.status(204).send();
|
|
70
|
+
});
|
|
71
|
+
process.on("message", (message) => {
|
|
72
|
+
const { source, port } = message;
|
|
73
|
+
console.log(`Options get From Parents`, source, port);
|
|
74
|
+
createRoutes(router, source);
|
|
75
|
+
app.use(router);
|
|
76
|
+
app.listen(port, () => {
|
|
77
|
+
console.log(`Mock Server Listen ${port} is Running`);
|
|
78
|
+
});
|
|
79
|
+
const parentPid = process.ppid;
|
|
80
|
+
setInterval(() => {
|
|
81
|
+
try {
|
|
82
|
+
process.kill(parentPid, 0);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.log("Parent process exited, shutting down mock server");
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
}, 1e3);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
//#endregion
|
package/dist/app.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import express from "express";
|
|
4
|
+
import bodyParser from "body-parser";
|
|
5
|
+
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/utils.ts
|
|
11
|
+
const METHODS_MAP = {
|
|
12
|
+
POST: "post",
|
|
13
|
+
GET: "get",
|
|
14
|
+
DELETE: "delete",
|
|
15
|
+
PUT: "put"
|
|
16
|
+
};
|
|
17
|
+
function handleResult(router, result) {
|
|
18
|
+
const { path, data } = result;
|
|
19
|
+
const methods = result.method || result.methods;
|
|
20
|
+
if (!methods) {
|
|
21
|
+
console.error(`Methods did not exist. Please make sure your method is one of ${Object.keys(METHODS_MAP).join(" ")}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!data) {
|
|
25
|
+
console.error(`Data did not exists. Please make sure your data is correct`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const method = METHODS_MAP[methods];
|
|
29
|
+
if (!method) {
|
|
30
|
+
console.error(`Unknown method: ${methods}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
router[method](path, (req, res) => {
|
|
34
|
+
if (typeof data === "function") res.json(data(req));
|
|
35
|
+
else res.json(data);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createRoutes(router, p) {
|
|
39
|
+
const stats = fs.statSync(p);
|
|
40
|
+
if (stats.isDirectory()) fs.readdirSync(p).forEach((item) => {
|
|
41
|
+
createRoutes(router, `${p}/${item}`);
|
|
42
|
+
});
|
|
43
|
+
else if (stats.isFile()) {
|
|
44
|
+
delete __require.cache[__require.resolve(p)];
|
|
45
|
+
let results = __require(p);
|
|
46
|
+
if (results && typeof results === "object" && "default" in results) results = results.default;
|
|
47
|
+
if (Array.isArray(results)) results.forEach((result) => {
|
|
48
|
+
handleResult(router, result);
|
|
49
|
+
});
|
|
50
|
+
else if (results && typeof results === "object") handleResult(router, results);
|
|
51
|
+
else throw new Error(`Mock File Content Error...`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/app.ts
|
|
57
|
+
const app = express();
|
|
58
|
+
const router = express.Router();
|
|
59
|
+
app.use(bodyParser.json());
|
|
60
|
+
app.use(bodyParser.urlencoded({ extended: false }));
|
|
61
|
+
app.use((req, res, next) => {
|
|
62
|
+
res.header("Access-Control-Allow-Origin", "*");
|
|
63
|
+
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH");
|
|
64
|
+
res.header("Access-Control-Allow-Headers", req.headers["access-control-request-headers"] || "");
|
|
65
|
+
res.header("Access-Control-Allow-Credentials", "true");
|
|
66
|
+
res.header("Access-Control-Max-Age", "3600");
|
|
67
|
+
next();
|
|
68
|
+
});
|
|
69
|
+
app.options("*", (req, res) => {
|
|
70
|
+
res.status(204).send();
|
|
71
|
+
});
|
|
72
|
+
process.on("message", (message) => {
|
|
73
|
+
const { source, port } = message;
|
|
74
|
+
console.log(`Options get From Parents`, source, port);
|
|
75
|
+
createRoutes(router, source);
|
|
76
|
+
app.use(router);
|
|
77
|
+
app.listen(port, () => {
|
|
78
|
+
console.log(`Mock Server Listen ${port} is Running`);
|
|
79
|
+
});
|
|
80
|
+
const parentPid = process.ppid;
|
|
81
|
+
setInterval(() => {
|
|
82
|
+
try {
|
|
83
|
+
process.kill(parentPid, 0);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log("Parent process exited, shutting down mock server");
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
}, 1e3);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { };
|
|
93
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","names":[],"sources":["../src/utils.ts","../src/app.ts"],"sourcesContent":["import fs from 'fs'\nimport type { Router, Request, Response } from 'express'\nimport type { MockRoute, HttpMethod } from './types'\n\nconst METHODS_MAP: Record<string, HttpMethod> = {\n POST: 'post',\n GET: 'get',\n DELETE: 'delete',\n PUT: 'put',\n}\n\nfunction handleResult(router: Router, result: MockRoute): void {\n const { path, data } = result\n const methods = result.method || result.methods\n if (!methods) {\n console.error(\n `Methods did not exist. Please make sure your method is one of ${Object.keys(\n METHODS_MAP,\n ).join(' ')}`,\n )\n return\n }\n\n if (!data) {\n console.error(`Data did not exists. Please make sure your data is correct`)\n return\n }\n\n const method = METHODS_MAP[methods]\n if (!method) {\n console.error(`Unknown method: ${methods}`)\n return\n }\n\n router[method](path, (req: Request, res: Response) => {\n if (typeof data === 'function') {\n res.json(data(req))\n } else {\n res.json(data)\n }\n })\n}\n\nexport function createRoutes(router: Router, p: string): void {\n const stats = fs.statSync(p)\n\n if (stats.isDirectory()) {\n fs.readdirSync(p).forEach((item) => {\n createRoutes(router, `${p}/${item}`)\n })\n } else if (stats.isFile()) {\n // Clear require cache for hot reload\n delete require.cache[require.resolve(p)]\n\n let results = require(p)\n\n // Handle ESM module default export\n if (results && typeof results === 'object' && 'default' in results) {\n results = results.default\n }\n\n if (Array.isArray(results)) {\n (results as MockRoute[]).forEach((result) => {\n handleResult(router, result)\n })\n } else if (results && typeof results === 'object') {\n handleResult(router, results as MockRoute)\n } else {\n throw new Error(`Mock File Content Error...`)\n }\n }\n}\n","import express from 'express'\nimport bodyParser from 'body-parser'\nimport type { IpcMessage } from './types'\nimport { createRoutes } from './utils'\n\nconst app = express()\nconst router = express.Router()\n\napp.use(bodyParser.json())\napp.use(\n bodyParser.urlencoded({\n extended: false,\n }),\n)\n\n// CORS headers\napp.use((req, res, next) => {\n res.header('Access-Control-Allow-Origin', '*')\n res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, PATCH')\n res.header('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || '')\n res.header('Access-Control-Allow-Credentials', 'true')\n res.header('Access-Control-Max-Age', '3600')\n next()\n})\n\n// Handle OPTIONS requests\napp.options('*', (req, res) => {\n res.status(204).send()\n})\n\n// Receive config from parent process via IPC\nprocess.on('message', (message: IpcMessage) => {\n const { source, port } = message\n console.log(`Options get From Parents`, source, port)\n\n createRoutes(router, source)\n app.use(router)\n\n app.listen(port, () => {\n console.log(`Mock Server Listen ${port} is Running`)\n })\n\n // 监听父进程退出\n const parentPid = process.ppid;\n setInterval(() => {\n try {\n process.kill(parentPid, 0); // 检查父进程是否存活\n } catch (e) {\n console.log('Parent process exited, shutting down mock server');\n process.exit(0);\n }\n }, 1000);\n\n})\n"],"mappings":";;;;;;;;;;AAIA,MAAM,cAA0C;CAC9C,MAAM;CACN,KAAK;CACL,QAAQ;CACR,KAAK;CACN;AAED,SAAS,aAAa,QAAgB,QAAyB;CAC7D,MAAM,EAAE,MAAM,SAAS;CACvB,MAAM,UAAU,OAAO,UAAU,OAAO;AACxC,KAAI,CAAC,SAAS;AACZ,UAAQ,MACN,iEAAiE,OAAO,KACtE,YACD,CAAC,KAAK,IAAI,GACZ;AACD;;AAGF,KAAI,CAAC,MAAM;AACT,UAAQ,MAAM,6DAA6D;AAC3E;;CAGF,MAAM,SAAS,YAAY;AAC3B,KAAI,CAAC,QAAQ;AACX,UAAQ,MAAM,mBAAmB,UAAU;AAC3C;;AAGF,QAAO,QAAQ,OAAO,KAAc,QAAkB;AACpD,MAAI,OAAO,SAAS,WAClB,KAAI,KAAK,KAAK,IAAI,CAAC;MAEnB,KAAI,KAAK,KAAK;GAEhB;;AAGJ,SAAgB,aAAa,QAAgB,GAAiB;CAC5D,MAAM,QAAQ,GAAG,SAAS,EAAE;AAE5B,KAAI,MAAM,aAAa,CACrB,IAAG,YAAY,EAAE,CAAC,SAAS,SAAS;AAClC,eAAa,QAAQ,GAAG,EAAE,GAAG,OAAO;GACpC;UACO,MAAM,QAAQ,EAAE;AAEzB,mBAAe,gBAAc,QAAQ,EAAE;EAEvC,IAAI,oBAAkB,EAAE;AAGxB,MAAI,WAAW,OAAO,YAAY,YAAY,aAAa,QACzD,WAAU,QAAQ;AAGpB,MAAI,MAAM,QAAQ,QAAQ,CACxB,CAAC,QAAwB,SAAS,WAAW;AAC3C,gBAAa,QAAQ,OAAO;IAC5B;WACO,WAAW,OAAO,YAAY,SACvC,cAAa,QAAQ,QAAqB;MAE1C,OAAM,IAAI,MAAM,6BAA6B;;;;;;AC/DnD,MAAM,MAAM,SAAS;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAE/B,IAAI,IAAI,WAAW,MAAM,CAAC;AAC1B,IAAI,IACF,WAAW,WAAW,EACpB,UAAU,OACX,CAAC,CACH;AAGD,IAAI,KAAK,KAAK,KAAK,SAAS;AAC1B,KAAI,OAAO,+BAA+B,IAAI;AAC9C,KAAI,OAAO,gCAAgC,yCAAyC;AACpF,KAAI,OAAO,gCAAgC,IAAI,QAAQ,qCAAqC,GAAG;AAC/F,KAAI,OAAO,oCAAoC,OAAO;AACtD,KAAI,OAAO,0BAA0B,OAAO;AAC5C,OAAM;EACN;AAGF,IAAI,QAAQ,MAAM,KAAK,QAAQ;AAC7B,KAAI,OAAO,IAAI,CAAC,MAAM;EACtB;AAGF,QAAQ,GAAG,YAAY,YAAwB;CAC7C,MAAM,EAAE,QAAQ,SAAS;AACzB,SAAQ,IAAI,4BAA4B,QAAQ,KAAK;AAErD,cAAa,QAAQ,OAAO;AAC5B,KAAI,IAAI,OAAO;AAEf,KAAI,OAAO,YAAY;AACrB,UAAQ,IAAI,sBAAsB,KAAK,aAAa;GACpD;CAGF,MAAM,YAAY,QAAQ;AAC1B,mBAAkB;AAChB,MAAI;AACF,WAAQ,KAAK,WAAW,EAAE;WACnB,GAAG;AACV,WAAQ,IAAI,mDAAmD;AAC/D,WAAQ,KAAK,EAAE;;IAEhB,IAAK;EAER"}
|
package/dist/chunk.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
Object.defineProperty(exports, '__toESM', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return __toESM;
|
|
33
|
+
}
|
|
34
|
+
});
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_chunk = require('./chunk.cjs');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_chunk.__toESM(path, 1);
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
fs = require_chunk.__toESM(fs, 1);
|
|
7
|
+
let child_process = require("child_process");
|
|
8
|
+
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
var MockServiceWebpackPlugin = class {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
apply(compiler) {
|
|
15
|
+
const { source, port = "9009" } = this.options;
|
|
16
|
+
if (!source) {
|
|
17
|
+
console.error(`Mock Directory did not exist. Please make sure your Mock Source Directory`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!fs.default.existsSync(source)) {
|
|
21
|
+
console.error(`${source} did not exist. Please make sure your Source is Correct`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const getAppPath = () => {
|
|
25
|
+
return path.default.resolve(__dirname, "app.js");
|
|
26
|
+
};
|
|
27
|
+
let child = (0, child_process.fork)(getAppPath(), [], { execArgv: process.execArgv });
|
|
28
|
+
child.send({
|
|
29
|
+
source,
|
|
30
|
+
port
|
|
31
|
+
});
|
|
32
|
+
compiler.hooks.watchRun.tapAsync("MockServiceWebpackPlugin", (compilation, callback) => {
|
|
33
|
+
console.log("compiler watching...");
|
|
34
|
+
fs.default.watch(source, { recursive: true }, (eventType, filename) => {
|
|
35
|
+
console.log("eventType:", eventType, "filename:", filename);
|
|
36
|
+
child.kill("SIGKILL");
|
|
37
|
+
child = (0, child_process.fork)(getAppPath(), [], { execArgv: process.execArgv });
|
|
38
|
+
child.send({
|
|
39
|
+
source,
|
|
40
|
+
port
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
callback();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.MockServiceWebpackPlugin = MockServiceWebpackPlugin;
|
|
50
|
+
exports.default = MockServiceWebpackPlugin;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { i as WebpackCompiler, n as MockRoute, t as MockOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare class MockServiceWebpackPlugin {
|
|
5
|
+
private options;
|
|
6
|
+
constructor(options: MockOptions);
|
|
7
|
+
apply(compiler: WebpackCompiler): void;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type MockOptions, type MockRoute, MockServiceWebpackPlugin, MockServiceWebpackPlugin as default };
|
|
11
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAKM,wBAAA;;EAAA,WAAA,CAAA,OAAA,EAGiB,WAHO;EAAA,KAAA,CAAA,QAAA,EAOZ,eAPY,CAAA,EAAA,IAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { i as WebpackCompiler, n as MockRoute, t as MockOptions } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare class MockServiceWebpackPlugin {
|
|
5
|
+
private options;
|
|
6
|
+
constructor(options: MockOptions);
|
|
7
|
+
apply(compiler: WebpackCompiler): void;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type MockOptions, type MockRoute, MockServiceWebpackPlugin, MockServiceWebpackPlugin as default };
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAKM,wBAAA;;EAAA,WAAA,CAAA,OAAA,EAGiB,WAHO;EAAA,KAAA,CAAA,QAAA,EAOZ,eAPY,CAAA,EAAA,IAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { fork } from "child_process";
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
var MockServiceWebpackPlugin = class {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
const { source, port = "9009" } = this.options;
|
|
12
|
+
if (!source) {
|
|
13
|
+
console.error(`Mock Directory did not exist. Please make sure your Mock Source Directory`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!fs.existsSync(source)) {
|
|
17
|
+
console.error(`${source} did not exist. Please make sure your Source is Correct`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const getAppPath = () => {
|
|
21
|
+
return path.resolve(__dirname, "app.js");
|
|
22
|
+
};
|
|
23
|
+
let child = fork(getAppPath(), [], { execArgv: process.execArgv });
|
|
24
|
+
child.send({
|
|
25
|
+
source,
|
|
26
|
+
port
|
|
27
|
+
});
|
|
28
|
+
compiler.hooks.watchRun.tapAsync("MockServiceWebpackPlugin", (compilation, callback) => {
|
|
29
|
+
console.log("compiler watching...");
|
|
30
|
+
fs.watch(source, { recursive: true }, (eventType, filename) => {
|
|
31
|
+
console.log("eventType:", eventType, "filename:", filename);
|
|
32
|
+
child.kill("SIGKILL");
|
|
33
|
+
child = fork(getAppPath(), [], { execArgv: process.execArgv });
|
|
34
|
+
child.send({
|
|
35
|
+
source,
|
|
36
|
+
port
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
callback();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { MockServiceWebpackPlugin, MockServiceWebpackPlugin as default };
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { fork } from 'child_process'\nimport type { MockOptions, WebpackCompiler, IpcMessage } from './types'\n\nclass MockServiceWebpackPlugin {\n private options: MockOptions\n\n constructor(options: MockOptions) {\n this.options = options\n }\n\n apply(compiler: WebpackCompiler): void {\n const { source, port = '9009' } = this.options\n\n if (!source) {\n console.error(\n `Mock Directory did not exist. Please make sure your Mock Source Directory`,\n )\n return\n }\n\n if (!fs.existsSync(source)) {\n console.error(\n `${source} did not exist. Please make sure your Source is Correct`,\n )\n return\n }\n\n const getAppPath = () => {\n // Resolve app.js path based on whether we're in CJS or ESM context\n return path.resolve(__dirname, 'app.js')\n }\n\n let child = fork(getAppPath(), [], {\n execArgv: process.execArgv,\n })\n\n child.send({ source, port })\n\n compiler.hooks.watchRun.tapAsync(\n 'MockServiceWebpackPlugin',\n (compilation, callback) => {\n console.log('compiler watching...')\n\n fs.watch(source, { recursive: true }, (eventType, filename) => {\n console.log('eventType:', eventType, 'filename:', filename)\n child.kill('SIGKILL')\n child = fork(getAppPath(), [], {\n execArgv: process.execArgv,\n })\n child.send({ source, port })\n })\n callback()\n },\n )\n }\n}\n\nexport default MockServiceWebpackPlugin\nexport { MockServiceWebpackPlugin }\nexport type { MockOptions, MockRoute } from './types'\n"],"mappings":";;;;;AAKA,IAAM,2BAAN,MAA+B;CAG7B,YAAY,SAAsB;AAChC,OAAK,UAAU;;CAGjB,MAAM,UAAiC;EACrC,MAAM,EAAE,QAAQ,OAAO,WAAW,KAAK;AAEvC,MAAI,CAAC,QAAQ;AACX,WAAQ,MACN,4EACD;AACD;;AAGF,MAAI,CAAC,GAAG,WAAW,OAAO,EAAE;AAC1B,WAAQ,MACN,GAAG,OAAO,yDACX;AACD;;EAGF,MAAM,mBAAmB;AAEvB,UAAO,KAAK,QAAQ,WAAW,SAAS;;EAG1C,IAAI,QAAQ,KAAK,YAAY,EAAE,EAAE,EAAE,EACjC,UAAU,QAAQ,UACnB,CAAC;AAEF,QAAM,KAAK;GAAE;GAAQ;GAAM,CAAC;AAE5B,WAAS,MAAM,SAAS,SACtB,6BACC,aAAa,aAAa;AACzB,WAAQ,IAAI,uBAAuB;AAEnC,MAAG,MAAM,QAAQ,EAAE,WAAW,MAAM,GAAG,WAAW,aAAa;AAC7D,YAAQ,IAAI,cAAc,WAAW,aAAa,SAAS;AAC3D,UAAM,KAAK,UAAU;AACrB,YAAQ,KAAK,YAAY,EAAE,EAAE,EAAE,EAC7B,UAAU,QAAQ,UACnB,CAAC;AACF,UAAM,KAAK;KAAE;KAAQ;KAAM,CAAC;KAC5B;AACF,aAAU;IAEb"}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface MockOptions {
|
|
5
|
+
/** Mock files directory path */
|
|
6
|
+
source: string;
|
|
7
|
+
/** Server port, default: 9009 */
|
|
8
|
+
port?: string | number;
|
|
9
|
+
}
|
|
10
|
+
interface MockRoute {
|
|
11
|
+
/** API path, e.g. '/api/users' */
|
|
12
|
+
path: string;
|
|
13
|
+
/** HTTP method */
|
|
14
|
+
methods: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
15
|
+
/** HTTP method */
|
|
16
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
17
|
+
/** Response data, can be static object or function */
|
|
18
|
+
data: Record<string, unknown> | ((req: Request) => Record<string, unknown>);
|
|
19
|
+
}
|
|
20
|
+
interface WebpackCompiler {
|
|
21
|
+
hooks: {
|
|
22
|
+
watchRun: {
|
|
23
|
+
tapAsync: (name: string, callback: (compilation: unknown, cb: () => void) => void) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
interface VitePluginResult {
|
|
28
|
+
name: string;
|
|
29
|
+
buildStart: () => void;
|
|
30
|
+
closeBundle: () => void;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { WebpackCompiler as i, MockRoute as n, VitePluginResult as r, MockOptions as t };
|
|
34
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;AAIiB,UAAA,WAAA,CAAW;EAOX;EAAS,MAAA,EAAA,MAAA;;MAQe,CAAA,EAAA,MAAA,GAAA,MAAA;;AAAkB,UAR1C,SAAA,CAQ0C;EAQ1C;EAQA,IAAA,EAAA,MAAA;;;;;;QAhBT,iCAAiC,YAAY;;UAQpC,eAAA;;;;;;;UAQA,gBAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface MockOptions {
|
|
5
|
+
/** Mock files directory path */
|
|
6
|
+
source: string;
|
|
7
|
+
/** Server port, default: 9009 */
|
|
8
|
+
port?: string | number;
|
|
9
|
+
}
|
|
10
|
+
interface MockRoute {
|
|
11
|
+
/** API path, e.g. '/api/users' */
|
|
12
|
+
path: string;
|
|
13
|
+
/** HTTP method */
|
|
14
|
+
methods: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
15
|
+
/** HTTP method */
|
|
16
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
17
|
+
/** Response data, can be static object or function */
|
|
18
|
+
data: Record<string, unknown> | ((req: Request) => Record<string, unknown>);
|
|
19
|
+
}
|
|
20
|
+
interface WebpackCompiler {
|
|
21
|
+
hooks: {
|
|
22
|
+
watchRun: {
|
|
23
|
+
tapAsync: (name: string, callback: (compilation: unknown, cb: () => void) => void) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
interface VitePluginResult {
|
|
28
|
+
name: string;
|
|
29
|
+
buildStart: () => void;
|
|
30
|
+
closeBundle: () => void;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { WebpackCompiler as i, MockRoute as n, VitePluginResult as r, MockOptions as t };
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;AAIiB,UAAA,WAAA,CAAW;EAOX;EAAS,MAAA,EAAA,MAAA;;MAQe,CAAA,EAAA,MAAA,GAAA,MAAA;;AAAkB,UAR1C,SAAA,CAQ0C;EAQ1C;EAQA,IAAA,EAAA,MAAA;;;;;;QAhBT,iCAAiC,YAAY;;UAQpC,eAAA;;;;;;;UAQA,gBAAA"}
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_chunk = require('./chunk.cjs');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_chunk.__toESM(path, 1);
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
fs = require_chunk.__toESM(fs, 1);
|
|
7
|
+
let child_process = require("child_process");
|
|
8
|
+
|
|
9
|
+
//#region src/vite-plugin.ts
|
|
10
|
+
function mockServiceVite(options) {
|
|
11
|
+
const { source, port = "9009" } = options;
|
|
12
|
+
const state = {
|
|
13
|
+
child: null,
|
|
14
|
+
watcher: null
|
|
15
|
+
};
|
|
16
|
+
if (!source) {
|
|
17
|
+
console.error(`Mock Directory did not exist. Please make sure your Mock Source Directory`);
|
|
18
|
+
throw new Error("Mock source directory is required");
|
|
19
|
+
}
|
|
20
|
+
if (!fs.default.existsSync(source)) {
|
|
21
|
+
console.error(`${source} did not exist. Please make sure your Source is Correct`);
|
|
22
|
+
throw new Error(`Mock source directory "${source}" does not exist`);
|
|
23
|
+
}
|
|
24
|
+
const getAppPath = () => {
|
|
25
|
+
return path.default.resolve(__dirname, "app.js");
|
|
26
|
+
};
|
|
27
|
+
const startServer = () => {
|
|
28
|
+
state.child = (0, child_process.fork)(getAppPath(), [], { execArgv: process.execArgv });
|
|
29
|
+
state.child.send({
|
|
30
|
+
source,
|
|
31
|
+
port
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const restartServer = () => {
|
|
35
|
+
if (state.child) state.child.kill("SIGKILL");
|
|
36
|
+
startServer();
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
name: "mock-service-vite",
|
|
40
|
+
buildStart() {
|
|
41
|
+
console.log("Mock Service Vite Plugin starting...");
|
|
42
|
+
startServer();
|
|
43
|
+
state.watcher = fs.default.watch(source, { recursive: true }, (eventType, filename) => {
|
|
44
|
+
console.log("Mock file changed:", eventType, filename);
|
|
45
|
+
restartServer();
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
closeBundle() {
|
|
49
|
+
if (state.watcher) state.watcher.close();
|
|
50
|
+
if (state.child) state.child.kill("SIGKILL");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.default = mockServiceVite;
|
|
57
|
+
exports.mockServiceVite = mockServiceVite;
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { r as VitePluginResult, t as MockOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/vite-plugin.d.ts
|
|
4
|
+
declare function mockServiceVite(options: MockOptions): VitePluginResult;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { mockServiceVite as default, mockServiceVite };
|
|
7
|
+
//# sourceMappingURL=vite.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.cts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;iBAKgB,eAAA,UAAyB,cAAc"}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { r as VitePluginResult, t as MockOptions } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/vite-plugin.d.ts
|
|
4
|
+
declare function mockServiceVite(options: MockOptions): VitePluginResult;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { mockServiceVite as default, mockServiceVite };
|
|
7
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;iBAKgB,eAAA,UAAyB,cAAc"}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { fork } from "child_process";
|
|
4
|
+
|
|
5
|
+
//#region src/vite-plugin.ts
|
|
6
|
+
function mockServiceVite(options) {
|
|
7
|
+
const { source, port = "9009" } = options;
|
|
8
|
+
const state = {
|
|
9
|
+
child: null,
|
|
10
|
+
watcher: null
|
|
11
|
+
};
|
|
12
|
+
if (!source) {
|
|
13
|
+
console.error(`Mock Directory did not exist. Please make sure your Mock Source Directory`);
|
|
14
|
+
throw new Error("Mock source directory is required");
|
|
15
|
+
}
|
|
16
|
+
if (!fs.existsSync(source)) {
|
|
17
|
+
console.error(`${source} did not exist. Please make sure your Source is Correct`);
|
|
18
|
+
throw new Error(`Mock source directory "${source}" does not exist`);
|
|
19
|
+
}
|
|
20
|
+
const getAppPath = () => {
|
|
21
|
+
return path.resolve(__dirname, "app.js");
|
|
22
|
+
};
|
|
23
|
+
const startServer = () => {
|
|
24
|
+
state.child = fork(getAppPath(), [], { execArgv: process.execArgv });
|
|
25
|
+
state.child.send({
|
|
26
|
+
source,
|
|
27
|
+
port
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const restartServer = () => {
|
|
31
|
+
if (state.child) state.child.kill("SIGKILL");
|
|
32
|
+
startServer();
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
name: "mock-service-vite",
|
|
36
|
+
buildStart() {
|
|
37
|
+
console.log("Mock Service Vite Plugin starting...");
|
|
38
|
+
startServer();
|
|
39
|
+
state.watcher = fs.watch(source, { recursive: true }, (eventType, filename) => {
|
|
40
|
+
console.log("Mock file changed:", eventType, filename);
|
|
41
|
+
restartServer();
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
closeBundle() {
|
|
45
|
+
if (state.watcher) state.watcher.close();
|
|
46
|
+
if (state.child) state.child.kill("SIGKILL");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { mockServiceVite as default, mockServiceVite };
|
|
53
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite-plugin.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { fork } from 'child_process'\nimport type { MockOptions, VitePluginResult, MockServiceState } from './types'\n\nexport function mockServiceVite(options: MockOptions): VitePluginResult {\n const { source, port = '9009' } = options\n const state: MockServiceState = {\n child: null,\n watcher: null,\n }\n\n if (!source) {\n console.error(\n `Mock Directory did not exist. Please make sure your Mock Source Directory`,\n )\n throw new Error('Mock source directory is required')\n }\n\n if (!fs.existsSync(source)) {\n console.error(\n `${source} did not exist. Please make sure your Source is Correct`,\n )\n throw new Error(`Mock source directory \"${source}\" does not exist`)\n }\n\n const getAppPath = () => {\n // Resolve app.js path based on whether we're in CJS or ESM context\n // In bundled output, app.js will be alongside vite-plugin.js\n return path.resolve(__dirname, 'app.js')\n }\n\n const startServer = () => {\n state.child = fork(getAppPath(), [], {\n execArgv: process.execArgv,\n })\n state.child.send({ source, port })\n }\n\n const restartServer = () => {\n if (state.child) {\n state.child.kill('SIGKILL')\n }\n startServer()\n }\n\n return {\n name: 'mock-service-vite',\n\n buildStart() {\n console.log('Mock Service Vite Plugin starting...')\n startServer()\n\n state.watcher = fs.watch(source, { recursive: true }, (eventType, filename) => {\n console.log('Mock file changed:', eventType, filename)\n restartServer()\n })\n },\n\n closeBundle() {\n if (state.watcher) {\n state.watcher.close()\n }\n if (state.child) {\n state.child.kill('SIGKILL')\n }\n },\n }\n}\n\nexport default mockServiceVite\n"],"mappings":";;;;;AAKA,SAAgB,gBAAgB,SAAwC;CACtE,MAAM,EAAE,QAAQ,OAAO,WAAW;CAClC,MAAM,QAA0B;EAC9B,OAAO;EACP,SAAS;EACV;AAED,KAAI,CAAC,QAAQ;AACX,UAAQ,MACN,4EACD;AACD,QAAM,IAAI,MAAM,oCAAoC;;AAGtD,KAAI,CAAC,GAAG,WAAW,OAAO,EAAE;AAC1B,UAAQ,MACN,GAAG,OAAO,yDACX;AACD,QAAM,IAAI,MAAM,0BAA0B,OAAO,kBAAkB;;CAGrE,MAAM,mBAAmB;AAGvB,SAAO,KAAK,QAAQ,WAAW,SAAS;;CAG1C,MAAM,oBAAoB;AACxB,QAAM,QAAQ,KAAK,YAAY,EAAE,EAAE,EAAE,EACnC,UAAU,QAAQ,UACnB,CAAC;AACF,QAAM,MAAM,KAAK;GAAE;GAAQ;GAAM,CAAC;;CAGpC,MAAM,sBAAsB;AAC1B,MAAI,MAAM,MACR,OAAM,MAAM,KAAK,UAAU;AAE7B,eAAa;;AAGf,QAAO;EACL,MAAM;EAEN,aAAa;AACX,WAAQ,IAAI,uCAAuC;AACnD,gBAAa;AAEb,SAAM,UAAU,GAAG,MAAM,QAAQ,EAAE,WAAW,MAAM,GAAG,WAAW,aAAa;AAC7E,YAAQ,IAAI,sBAAsB,WAAW,SAAS;AACtD,mBAAe;KACf;;EAGJ,cAAc;AACZ,OAAI,MAAM,QACR,OAAM,QAAQ,OAAO;AAEvB,OAAI,MAAM,MACR,OAAM,MAAM,KAAK,UAAU;;EAGhC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chapanda-mock-service",
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "mock service plugin for webpack and vite",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./vite": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/vite.d.ts",
|
|
24
|
+
"default": "./dist/vite.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/vite.d.cts",
|
|
28
|
+
"default": "./dist/vite.cjs"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"author": "baiwusanyu-c",
|
|
37
|
+
"homepage": "https://github.com/baiwusanyu-c/chapanda-mock-service",
|
|
38
|
+
"repository": "https://github.com/baiwusanyu-c/chapanda-mock-service",
|
|
39
|
+
"bugs": "https://github.com/baiwusanyu-c/chapanda-mock-service/issues",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"express": "^4.0.0",
|
|
42
|
+
"body-parser": "^1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"tsdown": "^0.12.7",
|
|
46
|
+
"typescript": "^5.8.3",
|
|
47
|
+
"@types/node": "^22.14.1",
|
|
48
|
+
"@types/express": "^5.0.1",
|
|
49
|
+
"@types/body-parser": "^1.19.5",
|
|
50
|
+
"bumpp": "^9.5.1",
|
|
51
|
+
"express": "^4.21.2",
|
|
52
|
+
"body-parser": "^1.20.3"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"init": "pnpm i",
|
|
56
|
+
"build": "tsdown",
|
|
57
|
+
"dev": "tsdown --watch",
|
|
58
|
+
"release": "bumpp package.json --commit --push --tag",
|
|
59
|
+
"publish:npm": "pnpm publish --no-git-checks --access public"
|
|
60
|
+
}
|
|
61
|
+
}
|