From 7ac91e452cb950f8b9dbb4ada2cd20a1c4ed0252 Mon Sep 17 00:00:00 2001 From: Gabriel-Ladzaretti <97394622+Gabriel-Ladzaretti@users.noreply.github.com> Date: Tue, 28 Jun 2022 16:49:42 +0300 Subject: [PATCH] docs(config): Don't show [template] for long strings (#16224) --- lib/logger/index.spec.ts | 5 +++-- lib/logger/utils.ts | 4 +--- tools/docs/config.ts | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/logger/index.spec.ts b/lib/logger/index.spec.ts index 9b66e5c4c4..a6c8368e8e 100644 --- a/lib/logger/index.spec.ts +++ b/lib/logger/index.spec.ts @@ -160,13 +160,14 @@ describe('logger/index', () => { constructor(public field: string) {} } + const prBody = 'test'; logger.error({ foo: 'secret"password', bar: ['somethingelse', 'secret"password'], npmToken: 'token', buffer: Buffer.from('test'), content: 'test', - prBody: 'test', + prBody, secrets: { foo: 'barsecret', }, @@ -181,7 +182,7 @@ describe('logger/index', () => { expect(logged.npmToken).not.toBe('token'); expect(logged.buffer).toBe('[content]'); expect(logged.content).toBe('[content]'); - expect(logged.prBody).toBe('[Template]'); + expect(logged.prBody).toBe(prBody); expect(logged.secrets.foo).toBe('***********'); expect(logged.someFn).toBe('[function]'); expect(logged.someObject.field).toBe('**redacted**'); diff --git a/lib/logger/utils.ts b/lib/logger/utils.ts index d797fbe59a..90e0e263f7 100644 --- a/lib/logger/utils.ts +++ b/lib/logger/utils.ts @@ -39,7 +39,7 @@ export class ProblemStream extends Stream { this._problems = []; } } -const templateFields = ['prBody']; + const contentFields = [ 'content', 'contents', @@ -148,8 +148,6 @@ export function sanitizeValue( curValue = '***********'; } else if (contentFields.includes(key)) { curValue = '[content]'; - } else if (templateFields.includes(key)) { - curValue = '[Template]'; } else if (key === 'secrets') { curValue = {}; Object.keys(val).forEach((secretKey) => { diff --git a/tools/docs/config.ts b/tools/docs/config.ts index 110773c666..d4c5a2a007 100644 --- a/tools/docs/config.ts +++ b/tools/docs/config.ts @@ -116,9 +116,6 @@ function genTable(obj: [string, string][], type: string, def: any): string { ) { el[1] = `<code>${el[1]}</code>`; } - if (type === 'string' && el[0] === 'default' && el[1].length > 200) { - el[1] = `[template]`; - } // objects and arrays should be printed in JSON notation if ((type === 'object' || type === 'array') && el[0] === 'default') { // only show array and object defaults if they are not null and are not empty -- GitLab