@midwayjs/mock 3.11.11 → 3.11.15
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/creator.d.ts +3 -3
- package/dist/creator.js +13 -3
- package/dist/interface.d.ts +3 -0
- package/package.json +6 -6
package/dist/creator.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMidwayApplication, IMidwayFramework } from '@midwayjs/core';
|
|
2
|
-
import { ComponentModule, MockAppConfigurationOptions, IBootstrapAppStarter } from './interface';
|
|
3
|
-
export declare function create<T extends IMidwayFramework<any, any, any, any, any>>(appDir
|
|
2
|
+
import { ComponentModule, MockAppConfigurationOptions, IBootstrapAppStarter, MockBootstrapOptions } from './interface';
|
|
3
|
+
export declare function create<T extends IMidwayFramework<any, any, any, any, any>>(appDir: string | MockAppConfigurationOptions, options?: MockAppConfigurationOptions, customFramework?: {
|
|
4
4
|
new (...args: any[]): T;
|
|
5
5
|
} | ComponentModule): Promise<T>;
|
|
6
6
|
export declare function createApp<T extends IMidwayFramework<any, any, any, any, any>>(baseDir?: string, options?: MockAppConfigurationOptions, customFramework?: {
|
|
@@ -22,5 +22,5 @@ export declare function createFunctionApp<T extends IMidwayFramework<any, any, a
|
|
|
22
22
|
* @param options
|
|
23
23
|
*/
|
|
24
24
|
export declare function createLightApp(baseDir?: string, options?: MockAppConfigurationOptions): Promise<IMidwayApplication>;
|
|
25
|
-
export declare function createBootstrap(entryFile: string, options?:
|
|
25
|
+
export declare function createBootstrap(entryFile: string, options?: MockBootstrapOptions): Promise<IBootstrapAppStarter>;
|
|
26
26
|
//# sourceMappingURL=creator.d.ts.map
|
package/dist/creator.js
CHANGED
|
@@ -20,9 +20,13 @@ function formatPath(baseDir, p) {
|
|
|
20
20
|
return (0, path_1.resolve)(baseDir, p);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
async function create(appDir =
|
|
23
|
+
async function create(appDir, options = {}, customFramework) {
|
|
24
24
|
debug(`[mock]: Create app, appDir="${appDir}"`);
|
|
25
25
|
process.env.MIDWAY_TS_MODE = 'true';
|
|
26
|
+
if (typeof appDir === 'object') {
|
|
27
|
+
options = appDir;
|
|
28
|
+
appDir = options.appDir || '';
|
|
29
|
+
}
|
|
26
30
|
try {
|
|
27
31
|
if (appDir) {
|
|
28
32
|
// 处理测试的 fixtures
|
|
@@ -33,6 +37,9 @@ async function create(appDir = process.cwd(), options, customFramework) {
|
|
|
33
37
|
throw new core_1.MidwayCommonError(`Path "${appDir}" not exists, please check it.`);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
40
|
+
else {
|
|
41
|
+
appDir = process.cwd();
|
|
42
|
+
}
|
|
36
43
|
(0, logger_1.clearAllLoggers)();
|
|
37
44
|
options = options || {};
|
|
38
45
|
if (options.baseDir) {
|
|
@@ -192,7 +199,7 @@ async function createFunctionApp(baseDir, options = {}, customFrameworkModule) {
|
|
|
192
199
|
}
|
|
193
200
|
// v3 新的处理 bootstrap 过来的 faas 入口
|
|
194
201
|
if (options.entryFile) {
|
|
195
|
-
const exportModules = require((
|
|
202
|
+
const exportModules = require(formatPath(baseDir, options.entryFile));
|
|
196
203
|
options.starter = exportModules.getStarter();
|
|
197
204
|
}
|
|
198
205
|
let starterName;
|
|
@@ -436,7 +443,10 @@ async function createLightApp(baseDir = '', options = {}) {
|
|
|
436
443
|
}
|
|
437
444
|
exports.createLightApp = createLightApp;
|
|
438
445
|
async function createBootstrap(entryFile, options = {}) {
|
|
439
|
-
if (
|
|
446
|
+
if (!options.bootstrapMode) {
|
|
447
|
+
options.bootstrapMode = (0, core_1.safeRequire)('@midwayjs/faas') ? 'faas' : 'app';
|
|
448
|
+
}
|
|
449
|
+
if (options.bootstrapMode === 'faas') {
|
|
440
450
|
options.entryFile = entryFile;
|
|
441
451
|
const app = await createFunctionApp(process.cwd(), options);
|
|
442
452
|
return {
|
package/dist/interface.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ export interface MockAppConfigurationOptions extends IMidwayBootstrapOptions {
|
|
|
3
3
|
cleanLogsDir?: boolean;
|
|
4
4
|
cleanTempDir?: boolean;
|
|
5
5
|
ssl?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface MockBootstrapOptions extends MockAppConfigurationOptions {
|
|
6
8
|
entryFile?: string;
|
|
9
|
+
bootstrapMode?: 'faas' | 'app';
|
|
7
10
|
}
|
|
8
11
|
export type ComponentModule = {
|
|
9
12
|
Configuration: new () => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/mock",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.15",
|
|
4
4
|
"description": "create your test app from midway framework",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@midwayjs/core": "^3.11.
|
|
30
|
+
"@midwayjs/core": "^3.11.15",
|
|
31
31
|
"@midwayjs/logger": "^2.15.0",
|
|
32
32
|
"@types/amqplib": "0.10.1",
|
|
33
33
|
"amqplib": "0.10.3",
|
|
34
34
|
"kafkajs": "2.2.4",
|
|
35
|
-
"socket.io": "4.
|
|
36
|
-
"socket.io-client": "4.
|
|
35
|
+
"socket.io": "4.7.1",
|
|
36
|
+
"socket.io-client": "4.7.1",
|
|
37
37
|
"ws": "8.13.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@midwayjs/async-hooks-context-manager": "^3.11.
|
|
40
|
+
"@midwayjs/async-hooks-context-manager": "^3.11.15",
|
|
41
41
|
"@types/superagent": "4.1.14",
|
|
42
42
|
"@types/supertest": "2.0.12",
|
|
43
43
|
"js-yaml": "4.1.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"type": "git",
|
|
50
50
|
"url": "https://github.com/midwayjs/midway.git"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a4054247f3b9f4fc8ba51684c002606d849e0bd3"
|
|
53
53
|
}
|