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 CHANGED
@@ -10,7 +10,7 @@ English | [简体中文](./README.zh-CN.md)
10
10
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feggjs%2Fegg.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_shield)
11
11
 
12
12
  [![Continuous Integration](https://github.com/eggjs/egg/actions/workflows/nodejs-3.x.yml/badge.svg)](https://github.com/eggjs/egg/actions?query=branch%3A3.x)
13
- [![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg)
13
+ [![codecov](https://codecov.io/gh/eggjs/egg/branch/3.x/graph/badge.svg?token=2sKMCDNkcl)](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
14
14
  [![Known Vulnerabilities](https://snyk.io/test/npm/egg/badge.svg?style=flat-square)](https://snyk.io/test/npm/egg)
15
15
  [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/eggjs?style=flat-square)](https://opencollective.com/eggjs)
16
16
 
package/README.zh-CN.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![NPM download](https://img.shields.io/npm/dm/egg.svg?style=flat-square)](https://npmjs.org/package/egg)
10
10
 
11
11
  [![Continuous Integration](https://github.com/eggjs/egg/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg/actions?query=branch%3Amaster)
12
- [![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg)
12
+ [![codecov](https://codecov.io/gh/eggjs/egg/branch/3.x/graph/badge.svg?token=2sKMCDNkcl)](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
13
13
  [![Known Vulnerabilities](https://snyk.io/test/npm/egg/badge.svg?style=flat-square)](https://snyk.io/test/npm/egg)
14
14
  [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/eggjs?style=flat-square)](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)) ignore = [ 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
- if (!hit) {
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
- return convertObject(value, ignore);
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,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "publishConfig": {
5
- "tag": "release-3.x",
5
+ "tag": "latest",
6
6
  "access": "public"
7
7
  },
8
8
  "description": "A web framework's framework for Node.js",