vite-plugin-mock-data 6.0.2 → 6.0.3

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,10 +2,11 @@
2
2
 
3
3
  [![npm package](https://nodei.co/npm/vite-plugin-mock-data.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/vite-plugin-mock-data)
4
4
 
5
- > Provides a simple way to mock data. Vite >= 3.1
5
+ > Provides a simple way to mock data.
6
6
 
7
7
  [![NPM version](https://img.shields.io/npm/v/vite-plugin-mock-data.svg?style=flat)](https://npmjs.org/package/vite-plugin-mock-data)
8
8
  [![NPM Downloads](https://img.shields.io/npm/dm/vite-plugin-mock-data.svg?style=flat)](https://npmjs.org/package/vite-plugin-mock-data)
9
+ [![Node version](https://img.shields.io/node/v/vite-plugin-mock-data.svg?style=flat)](https://npmjs.org/package/vite-plugin-mock-data)
9
10
 
10
11
  ## Installation
11
12
 
@@ -30,4 +31,4 @@ We welcome contributions from the community! If you find a bug or want to sugges
30
31
 
31
32
  ## License
32
33
 
33
- This project is licensed under the [MIT License](../../LICENSE).
34
+ This project is licensed under the [MIT License](LICENSE).
@@ -2,6 +2,6 @@ import { OutgoingHttpHeaders } from 'node:http';
2
2
  import { Config as SirvConfig, HTTPVersion } from 'find-my-way';
3
3
  import { type Options as SirvOptions } from 'sirv';
4
4
  import { ViteDevServer } from 'vite';
5
- import { RouteConfig } from './typings';
5
+ import { RouteConfig } from './types';
6
6
  export declare function sirvOptions(headers?: OutgoingHttpHeaders): SirvOptions;
7
7
  export declare function configureServer(server: ViteDevServer, routerOpts: SirvConfig<HTTPVersion.V1> | SirvConfig<HTTPVersion.V2> | undefined, routes: RouteConfig[], cwd: string): void;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
- import { Options } from './typings';
3
- export * from './typings';
2
+ import { Options } from './types';
3
+ export * from './types';
4
4
  /**
5
5
  * Provides a simple way to mock data.
6
6
  *
package/dist/index.js CHANGED
@@ -9,8 +9,6 @@ const node_fs = require("node:fs");
9
9
  const promises = require("node:fs/promises");
10
10
  const node_module = require("node:module");
11
11
  const tinyglobby = require("tinyglobby");
12
- const baseLogFactory = require("base-log-factory");
13
- const blfColorfulAppender = require("blf-colorful-appender");
14
12
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
15
13
  const name = "vite-plugin-mock-data";
16
14
  const pkg = {
@@ -81,13 +79,8 @@ function configureServer(server, routerOpts, routes, cwd) {
81
79
  router.lookup(req, res);
82
80
  });
83
81
  }
84
- const PLUGIN_NAME = pkg.name;
85
- const logger = new baseLogFactory.Logger(PLUGIN_NAME, {
86
- level: baseLogFactory.Level.WARN,
87
- appenders: [
88
- new blfColorfulAppender.ColorfulAppender()
89
- ]
90
- });
82
+ const PLUGIN_NAME = name;
83
+ const logger = vpRuntimeHelper.logFactory.getLogger(PLUGIN_NAME);
91
84
  async function getRoute(filename) {
92
85
  logger.debug("Load mock file:", filename);
93
86
  let { ext, dir, name: name2 } = node_path.parse(filename);
@@ -128,7 +121,9 @@ async function loadRoutes(dir, routes) {
128
121
  }
129
122
  }
130
123
  function pluginMockDate(opts) {
131
- vpRuntimeHelper.banner(pkg.name);
124
+ if (opts.enableBanner) {
125
+ vpRuntimeHelper.banner(pkg.name);
126
+ }
132
127
  const { isAfter, routerOptions, routes, logLevel, cwd = process.cwd() } = opts;
133
128
  if (logLevel) {
134
129
  logger.level = logLevel;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isObject } from "is-what-type";
2
- import { toAbsolutePath, banner } from "vp-runtime-helper";
2
+ import { toAbsolutePath, logFactory, banner } from "vp-runtime-helper";
3
3
  import { parse, join } from "node:path";
4
4
  import getRouter from "find-my-way";
5
5
  import sirv from "sirv";
@@ -8,8 +8,6 @@ import { readFileSync } from "node:fs";
8
8
  import { writeFile, unlink } from "node:fs/promises";
9
9
  import { createRequire } from "node:module";
10
10
  import { glob } from "tinyglobby";
11
- import { Logger, Level } from "base-log-factory";
12
- import { ColorfulAppender } from "blf-colorful-appender";
13
11
  const name = "vite-plugin-mock-data";
14
12
  const pkg = {
15
13
  name
@@ -79,13 +77,8 @@ function configureServer(server, routerOpts, routes, cwd) {
79
77
  router.lookup(req, res);
80
78
  });
81
79
  }
82
- const PLUGIN_NAME = pkg.name;
83
- const logger = new Logger(PLUGIN_NAME, {
84
- level: Level.WARN,
85
- appenders: [
86
- new ColorfulAppender()
87
- ]
88
- });
80
+ const PLUGIN_NAME = name;
81
+ const logger = logFactory.getLogger(PLUGIN_NAME);
89
82
  async function getRoute(filename) {
90
83
  logger.debug("Load mock file:", filename);
91
84
  let { ext, dir, name: name2 } = parse(filename);
@@ -126,7 +119,9 @@ async function loadRoutes(dir, routes) {
126
119
  }
127
120
  }
128
121
  function pluginMockDate(opts) {
129
- banner(pkg.name);
122
+ if (opts.enableBanner) {
123
+ banner(pkg.name);
124
+ }
130
125
  const { isAfter, routerOptions, routes, logLevel, cwd = process.cwd() } = opts;
131
126
  if (logLevel) {
132
127
  logger.level = logLevel;
@@ -1,2 +1,2 @@
1
- import { RouteConfig } from './typings';
1
+ import { RouteConfig } from './types';
2
2
  export default function loadRoutes(dir: string, routes: RouteConfig[]): Promise<void>;
@@ -1,5 +1,5 @@
1
- import { LogLevel } from 'base-log-factory';
2
1
  import { Config as SirvConfig, Handler, HTTPVersion, RouteOptions } from 'find-my-way';
2
+ import { LogLevel } from 'vp-runtime-helper';
3
3
  export interface HandleRoute {
4
4
  file?: string;
5
5
  handler?: any | Handler<HTTPVersion.V1>;
@@ -43,4 +43,10 @@ export interface Options {
43
43
  * or specify the directory to define mock routes that should be added to the dev server.
44
44
  */
45
45
  routes?: RouteConfig | Array<RouteConfig | string> | string;
46
+ /**
47
+ * Whether to output the banner
48
+ *
49
+ * 是否输出 banner
50
+ */
51
+ enableBanner?: boolean;
46
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-mock-data",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "description": "Provides a simple way to mock data.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -32,13 +32,11 @@
32
32
  },
33
33
  "homepage": "https://fengxinming.github.io/vite-plugins/plugins/vite-plugin-mock-data/quick-start",
34
34
  "dependencies": {
35
- "base-log-factory": "^2.0.9",
36
- "blf-colorful-appender": "^1.0.2",
37
35
  "find-my-way": "^9.2.0",
38
- "is-what-type": "^1.0.0",
36
+ "is-what-type": "^1.1.4",
39
37
  "sirv": "^3.0.1",
40
38
  "tinyglobby": "^0.2.12",
41
- "vp-runtime-helper": "^1.0.3"
39
+ "vp-runtime-helper": "^1.0.10"
42
40
  },
43
41
  "devDependencies": {
44
42
  "@rollup/plugin-typescript": "^12.1.2",
@@ -49,7 +47,7 @@
49
47
  "dist"
50
48
  ],
51
49
  "scripts": {
52
- "build:lib": "vite build",
50
+ "build": "vite build",
53
51
  "watch": "vite build --watch",
54
52
  "release": "pnpm publish --no-git-checks"
55
53
  }
package/dist/logger.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Logger } from 'base-log-factory';
2
- export declare const PLUGIN_NAME: string;
3
- export declare const logger: Logger;