From 6603852355a461a049cc3db72e9c0fb78f202234 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 26 May 2024 12:24:35 +0200 Subject: [PATCH] Remove premature optimization --- src/bin/keycloakify/buildJars/buildJar.ts | 53 +++++++++++++---------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/bin/keycloakify/buildJars/buildJar.ts b/src/bin/keycloakify/buildJars/buildJar.ts index e383467d..43301e9b 100644 --- a/src/bin/keycloakify/buildJars/buildJar.ts +++ b/src/bin/keycloakify/buildJars/buildJar.ts @@ -98,20 +98,6 @@ export async function buildJar(params: { }; } - const themePropertiesFileRelativePathSet = new Set( - buildOptions.themeNames.map(themeName => - pathJoin( - "src", - "main", - "resources", - "theme", - themeName, - "account", - "theme.properties" - ) - ) - ); - const accountV1RelativeDirPath = pathJoin( "src", "main", @@ -152,17 +138,33 @@ export async function buildJar(params: { }; } - if (themePropertiesFileRelativePathSet.has(fileRelativePath)) { - const modifiedSourceCode = Buffer.from( - sourceCode - .toString("utf8") - .replace(`parent=${accountV1ThemeName}`, "parent=keycloak"), - "utf8" - ); + for (const themeName of buildOptions.themeNames) { + if ( + fileRelativePath === + pathJoin( + "src", + "main", + "resources", + "theme", + themeName, + "account", + "theme.properties" + ) + ) { + const modifiedSourceCode = Buffer.from( + sourceCode + .toString("utf8") + .replace( + `parent=${accountV1ThemeName}`, + "parent=keycloak" + ), + "utf8" + ); - assert(Buffer.compare(modifiedSourceCode, sourceCode) !== 0); + assert(Buffer.compare(modifiedSourceCode, sourceCode) !== 0); - return { modifiedSourceCode }; + return { modifiedSourceCode }; + } } return { modifiedSourceCode: sourceCode }; @@ -171,6 +173,9 @@ export async function buildJar(params: { return { transformCodebase_patchForUsingBuiltinAccountV1 }; })(); + console.log("Transforming codebase..."); + const start = Date.now(); + transformCodebase({ srcDirPath: buildOptions.keycloakifyBuildDirPath, destDirPath: keycloakifyBuildTmpDirPath, @@ -195,6 +200,8 @@ export async function buildJar(params: { }); } }); + + console.log(`Transforming codebase done in ${Date.now() - start}ms`); } route_legacy_pages: {