Filter out many of the unused keycloak resources

This commit is contained in:
Joseph Garrone
2024-05-25 12:19:03 +02:00
parent caa42538a1
commit 84bb2338d1

View File

@ -72,14 +72,19 @@ export async function downloadKeycloakDefaultTheme(params: {
} }
skip_unused_node_modules: { skip_unused_node_modules: {
const dirPath = pathJoin( const nodeModulesDirPath = pathJoin(
"keycloak", "keycloak",
"common", "common",
"resources", "resources",
"node_modules" "node_modules"
); );
if (!isInside({ dirPath, filePath: fileRelativePath })) { if (
!isInside({
dirPath: nodeModulesDirPath,
filePath: fileRelativePath
})
) {
break skip_unused_node_modules; break skip_unused_node_modules;
} }
@ -89,9 +94,15 @@ export async function downloadKeycloakDefaultTheme(params: {
"patternfly-additions.min.css", "patternfly-additions.min.css",
"patternfly-additions.min.css" "patternfly-additions.min.css"
].map(fileBasename => ].map(fileBasename =>
pathJoin(dirPath, "patternfly", "dist", "css", fileBasename) pathJoin(
nodeModulesDirPath,
"patternfly",
"dist",
"css",
fileBasename
)
), ),
pathJoin(dirPath, "patternfly", "dist", "fonts") pathJoin(nodeModulesDirPath, "patternfly", "dist", "fonts")
]; ];
if ( if (
@ -106,6 +117,70 @@ export async function downloadKeycloakDefaultTheme(params: {
} }
} }
skip_unused_resources: {
if (keycloakVersion !== "24.0.4") {
break skip_unused_resources;
}
for (const dirBasename of [
"@patternfly-v5",
"@rollup",
"rollup",
"react",
"react-dom",
"shx",
".pnpm"
]) {
if (
isInside({
dirPath: pathJoin(
"keycloak",
"common",
"resources",
"node_modules",
dirBasename
),
filePath: fileRelativePath
})
) {
return;
}
}
for (const dirBasename of ["react", "react-dom"]) {
if (
isInside({
dirPath: pathJoin(
"keycloak",
"common",
"resources",
"vendor",
dirBasename
),
filePath: fileRelativePath
})
) {
return;
}
}
if (
isInside({
dirPath: pathJoin(
"keycloak",
"common",
"resources",
"node_modules",
"@patternfly",
"react-core"
),
filePath: fileRelativePath
})
) {
return;
}
}
await writeFile({ fileRelativePath }); await writeFile({ fileRelativePath });
} }
}); });