@midwayjs/mock 3.11.1-beta.2 → 3.11.1-beta.4

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
@@ -11,10 +11,7 @@ export declare function close<T extends IMidwayApplication<any>>(app: T, options
11
11
  cleanTempDir?: boolean;
12
12
  sleep?: number;
13
13
  }): Promise<void>;
14
- export declare function createFunctionApp<T extends IMidwayFramework<any, any, any, any, any>, Y = ReturnType<T['getApplication']>>(options: MockAppConfigurationOptions, customFrameworkModule?: {
15
- new (...args: any[]): T;
16
- } | ComponentModule): Promise<Y>;
17
- export declare function createFunctionApp<T extends IMidwayFramework<any, any, any, any, any>, Y = ReturnType<T['getApplication']>>(baseDir: string, options: MockAppConfigurationOptions, customFrameworkModule?: {
14
+ export declare function createFunctionApp<T extends IMidwayFramework<any, any, any, any, any>, Y = ReturnType<T['getApplication']>>(baseDir?: string | MockAppConfigurationOptions, options?: MockAppConfigurationOptions, customFrameworkModule?: {
18
15
  new (...args: any[]): T;
19
16
  } | ComponentModule): Promise<Y>;
20
17
  declare class BootstrapAppStarter {
package/dist/creator.js CHANGED
@@ -184,7 +184,7 @@ async function createFunctionApp(baseDir, options, customFrameworkModule) {
184
184
  baseDir = options.appDir || process.cwd();
185
185
  }
186
186
  let starterName;
187
- if (!options.starterExports && !options.starter) {
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.starterExports || options.starter) {
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
- let exports;
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);
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/mock",
3
- "version": "3.11.1-beta.2",
3
+ "version": "3.11.1-beta.4",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",