@midwayjs/mock 3.11.11 → 3.11.12

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
@@ -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?: string, options?: MockAppConfigurationOptions, customFramework?: {
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?: MockAppConfigurationOptions): Promise<IBootstrapAppStarter>;
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 = process.cwd(), options, customFramework) {
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((0, path_1.join)(baseDir, options.entryFile));
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 ((0, core_1.safeRequire)('@midwayjs/faas')) {
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 {
@@ -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.11",
3
+ "version": "3.11.12",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "@types/amqplib": "0.10.1",
33
33
  "amqplib": "0.10.3",
34
34
  "kafkajs": "2.2.4",
35
- "socket.io": "4.6.2",
36
- "socket.io-client": "4.6.2",
35
+ "socket.io": "4.7.1",
36
+ "socket.io-client": "4.7.1",
37
37
  "ws": "8.13.0"
38
38
  },
39
39
  "dependencies": {
@@ -49,5 +49,5 @@
49
49
  "type": "git",
50
50
  "url": "https://github.com/midwayjs/midway.git"
51
51
  },
52
- "gitHead": "3d2e85a212cfecb5cecb8ab45134fa361fe6cba2"
52
+ "gitHead": "7454a59cd57e693a04e4c887535c9193354e2980"
53
53
  }