@midwayjs/mock 3.0.0-beta.12 → 3.0.0-beta.16
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 +5 -0
- package/dist/creator.js +26 -8
- package/package.json +10 -10
- package/CHANGELOG.md +0 -2098
package/dist/creator.d.ts
CHANGED
|
@@ -14,5 +14,10 @@ export declare function close(app: IMidwayApplication, options?: {
|
|
|
14
14
|
export declare function createFunctionApp<T extends IMidwayFramework<any, any, U>, U = T['configurationOptions'], Y = ReturnType<T['getApplication']>>(baseDir?: string, options?: MockAppConfigurationOptions, customFrameworkName?: {
|
|
15
15
|
new (...args: any[]): T;
|
|
16
16
|
} | ComponentModule): Promise<Y>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a real project but not ready or a virtual project
|
|
19
|
+
* @param baseDir
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
17
22
|
export declare function createLightApp(baseDir?: string, options?: MockAppConfigurationOptions): Promise<IMidwayApplication>;
|
|
18
23
|
//# sourceMappingURL=creator.d.ts.map
|
package/dist/creator.js
CHANGED
|
@@ -14,19 +14,21 @@ process.setMaxListeners(0);
|
|
|
14
14
|
async function create(appDir = process.cwd(), options, customFramework) {
|
|
15
15
|
debug(`[mock]: Create app, appDir="${appDir}"`);
|
|
16
16
|
process.env.MIDWAY_TS_MODE = 'true';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (appDir) {
|
|
18
|
+
// 处理测试的 fixtures
|
|
19
|
+
if (!(0, path_1.isAbsolute)(appDir)) {
|
|
20
|
+
appDir = (0, path_1.join)(process.cwd(), 'test', 'fixtures', appDir);
|
|
21
|
+
}
|
|
22
|
+
if (!(0, fs_1.existsSync)(appDir)) {
|
|
23
|
+
throw new core_1.MidwayCommonError(`Path "${appDir}" not exists, please check it.`);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
(0, logger_1.clearAllLoggers)();
|
|
25
27
|
options = options || {};
|
|
26
28
|
if (options.baseDir) {
|
|
27
29
|
(0, core_1.safeRequire)((0, path_1.join)(`${options.baseDir}`, 'interface'));
|
|
28
30
|
}
|
|
29
|
-
else {
|
|
31
|
+
else if (appDir) {
|
|
30
32
|
options.baseDir = `${appDir}/src`;
|
|
31
33
|
(0, core_1.safeRequire)((0, path_1.join)(`${options.baseDir}`, 'interface'));
|
|
32
34
|
}
|
|
@@ -67,7 +69,9 @@ async function create(appDir = process.cwd(), options, customFramework) {
|
|
|
67
69
|
appDir,
|
|
68
70
|
configurationModule: []
|
|
69
71
|
.concat(options.configurationModule)
|
|
70
|
-
.concat(
|
|
72
|
+
.concat(options.baseDir
|
|
73
|
+
? (0, core_1.safeRequire)((0, path_1.join)(options.baseDir, 'configuration'))
|
|
74
|
+
: []),
|
|
71
75
|
});
|
|
72
76
|
if (customFramework) {
|
|
73
77
|
return container.getAsync(customFramework);
|
|
@@ -138,8 +142,22 @@ class LightFramework extends core_1.BaseFramework {
|
|
|
138
142
|
return {};
|
|
139
143
|
}
|
|
140
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a real project but not ready or a virtual project
|
|
147
|
+
* @param baseDir
|
|
148
|
+
* @param options
|
|
149
|
+
*/
|
|
141
150
|
async function createLightApp(baseDir = '', options = {}) {
|
|
151
|
+
var _a;
|
|
142
152
|
(0, decorator_1.Framework)()(LightFramework);
|
|
153
|
+
options.globalConfig = Object.assign({
|
|
154
|
+
midwayLogger: {
|
|
155
|
+
default: {
|
|
156
|
+
disableFile: true,
|
|
157
|
+
disableError: true,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
}, (_a = options.globalConfig) !== null && _a !== void 0 ? _a : {});
|
|
143
161
|
return createApp(baseDir, {
|
|
144
162
|
...options,
|
|
145
163
|
configurationModule: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/mock",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.16",
|
|
4
4
|
"description": "create your test app from midway framework",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
},
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@midwayjs/core": "^3.0.0-beta.
|
|
30
|
-
"@midwayjs/decorator": "^3.0.0-beta.
|
|
31
|
-
"@midwayjs/logger": "
|
|
29
|
+
"@midwayjs/core": "^3.0.0-beta.16",
|
|
30
|
+
"@midwayjs/decorator": "^3.0.0-beta.16",
|
|
31
|
+
"@midwayjs/logger": "2.14.0",
|
|
32
32
|
"@types/amqplib": "*",
|
|
33
33
|
"amqplib": "*",
|
|
34
|
-
"socket.io": "
|
|
35
|
-
"socket.io-client": "
|
|
36
|
-
"ws": "
|
|
34
|
+
"socket.io": "4.4.1",
|
|
35
|
+
"socket.io-client": "4.4.1",
|
|
36
|
+
"ws": "8.4.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"fs-extra": "
|
|
40
|
-
"supertest": "
|
|
39
|
+
"fs-extra": "10.0.0",
|
|
40
|
+
"supertest": "6.2.0"
|
|
41
41
|
},
|
|
42
42
|
"author": "Harry Chen <czy88840616@gmail.com>",
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
|
45
45
|
"url": "http://github.com/midwayjs/midway.git"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "43a32745ac45164dfef1494cba979f9652a6692b"
|
|
48
48
|
}
|