This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import type { AccountThemePageId } from "keycloakify/bin/keycloakify/generateFtl";
|
import type { AccountThemePageId, ThemeType } from "keycloakify/bin/keycloakify/generateFtl";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { Equals } from "tsafe";
|
import type { Equals } from "tsafe";
|
||||||
|
|
||||||
@ -7,6 +7,7 @@ export type KcContext = KcContext.Password | KcContext.Account;
|
|||||||
export declare namespace KcContext {
|
export declare namespace KcContext {
|
||||||
export type Common = {
|
export type Common = {
|
||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
|
themeType: "account";
|
||||||
locale?: {
|
locale?: {
|
||||||
supported: {
|
supported: {
|
||||||
url: string;
|
url: string;
|
||||||
@ -84,4 +85,15 @@ export declare namespace KcContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
assert<Equals<KcContext["pageId"], AccountThemePageId>>();
|
{
|
||||||
|
type Got = KcContext["pageId"];
|
||||||
|
type Expected = AccountThemePageId;
|
||||||
|
|
||||||
|
type OnlyInGot = Exclude<Got, Expected>;
|
||||||
|
type OnlyInExpected = Exclude<Expected, Got>;
|
||||||
|
|
||||||
|
assert<Equals<OnlyInGot, never>>();
|
||||||
|
assert<Equals<OnlyInExpected, never>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
assert<KcContext["themeType"] extends ThemeType ? true : false>();
|
||||||
|
@ -7,8 +7,6 @@ import { pathBasename } from "keycloakify/tools/pathBasename";
|
|||||||
import { resourcesCommonDirPathRelativeToPublicDir } from "keycloakify/bin/mockTestingResourcesPath";
|
import { resourcesCommonDirPathRelativeToPublicDir } from "keycloakify/bin/mockTestingResourcesPath";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
import { kcContextMocks, kcContextCommonMock } from "keycloakify/account/kcContext/kcContextMocks";
|
import { kcContextMocks, kcContextCommonMock } from "keycloakify/account/kcContext/kcContextMocks";
|
||||||
import { id } from "tsafe/id";
|
|
||||||
import { accountThemePageIds } from "keycloakify/bin/keycloakify/generateFtl/pageId";
|
|
||||||
|
|
||||||
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||||
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
||||||
@ -87,7 +85,7 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|||||||
return { "kcContext": undefined as any };
|
return { "kcContext": undefined as any };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id<readonly string[]>(accountThemePageIds).indexOf(realKcContext.pageId) < 0 && !("account" in realKcContext)) {
|
if (realKcContext.themeType !== "account") {
|
||||||
return { "kcContext": undefined as any };
|
return { "kcContext": undefined as any };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ const PUBLIC_URL = process.env["PUBLIC_URL"] ?? "/";
|
|||||||
|
|
||||||
export const kcContextCommonMock: KcContext.Common = {
|
export const kcContextCommonMock: KcContext.Common = {
|
||||||
"keycloakifyVersion": "0.0.0",
|
"keycloakifyVersion": "0.0.0",
|
||||||
|
"themeType": "account",
|
||||||
"url": {
|
"url": {
|
||||||
"resourcesPath": pathJoin(PUBLIC_URL, resourcesDirPathRelativeToPublicDir),
|
"resourcesPath": pathJoin(PUBLIC_URL, resourcesDirPathRelativeToPublicDir),
|
||||||
"resourcesCommonPath": pathJoin(PUBLIC_URL, resourcesCommonDirPathRelativeToPublicDir),
|
"resourcesCommonPath": pathJoin(PUBLIC_URL, resourcesCommonDirPathRelativeToPublicDir),
|
||||||
|
@ -121,6 +121,7 @@
|
|||||||
|
|
||||||
out["keycloakifyVersion"] = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
|
out["keycloakifyVersion"] = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
|
||||||
out["themeVersion"] = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
|
out["themeVersion"] = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
|
||||||
|
out["themeType"] = "KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr";
|
||||||
out["pageId"] = "${pageId}";
|
out["pageId"] = "${pageId}";
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -55,8 +55,9 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
cssGlobalsToDefine: Record<string, string>;
|
cssGlobalsToDefine: Record<string, string>;
|
||||||
buildOptions: BuildOptionsLike;
|
buildOptions: BuildOptionsLike;
|
||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
|
themeType: ThemeType;
|
||||||
}) {
|
}) {
|
||||||
const { cssGlobalsToDefine, indexHtmlCode, buildOptions, keycloakifyVersion } = params;
|
const { cssGlobalsToDefine, indexHtmlCode, buildOptions, keycloakifyVersion, themeType } = params;
|
||||||
|
|
||||||
const $ = cheerio.load(indexHtmlCode);
|
const $ = cheerio.load(indexHtmlCode);
|
||||||
|
|
||||||
@ -132,7 +133,8 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
buildOptions.customUserAttributes.length === 0 ? "" : ", " + buildOptions.customUserAttributes.map(name => `"${name}"`).join(", ")
|
buildOptions.customUserAttributes.length === 0 ? "" : ", " + buildOptions.customUserAttributes.map(name => `"${name}"`).join(", ")
|
||||||
)
|
)
|
||||||
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
||||||
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildOptions.themeVersion),
|
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildOptions.themeVersion)
|
||||||
|
.replace("KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr", themeType),
|
||||||
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
|
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
|
||||||
"<#if scripts??>",
|
"<#if scripts??>",
|
||||||
" <#list scripts as script>",
|
" <#list scripts as script>",
|
||||||
|
@ -141,7 +141,8 @@ export async function generateTheme(params: {
|
|||||||
"indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
|
"indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
|
||||||
"cssGlobalsToDefine": allCssGlobalsToDefine,
|
"cssGlobalsToDefine": allCssGlobalsToDefine,
|
||||||
buildOptions,
|
buildOptions,
|
||||||
keycloakifyVersion
|
keycloakifyVersion,
|
||||||
|
themeType
|
||||||
});
|
});
|
||||||
|
|
||||||
return generateFtlFilesCode;
|
return generateFtlFilesCode;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { LoginThemePageId } from "keycloakify/bin/keycloakify/generateFtl";
|
import type { LoginThemePageId, ThemeType } from "keycloakify/bin/keycloakify/generateFtl";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { Equals } from "tsafe";
|
import type { Equals } from "tsafe";
|
||||||
import type { MessageKey } from "../i18n/i18n";
|
import type { MessageKey } from "../i18n/i18n";
|
||||||
@ -38,6 +38,7 @@ export type KcContext =
|
|||||||
export declare namespace KcContext {
|
export declare namespace KcContext {
|
||||||
export type Common = {
|
export type Common = {
|
||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
|
themeType: "login";
|
||||||
url: {
|
url: {
|
||||||
loginAction: string;
|
loginAction: string;
|
||||||
resourcesPath: string;
|
resourcesPath: string;
|
||||||
@ -564,3 +565,5 @@ export declare namespace Validators {
|
|||||||
assert<Equals<OnlyInGot, never>>();
|
assert<Equals<OnlyInGot, never>>();
|
||||||
assert<Equals<OnlyInExpected, never>>();
|
assert<Equals<OnlyInExpected, never>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert<KcContext["themeType"] extends ThemeType ? true : false>();
|
||||||
|
@ -11,7 +11,6 @@ import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
|||||||
import { pathBasename } from "keycloakify/tools/pathBasename";
|
import { pathBasename } from "keycloakify/tools/pathBasename";
|
||||||
import { resourcesCommonDirPathRelativeToPublicDir } from "keycloakify/bin/mockTestingResourcesPath";
|
import { resourcesCommonDirPathRelativeToPublicDir } from "keycloakify/bin/mockTestingResourcesPath";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
import { loginThemePageIds } from "keycloakify/bin/keycloakify/generateFtl/pageId";
|
|
||||||
|
|
||||||
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||||
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
||||||
@ -145,7 +144,7 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|||||||
return { "kcContext": undefined as any };
|
return { "kcContext": undefined as any };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id<readonly string[]>(loginThemePageIds).indexOf(realKcContext.pageId) < 0 && !("login" in realKcContext)) {
|
if (realKcContext.themeType !== "login") {
|
||||||
return { "kcContext": undefined as any };
|
return { "kcContext": undefined as any };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ const attributesByName = Object.fromEntries(attributes.map(attribute => [attribu
|
|||||||
|
|
||||||
export const kcContextCommonMock: KcContext.Common = {
|
export const kcContextCommonMock: KcContext.Common = {
|
||||||
"keycloakifyVersion": "0.0.0",
|
"keycloakifyVersion": "0.0.0",
|
||||||
|
"themeType": "login",
|
||||||
"url": {
|
"url": {
|
||||||
"loginAction": "#",
|
"loginAction": "#",
|
||||||
"resourcesPath": pathJoin(PUBLIC_URL, resourcesDirPathRelativeToPublicDir),
|
"resourcesPath": pathJoin(PUBLIC_URL, resourcesDirPathRelativeToPublicDir),
|
||||||
|
Reference in New Issue
Block a user