Bugfix: keycloak_build that grow and grow in size

This commit is contained in:
Joseph Garrone 2021-03-19 22:39:32 +01:00
parent 0e1d919f7e
commit 5ced0e2809
2 changed files with 29 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import { downloadAndUnzip } from "../tools/downloadAndUnzip";
import * as child_process from "child_process"; import * as child_process from "child_process";
import { ftlValuesGlobalName } from "./ftlValuesGlobalName"; import { ftlValuesGlobalName } from "./ftlValuesGlobalName";
import { resourcesCommonPath, resourcesPath, subDirOfPublicDirBasename } from "../../lib/kcContextMocks/urlResourcesPath"; import { resourcesCommonPath, resourcesPath, subDirOfPublicDirBasename } from "../../lib/kcContextMocks/urlResourcesPath";
import { isInside } from "../tools/isInside";
export function generateKeycloakThemeResources( export function generateKeycloakThemeResources(
params: { params: {
@ -32,6 +33,17 @@ export function generateKeycloakThemeResources(
"srcDirPath": reactAppBuildDirPath, "srcDirPath": reactAppBuildDirPath,
"transformSourceCode": ({ filePath, sourceCode }) => { "transformSourceCode": ({ filePath, sourceCode }) => {
//NOTE: Prevent cycles, excludes the folder we generated for debug in public/
if (
isInside({
"dirPath": pathJoin(reactAppBuildDirPath, subDirOfPublicDirBasename),
filePath
})
) {
return undefined;
}
if (/\.css?$/i.test(filePath)) { if (/\.css?$/i.test(filePath)) {
const { cssGlobalsToDefine, fixedCssCode } = replaceImportFromStaticInCssCode( const { cssGlobalsToDefine, fixedCssCode } = replaceImportFromStaticInCssCode(
@ -91,7 +103,7 @@ export function generateKeycloakThemeResources(
"destDirPath": tmpDirPath "destDirPath": tmpDirPath
}); });
const themeResourcesDirPath= pathJoin(themeDirPath, "resources"); const themeResourcesDirPath = pathJoin(themeDirPath, "resources");
transformCodebase({ transformCodebase({
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"), "srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"),

14
src/bin/tools/isInside.ts Normal file
View File

@ -0,0 +1,14 @@
import { relative as pathRelative } from "path";
export function isInside(
params: {
dirPath: string;
filePath: string;
}
) {
const { dirPath, filePath } = params;
return !pathRelative(dirPath, filePath).startsWith("..");
}