add possibility to add custom properties to theme.properties file

This commit is contained in:
Alex Oliynyk 2021-07-06 15:52:14 +03:00
parent fffb6d5b5e
commit 551e9c041e
3 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,7 @@ export function main() {
console.log("🔏 Building the keycloak theme...⌚"); console.log("🔏 Building the keycloak theme...⌚");
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? []; const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
const extraThemeProperties: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraThemeProperties"] ?? [];
generateKeycloakThemeResources({ generateKeycloakThemeResources({
keycloakThemeBuildingDirPath, keycloakThemeBuildingDirPath,
@ -55,7 +56,8 @@ export function main() {
}; };
})(), })(),
extraPagesId extraPagesId,
extraThemeProperties
}); });
const { jarFilePath } = generateJavaStackFiles({ const { jarFilePath } = generateJavaStackFiles({

View File

@ -23,12 +23,13 @@ export function generateKeycloakThemeResources(
//If urlOrigin is not undefined then it means --externals-assets //If urlOrigin is not undefined then it means --externals-assets
urlOrigin: undefined | string; urlOrigin: undefined | string;
extraPagesId: string[]; extraPagesId: string[];
extraThemeProperties: string[];
} }
) { ) {
const { const {
themeName, reactAppBuildDirPath, keycloakThemeBuildingDirPath, themeName, reactAppBuildDirPath, keycloakThemeBuildingDirPath,
urlPathname, urlOrigin, extraPagesId urlPathname, urlOrigin, extraPagesId, extraThemeProperties
} = params; } = params;
const themeDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName, "login"); const themeDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName, "login");
@ -166,7 +167,10 @@ export function generateKeycloakThemeResources(
fs.writeFileSync( fs.writeFileSync(
pathJoin(themeDirPath, "theme.properties"), pathJoin(themeDirPath, "theme.properties"),
Buffer.from("parent=keycloak", "utf8") Buffer.from(
"parent=keycloak".concat("\n\n", extraThemeProperties.join("\n\n")),
"utf8"
)
); );
} }

View File

@ -14,6 +14,7 @@ generateKeycloakThemeResources({
"keycloakThemeBuildingDirPath": pathJoin(sampleReactProjectDirPath, "build_keycloak_theme"), "keycloakThemeBuildingDirPath": pathJoin(sampleReactProjectDirPath, "build_keycloak_theme"),
"urlPathname": "/keycloakify-demo-app/", "urlPathname": "/keycloakify-demo-app/",
"urlOrigin": undefined, "urlOrigin": undefined,
"extraPagesId": ["my-custom-page.ftl"] "extraPagesId": ["my-custom-page.ftl"],
"extraThemeProperties": ["env=test"]
}); });