egg 3.29.0 → 3.30.0
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/README.zh-CN.md +1 -1
- package/lib/core/utils.js +25 -6
- package/lib/egg.js +8 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -2395
- package/History.md +0 -52
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
10
10
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_shield)
|
|
11
11
|
|
|
12
12
|
[](https://github.com/eggjs/egg/actions?query=branch%3A3.x)
|
|
13
|
-
[](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
|
|
14
14
|
[](https://snyk.io/test/npm/egg)
|
|
15
15
|
[](https://opencollective.com/eggjs)
|
|
16
16
|
|
package/README.zh-CN.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://npmjs.org/package/egg)
|
|
10
10
|
|
|
11
11
|
[](https://github.com/eggjs/egg/actions?query=branch%3Amaster)
|
|
12
|
-
[](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
|
|
13
13
|
[](https://snyk.io/test/npm/egg)
|
|
14
14
|
[](https://opencollective.com/eggjs)
|
|
15
15
|
|
package/lib/core/utils.js
CHANGED
|
@@ -9,18 +9,28 @@ module.exports = {
|
|
|
9
9
|
safeParseURL,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
function convertObject(obj, ignore) {
|
|
13
|
-
if (!is.array(ignore))
|
|
12
|
+
function convertObject(obj, ignore, ignoreKeyPaths) {
|
|
13
|
+
if (!is.array(ignore)) {
|
|
14
|
+
ignore = [ ignore ];
|
|
15
|
+
}
|
|
16
|
+
if (!is.array(ignoreKeyPaths)) {
|
|
17
|
+
ignoreKeyPaths = ignoreKeyPaths ? [ ignoreKeyPaths ] : [];
|
|
18
|
+
}
|
|
19
|
+
_convertObject(obj, ignore, ignoreKeyPaths, '');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _convertObject(obj, ignore, ignoreKeyPaths, keyPath) {
|
|
14
23
|
for (const key of Object.keys(obj)) {
|
|
15
|
-
obj[key] = convertValue(key, obj[key], ignore);
|
|
24
|
+
obj[key] = convertValue(key, obj[key], ignore, ignoreKeyPaths, keyPath ? `${keyPath}.${key}` : key);
|
|
16
25
|
}
|
|
17
26
|
return obj;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
|
-
function convertValue(key, value, ignore) {
|
|
29
|
+
function convertValue(key, value, ignore, ignoreKeyPaths, keyPath) {
|
|
21
30
|
if (is.nullOrUndefined(value)) return value;
|
|
22
31
|
|
|
23
32
|
let hit = false;
|
|
33
|
+
let hitKeyPath = false;
|
|
24
34
|
for (const matchKey of ignore) {
|
|
25
35
|
if (is.string(matchKey) && matchKey === key) {
|
|
26
36
|
hit = true;
|
|
@@ -30,7 +40,13 @@ function convertValue(key, value, ignore) {
|
|
|
30
40
|
break;
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
for (const matchKeyPath of ignoreKeyPaths) {
|
|
44
|
+
if (is.string(matchKeyPath) && keyPath === matchKeyPath) {
|
|
45
|
+
hitKeyPath = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!hit && !hitKeyPath) {
|
|
34
50
|
if (is.symbol(value) || is.regExp(value)) return value.toString();
|
|
35
51
|
if (is.primitive(value) || is.array(value)) return value;
|
|
36
52
|
}
|
|
@@ -38,7 +54,10 @@ function convertValue(key, value, ignore) {
|
|
|
38
54
|
// only convert recursively when it's a plain object,
|
|
39
55
|
// o = {}
|
|
40
56
|
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
41
|
-
|
|
57
|
+
if (hitKeyPath) {
|
|
58
|
+
return '<Object>';
|
|
59
|
+
}
|
|
60
|
+
return _convertObject(value, ignore, ignoreKeyPaths, keyPath);
|
|
42
61
|
}
|
|
43
62
|
|
|
44
63
|
// support class
|
package/lib/egg.js
CHANGED
|
@@ -395,8 +395,15 @@ class EggApplication extends EggCore {
|
|
|
395
395
|
ignoreList = [];
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
+
let ignoreKeyPaths;
|
|
399
|
+
try {
|
|
400
|
+
ignoreKeyPaths = this.config.dump.ignoreKeyPaths;
|
|
401
|
+
} catch (e) {
|
|
402
|
+
ignoreKeyPaths = {};
|
|
403
|
+
}
|
|
404
|
+
|
|
398
405
|
const json = extend(true, {}, { config: this.config, plugins: this.loader.allPlugins, appInfo: this.loader.appInfo });
|
|
399
|
-
utils.convertObject(json, ignoreList);
|
|
406
|
+
utils.convertObject(json, ignoreList, ignoreKeyPaths ? Object.keys(ignoreKeyPaths) : []);
|
|
400
407
|
return {
|
|
401
408
|
config: json,
|
|
402
409
|
meta: this.loader.configMeta,
|