@fastcar/core 0.2.57 → 0.2.59

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/README.md CHANGED
@@ -44,6 +44,8 @@ Component 标注为组件
44
44
 
45
45
  ComponentInjection 自定义组件入口
46
46
 
47
+ ComponentScanMust 0.2.58 声明一个必须要扫描注入的方法 防止被笼统的排除在外
48
+
47
49
  Hotter 指定热更新类 0.2.13 版本生效(当我们修改代码后,可以自动热加载文件)
48
50
 
49
51
  BeanName 指明组件名称(每个组件具有一个系统生成id为"类名:16位随机值",为了便于调用可自定义逻辑名)
package/annotation.d.ts CHANGED
@@ -41,6 +41,7 @@ export function ApplicationDestory(order?: number): MRet;
41
41
  export function ComponentScan(...names: string[]): Ret;
42
42
  export function ComponentScanExclusion(...names: string[]): Ret;
43
43
  export function ComponentInjection(target: any, ...names: string[]): void;
44
+ export function ComponentScanMust(...names: string[]): Ret;
44
45
  export function Hotter(target: any): void;
45
46
 
46
47
  /***
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.2.57",
3
+ "version": "0.2.59",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -254,6 +254,7 @@ class FastCarApplication extends Events {
254
254
  //加载文件扫描下的bean
255
255
  let tmpFilePath: string[] = Array.of();
256
256
  let includeList: string[] = (Reflect.get(this, FastCarMetaData.ComponentScan) as string[]) || [];
257
+ let mustIncludMustList: string[] = (Reflect.get(this, FastCarMetaData.ComponentScanMust) as string[]) || [];
257
258
 
258
259
  //从配置文件内读
259
260
  if (Array.isArray(this.sysConfig.application?.scan?.include) && this.sysConfig.application?.scan?.include) {
@@ -268,7 +269,12 @@ class FastCarApplication extends Events {
268
269
  });
269
270
  }
270
271
 
271
- let includeFinalList: string[] = [...tmpFilePath];
272
+ let includeFinalList: string[] = [];
273
+ mustIncludMustList.forEach((item) => {
274
+ let tmpList = FileUtil.getFilePathList(item);
275
+ includeFinalList = includeFinalList.concat(tmpList);
276
+ });
277
+
272
278
  let filePathList = FileUtil.getFilePathList(this.basePath);
273
279
 
274
280
  filePathList = tmpFilePath.concat(filePathList);
@@ -0,0 +1,26 @@
1
+ import "reflect-metadata";
2
+ import * as path from "path";
3
+ import * as fs from "fs";
4
+ import { FastCarMetaData } from "../../constant/FastCarMetaData";
5
+
6
+ //和本包的相对路径
7
+ export default function ComponentScanMust(...names: string[]) {
8
+ return function (target: any) {
9
+ let scanMust = FastCarMetaData.ComponentScanMust;
10
+ let list: string[] = Reflect.get(target.prototype, scanMust) || [];
11
+
12
+ for (let name of names) {
13
+ //可支持绝对路径
14
+ let p = path.join(require.main?.path || process.cwd() || "", name);
15
+ if (fs.existsSync(name)) {
16
+ p = name;
17
+ }
18
+
19
+ if (!list.includes(p)) {
20
+ list.push(p);
21
+ }
22
+ }
23
+
24
+ Reflect.set(target.prototype, scanMust, list);
25
+ };
26
+ }
package/src/annotation.ts CHANGED
@@ -49,6 +49,7 @@ import AliasInjection from "./annotation/bind/AliasInjection";
49
49
  import ResourcePath from "./annotation/env/ResourcePath";
50
50
  import BaseName from "./annotation/env/BaseName";
51
51
  import CustomType from "./annotation/valid/CustomType";
52
+ import ComponentScanMust from "./annotation/scan/ComponentScanMust";
52
53
 
53
54
  //注解暴露出去
54
55
  export {
@@ -61,6 +62,7 @@ export {
61
62
  ComponentScanExclusion,
62
63
  Component,
63
64
  ComponentInjection,
65
+ ComponentScanMust,
64
66
  Hotter,
65
67
  BeanName,
66
68
  Configure,
@@ -23,4 +23,5 @@ export enum FastCarMetaData {
23
23
  LoggerModule = "LoggerModule", //日志模块集合
24
24
  HotterSysConfig = "hotterSysConfig", //支持热更系统配置
25
25
  CustomType = "custom:type", //自定义类型
26
+ ComponentScanMust = "ComponentScanMust", //扫描路径
26
27
  }
@@ -215,6 +215,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
215
215
  //加载文件扫描下的bean
216
216
  let tmpFilePath = Array.of();
217
217
  let includeList = Reflect.get(this, FastCarMetaData_1.FastCarMetaData.ComponentScan) || [];
218
+ let mustIncludMustList = Reflect.get(this, FastCarMetaData_1.FastCarMetaData.ComponentScanMust) || [];
218
219
  //从配置文件内读
219
220
  if (Array.isArray(this.sysConfig.application?.scan?.include) && this.sysConfig.application?.scan?.include) {
220
221
  includeList = [...includeList, ...this.sysConfig.application.scan.include];
@@ -226,7 +227,11 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
226
227
  tmpFilePath = tmpFilePath.concat(tmpList);
227
228
  });
228
229
  }
229
- let includeFinalList = [...tmpFilePath];
230
+ let includeFinalList = [];
231
+ mustIncludMustList.forEach((item) => {
232
+ let tmpList = FileUtil_1.default.getFilePathList(item);
233
+ includeFinalList = includeFinalList.concat(tmpList);
234
+ });
230
235
  let filePathList = FileUtil_1.default.getFilePathList(this.basePath);
231
236
  filePathList = tmpFilePath.concat(filePathList);
232
237
  filePathList = [...new Set(filePathList)];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
7
+ //和本包的相对路径
8
+ function ComponentScanMust(...names) {
9
+ return function (target) {
10
+ let scanMust = FastCarMetaData_1.FastCarMetaData.ComponentScanMust;
11
+ let list = Reflect.get(target.prototype, scanMust) || [];
12
+ for (let name of names) {
13
+ //可支持绝对路径
14
+ let p = path.join(require.main?.path || process.cwd() || "", name);
15
+ if (fs.existsSync(name)) {
16
+ p = name;
17
+ }
18
+ if (!list.includes(p)) {
19
+ list.push(p);
20
+ }
21
+ }
22
+ Reflect.set(target.prototype, scanMust, list);
23
+ };
24
+ }
25
+ exports.default = ComponentScanMust;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = exports.Transactional = exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.Hotter = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
4
- exports.ApplicationSetting = void 0;
3
+ exports.BasePath = exports.BaseFilePath = exports.ENV = exports.Transactional = exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
4
+ exports.ApplicationSetting = exports.BaseName = void 0;
5
5
  const Application_1 = require("./annotation/Application");
6
6
  exports.Application = Application_1.default;
7
7
  const Autowired_1 = require("./annotation/bind/Autowired");
@@ -104,3 +104,5 @@ const BaseName_1 = require("./annotation/env/BaseName");
104
104
  exports.BaseName = BaseName_1.default;
105
105
  const CustomType_1 = require("./annotation/valid/CustomType");
106
106
  exports.CustomType = CustomType_1.default;
107
+ const ComponentScanMust_1 = require("./annotation/scan/ComponentScanMust");
108
+ exports.ComponentScanMust = ComponentScanMust_1.default;
@@ -27,4 +27,5 @@ var FastCarMetaData;
27
27
  FastCarMetaData["LoggerModule"] = "LoggerModule";
28
28
  FastCarMetaData["HotterSysConfig"] = "hotterSysConfig";
29
29
  FastCarMetaData["CustomType"] = "custom:type";
30
+ FastCarMetaData["ComponentScanMust"] = "ComponentScanMust";
30
31
  })(FastCarMetaData = exports.FastCarMetaData || (exports.FastCarMetaData = {}));