From ad3cf3fab8a98f1a4892bdac2cbe76c7b2a562ff Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Mon, 13 May 2024 23:21:27 +0200 Subject: [PATCH] Fix several logical errors --- src/bin/keycloakify/buildJars/buildJar.ts | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/bin/keycloakify/buildJars/buildJar.ts b/src/bin/keycloakify/buildJars/buildJar.ts index a077dedf..c2dbb6d1 100644 --- a/src/bin/keycloakify/buildJars/buildJar.ts +++ b/src/bin/keycloakify/buildJars/buildJar.ts @@ -29,24 +29,23 @@ export async function buildJar(params: { const keycloakifyBuildTmpDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "..", jarFileBasename.replace(".jar", "")); - { - if (!existsSync(buildOptions.keycloakifyBuildDirPath)) { - await fs.mkdir(buildOptions.keycloakifyBuildDirPath, { "recursive": true }); - } - - await fs.writeFile(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8")); + if (existsSync(keycloakifyBuildTmpDirPath)) { + await fs.rm(keycloakifyBuildTmpDirPath, { "recursive": true }); } + await fs.mkdir(keycloakifyBuildTmpDirPath, { "recursive": true }); + await fs.writeFile(pathJoin(keycloakifyBuildTmpDirPath, ".gitignore"), Buffer.from("*", "utf8")); + const srcMainResourcesRelativeDirPath = pathJoin("src", "main", "resources"); { const keycloakThemesJsonFilePath = pathJoin(srcMainResourcesRelativeDirPath, "META-INF", "keycloak-themes.json"); const themePropertiesFilePathSet = new Set( - ...buildOptions.themeNames.map(themeName => pathJoin(srcMainResourcesRelativeDirPath, "themes", themeName, "account", "theme.properties")) + ...buildOptions.themeNames.map(themeName => pathJoin(srcMainResourcesRelativeDirPath, "theme", themeName, "account", "theme.properties")) ); - const accountV1RelativeDirPath = pathJoin(srcMainResourcesRelativeDirPath, "themes", accountV1ThemeName); + const accountV1RelativeDirPath = pathJoin(srcMainResourcesRelativeDirPath, "theme", accountV1ThemeName); transformCodebase({ "srcDirPath": buildOptions.keycloakifyBuildDirPath, @@ -108,7 +107,14 @@ export async function buildJar(params: { (["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId => buildOptions.themeNames.map(themeName => { - const ftlFilePath = pathJoin(srcMainResourcesRelativeDirPath, "themes", themeName, "login", pageId); + const ftlFilePath = pathJoin( + buildOptions.keycloakifyBuildDirPath, + srcMainResourcesRelativeDirPath, + "theme", + themeName, + "login", + pageId + ); const ftlFileContent = readFileSync(ftlFilePath).toString("utf8"); @@ -123,7 +129,7 @@ export async function buildJar(params: { })(); const modifiedFtlFileContent = ftlFileContent.replace( - `out["pageId"] = "${pageId}";`, + `out["pageId"] = "\${pageId}";`, `out["pageId"] = "${pageId}"; out["realPageId"] = "${realPageId}";` );