@midwayjs/info 3.19.2 → 4.0.0-alpha.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/dist/config.default.js +0 -1
- package/dist/configuration.js +2 -2
- package/dist/infoService.d.ts +6 -10
- package/dist/infoService.js +29 -45
- package/dist/interface.d.ts +0 -14
- package/dist/interface.js +1 -15
- package/dist/middleware/info.middleware.d.ts +1 -1
- package/dist/middleware/info.middleware.js +4 -4
- package/dist/utils.d.ts +1 -1
- package/package.json +8 -10
package/dist/config.default.js
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -22,11 +22,12 @@ let InfoConfiguration = class InfoConfiguration {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
exports.InfoConfiguration = InfoConfiguration;
|
|
25
26
|
__decorate([
|
|
26
27
|
(0, core_1.Inject)(),
|
|
27
28
|
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
28
29
|
], InfoConfiguration.prototype, "applicationManager", void 0);
|
|
29
|
-
InfoConfiguration = __decorate([
|
|
30
|
+
exports.InfoConfiguration = InfoConfiguration = __decorate([
|
|
30
31
|
(0, core_1.Configuration)({
|
|
31
32
|
namespace: 'info',
|
|
32
33
|
importConfigs: [
|
|
@@ -36,5 +37,4 @@ InfoConfiguration = __decorate([
|
|
|
36
37
|
],
|
|
37
38
|
})
|
|
38
39
|
], InfoConfiguration);
|
|
39
|
-
exports.InfoConfiguration = InfoConfiguration;
|
|
40
40
|
//# sourceMappingURL=configuration.js.map
|
package/dist/infoService.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { MidwayInformationService, IMidwayContainer, MidwayConfigService, MidwayEnvironmentService } from '@midwayjs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { 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: any;
|
|
8
8
|
defaultHiddenKey: string[];
|
|
9
|
-
ignoreKey: string[];
|
|
10
9
|
secretMatchList: Array<any>;
|
|
11
10
|
container: IMidwayContainer;
|
|
12
11
|
init(): Promise<void>;
|
|
13
|
-
info(infoValueType?: InfoValueType): string |
|
|
14
|
-
type: string;
|
|
15
|
-
info: {};
|
|
16
|
-
}[];
|
|
12
|
+
info(infoValueType?: InfoValueType): string | TypeInfo[];
|
|
17
13
|
projectInfo(): TypeInfo;
|
|
18
14
|
systemInfo(): TypeInfo;
|
|
19
15
|
resourceOccupationInfo(): TypeInfo;
|
|
@@ -23,14 +19,14 @@ export declare class InfoService {
|
|
|
23
19
|
networkInfo(): TypeInfo;
|
|
24
20
|
dependenciesInfo(): TypeInfo;
|
|
25
21
|
midwayService(): {
|
|
26
|
-
type:
|
|
22
|
+
type: string;
|
|
27
23
|
info: {};
|
|
28
24
|
};
|
|
29
25
|
midwayConfig(): {
|
|
30
|
-
type:
|
|
26
|
+
type: string;
|
|
31
27
|
info: {};
|
|
32
28
|
};
|
|
33
|
-
protected filterSecretContent(key:
|
|
29
|
+
protected filterSecretContent(key: any, value: any): any;
|
|
34
30
|
protected safeJson(value: any): string;
|
|
35
31
|
}
|
|
36
32
|
//# sourceMappingURL=infoService.d.ts.map
|
package/dist/infoService.js
CHANGED
|
@@ -12,7 +12,6 @@ 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");
|
|
16
15
|
const utils_1 = require("./utils");
|
|
17
16
|
const os_1 = require("os");
|
|
18
17
|
const path_1 = require("path");
|
|
@@ -24,35 +23,25 @@ let InfoService = class InfoService {
|
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
info(infoValueType) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
});
|
|
26
|
+
const info = [];
|
|
27
|
+
info.push(this.projectInfo());
|
|
28
|
+
info.push(this.systemInfo());
|
|
29
|
+
info.push(this.resourceOccupationInfo());
|
|
30
|
+
info.push(this.softwareInfo());
|
|
31
|
+
info.push(this.midwayConfig());
|
|
32
|
+
info.push(this.midwayService());
|
|
33
|
+
info.push(this.timeInfo());
|
|
34
|
+
info.push(this.envInfo());
|
|
35
|
+
info.push(this.dependenciesInfo());
|
|
36
|
+
info.push(this.networkInfo());
|
|
48
37
|
if (infoValueType === 'html') {
|
|
49
|
-
return (0, utils_1.renderToHtml)(
|
|
38
|
+
return (0, utils_1.renderToHtml)(info, this.titleConfig);
|
|
50
39
|
}
|
|
51
|
-
return
|
|
40
|
+
return info;
|
|
52
41
|
}
|
|
53
42
|
projectInfo() {
|
|
54
43
|
return {
|
|
55
|
-
type:
|
|
44
|
+
type: 'Project',
|
|
56
45
|
info: {
|
|
57
46
|
Project: this.midwayInformationService.getProjectName(),
|
|
58
47
|
AppDir: this.midwayInformationService.getAppDir(),
|
|
@@ -65,7 +54,7 @@ let InfoService = class InfoService {
|
|
|
65
54
|
systemInfo() {
|
|
66
55
|
const _platform = process.platform;
|
|
67
56
|
return {
|
|
68
|
-
type:
|
|
57
|
+
type: 'System',
|
|
69
58
|
info: {
|
|
70
59
|
Platform: _platform === 'win32' ? 'Windows' : _platform,
|
|
71
60
|
Node: process.versions.node,
|
|
@@ -83,7 +72,7 @@ let InfoService = class InfoService {
|
|
|
83
72
|
const memory = process.memoryUsage();
|
|
84
73
|
const cpu = (0, os_1.cpus)();
|
|
85
74
|
return {
|
|
86
|
-
type:
|
|
75
|
+
type: 'Memory & CPU',
|
|
87
76
|
info: {
|
|
88
77
|
'Memory Total Occupy': (0, utils_1.bitToMB)(memory.rss),
|
|
89
78
|
'Heap Total Occupy': (0, utils_1.bitToMB)(memory.heapTotal),
|
|
@@ -121,7 +110,7 @@ let InfoService = class InfoService {
|
|
|
121
110
|
}
|
|
122
111
|
}
|
|
123
112
|
return {
|
|
124
|
-
type:
|
|
113
|
+
type: 'Software',
|
|
125
114
|
info,
|
|
126
115
|
};
|
|
127
116
|
}
|
|
@@ -131,14 +120,14 @@ let InfoService = class InfoService {
|
|
|
131
120
|
env[envName] = this.filterSecretContent(envName, process.env[envName]);
|
|
132
121
|
});
|
|
133
122
|
return {
|
|
134
|
-
type:
|
|
123
|
+
type: 'Environment Variable',
|
|
135
124
|
info: env,
|
|
136
125
|
};
|
|
137
126
|
}
|
|
138
127
|
timeInfo() {
|
|
139
128
|
const t = new Date().toString().split(' ');
|
|
140
129
|
return {
|
|
141
|
-
type:
|
|
130
|
+
type: 'Time',
|
|
142
131
|
info: {
|
|
143
132
|
Current: Date.now(),
|
|
144
133
|
Uptime: (0, os_1.uptime)(),
|
|
@@ -175,7 +164,7 @@ let InfoService = class InfoService {
|
|
|
175
164
|
.join(' / ');
|
|
176
165
|
});
|
|
177
166
|
return {
|
|
178
|
-
type:
|
|
167
|
+
type: 'Network',
|
|
179
168
|
info,
|
|
180
169
|
};
|
|
181
170
|
}
|
|
@@ -188,22 +177,21 @@ let InfoService = class InfoService {
|
|
|
188
177
|
info[modName] = `${modInfo.version || 'Not Found'}(${dependencies[modName]})`;
|
|
189
178
|
});
|
|
190
179
|
return {
|
|
191
|
-
type:
|
|
180
|
+
type: 'Dependencies',
|
|
192
181
|
info,
|
|
193
182
|
};
|
|
194
183
|
}
|
|
195
184
|
midwayService() {
|
|
196
|
-
var _a;
|
|
197
185
|
const info = {};
|
|
198
|
-
if (
|
|
186
|
+
if (this.container?.registry) {
|
|
199
187
|
for (const item of this.container.registry) {
|
|
200
188
|
const [key, value] = item;
|
|
201
|
-
const name = value ?
|
|
202
|
-
info[key] = `${
|
|
189
|
+
const name = value ? value?.name || value : typeof value;
|
|
190
|
+
info[key] = `${value?.namespace ? `${value?.namespace}:` : ''}${name}${value?.scope ? ` [${value?.scope}]` : ''}`;
|
|
203
191
|
}
|
|
204
192
|
}
|
|
205
193
|
return {
|
|
206
|
-
type:
|
|
194
|
+
type: 'Midway Service',
|
|
207
195
|
info,
|
|
208
196
|
};
|
|
209
197
|
}
|
|
@@ -214,7 +202,7 @@ let InfoService = class InfoService {
|
|
|
214
202
|
info[key] = this.safeJson(this.filterSecretContent(key, config[key]));
|
|
215
203
|
});
|
|
216
204
|
return {
|
|
217
|
-
type:
|
|
205
|
+
type: 'Midway Config',
|
|
218
206
|
info,
|
|
219
207
|
};
|
|
220
208
|
}
|
|
@@ -264,6 +252,7 @@ let InfoService = class InfoService {
|
|
|
264
252
|
return '';
|
|
265
253
|
}
|
|
266
254
|
};
|
|
255
|
+
exports.InfoService = InfoService;
|
|
267
256
|
__decorate([
|
|
268
257
|
(0, core_1.Inject)(),
|
|
269
258
|
__metadata("design:type", core_2.MidwayInformationService)
|
|
@@ -278,16 +267,12 @@ __decorate([
|
|
|
278
267
|
], InfoService.prototype, "environment", void 0);
|
|
279
268
|
__decorate([
|
|
280
269
|
(0, core_1.Config)('info.title'),
|
|
281
|
-
__metadata("design:type",
|
|
270
|
+
__metadata("design:type", Object)
|
|
282
271
|
], InfoService.prototype, "titleConfig", void 0);
|
|
283
272
|
__decorate([
|
|
284
273
|
(0, core_1.Config)('info.hiddenKey'),
|
|
285
274
|
__metadata("design:type", Array)
|
|
286
275
|
], 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);
|
|
291
276
|
__decorate([
|
|
292
277
|
(0, core_1.ApplicationContext)(),
|
|
293
278
|
__metadata("design:type", Object)
|
|
@@ -298,9 +283,8 @@ __decorate([
|
|
|
298
283
|
__metadata("design:paramtypes", []),
|
|
299
284
|
__metadata("design:returntype", Promise)
|
|
300
285
|
], InfoService.prototype, "init", null);
|
|
301
|
-
InfoService = __decorate([
|
|
286
|
+
exports.InfoService = InfoService = __decorate([
|
|
302
287
|
(0, core_1.Provide)(),
|
|
303
288
|
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
304
289
|
], InfoService);
|
|
305
|
-
exports.InfoService = InfoService;
|
|
306
290
|
//# sourceMappingURL=infoService.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -10,19 +10,5 @@ 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"
|
|
27
13
|
}
|
|
28
14
|
//# sourceMappingURL=interface.d.ts.map
|
package/dist/interface.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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 || (exports.InfoType = {}));
|
|
19
5
|
//# 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: any;
|
|
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;
|
|
@@ -14,7 +14,7 @@ const core_1 = require("@midwayjs/core");
|
|
|
14
14
|
const infoService_1 = require("../infoService");
|
|
15
15
|
let InfoMiddleware = class InfoMiddleware {
|
|
16
16
|
resolve(app) {
|
|
17
|
-
if (
|
|
17
|
+
if ('express' === app.getNamespace()) {
|
|
18
18
|
return async (req, res, next) => {
|
|
19
19
|
if (req.path === this.infoPath) {
|
|
20
20
|
// return html
|
|
@@ -40,16 +40,16 @@ let InfoMiddleware = class InfoMiddleware {
|
|
|
40
40
|
return 'info';
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
exports.InfoMiddleware = InfoMiddleware;
|
|
43
44
|
__decorate([
|
|
44
45
|
(0, core_1.Config)('info.infoPath'),
|
|
45
|
-
__metadata("design:type",
|
|
46
|
+
__metadata("design:type", Object)
|
|
46
47
|
], InfoMiddleware.prototype, "infoPath", void 0);
|
|
47
48
|
__decorate([
|
|
48
49
|
(0, core_1.Inject)(),
|
|
49
50
|
__metadata("design:type", infoService_1.InfoService)
|
|
50
51
|
], InfoMiddleware.prototype, "infoService", void 0);
|
|
51
|
-
InfoMiddleware = __decorate([
|
|
52
|
+
exports.InfoMiddleware = InfoMiddleware = __decorate([
|
|
52
53
|
(0, core_1.Middleware)()
|
|
53
54
|
], InfoMiddleware);
|
|
54
|
-
exports.InfoMiddleware = InfoMiddleware;
|
|
55
55
|
//# sourceMappingURL=info.middleware.js.map
|
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: any): 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
|
+
"version": "4.0.0-alpha.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -13,12 +13,10 @@
|
|
|
13
13
|
"picomatch": "2.3.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@midwayjs/core": "^
|
|
17
|
-
"@midwayjs/express": "^
|
|
18
|
-
"@midwayjs/koa": "^
|
|
19
|
-
"@midwayjs/mock": "^
|
|
20
|
-
"@midwayjs/serverless-fc-starter": "^3.19.0",
|
|
21
|
-
"@midwayjs/serverless-scf-starter": "^3.14.0"
|
|
16
|
+
"@midwayjs/core": "^4.0.0-alpha.1",
|
|
17
|
+
"@midwayjs/express": "^4.0.0-alpha.1",
|
|
18
|
+
"@midwayjs/koa": "^4.0.0-alpha.1",
|
|
19
|
+
"@midwayjs/mock": "^4.0.0-alpha.1"
|
|
22
20
|
},
|
|
23
21
|
"keywords": [
|
|
24
22
|
"midway"
|
|
@@ -27,8 +25,8 @@
|
|
|
27
25
|
"license": "MIT",
|
|
28
26
|
"scripts": {
|
|
29
27
|
"build": "tsc",
|
|
30
|
-
"test": "node
|
|
31
|
-
"cov": "node
|
|
28
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
29
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
|
|
32
30
|
"ci": "npm run test",
|
|
33
31
|
"lint": "mwts check"
|
|
34
32
|
},
|
|
@@ -39,5 +37,5 @@
|
|
|
39
37
|
"type": "git",
|
|
40
38
|
"url": "https://github.com/midwayjs/midway.git"
|
|
41
39
|
},
|
|
42
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
43
41
|
}
|