@midwayjs/info 4.0.0-alpha.1 → 4.0.0-beta.2
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 +1 -1
- package/dist/config.default.js +1 -0
- package/dist/infoService.d.ts +10 -6
- package/dist/infoService.js +39 -24
- package/dist/interface.d.ts +14 -0
- package/dist/interface.js +15 -1
- package/dist/middleware/info.middleware.d.ts +1 -1
- package/dist/middleware/info.middleware.js +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
package/dist/config.default.js
CHANGED
package/dist/infoService.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { MidwayInformationService, IMidwayContainer, MidwayConfigService, MidwayEnvironmentService } from '@midwayjs/core';
|
|
2
|
-
import { InfoValueType, TypeInfo } from './interface';
|
|
2
|
+
import { InfoType, InfoValueType, TypeInfo } from './interface';
|
|
3
3
|
export declare class InfoService {
|
|
4
4
|
midwayInformationService: MidwayInformationService;
|
|
5
5
|
configService: MidwayConfigService;
|
|
6
6
|
environment: MidwayEnvironmentService;
|
|
7
|
-
titleConfig:
|
|
7
|
+
titleConfig: string;
|
|
8
8
|
defaultHiddenKey: string[];
|
|
9
|
+
ignoreKey: string[];
|
|
9
10
|
secretMatchList: Array<any>;
|
|
10
11
|
container: IMidwayContainer;
|
|
11
12
|
init(): Promise<void>;
|
|
12
|
-
info(infoValueType?: InfoValueType): string |
|
|
13
|
+
info(infoValueType?: InfoValueType): string | {
|
|
14
|
+
type: string;
|
|
15
|
+
info: {};
|
|
16
|
+
}[];
|
|
13
17
|
projectInfo(): TypeInfo;
|
|
14
18
|
systemInfo(): TypeInfo;
|
|
15
19
|
resourceOccupationInfo(): TypeInfo;
|
|
@@ -19,14 +23,14 @@ export declare class InfoService {
|
|
|
19
23
|
networkInfo(): TypeInfo;
|
|
20
24
|
dependenciesInfo(): TypeInfo;
|
|
21
25
|
midwayService(): {
|
|
22
|
-
type:
|
|
26
|
+
type: InfoType;
|
|
23
27
|
info: {};
|
|
24
28
|
};
|
|
25
29
|
midwayConfig(): {
|
|
26
|
-
type:
|
|
30
|
+
type: InfoType;
|
|
27
31
|
info: {};
|
|
28
32
|
};
|
|
29
|
-
protected filterSecretContent(key:
|
|
33
|
+
protected filterSecretContent(key: string, value: any): any;
|
|
30
34
|
protected safeJson(value: any): string;
|
|
31
35
|
}
|
|
32
36
|
//# sourceMappingURL=infoService.d.ts.map
|
package/dist/infoService.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.InfoService = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const core_2 = require("@midwayjs/core");
|
|
15
|
+
const interface_1 = require("./interface");
|
|
15
16
|
const utils_1 = require("./utils");
|
|
16
17
|
const os_1 = require("os");
|
|
17
18
|
const path_1 = require("path");
|
|
@@ -23,25 +24,35 @@ let InfoService = class InfoService {
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
info(infoValueType) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const allInfo = [];
|
|
28
|
+
allInfo.push(this.projectInfo());
|
|
29
|
+
allInfo.push(this.systemInfo());
|
|
30
|
+
allInfo.push(this.resourceOccupationInfo());
|
|
31
|
+
allInfo.push(this.softwareInfo());
|
|
32
|
+
allInfo.push(this.midwayConfig());
|
|
33
|
+
allInfo.push(this.midwayService());
|
|
34
|
+
allInfo.push(this.timeInfo());
|
|
35
|
+
allInfo.push(this.envInfo());
|
|
36
|
+
allInfo.push(this.dependenciesInfo());
|
|
37
|
+
allInfo.push(this.networkInfo());
|
|
38
|
+
// 过滤自定义隐藏的key
|
|
39
|
+
const newInfo = allInfo.map(({ type, info }) => {
|
|
40
|
+
const infoKeys = Object.keys(info);
|
|
41
|
+
const keys = infoKeys.filter(k => !this.ignoreKey.includes(k));
|
|
42
|
+
const infoByIgnore = {};
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
infoByIgnore[key] = info[key];
|
|
45
|
+
}
|
|
46
|
+
return { type, info: infoByIgnore };
|
|
47
|
+
});
|
|
37
48
|
if (infoValueType === 'html') {
|
|
38
|
-
return (0, utils_1.renderToHtml)(
|
|
49
|
+
return (0, utils_1.renderToHtml)(newInfo, this.titleConfig);
|
|
39
50
|
}
|
|
40
|
-
return
|
|
51
|
+
return newInfo;
|
|
41
52
|
}
|
|
42
53
|
projectInfo() {
|
|
43
54
|
return {
|
|
44
|
-
type:
|
|
55
|
+
type: interface_1.InfoType.PROJECT,
|
|
45
56
|
info: {
|
|
46
57
|
Project: this.midwayInformationService.getProjectName(),
|
|
47
58
|
AppDir: this.midwayInformationService.getAppDir(),
|
|
@@ -54,7 +65,7 @@ let InfoService = class InfoService {
|
|
|
54
65
|
systemInfo() {
|
|
55
66
|
const _platform = process.platform;
|
|
56
67
|
return {
|
|
57
|
-
type:
|
|
68
|
+
type: interface_1.InfoType.SYSTEM,
|
|
58
69
|
info: {
|
|
59
70
|
Platform: _platform === 'win32' ? 'Windows' : _platform,
|
|
60
71
|
Node: process.versions.node,
|
|
@@ -72,7 +83,7 @@ let InfoService = class InfoService {
|
|
|
72
83
|
const memory = process.memoryUsage();
|
|
73
84
|
const cpu = (0, os_1.cpus)();
|
|
74
85
|
return {
|
|
75
|
-
type:
|
|
86
|
+
type: interface_1.InfoType.MEMORY_CPU,
|
|
76
87
|
info: {
|
|
77
88
|
'Memory Total Occupy': (0, utils_1.bitToMB)(memory.rss),
|
|
78
89
|
'Heap Total Occupy': (0, utils_1.bitToMB)(memory.heapTotal),
|
|
@@ -110,7 +121,7 @@ let InfoService = class InfoService {
|
|
|
110
121
|
}
|
|
111
122
|
}
|
|
112
123
|
return {
|
|
113
|
-
type:
|
|
124
|
+
type: interface_1.InfoType.SOFTWARE,
|
|
114
125
|
info,
|
|
115
126
|
};
|
|
116
127
|
}
|
|
@@ -120,14 +131,14 @@ let InfoService = class InfoService {
|
|
|
120
131
|
env[envName] = this.filterSecretContent(envName, process.env[envName]);
|
|
121
132
|
});
|
|
122
133
|
return {
|
|
123
|
-
type:
|
|
134
|
+
type: interface_1.InfoType.ENVIRONMENT_VARIABLE,
|
|
124
135
|
info: env,
|
|
125
136
|
};
|
|
126
137
|
}
|
|
127
138
|
timeInfo() {
|
|
128
139
|
const t = new Date().toString().split(' ');
|
|
129
140
|
return {
|
|
130
|
-
type:
|
|
141
|
+
type: interface_1.InfoType.TIME,
|
|
131
142
|
info: {
|
|
132
143
|
Current: Date.now(),
|
|
133
144
|
Uptime: (0, os_1.uptime)(),
|
|
@@ -164,7 +175,7 @@ let InfoService = class InfoService {
|
|
|
164
175
|
.join(' / ');
|
|
165
176
|
});
|
|
166
177
|
return {
|
|
167
|
-
type:
|
|
178
|
+
type: interface_1.InfoType.NETWORK,
|
|
168
179
|
info,
|
|
169
180
|
};
|
|
170
181
|
}
|
|
@@ -177,7 +188,7 @@ let InfoService = class InfoService {
|
|
|
177
188
|
info[modName] = `${modInfo.version || 'Not Found'}(${dependencies[modName]})`;
|
|
178
189
|
});
|
|
179
190
|
return {
|
|
180
|
-
type:
|
|
191
|
+
type: interface_1.InfoType.DEPENDENCIES,
|
|
181
192
|
info,
|
|
182
193
|
};
|
|
183
194
|
}
|
|
@@ -191,7 +202,7 @@ let InfoService = class InfoService {
|
|
|
191
202
|
}
|
|
192
203
|
}
|
|
193
204
|
return {
|
|
194
|
-
type:
|
|
205
|
+
type: interface_1.InfoType.MIDWAY_SERVICE,
|
|
195
206
|
info,
|
|
196
207
|
};
|
|
197
208
|
}
|
|
@@ -202,7 +213,7 @@ let InfoService = class InfoService {
|
|
|
202
213
|
info[key] = this.safeJson(this.filterSecretContent(key, config[key]));
|
|
203
214
|
});
|
|
204
215
|
return {
|
|
205
|
-
type:
|
|
216
|
+
type: interface_1.InfoType.MIDWAY_CONFIG,
|
|
206
217
|
info,
|
|
207
218
|
};
|
|
208
219
|
}
|
|
@@ -267,12 +278,16 @@ __decorate([
|
|
|
267
278
|
], InfoService.prototype, "environment", void 0);
|
|
268
279
|
__decorate([
|
|
269
280
|
(0, core_1.Config)('info.title'),
|
|
270
|
-
__metadata("design:type",
|
|
281
|
+
__metadata("design:type", String)
|
|
271
282
|
], InfoService.prototype, "titleConfig", void 0);
|
|
272
283
|
__decorate([
|
|
273
284
|
(0, core_1.Config)('info.hiddenKey'),
|
|
274
285
|
__metadata("design:type", Array)
|
|
275
286
|
], InfoService.prototype, "defaultHiddenKey", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
(0, core_1.Config)('info.ignoreKey'),
|
|
289
|
+
__metadata("design:type", Array)
|
|
290
|
+
], InfoService.prototype, "ignoreKey", void 0);
|
|
276
291
|
__decorate([
|
|
277
292
|
(0, core_1.ApplicationContext)(),
|
|
278
293
|
__metadata("design:type", Object)
|
package/dist/interface.d.ts
CHANGED
|
@@ -10,5 +10,19 @@ export interface InfoConfigOptions {
|
|
|
10
10
|
title: string;
|
|
11
11
|
infoPath: string;
|
|
12
12
|
hiddenKey: Array<string>;
|
|
13
|
+
ignoreKey: Array<string>;
|
|
14
|
+
}
|
|
15
|
+
export declare enum InfoType {
|
|
16
|
+
PROJECT = "Project",
|
|
17
|
+
SYSTEM = "System",
|
|
18
|
+
MEMORY_CPU = "Memory & CPU",
|
|
19
|
+
SOFTWARE = "Software",
|
|
20
|
+
ENVIRONMENT_VARIABLE = "Environment Variable",
|
|
21
|
+
TIME = "Time",
|
|
22
|
+
NETWORK = "Network",
|
|
23
|
+
RESOURCE = "Resource",
|
|
24
|
+
DEPENDENCIES = "Dependencies",
|
|
25
|
+
MIDWAY_SERVICE = "Midway Service",
|
|
26
|
+
MIDWAY_CONFIG = "Midway Config"
|
|
13
27
|
}
|
|
14
28
|
//# sourceMappingURL=interface.d.ts.map
|
package/dist/interface.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultHiddenKey = void 0;
|
|
3
|
+
exports.InfoType = exports.DefaultHiddenKey = void 0;
|
|
4
4
|
exports.DefaultHiddenKey = ['keys', '*key', '*token', '*secret*', 'pass*'];
|
|
5
|
+
var InfoType;
|
|
6
|
+
(function (InfoType) {
|
|
7
|
+
InfoType["PROJECT"] = "Project";
|
|
8
|
+
InfoType["SYSTEM"] = "System";
|
|
9
|
+
InfoType["MEMORY_CPU"] = "Memory & CPU";
|
|
10
|
+
InfoType["SOFTWARE"] = "Software";
|
|
11
|
+
InfoType["ENVIRONMENT_VARIABLE"] = "Environment Variable";
|
|
12
|
+
InfoType["TIME"] = "Time";
|
|
13
|
+
InfoType["NETWORK"] = "Network";
|
|
14
|
+
InfoType["RESOURCE"] = "Resource";
|
|
15
|
+
InfoType["DEPENDENCIES"] = "Dependencies";
|
|
16
|
+
InfoType["MIDWAY_SERVICE"] = "Midway Service";
|
|
17
|
+
InfoType["MIDWAY_CONFIG"] = "Midway Config";
|
|
18
|
+
})(InfoType || (exports.InfoType = InfoType = {}));
|
|
5
19
|
//# sourceMappingURL=interface.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InfoService } from '../infoService';
|
|
2
2
|
export declare class InfoMiddleware {
|
|
3
|
-
protected infoPath:
|
|
3
|
+
protected infoPath: string;
|
|
4
4
|
protected infoService: InfoService;
|
|
5
5
|
resolve(app: any): ((req: any, res: any, next: any) => Promise<void>) | ((ctx: any, next: any) => Promise<any>);
|
|
6
6
|
static getName(): string;
|
|
@@ -43,7 +43,7 @@ let InfoMiddleware = class InfoMiddleware {
|
|
|
43
43
|
exports.InfoMiddleware = InfoMiddleware;
|
|
44
44
|
__decorate([
|
|
45
45
|
(0, core_1.Config)('info.infoPath'),
|
|
46
|
-
__metadata("design:type",
|
|
46
|
+
__metadata("design:type", String)
|
|
47
47
|
], InfoMiddleware.prototype, "infoPath", void 0);
|
|
48
48
|
__decorate([
|
|
49
49
|
(0, core_1.Inject)(),
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypeInfo } from './interface';
|
|
2
2
|
export declare function safeRequire(mod: string, defaultValue?: any): any;
|
|
3
3
|
export declare function bitToMB(bit: number): string;
|
|
4
|
-
export declare function renderToHtml(infoList: TypeInfo[], title:
|
|
4
|
+
export declare function renderToHtml(infoList: TypeInfo[], title: string): string;
|
|
5
5
|
export declare function safeContent(value?: string): string;
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/info",
|
|
3
3
|
"description": "midway info",
|
|
4
|
-
"version": "4.0.0-
|
|
4
|
+
"version": "4.0.0-beta.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"picomatch": "2.3.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@midwayjs/core": "^4.0.0-
|
|
17
|
-
"@midwayjs/express": "^4.0.0-
|
|
18
|
-
"@midwayjs/koa": "^4.0.0-
|
|
19
|
-
"@midwayjs/mock": "^4.0.0-
|
|
16
|
+
"@midwayjs/core": "^4.0.0-beta.2",
|
|
17
|
+
"@midwayjs/express": "^4.0.0-beta.2",
|
|
18
|
+
"@midwayjs/koa": "^4.0.0-beta.2",
|
|
19
|
+
"@midwayjs/mock": "^4.0.0-beta.2"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"midway"
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"lint": "mwts check"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">=20"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
38
|
"url": "https://github.com/midwayjs/midway.git"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "53bfef4c5279da5f09025e4610bdbf64f94f60bd"
|
|
41
41
|
}
|