vite-plugin-mock-dev-server 0.3.14 → 0.3.16

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/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  <br>
4
4
  <br>
5
- <p align="center">Vite Plugin for API mock dev server.</p>
5
+ <p align="center">
6
+ <b>Vite Plugin for API mock dev server.</b>
7
+ </p>
6
8
 
7
9
  <br>
8
10
  <p align="center">
@@ -10,6 +12,7 @@
10
12
  <img alt="node-current" src="https://img.shields.io/node/v/vite-plugin-mock-dev-server?style=flat-square">
11
13
  <img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/vite-plugin-mock-dev-server/peer/vite?style=flat-square">
12
14
  <img alt="GitHub" src="https://img.shields.io/github/license/pengzhanbo/vite-plugin-mock-dev-server?style=flat-square">
15
+ <img alt="npm" src="https://img.shields.io/npm/dm/vite-plugin-mock-dev-server?style=flat-square">
13
16
  </p>
14
17
  <br>
15
18
  <p align="center">
@@ -34,11 +37,17 @@
34
37
  - ⚖️ Use `server.proxy`
35
38
  - 🍕 Support `viteConfig.define` in mock file
36
39
  - 📤 Support `multipart` content-type,mock upload file.
40
+ - 🌈 Support `vite preview` mode.
37
41
  ## Documentation
38
42
 
39
43
  See the [documentation](https://vite-plugin-mock-dev-server.netlify.app/) to learn more.
44
+
40
45
  [![Netlify Status](https://api.netlify.com/api/v1/badges/9ccda610-2c6a-4cd0-aeaa-a8932f2b477c/deploy-status)](https://app.netlify.com/sites/vite-plugin-mock-dev-server/deploys)
41
46
 
47
+ ## Playground
48
+
49
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/pengzhanbo/vite-plugin-mock-dev-server/tree/main/playground)
50
+
42
51
  ## Usage
43
52
 
44
53
  ### Install
@@ -125,14 +134,13 @@ export default defineConfig({
125
134
 
126
135
  - `options.exclude`
127
136
 
128
- When you configure the mock files to be read, the files you want to exclude can be a directory, a glob, or an array
137
+ When you configure the mock files to be read, the files you want to exclude can be a directory, glob, or array
129
138
 
130
139
  Default:
131
140
  ```ts
132
141
  [
133
142
  '**/node_modules/**',
134
143
  '**/test/**',
135
- '**/cypress/**',
136
144
  'src/**',
137
145
  '**/.vscode/**',
138
146
  '**/.git/**',
@@ -219,14 +227,14 @@ export default defineMock({
219
227
  * configurations and determines which mock configuration
220
228
  * is valid according to the validator.
221
229
  *
222
- * @type { header?: object; body?: object; query?: object; params?: object }
230
+ * @type { headers?: object; body?: object; query?: object; params?: object }
223
231
  *
224
232
  * If the validator incoming is an object,
225
233
  * then the validation method is the comparison of the
226
234
  * strict request of interface, headers/body/query/params
227
235
  * each `key-value` congruent, congruent check through
228
236
  *
229
- * @type ({ header: object; body: object; query: object; params: object }) => boolean
237
+ * @type ({ headers: object; body: object; query: object; params: object }) => boolean
230
238
  * If the validator is passed a function,
231
239
  * it takes the requested interface-related data as an input,
232
240
  * gives it to the consumer for custom validation,
@@ -258,7 +266,7 @@ export default defineMock({
258
266
  *
259
267
  * @type string | number | array | object
260
268
  *
261
- * @type (request: { header, query, body, params }) => any | Promise<any>
269
+ * @type (request: { headers, query, body, params }) => any | Promise<any>
262
270
  */
263
271
  body: {},
264
272
 
@@ -293,7 +301,7 @@ export default defineMock({
293
301
  ```
294
302
 
295
303
  #### Example 2:
296
- Match `/api/test` ,And returns a fixed content data
304
+ Match `/api/test` ,And returns a static content data
297
305
  ```ts
298
306
  export default defineMock({
299
307
  url: '/api/test',
package/README.zh-CN.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  <br>
4
4
  <br>
5
- <p align="center">vite mock开发服务(mock-dev-server)插件。</p>
5
+ <p align="center">
6
+ <b>vite mock开发服务(mock-dev-server)插件。</b>
7
+ </p>
6
8
 
7
9
  <p align="center">在 vite 开发环境中,注入一个 mock-dev-server。</p>
8
10
 
@@ -12,6 +14,7 @@
12
14
  <img alt="node-current" src="https://img.shields.io/node/v/vite-plugin-mock-dev-server?style=flat-square">
13
15
  <img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/vite-plugin-mock-dev-server/peer/vite?style=flat-square">
14
16
  <img alt="GitHub" src="https://img.shields.io/github/license/pengzhanbo/vite-plugin-mock-dev-server?style=flat-square">
17
+ <img alt="npm" src="https://img.shields.io/npm/dm/vite-plugin-mock-dev-server?style=flat-square">
15
18
  </p>
16
19
  <br>
17
20
  <p align="center">
@@ -28,19 +31,25 @@
28
31
  - 🦾 Typescript
29
32
  - 🏷 支持 json / json5 编写 mock 数据
30
33
  - 📦 自动加载 mock 文件
31
- - 🎨 可选择你喜欢的任意用于生成mock数据库,如 `mockjs`,或者不是用其他库
34
+ - 🎨 可选择你喜欢的任意用于生成mock数据库,如 `mockjs`,或者不使用其他库
32
35
  - 📥 路径规则匹配,请求参数匹配
33
36
  - ⚙️ 随意开启或关闭对某个接口的 mock配置
34
37
  - 🔥 热更新
35
38
  - ⚖️ 使用 `server.proxy` 配置
36
39
  - 🍕 支持在 mock文件中使用 `viteConfig.define`配置字段
37
40
  - 📤 支持 multipart 类型,模拟文件上传
41
+ - 🌈 支持 `vite preview` 模式.
38
42
 
39
43
 
40
44
  ## 文档
41
45
 
42
46
  查看 [Documentation](https://vite-plugin-mock-dev-server.netlify.app/) 了解更多。
47
+
43
48
  [![Netlify Status](https://api.netlify.com/api/v1/badges/9ccda610-2c6a-4cd0-aeaa-a8932f2b477c/deploy-status)](https://app.netlify.com/sites/vite-plugin-mock-dev-server/deploys)
49
+
50
+ ## Playground
51
+
52
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/pengzhanbo/vite-plugin-mock-dev-server/tree/main/playground)
44
53
  ## 使用
45
54
 
46
55
  ### 安装
@@ -130,7 +139,17 @@ export default defineConfig({
130
139
 
131
140
  配置读取 mock文件时,需要排除的文件, 可以是一个 目录、glob、或者一个数组
132
141
 
133
- 默认值:`['**/node_modules/**','**/test/**','**/cypress/**','src/**','**/.vscode/**','**/.git/**','**/dist/**',]`
142
+ 默认值:
143
+ ```ts
144
+ [
145
+ '**/node_modules/**',
146
+ '**/test/**',
147
+ 'src/**',
148
+ '**/.vscode/**',
149
+ '**/.git/**',
150
+ '**/dist/**'
151
+ ]
152
+ ```
134
153
 
135
154
  - `options.formidableOptions`
136
155
 
@@ -209,13 +228,13 @@ export default defineMock({
209
228
  * 验证器可以很好的解决这一类问题,将同个 url 分为多个 mock配置,
210
229
  * 根据 验证器来判断哪个mock配置生效。
211
230
  *
212
- * @type { header?: object; body?: object; query?: object; params?: object }
231
+ * @type { headers?: object; body?: object; query?: object; params?: object }
213
232
  *
214
233
  * 如果 validator 传入的是一个对象,那么验证方式是严格比较 请求的接口
215
234
  * 中,headers/body/query/params 的各个`key`的`value`是否全等,
216
235
  * 全等则校验通过
217
236
  *
218
- * @type ({ header: object; body: object; query: object; params: object }) => boolean
237
+ * @type ({ headers: object; body: object; query: object; params: object }) => boolean
219
238
  * 如果 validator 传入的是一个函数,那么会讲 请求的接口相关数据作为入参,提供给使用者进行自定义校验,并返回一个 boolean
220
239
  *
221
240
  */
@@ -247,7 +266,7 @@ export default defineMock({
247
266
  * @type string | number | array | object
248
267
  * 直接返回定义的数据
249
268
  *
250
- * @type (request: { header, query, body, params }) => any | Promise<any>
269
+ * @type (request: { headers, query, body, params }) => any | Promise<any>
251
270
  * 如果传入一个函数,那么可以更加灵活的定义返回响应体数据
252
271
  */
253
272
  body: {},
package/dist/index.cjs CHANGED
@@ -42,11 +42,11 @@ var import_node_fs2 = __toESM(require("fs"), 1);
42
42
  var import_node_module = require("module");
43
43
  var import_node_path2 = __toESM(require("path"), 1);
44
44
  var import_node_url2 = require("url");
45
- var import_pluginutils = require("@rollup/pluginutils");
46
45
  var import_chokidar = __toESM(require("chokidar"), 1);
47
46
  var import_esbuild = require("esbuild");
48
47
  var import_fast_glob = __toESM(require("fast-glob"), 1);
49
48
  var import_json5 = __toESM(require("json5"), 1);
49
+ var import_vite = require("vite");
50
50
 
51
51
  // src/utils.ts
52
52
  var import_node_fs = __toESM(require("fs"), 1);
@@ -85,11 +85,11 @@ var _require = (0, import_node_module.createRequire)(_dirname);
85
85
  var _MockLoader = class extends import_node_events.default {
86
86
  constructor(options) {
87
87
  super();
88
+ this.options = options;
88
89
  this.moduleCache = /* @__PURE__ */ new Map();
89
90
  this.moduleDeps = /* @__PURE__ */ new Map();
90
- this._mockList = [];
91
+ this._mockList = {};
91
92
  this.moduleType = "cjs";
92
- this.options = options;
93
93
  this.cwd = options.cwd || process.cwd();
94
94
  try {
95
95
  const pkg = lookupFile(this.cwd, ["package.json"]);
@@ -105,7 +105,7 @@ var _MockLoader = class extends import_node_events.default {
105
105
  const includePaths = await (0, import_fast_glob.default)(include, {
106
106
  cwd: this.cwd
107
107
  });
108
- const includeFilter = (0, import_pluginutils.createFilter)(include, exclude, {
108
+ const includeFilter = (0, import_vite.createFilter)(include, exclude, {
109
109
  resolve: false
110
110
  });
111
111
  this.watchMockEntry();
@@ -183,9 +183,15 @@ var _MockLoader = class extends import_node_events.default {
183
183
  for (const [, handle] of this.moduleCache.entries()) {
184
184
  isArray(handle) ? mockList.push(...handle) : mockList.push(handle);
185
185
  }
186
- this._mockList = mockList.filter(
187
- (mock) => mock.enabled || typeof mock.enabled === "undefined"
188
- );
186
+ const mocks = {};
187
+ mockList.filter((mock) => mock.enabled || typeof mock.enabled === "undefined").forEach((mock) => {
188
+ if (!mocks[mock.url]) {
189
+ mocks[mock.url] = [];
190
+ }
191
+ const list = mocks[mock.url];
192
+ mock.validator ? list.unshift(mock) : list.push(mock);
193
+ });
194
+ this._mockList = mocks;
189
195
  }
190
196
  updateModuleDeps(filepath, deps) {
191
197
  Object.keys(deps).forEach((mPath) => {
@@ -274,11 +280,6 @@ var _MockLoader = class extends import_node_events.default {
274
280
  }
275
281
  async transformWithEsbuild(filepath, isESM) {
276
282
  var _a;
277
- const userDefine = {};
278
- for (const key in this.options.define) {
279
- const val = this.options.define[key];
280
- userDefine[key] = typeof val === "string" ? val : JSON.stringify(val);
281
- }
282
283
  try {
283
284
  const result = await (0, import_esbuild.build)({
284
285
  entryPoints: [filepath],
@@ -289,7 +290,7 @@ var _MockLoader = class extends import_node_events.default {
289
290
  bundle: true,
290
291
  metafile: true,
291
292
  format: isESM ? "esm" : "cjs",
292
- define: userDefine,
293
+ define: this.options.define,
293
294
  plugins: [
294
295
  {
295
296
  name: "externalize-deps",
@@ -377,22 +378,36 @@ function equalObj(left, right) {
377
378
  async function mockServerMiddleware(httpServer, config, options) {
378
379
  const include = isArray(options.include) ? options.include : [options.include];
379
380
  const exclude = isArray(options.exclude) ? options.exclude : [options.exclude];
381
+ const define = {};
382
+ if (config.define) {
383
+ for (const key in config.define) {
384
+ const val = config.define[key];
385
+ define[key] = typeof val === "string" ? val : JSON.stringify(val);
386
+ }
387
+ }
380
388
  const loader = new MockLoader({
381
389
  include,
382
390
  exclude,
383
- define: config.define || {}
391
+ define
384
392
  });
385
393
  await loader.load();
386
394
  httpServer == null ? void 0 : httpServer.on("close", () => loader.close());
387
395
  const proxies = Object.keys(config.server.proxy || {});
388
396
  return async function(req, res, next) {
389
- if (proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url))) {
390
- return next();
391
- }
392
397
  const method = req.method.toUpperCase();
393
398
  const { query, pathname } = (0, import_node_url3.parse)(req.url, true);
399
+ if (!pathname || proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url))) {
400
+ return next();
401
+ }
402
+ const mockUrl = Object.keys(loader._mockList).find((key) => {
403
+ return (0, import_path_to_regexp.pathToRegexp)(key).test(pathname);
404
+ });
405
+ if (!mockUrl) {
406
+ return next();
407
+ }
408
+ const mockList = loader.mockList[mockUrl];
394
409
  const reqBody = await parseReqBody(req, options.formidableOptions);
395
- const currentMock = loader.mockList.find((mock) => {
410
+ const currentMock = mockList.find((mock) => {
396
411
  if (!pathname || !mock || !mock.url)
397
412
  return false;
398
413
  const methods = mock.method ? isArray(mock.method) ? mock.method : [mock.method] : ["GET", "POST"];
@@ -477,6 +492,7 @@ function doesProxyContextMatchUrl(context, url) {
477
492
  }
478
493
 
479
494
  // src/plugin.ts
495
+ var viteConfig = {};
480
496
  function mockDevServerPlugin({
481
497
  include = ["mock/**/*.mock.{js,ts,cjs,mjs,json,json5}"],
482
498
  exclude = [
@@ -493,6 +509,10 @@ function mockDevServerPlugin({
493
509
  name: "vite-plugin-mock-dev-server",
494
510
  enforce: "pre",
495
511
  apply: "serve",
512
+ configResolved(config) {
513
+ viteConfig = config;
514
+ config.logger.warn("");
515
+ },
496
516
  async configureServer({ middlewares, config, httpServer }) {
497
517
  const middleware = await mockServerMiddleware(httpServer, config, {
498
518
  include,
@@ -503,6 +523,17 @@ function mockDevServerPlugin({
503
523
  }
504
524
  });
505
525
  middlewares.use(middleware);
526
+ },
527
+ async configurePreviewServer({ middlewares, httpServer }) {
528
+ const middleware = await mockServerMiddleware(httpServer, viteConfig, {
529
+ include,
530
+ exclude,
531
+ formidableOptions: {
532
+ multiples: true,
533
+ ...formidableOptions
534
+ }
535
+ });
536
+ middlewares.use(middleware);
506
537
  }
507
538
  };
508
539
  }
package/dist/index.js CHANGED
@@ -8,11 +8,11 @@ import fs2 from "fs";
8
8
  import { createRequire } from "module";
9
9
  import path2 from "path";
10
10
  import { pathToFileURL } from "url";
11
- import { createFilter } from "@rollup/pluginutils";
12
11
  import chokidar from "chokidar";
13
12
  import { build } from "esbuild";
14
13
  import fastGlob from "fast-glob";
15
14
  import JSON5 from "json5";
15
+ import { createFilter } from "vite";
16
16
 
17
17
  // src/utils.ts
18
18
  import fs from "fs";
@@ -50,11 +50,11 @@ var _require = createRequire(_dirname);
50
50
  var _MockLoader = class extends EventEmitter {
51
51
  constructor(options) {
52
52
  super();
53
+ this.options = options;
53
54
  this.moduleCache = /* @__PURE__ */ new Map();
54
55
  this.moduleDeps = /* @__PURE__ */ new Map();
55
- this._mockList = [];
56
+ this._mockList = {};
56
57
  this.moduleType = "cjs";
57
- this.options = options;
58
58
  this.cwd = options.cwd || process.cwd();
59
59
  try {
60
60
  const pkg = lookupFile(this.cwd, ["package.json"]);
@@ -148,9 +148,15 @@ var _MockLoader = class extends EventEmitter {
148
148
  for (const [, handle] of this.moduleCache.entries()) {
149
149
  isArray(handle) ? mockList.push(...handle) : mockList.push(handle);
150
150
  }
151
- this._mockList = mockList.filter(
152
- (mock) => mock.enabled || typeof mock.enabled === "undefined"
153
- );
151
+ const mocks = {};
152
+ mockList.filter((mock) => mock.enabled || typeof mock.enabled === "undefined").forEach((mock) => {
153
+ if (!mocks[mock.url]) {
154
+ mocks[mock.url] = [];
155
+ }
156
+ const list = mocks[mock.url];
157
+ mock.validator ? list.unshift(mock) : list.push(mock);
158
+ });
159
+ this._mockList = mocks;
154
160
  }
155
161
  updateModuleDeps(filepath, deps) {
156
162
  Object.keys(deps).forEach((mPath) => {
@@ -239,11 +245,6 @@ var _MockLoader = class extends EventEmitter {
239
245
  }
240
246
  async transformWithEsbuild(filepath, isESM) {
241
247
  var _a;
242
- const userDefine = {};
243
- for (const key in this.options.define) {
244
- const val = this.options.define[key];
245
- userDefine[key] = typeof val === "string" ? val : JSON.stringify(val);
246
- }
247
248
  try {
248
249
  const result = await build({
249
250
  entryPoints: [filepath],
@@ -254,7 +255,7 @@ var _MockLoader = class extends EventEmitter {
254
255
  bundle: true,
255
256
  metafile: true,
256
257
  format: isESM ? "esm" : "cjs",
257
- define: userDefine,
258
+ define: this.options.define,
258
259
  plugins: [
259
260
  {
260
261
  name: "externalize-deps",
@@ -342,22 +343,36 @@ function equalObj(left, right) {
342
343
  async function mockServerMiddleware(httpServer, config, options) {
343
344
  const include = isArray(options.include) ? options.include : [options.include];
344
345
  const exclude = isArray(options.exclude) ? options.exclude : [options.exclude];
346
+ const define = {};
347
+ if (config.define) {
348
+ for (const key in config.define) {
349
+ const val = config.define[key];
350
+ define[key] = typeof val === "string" ? val : JSON.stringify(val);
351
+ }
352
+ }
345
353
  const loader = new MockLoader({
346
354
  include,
347
355
  exclude,
348
- define: config.define || {}
356
+ define
349
357
  });
350
358
  await loader.load();
351
359
  httpServer == null ? void 0 : httpServer.on("close", () => loader.close());
352
360
  const proxies = Object.keys(config.server.proxy || {});
353
361
  return async function(req, res, next) {
354
- if (proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url))) {
355
- return next();
356
- }
357
362
  const method = req.method.toUpperCase();
358
363
  const { query, pathname } = urlParse(req.url, true);
364
+ if (!pathname || proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url))) {
365
+ return next();
366
+ }
367
+ const mockUrl = Object.keys(loader._mockList).find((key) => {
368
+ return pathToRegexp(key).test(pathname);
369
+ });
370
+ if (!mockUrl) {
371
+ return next();
372
+ }
373
+ const mockList = loader.mockList[mockUrl];
359
374
  const reqBody = await parseReqBody(req, options.formidableOptions);
360
- const currentMock = loader.mockList.find((mock) => {
375
+ const currentMock = mockList.find((mock) => {
361
376
  if (!pathname || !mock || !mock.url)
362
377
  return false;
363
378
  const methods = mock.method ? isArray(mock.method) ? mock.method : [mock.method] : ["GET", "POST"];
@@ -442,6 +457,7 @@ function doesProxyContextMatchUrl(context, url) {
442
457
  }
443
458
 
444
459
  // src/plugin.ts
460
+ var viteConfig = {};
445
461
  function mockDevServerPlugin({
446
462
  include = ["mock/**/*.mock.{js,ts,cjs,mjs,json,json5}"],
447
463
  exclude = [
@@ -458,6 +474,10 @@ function mockDevServerPlugin({
458
474
  name: "vite-plugin-mock-dev-server",
459
475
  enforce: "pre",
460
476
  apply: "serve",
477
+ configResolved(config) {
478
+ viteConfig = config;
479
+ config.logger.warn("");
480
+ },
461
481
  async configureServer({ middlewares, config, httpServer }) {
462
482
  const middleware = await mockServerMiddleware(httpServer, config, {
463
483
  include,
@@ -468,6 +488,17 @@ function mockDevServerPlugin({
468
488
  }
469
489
  });
470
490
  middlewares.use(middleware);
491
+ },
492
+ async configurePreviewServer({ middlewares, httpServer }) {
493
+ const middleware = await mockServerMiddleware(httpServer, viteConfig, {
494
+ include,
495
+ exclude,
496
+ formidableOptions: {
497
+ multiples: true,
498
+ ...formidableOptions
499
+ }
500
+ });
501
+ middlewares.use(middleware);
471
502
  }
472
503
  };
473
504
  }
package/package.json CHANGED
@@ -1,15 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-mock-dev-server",
3
- "type": "module",
4
- "version": "0.3.14",
5
- "packageManager": "pnpm@7.18.2",
6
- "author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)",
7
- "license": "GPL-3.0",
8
- "homepage": "https://vite-plugin-mock-dev-server.netlify.app",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/pengzhanbo/vite-plugin-mock-dev-server"
12
- },
3
+ "version": "0.3.16",
13
4
  "keywords": [
14
5
  "vite",
15
6
  "plugin",
@@ -17,6 +8,14 @@
17
8
  "mock",
18
9
  "mock-server"
19
10
  ],
11
+ "homepage": "https://vite-plugin-mock-dev-server.netlify.app",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/pengzhanbo/vite-plugin-mock-dev-server"
15
+ },
16
+ "license": "GPL-3.0",
17
+ "author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)",
18
+ "type": "module",
20
19
  "exports": {
21
20
  ".": {
22
21
  "require": "./dist/index.cjs",
@@ -29,28 +28,8 @@
29
28
  "files": [
30
29
  "dist"
31
30
  ],
32
- "engines": {
33
- "node": "^14.18.0 || >=16"
34
- },
35
- "tsup": {
36
- "entry": [
37
- "src/index.ts"
38
- ],
39
- "sourcemap": false,
40
- "dts": true,
41
- "splitting": false,
42
- "clean": true,
43
- "format": [
44
- "esm",
45
- "cjs"
46
- ]
47
- },
48
31
  "prettier": "@pengzhanbo/prettier-config",
49
- "peerDependencies": {
50
- "vite": ">=3.0.0"
51
- },
52
32
  "dependencies": {
53
- "@rollup/pluginutils": "^5.0.2",
54
33
  "chokidar": "^3.5.3",
55
34
  "co-body": "^6.1.0",
56
35
  "debug": "^4.3.4",
@@ -61,30 +40,51 @@
61
40
  "path-to-regexp": "^6.2.1"
62
41
  },
63
42
  "devDependencies": {
64
- "@pengzhanbo/eslint-config-ts": "^0.3.1",
65
- "@pengzhanbo/prettier-config": "^0.3.1",
43
+ "@pengzhanbo/eslint-config-ts": "^0.3.2",
44
+ "@pengzhanbo/prettier-config": "^0.3.2",
66
45
  "@types/co-body": "^6.1.0",
67
46
  "@types/debug": "^4.1.7",
68
47
  "@types/formidable": "^2.0.5",
69
48
  "@types/node": "^18.11.7",
70
49
  "bumpp": "^8.2.1",
50
+ "conventional-changelog-cli": "^2.2.2",
71
51
  "eslint": "^8.31.0",
72
52
  "mockjs": "^1.1.0",
73
53
  "prettier": "^2.8.1",
74
54
  "tsup": "^6.5.0",
75
55
  "typescript": "^4.9.4",
76
56
  "vite": "^4.0.2",
77
- "vite-plugin-mock-dev-server": "file:",
78
- "vitepress": "1.0.0-alpha.32",
57
+ "vitepress": "1.0.0-alpha.35",
79
58
  "vue": "^3.2.45"
80
59
  },
60
+ "peerDependencies": {
61
+ "vite": ">=3.0.0"
62
+ },
63
+ "packageManager": "pnpm@7.18.2",
64
+ "engines": {
65
+ "node": "^14.18.0 || >=16"
66
+ },
67
+ "tsup": {
68
+ "entry": [
69
+ "src/index.ts"
70
+ ],
71
+ "sourcemap": false,
72
+ "dts": true,
73
+ "splitting": false,
74
+ "clean": true,
75
+ "format": [
76
+ "esm",
77
+ "cjs"
78
+ ]
79
+ },
81
80
  "scripts": {
82
- "dev": "DEBUG=vite:plugin-mock-dev-server vite example --config ./example/vite.config.ts",
83
81
  "build": "tsup",
84
- "docs:dev": "vitepress dev docs",
82
+ "dev": "DEBUG=vite:plugin-mock-dev-server vite example --config ./example/vite.config.ts",
85
83
  "docs:build": "vitepress build docs",
84
+ "docs:dev": "vitepress dev docs",
86
85
  "docs:preview": "vitepress preview docs",
87
86
  "lint": "eslint .",
88
- "release": "bumpp package.json --commit --push --tag && pnpm publish --access public"
87
+ "release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
88
+ "release": "bumpp package.json --execute=\"pnpm release:changelog\" --commit --all --push --tag && pnpm publish --access public"
89
89
  }
90
90
  }