@modern-js/plugin-testing 0.0.0-next-20240611055244 → 0.0.0-next-20240611080534
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/dist/cjs/cli/bff/app.js +2 -1
- package/dist/cjs/cli/bff/index.js +1 -2
- package/dist/cjs/cli/test.js +8 -0
- package/dist/esm/cli/bff/app.js +4 -3
- package/dist/esm/cli/bff/index.js +1 -2
- package/dist/esm/cli/test.js +17 -3
- package/dist/esm-node/cli/bff/app.js +3 -2
- package/dist/esm-node/cli/bff/index.js +1 -2
- package/dist/esm-node/cli/test.js +8 -0
- package/dist/types/cli/bff/app.d.ts +2 -2
- package/dist/types/cli/bff/index.d.ts +2 -2
- package/package.json +12 -12
package/dist/cjs/cli/bff/app.js
CHANGED
|
@@ -43,10 +43,11 @@ let server;
|
|
|
43
43
|
const createApp = async (pwd, config, plugins, routes) => {
|
|
44
44
|
if (!server) {
|
|
45
45
|
config.output.path = "./";
|
|
46
|
+
const pluginInstances = (0, import_prod_server.loadServerPlugins)(plugins, pwd);
|
|
46
47
|
server = await (0, import_prod_server.createProdServer)({
|
|
47
48
|
pwd,
|
|
48
49
|
config,
|
|
49
|
-
|
|
50
|
+
plugins: pluginInstances,
|
|
50
51
|
routes,
|
|
51
52
|
appContext: {
|
|
52
53
|
apiDirectory: import_node_path.default.join(pwd, "api"),
|
|
@@ -138,8 +138,7 @@ const testingBffPlugin = () => ({
|
|
|
138
138
|
pwd,
|
|
139
139
|
userConfig,
|
|
140
140
|
routes: appContext.serverRoutes,
|
|
141
|
-
|
|
142
|
-
plugins: appContext.serverInternalPlugins,
|
|
141
|
+
plugins: appContext.serverPlugins,
|
|
143
142
|
utils,
|
|
144
143
|
appContext
|
|
145
144
|
});
|
package/dist/cjs/cli/test.js
CHANGED
|
@@ -38,6 +38,14 @@ const test = async (api) => {
|
|
|
38
38
|
var _userConfig_tools, _userConfig_tools1;
|
|
39
39
|
const userConfig = api.useResolvedConfigContext();
|
|
40
40
|
const appContext = api.useAppContext();
|
|
41
|
+
const runner = api.useHookRunners();
|
|
42
|
+
const { plugins } = await runner._internalServerPlugins({
|
|
43
|
+
plugins: []
|
|
44
|
+
});
|
|
45
|
+
api.setAppContext({
|
|
46
|
+
...api.useAppContext(),
|
|
47
|
+
serverPlugins: plugins
|
|
48
|
+
});
|
|
41
49
|
userConfig.testing = userConfig.testing || {};
|
|
42
50
|
const jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
|
|
43
51
|
if (Array.isArray(jest)) {
|
package/dist/esm/cli/bff/app.js
CHANGED
|
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { AsyncLocalStorage } from "async_hooks";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { createProdServer } from "@modern-js/prod-server";
|
|
5
|
+
import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
|
|
6
6
|
var store = new AsyncLocalStorage();
|
|
7
7
|
var isInHandler = function() {
|
|
8
8
|
return Boolean(store.getStore());
|
|
@@ -10,7 +10,7 @@ var isInHandler = function() {
|
|
|
10
10
|
var server;
|
|
11
11
|
var createApp = function() {
|
|
12
12
|
var _ref = _async_to_generator(function(pwd, config, plugins, routes) {
|
|
13
|
-
var app;
|
|
13
|
+
var pluginInstances, app;
|
|
14
14
|
return _ts_generator(this, function(_state) {
|
|
15
15
|
switch (_state.label) {
|
|
16
16
|
case 0:
|
|
@@ -20,12 +20,13 @@ var createApp = function() {
|
|
|
20
20
|
2
|
|
21
21
|
];
|
|
22
22
|
config.output.path = "./";
|
|
23
|
+
pluginInstances = loadServerPlugins(plugins, pwd);
|
|
23
24
|
return [
|
|
24
25
|
4,
|
|
25
26
|
createProdServer({
|
|
26
27
|
pwd,
|
|
27
28
|
config,
|
|
28
|
-
|
|
29
|
+
plugins: pluginInstances,
|
|
29
30
|
routes,
|
|
30
31
|
appContext: {
|
|
31
32
|
apiDirectory: path.join(pwd, "api"),
|
|
@@ -129,8 +129,7 @@ var testingBffPlugin = function() {
|
|
|
129
129
|
pwd,
|
|
130
130
|
userConfig,
|
|
131
131
|
routes: appContext.serverRoutes,
|
|
132
|
-
|
|
133
|
-
plugins: appContext.serverInternalPlugins,
|
|
132
|
+
plugins: appContext.serverPlugins,
|
|
134
133
|
utils,
|
|
135
134
|
appContext
|
|
136
135
|
})
|
package/dist/esm/cli/test.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
2
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
5
|
import path from "path";
|
|
4
6
|
import { compiler } from "@modern-js/babel-compiler";
|
|
5
7
|
import { runTest } from "../base";
|
|
6
8
|
var test = function() {
|
|
7
9
|
var _ref = _async_to_generator(function(api) {
|
|
8
|
-
var _userConfig_tools, _userConfig_tools1, userConfig, appContext, jest, runtimeExportsPath;
|
|
10
|
+
var _userConfig_tools, _userConfig_tools1, userConfig, appContext, runner, plugins, jest, runtimeExportsPath;
|
|
9
11
|
return _ts_generator(this, function(_state) {
|
|
10
12
|
switch (_state.label) {
|
|
11
13
|
case 0:
|
|
12
14
|
userConfig = api.useResolvedConfigContext();
|
|
13
15
|
appContext = api.useAppContext();
|
|
16
|
+
runner = api.useHookRunners();
|
|
17
|
+
return [
|
|
18
|
+
4,
|
|
19
|
+
runner._internalServerPlugins({
|
|
20
|
+
plugins: []
|
|
21
|
+
})
|
|
22
|
+
];
|
|
23
|
+
case 1:
|
|
24
|
+
plugins = _state.sent().plugins;
|
|
25
|
+
api.setAppContext(_object_spread_props(_object_spread({}, api.useAppContext()), {
|
|
26
|
+
serverPlugins: plugins
|
|
27
|
+
}));
|
|
14
28
|
userConfig.testing = userConfig.testing || {};
|
|
15
29
|
jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
|
|
16
30
|
if (Array.isArray(jest)) {
|
|
@@ -36,13 +50,13 @@ var test = function() {
|
|
|
36
50
|
]
|
|
37
51
|
})
|
|
38
52
|
];
|
|
39
|
-
case
|
|
53
|
+
case 2:
|
|
40
54
|
_state.sent();
|
|
41
55
|
return [
|
|
42
56
|
4,
|
|
43
57
|
runTest(api, userConfig.testing)
|
|
44
58
|
];
|
|
45
|
-
case
|
|
59
|
+
case 3:
|
|
46
60
|
_state.sent();
|
|
47
61
|
return [
|
|
48
62
|
2
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { createProdServer } from "@modern-js/prod-server";
|
|
3
|
+
import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
|
|
4
4
|
const store = new AsyncLocalStorage();
|
|
5
5
|
const isInHandler = () => Boolean(store.getStore());
|
|
6
6
|
let server;
|
|
7
7
|
const createApp = async (pwd, config, plugins, routes) => {
|
|
8
8
|
if (!server) {
|
|
9
9
|
config.output.path = "./";
|
|
10
|
+
const pluginInstances = loadServerPlugins(plugins, pwd);
|
|
10
11
|
server = await createProdServer({
|
|
11
12
|
pwd,
|
|
12
13
|
config,
|
|
13
|
-
|
|
14
|
+
plugins: pluginInstances,
|
|
14
15
|
routes,
|
|
15
16
|
appContext: {
|
|
16
17
|
apiDirectory: path.join(pwd, "api"),
|
|
@@ -104,8 +104,7 @@ const testingBffPlugin = () => ({
|
|
|
104
104
|
pwd,
|
|
105
105
|
userConfig,
|
|
106
106
|
routes: appContext.serverRoutes,
|
|
107
|
-
|
|
108
|
-
plugins: appContext.serverInternalPlugins,
|
|
107
|
+
plugins: appContext.serverPlugins,
|
|
109
108
|
utils,
|
|
110
109
|
appContext
|
|
111
110
|
});
|
|
@@ -5,6 +5,14 @@ const test = async (api) => {
|
|
|
5
5
|
var _userConfig_tools, _userConfig_tools1;
|
|
6
6
|
const userConfig = api.useResolvedConfigContext();
|
|
7
7
|
const appContext = api.useAppContext();
|
|
8
|
+
const runner = api.useHookRunners();
|
|
9
|
+
const { plugins } = await runner._internalServerPlugins({
|
|
10
|
+
plugins: []
|
|
11
|
+
});
|
|
12
|
+
api.setAppContext({
|
|
13
|
+
...api.useAppContext(),
|
|
14
|
+
serverPlugins: plugins
|
|
15
|
+
});
|
|
8
16
|
userConfig.testing = userConfig.testing || {};
|
|
9
17
|
const jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
|
|
10
18
|
if (Array.isArray(jest)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { ServerPlugin } from '@modern-js/types';
|
|
3
3
|
export declare const isInHandler: () => boolean;
|
|
4
|
-
declare const createApp: (pwd: string, config: any, plugins:
|
|
4
|
+
declare const createApp: (pwd: string, config: any, plugins: ServerPlugin[], routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<void>>;
|
|
5
5
|
declare const getApp: () => (req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<void>;
|
|
6
6
|
declare const closeServer: () => Promise<void>;
|
|
7
7
|
export { createApp, getApp, closeServer };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { CliPlugin, IAppContext } from '@modern-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ServerPlugin } from '@modern-js/prod-server';
|
|
3
3
|
import { UserConfig } from '../../base/config';
|
|
4
4
|
import { TestConfigOperator } from '../../base';
|
|
5
5
|
import type { Hooks } from '../../base/hook';
|
|
6
6
|
export declare const setJestConfigForBFF: ({ pwd, userConfig, plugins, routes, utils, appContext, }: {
|
|
7
7
|
pwd: string;
|
|
8
8
|
userConfig: any;
|
|
9
|
-
plugins:
|
|
9
|
+
plugins: ServerPlugin[];
|
|
10
10
|
routes: any[];
|
|
11
11
|
utils: TestConfigOperator;
|
|
12
12
|
appContext: IAppContext;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-next-
|
|
18
|
+
"version": "0.0.0-next-20240611080534",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/cli/index.js",
|
|
@@ -131,17 +131,17 @@
|
|
|
131
131
|
"ts-jest": "^29.1.0",
|
|
132
132
|
"yargs": "^17.0.1",
|
|
133
133
|
"@swc/helpers": "0.5.3",
|
|
134
|
-
"@modern-js/babel-compiler": "0.0.0-next-
|
|
135
|
-
"@modern-js/utils": "0.0.0-next-
|
|
136
|
-
"@modern-js/
|
|
137
|
-
"@modern-js/
|
|
138
|
-
"@modern-js/types": "0.0.0-next-
|
|
139
|
-
"@modern-js/bff-core": "0.0.0-next-
|
|
134
|
+
"@modern-js/babel-compiler": "0.0.0-next-20240611080534",
|
|
135
|
+
"@modern-js/utils": "0.0.0-next-20240611080534",
|
|
136
|
+
"@modern-js/plugin": "0.0.0-next-20240611080534",
|
|
137
|
+
"@modern-js/prod-server": "0.0.0-next-20240611080534",
|
|
138
|
+
"@modern-js/types": "0.0.0-next-20240611080534",
|
|
139
|
+
"@modern-js/bff-core": "0.0.0-next-20240611080534"
|
|
140
140
|
},
|
|
141
141
|
"peerDependencies": {
|
|
142
142
|
"react": ">=17",
|
|
143
143
|
"react-dom": ">=17",
|
|
144
|
-
"@modern-js/runtime": "0.0.0-next-
|
|
144
|
+
"@modern-js/runtime": "0.0.0-next-20240611080534"
|
|
145
145
|
},
|
|
146
146
|
"peerDependenciesMeta": {
|
|
147
147
|
"@modern-js/runtime": {
|
|
@@ -156,10 +156,10 @@
|
|
|
156
156
|
"@types/node": "^14",
|
|
157
157
|
"@types/yargs": "^17.0.2",
|
|
158
158
|
"typescript": "^5",
|
|
159
|
-
"@modern-js/core": "0.0.0-next-
|
|
160
|
-
"@
|
|
161
|
-
"@
|
|
162
|
-
"@scripts/jest-config": "0.0.0-next-
|
|
159
|
+
"@modern-js/core": "0.0.0-next-20240611080534",
|
|
160
|
+
"@scripts/build": "0.0.0-next-20240611080534",
|
|
161
|
+
"@modern-js/runtime": "0.0.0-next-20240611080534",
|
|
162
|
+
"@scripts/jest-config": "0.0.0-next-20240611080534"
|
|
163
163
|
},
|
|
164
164
|
"sideEffects": false,
|
|
165
165
|
"publishConfig": {
|