mock-service-cli 2.1.0 → 2.1.1
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/CHANGELOG.md +8 -0
- package/lib/manageMockFiles.js +13 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.1.1](https://github.com/chandq/mock-service-cli/compare/v2.1.0...v2.1.1) (2021-12-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* issue of friendly show error tip ([e9822c2](https://github.com/chandq/mock-service-cli/commit/e9822c2038ad411d91a170af33e7541e266ca8e6))
|
|
11
|
+
* issue of empty file content ([3949e00](https://github.com/chandq/mock-service-cli/commit/3949e00a46b4555bc08ec8564221cc230c780dcb))
|
|
12
|
+
|
|
5
13
|
## [2.1.0](https://github.com/chandq/mock-service-cli/compare/v2.0.5...v2.1.0) (2021-12-30)
|
|
6
14
|
|
|
7
15
|
|
package/lib/manageMockFiles.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @description: 生成Mock文件、获取mock数据统计
|
|
3
3
|
* @Date: 2021-12-22 16:57:08
|
|
4
4
|
* @LastEditors: chendq
|
|
5
|
-
* @LastEditTime: 2021-12-30
|
|
5
|
+
* @LastEditTime: 2021-12-30 16:43:04
|
|
6
6
|
* @Author: chendq
|
|
7
7
|
*/
|
|
8
8
|
const fsa = require('fs-extra'),
|
|
@@ -24,15 +24,22 @@ const methodRegExp = new RegExp(`(${SupportMethods.join('|')}) +(.*)`, 'i');
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
const genMockFiles = function ({ url: apiUrl, method, data: resJsonData, dir: mockDir }) {
|
|
27
|
+
const type = getDataType(resJsonData);
|
|
27
28
|
if (!apiUrl || !method || !resJsonData || !mockDir) {
|
|
28
29
|
log.info(
|
|
29
|
-
colors.red(
|
|
30
|
-
[`参数: apiUrl: ${apiUrl}, method: ${method}, mockDir: ${mockDir}, resJsonData: `, `必须是有效值`].join(',')
|
|
31
|
-
)
|
|
30
|
+
colors.red([`参数: apiUrl: ${apiUrl}, method: ${method}, mockDir: ${mockDir} `, `必须是有效值`].join(','))
|
|
32
31
|
);
|
|
33
32
|
return;
|
|
34
|
-
} else if (
|
|
35
|
-
|
|
33
|
+
} else if (
|
|
34
|
+
!['object', 'array'].includes(type) ||
|
|
35
|
+
(type === 'object' && Object.keys(resJsonData).length === 0) ||
|
|
36
|
+
(type === 'array' && resJsonData.length === 0)
|
|
37
|
+
) {
|
|
38
|
+
log.info(
|
|
39
|
+
`参数: apiUrl: ${apiUrl}, method: ${method}, resJsonData:`,
|
|
40
|
+
resJsonData,
|
|
41
|
+
colors.red(', 参数字段resJsonData必须是非空的数组或对象!')
|
|
42
|
+
);
|
|
36
43
|
return;
|
|
37
44
|
}
|
|
38
45
|
apiUrl = apiUrl.trim().split('?')[0];
|