Fix some errors in base account v1 theme

This commit is contained in:
Joseph Garrone 2024-02-03 08:16:16 +01:00
parent bd25621b2c
commit 75c54df109
2 changed files with 63 additions and 3 deletions

View File

@ -26,6 +26,51 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
"preCacheTransform": { "preCacheTransform": {
"actionCacheId": "npm install and build", "actionCacheId": "npm install and build",
"action": async ({ destDirPath }) => { "action": async ({ destDirPath }) => {
fix_account_css: {
const accountCssFilePath = pathJoin(destDirPath, "keycloak", "account", "resources", "css", "account.css");
if (!fs.existsSync(accountCssFilePath)) {
break fix_account_css;
}
fs.writeFileSync(
accountCssFilePath,
Buffer.from(fs.readFileSync(accountCssFilePath).toString("utf8").replace("top: -34px;", "top: -34px !important;"), "utf8")
);
}
fix_account_topt: {
const totpFtlFilePath = pathJoin(destDirPath, "base", "account", "totp.ftl");
if (!fs.existsSync(totpFtlFilePath)) {
break fix_account_topt;
}
fs.writeFileSync(
totpFtlFilePath,
Buffer.from(
fs
.readFileSync(totpFtlFilePath)
.toString("utf8")
.replace(
[
" <#list totp.policy.supportedApplications as app>",
" <li>${app}</li>",
" </#list>"
].join("\n"),
[
" <#if totp.policy.supportedApplications?has_content>",
" <#list totp.policy.supportedApplications as app>",
" <li>${app}</li>",
" </#list>",
" </#if>"
].join("\n")
),
"utf8"
)
);
}
install_common_node_modules: { install_common_node_modules: {
const commonResourcesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources"); const commonResourcesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources");

View File

@ -38,7 +38,22 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike
const commonResourceFilePaths = [ const commonResourceFilePaths = [
"node_modules/patternfly/dist/css/patternfly.min.css", "node_modules/patternfly/dist/css/patternfly.min.css",
"node_modules/patternfly/dist/css/patternfly-additions.min.css" "node_modules/patternfly/dist/css/patternfly-additions.min.css",
"node_modules/patternfly/dist/css/patternfly-additions.min.css",
...[
"OpenSans-Light-webfont.woff2",
"OpenSans-Regular-webfont.woff2",
"OpenSans-Bold-webfont.woff2",
"OpenSans-Semibold-webfont.woff2",
"OpenSans-Bold-webfont.woff",
"OpenSans-Light-webfont.woff",
"OpenSans-Regular-webfont.woff",
"OpenSans-Semibold-webfont.woff",
"OpenSans-Regular-webfont.ttf",
"OpenSans-Light-webfont.ttf",
"OpenSans-Semibold-webfont.ttf",
"OpenSans-Bold-webfont.ttf"
].map(path => `node_modules/patternfly/dist/fonts/${path}`)
]; ];
for (const relativeFilePath of commonResourceFilePaths.map(path => pathJoin(...path.split("/")))) { for (const relativeFilePath of commonResourceFilePaths.map(path => pathJoin(...path.split("/")))) {
@ -49,7 +64,7 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike
fs.cpSync(pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "common", "resources", relativeFilePath), destFilePath); fs.cpSync(pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "common", "resources", relativeFilePath), destFilePath);
} }
const resourceFilePaths = ["css/account.css"]; const resourceFilePaths = ["css/account.css", "img/icon-sidebar-active.png", "img/logo.png"];
for (const relativeFilePath of resourceFilePaths.map(path => pathJoin(...path.split("/")))) { for (const relativeFilePath of resourceFilePaths.map(path => pathJoin(...path.split("/")))) {
const destFilePath = pathJoin(accountV1DirPath, "resources", relativeFilePath); const destFilePath = pathJoin(accountV1DirPath, "resources", relativeFilePath);
@ -69,7 +84,7 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike
"", "",
"locales=ar,ca,cs,da,de,en,es,fr,fi,hu,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN", "locales=ar,ca,cs,da,de,en,es,fr,fi,hu,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN",
"", "",
"styles=" + [...resourceFilePaths, ...commonResourceFilePaths.map(path => `resources_common/${path}`)].join(" "), "styles=" + [...resourceFilePaths, ...commonResourceFilePaths.map(path => `resources-common/${path}`)].join(" "),
"", "",
"##### css classes for form buttons", "##### css classes for form buttons",
"# main class used for all buttons", "# main class used for all buttons",