@midwayjs/mock 3.0.0-alpha.1 → 3.0.0-alpha.36

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/CHANGELOG.md CHANGED
@@ -3,12 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [3.0.0-alpha.1](https://github.com/midwayjs/midway/compare/v2.12.1...v3.0.0-alpha.1) (2021-08-04)
6
+ ## [2.12.3](https://github.com/midwayjs/midway/compare/v2.12.2...v2.12.3) (2021-08-09)
7
7
 
8
-
9
- ### Bug Fixes
10
-
11
- * refactor directory file detector ([f869942](https://github.com/midwayjs/midway/commit/f869942589a4985dfc59457fa80b536be7bdc19f))
8
+ **Note:** Version bump only for package @midwayjs/mock
12
9
 
13
10
 
14
11
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { create, close, createApp, createFunctionApp, createBootstrap, } from './utils';
1
+ export { create, close, createApp, createFunctionApp, createBootstrap, createLightApp, } from './utils';
2
2
  export * from './client/http';
3
3
  export * from './client/rabbitMQ';
4
4
  export * from './client/socketio';
package/dist/index.js CHANGED
@@ -10,13 +10,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.createBootstrap = exports.createFunctionApp = exports.createApp = exports.close = exports.create = void 0;
13
+ exports.createLightApp = exports.createBootstrap = exports.createFunctionApp = exports.createApp = exports.close = exports.create = void 0;
14
14
  var utils_1 = require("./utils");
15
15
  Object.defineProperty(exports, "create", { enumerable: true, get: function () { return utils_1.create; } });
16
16
  Object.defineProperty(exports, "close", { enumerable: true, get: function () { return utils_1.close; } });
17
17
  Object.defineProperty(exports, "createApp", { enumerable: true, get: function () { return utils_1.createApp; } });
18
18
  Object.defineProperty(exports, "createFunctionApp", { enumerable: true, get: function () { return utils_1.createFunctionApp; } });
19
19
  Object.defineProperty(exports, "createBootstrap", { enumerable: true, get: function () { return utils_1.createBootstrap; } });
20
+ Object.defineProperty(exports, "createLightApp", { enumerable: true, get: function () { return utils_1.createLightApp; } });
20
21
  __exportStar(require("./client/http"), exports);
21
22
  __exportStar(require("./client/rabbitMQ"), exports);
22
23
  __exportStar(require("./client/socketio"), exports);
@@ -1,5 +1,5 @@
1
1
  import { MockApplication, MockOption } from 'egg-mock';
2
- import { IApplicationContext, IMidwayContainer } from '@midwayjs/core';
2
+ import { IMidwayContainer } from '@midwayjs/core';
3
3
  /**
4
4
  * @deprecated
5
5
  */
@@ -36,7 +36,7 @@ export interface MidwayMockApplication extends MockApplication {
36
36
  baseDir: string;
37
37
  enablePlugins: any;
38
38
  getApplicationContext(): IMidwayContainer;
39
- getPluginContext(): IApplicationContext;
39
+ getPluginContext(): IMidwayContainer;
40
40
  getPlugin(pluginName: string): any;
41
41
  getLogger(name?: string): any;
42
42
  getConfig(key?: string): any;
package/dist/utils.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare function close(app: IMidwayApplication | IMidwayFramework<any, an
14
14
  sleep?: number;
15
15
  }): Promise<void>;
16
16
  export declare function createFunctionApp<T extends IMidwayFramework<any, U>, U = T['configurationOptions'], Y = ReturnType<T['getApplication']>>(baseDir?: string, options?: U & MockAppConfigurationOptions, customFrameworkName?: string | MidwayFrameworkType | any): Promise<Y>;
17
+ export declare function createLightApp(baseDir?: string, options?: MockAppConfigurationOptions): Promise<IMidwayApplication>;
17
18
  declare class BootstrapAppStarter {
18
19
  getApp(type: MidwayFrameworkType): IMidwayApplication<any>;
19
20
  close(options?: {
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBootstrap = exports.createFunctionApp = exports.close = exports.createApp = exports.create = void 0;
3
+ exports.createBootstrap = exports.createLightApp = exports.createFunctionApp = exports.close = exports.createApp = exports.create = void 0;
4
4
  const bootstrap_1 = require("@midwayjs/bootstrap");
5
5
  const core_1 = require("@midwayjs/core");
6
6
  const path_1 = require("path");
@@ -51,34 +51,34 @@ function getIncludeFramework(dependencies) {
51
51
  }
52
52
  }
53
53
  function formatPath(baseDir, p) {
54
- if (path_1.isAbsolute(p)) {
54
+ if ((0, path_1.isAbsolute)(p)) {
55
55
  return p;
56
56
  }
57
57
  else {
58
- return path_1.resolve(baseDir, p);
58
+ return (0, path_1.resolve)(baseDir, p);
59
59
  }
60
60
  }
61
61
  let lastAppDir;
62
62
  async function create(appDir = process.cwd(), options, customFrameworkName) {
63
63
  process.env.MIDWAY_TS_MODE = 'true';
64
64
  // 处理测试的 fixtures
65
- if (!path_1.isAbsolute(appDir)) {
66
- appDir = path_1.join(process.cwd(), 'test', 'fixtures', appDir);
65
+ if (!(0, path_1.isAbsolute)(appDir)) {
66
+ appDir = (0, path_1.join)(process.cwd(), 'test', 'fixtures', appDir);
67
67
  }
68
68
  if (lastAppDir && lastAppDir !== appDir) {
69
69
  // 当目录不同才清理缓存,相同目录的装饰器只加载一次,清理了就没了
70
- decorator_1.clearAllModule();
70
+ (0, decorator_1.clearAllModule)();
71
71
  }
72
72
  lastAppDir = appDir;
73
73
  global['MIDWAY_BOOTSTRAP_APP_SET'].clear();
74
74
  // clearContainerCache();
75
- logger_1.clearAllLoggers();
75
+ (0, logger_1.clearAllLoggers)();
76
76
  options = options || {};
77
77
  if (options.baseDir) {
78
- core_1.safeRequire(path_1.join(`${options.baseDir}`, 'interface'));
78
+ (0, core_1.safeRequire)((0, path_1.join)(`${options.baseDir}`, 'interface'));
79
79
  }
80
80
  else {
81
- core_1.safeRequire(path_1.join(`${appDir}`, 'src/interface'));
81
+ (0, core_1.safeRequire)((0, path_1.join)(`${appDir}`, 'src/interface'));
82
82
  }
83
83
  if (options.entryFile) {
84
84
  // start from entry file, like bootstrap.js
@@ -119,7 +119,7 @@ async function create(appDir = process.cwd(), options, customFrameworkName) {
119
119
  }
120
120
  else {
121
121
  // find default framework from pkg
122
- const pkg = require(path_1.join(appDir, 'package.json'));
122
+ const pkg = require((0, path_1.join)(appDir, 'package.json'));
123
123
  if (pkg.dependencies || pkg.devDependencies) {
124
124
  customFrameworkName = getIncludeFramework(Object.assign({}, pkg.dependencies || {}, pkg.devDependencies || {}));
125
125
  }
@@ -189,18 +189,18 @@ async function close(app, options) {
189
189
  if (isTestEnvironment()) {
190
190
  // clean first
191
191
  if (options.cleanLogsDir && !isWin32()) {
192
- await fs_extra_1.remove(path_1.join(newApp.getAppDir(), 'logs'));
192
+ await (0, fs_extra_1.remove)((0, path_1.join)(newApp.getAppDir(), 'logs'));
193
193
  }
194
194
  if (core_1.MidwayFrameworkType.WEB === newApp.getFrameworkType()) {
195
195
  if (options.cleanTempDir && !isWin32()) {
196
- await fs_extra_1.remove(path_1.join(newApp.getAppDir(), 'run'));
196
+ await (0, fs_extra_1.remove)((0, path_1.join)(newApp.getAppDir(), 'run'));
197
197
  }
198
198
  }
199
199
  if (options.sleep > 0) {
200
- await decorator_1.sleep(options.sleep);
200
+ await (0, decorator_1.sleep)(options.sleep);
201
201
  }
202
202
  else {
203
- await decorator_1.sleep(50);
203
+ await (0, decorator_1.sleep)(50);
204
204
  }
205
205
  }
206
206
  }
@@ -215,6 +215,10 @@ async function createFunctionApp(baseDir = process.cwd(), options, customFramewo
215
215
  return framework.getApplication();
216
216
  }
217
217
  exports.createFunctionApp = createFunctionApp;
218
+ async function createLightApp(baseDir = process.cwd(), options) {
219
+ return await createApp(baseDir, options, core_1.LightFramework);
220
+ }
221
+ exports.createLightApp = createLightApp;
218
222
  class BootstrapAppStarter {
219
223
  getApp(type) {
220
224
  const appMap = bootstrap_1.Bootstrap.starter.getBootstrapAppMap();
@@ -223,10 +227,10 @@ class BootstrapAppStarter {
223
227
  async close(options = {}) {
224
228
  await bootstrap_1.Bootstrap.stop();
225
229
  if (options.sleep > 0) {
226
- await decorator_1.sleep(options.sleep);
230
+ await (0, decorator_1.sleep)(options.sleep);
227
231
  }
228
232
  else {
229
- await decorator_1.sleep(50);
233
+ await (0, decorator_1.sleep)(50);
230
234
  }
231
235
  }
232
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/mock",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.36+b2d0a363",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@midwayjs/core": "^3.0.0-alpha.1",
32
- "@midwayjs/decorator": "^3.0.0-alpha.1",
33
- "@midwayjs/logger": "^2.11.3",
31
+ "@midwayjs/core": "^3.0.0-alpha.36+b2d0a363",
32
+ "@midwayjs/decorator": "^3.0.0-alpha.36+b2d0a363",
33
+ "@midwayjs/logger": "^2.13.0",
34
34
  "@types/amqplib": "*",
35
35
  "amqplib": "*",
36
36
  "socket.io": "^4.0.0",
@@ -38,7 +38,7 @@
38
38
  "ws": "^7.4.5"
39
39
  },
40
40
  "dependencies": {
41
- "@midwayjs/bootstrap": "^3.0.0-alpha.1",
41
+ "@midwayjs/bootstrap": "^3.0.0-alpha.36+b2d0a363",
42
42
  "egg-mock": "^3.21.0",
43
43
  "fs-extra": "^8.0.1",
44
44
  "supertest": "^6.0.0"
@@ -48,5 +48,5 @@
48
48
  "type": "git",
49
49
  "url": "http://github.com/midwayjs/midway.git"
50
50
  },
51
- "gitHead": "408dca018bcbf6d1724e44fdcb785867e76a4007"
51
+ "gitHead": "b2d0a363d98302fda64ff47a6d25fca6e003a434"
52
52
  }