diff --git a/src/bin/keycloakify/generateTheme/bringInAccountV1.ts b/src/bin/keycloakify/generateTheme/bringInAccountV1.ts index a006791d..461ccf27 100644 --- a/src/bin/keycloakify/generateTheme/bringInAccountV1.ts +++ b/src/bin/keycloakify/generateTheme/bringInAccountV1.ts @@ -10,14 +10,15 @@ import { rmSync } from "../../tools/fs.rmSync"; type BuildOptionsLike = { cacheDirPath: string; npmWorkspaceRootDirPath: string; + keycloakifyBuildDirPath: string; }; assert(); -export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike; srcMainResourcesDirPath: string }) { - const { buildOptions, srcMainResourcesDirPath } = params; +export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike }) { + const { buildOptions } = params; - const builtinKeycloakThemeTmpDirPath = pathJoin(srcMainResourcesDirPath, "..", "tmp_yxdE2_builtin_keycloak_theme"); + const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "tmp_yxdE2_builtin_keycloak_theme"); await downloadBuiltinKeycloakTheme({ "destDirPath": builtinKeycloakThemeTmpDirPath, @@ -25,7 +26,7 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike; buildOptions }); - const accountV1DirPath = pathJoin(srcMainResourcesDirPath, "theme", accountV1ThemeName, "account"); + const accountV1DirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme", accountV1ThemeName, "account"); transformCodebase({ "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "base", "account"), diff --git a/src/bin/keycloakify/generateTheme/generateSrcMainResources.ts b/src/bin/keycloakify/generateTheme/generateSrcMainResources.ts index 98cc46c5..270ebaca 100644 --- a/src/bin/keycloakify/generateTheme/generateSrcMainResources.ts +++ b/src/bin/keycloakify/generateTheme/generateSrcMainResources.ts @@ -35,22 +35,19 @@ export type BuildOptionsLike = { urlPathname: string | undefined; npmWorkspaceRootDirPath: string; reactAppRootDirPath: string; + keycloakifyBuildDirPath: string; }; assert(); -export async function generateSrcMainResources(params: { - themeName: string; - buildOptions: BuildOptionsLike; - srcMainResourcesDirPath: string; -}): Promise { - const { themeName, buildOptions, srcMainResourcesDirPath } = params; +export async function generateSrcMainResources(params: { themeName: string; buildOptions: BuildOptionsLike }): Promise { + const { themeName, buildOptions } = params; const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath }); const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => { const { themeType } = params; - return pathJoin(srcMainResourcesDirPath, "theme", themeName, themeType); + return pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme", themeName, themeType); }; const cssGlobalsToDefine: Record = {}; @@ -245,7 +242,6 @@ export async function generateSrcMainResources(params: { } await bringInAccountV1({ - srcMainResourcesDirPath, buildOptions }); @@ -256,7 +252,14 @@ export async function generateSrcMainResources(params: { } { - const keycloakThemeJsonFilePath = pathJoin(srcMainResourcesDirPath, "META-INF", "keycloak-themes.json"); + const keycloakThemeJsonFilePath = pathJoin( + buildOptions.keycloakifyBuildDirPath, + "src", + "main", + "resources", + "META-INF", + "keycloak-themes.json" + ); try { fs.mkdirSync(pathDirname(keycloakThemeJsonFilePath)); diff --git a/src/bin/keycloakify/generateTheme/generateTheme.ts b/src/bin/keycloakify/generateTheme/generateTheme.ts index 979d4e4d..6d8336de 100644 --- a/src/bin/keycloakify/generateTheme/generateTheme.ts +++ b/src/bin/keycloakify/generateTheme/generateTheme.ts @@ -1,4 +1,3 @@ -import { join as pathJoin } from "path"; import type { BuildOptions } from "../../shared/buildOptions"; import { assert } from "tsafe/assert"; import { generateSrcMainResources, type BuildOptionsLike as BuildOptionsLike_generateSrcMainResources } from "./generateSrcMainResources"; @@ -16,11 +15,8 @@ export async function generateTheme(params: { buildOptions: BuildOptionsLike }): const [themeName, ...themeVariantNames] = buildOptions.themeNames; - const srcMainResourcesDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources"); - await generateSrcMainResources({ themeName, - srcMainResourcesDirPath, buildOptions }); @@ -28,7 +24,7 @@ export async function generateTheme(params: { buildOptions: BuildOptionsLike }): generateThemeVariations({ themeName, themeVariantName, - srcMainResourcesDirPath + buildOptions }); } } diff --git a/src/bin/keycloakify/generateTheme/generateThemeVariants.ts b/src/bin/keycloakify/generateTheme/generateThemeVariants.ts index 80cafda6..dbc916f3 100644 --- a/src/bin/keycloakify/generateTheme/generateThemeVariants.ts +++ b/src/bin/keycloakify/generateTheme/generateThemeVariants.ts @@ -1,12 +1,19 @@ import { join as pathJoin, extname as pathExtname, sep as pathSep } from "path"; import { transformCodebase } from "../../tools/transformCodebase"; +import type { BuildOptions } from "../../shared/buildOptions"; import { assert } from "tsafe/assert"; import * as fs from "fs"; -export function generateThemeVariations(params: { themeName: string; themeVariantName: string; srcMainResourcesDirPath: string }) { - const { themeName, themeVariantName, srcMainResourcesDirPath } = params; +export type BuildOptionsLike = { + keycloakifyBuildDirPath: string; +}; - const mainThemeDirPath = pathJoin(srcMainResourcesDirPath, "theme", themeName); +assert(); + +export function generateThemeVariations(params: { themeName: string; themeVariantName: string; buildOptions: BuildOptionsLike }) { + const { themeName, themeVariantName, buildOptions } = params; + + const mainThemeDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme", themeName); transformCodebase({ "srcDirPath": mainThemeDirPath, @@ -30,7 +37,14 @@ export function generateThemeVariations(params: { themeName: string; themeVarian }); { - const keycloakThemeJsonFilePath = pathJoin(srcMainResourcesDirPath, "META-INF", "keycloak-themes.json"); + const keycloakThemeJsonFilePath = pathJoin( + buildOptions.keycloakifyBuildDirPath, + "src", + "main", + "resources", + "META-INF", + "keycloak-themes.json" + ); const modifiedParsedJson = JSON.parse(fs.readFileSync(keycloakThemeJsonFilePath).toString("utf8")) as { themes: { name: string; types: string[] }[]; diff --git a/src/bin/keycloakify/keycloakify.ts b/src/bin/keycloakify/keycloakify.ts index 27115ed3..00dfcdbc 100644 --- a/src/bin/keycloakify/keycloakify.ts +++ b/src/bin/keycloakify/keycloakify.ts @@ -41,6 +41,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) }); } + // TODO: find from META-INF/keycloak-themes.json + const doesImplementAccountTheme = true; + await buildJars({ doesImplementAccountTheme, buildOptions