From 72424b623c6f97db26b1b93eefb74b1b72f417d8 Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Fri, 27 Sep 2024 12:06:14 -0400 Subject: [PATCH] fix(class-name-updater): ignore css vars when running in v6 mode --- packages/class-name-updater/src/classNameUpdate.ts | 7 ++++--- packages/class-name-updater/test/test.css | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/class-name-updater/src/classNameUpdate.ts b/packages/class-name-updater/src/classNameUpdate.ts index 01ee76bbf..bc2df0676 100644 --- a/packages/class-name-updater/src/classNameUpdate.ts +++ b/packages/class-name-updater/src/classNameUpdate.ts @@ -16,10 +16,11 @@ export async function classNameUpdate( const isPostV5 = pfVersion > 5; const previousVersion = isPostV5 ? "-v" + (pfVersion - 1) : ""; const classNameMatches = "[cul]"; - const cssVarMatches = `${classNameMatches}|global|theme|color`; + const cssVarMatches = `${classNameMatches}|global|theme|color|chart`; const bodyMatches = isPostV5 ? classNameMatches : cssVarMatches; + const cssVarStart = isPostV5 ? "[^-]" : ""; const changeNeededRegex = new RegExp( - "(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`, + `(${cssVarStart})` + "(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`, "g" ); const newVersion = pfVersion || 5; @@ -47,7 +48,7 @@ export async function classNameUpdate( const newContent = fileContent.replace( changeNeededRegex, - `$1pf-v${newVersion}-$2-` + `$1$2pf-v${newVersion}-$3-` ); printDiff(file, fileContent, newContent, changeNeededRegex); diff --git a/packages/class-name-updater/test/test.css b/packages/class-name-updater/test/test.css index b4b1b7172..cb50e0ccd 100644 --- a/packages/class-name-updater/test/test.css +++ b/packages/class-name-updater/test/test.css @@ -11,6 +11,7 @@ } .pf-c-console__actions > div { margin-right: var(--pf-v5-global--spacer--sm); + box-shadow: var(--pf-v5-c-wizard__toggle--BoxShadow); } .pf-m-selectable {