This commit is contained in:
parent
6d57872e85
commit
11b2c6651d
@ -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,15 +45,9 @@ 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)
|
|
||||||
.filter(name => fs.lstatSync(pathJoin(themeDirPath, name)).isDirectory())
|
|
||||||
.map(
|
|
||||||
themeName =>
|
themeName =>
|
||||||
` -v "${pathJoin("$(pwd)", themeRelativeDirPath, themeName).replace(
|
` -v "${pathJoin("$(pwd)", themeRelativeDirPath, themeName).replace(/\\/g, "/")}":"/opt/keycloak/themes/${themeName}":rw \\`
|
||||||
/\\/g,
|
|
||||||
"/"
|
|
||||||
)}":"/opt/keycloak/themes/${themeName}":rw \\`
|
|
||||||
),
|
),
|
||||||
` -it quay.io/keycloak/keycloak:${keycloakVersion} \\`,
|
` -it quay.io/keycloak/keycloak:${keycloakVersion} \\`,
|
||||||
` start-dev`,
|
` start-dev`,
|
||||||
|
@ -57,6 +57,7 @@ export async function main() {
|
|||||||
|
|
||||||
generateStartKeycloakTestingContainer({
|
generateStartKeycloakTestingContainer({
|
||||||
"jarFilePath": pathJoin(buildOptions.keycloakifyBuildDirPath, lastJarFileBasename),
|
"jarFilePath": pathJoin(buildOptions.keycloakifyBuildDirPath, lastJarFileBasename),
|
||||||
|
doesImplementAccountTheme,
|
||||||
buildOptions
|
buildOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user