whistle.mock-plugins 1.0.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/API.md +247 -0
- package/README.md +91 -0
- package/app/cgi-bin/features.js +285 -0
- package/app/cgi-bin/index.js +31 -0
- package/app/cgi-bin/interfaces.js +409 -0
- package/app/cgi-bin/logs.js +151 -0
- package/app/cgi-bin/test-interface.js +152 -0
- package/app/public/index.html +1 -0
- package/app/public/js/index.js +2 -0
- package/app/public/js/index.js.LICENSE.txt +150 -0
- package/app/util/index.js +24 -0
- package/index.html +52 -0
- package/initialize.js +32 -0
- package/lib/dataManager.js +500 -0
- package/lib/index.js +3 -0
- package/lib/models.js +64 -0
- package/lib/routes/features.js +213 -0
- package/lib/routes/interfaces.js +304 -0
- package/lib/routes/proxy.js +239 -0
- package/lib/ruleManager.js +551 -0
- package/lib/rules-server.js +267 -0
- package/lib/server.js +805 -0
- package/lib/storage.js +16 -0
- package/lib/ui-server.js +68 -0
- package/package.json +51 -0
- package/public/bundle.js +2 -0
- package/public/bundle.js.LICENSE.txt +38 -0
- package/public/index.html +1 -0
- package/public/plugin.mock-plugin.html +14 -0
- package/rules.txt +22 -0
- package/test/rulesServer.test.js +120 -0
- package/ui/src/App.css +173 -0
- package/ui/src/App.js +24 -0
- package/ui/src/components/AppLayout.js +149 -0
- package/ui/src/components/FeatureCard.js +53 -0
- package/ui/src/components/Layout.js +94 -0
- package/ui/src/components/MainNav.js +42 -0
- package/ui/src/components/PageContainer.js +16 -0
- package/ui/src/index.html +11 -0
- package/ui/src/index.js +43 -0
- package/ui/src/pages/FileProxy.js +235 -0
- package/ui/src/pages/FilesPage.js +292 -0
- package/ui/src/pages/Home.js +128 -0
- package/ui/src/pages/HomePage.js +195 -0
- package/ui/src/pages/InterfaceManagement.js +829 -0
- package/ui/src/pages/InterfacePage.js +342 -0
- package/ui/src/pages/MockData.js +472 -0
- package/ui/src/pages/Settings.js +192 -0
- package/ui/src/pages/SettingsPage.js +165 -0
- package/ui/src/pages/UrlRedirect.js +225 -0
- package/ui/src/pages/Welcome.js +155 -0
- package/ui/src/services/api.js +186 -0
- package/ui/src/styles/app-layout.css +337 -0
- package/ui/src/styles/feature-card.css +172 -0
- package/ui/src/styles/file-proxy.css +301 -0
- package/ui/src/styles/global.css +224 -0
- package/ui/src/styles/home.css +123 -0
- package/ui/src/styles/index.css +419 -0
- package/ui/src/styles/interface-management.css +694 -0
- package/ui/src/styles/layout.css +159 -0
- package/ui/src/styles/logs-page.css +427 -0
- package/ui/src/styles/main-nav.css +52 -0
- package/ui/src/styles/mock-data.css +850 -0
- package/ui/src/styles/page-container.css +11 -0
- package/ui/src/styles/settings.css +208 -0
- package/ui/src/styles/url-redirect.css +279 -0
- package/ui/src/styles/welcome.css +282 -0
- package/webpack.config.js +49 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-dom.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @license React
|
|
21
|
+
* react-is.production.min.js
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @license React
|
|
31
|
+
* react.production.min.js
|
|
32
|
+
*
|
|
33
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the MIT license found in the
|
|
36
|
+
* LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @license React
|
|
41
|
+
* scheduler.production.min.js
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the MIT license found in the
|
|
46
|
+
* LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** @license React v16.13.1
|
|
50
|
+
* react-is.production.min.js
|
|
51
|
+
*
|
|
52
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the MIT license found in the
|
|
55
|
+
* LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/** */
|
|
59
|
+
|
|
60
|
+
/** */
|
|
61
|
+
|
|
62
|
+
/** */
|
|
63
|
+
|
|
64
|
+
/** */
|
|
65
|
+
|
|
66
|
+
/** */
|
|
67
|
+
|
|
68
|
+
/** */
|
|
69
|
+
|
|
70
|
+
/** */
|
|
71
|
+
|
|
72
|
+
/** */
|
|
73
|
+
|
|
74
|
+
/** */
|
|
75
|
+
|
|
76
|
+
/** */
|
|
77
|
+
|
|
78
|
+
/** */
|
|
79
|
+
|
|
80
|
+
/** */
|
|
81
|
+
|
|
82
|
+
/** */
|
|
83
|
+
|
|
84
|
+
/** */
|
|
85
|
+
|
|
86
|
+
/** */
|
|
87
|
+
|
|
88
|
+
/** */
|
|
89
|
+
|
|
90
|
+
/** */
|
|
91
|
+
|
|
92
|
+
/** */
|
|
93
|
+
|
|
94
|
+
/** */
|
|
95
|
+
|
|
96
|
+
/** */
|
|
97
|
+
|
|
98
|
+
/** */
|
|
99
|
+
|
|
100
|
+
/** */
|
|
101
|
+
|
|
102
|
+
/** */
|
|
103
|
+
|
|
104
|
+
/** */
|
|
105
|
+
|
|
106
|
+
/** */
|
|
107
|
+
|
|
108
|
+
/** */
|
|
109
|
+
|
|
110
|
+
/** */
|
|
111
|
+
|
|
112
|
+
/** */
|
|
113
|
+
|
|
114
|
+
/** */
|
|
115
|
+
|
|
116
|
+
/** */
|
|
117
|
+
|
|
118
|
+
/** */
|
|
119
|
+
|
|
120
|
+
/** */
|
|
121
|
+
|
|
122
|
+
/** */
|
|
123
|
+
|
|
124
|
+
/** */
|
|
125
|
+
|
|
126
|
+
/** */
|
|
127
|
+
|
|
128
|
+
/** */
|
|
129
|
+
|
|
130
|
+
/** */
|
|
131
|
+
|
|
132
|
+
/** */
|
|
133
|
+
|
|
134
|
+
/** */
|
|
135
|
+
|
|
136
|
+
/** */
|
|
137
|
+
|
|
138
|
+
/** */
|
|
139
|
+
|
|
140
|
+
/** */
|
|
141
|
+
|
|
142
|
+
/** */
|
|
143
|
+
|
|
144
|
+
/** */
|
|
145
|
+
|
|
146
|
+
/** */
|
|
147
|
+
|
|
148
|
+
/** */
|
|
149
|
+
|
|
150
|
+
/** */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
exports.noop = function() {};
|
|
5
|
+
|
|
6
|
+
// 格式化路径
|
|
7
|
+
exports.formatPath = function(filePath) {
|
|
8
|
+
return filePath && filePath.replace(/\\/g, '/');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// 加载指定目录下的模块
|
|
12
|
+
exports.loadModulesSync = function(dir) {
|
|
13
|
+
const modules = {};
|
|
14
|
+
try {
|
|
15
|
+
fs.readdirSync(dir).forEach(function(name) {
|
|
16
|
+
if (!/^\./.test(name) && /\.js$/.test(name)) {
|
|
17
|
+
const moduleName = exports.formatPath(path.join(dir, name));
|
|
18
|
+
modules[moduleName.replace(/\.js$/, '')] = require(moduleName);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
} catch (e) {}
|
|
22
|
+
|
|
23
|
+
return modules;
|
|
24
|
+
};
|
package/index.html
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta http-equiv="refresh" content="0;url=/" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>Whistle Mock 插件</title>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
height: 100vh;
|
|
15
|
+
margin: 0;
|
|
16
|
+
background-color: #f5f5f5;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
.container {
|
|
20
|
+
text-align: center;
|
|
21
|
+
padding: 2rem;
|
|
22
|
+
background-color: white;
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
25
|
+
}
|
|
26
|
+
h1 {
|
|
27
|
+
color: #1890ff;
|
|
28
|
+
}
|
|
29
|
+
p {
|
|
30
|
+
margin: 1rem 0;
|
|
31
|
+
}
|
|
32
|
+
a {
|
|
33
|
+
color: #1890ff;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
}
|
|
36
|
+
a:hover {
|
|
37
|
+
text-decoration: underline;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<div class="container">
|
|
43
|
+
<h1>Whistle Mock 插件</h1>
|
|
44
|
+
<p>正在重定向到插件主页...</p>
|
|
45
|
+
<p>如果您没有被自动重定向,请<a href="/">点击此处</a>访问插件界面。</p>
|
|
46
|
+
</div>
|
|
47
|
+
<script>
|
|
48
|
+
// 确保重定向到正确的UI路径
|
|
49
|
+
window.location.href = '/';
|
|
50
|
+
</script>
|
|
51
|
+
</body>
|
|
52
|
+
</html>
|
package/initialize.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const storage = require('./lib/storage');
|
|
4
|
+
const dataManager = require('./lib/dataManager');
|
|
5
|
+
const ruleManager = require('./lib/ruleManager');
|
|
6
|
+
|
|
7
|
+
module.exports = options => {
|
|
8
|
+
const baseDir = process.env.WHISTLE_PLUGIN_DATA_DIR || storage.DATA_DIR;
|
|
9
|
+
|
|
10
|
+
// 初始化数据目录
|
|
11
|
+
if (!fs.existsSync(baseDir)) {
|
|
12
|
+
fs.ensureDirSync(baseDir);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 初始化数据管理器
|
|
16
|
+
dataManager.init({
|
|
17
|
+
baseDir,
|
|
18
|
+
log: (message) => console.log(`[whistle.mock-plugin] ${message}`)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// 初始化规则管理器
|
|
22
|
+
ruleManager.init({
|
|
23
|
+
server: null, // 将在具体server创建时赋值
|
|
24
|
+
config: {
|
|
25
|
+
baseDir
|
|
26
|
+
},
|
|
27
|
+
dataManager,
|
|
28
|
+
log: (message) => console.log(`[whistle.mock-plugin] ${message}`)
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('[whistle.mock-plugin] 插件初始化完成');
|
|
32
|
+
};
|