mock-service-cli 2.0.3 → 2.0.4
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 +7 -0
- package/lib/mockServer.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.0.4](https://github.com/chandq/mock-service-cli/compare/v2.0.3...v2.0.4) (2021-12-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* get valid api url for route ([8770751](https://github.com/chandq/mock-service-cli/commit/877075107ea60244a52e345f37b7df855752d5f6))
|
|
11
|
+
|
|
5
12
|
### [2.0.3](https://github.com/chandq/mock-service-cli/compare/v2.0.2...v2.0.3) (2021-12-27)
|
|
6
13
|
|
|
7
14
|
|
package/lib/mockServer.js
CHANGED
|
@@ -7,7 +7,7 @@ const express = require('express'), // 引入express
|
|
|
7
7
|
chalk = require('chalk');
|
|
8
8
|
const ifaces = os.networkInterfaces();
|
|
9
9
|
const { Server } = require('socket.io');
|
|
10
|
-
const { dateFormat, logger, SupportMethods, getFileLatestContent } = require('./utils');
|
|
10
|
+
const { dateFormat, logger, SupportMethods, getFileLatestContent, filePath2ApiUrl } = require('./utils');
|
|
11
11
|
const { genMockFiles, getMockStatFromDir, getMockStatFromFile } = require('./manageMockFiles');
|
|
12
12
|
|
|
13
13
|
const methodRegExp = new RegExp(`(${SupportMethods.join('|')}) +(.*)`, 'i');
|
|
@@ -107,7 +107,7 @@ const parseMockFiles = function (specialDir = '../mock') {
|
|
|
107
107
|
const fileObject = getFileLatestContent(filePath);
|
|
108
108
|
// eslint-disable-next-line no-loop-func
|
|
109
109
|
Object.keys(fileObject).forEach(method => {
|
|
110
|
-
const apiUrl = decodeURIComponent(el.name.split('.')[0]);
|
|
110
|
+
const apiUrl = filePath2ApiUrl(decodeURIComponent(el.name.split('.')[0]));
|
|
111
111
|
log.info(colors.yellow(`path ${++count}: `), `${method} ${apiUrl}`, colors.blue(typeof fileObject[method]));
|
|
112
112
|
log.assert(typeof app[method] === 'function', colors.red(`${filePath}, ${method}`));
|
|
113
113
|
app[method](apiUrl, function (req, res) {
|