@fastcar/core 0.3.0 → 0.3.1
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/package.json +2 -2
- package/src/FastCarApplication.ts +4 -2
- package/src/annotation/Application.ts +2 -1
- package/src/annotation/bind/DemandInjection.ts +1 -2
- package/target/FastCarApplication.js +3 -2
- package/target/annotation/Application.js +3 -3
- package/test/multi/app.ts +2 -2
- package/test/example/logs/fastcar-server.app.log +0 -0
- package/test/example/logs/fastcar-server.sys.log +0 -10
- package/test/example/logs/fastcar-server.sys1.log +0 -8
- package/test/example/logs/fastcar-server.sys2.log +0 -11
- package/test/example/logs/fastcar-server.sys3.log +0 -0
- package/test/example/logs/other-server.app.log +0 -0
- package/test/example/logs/other-server.sys.log +0 -5
- package/test/example/logs/sys.log +0 -0
- package/test/example/logs/sys1.log +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastcar/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"homepage": "https://github.com/williamDazhangyu/fast-car",
|
|
5
5
|
"main": "target/index.js",
|
|
6
6
|
"author": "william_zhong",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@fastcar/core"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=16"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"reflect-metadata": "^0.2.2",
|
|
@@ -27,7 +27,7 @@ import { LifeCycleType } from "./annotation/lifeCycle/AddLifeCycleItem";
|
|
|
27
27
|
import { WinstonLoggerType } from "./type/WinstonLoggerType";
|
|
28
28
|
import { ClassConstructor } from "./type/ClassConstructor";
|
|
29
29
|
import ReflectUtil from "./utils/ReflectUtil";
|
|
30
|
-
import
|
|
30
|
+
import Log from "./annotation/stereotype/Log";
|
|
31
31
|
|
|
32
32
|
@Component
|
|
33
33
|
class FastCarApplication extends Events {
|
|
@@ -39,7 +39,7 @@ class FastCarApplication extends Events {
|
|
|
39
39
|
protected applicationStatus: AppStatusEnum;
|
|
40
40
|
|
|
41
41
|
@Log("sys")
|
|
42
|
-
protected sysLogger
|
|
42
|
+
protected sysLogger: Logger;
|
|
43
43
|
|
|
44
44
|
protected componentDeatils: Map<string | symbol, ComponentDesc>; //读取路径 名称
|
|
45
45
|
protected liveTime: number;
|
|
@@ -65,6 +65,8 @@ class FastCarApplication extends Events {
|
|
|
65
65
|
this.componentAliasMap = new Map();
|
|
66
66
|
this.hotConfigure = new Map();
|
|
67
67
|
|
|
68
|
+
this.sysLogger = console;
|
|
69
|
+
|
|
68
70
|
this.loadSelf();
|
|
69
71
|
this.addHot();
|
|
70
72
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import FastCarApplication from "../FastCarApplication";
|
|
2
1
|
import { ClassConstructor } from "../type/ClassConstructor";
|
|
3
2
|
import ClassUtils from "../utils/ClassUtils";
|
|
4
3
|
import TypeUtil from "../utils/TypeUtil";
|
|
@@ -7,6 +6,8 @@ import TypeUtil from "../utils/TypeUtil";
|
|
|
7
6
|
export default function Application(target: any) {
|
|
8
7
|
return new Proxy(target, {
|
|
9
8
|
construct: (target: ClassConstructor<Object>, args: any) => {
|
|
9
|
+
const FastCarApplication = require("../FastCarApplication").default;
|
|
10
|
+
|
|
10
11
|
let app = new FastCarApplication();
|
|
11
12
|
let appProxy = new target(...args);
|
|
12
13
|
Reflect.set(appProxy, "app", app);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
//延迟注入作用用于类上,用于没有初始时的依赖注入
|
|
2
2
|
import { CommonConstant } from "../../constant/CommonConstant";
|
|
3
|
-
import FastCarApplication from "../../FastCarApplication";
|
|
4
3
|
import { ClassConstructor } from "../../type/ClassConstructor";
|
|
5
4
|
|
|
6
5
|
export default function DemandInjection(Target: ClassConstructor<any>) {
|
|
7
6
|
return new Proxy(Target, {
|
|
8
7
|
construct: (Target: ClassConstructor<any>, args: any) => {
|
|
9
8
|
let c = new Target(...args);
|
|
10
|
-
let app:
|
|
9
|
+
let app: any = Reflect.get(global, CommonConstant.FastcarApp);
|
|
11
10
|
|
|
12
11
|
app?.loadInjectionService(c);
|
|
13
12
|
return c;
|
|
@@ -31,7 +31,7 @@ const Logger_1 = require("./interface/Logger");
|
|
|
31
31
|
const DateUtil_1 = require("./utils/DateUtil");
|
|
32
32
|
const FileHotterDesc_1 = require("./type/FileHotterDesc");
|
|
33
33
|
const ReflectUtil_1 = require("./utils/ReflectUtil");
|
|
34
|
-
const
|
|
34
|
+
const Log_1 = require("./annotation/stereotype/Log");
|
|
35
35
|
let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends Events {
|
|
36
36
|
componentMap; //组件键值对
|
|
37
37
|
sysConfig; //系统配置
|
|
@@ -61,6 +61,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
|
|
|
61
61
|
this.reloadTimerId = null;
|
|
62
62
|
this.componentAliasMap = new Map();
|
|
63
63
|
this.hotConfigure = new Map();
|
|
64
|
+
this.sysLogger = console;
|
|
64
65
|
this.loadSelf();
|
|
65
66
|
this.addHot();
|
|
66
67
|
}
|
|
@@ -754,7 +755,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
|
|
|
754
755
|
}
|
|
755
756
|
};
|
|
756
757
|
__decorate([
|
|
757
|
-
(0,
|
|
758
|
+
(0, Log_1.default)("sys"),
|
|
758
759
|
__metadata("design:type", Logger_1.default)
|
|
759
760
|
], FastCarApplication.prototype, "sysLogger", void 0);
|
|
760
761
|
FastCarApplication = FastCarApplication_1 = __decorate([
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = Application;
|
|
4
|
-
const FastCarApplication_1 = require("../FastCarApplication");
|
|
5
4
|
const ClassUtils_1 = require("../utils/ClassUtils");
|
|
6
5
|
const TypeUtil_1 = require("../utils/TypeUtil");
|
|
7
6
|
//基础服务的应用
|
|
8
7
|
function Application(target) {
|
|
9
8
|
return new Proxy(target, {
|
|
10
9
|
construct: (target, args) => {
|
|
11
|
-
|
|
10
|
+
const FastCarApplication = require("../FastCarApplication").default;
|
|
11
|
+
let app = new FastCarApplication();
|
|
12
12
|
let appProxy = new target(...args);
|
|
13
13
|
Reflect.set(appProxy, "app", app);
|
|
14
14
|
let keys = ClassUtils_1.default.getProtoType(target);
|
|
@@ -16,7 +16,7 @@ function Application(target) {
|
|
|
16
16
|
if (key != "constructor") {
|
|
17
17
|
let desc = ClassUtils_1.default.getProtoDesc(target, key);
|
|
18
18
|
if (desc) {
|
|
19
|
-
let beforeFun = Object.getOwnPropertyDescriptor(
|
|
19
|
+
let beforeFun = Object.getOwnPropertyDescriptor(FastCarApplication.prototype, key)?.value;
|
|
20
20
|
let afterFun = desc.value;
|
|
21
21
|
if (Reflect.has(app, key) && TypeUtil_1.default.isFunction(afterFun) && TypeUtil_1.default.isFunction(beforeFun)) {
|
|
22
22
|
let mixFn = async (...args) => {
|
package/test/multi/app.ts
CHANGED
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-12-03 21:04:11.499","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2024-12-03 21:04:11.802","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2024-12-03 21:04:11.805","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2024-12-03 21:04:11.808","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2024-12-03 21:04:11.809","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
-
{"timestamp":"2024-12-04 10:41:41.933","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
-
{"timestamp":"2024-12-04 10:41:42.256","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
-
{"timestamp":"2024-12-04 10:41:42.258","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
-
{"timestamp":"2024-12-04 10:41:42.260","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
-
{"timestamp":"2024-12-04 10:41:42.260","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-12-04 10:46:19.406","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2024-12-04 10:46:19.697","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2024-12-04 10:46:19.700","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2024-12-04 10:46:19.701","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2024-12-04 10:46:19.702","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
-
{"timestamp":"2024-12-04 10:46:32.426","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
7
|
-
{"timestamp":"2024-12-04 10:46:37.328","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
8
|
-
{"timestamp":"2024-12-04 10:46:39.653","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-12-04 10:49:26.216","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2024-12-04 10:49:26.499","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2024-12-04 10:49:26.502","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2024-12-04 10:49:26.505","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2024-12-04 10:49:26.506","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
-
{"timestamp":"2024-12-04 10:49:32.122","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
7
|
-
{"timestamp":"2024-12-04 10:49:36.193","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
8
|
-
{"timestamp":"2024-12-04 10:49:40.181","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
9
|
-
{"timestamp":"2024-12-04 10:49:43.876","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
10
|
-
{"timestamp":"2024-12-04 10:49:46.833","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
11
|
-
{"timestamp":"2024-12-04 10:49:52.191","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-12-03 21:04:24.672","level":"INFO","label":"other-server.sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2024-12-03 21:04:25.431","level":"INFO","label":"other-server.sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2024-12-03 21:04:25.433","level":"INFO","label":"other-server.sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2024-12-03 21:04:25.436","level":"INFO","label":"other-server.sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2024-12-03 21:04:25.437","level":"INFO","label":"other-server.sys","message":"version 1.0.0"}
|
|
File without changes
|
|
File without changes
|