@jonathanleelx/meddle 0.5.0 → 0.5.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/bin/commands/mock/add.js +22 -0
- package/bin/commands/mock/index.js +51 -21
- package/bin/commands/route/add.js +2 -2
- package/bin/commands/route/delete.js +2 -2
- package/bin/commands/route/index.js +60 -30
- package/bin/commands/route/preview.js +2 -2
- package/bin/commands/route/show.js +2 -2
- package/bin/commands/route/update.js +2 -2
- package/bin/commands/status.js +27 -11
- package/bin/doctor.js +8 -4
- package/bin/index.js +4 -4
- package/bin/lib/file-access.js +28 -11
- package/bin/lib/meddle-home.js +14 -1
- package/bin/lib/output.js +8 -3
- package/bin/lib/proxy-or-file.js +4 -1
- package/dist/cert.d.ts +2 -0
- package/dist/cert.d.ts.map +1 -1
- package/dist/cert.js +10 -1
- package/dist/cert.js.map +1 -1
- package/dist/core/browser.d.ts +2 -0
- package/dist/core/browser.d.ts.map +1 -1
- package/dist/core/browser.js +21 -8
- package/dist/core/browser.js.map +1 -1
- package/dist/core/mock-handler.d.ts +5 -1
- package/dist/core/mock-handler.d.ts.map +1 -1
- package/dist/core/mock-handler.js +17 -3
- package/dist/core/mock-handler.js.map +1 -1
- package/dist/core/proxy-record.d.ts +14 -0
- package/dist/core/proxy-record.d.ts.map +1 -1
- package/dist/core/proxy-record.js +39 -0
- package/dist/core/proxy-record.js.map +1 -1
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +15 -9
- package/dist/server/config.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +7 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/json-parse-error.d.ts +7 -0
- package/dist/server/json-parse-error.d.ts.map +1 -0
- package/dist/server/json-parse-error.js +28 -0
- package/dist/server/json-parse-error.js.map +1 -0
- package/dist/server/mocks.d.ts +1 -1
- package/dist/server/mocks.d.ts.map +1 -1
- package/dist/server/rule-files.d.ts.map +1 -1
- package/dist/server/rule-files.js +2 -9
- package/dist/server/rule-files.js.map +1 -1
- package/index.js +92 -9
- package/mcp-server.js +18 -5
- package/package.json +1 -1
- package/web/dist/assets/detail-panel-DZRKJG2W.js +4 -0
- package/web/dist/assets/global-panel-shell-Iir-c_pQ.js +6 -0
- package/web/dist/assets/{health-panel-DhXLqcOU.js → health-panel-Dmf-EhJz.js} +1 -1
- package/web/dist/assets/{index-B-6nUrqW.js → index-C4dIj1nT.js} +5 -5
- package/web/dist/assets/index-CdYMl1M7.css +2 -0
- package/web/dist/assets/{mobile-proxy-panel-BY8Oi-qC.js → mobile-proxy-panel-CFcwa11A.js} +5 -5
- package/web/dist/assets/{mock-config-TPmfJwAt.js → mock-config-CGl50MIr.js} +1 -1
- package/web/dist/assets/mock-editor-panel-xcCk23oH.js +20 -0
- package/web/dist/assets/{mocks-file-missing-note-BR5oWFLh.js → mocks-file-missing-note-CW_ONVLA.js} +1 -1
- package/web/dist/assets/{monaco-editor-BGLPrb0C.js → monaco-editor-BkP7envQ.js} +1 -1
- package/web/dist/assets/{pane-bar-gFRISZLD.js → pane-bar-5j9Nf7W_.js} +1 -1
- package/web/dist/assets/{pane-split-B6aLmY7G.js → pane-split-C0OSe365.js} +1 -1
- package/web/dist/assets/panel-heading-izT5q0ZN.js +1 -0
- package/web/dist/assets/plugin-code-editor-DKE9dFEE.js +2 -0
- package/web/dist/assets/plugin-config-Cg09TsuV.js +2 -0
- package/web/dist/assets/{plugin-generator-Bj4f6dxo.js → plugin-generator-CT1f1tu0.js} +2 -2
- package/web/dist/assets/plugin-test-dialog-BbLIMnkJ.js +7 -0
- package/web/dist/assets/route-preview-CKO7nF4W.js +1 -0
- package/web/dist/assets/{rule-ai-assistant-panel-BEfPNBbx.js → rule-ai-assistant-panel-CtfUqdYG.js} +2 -2
- package/web/dist/assets/rule-config-Cb4ejIXI.js +15 -0
- package/web/dist/assets/rule-overview-panel-xtHTS27O.js +1 -0
- package/web/dist/assets/settings-panel-CpQuE6nr.js +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/detail-panel-BtgWWeu3.js +0 -4
- package/web/dist/assets/global-panel-shell-NaUhzX7J.js +0 -6
- package/web/dist/assets/index-EWNlAdFB.css +0 -2
- package/web/dist/assets/mock-editor-panel-WQwcHSTD.js +0 -20
- package/web/dist/assets/panel-heading-DT_nXayM.js +0 -1
- package/web/dist/assets/plugin-code-editor--Gf4ZwGb.js +0 -2
- package/web/dist/assets/plugin-config-DsX9xCW_.js +0 -2
- package/web/dist/assets/plugin-test-dialog-DICuykBK.js +0 -7
- package/web/dist/assets/route-preview-C-LzS1lT.js +0 -1
- package/web/dist/assets/rule-config-Dw9pcuah.js +0 -15
- package/web/dist/assets/rule-overview-panel-C4QQ7U3S.js +0 -1
- package/web/dist/assets/settings-panel-D8DEH8aH.js +0 -1
package/bin/commands/mock/add.js
CHANGED
|
@@ -7,8 +7,30 @@ const { apiPost } = require('../../lib/api-client')
|
|
|
7
7
|
const { addMockRule } = require('../../lib/file-access')
|
|
8
8
|
const { withProxyOrFile, failCommand } = require('../../lib/proxy-or-file')
|
|
9
9
|
|
|
10
|
+
const MOCK_ADD_HELP = `
|
|
11
|
+
meddle mock add --name <n> --pattern <p> [options] [--json]
|
|
12
|
+
|
|
13
|
+
Add a mock rule. Required: --name and --pattern.
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--name <n> Rule name
|
|
17
|
+
--pattern <p> URL pattern (regex or string; may include query)
|
|
18
|
+
--query <q> Query match (exact key=value params)
|
|
19
|
+
--method <m> HTTP method (GET, POST, *, default: *)
|
|
20
|
+
--status <s> Response status code (default: 200)
|
|
21
|
+
--body <b> Response body content
|
|
22
|
+
--delay <d> Response delay in ms (default: 0)
|
|
23
|
+
--headers <json> Response headers JSON (values may use {origin})
|
|
24
|
+
--cors Shortcut: credentials-friendly CORS headers with {origin}
|
|
25
|
+
--json JSON output
|
|
26
|
+
`
|
|
27
|
+
|
|
10
28
|
// Parse arguments
|
|
11
29
|
const args = process.argv.slice(3)
|
|
30
|
+
if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {
|
|
31
|
+
console.log(MOCK_ADD_HELP.trim())
|
|
32
|
+
process.exit(0)
|
|
33
|
+
}
|
|
12
34
|
const jsonFlag = args.includes('--json')
|
|
13
35
|
output.setJsonMode(jsonFlag)
|
|
14
36
|
|
|
@@ -2,28 +2,13 @@
|
|
|
2
2
|
* meddle mock - Mock rule subcommand router
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
const output = require('../../lib/output')
|
|
6
|
+
|
|
5
7
|
const args = process.argv.slice(3)
|
|
6
8
|
const subcommand = args[0]
|
|
9
|
+
const jsonFlag = args.includes('--json')
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
case 'list':
|
|
10
|
-
require('./list.js')
|
|
11
|
-
break
|
|
12
|
-
case 'add':
|
|
13
|
-
require('./add.js')
|
|
14
|
-
break
|
|
15
|
-
case 'update':
|
|
16
|
-
require('./update.js')
|
|
17
|
-
break
|
|
18
|
-
case 'delete':
|
|
19
|
-
require('./delete.js')
|
|
20
|
-
break
|
|
21
|
-
case 'enable':
|
|
22
|
-
case 'disable':
|
|
23
|
-
require('./toggle.js')
|
|
24
|
-
break
|
|
25
|
-
default:
|
|
26
|
-
console.log(`
|
|
11
|
+
const MOCK_HELP = `
|
|
27
12
|
Mock Commands:
|
|
28
13
|
meddle mock list [--json] List all mock rules
|
|
29
14
|
meddle mock add [options] Add a mock rule
|
|
@@ -49,6 +34,51 @@ Examples:
|
|
|
49
34
|
meddle mock add --name "Policy A" --pattern "/ops/.*/policy" --query "window_key=A" --body '{"key":"A"}' --cors
|
|
50
35
|
meddle mock update 1 --status 404 --headers '{"X-Debug":"1"}'
|
|
51
36
|
meddle mock delete 1
|
|
52
|
-
`
|
|
53
|
-
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
function printHelp(stream = process.stdout) {
|
|
40
|
+
stream.write(MOCK_HELP.trimStart())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function failUnknown(name) {
|
|
44
|
+
const message = `Unknown command: mock ${name}`
|
|
45
|
+
if (jsonFlag) {
|
|
46
|
+
output.setJsonMode(true)
|
|
47
|
+
output.error(message)
|
|
48
|
+
} else {
|
|
49
|
+
console.error(message)
|
|
50
|
+
printHelp(process.stderr)
|
|
51
|
+
}
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
switch (subcommand) {
|
|
56
|
+
case 'list':
|
|
57
|
+
require('./list.js')
|
|
58
|
+
break
|
|
59
|
+
case 'add':
|
|
60
|
+
require('./add.js')
|
|
61
|
+
break
|
|
62
|
+
case 'update':
|
|
63
|
+
require('./update.js')
|
|
64
|
+
break
|
|
65
|
+
case 'delete':
|
|
66
|
+
require('./delete.js')
|
|
67
|
+
break
|
|
68
|
+
case 'enable':
|
|
69
|
+
case 'disable':
|
|
70
|
+
require('./toggle.js')
|
|
71
|
+
break
|
|
72
|
+
case '--help':
|
|
73
|
+
case '-h':
|
|
74
|
+
case 'help':
|
|
75
|
+
printHelp()
|
|
76
|
+
process.exit(0)
|
|
77
|
+
break
|
|
78
|
+
default:
|
|
79
|
+
if (!subcommand) {
|
|
80
|
+
printHelp()
|
|
81
|
+
process.exit(1)
|
|
82
|
+
}
|
|
83
|
+
failUnknown(subcommand)
|
|
54
84
|
}
|
|
@@ -123,7 +123,7 @@ async function run() {
|
|
|
123
123
|
// Issue #137: a locked ruleset is a final answer, never a cue to write the file directly.
|
|
124
124
|
if (isRulesetReadonlyError(e)) exitRulesetReadonly(e, { json: jsonFlag, ruleFile: fileName })
|
|
125
125
|
const content = getRuleFileContent(fileName)
|
|
126
|
-
if (
|
|
126
|
+
if (content == null) fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
127
127
|
const newContent = applyAdd(content, plan)
|
|
128
128
|
saveRuleFileContent(fileName, newContent)
|
|
129
129
|
output.warnFileOnlyMode()
|
|
@@ -133,7 +133,7 @@ async function run() {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
const content = getRuleFileContent(fileName)
|
|
136
|
-
if (
|
|
136
|
+
if (content == null) fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
137
137
|
const newContent = applyAdd(content, plan)
|
|
138
138
|
saveRuleFileContent(fileName, newContent)
|
|
139
139
|
output.warnFileOnlyMode()
|
|
@@ -101,7 +101,7 @@ async function run() {
|
|
|
101
101
|
if (isRulesetReadonlyError(e)) exitRulesetReadonly(e, { json: jsonFlag, ruleFile: fileName })
|
|
102
102
|
// Fallback to file mode
|
|
103
103
|
const content = getRuleFileContent(fileName)
|
|
104
|
-
if (
|
|
104
|
+
if (content == null) {
|
|
105
105
|
fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -125,7 +125,7 @@ async function run() {
|
|
|
125
125
|
} else {
|
|
126
126
|
// File mode
|
|
127
127
|
const content = getRuleFileContent(fileName)
|
|
128
|
-
if (
|
|
128
|
+
if (content == null) {
|
|
129
129
|
fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -2,36 +2,13 @@
|
|
|
2
2
|
* meddle route - Route rule subcommand router
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
const output = require('../../lib/output')
|
|
6
|
+
|
|
5
7
|
const args = process.argv.slice(3)
|
|
6
8
|
const subcommand = args[0]
|
|
9
|
+
const jsonFlag = args.includes('--json')
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
case 'list':
|
|
10
|
-
require('./list.js')
|
|
11
|
-
break
|
|
12
|
-
case 'show':
|
|
13
|
-
require('./show.js')
|
|
14
|
-
break
|
|
15
|
-
case 'preview':
|
|
16
|
-
require('./preview.js')
|
|
17
|
-
break
|
|
18
|
-
case 'active':
|
|
19
|
-
require('./active.js')
|
|
20
|
-
break
|
|
21
|
-
case 'create':
|
|
22
|
-
require('./create.js')
|
|
23
|
-
break
|
|
24
|
-
case 'add':
|
|
25
|
-
require('./add.js')
|
|
26
|
-
break
|
|
27
|
-
case 'update':
|
|
28
|
-
require('./update.js')
|
|
29
|
-
break
|
|
30
|
-
case 'delete':
|
|
31
|
-
require('./delete.js')
|
|
32
|
-
break
|
|
33
|
-
default:
|
|
34
|
-
console.log(`
|
|
11
|
+
const ROUTE_HELP = `
|
|
35
12
|
Route Commands:
|
|
36
13
|
meddle route list [--json] List all route files
|
|
37
14
|
meddle route show <file> [--json] Show rules in a file
|
|
@@ -72,6 +49,59 @@ Exclusions:
|
|
|
72
49
|
|
|
73
50
|
A "#" comments out a whole line only when it is the first non-space
|
|
74
51
|
character. A "#" later on a rule line is a pattern, not a trailing comment.
|
|
75
|
-
`
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
`
|
|
53
|
+
|
|
54
|
+
function printHelp(stream = process.stdout) {
|
|
55
|
+
stream.write(ROUTE_HELP.trimStart())
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function failUnknown(name) {
|
|
59
|
+
const message = `Unknown command: route ${name}`
|
|
60
|
+
if (jsonFlag) {
|
|
61
|
+
output.setJsonMode(true)
|
|
62
|
+
output.error(message)
|
|
63
|
+
} else {
|
|
64
|
+
console.error(message)
|
|
65
|
+
printHelp(process.stderr)
|
|
66
|
+
}
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
switch (subcommand) {
|
|
71
|
+
case 'list':
|
|
72
|
+
require('./list.js')
|
|
73
|
+
break
|
|
74
|
+
case 'show':
|
|
75
|
+
require('./show.js')
|
|
76
|
+
break
|
|
77
|
+
case 'preview':
|
|
78
|
+
require('./preview.js')
|
|
79
|
+
break
|
|
80
|
+
case 'active':
|
|
81
|
+
require('./active.js')
|
|
82
|
+
break
|
|
83
|
+
case 'create':
|
|
84
|
+
require('./create.js')
|
|
85
|
+
break
|
|
86
|
+
case 'add':
|
|
87
|
+
require('./add.js')
|
|
88
|
+
break
|
|
89
|
+
case 'update':
|
|
90
|
+
require('./update.js')
|
|
91
|
+
break
|
|
92
|
+
case 'delete':
|
|
93
|
+
require('./delete.js')
|
|
94
|
+
break
|
|
95
|
+
case '--help':
|
|
96
|
+
case '-h':
|
|
97
|
+
case 'help':
|
|
98
|
+
printHelp()
|
|
99
|
+
process.exit(0)
|
|
100
|
+
break
|
|
101
|
+
default:
|
|
102
|
+
if (!subcommand) {
|
|
103
|
+
printHelp()
|
|
104
|
+
process.exit(1)
|
|
105
|
+
}
|
|
106
|
+
failUnknown(subcommand)
|
|
107
|
+
}
|
|
@@ -57,7 +57,7 @@ async function run() {
|
|
|
57
57
|
const content = await fetch(`${baseUrl}/api/rule-files/${encodeURIComponent(ruleFileArg)}/content`)
|
|
58
58
|
.then(r => r.ok ? r.text() : null)
|
|
59
59
|
.catch(() => null)
|
|
60
|
-
if (
|
|
60
|
+
if (content == null) {
|
|
61
61
|
output.error(`Rule file not found: ${ruleFileArg}`)
|
|
62
62
|
process.exit(1)
|
|
63
63
|
}
|
|
@@ -91,7 +91,7 @@ async function run() {
|
|
|
91
91
|
if (ruleFileArg) {
|
|
92
92
|
// Use specified rule file
|
|
93
93
|
const content = getRuleFileContent(ruleFileArg)
|
|
94
|
-
if (
|
|
94
|
+
if (content == null) {
|
|
95
95
|
output.error(`Rule file not found: ${ruleFileArg}`)
|
|
96
96
|
process.exit(1)
|
|
97
97
|
}
|
|
@@ -41,7 +41,7 @@ async function run() {
|
|
|
41
41
|
} catch (e) {
|
|
42
42
|
// Fallback to file mode
|
|
43
43
|
content = getRuleFileContent(fileName)
|
|
44
|
-
if (
|
|
44
|
+
if (content == null) {
|
|
45
45
|
output.error(`Route file not found: ${fileName}`)
|
|
46
46
|
process.exit(1)
|
|
47
47
|
}
|
|
@@ -52,7 +52,7 @@ async function run() {
|
|
|
52
52
|
}
|
|
53
53
|
} else {
|
|
54
54
|
content = getRuleFileContent(fileName)
|
|
55
|
-
if (
|
|
55
|
+
if (content == null) {
|
|
56
56
|
output.error(`Route file not found: ${fileName}`)
|
|
57
57
|
process.exit(1)
|
|
58
58
|
}
|
|
@@ -146,7 +146,7 @@ async function run() {
|
|
|
146
146
|
if (isRulesetReadonlyError(e)) exitRulesetReadonly(e, { json: jsonFlag, ruleFile: fileName })
|
|
147
147
|
// Fallback to file mode
|
|
148
148
|
const content = getRuleFileContent(fileName)
|
|
149
|
-
if (
|
|
149
|
+
if (content == null) fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
150
150
|
const newContent = applyUpdate(content, plan)
|
|
151
151
|
saveRuleFileContent(fileName, newContent)
|
|
152
152
|
output.warnFileOnlyMode()
|
|
@@ -156,7 +156,7 @@ async function run() {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const content = getRuleFileContent(fileName)
|
|
159
|
-
if (
|
|
159
|
+
if (content == null) fail(`Route file not found: ${fileName}`, jsonFlag)
|
|
160
160
|
const newContent = applyUpdate(content, plan)
|
|
161
161
|
saveRuleFileContent(fileName, newContent)
|
|
162
162
|
output.warnFileOnlyMode()
|
package/bin/commands/status.js
CHANGED
|
@@ -22,6 +22,22 @@ async function run() {
|
|
|
22
22
|
let activeRoutes = 0
|
|
23
23
|
let health = null
|
|
24
24
|
|
|
25
|
+
let mocksError = null
|
|
26
|
+
|
|
27
|
+
function readMocksFromFile() {
|
|
28
|
+
try {
|
|
29
|
+
const mocks = loadMockRules()
|
|
30
|
+
mockCount = mocks.length
|
|
31
|
+
activeMocks = mocks.filter(m => m.enabled).length
|
|
32
|
+
} catch (err) {
|
|
33
|
+
mocksError = err && err.code === 'MOCKS_FILE_INVALID'
|
|
34
|
+
? 'Mock 规则文件格式错误'
|
|
35
|
+
: (err && err.message ? String(err.message) : String(err))
|
|
36
|
+
mockCount = 0
|
|
37
|
+
activeMocks = 0
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
if (running) {
|
|
26
42
|
try {
|
|
27
43
|
// Get mock rules from API
|
|
@@ -36,19 +52,13 @@ async function run() {
|
|
|
36
52
|
health = await apiGet('/api/health')
|
|
37
53
|
} catch (_) {
|
|
38
54
|
// Fallback to file access
|
|
39
|
-
|
|
40
|
-
mockCount = mocks.length
|
|
41
|
-
activeMocks = mocks.filter(m => m.enabled).length
|
|
42
|
-
|
|
55
|
+
readMocksFromFile()
|
|
43
56
|
routeFiles = listRuleFiles()
|
|
44
57
|
activeRoutes = routeFiles.filter(f => f.enabled).length
|
|
45
58
|
}
|
|
46
59
|
} else {
|
|
47
60
|
// File mode
|
|
48
|
-
|
|
49
|
-
mockCount = mocks.length
|
|
50
|
-
activeMocks = mocks.filter(m => m.enabled).length
|
|
51
|
-
|
|
61
|
+
readMocksFromFile()
|
|
52
62
|
routeFiles = listRuleFiles()
|
|
53
63
|
activeRoutes = routeFiles.filter(f => f.enabled).length
|
|
54
64
|
}
|
|
@@ -61,7 +71,9 @@ async function run() {
|
|
|
61
71
|
proxyUrl: url,
|
|
62
72
|
running,
|
|
63
73
|
health,
|
|
64
|
-
mocks:
|
|
74
|
+
mocks: mocksError
|
|
75
|
+
? { total: mockCount, active: activeMocks, error: mocksError }
|
|
76
|
+
: { total: mockCount, active: activeMocks },
|
|
65
77
|
routes: { files: routeFiles.length, activeFiles: activeRoutes, totalRules: totalRouteRules, totalExclusions }
|
|
66
78
|
})
|
|
67
79
|
return
|
|
@@ -81,8 +93,12 @@ async function run() {
|
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
output.section('Mock Rules')
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
if (mocksError) {
|
|
97
|
+
output.warning(mocksError)
|
|
98
|
+
} else {
|
|
99
|
+
output.kv('Total', mockCount)
|
|
100
|
+
output.kv('Active', activeMocks)
|
|
101
|
+
}
|
|
86
102
|
|
|
87
103
|
output.section('Route Rules')
|
|
88
104
|
output.kv('Files', routeFiles.length)
|
package/bin/doctor.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const fs = require('fs')
|
|
8
8
|
const path = require('path')
|
|
9
9
|
const chalk = require('chalk')
|
|
10
|
-
const { resolveMeddleHome } = require('./lib/meddle-home')
|
|
10
|
+
const { resolveMeddleHome, resolveConfiguredMocksPath } = require('./lib/meddle-home')
|
|
11
11
|
|
|
12
12
|
const meddleDir = resolveMeddleHome()
|
|
13
13
|
const settingsPath = path.resolve(meddleDir, 'settings.json')
|
|
@@ -183,10 +183,14 @@ function checkMocksFile(settings) {
|
|
|
183
183
|
|
|
184
184
|
let mocksPath = defaultMocksPath
|
|
185
185
|
|
|
186
|
-
//
|
|
186
|
+
// Same resolution as the proxy: ~ expands, relative paths use MEDDLE_HOME.
|
|
187
187
|
if (settings && settings.mocksFilePath) {
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const resolved = resolveConfiguredMocksPath(settings.mocksFilePath, meddleDir)
|
|
189
|
+
mocksPath = resolved || defaultMocksPath
|
|
190
|
+
printInfo(`使用自定义路径: ${settings.mocksFilePath}`)
|
|
191
|
+
if (resolved && resolved !== settings.mocksFilePath) {
|
|
192
|
+
printInfo(`解析后路径: ${resolved}`)
|
|
193
|
+
}
|
|
190
194
|
} else {
|
|
191
195
|
printInfo(`使用默认路径: ${mocksPath}`)
|
|
192
196
|
}
|
package/bin/index.js
CHANGED
|
@@ -60,12 +60,12 @@ if (command === 'mock' || command === 'route' || command === 'session') {
|
|
|
60
60
|
require('../index.js')
|
|
61
61
|
} else {
|
|
62
62
|
console.error(`Unknown command: ${command}`)
|
|
63
|
-
showHelp()
|
|
63
|
+
showHelp(process.stderr)
|
|
64
64
|
process.exit(1)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function showHelp() {
|
|
68
|
-
|
|
67
|
+
function showHelp(stream = process.stdout) {
|
|
68
|
+
stream.write(`
|
|
69
69
|
Meddle - 开发代理工具
|
|
70
70
|
|
|
71
71
|
用法:
|
|
@@ -144,5 +144,5 @@ Route 命令:
|
|
|
144
144
|
meddle route active set beta-rules
|
|
145
145
|
|
|
146
146
|
更多信息请访问: https://github.com/JonathanLee-LX/meddle
|
|
147
|
-
|
|
147
|
+
`)
|
|
148
148
|
}
|
package/bin/lib/file-access.js
CHANGED
|
@@ -167,31 +167,48 @@ function describeMocksParseFailure(text, err) {
|
|
|
167
167
|
return `${loc}${short}`
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
const MOCKS_MISSING_RULES_MESSAGE = '缺少 rules 数组'
|
|
171
|
+
|
|
172
|
+
function mocksDocumentShapeError(data) {
|
|
173
|
+
if (!data || typeof data !== 'object' || Array.isArray(data) || !Array.isArray(data.rules)) {
|
|
174
|
+
return MOCKS_MISSING_RULES_MESSAGE
|
|
175
|
+
}
|
|
176
|
+
return null
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function throwMocksFileInvalid(mocksPath, detail) {
|
|
180
|
+
const error = new Error(`Mock 文件格式错误,已禁止写入以免覆盖: ${mocksPath} ${detail}`)
|
|
181
|
+
error.code = 'MOCKS_FILE_INVALID'
|
|
182
|
+
error.filePath = mocksPath
|
|
183
|
+
error.detail = detail
|
|
184
|
+
error.listMessage = `Mock 文件格式错误: ${mocksPath} ${detail}`
|
|
185
|
+
throw error
|
|
186
|
+
}
|
|
187
|
+
|
|
170
188
|
/**
|
|
171
189
|
* Read mocks.json. Missing file → null. Empty / whitespace → {}.
|
|
172
|
-
* Invalid JSON
|
|
190
|
+
* Invalid JSON or a valid document with the wrong shape (issue #160, e.g. a
|
|
191
|
+
* top-level array) throws MOCKS_FILE_INVALID and must not be treated as [].
|
|
173
192
|
* `message` refuses a write; `listMessage` is what `mock list` prints.
|
|
174
193
|
*/
|
|
175
194
|
function readMocksDocument(mocksPath) {
|
|
176
195
|
if (!fs.existsSync(mocksPath)) return null
|
|
177
196
|
const text = fs.readFileSync(mocksPath, 'utf8').replace(/^\uFEFF/, '')
|
|
178
197
|
if (text.trim() === '') return {}
|
|
198
|
+
let data
|
|
179
199
|
try {
|
|
180
|
-
|
|
200
|
+
data = JSON.parse(text)
|
|
181
201
|
} catch (err) {
|
|
182
|
-
|
|
183
|
-
const error = new Error(`Mock 文件格式错误,已禁止写入以免覆盖: ${mocksPath} ${detail}`)
|
|
184
|
-
error.code = 'MOCKS_FILE_INVALID'
|
|
185
|
-
error.filePath = mocksPath
|
|
186
|
-
error.detail = detail
|
|
187
|
-
error.listMessage = `Mock 文件格式错误: ${mocksPath} ${detail}`
|
|
188
|
-
throw error
|
|
202
|
+
throwMocksFileInvalid(mocksPath, describeMocksParseFailure(text, err))
|
|
189
203
|
}
|
|
204
|
+
const shape = mocksDocumentShapeError(data)
|
|
205
|
+
if (shape) throwMocksFileInvalid(mocksPath, shape)
|
|
206
|
+
return data
|
|
190
207
|
}
|
|
191
208
|
|
|
192
209
|
function rulesFromDocument(data) {
|
|
193
|
-
if (!data || typeof data !== 'object' || Array.isArray(data)) return []
|
|
194
|
-
return
|
|
210
|
+
if (!data || typeof data !== 'object' || Array.isArray(data) || !Array.isArray(data.rules)) return []
|
|
211
|
+
return data.rules
|
|
195
212
|
}
|
|
196
213
|
|
|
197
214
|
function metaFromDocument(data) {
|
package/bin/lib/meddle-home.js
CHANGED
|
@@ -17,4 +17,17 @@ function resolveMeddleHome() {
|
|
|
17
17
|
return path.resolve(os.homedir(), '.meddle')
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Same rules as core/mock-handler.resolveConfiguredMocksPath: `~` expands to
|
|
22
|
+
* the user home directory; a relative path is resolved against MEDDLE_HOME.
|
|
23
|
+
*/
|
|
24
|
+
function resolveConfiguredMocksPath(raw, meddleDir, homeDir = os.homedir()) {
|
|
25
|
+
const v = typeof raw === 'string' ? raw.trim() : ''
|
|
26
|
+
if (!v) return null
|
|
27
|
+
let p = v
|
|
28
|
+
if (p === '~') p = homeDir
|
|
29
|
+
else if (p.startsWith('~/') || p.startsWith('~\\')) p = path.join(homeDir, p.slice(2))
|
|
30
|
+
return path.resolve(meddleDir, p)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = { resolveMeddleHome, resolveConfiguredMocksPath }
|
package/bin/lib/output.js
CHANGED
|
@@ -52,11 +52,16 @@ function success(message) {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Print a command failure. Human-readable text goes to stderr so stdout stays
|
|
55
|
-
* empty on error. In --json mode
|
|
56
|
-
*
|
|
55
|
+
* empty on error. In --json mode stdout is one `{ success: false }` object and
|
|
56
|
+
* the same message is copied to stderr without a `✗` prefix.
|
|
57
57
|
*/
|
|
58
58
|
function error(message) {
|
|
59
|
-
if (jsonMode)
|
|
59
|
+
if (jsonMode) {
|
|
60
|
+
const text = String(message)
|
|
61
|
+
console.log(JSON.stringify({ success: false, error: { message: text } }))
|
|
62
|
+
console.error(text)
|
|
63
|
+
return
|
|
64
|
+
}
|
|
60
65
|
console.error(chalk.red(' ✗'), message)
|
|
61
66
|
}
|
|
62
67
|
|
package/bin/lib/proxy-or-file.js
CHANGED
|
@@ -77,7 +77,10 @@ async function withProxyOrFile({ api, file }) {
|
|
|
77
77
|
*/
|
|
78
78
|
function failCommand(err) {
|
|
79
79
|
const message = err && err.message ? String(err.message) : String(err)
|
|
80
|
-
|
|
80
|
+
// HTTP / raw-stderr failures print the body as-is (no JSON wrapper, no `✗`).
|
|
81
|
+
// Other failures go through output.error, which emits `{success:false}` on
|
|
82
|
+
// stdout when --json is set.
|
|
83
|
+
if (isApiHttpError(err) || (err && err.rawStderr)) console.error(message)
|
|
81
84
|
else output.error(message)
|
|
82
85
|
process.exit(1)
|
|
83
86
|
}
|
package/dist/cert.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ interface CAStatus {
|
|
|
4
4
|
trusted?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare function getCAStatus(): Promise<CAStatus>;
|
|
7
|
+
/** Skip the interactive CA menu when stdin is not a TTY or a headless/supervised start. */
|
|
8
|
+
export declare function shouldPromptCaTrust(): boolean;
|
|
7
9
|
export declare function checkCATrusted(): boolean;
|
|
8
10
|
export declare function ensureRootCA(opts?: {
|
|
9
11
|
trustCheckAsync?: boolean;
|
package/dist/cert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cert.d.ts","sourceRoot":"","sources":["../cert.ts"],"names":[],"mappings":"AAiEA,QAAA,MAAM,MAAM,KAA8B,CAAC;AA+B3C,UAAU,QAAQ;IACd,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAGD,wBAAsB,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC,CAYrD;
|
|
1
|
+
{"version":3,"file":"cert.d.ts","sourceRoot":"","sources":["../cert.ts"],"names":[],"mappings":"AAiEA,QAAA,MAAM,MAAM,KAA8B,CAAC;AA+B3C,UAAU,QAAQ;IACd,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAGD,wBAAsB,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC,CAYrD;AAwBD,2FAA2F;AAC3F,wBAAgB,mBAAmB,IAAI,OAAO,CAI7C;AAuED,wBAAgB,cAAc,IAAI,OAAO,CAgCxC;AAED,wBAAsB,YAAY,CAAC,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB1F;AAMD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/cert.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.crtMgr = void 0;
|
|
37
37
|
exports.getCAStatus = getCAStatus;
|
|
38
|
+
exports.shouldPromptCaTrust = shouldPromptCaTrust;
|
|
38
39
|
exports.checkCATrusted = checkCATrusted;
|
|
39
40
|
exports.ensureRootCA = ensureRootCA;
|
|
40
41
|
exports.getRootCAPath = getRootCAPath;
|
|
@@ -166,6 +167,14 @@ function openCertForUser(rootCAPath) {
|
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
}
|
|
170
|
+
/** Skip the interactive CA menu when stdin is not a TTY or a headless/supervised start. */
|
|
171
|
+
function shouldPromptCaTrust() {
|
|
172
|
+
if (process.env.MEDDLE_HEADLESS || process.env.MEDDLE_MCP || process.env.MEDDLE_SUPERVISED)
|
|
173
|
+
return false;
|
|
174
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
175
|
+
return false;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
169
178
|
async function trustRootCA() {
|
|
170
179
|
const platform = os.platform();
|
|
171
180
|
const rootCAPath = crtMgr.getRootCAFilePath();
|
|
@@ -281,7 +290,7 @@ async function ensureRootCA(opts = {}) {
|
|
|
281
290
|
const runTrustCheck = () => {
|
|
282
291
|
try {
|
|
283
292
|
const isTrusted = checkCATrusted();
|
|
284
|
-
if (!isTrusted &&
|
|
293
|
+
if (!isTrusted && shouldPromptCaTrust()) {
|
|
285
294
|
trustRootCA();
|
|
286
295
|
}
|
|
287
296
|
}
|
package/dist/cert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cert.js","sourceRoot":"","sources":["../cert.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,kCAYC;
|
|
1
|
+
{"version":3,"file":"cert.js","sourceRoot":"","sources":["../cert.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,kCAYC;AAyBD,kDAIC;AAuED,wCAgCC;AAED,oCAyBC;AAMD,sCAEC;AAzRD,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC3C,+CAAiC;AACjC,uCAAyB;AACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,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C;QACvB,iCAAiC;QACjC,oCAAoC;QACpC,YAAY,CAAC,aAAa,CAAC,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,aAAa,EAAE,CAAC;AACpB,CAAC;AAED,SAAS,eAAe,CAAC,GAAY;IACjC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,aAAa;IACzB,OAAO,MAAM,CAAC,iBAAiB,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/core/browser.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as os from 'os';
|
|
2
2
|
type Platform = ReturnType<typeof os.platform>;
|
|
3
|
+
/** Same availability rules as `findInstalledBrowser` (PATH on Windows/Linux, .app on macOS). */
|
|
4
|
+
export declare function candidateAvailable(platform: Platform, app: string): boolean;
|
|
3
5
|
/** Name of a browser this machine can launch (`google-chrome`, `Google Chrome`, …), or null. */
|
|
4
6
|
export declare function findInstalledBrowser(platform?: Platform): string | null;
|
|
5
7
|
/** Stop browsers opened by this process. Tests call this from afterAll. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAmBxB,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAA;AAgC9C,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,QAAwB,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAmBxB,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAA;AAgC9C,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,QAAwB,GAAG,MAAM,GAAG,IAAI,CAKtF;AAwCD,2EAA2E;AAC3E,wBAAgB,qBAAqB,IAAI,IAAI,CAM5C;AAgHD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA6B9I"}
|