@modern-js/plugin-proxy 1.1.0 → 1.2.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/CHANGELOG.md +32 -67
- package/dist/js/modern/index.js +11 -7
- package/dist/js/modern/utils/macCAManager.js +1 -1
- package/dist/js/modern/utils/macProxyManager.js +1 -1
- package/dist/js/modern/utils/whistleProxy.js +2 -2
- package/dist/js/node/index.js +12 -7
- package/dist/js/node/utils/macCAManager.js +1 -1
- package/dist/js/node/utils/macProxyManager.js +1 -1
- package/dist/js/node/utils/whistleProxy.js +2 -2
- package/dist/types/index.d.ts +1 -3
- package/jest.config.js +8 -0
- package/modern.config.js +1 -9
- package/package.json +17 -13
- package/src/index.ts +9 -12
- package/src/utils/macCAManager.ts +1 -1
- package/src/utils/macProxyManager.ts +1 -1
- package/src/utils/whistleProxy.ts +2 -2
- package/tests/.eslintrc.js +6 -0
- package/tests/__snapshots__/cli.test.ts.snap +19 -0
- package/tests/cli.test.ts +39 -0
- package/tests/tsconfig.json +14 -0
- package/tsconfig.json +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,85 +1,50 @@
|
|
|
1
1
|
# @modern-js/plugin-proxy
|
|
2
2
|
|
|
3
|
-
## 1.1
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 96119db2: Relese v1.1.0
|
|
8
|
-
|
|
9
|
-
1. 全面支持 Windows 平台
|
|
10
|
-
|
|
11
|
-
ISSUE:
|
|
12
|
-
|
|
13
|
-
- [182](https://github.com/modern-js-dev/modern.js/issues/182)
|
|
14
|
-
- [236](https://github.com/modern-js-dev/modern.js/issues/236)
|
|
15
|
-
|
|
16
|
-
PR
|
|
17
|
-
|
|
18
|
-
- [219](https://github.com/modern-js-dev/modern.js/pull/219)
|
|
19
|
-
- [247](https://github.com/modern-js-dev/modern.js/pull/247)
|
|
20
|
-
- [249](https://github.com/modern-js-dev/modern.js/pull/249)
|
|
21
|
-
- [253](https://github.com/modern-js-dev/modern.js/pull/253)
|
|
22
|
-
- [268](https://github.com/modern-js-dev/modern.js/pull/268)
|
|
23
|
-
- [270](https://github.com/modern-js-dev/modern.js/pull/270)
|
|
24
|
-
- [273](https://github.com/modern-js-dev/modern.js/pull/273)
|
|
25
|
-
- [276](https://github.com/modern-js-dev/modern.js/pull/276)
|
|
26
|
-
|
|
27
|
-
2. 修复 Unbundled 模式启用问题
|
|
28
|
-
|
|
29
|
-
ISSUE
|
|
30
|
-
|
|
31
|
-
- [186](https://github.com/modern-js-dev/modern.js/issues/186)
|
|
32
|
-
- [224](https://github.com/modern-js-dev/modern.js/issues/224)
|
|
33
|
-
- [225](https://github.com/modern-js-dev/modern.js/issues/225)
|
|
34
|
-
- [238](https://github.com/modern-js-dev/modern.js/issues/238)
|
|
35
|
-
|
|
36
|
-
PR
|
|
37
|
-
|
|
38
|
-
- [226](https://github.com/modern-js-dev/modern.js/pull/226)
|
|
39
|
-
- [264](https://github.com/modern-js-dev/modern.js/pull/264)
|
|
40
|
-
- [codesmith-12](https://github.com/modern-js-dev/codesmith/pull/12)
|
|
3
|
+
## 1.2.1
|
|
41
4
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ISSUE
|
|
45
|
-
|
|
46
|
-
- [198](https://github.com/modern-js-dev/modern.js/issues/198)
|
|
47
|
-
|
|
48
|
-
PR
|
|
49
|
-
|
|
50
|
-
- [209](https://github.com/modern-js-dev/modern.js/pull/209)
|
|
51
|
-
|
|
52
|
-
4. 修复 Storybook 使用时浏览器打开页面报错
|
|
53
|
-
|
|
54
|
-
ISSUE
|
|
55
|
-
|
|
56
|
-
- [228](https://github.com/modern-js-dev/modern.js/issues/228)
|
|
5
|
+
### Patch Changes
|
|
57
6
|
|
|
58
|
-
|
|
7
|
+
- e2d3a575: fix extending core config interface
|
|
8
|
+
- e2d3a575: fix extending core config interface
|
|
9
|
+
- Updated dependencies [823809c6]
|
|
10
|
+
- Updated dependencies [4584cc04]
|
|
11
|
+
- Updated dependencies [7c19fd94]
|
|
12
|
+
- @modern-js/utils@1.2.1
|
|
13
|
+
- @modern-js/core@1.3.1
|
|
59
14
|
|
|
60
|
-
|
|
15
|
+
## 1.2.0
|
|
61
16
|
|
|
62
|
-
|
|
17
|
+
### Minor Changes
|
|
63
18
|
|
|
64
|
-
|
|
19
|
+
- cfe11628: Make Modern.js self bootstraping
|
|
65
20
|
|
|
66
|
-
|
|
67
|
-
- [257](https://github.com/modern-js-dev/modern.js/issues/257)
|
|
21
|
+
### Patch Changes
|
|
68
22
|
|
|
69
|
-
|
|
23
|
+
- f6932de7: fix proxy bin error
|
|
24
|
+
- bc87647d: fix: terminate whistle proxy when exiting the process
|
|
25
|
+
- Updated dependencies [2da09c69]
|
|
26
|
+
- Updated dependencies [fc71e36f]
|
|
27
|
+
- Updated dependencies [c3d46ee4]
|
|
28
|
+
- Updated dependencies [cfe11628]
|
|
29
|
+
- @modern-js/utils@1.2.0
|
|
30
|
+
- @modern-js/core@1.3.0
|
|
70
31
|
|
|
71
|
-
|
|
72
|
-
- [271](https://github.com/modern-js-dev/modern.js/pull/271)
|
|
32
|
+
## 1.1.1
|
|
73
33
|
|
|
74
|
-
|
|
34
|
+
### Patch Changes
|
|
75
35
|
|
|
76
|
-
|
|
36
|
+
- 0fa83663: support more .env files
|
|
37
|
+
- Updated dependencies [6f7fe574]
|
|
38
|
+
- Updated dependencies [0fa83663]
|
|
39
|
+
- Updated dependencies [f594fbc8]
|
|
40
|
+
- @modern-js/core@1.1.2
|
|
41
|
+
- @modern-js/utils@1.1.2
|
|
77
42
|
|
|
78
|
-
|
|
43
|
+
## 1.1.0
|
|
79
44
|
|
|
80
|
-
|
|
45
|
+
### Minor Changes
|
|
81
46
|
|
|
82
|
-
|
|
47
|
+
- 96119db2: Relese v1.1.0
|
|
83
48
|
|
|
84
49
|
### Patch Changes
|
|
85
50
|
|
package/dist/js/modern/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-j
|
|
|
2
2
|
import { PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
3
3
|
import { createProxyRule } from "./utils/createProxyRule";
|
|
4
4
|
import WhistleProxy from "./utils/whistleProxy";
|
|
5
|
+
let proxyServer;
|
|
5
6
|
export default createPlugin(() => ({
|
|
6
7
|
validateSchema() {
|
|
7
8
|
return PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
|
|
@@ -17,20 +18,23 @@ export default createPlugin(() => ({
|
|
|
17
18
|
} = useAppContext();
|
|
18
19
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
19
20
|
|
|
20
|
-
if (!dev.proxy) {
|
|
21
|
+
if (!(dev !== null && dev !== void 0 && dev.proxy)) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const rule = createProxyRule(internalDirectory, dev.proxy);
|
|
25
|
-
|
|
26
|
+
proxyServer = new WhistleProxy({
|
|
26
27
|
port: 8899,
|
|
27
28
|
rule
|
|
28
29
|
});
|
|
29
|
-
await proxyServer.start();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
await proxyServer.start();
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
beforeExit() {
|
|
34
|
+
var _proxyServer;
|
|
35
|
+
|
|
36
|
+
// terminate whistle proxy
|
|
37
|
+
(_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
}), {
|
|
@@ -35,7 +35,7 @@ export const generateRootCA = () => new Promise((resolve, reject) => {
|
|
|
35
35
|
|
|
36
36
|
fs.ensureDirSync(defaultCertDir);
|
|
37
37
|
const stream = fs.createWriteStream(defaultRootCA);
|
|
38
|
-
http.get('http://
|
|
38
|
+
http.get('http://localhost:8899/cgi-bin/rootca', response => {
|
|
39
39
|
response.pipe(stream);
|
|
40
40
|
stream.on('finish', () => {
|
|
41
41
|
resolve(defaultRootCA);
|
|
@@ -16,7 +16,7 @@ const getNetworkType = () => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const enableGlobalProxy = (ip, port) => {
|
|
19
|
-
const networkType = getNetworkType(); // && networksetup -setproxybypassdomains ${networkType}
|
|
19
|
+
const networkType = getNetworkType(); // && networksetup -setproxybypassdomains ${networkType} localhost localhost
|
|
20
20
|
|
|
21
21
|
execSync(`networksetup -setwebproxy ${networkType} ${ip} ${port}`);
|
|
22
22
|
execSync(`networksetup -setsecurewebproxy ${networkType} ${ip} ${port}`);
|
|
@@ -39,14 +39,14 @@ export default class WhistleProxy {
|
|
|
39
39
|
execSync(`${this.bin} start --certDir=${this.certDir} --port=${this.port}`);
|
|
40
40
|
execSync(`${this.bin} use ${this.rule} --force`);
|
|
41
41
|
await this.installRootCA();
|
|
42
|
-
enableGlobalProxy('
|
|
42
|
+
enableGlobalProxy('localhost', this.port);
|
|
43
43
|
logger.info(`Proxy Server start on localhost:${this.port}\n`);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
close() {
|
|
47
47
|
execSync(`${this.bin} stop`);
|
|
48
48
|
disableGlobalProxy();
|
|
49
|
-
logger.info(`Proxy Server has closed`);
|
|
49
|
+
logger.info(`Proxy Server has been closed`);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
}
|
package/dist/js/node/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var _whistleProxy = _interopRequireDefault(require("./utils/whistleProxy"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
+
let proxyServer;
|
|
19
|
+
|
|
18
20
|
var _default = (0, _core.createPlugin)(() => ({
|
|
19
21
|
validateSchema() {
|
|
20
22
|
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
|
|
@@ -30,20 +32,23 @@ var _default = (0, _core.createPlugin)(() => ({
|
|
|
30
32
|
} = (0, _core.useAppContext)();
|
|
31
33
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
32
34
|
|
|
33
|
-
if (!dev.proxy) {
|
|
35
|
+
if (!(dev !== null && dev !== void 0 && dev.proxy)) {
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const rule = (0, _createProxyRule.createProxyRule)(internalDirectory, dev.proxy);
|
|
38
|
-
|
|
40
|
+
proxyServer = new _whistleProxy.default({
|
|
39
41
|
port: 8899,
|
|
40
42
|
rule
|
|
41
43
|
});
|
|
42
|
-
await proxyServer.start();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
await proxyServer.start();
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
beforeExit() {
|
|
48
|
+
var _proxyServer;
|
|
49
|
+
|
|
50
|
+
// terminate whistle proxy
|
|
51
|
+
(_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
}), {
|
|
@@ -62,7 +62,7 @@ const generateRootCA = () => new Promise((resolve, reject) => {
|
|
|
62
62
|
|
|
63
63
|
const stream = _utils.fs.createWriteStream(defaultRootCA);
|
|
64
64
|
|
|
65
|
-
_http.default.get('http://
|
|
65
|
+
_http.default.get('http://localhost:8899/cgi-bin/rootca', response => {
|
|
66
66
|
response.pipe(stream);
|
|
67
67
|
stream.on('finish', () => {
|
|
68
68
|
resolve(defaultRootCA);
|
|
@@ -26,7 +26,7 @@ const getNetworkType = () => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const enableGlobalProxy = (ip, port) => {
|
|
29
|
-
const networkType = getNetworkType(); // && networksetup -setproxybypassdomains ${networkType}
|
|
29
|
+
const networkType = getNetworkType(); // && networksetup -setproxybypassdomains ${networkType} localhost localhost
|
|
30
30
|
|
|
31
31
|
(0, _execSync.default)(`networksetup -setwebproxy ${networkType} ${ip} ${port}`);
|
|
32
32
|
(0, _execSync.default)(`networksetup -setsecurewebproxy ${networkType} ${ip} ${port}`);
|
|
@@ -52,7 +52,7 @@ class WhistleProxy {
|
|
|
52
52
|
(0, _execSync.default)(`${this.bin} start --certDir=${this.certDir} --port=${this.port}`);
|
|
53
53
|
(0, _execSync.default)(`${this.bin} use ${this.rule} --force`);
|
|
54
54
|
await this.installRootCA();
|
|
55
|
-
enableGlobalProxy('
|
|
55
|
+
enableGlobalProxy('localhost', this.port);
|
|
56
56
|
|
|
57
57
|
_utils.logger.info(`Proxy Server start on localhost:${this.port}\n`);
|
|
58
58
|
}
|
|
@@ -61,7 +61,7 @@ class WhistleProxy {
|
|
|
61
61
|
(0, _execSync.default)(`${this.bin} stop`);
|
|
62
62
|
disableGlobalProxy();
|
|
63
63
|
|
|
64
|
-
_utils.logger.info(`Proxy Server has closed`);
|
|
64
|
+
_utils.logger.info(`Proxy Server has been closed`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
}
|
package/dist/types/index.d.ts
CHANGED
package/jest.config.js
ADDED
package/modern.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1
|
|
14
|
+
"version": "1.2.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -20,31 +20,33 @@
|
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"node": {
|
|
23
|
+
"jsnext:source": "./src/index.ts",
|
|
23
24
|
"import": "./dist/js/modern/index.js",
|
|
24
25
|
"require": "./dist/js/node/index.js"
|
|
25
26
|
},
|
|
26
27
|
"default": "./dist/js/treeshaking/index.js"
|
|
27
28
|
},
|
|
28
|
-
"./cli":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
"./cli": {
|
|
30
|
+
"jsnext:source": "./src/index.ts",
|
|
31
|
+
"default": "./dist/js/node/index.js"
|
|
32
|
+
}
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@babel/runtime": "^7",
|
|
35
|
-
"@modern-js/utils": "^1.1
|
|
36
|
+
"@modern-js/utils": "^1.2.1",
|
|
36
37
|
"whistle": "^2.7.18"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/jest": "^26",
|
|
40
41
|
"@types/node": "^14",
|
|
41
42
|
"typescript": "^4",
|
|
42
|
-
"@modern-js/core": "^1.1
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
43
|
+
"@modern-js/core": "^1.3.1",
|
|
44
|
+
"@scripts/build": "0.0.0",
|
|
45
|
+
"jest": "^27",
|
|
46
|
+
"@scripts/jest-config": "0.0.0"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
|
-
"@modern-js/core": "^1.1
|
|
49
|
+
"@modern-js/core": "^1.3.1"
|
|
48
50
|
},
|
|
49
51
|
"sideEffects": false,
|
|
50
52
|
"modernConfig": {
|
|
@@ -54,11 +56,13 @@
|
|
|
54
56
|
},
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"registry": "https://registry.npmjs.org/",
|
|
57
|
-
"access": "public"
|
|
59
|
+
"access": "public",
|
|
60
|
+
"types": "./dist/types/index.d.ts"
|
|
58
61
|
},
|
|
59
62
|
"scripts": {
|
|
60
63
|
"new": "modern new",
|
|
61
64
|
"build": "modern build",
|
|
62
|
-
"test": "
|
|
63
|
-
}
|
|
65
|
+
"test": "jest --passWithNoTests"
|
|
66
|
+
},
|
|
67
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
64
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
|
7
7
|
import { createProxyRule } from './utils/createProxyRule';
|
|
8
8
|
import WhistleProxy from './utils/whistleProxy';
|
|
9
9
|
|
|
10
|
+
let proxyServer: WhistleProxy;
|
|
10
11
|
export default createPlugin(
|
|
11
12
|
() => ({
|
|
12
13
|
validateSchema() {
|
|
@@ -18,19 +19,17 @@ export default createPlugin(
|
|
|
18
19
|
const { internalDirectory } = useAppContext();
|
|
19
20
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
20
21
|
|
|
21
|
-
if (!
|
|
22
|
+
if (!dev?.proxy) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const rule = createProxyRule(internalDirectory,
|
|
26
|
-
|
|
26
|
+
const rule = createProxyRule(internalDirectory, dev.proxy);
|
|
27
|
+
proxyServer = new WhistleProxy({ port: 8899, rule });
|
|
27
28
|
await proxyServer.start();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
// proxyServer.close();
|
|
33
|
-
// });
|
|
29
|
+
},
|
|
30
|
+
beforeExit() {
|
|
31
|
+
// terminate whistle proxy
|
|
32
|
+
proxyServer?.close();
|
|
34
33
|
},
|
|
35
34
|
}),
|
|
36
35
|
{ name: '@modern-js/plugin-proxy' },
|
|
@@ -40,8 +39,6 @@ export type ProxyOptions = string | Record<string, string>;
|
|
|
40
39
|
|
|
41
40
|
declare module '@modern-js/core' {
|
|
42
41
|
export interface DevConfig {
|
|
43
|
-
|
|
44
|
-
proxy?: ProxyOptions;
|
|
45
|
-
};
|
|
42
|
+
proxy?: ProxyOptions;
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -41,7 +41,7 @@ export const generateRootCA = () =>
|
|
|
41
41
|
const stream = fs.createWriteStream(defaultRootCA);
|
|
42
42
|
|
|
43
43
|
http
|
|
44
|
-
.get('http://
|
|
44
|
+
.get('http://localhost:8899/cgi-bin/rootca', response => {
|
|
45
45
|
response.pipe(stream);
|
|
46
46
|
stream
|
|
47
47
|
.on('finish', () => {
|
|
@@ -19,7 +19,7 @@ const getNetworkType = () => {
|
|
|
19
19
|
export const enableGlobalProxy = (ip: string, port: string) => {
|
|
20
20
|
const networkType = getNetworkType();
|
|
21
21
|
|
|
22
|
-
// && networksetup -setproxybypassdomains ${networkType}
|
|
22
|
+
// && networksetup -setproxybypassdomains ${networkType} localhost localhost
|
|
23
23
|
execSync(`networksetup -setwebproxy ${networkType} ${ip} ${port}`);
|
|
24
24
|
execSync(`networksetup -setsecurewebproxy ${networkType} ${ip} ${port}`);
|
|
25
25
|
};
|
|
@@ -55,13 +55,13 @@ export default class WhistleProxy {
|
|
|
55
55
|
execSync(`${this.bin} use ${this.rule} --force`);
|
|
56
56
|
await this.installRootCA();
|
|
57
57
|
|
|
58
|
-
enableGlobalProxy('
|
|
58
|
+
enableGlobalProxy('localhost', this.port);
|
|
59
59
|
logger.info(`Proxy Server start on localhost:${this.port}\n`);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
close() {
|
|
63
63
|
execSync(`${this.bin} stop`);
|
|
64
64
|
disableGlobalProxy();
|
|
65
|
-
logger.info(`Proxy Server has closed`);
|
|
65
|
+
logger.info(`Proxy Server has been closed`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`plugin proxy test config 1`] = `Array []`;
|
|
4
|
+
|
|
5
|
+
exports[`plugin proxy test schema 1`] = `
|
|
6
|
+
Array [
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"schema": Object {
|
|
10
|
+
"typeof": Array [
|
|
11
|
+
"string",
|
|
12
|
+
"object",
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
"target": "dev.proxy",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
]
|
|
19
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { manager } from '@modern-js/core';
|
|
3
|
+
import plugin from '../src';
|
|
4
|
+
|
|
5
|
+
const root = path.normalize(path.resolve(__dirname, '../../../../'));
|
|
6
|
+
expect.addSnapshotSerializer({
|
|
7
|
+
test: val =>
|
|
8
|
+
typeof val === 'string' &&
|
|
9
|
+
(val.includes('modern.js') ||
|
|
10
|
+
val.includes('node_modules') ||
|
|
11
|
+
val.includes(root)),
|
|
12
|
+
print: val =>
|
|
13
|
+
// eslint-disable-next-line no-nested-ternary
|
|
14
|
+
typeof val === 'string'
|
|
15
|
+
? // eslint-disable-next-line no-nested-ternary
|
|
16
|
+
val.includes('node_modules')
|
|
17
|
+
? `"${val.replace(/.+node_modules/, '')}"`
|
|
18
|
+
: val.includes('modern.js')
|
|
19
|
+
? `"${val.replace(/.+modern\.js/, '')}"`
|
|
20
|
+
: `"${val.replace(root, '')}"`
|
|
21
|
+
: (val as string),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('plugin proxy test', () => {
|
|
25
|
+
it('schema', async () => {
|
|
26
|
+
const main = manager.clone().usePlugin(plugin);
|
|
27
|
+
const runner = await main.init();
|
|
28
|
+
const result = await runner.validateSchema();
|
|
29
|
+
|
|
30
|
+
expect(result).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('config', async () => {
|
|
34
|
+
const main = manager.clone().usePlugin(plugin);
|
|
35
|
+
const runner = await main.init();
|
|
36
|
+
const result = await runner.config();
|
|
37
|
+
expect(result).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@modern-js/tsconfig/base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"jsx": "preserve",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"paths": {},
|
|
12
|
+
"types": ["node", "jest"]
|
|
13
|
+
}
|
|
14
|
+
}
|