@abtnode/util 1.16.7 → 1.16.8-beta-0c0c5eb2
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/lib/format-context.js +7 -4
- package/lib/run-script.js +13 -1
- package/lib/url-evaluation/index.js +1 -0
- package/package.json +5 -5
package/lib/format-context.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
const omit = require('lodash/omit');
|
|
1
2
|
const get = require('lodash/get');
|
|
2
3
|
|
|
3
4
|
// Format context: https://github.com/graphql/express-graphql
|
|
4
5
|
module.exports = (ctx = {}) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// 不要更改入参的值,base case
|
|
7
|
+
// if (ctx && ctx.user) {
|
|
8
|
+
// delete ctx.user.avatar;
|
|
9
|
+
// }
|
|
10
|
+
const contextUser = omit(ctx?.user || {}, 'avatar');
|
|
8
11
|
|
|
9
12
|
const safeGet = (key, _default = '') =>
|
|
10
13
|
(typeof ctx.get === 'function' ? ctx.get(key) : get(ctx, `headers[${key}]`)) || _default;
|
|
@@ -13,7 +16,7 @@ module.exports = (ctx = {}) => {
|
|
|
13
16
|
ip: safeGet('x-real-ip', '127.0.0.1'),
|
|
14
17
|
ua: safeGet('user-agent'),
|
|
15
18
|
protocol: safeGet('x-real-protocol').replace(/:$/, '') || 'http',
|
|
16
|
-
user:
|
|
19
|
+
user: contextUser,
|
|
17
20
|
url: ctx.originalUrl,
|
|
18
21
|
query: ctx.query,
|
|
19
22
|
hostname: safeGet('x-real-hostname'),
|
package/lib/run-script.js
CHANGED
|
@@ -5,6 +5,17 @@ const which = require('which');
|
|
|
5
5
|
const stream = require('stream');
|
|
6
6
|
const spawn = require('cross-spawn');
|
|
7
7
|
|
|
8
|
+
const getDate = () => {
|
|
9
|
+
const date = new Date();
|
|
10
|
+
const year = date.getFullYear();
|
|
11
|
+
const month = `0${date.getMonth() + 1}`.slice(-2);
|
|
12
|
+
const day = `0${date.getDate()}`.slice(-2);
|
|
13
|
+
const hours = `0${date.getHours()}`.slice(-2);
|
|
14
|
+
const minutes = `0${date.getMinutes()}`.slice(-2);
|
|
15
|
+
const seconds = `0${date.getSeconds()}`.slice(-2);
|
|
16
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
17
|
+
};
|
|
18
|
+
|
|
8
19
|
class PrefixTransform extends stream.Transform {
|
|
9
20
|
constructor(prefix, state) {
|
|
10
21
|
super();
|
|
@@ -15,7 +26,8 @@ class PrefixTransform extends stream.Transform {
|
|
|
15
26
|
|
|
16
27
|
// transform all output from child process with a prefix for better readability
|
|
17
28
|
_transform(chunk, _encoding, callback) {
|
|
18
|
-
const { prefix, state } = this;
|
|
29
|
+
const { prefix: rawPrefix, state } = this;
|
|
30
|
+
const prefix = `[${getDate()}] ${rawPrefix}`;
|
|
19
31
|
const nPrefix = `\n${prefix}`;
|
|
20
32
|
const firstPrefix = state.lastIsLineBreak ? prefix : state.lastPrefix !== prefix ? '\n' : '';
|
|
21
33
|
const prefixed = `${firstPrefix}${chunk}`.replace(/\n/g, nPrefix);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.8-beta-0c0c5eb2",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.
|
|
22
|
-
"@abtnode/logger": "1.16.
|
|
23
|
-
"@blocklet/constant": "1.16.
|
|
21
|
+
"@abtnode/constant": "1.16.8-beta-0c0c5eb2",
|
|
22
|
+
"@abtnode/logger": "1.16.8-beta-0c0c5eb2",
|
|
23
|
+
"@blocklet/constant": "1.16.8-beta-0c0c5eb2",
|
|
24
24
|
"@ocap/client": "1.18.78",
|
|
25
25
|
"@ocap/mcrypto": "1.18.78",
|
|
26
26
|
"@ocap/util": "1.18.78",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"jest": "^27.5.1",
|
|
72
72
|
"unzipper": "^0.10.11"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "0d8ec3154caf670770284dbdabc61a5f4e8b205f"
|
|
75
75
|
}
|