har-gen-api 0.1.2 → 0.1.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/.editorconfig +9 -0
- package/README.md +44 -20
- package/package.json +29 -29
package/.editorconfig
ADDED
package/README.md
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
# har-gen-api
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
# har-gen-api
|
|
2
|
+
|
|
3
|
+
> 浏览器har文件转成自定义的接口文件,通过`vite`启动`mock`服务,实现接口模拟
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
### 安装
|
|
8
|
+
```bash
|
|
9
|
+
npm install har-gen-api
|
|
10
|
+
# or
|
|
11
|
+
yarn add har-gen-api
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 导出har文件
|
|
15
|
+
1. 打开浏览器`chrome`
|
|
16
|
+
2. 打开`F12`切换到`Network`
|
|
17
|
+
3. 点击导出按钮,选择保存路径
|
|
18
|
+
4. 保存**har**文件到 `mock/har.local` 文件夹下
|
|
19
|
+
|
|
20
|
+
### 命令行使用
|
|
21
|
+
```bash
|
|
22
|
+
npx har-gen-api --input mock/har.local --output mock/api.local --baseURL /api --overwrite
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 参数说明:
|
|
26
|
+
* input: 输入路径,默认为 `mock/har.local` (default: "mock/har.local")
|
|
27
|
+
* output: 输出路径,默认为 `mock/api.local` (default: "mock/api.local")
|
|
28
|
+
* baseURL: baseURL路径 (default: "")
|
|
29
|
+
* overwrite: 是否覆盖已存在的文件 (default: false)
|
|
30
|
+
|
|
31
|
+
### vite配置
|
|
32
|
+
```js
|
|
33
|
+
import { mockServer } from 'har-gen-api/vite';
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
plugins: [
|
|
37
|
+
mockServer({
|
|
38
|
+
mockPath: 'mock',
|
|
39
|
+
baseURL: '/api',
|
|
40
|
+
enabled: true
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
```
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "har-gen-api",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/lemonppai/har-gen-api.git"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"import": "./index.js"
|
|
13
|
-
},
|
|
14
|
-
"./vite": {
|
|
15
|
-
"import": "./mockServer.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"bin": {
|
|
19
|
-
"har-gen-api": "bin/cli.js"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"cfonts": "^3.3.1",
|
|
23
|
-
"chalk": "^5.6.2",
|
|
24
|
-
"commander": "^14.0.3",
|
|
25
|
-
"json5": "^2.2.3",
|
|
26
|
-
"lodash": "^4.18.1",
|
|
27
|
-
"mockjs": "^1.1.0"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "har-gen-api",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.4",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lemonppai/har-gen-api.git"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./vite": {
|
|
15
|
+
"import": "./mockServer.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"har-gen-api": "bin/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"cfonts": "^3.3.1",
|
|
23
|
+
"chalk": "^5.6.2",
|
|
24
|
+
"commander": "^14.0.3",
|
|
25
|
+
"json5": "^2.2.3",
|
|
26
|
+
"lodash": "^4.18.1",
|
|
27
|
+
"mockjs": "^1.1.0"
|
|
28
|
+
}
|
|
29
|
+
}
|