diff --git a/package.json b/package.json index 51a9a550..65b3b207 100755 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "cheerio": "^1.0.0-rc.5", "evt": "2.0.0-beta.15", "minimal-polyfills": "^2.1.6", - "powerhooks": "^0.0.19", + "path": "^0.12.7", + "powerhooks": "^0.0.20", "scripting-tools": "^0.19.13", "tss-react": "^0.0.11" } diff --git a/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts b/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts index 3a7168aa..0225291f 100644 --- a/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts +++ b/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts @@ -11,6 +11,7 @@ import { builtinThemesUrl } from "../install-builtin-keycloak-themes"; import { downloadAndUnzip } from "../tools/downloadAndUnzip"; import * as child_process from "child_process"; import { ftlValuesGlobalName } from "./ftlValuesGlobalName"; +import { resourcesCommonPath, resourcesPath, subDirOfPublicDirBasename } from "../../lib/kcMockContext/urlResourcesPath"; export function generateKeycloakThemeResources( params: { @@ -90,11 +91,54 @@ export function generateKeycloakThemeResources( "destDirPath": tmpDirPath }); + const themeResourcesDirPath= pathJoin(themeDirPath, "resources"); + transformCodebase({ "srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"), - "destDirPath": pathJoin(themeDirPath, "resources") + "destDirPath": themeResourcesDirPath }); + //const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public", "keycloak_static"); + + const reactAppPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public"); + + + + transformCodebase({ + "srcDirPath": themeResourcesDirPath, + "destDirPath": pathJoin( + reactAppPublicDirPath, + resourcesPath + ) + }); + + transformCodebase({ + "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"), + "destDirPath": pathJoin( + reactAppPublicDirPath, + resourcesCommonPath + ) + }); + + const keycloakResourcesWithinPublicDirPath = + pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename); + + fs.writeFileSync( + pathJoin(keycloakResourcesWithinPublicDirPath, ".gitignore"), + Buffer.from([ + resourcesPath, + resourcesCommonPath + ].join("\n")) + ); + + fs.writeFileSync( + pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"), + Buffer.from([ + "This is just a test folder that helps develop", + "the login and register page without having to yarn build" + ].join(" ")) + ); + child_process.execSync(`rm -r ${tmpDirPath}`); } diff --git a/src/lib/components/Error.tsx b/src/lib/components/Error.tsx index a07f834e..ad5b83fd 100644 --- a/src/lib/components/Error.tsx +++ b/src/lib/components/Error.tsx @@ -3,24 +3,20 @@ import { memo } from "react"; import { Template } from "./Template"; import type { KcProps } from "./KcProps"; import { assert } from "../tools/assert"; -import { kcContext } from "../kcContext"; +import type { KcContext } from "../KcContext"; import { useKcMessage } from "../i18n/useKcMessage"; -export const Error = memo((props: KcProps) => { +export const Error = memo(({ kcContext, ...props }: { kcContext: KcContext.Error; } & KcProps) => { const { msg } = useKcMessage(); - assert( - kcContext !== undefined && - kcContext.pageId === "error.ftl" && - kcContext.message !== undefined - ); + assert(kcContext.message !== undefined); const { message, client } = kcContext; return (