@midwayjs/core 3.4.6 → 3.4.7

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.
@@ -9,7 +9,7 @@ const error_1 = require("../error");
9
9
  const glob_1 = require("@midwayjs/glob");
10
10
  const path_1 = require("path");
11
11
  const decorator_1 = require("@midwayjs/decorator");
12
- const DEFAULT_PATTERN = ['**/**.ts', '**/**.js'];
12
+ const interface_1 = require("../interface");
13
13
  class DataSourceManager {
14
14
  constructor() {
15
15
  this.dataSource = new Map();
@@ -104,8 +104,9 @@ function globModels(globString, appDir) {
104
104
  const cwd = (0, path_1.join)(appDir, globString);
105
105
  const models = [];
106
106
  // string will be glob file
107
- const files = (0, glob_1.run)(DEFAULT_PATTERN, {
107
+ const files = (0, glob_1.run)(interface_1.DEFAULT_PATTERN, {
108
108
  cwd,
109
+ ignore: interface_1.IGNORE_PATTERN,
109
110
  });
110
111
  for (const file of files) {
111
112
  const exports = require(file);
@@ -4,6 +4,7 @@ exports.CustomModuleDetector = exports.DirectoryFileDetector = exports.AbstractF
4
4
  const decorator_1 = require("@midwayjs/decorator");
5
5
  const glob_1 = require("@midwayjs/glob");
6
6
  const error_1 = require("../error");
7
+ const interface_1 = require("../interface");
7
8
  class AbstractFileDetector {
8
9
  constructor(options) {
9
10
  this.options = options;
@@ -14,9 +15,8 @@ class AbstractFileDetector {
14
15
  }
15
16
  }
16
17
  exports.AbstractFileDetector = AbstractFileDetector;
17
- const DEFAULT_PATTERN = ['**/**.ts', '**/**.tsx', '**/**.js'];
18
+ const DEFAULT_GLOB_PATTERN = ['**/**.tsx'].concat(interface_1.DEFAULT_PATTERN);
18
19
  const DEFAULT_IGNORE_PATTERN = [
19
- '**/**.d.ts',
20
20
  '**/logs/**',
21
21
  '**/run/**',
22
22
  '**/public/**',
@@ -27,7 +27,7 @@ const DEFAULT_IGNORE_PATTERN = [
27
27
  '**/**.test.ts',
28
28
  '**/**.test.js',
29
29
  '**/__test__/**',
30
- ];
30
+ ].concat(interface_1.IGNORE_PATTERN);
31
31
  class DirectoryFileDetector extends AbstractFileDetector {
32
32
  constructor() {
33
33
  super(...arguments);
@@ -39,7 +39,7 @@ class DirectoryFileDetector extends AbstractFileDetector {
39
39
  .concat(this.options.loadDir || [])
40
40
  .concat(this.extraDetectorOptions.loadDir || []);
41
41
  for (const dir of loadDirs) {
42
- const fileResults = (0, glob_1.run)(DEFAULT_PATTERN.concat(this.options.pattern || []).concat(this.extraDetectorOptions.pattern || []), {
42
+ const fileResults = (0, glob_1.run)(DEFAULT_GLOB_PATTERN.concat(this.options.pattern || []).concat(this.extraDetectorOptions.pattern || []), {
43
43
  cwd: dir,
44
44
  ignore: DEFAULT_IGNORE_PATTERN.concat(this.options.ignore || []).concat(this.extraDetectorOptions.ignore || []),
45
45
  });
@@ -60,6 +60,8 @@ export declare class ContextMiddlewareManager<CTX extends IMidwayContext, R, N>
60
60
  * @param middlewareOrNameOrIdx
61
61
  */
62
62
  remove(middlewareOrNameOrIdx: CommonMiddleware<CTX, R, N> | string | number): CommonMiddleware<CTX, R, N>;
63
+ push(...items: any[]): number;
64
+ unshift(...items: any[]): number;
63
65
  /**
64
66
  * get middleware name list
65
67
  */
@@ -170,6 +170,22 @@ class ContextMiddlewareManager extends Array {
170
170
  }
171
171
  }
172
172
  }
173
+ push(...items) {
174
+ items.forEach(item => {
175
+ if (typeof item !== 'string' && !this.getMiddlewareName(item)) {
176
+ item._name = 'anonymous';
177
+ }
178
+ });
179
+ return super.push(...items);
180
+ }
181
+ unshift(...items) {
182
+ items.forEach(item => {
183
+ if (typeof item !== 'string' && !this.getMiddlewareName(item)) {
184
+ item._name = 'anonymous';
185
+ }
186
+ });
187
+ return super.unshift(...items);
188
+ }
173
189
  /**
174
190
  * get middleware name list
175
191
  */
@@ -483,5 +483,7 @@ export interface MidwayConfig extends FileConfigOption<typeof _default> {
483
483
  }
484
484
  export declare const ASYNC_CONTEXT_KEY: unique symbol;
485
485
  export declare const ASYNC_CONTEXT_MANAGER_KEY = "MIDWAY_ASYNC_CONTEXT_MANAGER_KEY";
486
+ export declare const DEFAULT_PATTERN: string[];
487
+ export declare const IGNORE_PATTERN: string[];
486
488
  export {};
487
489
  //# sourceMappingURL=interface.d.ts.map
package/dist/interface.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ASYNC_CONTEXT_MANAGER_KEY = exports.ASYNC_CONTEXT_KEY = exports.MIDWAY_LOGGER_WRITEABLE_DIR = exports.MidwayProcessTypeEnum = exports.REQUEST_CTX_LOGGER_CACHE_KEY = exports.HTTP_SERVER_KEY = exports.REQUEST_OBJ_CTX_KEY = exports.REQUEST_CTX_KEY = exports.ObjectLifeCycleEvent = void 0;
3
+ exports.IGNORE_PATTERN = exports.DEFAULT_PATTERN = exports.ASYNC_CONTEXT_MANAGER_KEY = exports.ASYNC_CONTEXT_KEY = exports.MIDWAY_LOGGER_WRITEABLE_DIR = exports.MidwayProcessTypeEnum = exports.REQUEST_CTX_LOGGER_CACHE_KEY = exports.HTTP_SERVER_KEY = exports.REQUEST_OBJ_CTX_KEY = exports.REQUEST_CTX_KEY = exports.ObjectLifeCycleEvent = void 0;
4
4
  var ObjectLifeCycleEvent;
5
5
  (function (ObjectLifeCycleEvent) {
6
6
  ObjectLifeCycleEvent["BEFORE_BIND"] = "beforeBind";
@@ -21,4 +21,13 @@ var MidwayProcessTypeEnum;
21
21
  exports.MIDWAY_LOGGER_WRITEABLE_DIR = 'MIDWAY_LOGGER_WRITEABLE_DIR';
22
22
  exports.ASYNC_CONTEXT_KEY = Symbol('ASYNC_CONTEXT_KEY');
23
23
  exports.ASYNC_CONTEXT_MANAGER_KEY = 'MIDWAY_ASYNC_CONTEXT_MANAGER_KEY';
24
+ exports.DEFAULT_PATTERN = [
25
+ '**/**.ts',
26
+ '**/**.js',
27
+ '**/**.mts',
28
+ '**/**.mjs',
29
+ '**/**.cts',
30
+ '**/**.cjs'
31
+ ];
32
+ exports.IGNORE_PATTERN = ['**/**.d.ts', '**/**.d.mts', '**/**.d.cts'];
24
33
  //# sourceMappingURL=interface.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.4.6",
3
+ "version": "3.4.7",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "36687482782bcf526efc2a4773c09e166820c1a8"
48
+ "gitHead": "3c60619a65c6776d99fbf0b30ac454d3cb6926b9"
49
49
  }