mock-service-cli 3.1.5 → 3.1.7

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
@@ -14,6 +14,11 @@
14
14
 
15
15
  **简易轻量**、**B/S 架构**、**0 秒启动**的本地命令行 Mock 服务套件, 支持热更新,对于开发调试 mock 数据很实用,能提高前端开发者的开发效率。支持 `GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`OPTIONS`,`COPY`,`LINK`,`UNLINK`,`PURGE` 等常用请求类型,无需布署后端,可能是本地最好用的 Mock 工具之一。
16
16
 
17
+ 特性功能:
18
+
19
+ - 支持统计 mock 的文件数量和 mock 请求数量
20
+ - 支持终端打开 mock 文件的所在位置
21
+
17
22
  #### Mock Server - 本地 Mock 服务器
18
23
 
19
24
  支持以下常见业务场景:
@@ -102,10 +107,16 @@ This will install `mock-service-cli` globally so that it may be run from the com
102
107
 
103
108
  `mock-service-cli -S`
104
109
 
105
- 6. Start static web server for SPA, and optionally specify public path and port.
106
- `mock-service-cli -D ../react-best-practice/dist [-b '/redbridge/'] [-P 9090]`
110
+ 6. Only Used as api server for test on browser console or api request tools.
111
+ > must specified server directory which can be empty but not includes index.html file, and also need config API proxy.
112
+
113
+ `mock-service-cli -D server -O '/api/apaas|http://192.168.0.105:60700'`
114
+
115
+ 7. Start static web server for SPA, and optionally specify public path and port.
116
+
117
+ `mock-service-cli -D ../react-best-practice/dist [-b '/redbridge/'] [-P 9090]`
107
118
 
108
- 7. Enable Proxy base on above item 6. support accept js file、json file、cli arguments string
119
+ 8. Enable Proxy base on above item 7. support accept js file、json file、cli arguments string
109
120
 
110
121
  - cli arguments string
111
122
 
package/lib/mockServer.js CHANGED
@@ -109,7 +109,7 @@ const composeRouteFromJsFile = function (file) {
109
109
  colors.grey(`path ${String(++count).padStart(3, ' ')}: `),
110
110
  colors.cyan(reqMethod.padEnd(8, ' ')),
111
111
  colors.cyan(reqUrl),
112
- colors.blue(typeof fileObject[item])
112
+ colors.grey(typeof fileObject[item])
113
113
  );
114
114
  log.assert(typeof app[reqMethod] === 'function', colors.red(`${file}, ${reqMethod}`));
115
115
  if (typeof fileObject[item] === 'function') {
@@ -154,7 +154,7 @@ const parseMockFiles = function (specialDir = '../mock') {
154
154
  colors.grey(`path ${String(++count).padStart(3, ' ')}: `),
155
155
  colors.cyan(method.padEnd(8, ' ')),
156
156
  colors.cyan(apiUrl),
157
- colors.blue(typeof fileObject[method])
157
+ colors.grey(typeof fileObject[method])
158
158
  );
159
159
  log.assert(typeof app[method] === 'function', colors.red(`${filePath}, ${method}`));
160
160
  app[method](apiUrl, function (req, res) {
@@ -221,10 +221,12 @@ if (process.env.WEB_ROOT) {
221
221
  webApp.use(webPublicPath, express.static(process.env.WEB_ROOT)); // 将dist目录下所有文件作为静态文件来管理
222
222
  const defaultStaticEntry = `${process.env.WEB_ROOT}/index.html`;
223
223
  if (fs.existsSync(defaultStaticEntry)) {
224
+ // Used as static HTTP server for SPA
224
225
  webApp.get('*', (req, res) => {
225
226
  res.sendFile(defaultStaticEntry);
226
227
  });
227
228
  } else {
229
+ // Used as api server for test on browser console or api request tools
228
230
  webApp.use(webPublicPath, (req, res) => {
229
231
  res.status(200)
230
232
  .send(`Hi, welcome to web server entrance ui, you can test http proxy on browser console or api request tools. Examples as follows:<br />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mock-service-cli",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "🦅 Local mock server",
5
5
  "main": "./lib/mockServer.js",
6
6
  "bin": {