@midwayjs/mock 3.11.1-beta.3 → 3.11.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/LICENSE +21 -0
- package/dist/creator.js +4 -11
- package/dist/interface.d.ts +0 -4
- package/dist/utils.js +4 -3
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/creator.js
CHANGED
|
@@ -177,14 +177,14 @@ async function close(app, options) {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
exports.close = close;
|
|
180
|
-
async function createFunctionApp(baseDir, options, customFrameworkModule) {
|
|
180
|
+
async function createFunctionApp(baseDir, options = {}, customFrameworkModule) {
|
|
181
181
|
var _a, _b, _c, _d;
|
|
182
182
|
if (typeof baseDir === 'object') {
|
|
183
183
|
options = baseDir;
|
|
184
184
|
baseDir = options.appDir || process.cwd();
|
|
185
185
|
}
|
|
186
186
|
let starterName;
|
|
187
|
-
if (!options.
|
|
187
|
+
if (!options.starter) {
|
|
188
188
|
// load yaml
|
|
189
189
|
try {
|
|
190
190
|
const doc = yaml.load((0, fs_1.readFileSync)((0, path_1.join)(baseDir, 'f.yml'), 'utf8'));
|
|
@@ -201,7 +201,7 @@ async function createFunctionApp(baseDir, options, customFrameworkModule) {
|
|
|
201
201
|
console.error('[mock]: get f.yml information fail, err = ' + e.stack);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
if (options.
|
|
204
|
+
if (options.starter) {
|
|
205
205
|
options.appDir = baseDir;
|
|
206
206
|
debug(`[mock]: Create app, appDir="${options.appDir}"`);
|
|
207
207
|
process.env.MIDWAY_TS_MODE = 'true';
|
|
@@ -224,13 +224,7 @@ async function createFunctionApp(baseDir, options, customFrameworkModule) {
|
|
|
224
224
|
(0, core_1.safeRequire)((0, path_1.join)(`${options.baseDir}`, 'interface'));
|
|
225
225
|
}
|
|
226
226
|
// new mode
|
|
227
|
-
|
|
228
|
-
if (options.starterExports) {
|
|
229
|
-
exports = options.starterExports;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
exports = options.starter.start(options);
|
|
233
|
-
}
|
|
227
|
+
const exports = options.starter.start(options);
|
|
234
228
|
await exports[options.initializeMethodName || 'initializer'](options['initializeContext']);
|
|
235
229
|
const appCtx = options.starter.getApplicationContext();
|
|
236
230
|
const configService = appCtx.get(core_1.MidwayConfigService);
|
|
@@ -342,7 +336,6 @@ async function createFunctionApp(baseDir, options, customFrameworkModule) {
|
|
|
342
336
|
return app;
|
|
343
337
|
}
|
|
344
338
|
else {
|
|
345
|
-
// 兼容老代码
|
|
346
339
|
const customFramework = customFrameworkModule !== null && customFrameworkModule !== void 0 ? customFrameworkModule : (0, utils_1.findFirstExistModule)([
|
|
347
340
|
process.env.MIDWAY_SERVERLESS_APP_NAME,
|
|
348
341
|
'@ali/serverless-app',
|
package/dist/interface.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ export interface MockAppConfigurationOptions extends IMidwayBootstrapOptions {
|
|
|
3
3
|
cleanLogsDir?: boolean;
|
|
4
4
|
cleanTempDir?: boolean;
|
|
5
5
|
ssl?: boolean;
|
|
6
|
-
starterExports?: {
|
|
7
|
-
start: () => unknown;
|
|
8
|
-
close: () => unknown;
|
|
9
|
-
};
|
|
10
6
|
}
|
|
11
7
|
export type ComponentModule = {
|
|
12
8
|
Configuration: new () => any;
|
package/dist/utils.js
CHANGED
|
@@ -10,7 +10,8 @@ exports.mergeGlobalConfig = exports.removeFile = exports.transformFrameworkToCon
|
|
|
10
10
|
const core_1 = require("@midwayjs/core");
|
|
11
11
|
const os = require("os");
|
|
12
12
|
const assert = require("assert");
|
|
13
|
-
const
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const { access, unlink, constants } = fs_1.promises;
|
|
14
15
|
function isTestEnvironment() {
|
|
15
16
|
const testEnv = ['test', 'unittest'];
|
|
16
17
|
return (testEnv.includes(process.env.MIDWAY_SERVER_ENV) ||
|
|
@@ -73,8 +74,8 @@ function transformFrameworkToConfiguration(Framework) {
|
|
|
73
74
|
exports.transformFrameworkToConfiguration = transformFrameworkToConfiguration;
|
|
74
75
|
async function removeFile(file) {
|
|
75
76
|
try {
|
|
76
|
-
await
|
|
77
|
-
await
|
|
77
|
+
await access(file, constants.W_OK);
|
|
78
|
+
await unlink(file);
|
|
78
79
|
}
|
|
79
80
|
catch (_a) {
|
|
80
81
|
// ignore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/mock",
|
|
3
|
-
"version": "3.11.1
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "create your test app from midway framework",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@midwayjs/core": "^3.11.
|
|
30
|
+
"@midwayjs/core": "^3.11.1",
|
|
31
31
|
"@midwayjs/logger": "^2.15.0",
|
|
32
32
|
"@types/amqplib": "0.10.1",
|
|
33
33
|
"amqplib": "0.10.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
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.1",
|
|
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": "bd9375874eb8cfaa49fbcfaa0497021cea06a394"
|
|
53
53
|
}
|