From 9864473fdd3593d70dc167ffb6220a28ca11b76e Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Fri, 30 Aug 2024 21:13:19 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=AB=20Quiet=20webp=20warnings=20(#1499?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only show webp warnings on debug by default. Can turn this back on with an errorRule. --- .changeset/rotten-tools-live.md | 5 +++++ packages/myst-cli/src/store/types.ts | 2 +- packages/myst-cli/src/utils/addWarningForFile.ts | 5 ++++- packages/myst-cli/src/utils/imagemagick.ts | 6 +++--- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changeset/rotten-tools-live.md diff --git a/.changeset/rotten-tools-live.md b/.changeset/rotten-tools-live.md new file mode 100644 index 000000000..177003ad5 --- /dev/null +++ b/.changeset/rotten-tools-live.md @@ -0,0 +1,5 @@ +--- +"myst-cli": patch +--- + +Quiet webp warnings to debug diff --git a/packages/myst-cli/src/store/types.ts b/packages/myst-cli/src/store/types.ts index a772eaa8b..5e6b6f4a4 100644 --- a/packages/myst-cli/src/store/types.ts +++ b/packages/myst-cli/src/store/types.ts @@ -8,7 +8,7 @@ export type ExternalLinkResult = { statusText?: string; }; -export type WarningKind = 'error' | 'warn' | 'info'; +export type WarningKind = 'error' | 'warn' | 'info' | 'debug'; export type BuildWarning = { message: string; diff --git a/packages/myst-cli/src/utils/addWarningForFile.ts b/packages/myst-cli/src/utils/addWarningForFile.ts index e1370cf25..826119d95 100644 --- a/packages/myst-cli/src/utils/addWarningForFile.ts +++ b/packages/myst-cli/src/utils/addWarningForFile.ts @@ -53,9 +53,12 @@ export function addWarningForFile( session.log.error(`⛔️ ${prefix}${formatted}`); break; case 'warn': - default: session.log.warn(`⚠️ ${prefix}${formatted}`); break; + case 'debug': + default: + session.log.debug(`${prefix}${formatted}`); + break; } if (opts?.ruleId) { session.log.debug( diff --git a/packages/myst-cli/src/utils/imagemagick.ts b/packages/myst-cli/src/utils/imagemagick.ts index 229b9c889..2f646cfbd 100644 --- a/packages/myst-cli/src/utils/imagemagick.ts +++ b/packages/myst-cli/src/utils/imagemagick.ts @@ -173,7 +173,7 @@ export async function convertImageToWebp( session, image, `Image is too large (${inMB} MB) to convert to webp (build will be slow).`, - 'warn', + (isGif2webpAvailable() && imageExt === '.gif') || isWebpAvailable() ? 'warn' : 'debug', { ruleId: RuleId.imageFormatOptimizes }, ); return null; @@ -227,7 +227,7 @@ export async function convertImageToWebp( session, image, `Could not convert from image ${image} to webp:\ngif2webp is required\n`, - 'warn', + 'debug', { ruleId: RuleId.imageFormatOptimizes }, ); return null; @@ -239,7 +239,7 @@ export async function convertImageToWebp( session, image, `Could not convert from image ${image} to webp:\ncwebp is required\n`, - 'warn', + 'debug', { ruleId: RuleId.imageFormatOptimizes }, ); return null;