This commit is contained in:
Joseph Garrone 2024-05-14 04:57:38 +02:00
parent 6d57872e85
commit 11b2c6651d
2 changed files with 13 additions and 13 deletions

View File

@ -2,9 +2,11 @@ import * as fs from "fs";
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path"; import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
import type { BuildOptions } from "./buildOptions"; import type { BuildOptions } from "./buildOptions";
import { accountV1ThemeName } from "../constants";
export type BuildOptionsLike = { export type BuildOptionsLike = {
keycloakifyBuildDirPath: string; keycloakifyBuildDirPath: string;
themeNames: string[];
}; };
assert<BuildOptions extends BuildOptionsLike ? true : false>(); assert<BuildOptions extends BuildOptionsLike ? true : false>();
@ -15,11 +17,14 @@ const containerName = "keycloak-testing-container";
const keycloakVersion = "24.0.4"; const keycloakVersion = "24.0.4";
/** Files for being able to run a hot reload keycloak container */ /** Files for being able to run a hot reload keycloak container */
export function generateStartKeycloakTestingContainer(params: { jarFilePath: string; buildOptions: BuildOptionsLike }) { export function generateStartKeycloakTestingContainer(params: {
const { jarFilePath, buildOptions } = params; jarFilePath: string;
doesImplementAccountTheme: boolean;
buildOptions: BuildOptionsLike;
}) {
const { jarFilePath, doesImplementAccountTheme, buildOptions } = params;
const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme"); const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme");
const themeDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, themeRelativeDirPath);
fs.writeFileSync( fs.writeFileSync(
pathJoin(buildOptions.keycloakifyBuildDirPath, generateStartKeycloakTestingContainer.basename), pathJoin(buildOptions.keycloakifyBuildDirPath, generateStartKeycloakTestingContainer.basename),
@ -40,16 +45,10 @@ export function generateStartKeycloakTestingContainer(params: { jarFilePath: str
"$(pwd)", "$(pwd)",
pathRelative(buildOptions.keycloakifyBuildDirPath, jarFilePath) pathRelative(buildOptions.keycloakifyBuildDirPath, jarFilePath)
)}":"/opt/keycloak/providers/${pathBasename(jarFilePath)}" \\`, )}":"/opt/keycloak/providers/${pathBasename(jarFilePath)}" \\`,
...fs [...(doesImplementAccountTheme ? [accountV1ThemeName] : []), ...buildOptions.themeNames].map(
.readdirSync(themeDirPath) themeName =>
.filter(name => fs.lstatSync(pathJoin(themeDirPath, name)).isDirectory()) ` -v "${pathJoin("$(pwd)", themeRelativeDirPath, themeName).replace(/\\/g, "/")}":"/opt/keycloak/themes/${themeName}":rw \\`
.map( ),
themeName =>
` -v "${pathJoin("$(pwd)", themeRelativeDirPath, themeName).replace(
/\\/g,
"/"
)}":"/opt/keycloak/themes/${themeName}":rw \\`
),
` -it quay.io/keycloak/keycloak:${keycloakVersion} \\`, ` -it quay.io/keycloak/keycloak:${keycloakVersion} \\`,
` start-dev`, ` start-dev`,
"" ""

View File

@ -57,6 +57,7 @@ export async function main() {
generateStartKeycloakTestingContainer({ generateStartKeycloakTestingContainer({
"jarFilePath": pathJoin(buildOptions.keycloakifyBuildDirPath, lastJarFileBasename), "jarFilePath": pathJoin(buildOptions.keycloakifyBuildDirPath, lastJarFileBasename),
doesImplementAccountTheme,
buildOptions buildOptions
}); });