@midwayjs/mock 3.5.3 → 3.7.0

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import * as WebSocket from 'ws';
3
4
  import * as http from 'http';
4
5
  import * as url from 'url';
package/dist/creator.js CHANGED
@@ -4,7 +4,6 @@ exports.createBootstrap = exports.createLightApp = exports.createFunctionApp = e
4
4
  const core_1 = require("@midwayjs/core");
5
5
  const path_1 = require("path");
6
6
  const fs_extra_1 = require("fs-extra");
7
- const decorator_1 = require("@midwayjs/decorator");
8
7
  const logger_1 = require("@midwayjs/logger");
9
8
  const utils_1 = require("./utils");
10
9
  const util_1 = require("util");
@@ -83,7 +82,7 @@ async function create(appDir = process.cwd(), options, customFramework) {
83
82
  const originMethod = container.listModule;
84
83
  container.listModule = key => {
85
84
  const modules = originMethod.call(container, key);
86
- if (key === decorator_1.CONFIGURATION_KEY) {
85
+ if (key === core_1.CONFIGURATION_KEY) {
87
86
  return modules;
88
87
  }
89
88
  return modules.filter((module) => {
@@ -139,10 +138,10 @@ async function close(app, options) {
139
138
  }
140
139
  }
141
140
  if (options.sleep > 0) {
142
- await (0, decorator_1.sleep)(options.sleep);
141
+ await (0, core_1.sleep)(options.sleep);
143
142
  }
144
143
  else {
145
- await (0, decorator_1.sleep)(50);
144
+ await (0, core_1.sleep)(50);
146
145
  }
147
146
  }
148
147
  }
@@ -189,7 +188,7 @@ async function createFunctionApp(baseDir = process.cwd(), options = {}, customFr
189
188
  }
190
189
  // new mode
191
190
  const exports = options.starter.start(options);
192
- await exports[options.initializeMethodName || 'initializer']();
191
+ await exports[options.initializeMethodName || 'initializer'](options['initializeContext'] || {});
193
192
  const appCtx = options.starter.getApplicationContext();
194
193
  const configService = appCtx.get(core_1.MidwayConfigService);
195
194
  const frameworkService = appCtx.get(core_1.MidwayFrameworkService);
@@ -214,8 +213,7 @@ async function createFunctionApp(baseDir = process.cwd(), options = {}, customFr
214
213
  }
215
214
  const ctx = await framework.wrapHttpRequest(req);
216
215
  // create event and invoke
217
- const func = framework.getTriggerFunction(url.pathname);
218
- const result = await func(ctx, {
216
+ const result = await framework.getTriggerFunction(ctx, url.pathname, {
219
217
  isHttpFunction: true,
220
218
  originEvent: req,
221
219
  originContext: {},
@@ -309,10 +307,10 @@ class BootstrapAppStarter {
309
307
  await BootstrapModule.Bootstrap.stop();
310
308
  }
311
309
  if (options.sleep > 0) {
312
- await (0, decorator_1.sleep)(options.sleep);
310
+ await (0, core_1.sleep)(options.sleep);
313
311
  }
314
312
  else {
315
- await (0, decorator_1.sleep)(50);
313
+ await (0, core_1.sleep)(50);
316
314
  }
317
315
  }
318
316
  }
@@ -323,7 +321,7 @@ class BootstrapAppStarter {
323
321
  */
324
322
  async function createLightApp(baseDir = '', options = {}) {
325
323
  var _a;
326
- (0, decorator_1.Framework)()(LightFramework);
324
+ (0, core_1.Framework)()(LightFramework);
327
325
  options.globalConfig = Object.assign({
328
326
  midwayLogger: {
329
327
  default: {
package/dist/utils.js CHANGED
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.transformFrameworkToConfiguration = exports.findFirstExistModule = exports.isWin32 = exports.isTestEnvironment = void 0;
10
10
  const core_1 = require("@midwayjs/core");
11
- const decorator_1 = require("@midwayjs/decorator");
12
11
  const os = require("os");
13
12
  const assert = require("assert");
14
13
  function isTestEnvironment() {
@@ -63,7 +62,7 @@ function transformFrameworkToConfiguration(Framework) {
63
62
  }
64
63
  };
65
64
  CustomConfiguration = __decorate([
66
- (0, decorator_1.Configuration)()
65
+ (0, core_1.Configuration)()
67
66
  ], CustomConfiguration);
68
67
  return {
69
68
  Configuration: CustomConfiguration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/mock",
3
- "version": "3.5.3",
3
+ "version": "3.7.0",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -27,29 +27,28 @@
27
27
  },
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@midwayjs/core": "^3.5.3",
31
- "@midwayjs/decorator": "^3.4.11",
30
+ "@midwayjs/core": "^3.7.0",
32
31
  "@midwayjs/logger": "^2.15.0",
33
32
  "@types/amqplib": "0.8.2",
34
33
  "amqplib": "0.10.3",
35
- "kafkajs": "2.2.0",
36
- "socket.io": "4.5.2",
37
- "socket.io-client": "4.5.2",
34
+ "kafkajs": "2.2.2",
35
+ "socket.io": "4.5.3",
36
+ "socket.io-client": "4.5.3",
38
37
  "ws": "8.9.0"
39
38
  },
40
39
  "dependencies": {
41
- "@midwayjs/async-hooks-context-manager": "^3.5.3",
40
+ "@midwayjs/async-hooks-context-manager": "^3.7.0",
42
41
  "@types/superagent": "4.1.14",
43
42
  "@types/supertest": "2.0.12",
44
43
  "fs-extra": "10.0.1",
45
44
  "js-yaml": "4.1.0",
46
45
  "raw-body": "2.5.1",
47
- "supertest": "6.2.4"
46
+ "supertest": "6.3.0"
48
47
  },
49
48
  "author": "Harry Chen <czy88840616@gmail.com>",
50
49
  "repository": {
51
50
  "type": "git",
52
51
  "url": "http://github.com/midwayjs/midway.git"
53
52
  },
54
- "gitHead": "32356484664846984f6d3d65a3a75dea015e8dcc"
53
+ "gitHead": "99386083ee26b386fd508b9c892091c914e77535"
55
54
  }