Remove premature optimization

This commit is contained in:
Joseph Garrone 2024-05-26 12:24:35 +02:00
parent 5670a71e6b
commit 6603852355

View File

@ -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( const accountV1RelativeDirPath = pathJoin(
"src", "src",
"main", "main",
@ -152,17 +138,33 @@ export async function buildJar(params: {
}; };
} }
if (themePropertiesFileRelativePathSet.has(fileRelativePath)) { for (const themeName of buildOptions.themeNames) {
const modifiedSourceCode = Buffer.from( if (
sourceCode fileRelativePath ===
.toString("utf8") pathJoin(
.replace(`parent=${accountV1ThemeName}`, "parent=keycloak"), "src",
"utf8" "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 }; return { modifiedSourceCode: sourceCode };
@ -171,6 +173,9 @@ export async function buildJar(params: {
return { transformCodebase_patchForUsingBuiltinAccountV1 }; return { transformCodebase_patchForUsingBuiltinAccountV1 };
})(); })();
console.log("Transforming codebase...");
const start = Date.now();
transformCodebase({ transformCodebase({
srcDirPath: buildOptions.keycloakifyBuildDirPath, srcDirPath: buildOptions.keycloakifyBuildDirPath,
destDirPath: keycloakifyBuildTmpDirPath, destDirPath: keycloakifyBuildTmpDirPath,
@ -195,6 +200,8 @@ export async function buildJar(params: {
}); });
} }
}); });
console.log(`Transforming codebase done in ${Date.now() - start}ms`);
} }
route_legacy_pages: { route_legacy_pages: {