mock-service-cli 3.3.4 → 3.3.6
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 +4 -5
- package/lib/mockServer.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,12 +89,11 @@ This will install `mock-service-cli` globally so that it may be run from the com
|
|
|
89
89
|
| `-t` or `--track` | Whether record operation info by write file, default false. | false |
|
|
90
90
|
| `-o` or `--cors-origin` | Allow origin by cors, list separated by commas, must not be \* when withCredential is true .If specified, cors-headers will be `Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token,Token` | \* |
|
|
91
91
|
| `-O` or `--proxy-options` | Optionally provide http request proxy options list, support accept js file、json file、cli arguments string. Examples: `-O '/api/apaas\|http://192.168.0.105:60700,/api/permission\| http://192.168.0.105:60700'`. Must start web server to use proxy for http request test under browser console or api test tools. | - |
|
|
92
|
-
| `-H` or `--cors-headers` | When start Mock Server, optionally provide CORS headers list separated by commas. default
|
|
92
|
+
| `-H` or `--cors-headers` | When start Mock Server, optionally provide CORS headers list separated by commas. default . | \* |
|
|
93
93
|
| `-A` or `--append-headers` | When start Mock/Web/Static Server, optionally add response headers list separated by commas. For example: X-Frame-options=DENY,content-security-policy=frame-ancestors. | - |
|
|
94
|
-
|
|
95
|
-
| `-
|
|
96
|
-
| `-
|
|
97
|
-
| `-R` or `--static-server` | Specify directory of the Static Web Server. | - |
|
|
94
|
+
| `-P` or `--web-port` | Web server port to use. Use `-P 9090` to look for an open port, starting at 9090. | 9090 |
|
|
95
|
+
| `-b` or `--web-baseurl` | Specify public path of the SPA web server, can be base address of SPA route. | - |
|
|
96
|
+
| `-R` or `--static-server` | Specify directory of the Static Web Server. | - |
|
|
98
97
|
|
|
99
98
|
## Example
|
|
100
99
|
|
package/lib/mockServer.js
CHANGED
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
} = require('./utils');
|
|
20
20
|
const { genMockFiles, getMockStatFromDir, getMockStatFromFile } = require('./manageMockFiles');
|
|
21
21
|
|
|
22
|
-
const methodRegExp = new RegExp(`(${SupportMethods.join('|')}) +(
|
|
22
|
+
const methodRegExp = new RegExp(`((${SupportMethods.join('|')}) +)?([^?]*)`, 'i');
|
|
23
23
|
|
|
24
24
|
const app = express();
|
|
25
25
|
const log = logger(process.env.SILENT);
|
|
@@ -138,11 +138,11 @@ function composeRouteFromJsFile(file) {
|
|
|
138
138
|
let reqMethod = 'get',
|
|
139
139
|
reqUrl = item;
|
|
140
140
|
// 支持(GET|POST|PUT|DELETE|HEAD|PATCH|OPTIONS|COPY|LINK|UNLINK|PURGE)常用方法, 默认GET请求
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
const [, , method, url] = methodRegExp.exec(item);
|
|
142
|
+
if (method) {
|
|
143
143
|
reqMethod = method.toLowerCase();
|
|
144
|
-
reqUrl = url;
|
|
145
144
|
}
|
|
145
|
+
reqUrl = url;
|
|
146
146
|
argv.a &&
|
|
147
147
|
log.info(
|
|
148
148
|
colors.grey(`path ${String(++count).padStart(3, ' ')}: `),
|