Compat with Keycloak 16 (and probably 17, 18) #79
This commit is contained in:
parent
40237374a8
commit
fb0be3272c
@ -1,6 +1,6 @@
|
||||
import { transformCodebase } from "../tools/transformCodebase";
|
||||
import * as fs from "fs";
|
||||
import { join as pathJoin } from "path";
|
||||
import { join as pathJoin, basename as pathBasename } from "path";
|
||||
import { replaceImportsInCssCode, replaceImportsFromStaticInJsCode } from "./replaceImportFromStatic";
|
||||
import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl";
|
||||
import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme";
|
||||
@ -112,20 +112,22 @@ export function generateKeycloakThemeResources(params: {
|
||||
const reactAppPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public");
|
||||
|
||||
transformCodebase({
|
||||
"srcDirPath": themeResourcesDirPath,
|
||||
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath),
|
||||
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
|
||||
"destDirPath": pathJoin(themeResourcesDirPath, pathBasename(resourcesCommonPath)),
|
||||
});
|
||||
|
||||
transformCodebase({
|
||||
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
|
||||
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesCommonPath),
|
||||
"srcDirPath": themeResourcesDirPath,
|
||||
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath),
|
||||
});
|
||||
|
||||
const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename);
|
||||
|
||||
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(" ")),
|
||||
Buffer.from(
|
||||
["This is just a test folder that helps develop", "the login and register page without having to run a Keycloak container"].join(" "),
|
||||
),
|
||||
);
|
||||
|
||||
fs.writeFileSync(pathJoin(keycloakResourcesWithinPublicDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
||||
|
@ -7,6 +7,9 @@ import { exclude } from "tsafe/exclude";
|
||||
import { assert } from "tsafe/assert";
|
||||
import type { ExtendsKcContextBase } from "./getKcContextFromWindow";
|
||||
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
||||
import { pathJoin } from "../tools/pathJoin";
|
||||
import { pathBasename } from "../tools/pathBasename";
|
||||
import { resourcesCommonPath } from "./kcContextMocks/urlResourcesPath";
|
||||
|
||||
export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: {
|
||||
mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"];
|
||||
@ -93,5 +96,13 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
|
||||
return { kcContext };
|
||||
}
|
||||
|
||||
return { "kcContext": getKcContextFromWindow<KcContextExtended>() };
|
||||
const kcContext = getKcContextFromWindow<KcContextExtended>();
|
||||
|
||||
if (kcContext !== undefined) {
|
||||
const { url } = kcContext;
|
||||
|
||||
url.resourcesCommonPath = pathJoin(url.resourcesPath, pathBasename(resourcesCommonPath));
|
||||
}
|
||||
|
||||
return { kcContext };
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ import { pathJoin } from "../../tools/pathJoin";
|
||||
|
||||
export const subDirOfPublicDirBasename = "keycloak_static";
|
||||
export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources");
|
||||
export const resourcesCommonPath = pathJoin(subDirOfPublicDirBasename, "resources_common");
|
||||
export const resourcesCommonPath = pathJoin(resourcesPath, "resources_common");
|
||||
|
3
src/lib/tools/pathBasename.ts
Normal file
3
src/lib/tools/pathBasename.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function pathBasename(path: string) {
|
||||
return path.split("/").reverse()[0];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user