@verdaccio/logger 9.0.0-next-9.20 → 9.0.0-next-9.22
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/CHANGELOG.md +30 -0
- package/build/formatter.d.ts +2 -2
- package/build/formatter.js.map +1 -1
- package/build/formatter.mjs.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/levels.d.ts +7 -7
- package/build/levels.js.map +1 -1
- package/build/logger.d.ts +1 -1
- package/build/logger.js +2 -1
- package/build/logger.js.map +1 -1
- package/build/logger.mjs +2 -1
- package/build/logger.mjs.map +1 -1
- package/build/prettify.d.ts +4 -3
- package/build/prettify.js +3 -3
- package/build/prettify.js.map +1 -1
- package/build/prettify.mjs +3 -4
- package/build/prettify.mjs.map +1 -1
- package/build/transport.d.ts +1 -1
- package/build/transport.js +1 -1
- package/build/transport.js.map +1 -1
- package/build/transport.mjs +1 -1
- package/build/transport.mjs.map +1 -1
- package/build/types.d.ts +1 -1
- package/build/utils.js +1 -0
- package/build/utils.js.map +1 -1
- package/build/utils.mjs +1 -1
- package/build/utils.mjs.map +1 -1
- package/package.json +5 -5
- package/src/prettify.ts +5 -4
- package/src/transport.ts +5 -3
- package/test/prettify-onexit.spec.ts +70 -0
- package/build/_virtual/_rolldown/runtime.mjs +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @verdaccio/logger
|
|
2
2
|
|
|
3
|
+
## 9.0.0-next-9.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d3b0352: fix: harden plugin loading and logger for the ESM build
|
|
8
|
+
|
|
9
|
+
- loaders: use a real `createRequire` in both output formats (the ESM build
|
|
10
|
+
previously relied on a throwing `require` stub, so every plugin — including
|
|
11
|
+
CommonJS ones — was loaded through the `import()` fallback with interop
|
|
12
|
+
differences); report `err.message` instead of the nonexistent `err.msg`;
|
|
13
|
+
rethrow real plugin evaluation errors instead of retrying via `import()`
|
|
14
|
+
(which ran plugin side effects twice and masked the original error); support
|
|
15
|
+
ESM plugins using top-level await (`ERR_REQUIRE_ASYNC_MODULE`); resolve
|
|
16
|
+
entry points for manifest-less directory plugins; use `path.isAbsolute()`
|
|
17
|
+
so Windows paths convert to `file://` URLs correctly.
|
|
18
|
+
- logger: import `on-exit-leak-free` statically (the lazy `require` crashed
|
|
19
|
+
the ESM build when `setupOnExit` ran) and make the transport directory
|
|
20
|
+
detection immune to the `__dirname` global that `node -e`/REPL leak into
|
|
21
|
+
ES modules.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [c499c4e]
|
|
24
|
+
- @verdaccio/core@9.0.0-next-9.22
|
|
25
|
+
|
|
26
|
+
## 9.0.0-next-9.21
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [5aa8cca]
|
|
31
|
+
- @verdaccio/core@9.0.0-next-9.21
|
|
32
|
+
|
|
3
33
|
## 9.0.0-next-9.20
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/build/formatter.d.ts
CHANGED
package/build/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,eAAA,YAAY,GACtC,kBAAkB,KAAK,IAAI,iBAAiB,EAAE,MAAM;AAGtD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;CAGR,OAAO,IAAI,QAAQ,uCAAgB,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;EACJ,IAAI,KAAK,OAAO,YAAY;GAC1B,OAAO,KAAK,MAAM,CAAC;GACnB,UAAU;EACZ;EAGA,MAAM,gBAAgB,KAAK,MAAM,GAAG;EACpC,KAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;GACzB,IAAI,cAAA,SAAS,GAAG,GACd,MAAO,IAAe;EAE1B;EAEA,IAAI,OAAO,QAAQ,UAAU;GAC3B,IAAI,WAAW,SAAU,IAAe,SAAS,IAAI,GACnD,OAAO;QACF,IAAI,SACT,QAAA,GAAA,UAAA,
|
|
1
|
+
{"version":3,"file":"formatter.js","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,eAAA,YAAY,GACtC,kBAAkB,KAAK,IAAI,iBAAiB,EAAE,MAAM;AAGtD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;CAGR,OAAO,IAAI,QAAQ,uCAAgB,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;EACJ,IAAI,KAAK,OAAO,YAAY;GAC1B,OAAO,KAAK,MAAM,CAAC;GACnB,UAAU;EACZ;EAGA,MAAM,gBAAgB,KAAK,MAAM,GAAG;EACpC,KAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;GACzB,IAAI,cAAA,SAAS,GAAG,GACd,MAAO,IAAe;EAE1B;EAEA,IAAI,OAAO,QAAQ,UAAU;GAC3B,IAAI,WAAW,SAAU,IAAe,SAAS,IAAI,GACnD,OAAO;QACF,IAAI,SACT,QAAA,GAAA,UAAA,IAAA,CAAW,GAAG;GAEhB,QAAA,GAAA,UAAA,MAAA,CAAa,GAAG;EAClB;EAGA,QAAA,GAAA,UAAA,QAAA,CAAe,KAAK,KAAA,GAAW,MAAM,MAAM;CAC7C,CAAC;AACH;AAEA,SAAS,WAAW,YAAY,KAAK,KAAK,iBAAiB,WAAoB;CAC7E,MAAM,eAAe,kBAAkB,KAAK,iBAAiB,SAAS;CAEtE,MAAM,gBAAgB,YAClB,eAAA,gBAAgB,MAAM,OAAO,aAC7B,eAAA,gBAAgB,MAAM,OAAO;CACjC,IAAI,WAKF,OAAO,GAJc,eAAA,aAAa,WAAW,CAAC,cAAA,SAAS,YAAY,eAAe,CAAC,KAAA,GAAA,UAAA,MAAA,CACjF,GAAG,cAAc,GAAG,cACtB;CAMF,OAAO,GAFc,cAAA,SAAS,YAAY,eAAe,IAAI,cAAc,GAAG;AAGhF;AAEA,SAAgB,aACd,iBACA,SACA,WACQ;CACR,MAAM,EAAE,gBAAgB;CACxB,MAAM,EAAE,OAAO,KAAK,QAAQ;CAE5B,MAAM,aAAa,WADA,eAAA,eAAe,KACJ,GAAY,KAAK,KAAK,iBAAiB,SAAS;CAE9E,OAAO,cAAc,cAAA,kBAAkB,gBAAgB,MAAgB,UAAU,IAAI;AACvF"}
|
package/build/formatter.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.mjs","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,YAAY,GACtC,kBAAkB,KAAK,IAAI,iBAAiB,EAAE,MAAM;AAGtD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;CAGR,OAAO,IAAI,QAAQ,uCAAgB,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;EACJ,IAAI,KAAK,OAAO,YAAY;GAC1B,OAAO,KAAK,MAAM,CAAC;GACnB,UAAU;EACZ;EAGA,MAAM,gBAAgB,KAAK,MAAM,GAAG;EACpC,KAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;GACzB,IAAI,SAAS,GAAG,GACd,MAAO,IAAe;EAE1B;EAEA,IAAI,OAAO,QAAQ,UAAU;GAC3B,IAAI,WAAW,SAAU,IAAe,SAAS,IAAI,GACnD,OAAO;QACF,IAAI,SACT,OAAO,IAAI,GAAG;GAEhB,OAAO,MAAM,GAAG;EAClB;EAGA,OAAO,QAAQ,KAAK,KAAA,GAAW,MAAM,MAAM;CAC7C,CAAC;AACH;AAEA,SAAS,WAAW,YAAY,KAAK,KAAK,iBAAiB,WAAoB;CAC7E,MAAM,eAAe,kBAAkB,KAAK,iBAAiB,SAAS;CAEtE,MAAM,gBAAgB,YAClB,gBAAgB,MAAM,OAAO,aAC7B,gBAAgB,MAAM,OAAO;CACjC,IAAI,WAKF,OAAO,GAJc,aAAa,
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,YAAY,GACtC,kBAAkB,KAAK,IAAI,iBAAiB,EAAE,MAAM;AAGtD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;CAGR,OAAO,IAAI,QAAQ,uCAAgB,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;EACJ,IAAI,KAAK,OAAO,YAAY;GAC1B,OAAO,KAAK,MAAM,CAAC;GACnB,UAAU;EACZ;EAGA,MAAM,gBAAgB,KAAK,MAAM,GAAG;EACpC,KAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;GACzB,IAAI,SAAS,GAAG,GACd,MAAO,IAAe;EAE1B;EAEA,IAAI,OAAO,QAAQ,UAAU;GAC3B,IAAI,WAAW,SAAU,IAAe,SAAS,IAAI,GACnD,OAAO;QACF,IAAI,SACT,OAAO,IAAI,GAAG;GAEhB,OAAO,MAAM,GAAG;EAClB;EAGA,OAAO,QAAQ,KAAK,KAAA,GAAW,MAAM,MAAM;CAC7C,CAAC;AACH;AAEA,SAAS,WAAW,YAAY,KAAK,KAAK,iBAAiB,WAAoB;CAC7E,MAAM,eAAe,kBAAkB,KAAK,iBAAiB,SAAS;CAEtE,MAAM,gBAAgB,YAClB,gBAAgB,MAAM,OAAO,aAC7B,gBAAgB,MAAM,OAAO;CACjC,IAAI,WAKF,OAAO,GAJc,aAAa,WAAW,CAAC,SAAS,YAAY,eAAe,CAAC,IAAI,MACrF,GAAG,cAAc,GAAG,cACtB;CAMF,OAAO,GAFc,SAAS,YAAY,eAAe,IAAI,cAAc,GAAG;AAGhF;AAEA,SAAgB,aACd,iBACA,SACA,WACQ;CACR,MAAM,EAAE,gBAAgB;CACxB,MAAM,EAAE,OAAO,KAAK,QAAQ;CAE5B,MAAM,aAAa,WADA,eAAe,KACJ,GAAY,KAAK,KAAK,iBAAiB,SAAS;CAE9E,OAAO,cAAc,kBAAkB,gBAAgB,MAAgB,UAAU,IAAI;AACvF"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger, LoggerConfigItem } from '@verdaccio/types';
|
|
1
|
+
import type { Logger, LoggerConfigItem } from '@verdaccio/types';
|
|
2
2
|
export { createLogger, prepareSetup, willUseTransport } from './logger';
|
|
3
3
|
export type { LogPlugin, LoggerConfig } from './logger';
|
|
4
4
|
export { default as prettifyTransport, autoEnd, buildPretty, buildSafeSonicBoom } from './prettify';
|
package/build/levels.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ export type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' |
|
|
|
2
2
|
export type LevelCode = number;
|
|
3
3
|
export declare function calculateLevel(levelCode: LevelCode): LogLevel;
|
|
4
4
|
export declare const levelsColors: {
|
|
5
|
-
fatal: import(
|
|
6
|
-
error: import(
|
|
7
|
-
warn: import(
|
|
8
|
-
http: import(
|
|
9
|
-
info: import(
|
|
10
|
-
debug: import(
|
|
11
|
-
trace: import(
|
|
5
|
+
fatal: import("colorette").Color;
|
|
6
|
+
error: import("colorette").Color;
|
|
7
|
+
warn: import("colorette").Color;
|
|
8
|
+
http: import("colorette").Color;
|
|
9
|
+
info: import("colorette").Color;
|
|
10
|
+
debug: import("colorette").Color;
|
|
11
|
+
trace: import("colorette").Color;
|
|
12
12
|
};
|
|
13
13
|
declare enum ARROWS {
|
|
14
14
|
LEFT = "<--",
|
package/build/levels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"levels.js","names":[],"sources":["../src/levels.ts"],"sourcesContent":["import { black, blue, cyan, green, magenta, red, white, yellow } from 'colorette';\n\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal';\n\nexport type LevelCode = number;\n\nexport function calculateLevel(levelCode: LevelCode): LogLevel {\n switch (true) {\n case levelCode === 10:\n return 'trace';\n case levelCode === 20:\n return 'debug';\n case levelCode === 25:\n return 'http';\n case levelCode === 30:\n return 'info';\n case levelCode === 40:\n return 'warn';\n case levelCode === 50:\n return 'error';\n case levelCode === 60:\n return 'fatal';\n default:\n return 'fatal';\n }\n}\n\nexport const levelsColors = {\n fatal: red,\n error: red,\n warn: yellow,\n http: magenta,\n info: cyan,\n debug: green,\n trace: white,\n};\n\nenum ARROWS {\n LEFT = '<--',\n RIGHT = '-->',\n EQUAL = '-=-',\n NEUTRAL = '---',\n}\n\nexport const subSystemLevels = {\n color: {\n in: green(ARROWS.LEFT),\n out: yellow(ARROWS.RIGHT),\n auth: blue(ARROWS.NEUTRAL),\n fs: black(ARROWS.EQUAL),\n default: blue(ARROWS.NEUTRAL),\n },\n white: {\n in: ARROWS.LEFT,\n out: ARROWS.RIGHT,\n auth: ARROWS.NEUTRAL,\n fs: ARROWS.EQUAL,\n default: ARROWS.NEUTRAL,\n },\n};\n"],"mappings":";;AAMA,SAAgB,eAAe,WAAgC;CAC7D,QAAQ,MAAR;EACE,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,IAAa,eAAe;CAC1B,OAAO,UAAA;CACP,OAAO,UAAA;CACP,MAAM,UAAA;CACN,MAAM,UAAA;CACN,MAAM,UAAA;CACN,OAAO,UAAA;CACP,OAAO,UAAA;AACT;AASA,IAAa,kBAAkB;CAC7B,OAAO;EACL,KAAA,GAAA,UAAA,
|
|
1
|
+
{"version":3,"file":"levels.js","names":[],"sources":["../src/levels.ts"],"sourcesContent":["import { black, blue, cyan, green, magenta, red, white, yellow } from 'colorette';\n\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal';\n\nexport type LevelCode = number;\n\nexport function calculateLevel(levelCode: LevelCode): LogLevel {\n switch (true) {\n case levelCode === 10:\n return 'trace';\n case levelCode === 20:\n return 'debug';\n case levelCode === 25:\n return 'http';\n case levelCode === 30:\n return 'info';\n case levelCode === 40:\n return 'warn';\n case levelCode === 50:\n return 'error';\n case levelCode === 60:\n return 'fatal';\n default:\n return 'fatal';\n }\n}\n\nexport const levelsColors = {\n fatal: red,\n error: red,\n warn: yellow,\n http: magenta,\n info: cyan,\n debug: green,\n trace: white,\n};\n\nenum ARROWS {\n LEFT = '<--',\n RIGHT = '-->',\n EQUAL = '-=-',\n NEUTRAL = '---',\n}\n\nexport const subSystemLevels = {\n color: {\n in: green(ARROWS.LEFT),\n out: yellow(ARROWS.RIGHT),\n auth: blue(ARROWS.NEUTRAL),\n fs: black(ARROWS.EQUAL),\n default: blue(ARROWS.NEUTRAL),\n },\n white: {\n in: ARROWS.LEFT,\n out: ARROWS.RIGHT,\n auth: ARROWS.NEUTRAL,\n fs: ARROWS.EQUAL,\n default: ARROWS.NEUTRAL,\n },\n};\n"],"mappings":";;AAMA,SAAgB,eAAe,WAAgC;CAC7D,QAAQ,MAAR;EACE,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,KAAK,cAAc,IACjB,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,IAAa,eAAe;CAC1B,OAAO,UAAA;CACP,OAAO,UAAA;CACP,MAAM,UAAA;CACN,MAAM,UAAA;CACN,MAAM,UAAA;CACN,OAAO,UAAA;CACP,OAAO,UAAA;AACT;AASA,IAAa,kBAAkB;CAC7B,OAAO;EACL,KAAA,GAAA,UAAA,MAAA,CAAI,KAAiB;EACrB,MAAA,GAAA,UAAA,OAAA,CAAK,KAAmB;EACxB,OAAA,GAAA,UAAA,KAAA,CAAM,KAAmB;EACzB,KAAA,GAAA,UAAA,MAAA,CAAI,KAAkB;EACtB,UAAA,GAAA,UAAA,KAAA,CAAS,KAAmB;CAC9B;CACA,OAAO;EACL,IAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA;CACF;AACF"}
|
package/build/logger.d.ts
CHANGED
package/build/logger.js
CHANGED
|
@@ -32,7 +32,8 @@ function createLogger(options = { level: "http" }, destination, format = DEFAULT
|
|
|
32
32
|
...pinoConfig,
|
|
33
33
|
hooks: { logMethod(args, method, _level) {
|
|
34
34
|
const [templateObject, message, ...otherArgs] = args;
|
|
35
|
-
|
|
35
|
+
const templateVars = !!templateObject && typeof templateObject === "object" ? Object.getOwnPropertyNames(templateObject) : [];
|
|
36
|
+
if (!message || !templateVars.length) return method.apply(this, args);
|
|
36
37
|
const hydratedMessage = require_formatter.fillInMsgTemplate(message, templateObject, false);
|
|
37
38
|
return method.apply(this, [
|
|
38
39
|
templateObject,
|
package/build/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":[],"sources":["../src/logger.ts"],"sourcesContent":["// <reference types=\"node\" />\nimport buildDebug from 'debug';\nimport type { LoggerOptions } from 'pino';\n\nimport type { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { fillInMsgTemplate } from './formatter';\nimport { createPrettyTransport, isPrettyFormat } from './transport';\n\nconst debug = buildDebug('verdaccio:logger');\n\nfunction isProd() {\n return process.env.NODE_ENV === 'production';\n}\n\nconst DEFAULT_LOG_FORMAT = isProd() ? 'json' : 'pretty';\ndebug('default log format: %s', DEFAULT_LOG_FORMAT);\n\nexport type LogPlugin = {\n dest: string;\n options?: any[];\n};\n\nexport function createLogger(\n options: LoggerConfigItem = { level: 'http' },\n destination: NodeJS.WritableStream | undefined,\n format: LoggerFormat = DEFAULT_LOG_FORMAT,\n pino\n): any {\n debug('setup logger');\n let pinoConfig: LoggerOptions = {\n customLevels: {\n http: 25,\n },\n level: options.level,\n serializers: {\n err: pino.stdSerializers.err,\n req: pino.stdSerializers.req,\n res: pino.stdSerializers.res,\n },\n redact: options.redact,\n };\n\n debug('has prettifier? %o', !isProd());\n let logger;\n // pretty logs are not allowed in production for performance reasons\n if (isPrettyFormat(format) && isProd() === false) {\n const transport = createPrettyTransport(pino, options, format);\n logger = pino(pinoConfig, transport);\n } else {\n pinoConfig = {\n ...pinoConfig,\n // https://getpino.io/#/docs/api?id=hooks-object\n hooks: {\n logMethod(args: [obj: unknown, msg?: string, ...rest: unknown[]], method, _level) {\n const [templateObject, message, ...otherArgs] = args;\n const templateVars =\n !!templateObject && typeof templateObject === 'object'\n ? Object.getOwnPropertyNames(templateObject)\n : [];\n if (!message || !templateVars.length) return method.apply(this, args);\n const hydratedMessage = fillInMsgTemplate(message, templateObject as any, false);\n return method.apply(this, [templateObject, hydratedMessage, ...otherArgs] as any);\n },\n },\n };\n logger = pino(pinoConfig, destination);\n }\n\n if (process.env.DEBUG) {\n logger.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {\n if (logger !== instance) {\n return;\n }\n debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal);\n });\n }\n\n return logger;\n}\n\nconst DEFAULT_LOGGER_CONF: LoggerConfigItem = {\n type: 'stdout',\n format: 'pretty',\n level: 'http',\n};\n\nexport type LoggerConfig = LoggerConfigItem;\n\nexport function willUseTransport(format: LoggerFormat | undefined): boolean {\n const resolvedFormat = format ?? (isProd() ? 'json' : 'pretty');\n return isPrettyFormat(resolvedFormat) && isProd() === false;\n}\n\nexport async function prepareSetup(\n options: LoggerConfigItem = DEFAULT_LOGGER_CONF,\n pino\n): Promise<Logger> {\n let loggerConfig = options;\n if (!loggerConfig?.level) {\n loggerConfig = {\n ...loggerConfig,\n level: 'http',\n };\n }\n if (loggerConfig.type === 'file') {\n debug('logging file enabled');\n // Pretty format uses a pino transport that creates its own destination stream,\n // so no destination is needed here.\n if (willUseTransport(loggerConfig.format)) {\n return createLogger(loggerConfig, undefined, loggerConfig.format, pino);\n }\n // For file destinations (json format), wait for the fd to be ready\n // so we fail fast on bad paths / permissions instead of losing early logs\n const destination = pino.destination(loggerConfig.path);\n await new Promise<void>((resolve, reject) => {\n destination.once('ready', resolve);\n destination.once('error', reject);\n });\n debug('file destination ready: %s', loggerConfig.path);\n process.on('SIGUSR2', () => destination.reopen());\n return createLogger(loggerConfig, destination, loggerConfig.format, pino);\n }\n debug('logging stdout enabled');\n return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);\n}\n"],"mappings":";;;;;;AASA,IAAM,WAAA,GAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"logger.js","names":[],"sources":["../src/logger.ts"],"sourcesContent":["// <reference types=\"node\" />\nimport buildDebug from 'debug';\nimport type { LoggerOptions } from 'pino';\n\nimport type { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { fillInMsgTemplate } from './formatter';\nimport { createPrettyTransport, isPrettyFormat } from './transport';\n\nconst debug = buildDebug('verdaccio:logger');\n\nfunction isProd() {\n return process.env.NODE_ENV === 'production';\n}\n\nconst DEFAULT_LOG_FORMAT = isProd() ? 'json' : 'pretty';\ndebug('default log format: %s', DEFAULT_LOG_FORMAT);\n\nexport type LogPlugin = {\n dest: string;\n options?: any[];\n};\n\nexport function createLogger(\n options: LoggerConfigItem = { level: 'http' },\n destination: NodeJS.WritableStream | undefined,\n format: LoggerFormat = DEFAULT_LOG_FORMAT,\n pino\n): any {\n debug('setup logger');\n let pinoConfig: LoggerOptions = {\n customLevels: {\n http: 25,\n },\n level: options.level,\n serializers: {\n err: pino.stdSerializers.err,\n req: pino.stdSerializers.req,\n res: pino.stdSerializers.res,\n },\n redact: options.redact,\n };\n\n debug('has prettifier? %o', !isProd());\n let logger;\n // pretty logs are not allowed in production for performance reasons\n if (isPrettyFormat(format) && isProd() === false) {\n const transport = createPrettyTransport(pino, options, format);\n logger = pino(pinoConfig, transport);\n } else {\n pinoConfig = {\n ...pinoConfig,\n // https://getpino.io/#/docs/api?id=hooks-object\n hooks: {\n logMethod(args: [obj: unknown, msg?: string, ...rest: unknown[]], method, _level) {\n const [templateObject, message, ...otherArgs] = args;\n const templateVars =\n !!templateObject && typeof templateObject === 'object'\n ? Object.getOwnPropertyNames(templateObject)\n : [];\n if (!message || !templateVars.length) return method.apply(this, args);\n const hydratedMessage = fillInMsgTemplate(message, templateObject as any, false);\n return method.apply(this, [templateObject, hydratedMessage, ...otherArgs] as any);\n },\n },\n };\n logger = pino(pinoConfig, destination);\n }\n\n if (process.env.DEBUG) {\n logger.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {\n if (logger !== instance) {\n return;\n }\n debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal);\n });\n }\n\n return logger;\n}\n\nconst DEFAULT_LOGGER_CONF: LoggerConfigItem = {\n type: 'stdout',\n format: 'pretty',\n level: 'http',\n};\n\nexport type LoggerConfig = LoggerConfigItem;\n\nexport function willUseTransport(format: LoggerFormat | undefined): boolean {\n const resolvedFormat = format ?? (isProd() ? 'json' : 'pretty');\n return isPrettyFormat(resolvedFormat) && isProd() === false;\n}\n\nexport async function prepareSetup(\n options: LoggerConfigItem = DEFAULT_LOGGER_CONF,\n pino\n): Promise<Logger> {\n let loggerConfig = options;\n if (!loggerConfig?.level) {\n loggerConfig = {\n ...loggerConfig,\n level: 'http',\n };\n }\n if (loggerConfig.type === 'file') {\n debug('logging file enabled');\n // Pretty format uses a pino transport that creates its own destination stream,\n // so no destination is needed here.\n if (willUseTransport(loggerConfig.format)) {\n return createLogger(loggerConfig, undefined, loggerConfig.format, pino);\n }\n // For file destinations (json format), wait for the fd to be ready\n // so we fail fast on bad paths / permissions instead of losing early logs\n const destination = pino.destination(loggerConfig.path);\n await new Promise<void>((resolve, reject) => {\n destination.once('ready', resolve);\n destination.once('error', reject);\n });\n debug('file destination ready: %s', loggerConfig.path);\n process.on('SIGUSR2', () => destination.reopen());\n return createLogger(loggerConfig, destination, loggerConfig.format, pino);\n }\n debug('logging stdout enabled');\n return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);\n}\n"],"mappings":";;;;;;AASA,IAAM,WAAA,GAAA,MAAA,QAAA,CAAmB,kBAAkB;AAE3C,SAAS,SAAS;CAChB,OAAA,QAAA,IAAA,aAAgC;AAClC;AAEA,IAAM,qBAAqB,OAAO,IAAI,SAAS;AAC/C,QAAM,0BAA0B,kBAAkB;AAOlD,SAAgB,aACd,UAA4B,EAAE,OAAO,OAAO,GAC5C,aACA,SAAuB,oBACvB,MACK;CACL,QAAM,cAAc;CACpB,IAAI,aAA4B;EAC9B,cAAc,EACZ,MAAM,GACR;EACA,OAAO,QAAQ;EACf,aAAa;GACX,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;EAC3B;EACA,QAAQ,QAAQ;CAClB;CAEA,QAAM,sBAAsB,CAAC,OAAO,CAAC;CACrC,IAAI;CAEJ,IAAI,kBAAA,eAAe,MAAM,KAAK,OAAO,MAAM,OAAO;EAChD,MAAM,YAAY,kBAAA,sBAAsB,MAAM,SAAS,MAAM;EAC7D,SAAS,KAAK,YAAY,SAAS;CACrC,OAAO;EACL,aAAa;GACX,GAAG;GAEH,OAAO,EACL,UAAU,MAAwD,QAAQ,QAAQ;IAChF,MAAM,CAAC,gBAAgB,SAAS,GAAG,aAAa;IAChD,MAAM,eACJ,CAAC,CAAC,kBAAkB,OAAO,mBAAmB,WAC1C,OAAO,oBAAoB,cAAc,IACzC,CAAC;IACP,IAAI,CAAC,WAAW,CAAC,aAAa,QAAQ,OAAO,OAAO,MAAM,MAAM,IAAI;IACpE,MAAM,kBAAkB,kBAAA,kBAAkB,SAAS,gBAAuB,KAAK;IAC/E,OAAO,OAAO,MAAM,MAAM;KAAC;KAAgB;KAAiB,GAAG;IAAS,CAAQ;GAClF,EACF;EACF;EACA,SAAS,KAAK,YAAY,WAAW;CACvC;CAEA,IAAI,QAAQ,IAAI,OACd,OAAO,GAAG,iBAAiB,KAAK,KAAK,SAAS,SAAS,aAAa;EAClE,IAAI,WAAW,UACb;EAEF,QAAM,kCAAkC,KAAK,KAAK,SAAS,OAAO;CACpE,CAAC;CAGH,OAAO;AACT;AAEA,IAAM,sBAAwC;CAC5C,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAIA,SAAgB,iBAAiB,QAA2C;CAE1E,OAAO,kBAAA,eADgB,WAAW,OAAO,IAAI,SAAS,SAClB,KAAK,OAAO,MAAM;AACxD;AAEA,eAAsB,aACpB,UAA4B,qBAC5B,MACiB;CACjB,IAAI,eAAe;CACnB,IAAI,CAAC,cAAc,OACjB,eAAe;EACb,GAAG;EACH,OAAO;CACT;CAEF,IAAI,aAAa,SAAS,QAAQ;EAChC,QAAM,sBAAsB;EAG5B,IAAI,iBAAiB,aAAa,MAAM,GACtC,OAAO,aAAa,cAAc,KAAA,GAAW,aAAa,QAAQ,IAAI;EAIxE,MAAM,cAAc,KAAK,YAAY,aAAa,IAAI;EACtD,MAAM,IAAI,SAAe,SAAS,WAAW;GAC3C,YAAY,KAAK,SAAS,OAAO;GACjC,YAAY,KAAK,SAAS,MAAM;EAClC,CAAC;EACD,QAAM,8BAA8B,aAAa,IAAI;EACrD,QAAQ,GAAG,iBAAiB,YAAY,OAAO,CAAC;EAChD,OAAO,aAAa,cAAc,aAAa,aAAa,QAAQ,IAAI;CAC1E;CACA,QAAM,wBAAwB;CAC9B,OAAO,aAAa,cAAc,KAAK,YAAY,CAAC,GAAG,aAAa,QAAQ,IAAI;AAClF"}
|
package/build/logger.mjs
CHANGED
|
@@ -30,7 +30,8 @@ function createLogger(options = { level: "http" }, destination, format = DEFAULT
|
|
|
30
30
|
...pinoConfig,
|
|
31
31
|
hooks: { logMethod(args, method, _level) {
|
|
32
32
|
const [templateObject, message, ...otherArgs] = args;
|
|
33
|
-
|
|
33
|
+
const templateVars = !!templateObject && typeof templateObject === "object" ? Object.getOwnPropertyNames(templateObject) : [];
|
|
34
|
+
if (!message || !templateVars.length) return method.apply(this, args);
|
|
34
35
|
const hydratedMessage = fillInMsgTemplate(message, templateObject, false);
|
|
35
36
|
return method.apply(this, [
|
|
36
37
|
templateObject,
|
package/build/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.mjs","names":[],"sources":["../src/logger.ts"],"sourcesContent":["// <reference types=\"node\" />\nimport buildDebug from 'debug';\nimport type { LoggerOptions } from 'pino';\n\nimport type { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { fillInMsgTemplate } from './formatter';\nimport { createPrettyTransport, isPrettyFormat } from './transport';\n\nconst debug = buildDebug('verdaccio:logger');\n\nfunction isProd() {\n return process.env.NODE_ENV === 'production';\n}\n\nconst DEFAULT_LOG_FORMAT = isProd() ? 'json' : 'pretty';\ndebug('default log format: %s', DEFAULT_LOG_FORMAT);\n\nexport type LogPlugin = {\n dest: string;\n options?: any[];\n};\n\nexport function createLogger(\n options: LoggerConfigItem = { level: 'http' },\n destination: NodeJS.WritableStream | undefined,\n format: LoggerFormat = DEFAULT_LOG_FORMAT,\n pino\n): any {\n debug('setup logger');\n let pinoConfig: LoggerOptions = {\n customLevels: {\n http: 25,\n },\n level: options.level,\n serializers: {\n err: pino.stdSerializers.err,\n req: pino.stdSerializers.req,\n res: pino.stdSerializers.res,\n },\n redact: options.redact,\n };\n\n debug('has prettifier? %o', !isProd());\n let logger;\n // pretty logs are not allowed in production for performance reasons\n if (isPrettyFormat(format) && isProd() === false) {\n const transport = createPrettyTransport(pino, options, format);\n logger = pino(pinoConfig, transport);\n } else {\n pinoConfig = {\n ...pinoConfig,\n // https://getpino.io/#/docs/api?id=hooks-object\n hooks: {\n logMethod(args: [obj: unknown, msg?: string, ...rest: unknown[]], method, _level) {\n const [templateObject, message, ...otherArgs] = args;\n const templateVars =\n !!templateObject && typeof templateObject === 'object'\n ? Object.getOwnPropertyNames(templateObject)\n : [];\n if (!message || !templateVars.length) return method.apply(this, args);\n const hydratedMessage = fillInMsgTemplate(message, templateObject as any, false);\n return method.apply(this, [templateObject, hydratedMessage, ...otherArgs] as any);\n },\n },\n };\n logger = pino(pinoConfig, destination);\n }\n\n if (process.env.DEBUG) {\n logger.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {\n if (logger !== instance) {\n return;\n }\n debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal);\n });\n }\n\n return logger;\n}\n\nconst DEFAULT_LOGGER_CONF: LoggerConfigItem = {\n type: 'stdout',\n format: 'pretty',\n level: 'http',\n};\n\nexport type LoggerConfig = LoggerConfigItem;\n\nexport function willUseTransport(format: LoggerFormat | undefined): boolean {\n const resolvedFormat = format ?? (isProd() ? 'json' : 'pretty');\n return isPrettyFormat(resolvedFormat) && isProd() === false;\n}\n\nexport async function prepareSetup(\n options: LoggerConfigItem = DEFAULT_LOGGER_CONF,\n pino\n): Promise<Logger> {\n let loggerConfig = options;\n if (!loggerConfig?.level) {\n loggerConfig = {\n ...loggerConfig,\n level: 'http',\n };\n }\n if (loggerConfig.type === 'file') {\n debug('logging file enabled');\n // Pretty format uses a pino transport that creates its own destination stream,\n // so no destination is needed here.\n if (willUseTransport(loggerConfig.format)) {\n return createLogger(loggerConfig, undefined, loggerConfig.format, pino);\n }\n // For file destinations (json format), wait for the fd to be ready\n // so we fail fast on bad paths / permissions instead of losing early logs\n const destination = pino.destination(loggerConfig.path);\n await new Promise<void>((resolve, reject) => {\n destination.once('ready', resolve);\n destination.once('error', reject);\n });\n debug('file destination ready: %s', loggerConfig.path);\n process.on('SIGUSR2', () => destination.reopen());\n return createLogger(loggerConfig, destination, loggerConfig.format, pino);\n }\n debug('logging stdout enabled');\n return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);\n}\n"],"mappings":";;;;AASA,IAAM,QAAQ,WAAW,kBAAkB;AAE3C,SAAS,SAAS;CAChB,OAAA,QAAA,IAAA,aAAgC;AAClC;AAEA,IAAM,qBAAqB,OAAO,IAAI,SAAS;AAC/C,MAAM,0BAA0B,kBAAkB;AAOlD,SAAgB,aACd,UAA4B,EAAE,OAAO,OAAO,GAC5C,aACA,SAAuB,oBACvB,MACK;CACL,MAAM,cAAc;CACpB,IAAI,aAA4B;EAC9B,cAAc,EACZ,MAAM,GACR;EACA,OAAO,QAAQ;EACf,aAAa;GACX,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;EAC3B;EACA,QAAQ,QAAQ;CAClB;CAEA,MAAM,sBAAsB,CAAC,OAAO,CAAC;CACrC,IAAI;CAEJ,IAAI,eAAe,MAAM,KAAK,OAAO,MAAM,OAAO;EAChD,MAAM,YAAY,sBAAsB,MAAM,SAAS,MAAM;EAC7D,SAAS,KAAK,YAAY,SAAS;CACrC,OAAO;EACL,aAAa;GACX,GAAG;GAEH,OAAO,EACL,UAAU,MAAwD,QAAQ,QAAQ;IAChF,MAAM,CAAC,gBAAgB,SAAS,GAAG,aAAa;
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../src/logger.ts"],"sourcesContent":["// <reference types=\"node\" />\nimport buildDebug from 'debug';\nimport type { LoggerOptions } from 'pino';\n\nimport type { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { fillInMsgTemplate } from './formatter';\nimport { createPrettyTransport, isPrettyFormat } from './transport';\n\nconst debug = buildDebug('verdaccio:logger');\n\nfunction isProd() {\n return process.env.NODE_ENV === 'production';\n}\n\nconst DEFAULT_LOG_FORMAT = isProd() ? 'json' : 'pretty';\ndebug('default log format: %s', DEFAULT_LOG_FORMAT);\n\nexport type LogPlugin = {\n dest: string;\n options?: any[];\n};\n\nexport function createLogger(\n options: LoggerConfigItem = { level: 'http' },\n destination: NodeJS.WritableStream | undefined,\n format: LoggerFormat = DEFAULT_LOG_FORMAT,\n pino\n): any {\n debug('setup logger');\n let pinoConfig: LoggerOptions = {\n customLevels: {\n http: 25,\n },\n level: options.level,\n serializers: {\n err: pino.stdSerializers.err,\n req: pino.stdSerializers.req,\n res: pino.stdSerializers.res,\n },\n redact: options.redact,\n };\n\n debug('has prettifier? %o', !isProd());\n let logger;\n // pretty logs are not allowed in production for performance reasons\n if (isPrettyFormat(format) && isProd() === false) {\n const transport = createPrettyTransport(pino, options, format);\n logger = pino(pinoConfig, transport);\n } else {\n pinoConfig = {\n ...pinoConfig,\n // https://getpino.io/#/docs/api?id=hooks-object\n hooks: {\n logMethod(args: [obj: unknown, msg?: string, ...rest: unknown[]], method, _level) {\n const [templateObject, message, ...otherArgs] = args;\n const templateVars =\n !!templateObject && typeof templateObject === 'object'\n ? Object.getOwnPropertyNames(templateObject)\n : [];\n if (!message || !templateVars.length) return method.apply(this, args);\n const hydratedMessage = fillInMsgTemplate(message, templateObject as any, false);\n return method.apply(this, [templateObject, hydratedMessage, ...otherArgs] as any);\n },\n },\n };\n logger = pino(pinoConfig, destination);\n }\n\n if (process.env.DEBUG) {\n logger.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {\n if (logger !== instance) {\n return;\n }\n debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal);\n });\n }\n\n return logger;\n}\n\nconst DEFAULT_LOGGER_CONF: LoggerConfigItem = {\n type: 'stdout',\n format: 'pretty',\n level: 'http',\n};\n\nexport type LoggerConfig = LoggerConfigItem;\n\nexport function willUseTransport(format: LoggerFormat | undefined): boolean {\n const resolvedFormat = format ?? (isProd() ? 'json' : 'pretty');\n return isPrettyFormat(resolvedFormat) && isProd() === false;\n}\n\nexport async function prepareSetup(\n options: LoggerConfigItem = DEFAULT_LOGGER_CONF,\n pino\n): Promise<Logger> {\n let loggerConfig = options;\n if (!loggerConfig?.level) {\n loggerConfig = {\n ...loggerConfig,\n level: 'http',\n };\n }\n if (loggerConfig.type === 'file') {\n debug('logging file enabled');\n // Pretty format uses a pino transport that creates its own destination stream,\n // so no destination is needed here.\n if (willUseTransport(loggerConfig.format)) {\n return createLogger(loggerConfig, undefined, loggerConfig.format, pino);\n }\n // For file destinations (json format), wait for the fd to be ready\n // so we fail fast on bad paths / permissions instead of losing early logs\n const destination = pino.destination(loggerConfig.path);\n await new Promise<void>((resolve, reject) => {\n destination.once('ready', resolve);\n destination.once('error', reject);\n });\n debug('file destination ready: %s', loggerConfig.path);\n process.on('SIGUSR2', () => destination.reopen());\n return createLogger(loggerConfig, destination, loggerConfig.format, pino);\n }\n debug('logging stdout enabled');\n return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);\n}\n"],"mappings":";;;;AASA,IAAM,QAAQ,WAAW,kBAAkB;AAE3C,SAAS,SAAS;CAChB,OAAA,QAAA,IAAA,aAAgC;AAClC;AAEA,IAAM,qBAAqB,OAAO,IAAI,SAAS;AAC/C,MAAM,0BAA0B,kBAAkB;AAOlD,SAAgB,aACd,UAA4B,EAAE,OAAO,OAAO,GAC5C,aACA,SAAuB,oBACvB,MACK;CACL,MAAM,cAAc;CACpB,IAAI,aAA4B;EAC9B,cAAc,EACZ,MAAM,GACR;EACA,OAAO,QAAQ;EACf,aAAa;GACX,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;EAC3B;EACA,QAAQ,QAAQ;CAClB;CAEA,MAAM,sBAAsB,CAAC,OAAO,CAAC;CACrC,IAAI;CAEJ,IAAI,eAAe,MAAM,KAAK,OAAO,MAAM,OAAO;EAChD,MAAM,YAAY,sBAAsB,MAAM,SAAS,MAAM;EAC7D,SAAS,KAAK,YAAY,SAAS;CACrC,OAAO;EACL,aAAa;GACX,GAAG;GAEH,OAAO,EACL,UAAU,MAAwD,QAAQ,QAAQ;IAChF,MAAM,CAAC,gBAAgB,SAAS,GAAG,aAAa;IAChD,MAAM,eACJ,CAAC,CAAC,kBAAkB,OAAO,mBAAmB,WAC1C,OAAO,oBAAoB,cAAc,IACzC,CAAC;IACP,IAAI,CAAC,WAAW,CAAC,aAAa,QAAQ,OAAO,OAAO,MAAM,MAAM,IAAI;IACpE,MAAM,kBAAkB,kBAAkB,SAAS,gBAAuB,KAAK;IAC/E,OAAO,OAAO,MAAM,MAAM;KAAC;KAAgB;KAAiB,GAAG;IAAS,CAAQ;GAClF,EACF;EACF;EACA,SAAS,KAAK,YAAY,WAAW;CACvC;CAEA,IAAI,QAAQ,IAAI,OACd,OAAO,GAAG,iBAAiB,KAAK,KAAK,SAAS,SAAS,aAAa;EAClE,IAAI,WAAW,UACb;EAEF,MAAM,kCAAkC,KAAK,KAAK,SAAS,OAAO;CACpE,CAAC;CAGH,OAAO;AACT;AAEA,IAAM,sBAAwC;CAC5C,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAIA,SAAgB,iBAAiB,QAA2C;CAE1E,OAAO,eADgB,WAAW,OAAO,IAAI,SAAS,SAClB,KAAK,OAAO,MAAM;AACxD;AAEA,eAAsB,aACpB,UAA4B,qBAC5B,MACiB;CACjB,IAAI,eAAe;CACnB,IAAI,CAAC,cAAc,OACjB,eAAe;EACb,GAAG;EACH,OAAO;CACT;CAEF,IAAI,aAAa,SAAS,QAAQ;EAChC,MAAM,sBAAsB;EAG5B,IAAI,iBAAiB,aAAa,MAAM,GACtC,OAAO,aAAa,cAAc,KAAA,GAAW,aAAa,QAAQ,IAAI;EAIxE,MAAM,cAAc,KAAK,YAAY,aAAa,IAAI;EACtD,MAAM,IAAI,SAAe,SAAS,WAAW;GAC3C,YAAY,KAAK,SAAS,OAAO;GACjC,YAAY,KAAK,SAAS,MAAM;EAClC,CAAC;EACD,MAAM,8BAA8B,aAAa,IAAI;EACrD,QAAQ,GAAG,iBAAiB,YAAY,OAAO,CAAC;EAChD,OAAO,aAAa,cAAc,aAAa,aAAa,QAAQ,IAAI;CAC1E;CACA,MAAM,wBAAwB;CAC9B,OAAO,aAAa,cAAc,KAAK,YAAY,CAAC,GAAG,aAAa,QAAQ,IAAI;AAClF"}
|
package/build/prettify.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Transform } from 'node:stream';
|
|
2
|
-
import
|
|
3
|
-
import { SonicBoomOpts
|
|
2
|
+
import build from 'pino-abstract-transport';
|
|
3
|
+
import type { SonicBoomOpts } from 'sonic-boom';
|
|
4
|
+
import SonicBoom from 'sonic-boom';
|
|
4
5
|
import { fillInMsgTemplate } from './formatter';
|
|
5
|
-
import { PrettyOptionsExtended } from './types';
|
|
6
|
+
import type { PrettyOptionsExtended } from './types';
|
|
6
7
|
export { fillInMsgTemplate };
|
|
7
8
|
/**
|
|
8
9
|
* Creates a safe SonicBoom instance
|
package/build/prettify.js
CHANGED
|
@@ -3,6 +3,7 @@ const require_formatter = require("./formatter.js");
|
|
|
3
3
|
const require_colors = require("./colors.js");
|
|
4
4
|
let node_stream = require("node:stream");
|
|
5
5
|
let node_worker_threads = require("node:worker_threads");
|
|
6
|
+
let on_exit_leak_free = require("on-exit-leak-free");
|
|
6
7
|
let pino_abstract_transport = require("pino-abstract-transport");
|
|
7
8
|
pino_abstract_transport = require_runtime.__toESM(pino_abstract_transport);
|
|
8
9
|
let sonic_boom = require("sonic-boom");
|
|
@@ -47,10 +48,9 @@ function autoEnd(stream, eventName) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
function setupOnExit(stream) {
|
|
50
|
-
|
|
51
|
-
onExit.register(stream, autoEnd);
|
|
51
|
+
(0, on_exit_leak_free.register)(stream, autoEnd);
|
|
52
52
|
stream.on("close", function() {
|
|
53
|
-
|
|
53
|
+
(0, on_exit_leak_free.unregister)(stream);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function buildPretty(opts) {
|
package/build/prettify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettify.js","names":[],"sources":["../src/prettify.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { Transform, pipeline } from 'node:stream';\nimport { isMainThread } from 'node:worker_threads';\nimport build from 'pino-abstract-transport';\nimport type { SonicBoomOpts } from 'sonic-boom';\nimport SonicBoom from 'sonic-boom';\n\nimport { hasColors } from './colors';\nimport { fillInMsgTemplate, printMessage } from './formatter';\nimport type { PrettyOptionsExtended } from './types';\n\nexport { fillInMsgTemplate };\n\nfunction noop() {}\n\n/**\n * Creates a safe SonicBoom instance\n *\n * @param {object} opts Options for SonicBoom\n *\n * @returns {object} A new SonicBoom stream\n */\nexport function buildSafeSonicBoom(opts: SonicBoomOpts) {\n const stream = new SonicBoom(opts);\n stream.on('error', filterBrokenPipe);\n if (!opts.sync && isMainThread) {\n setupOnExit(stream);\n }\n return stream;\n\n function filterBrokenPipe(err) {\n if (err.code === 'EPIPE') {\n // @ts-ignore\n stream.write = noop;\n stream.end = noop;\n stream.flushSync = noop;\n stream.destroy = noop;\n return;\n }\n stream.removeListener('error', filterBrokenPipe);\n }\n}\n\nexport function autoEnd(stream: SonicBoom & { destroyed?: boolean }, eventName: string) {\n if (stream.destroyed) {\n return;\n }\n\n if (eventName === 'beforeExit') {\n stream.flush();\n stream.on('drain', function () {\n stream.end();\n });\n } else {\n // Guard against SonicBoom not being ready (file not yet opened)\n // to prevent \"sonic boom is not ready yet\" crash on early process exit\n try {\n stream.flushSync();\n } catch (err: unknown) {\n if (err instanceof Error && err.message?.includes('not ready')) {\n // Stream not ready, nothing to flush\n return;\n }\n // Re-throw real I/O errors (disk full, permission denied, etc.)\n throw err;\n }\n }\n}\n\nfunction setupOnExit(stream) {\n //
|
|
1
|
+
{"version":3,"file":"prettify.js","names":[],"sources":["../src/prettify.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { Transform, pipeline } from 'node:stream';\nimport { isMainThread } from 'node:worker_threads';\nimport { register as onExitRegister, unregister as onExitUnregister } from 'on-exit-leak-free';\nimport build from 'pino-abstract-transport';\nimport type { SonicBoomOpts } from 'sonic-boom';\nimport SonicBoom from 'sonic-boom';\n\nimport { hasColors } from './colors';\nimport { fillInMsgTemplate, printMessage } from './formatter';\nimport type { PrettyOptionsExtended } from './types';\n\nexport { fillInMsgTemplate };\n\nfunction noop() {}\n\n/**\n * Creates a safe SonicBoom instance\n *\n * @param {object} opts Options for SonicBoom\n *\n * @returns {object} A new SonicBoom stream\n */\nexport function buildSafeSonicBoom(opts: SonicBoomOpts) {\n const stream = new SonicBoom(opts);\n stream.on('error', filterBrokenPipe);\n if (!opts.sync && isMainThread) {\n setupOnExit(stream);\n }\n return stream;\n\n function filterBrokenPipe(err) {\n if (err.code === 'EPIPE') {\n // @ts-ignore\n stream.write = noop;\n stream.end = noop;\n stream.flushSync = noop;\n stream.destroy = noop;\n return;\n }\n stream.removeListener('error', filterBrokenPipe);\n }\n}\n\nexport function autoEnd(stream: SonicBoom & { destroyed?: boolean }, eventName: string) {\n if (stream.destroyed) {\n return;\n }\n\n if (eventName === 'beforeExit') {\n stream.flush();\n stream.on('drain', function () {\n stream.end();\n });\n } else {\n // Guard against SonicBoom not being ready (file not yet opened)\n // to prevent \"sonic boom is not ready yet\" crash on early process exit\n try {\n stream.flushSync();\n } catch (err: unknown) {\n if (err instanceof Error && err.message?.includes('not ready')) {\n // Stream not ready, nothing to flush\n return;\n }\n // Re-throw real I/O errors (disk full, permission denied, etc.)\n throw err;\n }\n }\n}\n\nfunction setupOnExit(stream) {\n // static import instead of a lazy require: rolldown rewrites bare `require`\n // to a throwing stub in the ESM output, which would crash this path\n onExitRegister(stream, autoEnd);\n stream.on('close', function () {\n onExitUnregister(stream);\n });\n}\n\nexport { hasColors } from './colors';\n\nexport function buildPretty(opts: PrettyOptionsExtended) {\n return (chunk) => {\n const colors = hasColors(opts.colors);\n return printMessage(chunk, { prettyStamp: opts.prettyStamp }, colors);\n };\n}\n\nexport default function (opts) {\n const pretty = buildPretty(opts);\n // @ts-ignore\n return build(function (source) {\n const stream = new Transform({\n objectMode: true,\n autoDestroy: true,\n transform(chunk, enc, cb) {\n const line = pretty(chunk) + '\\n';\n cb(null, line);\n },\n });\n const destination = buildSafeSonicBoom({\n dest: opts.destination || 1,\n // Defaults to async (false). The transport runs in a worker thread,\n // so sync only blocks the worker, not the main thread.\n // Can be set to true via config for deterministic log ordering (like console.log).\n sync: opts.sync ?? false,\n }) as unknown as WriteStream;\n\n source.on('unknown', function (line) {\n destination.write(line + '\\n');\n });\n\n pipeline(source, stream, destination, (err) => {\n if (err) {\n console.error('prettify pipeline error ', err);\n }\n });\n return stream;\n });\n}\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,OAAO,CAAC;;;;;;;;AASjB,SAAgB,mBAAmB,MAAqB;CACtD,MAAM,SAAS,IAAI,WAAA,QAAU,IAAI;CACjC,OAAO,GAAG,SAAS,gBAAgB;CACnC,IAAI,CAAC,KAAK,QAAQ,oBAAA,cAChB,YAAY,MAAM;CAEpB,OAAO;CAEP,SAAS,iBAAiB,KAAK;EAC7B,IAAI,IAAI,SAAS,SAAS;GAExB,OAAO,QAAQ;GACf,OAAO,MAAM;GACb,OAAO,YAAY;GACnB,OAAO,UAAU;GACjB;EACF;EACA,OAAO,eAAe,SAAS,gBAAgB;CACjD;AACF;AAEA,SAAgB,QAAQ,QAA6C,WAAmB;CACtF,IAAI,OAAO,WACT;CAGF,IAAI,cAAc,cAAc;EAC9B,OAAO,MAAM;EACb,OAAO,GAAG,SAAS,WAAY;GAC7B,OAAO,IAAI;EACb,CAAC;CACH,OAGE,IAAI;EACF,OAAO,UAAU;CACnB,SAAS,KAAc;EACrB,IAAI,eAAe,SAAS,IAAI,SAAS,SAAS,WAAW,GAE3D;EAGF,MAAM;CACR;AAEJ;AAEA,SAAS,YAAY,QAAQ;CAG3B,CAAA,GAAA,kBAAA,SAAA,CAAe,QAAQ,OAAO;CAC9B,OAAO,GAAG,SAAS,WAAY;EAC7B,CAAA,GAAA,kBAAA,WAAA,CAAiB,MAAM;CACzB,CAAC;AACH;AAIA,SAAgB,YAAY,MAA6B;CACvD,QAAQ,UAAU;EAChB,MAAM,SAAS,eAAA,UAAU,KAAK,MAAM;EACpC,OAAO,kBAAA,aAAa,OAAO,EAAE,aAAa,KAAK,YAAY,GAAG,MAAM;CACtE;AACF;AAEA,SAAA,iBAAyB,MAAM;CAC7B,MAAM,SAAS,YAAY,IAAI;CAE/B,QAAA,GAAA,wBAAA,QAAA,CAAa,SAAU,QAAQ;EAC7B,MAAM,SAAS,IAAI,YAAA,UAAU;GAC3B,YAAY;GACZ,aAAa;GACb,UAAU,OAAO,KAAK,IAAI;IAExB,GAAG,MADU,OAAO,KAAK,IAAI,IAChB;GACf;EACF,CAAC;EACD,MAAM,cAAc,mBAAmB;GACrC,MAAM,KAAK,eAAe;GAI1B,MAAM,KAAK,QAAQ;EACrB,CAAC;EAED,OAAO,GAAG,WAAW,SAAU,MAAM;GACnC,YAAY,MAAM,OAAO,IAAI;EAC/B,CAAC;EAED,CAAA,GAAA,YAAA,SAAA,CAAS,QAAQ,QAAQ,cAAc,QAAQ;GAC7C,IAAI,KACF,QAAQ,MAAM,4BAA4B,GAAG;EAEjD,CAAC;EACD,OAAO;CACT,CAAC;AACH"}
|
package/build/prettify.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
1
|
import { printMessage } from "./formatter.mjs";
|
|
3
2
|
import { hasColors } from "./colors.mjs";
|
|
4
3
|
import { Transform, pipeline } from "node:stream";
|
|
5
4
|
import { isMainThread } from "node:worker_threads";
|
|
5
|
+
import { register, unregister } from "on-exit-leak-free";
|
|
6
6
|
import build from "pino-abstract-transport";
|
|
7
7
|
import SonicBoom from "sonic-boom";
|
|
8
8
|
//#region src/prettify.ts
|
|
@@ -45,10 +45,9 @@ function autoEnd(stream, eventName) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function setupOnExit(stream) {
|
|
48
|
-
|
|
49
|
-
onExit.register(stream, autoEnd);
|
|
48
|
+
register(stream, autoEnd);
|
|
50
49
|
stream.on("close", function() {
|
|
51
|
-
|
|
50
|
+
unregister(stream);
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
function buildPretty(opts) {
|
package/build/prettify.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettify.mjs","names":[],"sources":["../src/prettify.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { Transform, pipeline } from 'node:stream';\nimport { isMainThread } from 'node:worker_threads';\nimport build from 'pino-abstract-transport';\nimport type { SonicBoomOpts } from 'sonic-boom';\nimport SonicBoom from 'sonic-boom';\n\nimport { hasColors } from './colors';\nimport { fillInMsgTemplate, printMessage } from './formatter';\nimport type { PrettyOptionsExtended } from './types';\n\nexport { fillInMsgTemplate };\n\nfunction noop() {}\n\n/**\n * Creates a safe SonicBoom instance\n *\n * @param {object} opts Options for SonicBoom\n *\n * @returns {object} A new SonicBoom stream\n */\nexport function buildSafeSonicBoom(opts: SonicBoomOpts) {\n const stream = new SonicBoom(opts);\n stream.on('error', filterBrokenPipe);\n if (!opts.sync && isMainThread) {\n setupOnExit(stream);\n }\n return stream;\n\n function filterBrokenPipe(err) {\n if (err.code === 'EPIPE') {\n // @ts-ignore\n stream.write = noop;\n stream.end = noop;\n stream.flushSync = noop;\n stream.destroy = noop;\n return;\n }\n stream.removeListener('error', filterBrokenPipe);\n }\n}\n\nexport function autoEnd(stream: SonicBoom & { destroyed?: boolean }, eventName: string) {\n if (stream.destroyed) {\n return;\n }\n\n if (eventName === 'beforeExit') {\n stream.flush();\n stream.on('drain', function () {\n stream.end();\n });\n } else {\n // Guard against SonicBoom not being ready (file not yet opened)\n // to prevent \"sonic boom is not ready yet\" crash on early process exit\n try {\n stream.flushSync();\n } catch (err: unknown) {\n if (err instanceof Error && err.message?.includes('not ready')) {\n // Stream not ready, nothing to flush\n return;\n }\n // Re-throw real I/O errors (disk full, permission denied, etc.)\n throw err;\n }\n }\n}\n\nfunction setupOnExit(stream) {\n //
|
|
1
|
+
{"version":3,"file":"prettify.mjs","names":[],"sources":["../src/prettify.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { Transform, pipeline } from 'node:stream';\nimport { isMainThread } from 'node:worker_threads';\nimport { register as onExitRegister, unregister as onExitUnregister } from 'on-exit-leak-free';\nimport build from 'pino-abstract-transport';\nimport type { SonicBoomOpts } from 'sonic-boom';\nimport SonicBoom from 'sonic-boom';\n\nimport { hasColors } from './colors';\nimport { fillInMsgTemplate, printMessage } from './formatter';\nimport type { PrettyOptionsExtended } from './types';\n\nexport { fillInMsgTemplate };\n\nfunction noop() {}\n\n/**\n * Creates a safe SonicBoom instance\n *\n * @param {object} opts Options for SonicBoom\n *\n * @returns {object} A new SonicBoom stream\n */\nexport function buildSafeSonicBoom(opts: SonicBoomOpts) {\n const stream = new SonicBoom(opts);\n stream.on('error', filterBrokenPipe);\n if (!opts.sync && isMainThread) {\n setupOnExit(stream);\n }\n return stream;\n\n function filterBrokenPipe(err) {\n if (err.code === 'EPIPE') {\n // @ts-ignore\n stream.write = noop;\n stream.end = noop;\n stream.flushSync = noop;\n stream.destroy = noop;\n return;\n }\n stream.removeListener('error', filterBrokenPipe);\n }\n}\n\nexport function autoEnd(stream: SonicBoom & { destroyed?: boolean }, eventName: string) {\n if (stream.destroyed) {\n return;\n }\n\n if (eventName === 'beforeExit') {\n stream.flush();\n stream.on('drain', function () {\n stream.end();\n });\n } else {\n // Guard against SonicBoom not being ready (file not yet opened)\n // to prevent \"sonic boom is not ready yet\" crash on early process exit\n try {\n stream.flushSync();\n } catch (err: unknown) {\n if (err instanceof Error && err.message?.includes('not ready')) {\n // Stream not ready, nothing to flush\n return;\n }\n // Re-throw real I/O errors (disk full, permission denied, etc.)\n throw err;\n }\n }\n}\n\nfunction setupOnExit(stream) {\n // static import instead of a lazy require: rolldown rewrites bare `require`\n // to a throwing stub in the ESM output, which would crash this path\n onExitRegister(stream, autoEnd);\n stream.on('close', function () {\n onExitUnregister(stream);\n });\n}\n\nexport { hasColors } from './colors';\n\nexport function buildPretty(opts: PrettyOptionsExtended) {\n return (chunk) => {\n const colors = hasColors(opts.colors);\n return printMessage(chunk, { prettyStamp: opts.prettyStamp }, colors);\n };\n}\n\nexport default function (opts) {\n const pretty = buildPretty(opts);\n // @ts-ignore\n return build(function (source) {\n const stream = new Transform({\n objectMode: true,\n autoDestroy: true,\n transform(chunk, enc, cb) {\n const line = pretty(chunk) + '\\n';\n cb(null, line);\n },\n });\n const destination = buildSafeSonicBoom({\n dest: opts.destination || 1,\n // Defaults to async (false). The transport runs in a worker thread,\n // so sync only blocks the worker, not the main thread.\n // Can be set to true via config for deterministic log ordering (like console.log).\n sync: opts.sync ?? false,\n }) as unknown as WriteStream;\n\n source.on('unknown', function (line) {\n destination.write(line + '\\n');\n });\n\n pipeline(source, stream, destination, (err) => {\n if (err) {\n console.error('prettify pipeline error ', err);\n }\n });\n return stream;\n });\n}\n"],"mappings":";;;;;;;;AAcA,SAAS,OAAO,CAAC;;;;;;;;AASjB,SAAgB,mBAAmB,MAAqB;CACtD,MAAM,SAAS,IAAI,UAAU,IAAI;CACjC,OAAO,GAAG,SAAS,gBAAgB;CACnC,IAAI,CAAC,KAAK,QAAQ,cAChB,YAAY,MAAM;CAEpB,OAAO;CAEP,SAAS,iBAAiB,KAAK;EAC7B,IAAI,IAAI,SAAS,SAAS;GAExB,OAAO,QAAQ;GACf,OAAO,MAAM;GACb,OAAO,YAAY;GACnB,OAAO,UAAU;GACjB;EACF;EACA,OAAO,eAAe,SAAS,gBAAgB;CACjD;AACF;AAEA,SAAgB,QAAQ,QAA6C,WAAmB;CACtF,IAAI,OAAO,WACT;CAGF,IAAI,cAAc,cAAc;EAC9B,OAAO,MAAM;EACb,OAAO,GAAG,SAAS,WAAY;GAC7B,OAAO,IAAI;EACb,CAAC;CACH,OAGE,IAAI;EACF,OAAO,UAAU;CACnB,SAAS,KAAc;EACrB,IAAI,eAAe,SAAS,IAAI,SAAS,SAAS,WAAW,GAE3D;EAGF,MAAM;CACR;AAEJ;AAEA,SAAS,YAAY,QAAQ;CAG3B,SAAe,QAAQ,OAAO;CAC9B,OAAO,GAAG,SAAS,WAAY;EAC7B,WAAiB,MAAM;CACzB,CAAC;AACH;AAIA,SAAgB,YAAY,MAA6B;CACvD,QAAQ,UAAU;EAChB,MAAM,SAAS,UAAU,KAAK,MAAM;EACpC,OAAO,aAAa,OAAO,EAAE,aAAa,KAAK,YAAY,GAAG,MAAM;CACtE;AACF;AAEA,SAAA,iBAAyB,MAAM;CAC7B,MAAM,SAAS,YAAY,IAAI;CAE/B,OAAO,MAAM,SAAU,QAAQ;EAC7B,MAAM,SAAS,IAAI,UAAU;GAC3B,YAAY;GACZ,aAAa;GACb,UAAU,OAAO,KAAK,IAAI;IAExB,GAAG,MADU,OAAO,KAAK,IAAI,IAChB;GACf;EACF,CAAC;EACD,MAAM,cAAc,mBAAmB;GACrC,MAAM,KAAK,eAAe;GAI1B,MAAM,KAAK,QAAQ;EACrB,CAAC;EAED,OAAO,GAAG,WAAW,SAAU,MAAM;GACnC,YAAY,MAAM,OAAO,IAAI;EAC/B,CAAC;EAED,SAAS,QAAQ,QAAQ,cAAc,QAAQ;GAC7C,IAAI,KACF,QAAQ,MAAM,4BAA4B,GAAG;EAEjD,CAAC;EACD,OAAO;CACT,CAAC;AACH"}
|
package/build/transport.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';
|
|
1
|
+
import type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';
|
|
2
2
|
export declare function isPrettyFormat(format: LoggerFormat | undefined): boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Create a pino pretty transport for non-production environments.
|
package/build/transport.js
CHANGED
|
@@ -2,7 +2,7 @@ const require_colors = require("./colors.js");
|
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
let node_url = require("node:url");
|
|
4
4
|
//#region src/transport.ts
|
|
5
|
-
var prettifyPath = (0, node_path.join)(
|
|
5
|
+
var prettifyPath = (0, node_path.join)({}.url ? (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url)) : __dirname, "..", "build", "prettify.js");
|
|
6
6
|
function isPrettyFormat(format) {
|
|
7
7
|
return ["pretty-timestamped", "pretty"].includes(format ?? "pretty");
|
|
8
8
|
}
|
package/build/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","names":[],"sources":["../src/transport.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { hasColors } from './colors';\n\n// Pino transports run in a worker thread via require(), so CJS output must work.\n// import.meta.
|
|
1
|
+
{"version":3,"file":"transport.js","names":[],"sources":["../src/transport.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { hasColors } from './colors';\n\n// Pino transports run in a worker thread via require(), so CJS output must work.\n// rolldown lowers `import.meta` to `{}` in the CJS output, so `import.meta.url`\n// is only truthy in the ESM build; module-scoped __dirname covers the CJS build\n// (checking `typeof __dirname` instead is unsafe: node -e and the REPL leak it\n// as a global into ES modules)\nconst currentDir = import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname;\nconst prettifyPath = join(currentDir, '..', 'build', 'prettify.js');\n\nexport function isPrettyFormat(format: LoggerFormat | undefined): boolean {\n return ['pretty-timestamped', 'pretty'].includes(format ?? 'pretty');\n}\n\n/**\n * Create a pino pretty transport for non-production environments.\n */\nexport function createPrettyTransport(pino: any, options: LoggerConfigItem, format: LoggerFormat) {\n return pino.transport({\n target: prettifyPath,\n options: {\n destination: options.path || 1,\n colors: hasColors(options.colors),\n prettyStamp: format === 'pretty-timestamped',\n sync: options.sync ?? false,\n },\n worker: {\n name: 'verdaccio-logger-prettify',\n },\n });\n}\n"],"mappings":";;;;AAaA,IAAM,gBAAA,GAAA,UAAA,KAAA,CAAA,CAAA,EADyB,OAAA,GAAA,UAAA,QAAA,EAAA,GAAA,SAAA,cAAA,CAAA,CAAA,EAAwC,GAAG,CAAC,IAAI,WACzC,MAAM,SAAS,aAAa;AAElE,SAAgB,eAAe,QAA2C;CACxE,OAAO,CAAC,sBAAsB,QAAQ,CAAC,CAAC,SAAS,UAAU,QAAQ;AACrE;;;;AAKA,SAAgB,sBAAsB,MAAW,SAA2B,QAAsB;CAChG,OAAO,KAAK,UAAU;EACpB,QAAQ;EACR,SAAS;GACP,aAAa,QAAQ,QAAQ;GAC7B,QAAQ,eAAA,UAAU,QAAQ,MAAM;GAChC,aAAa,WAAW;GACxB,MAAM,QAAQ,QAAQ;EACxB;EACA,QAAQ,EACN,MAAM,4BACR;CACF,CAAC;AACH"}
|
package/build/transport.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { hasColors } from "./colors.mjs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
//#region src/transport.ts
|
|
5
|
-
var prettifyPath = join(
|
|
5
|
+
var prettifyPath = join(import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname, "..", "build", "prettify.js");
|
|
6
6
|
function isPrettyFormat(format) {
|
|
7
7
|
return ["pretty-timestamped", "pretty"].includes(format ?? "pretty");
|
|
8
8
|
}
|
package/build/transport.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.mjs","names":[],"sources":["../src/transport.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { hasColors } from './colors';\n\n// Pino transports run in a worker thread via require(), so CJS output must work.\n// import.meta.
|
|
1
|
+
{"version":3,"file":"transport.mjs","names":[],"sources":["../src/transport.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { hasColors } from './colors';\n\n// Pino transports run in a worker thread via require(), so CJS output must work.\n// rolldown lowers `import.meta` to `{}` in the CJS output, so `import.meta.url`\n// is only truthy in the ESM build; module-scoped __dirname covers the CJS build\n// (checking `typeof __dirname` instead is unsafe: node -e and the REPL leak it\n// as a global into ES modules)\nconst currentDir = import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname;\nconst prettifyPath = join(currentDir, '..', 'build', 'prettify.js');\n\nexport function isPrettyFormat(format: LoggerFormat | undefined): boolean {\n return ['pretty-timestamped', 'pretty'].includes(format ?? 'pretty');\n}\n\n/**\n * Create a pino pretty transport for non-production environments.\n */\nexport function createPrettyTransport(pino: any, options: LoggerConfigItem, format: LoggerFormat) {\n return pino.transport({\n target: prettifyPath,\n options: {\n destination: options.path || 1,\n colors: hasColors(options.colors),\n prettyStamp: format === 'pretty-timestamped',\n sync: options.sync ?? false,\n },\n worker: {\n name: 'verdaccio-logger-prettify',\n },\n });\n}\n"],"mappings":";;;;AAaA,IAAM,eAAe,KADF,OAAO,KAAK,MAAM,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC,IAAI,WACzC,MAAM,SAAS,aAAa;AAElE,SAAgB,eAAe,QAA2C;CACxE,OAAO,CAAC,sBAAsB,QAAQ,CAAC,CAAC,SAAS,UAAU,QAAQ;AACrE;;;;AAKA,SAAgB,sBAAsB,MAAW,SAA2B,QAAsB;CAChG,OAAO,KAAK,UAAU;EACpB,QAAQ;EACR,SAAS;GACP,aAAa,QAAQ,QAAQ;GAC7B,QAAQ,UAAU,QAAQ,MAAM;GAChC,aAAa,WAAW;GACxB,MAAM,QAAQ,QAAQ;EACxB;EACA,QAAQ,EACN,MAAM,4BACR;CACF,CAAC;AACH"}
|
package/build/types.d.ts
CHANGED
package/build/utils.js
CHANGED
|
@@ -13,6 +13,7 @@ function formatLoggingDate(time, message) {
|
|
|
13
13
|
return `[${(0, dayjs.default)(time).format(FORMAT_DATE)}] ${message}`;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
|
+
exports.FORMAT_DATE = FORMAT_DATE;
|
|
16
17
|
exports.formatLoggingDate = formatLoggingDate;
|
|
17
18
|
exports.isObject = isObject;
|
|
18
19
|
exports.padRight = padRight;
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nexport const FORMAT_DATE = 'YYYY-MM-DD HH:mm:ss';\nexport const CUSTOM_PAD_LENGTH = 1;\n\nexport function isObject(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH) {\n return message.padEnd(max, ' ');\n}\n\nexport function formatLoggingDate(time: number, message: string): string {\n const timeFormatted = dayjs(time).format(FORMAT_DATE);\n\n return `[${timeFormatted}] ${message}`;\n}\n"],"mappings":";;;;AAEA,IAAa,cAAc;AAG3B,SAAgB,SAAS,KAAuB;CAC9C,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,GAAG;AACtE;AAEA,SAAgB,SAAS,SAAiB,MAAM,QAAQ,SAAA,GAA4B;CAClF,OAAO,QAAQ,OAAO,KAAK,GAAG;AAChC;AAEA,SAAgB,kBAAkB,MAAc,SAAyB;CAGvE,OAAO,KAAA,GAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nexport const FORMAT_DATE = 'YYYY-MM-DD HH:mm:ss';\nexport const CUSTOM_PAD_LENGTH = 1;\n\nexport function isObject(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH) {\n return message.padEnd(max, ' ');\n}\n\nexport function formatLoggingDate(time: number, message: string): string {\n const timeFormatted = dayjs(time).format(FORMAT_DATE);\n\n return `[${timeFormatted}] ${message}`;\n}\n"],"mappings":";;;;AAEA,IAAa,cAAc;AAG3B,SAAgB,SAAS,KAAuB;CAC9C,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,GAAG;AACtE;AAEA,SAAgB,SAAS,SAAiB,MAAM,QAAQ,SAAA,GAA4B;CAClF,OAAO,QAAQ,OAAO,KAAK,GAAG;AAChC;AAEA,SAAgB,kBAAkB,MAAc,SAAyB;CAGvE,OAAO,KAAA,GAAA,MAAA,QAAA,CAFqB,IAAI,CAAC,CAAC,OAAO,WAE9B,EAAc,IAAI;AAC/B"}
|
package/build/utils.mjs
CHANGED
|
@@ -11,6 +11,6 @@ function formatLoggingDate(time, message) {
|
|
|
11
11
|
return `[${dayjs(time).format(FORMAT_DATE)}] ${message}`;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
-
export { formatLoggingDate, isObject, padRight };
|
|
14
|
+
export { FORMAT_DATE, formatLoggingDate, isObject, padRight };
|
|
15
15
|
|
|
16
16
|
//# sourceMappingURL=utils.mjs.map
|
package/build/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nexport const FORMAT_DATE = 'YYYY-MM-DD HH:mm:ss';\nexport const CUSTOM_PAD_LENGTH = 1;\n\nexport function isObject(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH) {\n return message.padEnd(max, ' ');\n}\n\nexport function formatLoggingDate(time: number, message: string): string {\n const timeFormatted = dayjs(time).format(FORMAT_DATE);\n\n return `[${timeFormatted}] ${message}`;\n}\n"],"mappings":";;AAEA,IAAa,cAAc;AAG3B,SAAgB,SAAS,KAAuB;CAC9C,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,GAAG;AACtE;AAEA,SAAgB,SAAS,SAAiB,MAAM,QAAQ,SAAA,GAA4B;CAClF,OAAO,QAAQ,OAAO,KAAK,GAAG;AAChC;AAEA,SAAgB,kBAAkB,MAAc,SAAyB;CAGvE,OAAO,IAFe,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nexport const FORMAT_DATE = 'YYYY-MM-DD HH:mm:ss';\nexport const CUSTOM_PAD_LENGTH = 1;\n\nexport function isObject(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH) {\n return message.padEnd(max, ' ');\n}\n\nexport function formatLoggingDate(time: number, message: string): string {\n const timeFormatted = dayjs(time).format(FORMAT_DATE);\n\n return `[${timeFormatted}] ${message}`;\n}\n"],"mappings":";;AAEA,IAAa,cAAc;AAG3B,SAAgB,SAAS,KAAuB;CAC9C,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,GAAG;AACtE;AAEA,SAAgB,SAAS,SAAiB,MAAM,QAAQ,SAAA,GAA4B;CAClF,OAAO,QAAQ,OAAO,KAAK,GAAG;AAChC;AAEA,SAAgB,kBAAkB,MAAc,SAAyB;CAGvE,OAAO,IAFe,MAAM,IAAI,CAAC,CAAC,OAAO,WAE9B,EAAc,IAAI;AAC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/logger",
|
|
3
|
-
"version": "9.0.0-next-9.
|
|
3
|
+
"version": "9.0.0-next-9.22",
|
|
4
4
|
"description": "Verdaccio Logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"node": ">=24"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/core": "9.0.0-next-9.
|
|
36
|
+
"@verdaccio/core": "9.0.0-next-9.22",
|
|
37
37
|
"colorette": "2.0.20",
|
|
38
|
-
"dayjs": "1.11.
|
|
38
|
+
"dayjs": "1.11.21",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"on-exit-leak-free": "2.1.2",
|
|
41
41
|
"pino": "10.3.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@verdaccio/types": "14.0.0-next-9.11",
|
|
47
47
|
"cross-env": "10.1.0",
|
|
48
48
|
"rimraf": "6.1.3",
|
|
49
|
-
"vite": "8.
|
|
50
|
-
"vitest": "4.1.
|
|
49
|
+
"vite": "8.1.4",
|
|
50
|
+
"vitest": "4.1.10"
|
|
51
51
|
},
|
|
52
52
|
"funding": {
|
|
53
53
|
"type": "opencollective",
|
package/src/prettify.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WriteStream } from 'node:fs';
|
|
2
2
|
import { Transform, pipeline } from 'node:stream';
|
|
3
3
|
import { isMainThread } from 'node:worker_threads';
|
|
4
|
+
import { register as onExitRegister, unregister as onExitUnregister } from 'on-exit-leak-free';
|
|
4
5
|
import build from 'pino-abstract-transport';
|
|
5
6
|
import type { SonicBoomOpts } from 'sonic-boom';
|
|
6
7
|
import SonicBoom from 'sonic-boom';
|
|
@@ -68,11 +69,11 @@ export function autoEnd(stream: SonicBoom & { destroyed?: boolean }, eventName:
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function setupOnExit(stream) {
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// static import instead of a lazy require: rolldown rewrites bare `require`
|
|
73
|
+
// to a throwing stub in the ESM output, which would crash this path
|
|
74
|
+
onExitRegister(stream, autoEnd);
|
|
74
75
|
stream.on('close', function () {
|
|
75
|
-
|
|
76
|
+
onExitUnregister(stream);
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
|
package/src/transport.ts
CHANGED
|
@@ -6,9 +6,11 @@ import type { LoggerConfigItem, LoggerFormat } from '@verdaccio/types';
|
|
|
6
6
|
import { hasColors } from './colors';
|
|
7
7
|
|
|
8
8
|
// Pino transports run in a worker thread via require(), so CJS output must work.
|
|
9
|
-
// import.meta
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// rolldown lowers `import.meta` to `{}` in the CJS output, so `import.meta.url`
|
|
10
|
+
// is only truthy in the ESM build; module-scoped __dirname covers the CJS build
|
|
11
|
+
// (checking `typeof __dirname` instead is unsafe: node -e and the REPL leak it
|
|
12
|
+
// as a global into ES modules)
|
|
13
|
+
const currentDir = import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname;
|
|
12
14
|
const prettifyPath = join(currentDir, '..', 'build', 'prettify.js');
|
|
13
15
|
|
|
14
16
|
export function isPrettyFormat(format: LoggerFormat | undefined): boolean {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import type * as workerThreads from 'node:worker_threads';
|
|
5
|
+
import { afterAll, afterEach, describe, expect, test, vi } from 'vitest';
|
|
6
|
+
|
|
7
|
+
const { register, unregister } = vi.hoisted(() => ({
|
|
8
|
+
register: vi.fn(),
|
|
9
|
+
unregister: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock('on-exit-leak-free', () => ({ register, unregister }));
|
|
13
|
+
// buildSafeSonicBoom only registers exit handlers on the main thread; force it
|
|
14
|
+
// so the test does not depend on the vitest worker pool
|
|
15
|
+
vi.mock('node:worker_threads', async (importOriginal) => ({
|
|
16
|
+
...(await importOriginal<typeof workerThreads>()),
|
|
17
|
+
isMainThread: true,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
import { buildSafeSonicBoom } from '../src/prettify';
|
|
21
|
+
|
|
22
|
+
describe('buildSafeSonicBoom exit handling', () => {
|
|
23
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'prettify-'));
|
|
24
|
+
let fileCount = 0;
|
|
25
|
+
const nextDest = () => path.join(tmpDir, `out-${fileCount++}.log`);
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
vi.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterAll(() => {
|
|
32
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('registers a flush-on-exit handler for async streams', async () => {
|
|
36
|
+
const stream = buildSafeSonicBoom({ dest: nextDest(), sync: false });
|
|
37
|
+
|
|
38
|
+
expect(register).toHaveBeenCalledTimes(1);
|
|
39
|
+
expect(register).toHaveBeenCalledWith(stream, expect.any(Function));
|
|
40
|
+
|
|
41
|
+
await new Promise<void>((resolve) => {
|
|
42
|
+
stream.on('close', () => resolve());
|
|
43
|
+
stream.end();
|
|
44
|
+
});
|
|
45
|
+
expect(unregister).toHaveBeenCalledWith(stream);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('does not register an exit handler for sync streams', () => {
|
|
49
|
+
const stream = buildSafeSonicBoom({ dest: nextDest(), sync: true });
|
|
50
|
+
|
|
51
|
+
expect(register).not.toHaveBeenCalled();
|
|
52
|
+
stream.destroy();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('flush-on-exit handler ends the stream so buffered logs are not lost', async () => {
|
|
56
|
+
const dest = nextDest();
|
|
57
|
+
const stream = buildSafeSonicBoom({ dest, sync: false });
|
|
58
|
+
await new Promise<void>((resolve) => stream.once('ready', () => resolve()));
|
|
59
|
+
stream.write('tail line\n');
|
|
60
|
+
|
|
61
|
+
const autoEnd = register.mock.calls[0][1];
|
|
62
|
+
await new Promise<void>((resolve) => {
|
|
63
|
+
stream.on('close', () => resolve());
|
|
64
|
+
// simulate the process exit callback from on-exit-leak-free
|
|
65
|
+
autoEnd(stream, 'beforeExit');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(fs.readFileSync(dest, 'utf8')).toContain('tail line');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
-
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
-
});
|
|
6
|
-
//#endregion
|
|
7
|
-
export { __require };
|