@strapi/logger 0.0.0-next.fc231041206e6f3999b094160cfa05db2892ad54 → 0.0.0-next.fc9d26d995624dc886b29f563e1de655d47e6609
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/LICENSE +18 -3
- package/dist/configs/output-file-configuration.d.ts +2 -2
- package/dist/configs/output-file-configuration.d.ts.map +1 -1
- package/dist/formats/detailed-log.d.ts +7 -0
- package/dist/formats/detailed-log.d.ts.map +1 -0
- package/dist/formats/index.d.ts +1 -0
- package/dist/formats/index.d.ts.map +1 -1
- package/dist/index.js +116 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/LICENSE
CHANGED
|
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
|
|
|
2
2
|
|
|
3
3
|
Portions of the Strapi software are licensed as follows:
|
|
4
4
|
|
|
5
|
-
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
|
|
6
|
+
|
|
7
|
+
Enterprise License
|
|
8
|
+
|
|
9
|
+
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
|
|
10
|
+
https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
|
|
11
|
+
represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
|
|
12
|
+
agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
|
|
13
|
+
Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
|
|
14
|
+
|
|
15
|
+
BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
|
|
16
|
+
IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
|
|
17
|
+
HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
|
|
18
|
+
THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
|
|
19
|
+
IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
|
|
6
20
|
|
|
7
21
|
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
22
|
|
|
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
|
|
|
18
32
|
The above copyright notice and this permission notice shall be included in all
|
|
19
33
|
copies or substantial portions of the Software.
|
|
20
34
|
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
36
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
37
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoggerOptions } from 'winston';
|
|
2
|
-
declare const _default: (filename: string) => LoggerOptions;
|
|
1
|
+
import { transports, LoggerOptions } from 'winston';
|
|
2
|
+
declare const _default: (filename: string, fileTransportOptions?: transports.FileTransportOptions) => LoggerOptions;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=output-file-configuration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-file-configuration.d.ts","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"output-file-configuration.d.ts","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;mCAMxC,MAAM,yBACM,WAAW,oBAAoB,KACpD,aAAa;AAHhB,wBAkBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailed-log.d.ts","sourceRoot":"","sources":["../../src/formats/detailed-log.ts"],"names":[],"mappings":"AAEA;;;GAGG;;AACH,wBAYG"}
|
package/dist/formats/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as prettyPrint } from './pretty-print';
|
|
|
2
2
|
export type { PrettyPrintOptions } from './pretty-print';
|
|
3
3
|
export { default as levelFilter } from './level-filter';
|
|
4
4
|
export { default as excludeColors } from './exclude-colors';
|
|
5
|
+
export { default as detailedLogs } from './detailed-log';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,105 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
8
7
|
if (e) {
|
|
9
|
-
|
|
10
|
-
if (k !==
|
|
11
|
-
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
11
|
Object.defineProperty(n, k, d.get ? d : {
|
|
13
12
|
enumerable: true,
|
|
14
|
-
get: ()
|
|
13
|
+
get: function () { return e[k]; }
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
|
-
}
|
|
16
|
+
});
|
|
18
17
|
}
|
|
19
18
|
n.default = e;
|
|
20
19
|
return Object.freeze(n);
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
var winston__namespace = /*#__PURE__*/_interopNamespaceDefault(winston);
|
|
23
|
+
|
|
23
24
|
const LEVELS = winston.config.npm.levels;
|
|
24
|
-
const LEVEL_LABEL =
|
|
25
|
+
const LEVEL_LABEL = 'silly';
|
|
25
26
|
LEVELS[LEVEL_LABEL];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
const logErrors = winston.format((info)=>{
|
|
29
|
+
if (info instanceof Error) {
|
|
30
|
+
return {
|
|
31
|
+
...info,
|
|
32
|
+
message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return info;
|
|
32
36
|
});
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const excludeColors = winston.format.printf(({ message }) => {
|
|
59
|
-
if (typeof message !== "string") {
|
|
60
|
-
return message;
|
|
61
|
-
}
|
|
62
|
-
return message.replace(
|
|
63
|
-
// eslint-disable-next-line no-control-regex
|
|
64
|
-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
65
|
-
""
|
|
66
|
-
);
|
|
37
|
+
|
|
38
|
+
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
39
|
+
/**
|
|
40
|
+
* Create a pretty print formatter for a winston logger
|
|
41
|
+
* @param options
|
|
42
|
+
*/ var prettyPrint = ((options = {})=>{
|
|
43
|
+
const { timestamps = true, colors = true } = options;
|
|
44
|
+
const handlers = [];
|
|
45
|
+
if (timestamps) {
|
|
46
|
+
handlers.push(winston.format.timestamp({
|
|
47
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
if (colors) {
|
|
51
|
+
handlers.push(winston.format.colorize());
|
|
52
|
+
}
|
|
53
|
+
handlers.push(logErrors());
|
|
54
|
+
handlers.push(winston.format.printf(({ level, message, timestamp })=>{
|
|
55
|
+
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
56
|
+
}));
|
|
57
|
+
return winston.format.combine(...handlers);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
var levelFilter = ((...levels)=>{
|
|
61
|
+
return winston.format((info)=>levels.some((level)=>info.level.includes(level)) ? info : false)();
|
|
67
62
|
});
|
|
68
|
-
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This will remove the chalk color codes from the message provided.
|
|
66
|
+
* It's used to log plain text in the log file
|
|
67
|
+
*/ var excludeColors = winston.format.printf(({ message })=>{
|
|
68
|
+
if (typeof message !== 'string') {
|
|
69
|
+
return message;
|
|
70
|
+
}
|
|
71
|
+
return message.replace(// eslint-disable-next-line no-control-regex
|
|
72
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* This will remove the chalk color codes from the message provided.
|
|
77
|
+
* It's used to log plain text in the log file
|
|
78
|
+
*/ var detailedLog = winston.format.printf(({ message, level, timestamp })=>{
|
|
79
|
+
if (typeof message !== 'string') {
|
|
80
|
+
return message;
|
|
81
|
+
}
|
|
82
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
83
|
+
return newMessage.replace(// eslint-disable-next-line no-control-regex
|
|
84
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
69
88
|
__proto__: null,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
detailedLogs: detailedLog,
|
|
90
|
+
excludeColors: excludeColors,
|
|
91
|
+
levelFilter: levelFilter,
|
|
92
|
+
prettyPrint: prettyPrint
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
var defaultConfiguration = (()=>{
|
|
96
|
+
return {
|
|
97
|
+
level: LEVEL_LABEL,
|
|
98
|
+
levels: LEVELS,
|
|
99
|
+
format: prettyPrint(),
|
|
100
|
+
transports: [
|
|
101
|
+
new winston.transports.Console()
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
|
|
107
|
+
return {
|
|
108
|
+
level: LEVEL_LABEL,
|
|
109
|
+
levels: LEVELS,
|
|
110
|
+
format: prettyPrint(),
|
|
111
|
+
transports: [
|
|
112
|
+
new winston.transports.Console(),
|
|
113
|
+
new winston.transports.File({
|
|
114
|
+
level: 'error',
|
|
115
|
+
filename,
|
|
116
|
+
format: excludeColors,
|
|
117
|
+
...fileTransportOptions
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
94
124
|
__proto__: null,
|
|
95
125
|
createDefaultConfiguration: defaultConfiguration,
|
|
96
126
|
createOutputFileConfiguration: outputFileConfiguration
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const createLogger = (userConfiguration = {})=>{
|
|
130
|
+
const configuration = defaultConfiguration();
|
|
131
|
+
Object.assign(configuration, userConfiguration);
|
|
132
|
+
return winston__namespace.createLogger(configuration);
|
|
102
133
|
};
|
|
134
|
+
|
|
103
135
|
exports.winston = winston__namespace;
|
|
104
136
|
exports.configs = index;
|
|
105
137
|
exports.createLogger = createLogger;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (filename: string): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/formats/detailed-log.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message, level, timestamp }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n const newMessage = `[${timestamp as string}] ${level}: ${message as string}`;\n\n return newMessage.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (\n filename: string,\n fileTransportOptions: transports.FileTransportOptions = {}\n): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({\n level: 'error',\n filename,\n format: excludeColors,\n ...fileTransportOptions,\n }),\n ],\n };\n};\n","import * as winston from 'winston';\nimport * as configs from './configs';\n\nexport * as formats from './formats';\n\nexport type Logger = winston.Logger;\n\nconst createLogger = (userConfiguration: winston.LoggerOptions = {}): winston.Logger => {\n const configuration = configs.createDefaultConfiguration();\n\n Object.assign(configuration, userConfiguration);\n\n return winston.createLogger(configuration);\n};\n\nexport { createLogger, winston, configs };\n"],"names":["LEVELS","config","npm","levels","LEVEL_LABEL","logErrors","format","info","Error","message","stack","defaultTimestampFormat","options","timestamps","colors","handlers","push","timestamp","colorize","printf","level","combine","some","includes","replace","newMessage","prettyPrint","transports","Console","filename","fileTransportOptions","File","excludeColors","createLogger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AAAA,EAAAA;QACRC,UAAY,EAAA;AAAC,YAAA,IAAIA,mBAAWC,OAAO;AAAG;AACxC,KAAA;AACF,CAAA;;ACNA,8BAAe,CAAA,CACbC,QACAC,EAAAA,oBAAAA,GAAwD,EAAE,GAAA;IAE1D,OAAO;QACLV,KAAOhB,EAAAA,WAAAA;QACPD,MAAQH,EAAAA,MAAAA;QACRM,MAAQoB,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AACV,YAAA,IAAIA,mBAAWC,OAAO,EAAA;YACtB,IAAID,kBAAAA,CAAWI,IAAI,CAAC;gBAClBX,KAAO,EAAA,OAAA;AACPS,gBAAAA,QAAAA;gBACAvB,MAAQ0B,EAAAA,aAAAA;AACR,gBAAA,GAAGF;AACL,aAAA;AACD;AACH,KAAA;AACF,CAAA;;;;;;;;AChBA,MAAMG,YAAe,GAAA,CAACC,iBAA2C,GAAA,EAAE,GAAA;IACjE,MAAMC,aAAAA,GAAgBC,oBAAkC,EAAA;IAExDC,MAAOC,CAAAA,MAAM,CAACH,aAAeD,EAAAA,iBAAAA,CAAAA;IAE7B,OAAOK,kBAAAA,CAAQN,YAAY,CAACE,aAAAA,CAAAA;AAC9B;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,89 +1,117 @@
|
|
|
1
|
-
import * as winston from
|
|
2
|
-
import { config, format, transports } from
|
|
1
|
+
import * as winston from 'winston';
|
|
2
|
+
import { config, format, transports } from 'winston';
|
|
3
|
+
export { winston };
|
|
4
|
+
|
|
3
5
|
const LEVELS = config.npm.levels;
|
|
4
|
-
const LEVEL_LABEL =
|
|
6
|
+
const LEVEL_LABEL = 'silly';
|
|
5
7
|
LEVELS[LEVEL_LABEL];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
const logErrors = format((info)=>{
|
|
10
|
+
if (info instanceof Error) {
|
|
11
|
+
return {
|
|
12
|
+
...info,
|
|
13
|
+
message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return info;
|
|
12
17
|
});
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const excludeColors = format.printf(({ message }) => {
|
|
39
|
-
if (typeof message !== "string") {
|
|
40
|
-
return message;
|
|
41
|
-
}
|
|
42
|
-
return message.replace(
|
|
43
|
-
// eslint-disable-next-line no-control-regex
|
|
44
|
-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
45
|
-
""
|
|
46
|
-
);
|
|
18
|
+
|
|
19
|
+
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
20
|
+
/**
|
|
21
|
+
* Create a pretty print formatter for a winston logger
|
|
22
|
+
* @param options
|
|
23
|
+
*/ var prettyPrint = ((options = {})=>{
|
|
24
|
+
const { timestamps = true, colors = true } = options;
|
|
25
|
+
const handlers = [];
|
|
26
|
+
if (timestamps) {
|
|
27
|
+
handlers.push(format.timestamp({
|
|
28
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
if (colors) {
|
|
32
|
+
handlers.push(format.colorize());
|
|
33
|
+
}
|
|
34
|
+
handlers.push(logErrors());
|
|
35
|
+
handlers.push(format.printf(({ level, message, timestamp })=>{
|
|
36
|
+
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
37
|
+
}));
|
|
38
|
+
return format.combine(...handlers);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var levelFilter = ((...levels)=>{
|
|
42
|
+
return format((info)=>levels.some((level)=>info.level.includes(level)) ? info : false)();
|
|
47
43
|
});
|
|
48
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This will remove the chalk color codes from the message provided.
|
|
47
|
+
* It's used to log plain text in the log file
|
|
48
|
+
*/ var excludeColors = format.printf(({ message })=>{
|
|
49
|
+
if (typeof message !== 'string') {
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
return message.replace(// eslint-disable-next-line no-control-regex
|
|
53
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* This will remove the chalk color codes from the message provided.
|
|
58
|
+
* It's used to log plain text in the log file
|
|
59
|
+
*/ var detailedLog = format.printf(({ message, level, timestamp })=>{
|
|
60
|
+
if (typeof message !== 'string') {
|
|
61
|
+
return message;
|
|
62
|
+
}
|
|
63
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
64
|
+
return newMessage.replace(// eslint-disable-next-line no-control-regex
|
|
65
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
49
69
|
__proto__: null,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
detailedLogs: detailedLog,
|
|
71
|
+
excludeColors: excludeColors,
|
|
72
|
+
levelFilter: levelFilter,
|
|
73
|
+
prettyPrint: prettyPrint
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
var defaultConfiguration = (()=>{
|
|
77
|
+
return {
|
|
78
|
+
level: LEVEL_LABEL,
|
|
79
|
+
levels: LEVELS,
|
|
80
|
+
format: prettyPrint(),
|
|
81
|
+
transports: [
|
|
82
|
+
new transports.Console()
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
|
|
88
|
+
return {
|
|
89
|
+
level: LEVEL_LABEL,
|
|
90
|
+
levels: LEVELS,
|
|
91
|
+
format: prettyPrint(),
|
|
92
|
+
transports: [
|
|
93
|
+
new transports.Console(),
|
|
94
|
+
new transports.File({
|
|
95
|
+
level: 'error',
|
|
96
|
+
filename,
|
|
97
|
+
format: excludeColors,
|
|
98
|
+
...fileTransportOptions
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
74
105
|
__proto__: null,
|
|
75
106
|
createDefaultConfiguration: defaultConfiguration,
|
|
76
107
|
createOutputFileConfiguration: outputFileConfiguration
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
index as configs,
|
|
85
|
-
createLogger,
|
|
86
|
-
index$1 as formats,
|
|
87
|
-
winston
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const createLogger = (userConfiguration = {})=>{
|
|
111
|
+
const configuration = defaultConfiguration();
|
|
112
|
+
Object.assign(configuration, userConfiguration);
|
|
113
|
+
return winston.createLogger(configuration);
|
|
88
114
|
};
|
|
115
|
+
|
|
116
|
+
export { index as configs, createLogger, index$1 as formats };
|
|
89
117
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (filename: string): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/formats/detailed-log.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message, level, timestamp }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n const newMessage = `[${timestamp as string}] ${level}: ${message as string}`;\n\n return newMessage.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (\n filename: string,\n fileTransportOptions: transports.FileTransportOptions = {}\n): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({\n level: 'error',\n filename,\n format: excludeColors,\n ...fileTransportOptions,\n }),\n ],\n };\n};\n","import * as winston from 'winston';\nimport * as configs from './configs';\n\nexport * as formats from './formats';\n\nexport type Logger = winston.Logger;\n\nconst createLogger = (userConfiguration: winston.LoggerOptions = {}): winston.Logger => {\n const configuration = configs.createDefaultConfiguration();\n\n Object.assign(configuration, userConfiguration);\n\n return winston.createLogger(configuration);\n};\n\nexport { createLogger, winston, configs };\n"],"names":["LEVELS","config","npm","levels","LEVEL_LABEL","logErrors","format","info","Error","message","stack","defaultTimestampFormat","options","timestamps","colors","handlers","push","timestamp","colorize","printf","level","combine","some","includes","replace","newMessage","prettyPrint","transports","Console","filename","fileTransportOptions","File","excludeColors","createLogger","userConfiguration","configuration","configs","Object","assign","winston"],"mappings":";;;;AAEA,MAAMA,MAASC,GAAAA,MAAAA,CAAOC,GAAG,CAACC,MAAM;AAChC,MAAMC,WAAc,GAAA,OAAA;AACNJ,MAAM,CAACI,WAAY;;ACFjC,MAAMC,SAAAA,GAAgCC,OAAO,CAACC,IAAAA,GAAAA;AAC5C,IAAA,IAAIA,gBAAgBC,KAAO,EAAA;QACzB,OAAO;AAAE,YAAA,GAAGD,IAAI;AAAEE,YAAAA,OAAAA,EAAS,CAAC,EAAEF,IAAAA,CAAKE,OAAO,CAAW,EAAEF,KAAKG,KAAK,GAAG,CAAC,EAAE,EAAEH,IAAKG,C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A;AACR,gBAAA,GAAGF;AACL,aAAA;AACD;AACH,KAAA;AACF,CAAA;;;;;;;;AChBA,MAAMG,YAAe,GAAA,CAACC,iBAA2C,GAAA,EAAE,GAAA;IACjE,MAAMC,aAAAA,GAAgBC,oBAAkC,EAAA;IAExDC,MAAOC,CAAAA,MAAM,CAACH,aAAeD,EAAAA,iBAAAA,CAAAA;IAE7B,OAAOK,OAAAA,CAAQN,YAAY,CAACE,aAAAA,CAAAA;AAC9B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/logger",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.fc9d26d995624dc886b29f563e1de655d47e6609",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -28,27 +28,27 @@
|
|
|
28
28
|
"source": "./src/index.ts",
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"files": [
|
|
31
|
-
"
|
|
31
|
+
"dist/"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
34
|
+
"build": "run -T npm-run-all clean --parallel build:code build:types",
|
|
35
|
+
"build:code": "run -T rollup -c",
|
|
36
|
+
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
35
37
|
"clean": "run -T rimraf ./dist",
|
|
36
38
|
"lint": "run -T eslint .",
|
|
37
39
|
"test:ts": "run -T tsc --noEmit",
|
|
38
|
-
"watch": "
|
|
40
|
+
"watch": "run -T rollup -c -w"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"lodash": "4.17.21",
|
|
42
44
|
"winston": "3.10.0"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"tsconfig": "0.0.0-next.fc231041206e6f3999b094160cfa05db2892ad54"
|
|
47
|
+
"eslint-config-custom": "0.0.0-next.fc9d26d995624dc886b29f563e1de655d47e6609",
|
|
48
|
+
"tsconfig": "0.0.0-next.fc9d26d995624dc886b29f563e1de655d47e6609"
|
|
48
49
|
},
|
|
49
50
|
"engines": {
|
|
50
|
-
"node": ">=18.0.0 <=
|
|
51
|
+
"node": ">=18.0.0 <=22.x.x",
|
|
51
52
|
"npm": ">=6.0.0"
|
|
52
|
-
}
|
|
53
|
-
"gitHead": "fc231041206e6f3999b094160cfa05db2892ad54"
|
|
53
|
+
}
|
|
54
54
|
}
|