@midwayjs/mock 3.0.0-beta.13 → 3.0.0-beta.17

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 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,28 +14,29 @@ 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
- // 处理测试的 fixtures
18
- if (!(0, path_1.isAbsolute)(appDir)) {
19
- appDir = (0, path_1.join)(process.cwd(), 'test', 'fixtures', appDir);
20
- }
21
- if (!(0, fs_1.existsSync)(appDir)) {
22
- throw new core_1.MidwayCommonError(`Path "${appDir}" not exists, please check it.`);
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
  }
33
- if (!options.configurationModule && customFramework) {
34
- options.configurationModule =
35
- (0, utils_1.transformFrameworkToConfiguration)(customFramework);
35
+ if (!options.imports && customFramework) {
36
+ options.imports = (0, utils_1.transformFrameworkToConfiguration)(customFramework);
36
37
  }
37
38
  if (customFramework === null || customFramework === void 0 ? void 0 : customFramework['Configuration']) {
38
- options.configurationModule = customFramework;
39
+ options.imports = customFramework;
39
40
  customFramework = customFramework['Framework'];
40
41
  }
41
42
  const container = new core_1.MidwayContainer();
@@ -65,9 +66,11 @@ async function create(appDir = process.cwd(), options, customFramework) {
65
66
  await (0, core_1.initializeGlobalApplicationContext)({
66
67
  ...options,
67
68
  appDir,
68
- configurationModule: []
69
- .concat(options.configurationModule)
70
- .concat((0, core_1.safeRequire)((0, path_1.join)(options.baseDir, 'configuration'))),
69
+ imports: []
70
+ .concat(options.imports)
71
+ .concat(options.baseDir
72
+ ? (0, core_1.safeRequire)((0, path_1.join)(options.baseDir, 'configuration'))
73
+ : []),
71
74
  });
72
75
  if (customFramework) {
73
76
  return container.getAsync(customFramework);
@@ -116,7 +119,7 @@ async function createFunctionApp(baseDir = process.cwd(), options, customFramewo
116
119
  ]);
117
120
  const framework = await createApp(baseDir, {
118
121
  ...options,
119
- configurationModule: (0, utils_1.transformFrameworkToConfiguration)(customFramework),
122
+ imports: (0, utils_1.transformFrameworkToConfiguration)(customFramework),
120
123
  }, customFrameworkName);
121
124
  framework.configurationOptions = options;
122
125
  return framework;
@@ -138,13 +141,25 @@ class LightFramework extends core_1.BaseFramework {
138
141
  return {};
139
142
  }
140
143
  }
144
+ /**
145
+ * Create a real project but not ready or a virtual project
146
+ * @param baseDir
147
+ * @param options
148
+ */
141
149
  async function createLightApp(baseDir = '', options = {}) {
150
+ var _a;
142
151
  (0, decorator_1.Framework)()(LightFramework);
152
+ options.globalConfig = Object.assign({
153
+ midwayLogger: {
154
+ default: {
155
+ disableFile: true,
156
+ disableError: true,
157
+ },
158
+ },
159
+ }, (_a = options.globalConfig) !== null && _a !== void 0 ? _a : {});
143
160
  return createApp(baseDir, {
144
161
  ...options,
145
- configurationModule: [
146
- (0, utils_1.transformFrameworkToConfiguration)(LightFramework),
147
- ].concat(options === null || options === void 0 ? void 0 : options.configurationModule),
162
+ imports: [(0, utils_1.transformFrameworkToConfiguration)(LightFramework)].concat(options === null || options === void 0 ? void 0 : options.imports),
148
163
  });
149
164
  }
150
165
  exports.createLightApp = createLightApp;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/mock",
3
- "version": "3.0.0-beta.13",
3
+ "version": "3.0.0-beta.17",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
9
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
11
11
  "link": "npm link"
12
12
  },
13
13
  "keywords": [
@@ -26,23 +26,23 @@
26
26
  },
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@midwayjs/core": "^3.0.0-beta.13",
30
- "@midwayjs/decorator": "^3.0.0-beta.13",
31
- "@midwayjs/logger": "^3.0.0-beta.13",
29
+ "@midwayjs/core": "^3.0.0-beta.17",
30
+ "@midwayjs/decorator": "^3.0.0-beta.17",
31
+ "@midwayjs/logger": "2.14.0",
32
32
  "@types/amqplib": "*",
33
33
  "amqplib": "*",
34
- "socket.io": "^4.0.0",
35
- "socket.io-client": "^4.0.0",
36
- "ws": "^7.4.5"
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": "^8.0.1",
40
- "supertest": "^6.0.0"
39
+ "fs-extra": "10.0.0",
40
+ "supertest": "6.2.1"
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": "d3c47770fee9dce33a8d148882173fd7782864ad"
47
+ "gitHead": "17a8b5bd3d0b0b21f24dd2f165b5df9097fc3ec4"
48
48
  }