mock-service-cli 4.9.3 → 4.10.0
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 +7 -9
- package/dist/meta.json +8 -8
- package/dist/runtime.js +4 -4
- package/docs/static-server.config.example.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,10 +94,10 @@ npx mock-service-cli [options] [path]
|
|
|
94
94
|
| `--spa-fallback <path>` | 单目录模式显式启用 SPA 回退 | - |
|
|
95
95
|
| `--static-config <file>` | 使用自包含 JSON 配置启动静态服务器 | - |
|
|
96
96
|
| `-w` 或 `--open` | 自动打开可用的 Web 页面或 API 概览页 | false |
|
|
97
|
-
| `--watch-depth <n>` |
|
|
98
|
-
| `--watch-interval <n>` |
|
|
99
|
-
| `--
|
|
100
|
-
| `--
|
|
97
|
+
| `--watch-depth <n>` | 限制静态服务器文件监听递归深度(非负整数,需配合 `--watch`) | 无限 |
|
|
98
|
+
| `--watch-interval <n>` | 轮询间隔(毫秒;仅 Windows Node 24+,需配合 `--watch`) | 250 |
|
|
99
|
+
| `--watch` | 开启静态服务器的文件监听与 live-reload(默认关闭) | false |
|
|
100
|
+
| `--windows-hidden` | 读取 Windows 系统隐藏属性(attrib/PowerShell)判定隐藏项 | false |
|
|
101
101
|
| `-e` 或 `--explorer` | 启用文件浏览器服务器,指定要浏览的目录 | ./ |
|
|
102
102
|
| `--edit` | 启用文件浏览器的新建、重命名、删除和上传操作 | false |
|
|
103
103
|
| `--auth <password>` | 为文件浏览器启用密码认证(仅可搭配 `--explorer`) | - |
|
|
@@ -135,10 +135,10 @@ mock-service-cli -R --static-config ./static-server.json
|
|
|
135
135
|
mock-service-cli --static-config ./static-server.json
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
静态服务器默认**不监听**资源变化;传入 `--watch` 才监听并注入热更新客户端:CSS 文件更新时替换样式表,其余变更刷新页面。
|
|
139
139
|
默认不打开浏览器;使用 `-w/--open` 可自动打开静态服务器页面。也可在配置中设置 `"open": true` 或提供页面路径。完整配置字段和示例见
|
|
140
140
|
[`docs/static-server.config.example.json`](./docs/static-server.config.example.json):支持忽略规则、SPA 回退、挂载目录、代理、HTTPS、CORS、响应头和自定义浏览器命令。
|
|
141
|
-
`watch.enabled` 默认 `
|
|
141
|
+
`watch.enabled` 默认 `false`,设为 `true` 或传入 `--watch` 可启用;`watch.depth` 限制 chokidar 递归层数(默认无限,大目录建议设有限值),`watch.interval` 为 Windows Node 24+ 轮询周期(默认 250ms)。命令行 `--watch`、`--watch-depth <n>`、`--watch-interval <n>` 优先于配置文件。
|
|
142
142
|
配置文件只在顶层保留服务器级字段。所有应用都放在 `mounts` 中,并可独立设置 `directory`、`spaFallback`、`proxy`、`cors`、`headers`、`requestHeaders` 和 `secure`。mount 未设置 `path` 时默认挂载到 `/`;`directory` 可省略,但该应用必须配置至少一条代理。代理键使用完整公开路径,例如 `/api/app`。
|
|
143
143
|
`headers` 是发送给客户端的响应头。`requestHeaders` 是发送给该应用全部代理上游的请求头;也可放在单个 `proxy` 规则中,覆盖或追加 mount 级请求头。代理规则使用 `{ "target": "http://...", "rewrite": true }`;`rewrite` 为 true 时只移除匹配的完整代理前缀并保留剩余路径和 query string。应用级 `secure` 控制其代理 HTTPS 目标的证书校验,默认 `false`。配置模式不接受 `--proxy-options`、`--rewrite` 或 `--spa-fallback`。
|
|
144
144
|
未设置 `spaFallback` 时,应用目录会显示可点击的目录索引;可直接访问其中的 HTML 文件。mount 未命中的路由不会继续进入其他应用的 SPA fallback。
|
|
@@ -192,9 +192,7 @@ mock-service-cli -e ./ --host
|
|
|
192
192
|
mock-service-cli -e ./ --host ./allowed-ips.txt
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
传入 `--no-os-hidden` 可跳过系统隐藏属性判定、仅按点号命名判定(利于规避个别属性误判与探测开销),
|
|
197
|
-
对静态服务器目录索引与文件浏览器同时生效。
|
|
195
|
+
静态服务器目录索引与文件浏览器默认只按点号命名判定隐藏项;传入 `--windows-hidden` 才会额外读取 Windows 系统隐藏属性。
|
|
198
196
|
|
|
199
197
|
默认情况下,Mock、SPA、Static 和 File Explorer 服务只监听 `127.0.0.1`。
|
|
200
198
|
`--host` 会使这些服务监听所有 IPv4 网卡,请仅在可信网络中使用。传入白名单文件时,服务仍监听全部 IPv4 网卡,
|
package/dist/meta.json
CHANGED
|
@@ -1041,7 +1041,7 @@
|
|
|
1041
1041
|
"format": "cjs"
|
|
1042
1042
|
},
|
|
1043
1043
|
"src/lib/utils.js": {
|
|
1044
|
-
"bytes":
|
|
1044
|
+
"bytes": 22646,
|
|
1045
1045
|
"imports": [
|
|
1046
1046
|
{
|
|
1047
1047
|
"path": "fs",
|
|
@@ -1098,7 +1098,7 @@
|
|
|
1098
1098
|
"format": "cjs"
|
|
1099
1099
|
},
|
|
1100
1100
|
"src/bin/mock-service-cli": {
|
|
1101
|
-
"bytes":
|
|
1101
|
+
"bytes": 16589,
|
|
1102
1102
|
"imports": [
|
|
1103
1103
|
{
|
|
1104
1104
|
"path": "node_modules/colors/safe.js",
|
|
@@ -7435,7 +7435,7 @@
|
|
|
7435
7435
|
"format": "cjs"
|
|
7436
7436
|
},
|
|
7437
7437
|
"src/lib/staticServer.js": {
|
|
7438
|
-
"bytes":
|
|
7438
|
+
"bytes": 39068,
|
|
7439
7439
|
"imports": [
|
|
7440
7440
|
{
|
|
7441
7441
|
"path": "node_modules/express/index.js",
|
|
@@ -8509,7 +8509,7 @@
|
|
|
8509
8509
|
"format": "cjs"
|
|
8510
8510
|
},
|
|
8511
8511
|
"src/lib/fileExplorerServer.js": {
|
|
8512
|
-
"bytes":
|
|
8512
|
+
"bytes": 26443,
|
|
8513
8513
|
"imports": [
|
|
8514
8514
|
{
|
|
8515
8515
|
"path": "node_modules/express/index.js",
|
|
@@ -10085,7 +10085,7 @@
|
|
|
10085
10085
|
"bytesInOutput": 928
|
|
10086
10086
|
},
|
|
10087
10087
|
"src/bin/mock-service-cli": {
|
|
10088
|
-
"bytesInOutput":
|
|
10088
|
+
"bytesInOutput": 12856
|
|
10089
10089
|
},
|
|
10090
10090
|
"node_modules/depd/index.js": {
|
|
10091
10091
|
"bytesInOutput": 6779
|
|
@@ -11201,7 +11201,7 @@
|
|
|
11201
11201
|
"bytesInOutput": 11845
|
|
11202
11202
|
},
|
|
11203
11203
|
"src/lib/staticServer.js": {
|
|
11204
|
-
"bytesInOutput":
|
|
11204
|
+
"bytesInOutput": 29934
|
|
11205
11205
|
},
|
|
11206
11206
|
"node_modules/busboy/lib/utils.js": {
|
|
11207
11207
|
"bytesInOutput": 8707
|
|
@@ -11378,13 +11378,13 @@
|
|
|
11378
11378
|
"bytesInOutput": 7774
|
|
11379
11379
|
},
|
|
11380
11380
|
"src/lib/fileExplorerServer.js": {
|
|
11381
|
-
"bytesInOutput":
|
|
11381
|
+
"bytesInOutput": 19484
|
|
11382
11382
|
},
|
|
11383
11383
|
"src/runtime.js": {
|
|
11384
11384
|
"bytesInOutput": 507
|
|
11385
11385
|
}
|
|
11386
11386
|
},
|
|
11387
|
-
"bytes":
|
|
11387
|
+
"bytes": 1837008
|
|
11388
11388
|
}
|
|
11389
11389
|
}
|
|
11390
11390
|
}
|