@verdaccio/logger 9.0.0-next-9.25 → 9.0.0-next-9.26

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @verdaccio/logger
2
2
 
3
+ ## 9.0.0-next-9.26
4
+
5
+ ### Patch Changes
6
+
7
+ - @verdaccio/core@9.0.0-next-9.26
8
+
3
9
  ## 9.0.0-next-9.25
4
10
 
5
11
  ### Patch Changes
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
@@ -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,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"}
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,GAAO,UAAA,IAAA,CAAI,GAAG;GAEhB,QAAA,GAAO,UAAA,MAAA,CAAM,GAAG;EAClB;EAGA,QAAA,GAAO,UAAA,QAAA,CAAQ,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,GAAI,UAAA,MAAA,CACrF,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"}
@@ -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,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"}
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,GAAI,UAAA,MAAA,CAAA,KAAiB;EACrB,MAAA,GAAK,UAAA,OAAA,CAAA,KAAmB;EACxB,OAAA,GAAM,UAAA,KAAA,CAAA,KAAmB;EACzB,KAAA,GAAI,UAAA,MAAA,CAAA,KAAkB;EACtB,UAAA,GAAS,UAAA,KAAA,CAAA,KAAmB;CAC9B;CACA,OAAO;EACL,IAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA;CACF;AACF"}
package/build/logger.js CHANGED
@@ -56,7 +56,8 @@ var DEFAULT_LOGGER_CONF = {
56
56
  level: "http"
57
57
  };
58
58
  function willUseTransport(format) {
59
- return require_transport.isPrettyFormat(format ?? (isProd() ? "json" : "pretty")) && isProd() === false;
59
+ const resolvedFormat = format ?? (isProd() ? "json" : "pretty");
60
+ return require_transport.isPrettyFormat(resolvedFormat) && isProd() === false;
60
61
  }
61
62
  async function prepareSetup(options = DEFAULT_LOGGER_CONF, pino) {
62
63
  let loggerConfig = options;
@@ -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,QAAA,CAAmB,kBAAkB;AAE3C,SAAS,SAAS;CAChB,OAAA,Q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;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"}
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,GAAQ,MAAA,QAAA,CAAW,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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O,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
@@ -54,7 +54,8 @@ var DEFAULT_LOGGER_CONF = {
54
54
  level: "http"
55
55
  };
56
56
  function willUseTransport(format) {
57
- return isPrettyFormat(format ?? (isProd() ? "json" : "pretty")) && isProd() === false;
57
+ const resolvedFormat = format ?? (isProd() ? "json" : "pretty");
58
+ return isPrettyFormat(resolvedFormat) && isProd() === false;
58
59
  }
59
60
  async function prepareSetup(options = DEFAULT_LOGGER_CONF, pino) {
60
61
  let loggerConfig = options;
@@ -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;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"}
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,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AC3C,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"}
@@ -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 { 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,UA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D,OAAO;CACT,CAAC;AACH"}
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,GAAO,wBAAA,QAAA,CAAM,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"}
@@ -2,7 +2,8 @@ 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)({}.url ? (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url)) : __dirname, "..", "build", "prettify.js");
5
+ var currentDir = {}.url ? (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url)) : __dirname;
6
+ var prettifyPath = (0, node_path.join)(currentDir, "..", "build", "prettify.js");
6
7
  function isPrettyFormat(format) {
7
8
  return ["pretty-timestamped", "pretty"].includes(format ?? "pretty");
8
9
  }
@@ -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// 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"}
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":";;;;AAYA,IAAM,aAAA,CAAA,EAAyB,OAAA,GAAM,UAAA,QAAA,EAAA,GAAQ,SAAA,cAAA,CAAA,CAAA,EAA0B,GAAG,CAAC,IAAI;AAC/E,IAAM,gBAAA,GAAe,UAAA,KAAA,CAAK,YAAY,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"}
@@ -2,7 +2,8 @@ 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(import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname, "..", "build", "prettify.js");
5
+ var currentDir = import.meta.url ? dirname(fileURLToPath(import.meta.url)) : __dirname;
6
+ var prettifyPath = join(currentDir, "..", "build", "prettify.js");
6
7
  function isPrettyFormat(format) {
7
8
  return ["pretty-timestamped", "pretty"].includes(format ?? "pretty");
8
9
  }
@@ -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// 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"}
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":";;;;AAYA,IAAM,aAAa,YAAY,MAAM,QAAQ,cAAc,YAAY,GAAG,CAAC,IAAI;AAC/E,IAAM,eAAe,KAAK,YAAY,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"}
@@ -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,QAAA,CAFqB,IAAI,CAAC,CAAC,OAAO,WAE9B,EAAc,IAAI;AAC/B"}
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,GAFe,MAAA,QAAA,CAAM,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.25",
3
+ "version": "9.0.0-next-9.26",
4
4
  "description": "Verdaccio Logger",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "node": ">=24"
34
34
  },
35
35
  "dependencies": {
36
- "@verdaccio/core": "9.0.0-next-9.25",
36
+ "@verdaccio/core": "9.0.0-next-9.26",
37
37
  "colorette": "2.0.20",
38
38
  "dayjs": "1.11.21",
39
39
  "debug": "4.4.3",
@@ -46,7 +46,7 @@
46
46
  "@verdaccio/types": "14.0.0-next-9.12",
47
47
  "cross-env": "10.1.0",
48
48
  "rimraf": "6.1.3",
49
- "vite": "8.1.5",
49
+ "vite": "8.2.1",
50
50
  "vitest": "4.1.10"
51
51
  },
52
52
  "funding": {