Minor refactor (changelog ignore)

This commit is contained in:
garronej 2022-07-30 00:51:11 +02:00
parent de53f1ff40
commit 67e3dca0c3
5 changed files with 15 additions and 15 deletions

View File

@ -5,7 +5,7 @@ import { replaceImportsInCssCode, replaceImportsFromStaticInJsCode } from "./rep
import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl"; import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl";
import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme"; import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme";
import * as child_process from "child_process"; import * as child_process from "child_process";
import { resourcesCommonPath, resourcesPath, subDirOfPublicDirBasename } from "../urlResourcesPath"; import { mockTestingResourcesCommonPath, mockTestingResourcesPath, mockTestingSubDirOfPublicDirBasename } from "../mockTestingResourcesPath";
import { isInside } from "../tools/isInside"; import { isInside } from "../tools/isInside";
export function generateKeycloakThemeResources(params: { export function generateKeycloakThemeResources(params: {
@ -44,7 +44,7 @@ export function generateKeycloakThemeResources(params: {
if ( if (
urlOrigin === undefined && urlOrigin === undefined &&
isInside({ isInside({
"dirPath": pathJoin(reactAppBuildDirPath, subDirOfPublicDirBasename), "dirPath": pathJoin(reactAppBuildDirPath, mockTestingSubDirOfPublicDirBasename),
filePath, filePath,
}) })
) { ) {
@ -137,15 +137,15 @@ export function generateKeycloakThemeResources(params: {
transformCodebase({ transformCodebase({
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"), "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
"destDirPath": pathJoin(themeResourcesDirPath, pathBasename(resourcesCommonPath)), "destDirPath": pathJoin(themeResourcesDirPath, pathBasename(mockTestingResourcesCommonPath)),
}); });
transformCodebase({ transformCodebase({
"srcDirPath": themeResourcesDirPath, "srcDirPath": themeResourcesDirPath,
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath), "destDirPath": pathJoin(reactAppPublicDirPath, mockTestingResourcesPath),
}); });
const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename); const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, mockTestingSubDirOfPublicDirBasename);
fs.writeFileSync( fs.writeFileSync(
pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"), pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"),

View File

@ -0,0 +1,5 @@
import { pathJoin } from "./tools/pathJoin";
export const mockTestingSubDirOfPublicDirBasename = "keycloak_static";
export const mockTestingResourcesPath = pathJoin(mockTestingSubDirOfPublicDirBasename, "resources");
export const mockTestingResourcesCommonPath = pathJoin(mockTestingResourcesPath, "resources_common");

View File

@ -1,5 +0,0 @@
import { pathJoin } from "./tools/pathJoin";
export const subDirOfPublicDirBasename = "keycloak_static";
export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources");
export const resourcesCommonPath = pathJoin(resourcesPath, "resources_common");

View File

@ -9,7 +9,7 @@ import type { ExtendsKcContextBase } from "./getKcContextFromWindow";
import { getKcContextFromWindow } from "./getKcContextFromWindow"; import { getKcContextFromWindow } from "./getKcContextFromWindow";
import { pathJoin } from "../../bin/tools/pathJoin"; import { pathJoin } from "../../bin/tools/pathJoin";
import { pathBasename } from "../tools/pathBasename"; import { pathBasename } from "../tools/pathBasename";
import { resourcesCommonPath } from "../../bin/urlResourcesPath"; import { mockTestingResourcesCommonPath } from "../../bin/mockTestingResourcesPath";
export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: { export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: {
mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"]; mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"];
@ -101,7 +101,7 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
if (kcContext !== undefined) { if (kcContext !== undefined) {
const { url } = kcContext; const { url } = kcContext;
url.resourcesCommonPath = pathJoin(url.resourcesPath, pathBasename(resourcesCommonPath)); url.resourcesCommonPath = pathJoin(url.resourcesPath, pathBasename(mockTestingResourcesCommonPath));
} }
return { kcContext }; return { kcContext };

View File

@ -1,7 +1,7 @@
import "minimal-polyfills/Object.fromEntries"; import "minimal-polyfills/Object.fromEntries";
import type { KcContextBase, Attribute } from "../KcContextBase"; import type { KcContextBase, Attribute } from "../KcContextBase";
//NOTE: Aside because we want to be able to import them from node //NOTE: Aside because we want to be able to import them from node
import { resourcesCommonPath, resourcesPath } from "../../../bin/urlResourcesPath"; import { mockTestingResourcesCommonPath, mockTestingResourcesPath } from "../../../bin/mockTestingResourcesPath";
import { id } from "tsafe/id"; import { id } from "tsafe/id";
import { pathJoin } from "../../../bin/tools/pathJoin"; import { pathJoin } from "../../../bin/tools/pathJoin";
@ -10,8 +10,8 @@ const PUBLIC_URL = process.env["PUBLIC_URL"] ?? "/";
export const kcContextCommonMock: KcContextBase.Common = { export const kcContextCommonMock: KcContextBase.Common = {
"url": { "url": {
"loginAction": "#", "loginAction": "#",
"resourcesPath": pathJoin(PUBLIC_URL, resourcesPath), "resourcesPath": pathJoin(PUBLIC_URL, mockTestingResourcesPath),
"resourcesCommonPath": pathJoin(PUBLIC_URL, resourcesCommonPath), "resourcesCommonPath": pathJoin(PUBLIC_URL, mockTestingResourcesCommonPath),
"loginRestartFlowUrl": "/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg", "loginRestartFlowUrl": "/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg",
"loginUrl": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg", "loginUrl": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg",
}, },