Include keycloakfiy version number in kcContext (for debug purpose)

This commit is contained in:
garronej 2023-04-04 01:40:55 +02:00
parent f6c2ccb0d6
commit 49e495dbbe
8 changed files with 22 additions and 6 deletions

View File

@ -6,6 +6,7 @@ export type KcContext = KcContext.Password | KcContext.Account;
export declare namespace KcContext {
export type Common = {
keycloakifyVersion: string;
locale?: {
supported: {
url: string;

View File

@ -7,6 +7,7 @@ import type { KcContext } from "./KcContext";
const PUBLIC_URL = process.env["PUBLIC_URL"] ?? "/";
export const kcContextCommonMock: KcContext.Common = {
"keycloakifyVersion": "0.0.0",
"url": {
"resourcesPath": pathJoin(PUBLIC_URL, mockTestingResourcesPath),
"resourcesCommonPath": pathJoin(PUBLIC_URL, mockTestingResourcesCommonPath),

View File

@ -119,6 +119,7 @@
</#if>
out["pageId"] = "PAGE_ID_xIgLsPgGId9D8e";
out["keycloakifyVersion"] = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
return out;

View File

@ -53,8 +53,9 @@ export function generateFtlFilesCodeFactory(params: {
//NOTE: Expected to be an empty object if external assets mode is enabled.
cssGlobalsToDefine: Record<string, string>;
buildOptions: BuildOptionsLike;
keycloakifyVersion: string;
}) {
const { cssGlobalsToDefine, indexHtmlCode, buildOptions } = params;
const { cssGlobalsToDefine, indexHtmlCode, buildOptions, keycloakifyVersion } = params;
const $ = cheerio.load(indexHtmlCode);
@ -128,7 +129,8 @@ export function generateFtlFilesCodeFactory(params: {
.replace(
"CUSTOM_USER_ATTRIBUTES_eKsIY4ZsZ4xeM",
buildOptions.customUserAttributes.length === 0 ? "" : ", " + buildOptions.customUserAttributes.map(name => `"${name}"`).join(", ")
),
)
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion),
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
"<#if scripts??>",
" <#list scripts as script>",
@ -161,7 +163,6 @@ export function generateFtlFilesCodeFactory(params: {
Object.entries({
...replaceValueBySearchValue,
//If updated, don't forget to change in the ftl script as well.
"PAGE_ID_xIgLsPgGId9D8e": pageId
}).map(([searchValue, replaceValue]) => (ftlCode = ftlCode.replace(searchValue, replaceValue)));

View File

@ -54,8 +54,9 @@ export async function generateKeycloakThemeResources(params: {
emailThemeSrcDirPath: string | undefined;
keycloakVersion: string;
buildOptions: BuildOptionsLike;
keycloakifyVersion: string;
}): Promise<{ doBundlesEmailTemplate: boolean }> {
const { reactAppBuildDirPath, keycloakThemeBuildingDirPath, emailThemeSrcDirPath, keycloakVersion, buildOptions } = params;
const { reactAppBuildDirPath, keycloakThemeBuildingDirPath, emailThemeSrcDirPath, keycloakVersion, buildOptions, keycloakifyVersion } = params;
const getThemeDirPath = (themeType: ThemeType | "email") =>
pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", buildOptions.themeName, themeType);
@ -138,7 +139,8 @@ export async function generateKeycloakThemeResources(params: {
const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
"indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
"cssGlobalsToDefine": allCssGlobalsToDefine,
buildOptions
buildOptions,
keycloakifyVersion
});
return generateFtlFilesCode;

View File

@ -11,6 +11,7 @@ import jar from "../tools/jar";
import { assert } from "tsafe/assert";
import { Equals } from "tsafe";
import { getEmailThemeSrcDirPath } from "../getSrcDirPath";
import { getProjectRoot } from "../tools/getProjectRoot";
export async function main() {
const { isSilent, hasExternalAssets } = getCliOptions(process.argv.slice(2));
@ -38,7 +39,14 @@ export async function main() {
})(),
"reactAppBuildDirPath": buildOptions.reactAppBuildDirPath,
buildOptions,
"keycloakVersion": buildOptions.keycloakVersionDefaultAssets
"keycloakVersion": buildOptions.keycloakVersionDefaultAssets,
"keycloakifyVersion": (() => {
const version = JSON.parse(fs.readFileSync(pathJoin(getProjectRoot(), "package.json")).toString("utf8"))["version"];
assert(typeof version === "string");
return version;
})()
});
const { jarFilePath } = generateJavaStackFiles({

View File

@ -36,6 +36,7 @@ export type KcContext =
export declare namespace KcContext {
export type Common = {
keycloakifyVersion: string;
url: {
loginAction: string;
resourcesPath: string;

View File

@ -101,6 +101,7 @@ const attributes: Attribute[] = [
const attributesByName = Object.fromEntries(attributes.map(attribute => [attribute.name, attribute])) as any;
export const kcContextCommonMock: KcContext.Common = {
"keycloakifyVersion": "0.0.0",
"url": {
"loginAction": "#",
"resourcesPath": pathJoin(PUBLIC_URL, mockTestingResourcesPath),