Support building account v3
This commit is contained in:
parent
e2f5eb79ad
commit
c4638daf1b
@ -33,6 +33,7 @@ export async function buildJar(params: {
|
|||||||
keycloakAccountV1Version: KeycloakAccountV1Version;
|
keycloakAccountV1Version: KeycloakAccountV1Version;
|
||||||
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
||||||
resourcesDirPath: string;
|
resourcesDirPath: string;
|
||||||
|
doesImplementAccountV1Theme: boolean;
|
||||||
buildContext: BuildContextLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const {
|
const {
|
||||||
@ -40,6 +41,7 @@ export async function buildJar(params: {
|
|||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
resourcesDirPath,
|
resourcesDirPath,
|
||||||
|
doesImplementAccountV1Theme,
|
||||||
buildContext
|
buildContext
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ export async function buildJar(params: {
|
|||||||
srcDirPath: resourcesDirPath,
|
srcDirPath: resourcesDirPath,
|
||||||
destDirPath: tmpResourcesDirPath,
|
destDirPath: tmpResourcesDirPath,
|
||||||
transformSourceCode:
|
transformSourceCode:
|
||||||
keycloakAccountV1Version !== null
|
!doesImplementAccountV1Theme || keycloakAccountV1Version !== null
|
||||||
? undefined
|
? undefined
|
||||||
: (params: {
|
: (params: {
|
||||||
fileRelativePath: string;
|
fileRelativePath: string;
|
||||||
@ -105,7 +107,17 @@ export async function buildJar(params: {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (keycloakAccountV1Version === null) {
|
remove_account_v1_in_meta_inf: {
|
||||||
|
if (!doesImplementAccountV1Theme) {
|
||||||
|
// NOTE: We do not have account v1 anyway
|
||||||
|
break remove_account_v1_in_meta_inf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keycloakAccountV1Version !== null) {
|
||||||
|
// NOTE: No, we need to keep account-v1 in meta-inf
|
||||||
|
break remove_account_v1_in_meta_inf;
|
||||||
|
}
|
||||||
|
|
||||||
writeMetaInfKeycloakThemes({
|
writeMetaInfKeycloakThemes({
|
||||||
resourcesDirPath: tmpResourcesDirPath,
|
resourcesDirPath: tmpResourcesDirPath,
|
||||||
getNewMetaInfKeycloakTheme: ({ metaInfKeycloakTheme }) => {
|
getNewMetaInfKeycloakTheme: ({ metaInfKeycloakTheme }) => {
|
||||||
@ -135,6 +147,7 @@ export async function buildJar(params: {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// TODO: Remove this optimization, it's a bit hacky.
|
||||||
if (doBreak) {
|
if (doBreak) {
|
||||||
break route_legacy_pages;
|
break route_legacy_pages;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ export type BuildContextLike = BuildContextLike_buildJar & {
|
|||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
|
recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
|
||||||
jarTargets: BuildContext["jarTargets"];
|
jarTargets: BuildContext["jarTargets"];
|
||||||
|
doUseAccountV3: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildContext extends BuildContextLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
@ -22,7 +23,9 @@ export async function buildJars(params: {
|
|||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { resourcesDirPath, buildContext } = params;
|
const { resourcesDirPath, buildContext } = params;
|
||||||
|
|
||||||
const doesImplementAccountTheme = buildContext.recordIsImplementedByThemeType.account;
|
const doesImplementAccountV1Theme =
|
||||||
|
buildContext.recordIsImplementedByThemeType.account &&
|
||||||
|
!buildContext.doUseAccountV3;
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
keycloakAccountV1Versions
|
keycloakAccountV1Versions
|
||||||
@ -30,7 +33,7 @@ export async function buildJars(params: {
|
|||||||
keycloakThemeAdditionalInfoExtensionVersions.map(
|
keycloakThemeAdditionalInfoExtensionVersions.map(
|
||||||
keycloakThemeAdditionalInfoExtensionVersion => {
|
keycloakThemeAdditionalInfoExtensionVersion => {
|
||||||
const keycloakVersionRange = getKeycloakVersionRangeForJar({
|
const keycloakVersionRange = getKeycloakVersionRangeForJar({
|
||||||
doesImplementAccountTheme,
|
doesImplementAccountV1Theme,
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion
|
keycloakThemeAdditionalInfoExtensionVersion
|
||||||
});
|
});
|
||||||
@ -55,6 +58,7 @@ export async function buildJars(params: {
|
|||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
resourcesDirPath,
|
resourcesDirPath,
|
||||||
|
doesImplementAccountV1Theme,
|
||||||
buildContext
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,17 @@ import type {
|
|||||||
import type { KeycloakVersionRange } from "../../shared/KeycloakVersionRange";
|
import type { KeycloakVersionRange } from "../../shared/KeycloakVersionRange";
|
||||||
|
|
||||||
export function getKeycloakVersionRangeForJar(params: {
|
export function getKeycloakVersionRangeForJar(params: {
|
||||||
doesImplementAccountTheme: boolean;
|
doesImplementAccountV1Theme: boolean;
|
||||||
keycloakAccountV1Version: KeycloakAccountV1Version;
|
keycloakAccountV1Version: KeycloakAccountV1Version;
|
||||||
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
||||||
}): KeycloakVersionRange | undefined {
|
}): KeycloakVersionRange | undefined {
|
||||||
const {
|
const {
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
doesImplementAccountTheme
|
doesImplementAccountV1Theme
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
if (doesImplementAccountTheme) {
|
if (doesImplementAccountV1Theme) {
|
||||||
const keycloakVersionRange = (() => {
|
const keycloakVersionRange = (() => {
|
||||||
switch (keycloakAccountV1Version) {
|
switch (keycloakAccountV1Version) {
|
||||||
case null:
|
case null:
|
||||||
@ -63,7 +63,7 @@ export function getKeycloakVersionRangeForJar(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithAccountTheme | undefined
|
KeycloakVersionRange.WithAccountV1Theme | undefined
|
||||||
>
|
>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ export function getKeycloakVersionRangeForJar(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithoutAccountTheme | undefined
|
KeycloakVersionRange.WithoutAccountV1Theme | undefined
|
||||||
>
|
>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
themeType: ThemeType;
|
themeType: ThemeType;
|
||||||
fieldNames: string[];
|
fieldNames: string[];
|
||||||
|
isAccountV3: boolean;
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
themeName,
|
themeName,
|
||||||
@ -41,7 +42,8 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
buildContext,
|
buildContext,
|
||||||
keycloakifyVersion,
|
keycloakifyVersion,
|
||||||
themeType,
|
themeType,
|
||||||
fieldNames
|
fieldNames,
|
||||||
|
isAccountV3
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const $ = cheerio.load(indexHtmlCode);
|
const $ = cheerio.load(indexHtmlCode);
|
||||||
@ -68,7 +70,8 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
const { fixedCssCode } = replaceImportsInCssCode({
|
const { fixedCssCode } = replaceImportsInCssCode({
|
||||||
cssCode,
|
cssCode,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
buildContext
|
buildContext,
|
||||||
|
isAccountV3
|
||||||
});
|
});
|
||||||
|
|
||||||
$(element).text(fixedCssCode);
|
$(element).text(fixedCssCode);
|
||||||
@ -93,7 +96,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
new RegExp(
|
new RegExp(
|
||||||
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
||||||
),
|
),
|
||||||
`\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
`\${${!isAccountV3 ? "url.resourcesPath" : "resourceUrl"}}/${basenameOfTheKeycloakifyResourcesDir}/`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
|
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
|
||||||
|
<#assign themeType="KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr">
|
||||||
const kcContext = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
|
const kcContext = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
|
||||||
if( kcContext.messagesPerField ){
|
if( kcContext.messagesPerField ){
|
||||||
var existsError_singleFieldName = kcContext.messagesPerField.existsError;
|
var existsError_singleFieldName = kcContext.messagesPerField.existsError;
|
||||||
@ -27,7 +28,7 @@ if( kcContext.messagesPerField ){
|
|||||||
}
|
}
|
||||||
kcContext.keycloakifyVersion = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
|
kcContext.keycloakifyVersion = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
|
||||||
kcContext.themeVersion = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
|
kcContext.themeVersion = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
|
||||||
kcContext.themeType = "KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr";
|
kcContext.themeType = "${themeType}";
|
||||||
kcContext.themeName = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer";
|
kcContext.themeName = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer";
|
||||||
kcContext.pageId = "${pageId}";
|
kcContext.pageId = "${pageId}";
|
||||||
if( kcContext.url && kcContext.url.resourcesPath ){
|
if( kcContext.url && kcContext.url.resourcesPath ){
|
||||||
|
@ -54,6 +54,7 @@ export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
|
|||||||
recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
|
recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
|
||||||
themeSrcDirPath: string;
|
themeSrcDirPath: string;
|
||||||
bundler: { type: "vite" } | { type: "webpack" };
|
bundler: { type: "vite" } | { type: "webpack" };
|
||||||
|
doUseAccountV3: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildContext extends BuildContextLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
@ -71,6 +72,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const themeType of ["login", "account"] as const) {
|
for (const themeType of ["login", "account"] as const) {
|
||||||
|
const isAccountV3 = themeType === "account" && buildContext.doUseAccountV3;
|
||||||
if (!buildContext.recordIsImplementedByThemeType[themeType]) {
|
if (!buildContext.recordIsImplementedByThemeType[themeType]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -136,7 +138,8 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
const { fixedCssCode } = replaceImportsInCssCode({
|
const { fixedCssCode } = replaceImportsInCssCode({
|
||||||
cssCode: sourceCode.toString("utf8"),
|
cssCode: sourceCode.toString("utf8"),
|
||||||
cssFileRelativeDirPath: pathDirname(fileRelativePath),
|
cssFileRelativeDirPath: pathDirname(fileRelativePath),
|
||||||
buildContext
|
buildContext,
|
||||||
|
isAccountV3
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -171,7 +174,8 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
fieldNames: readFieldNameUsage({
|
fieldNames: readFieldNameUsage({
|
||||||
themeSrcDirPath: buildContext.themeSrcDirPath,
|
themeSrcDirPath: buildContext.themeSrcDirPath,
|
||||||
themeType
|
themeType
|
||||||
})
|
}),
|
||||||
|
isAccountV3
|
||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
@ -180,13 +184,15 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
case "login":
|
case "login":
|
||||||
return loginThemePageIds;
|
return loginThemePageIds;
|
||||||
case "account":
|
case "account":
|
||||||
return accountThemePageIds;
|
return isAccountV3 ? ["index.ftl"] : accountThemePageIds;
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
...readExtraPagesNames({
|
...(isAccountV3
|
||||||
|
? []
|
||||||
|
: readExtraPagesNames({
|
||||||
themeType,
|
themeType,
|
||||||
themeSrcDirPath: buildContext.themeSrcDirPath
|
themeSrcDirPath: buildContext.themeSrcDirPath
|
||||||
})
|
}))
|
||||||
].forEach(pageId => {
|
].forEach(pageId => {
|
||||||
const { ftlCode } = generateFtlFilesCode({ pageId });
|
const { ftlCode } = generateFtlFilesCode({ pageId });
|
||||||
|
|
||||||
@ -196,6 +202,11 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
i18n_messages_generation: {
|
||||||
|
if (isAccountV3) {
|
||||||
|
break i18n_messages_generation;
|
||||||
|
}
|
||||||
|
|
||||||
generateMessageProperties({
|
generateMessageProperties({
|
||||||
themeSrcDirPath: buildContext.themeSrcDirPath,
|
themeSrcDirPath: buildContext.themeSrcDirPath,
|
||||||
themeType
|
themeType
|
||||||
@ -216,6 +227,12 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
Buffer.from(propertiesFileSource, "utf8")
|
Buffer.from(propertiesFileSource, "utf8")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
keycloak_static_resources: {
|
||||||
|
if (isAccountV3) {
|
||||||
|
break keycloak_static_resources;
|
||||||
|
}
|
||||||
|
|
||||||
await downloadKeycloakStaticResources({
|
await downloadKeycloakStaticResources({
|
||||||
keycloakVersion: (() => {
|
keycloakVersion: (() => {
|
||||||
@ -230,6 +247,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
themeType,
|
themeType,
|
||||||
buildContext
|
buildContext
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(themeTypeDirPath, "theme.properties"),
|
pathJoin(themeTypeDirPath, "theme.properties"),
|
||||||
@ -238,12 +256,13 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
`parent=${(() => {
|
`parent=${(() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return accountV1ThemeName;
|
return isAccountV3 ? "base" : accountV1ThemeName;
|
||||||
case "login":
|
case "login":
|
||||||
return "keycloak";
|
return "keycloak";
|
||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})()}`,
|
})()}`,
|
||||||
|
...(isAccountV3 ? ["deprecatedMode=false"] : []),
|
||||||
...(buildContext.extraThemeProperties ?? []),
|
...(buildContext.extraThemeProperties ?? []),
|
||||||
...buildContext.environmentVariables.map(
|
...buildContext.environmentVariables.map(
|
||||||
({ name, default: defaultValue }) =>
|
({ name, default: defaultValue }) =>
|
||||||
@ -268,7 +287,15 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildContext.recordIsImplementedByThemeType.account) {
|
bring_in_account_v1: {
|
||||||
|
if (buildContext.doUseAccountV3) {
|
||||||
|
break bring_in_account_v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buildContext.recordIsImplementedByThemeType.account) {
|
||||||
|
break bring_in_account_v1;
|
||||||
|
}
|
||||||
|
|
||||||
await bringInAccountV1({
|
await bringInAccountV1({
|
||||||
resourcesDirPath,
|
resourcesDirPath,
|
||||||
buildContext
|
buildContext
|
||||||
|
@ -12,11 +12,12 @@ assert<BuildContext extends BuildContextLike ? true : false>();
|
|||||||
export function replaceImportsInCssCode(params: {
|
export function replaceImportsInCssCode(params: {
|
||||||
cssCode: string;
|
cssCode: string;
|
||||||
cssFileRelativeDirPath: string | undefined;
|
cssFileRelativeDirPath: string | undefined;
|
||||||
|
isAccountV3: boolean;
|
||||||
buildContext: BuildContextLike;
|
buildContext: BuildContextLike;
|
||||||
}): {
|
}): {
|
||||||
fixedCssCode: string;
|
fixedCssCode: string;
|
||||||
} {
|
} {
|
||||||
const { cssCode, cssFileRelativeDirPath, buildContext } = params;
|
const { cssCode, cssFileRelativeDirPath, buildContext, isAccountV3 } = params;
|
||||||
|
|
||||||
const fixedCssCode = cssCode.replace(
|
const fixedCssCode = cssCode.replace(
|
||||||
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
||||||
@ -37,7 +38,7 @@ export function replaceImportsInCssCode(params: {
|
|||||||
break inline_style_in_html;
|
break inline_style_in_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
|
return `url(\${${!isAccountV3 ? "url.resourcesPath" : "resourceUrl"}}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetFileRelativeUrlPathname = posix.relative(
|
const assetFileRelativeUrlPathname = posix.relative(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
export type KeycloakVersionRange =
|
export type KeycloakVersionRange =
|
||||||
| KeycloakVersionRange.WithAccountTheme
|
| KeycloakVersionRange.WithAccountV1Theme
|
||||||
| KeycloakVersionRange.WithoutAccountTheme;
|
| KeycloakVersionRange.WithoutAccountV1Theme;
|
||||||
|
|
||||||
export namespace KeycloakVersionRange {
|
export namespace KeycloakVersionRange {
|
||||||
export type WithoutAccountTheme = "21-and-below" | "22-and-above";
|
export type WithoutAccountV1Theme = "21-and-below" | "22-and-above";
|
||||||
|
|
||||||
export type WithAccountTheme = "21-and-below" | "23" | "24" | "25-and-above";
|
export type WithAccountV1Theme = "21-and-below" | "23" | "24" | "25-and-above";
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ export type BuildContext = {
|
|||||||
packageJsonDirPath: string;
|
packageJsonDirPath: string;
|
||||||
packageJsonScripts: Record<string, string>;
|
packageJsonScripts: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
doUseAccountV3: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BuildOptions = {
|
export type BuildOptions = {
|
||||||
@ -77,16 +78,17 @@ export type BuildOptions = {
|
|||||||
kcContextExclusionsFtl?: string;
|
kcContextExclusionsFtl?: string;
|
||||||
/** https://docs.keycloakify.dev/v/v10/targetting-specific-keycloak-versions */
|
/** https://docs.keycloakify.dev/v/v10/targetting-specific-keycloak-versions */
|
||||||
keycloakVersionTargets?: BuildOptions.KeycloakVersionTargets;
|
keycloakVersionTargets?: BuildOptions.KeycloakVersionTargets;
|
||||||
|
doUseAccountV3?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export namespace BuildOptions {
|
export namespace BuildOptions {
|
||||||
export type KeycloakVersionTargets =
|
export type KeycloakVersionTargets =
|
||||||
| ({ hasAccountTheme: true } & Record<
|
| ({ hasAccountTheme: true } & Record<
|
||||||
KeycloakVersionRange.WithAccountTheme,
|
KeycloakVersionRange.WithAccountV1Theme,
|
||||||
string | boolean
|
string | boolean
|
||||||
>)
|
>)
|
||||||
| ({ hasAccountTheme: false } & Record<
|
| ({ hasAccountTheme: false } & Record<
|
||||||
KeycloakVersionRange.WithoutAccountTheme,
|
KeycloakVersionRange.WithoutAccountV1Theme,
|
||||||
string | boolean
|
string | boolean
|
||||||
>);
|
>);
|
||||||
}
|
}
|
||||||
@ -229,6 +231,7 @@ export function getBuildContext(params: {
|
|||||||
projectBuildDirPath?: string;
|
projectBuildDirPath?: string;
|
||||||
staticDirPathInProjectBuildDirPath?: string;
|
staticDirPathInProjectBuildDirPath?: string;
|
||||||
publicDirPath?: string;
|
publicDirPath?: string;
|
||||||
|
doUseAccountV3?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ParsedPackageJson = {
|
type ParsedPackageJson = {
|
||||||
@ -297,7 +300,8 @@ export function getBuildContext(params: {
|
|||||||
|
|
||||||
return zKeycloakVersionTargets;
|
return zKeycloakVersionTargets;
|
||||||
})()
|
})()
|
||||||
).optional()
|
).optional(),
|
||||||
|
doUseAccountV3: z.boolean().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -386,6 +390,8 @@ export function getBuildContext(params: {
|
|||||||
|
|
||||||
const bundler = resolvedViteConfig !== undefined ? "vite" : "webpack";
|
const bundler = resolvedViteConfig !== undefined ? "vite" : "webpack";
|
||||||
|
|
||||||
|
const doUseAccountV3 = buildOptions.doUseAccountV3 ?? false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bundler:
|
bundler:
|
||||||
resolvedViteConfig !== undefined
|
resolvedViteConfig !== undefined
|
||||||
@ -606,10 +612,10 @@ export function getBuildContext(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const keycloakVersionRange: KeycloakVersionRange = (() => {
|
const keycloakVersionRange: KeycloakVersionRange = (() => {
|
||||||
const doesImplementAccountTheme =
|
const doesImplementAccountV1Theme =
|
||||||
recordIsImplementedByThemeType.account;
|
!doUseAccountV3 && recordIsImplementedByThemeType.account;
|
||||||
|
|
||||||
if (doesImplementAccountTheme) {
|
if (doesImplementAccountV1Theme) {
|
||||||
const keycloakVersionRange = (() => {
|
const keycloakVersionRange = (() => {
|
||||||
if (buildForKeycloakMajorVersionNumber <= 21) {
|
if (buildForKeycloakMajorVersionNumber <= 21) {
|
||||||
return "21-and-below" as const;
|
return "21-and-below" as const;
|
||||||
@ -631,7 +637,7 @@ export function getBuildContext(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithAccountTheme
|
KeycloakVersionRange.WithAccountV1Theme
|
||||||
>
|
>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
@ -648,7 +654,7 @@ export function getBuildContext(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithoutAccountTheme
|
KeycloakVersionRange.WithoutAccountV1Theme
|
||||||
>
|
>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
@ -696,7 +702,7 @@ export function getBuildContext(params: {
|
|||||||
const jarTargets_default = (() => {
|
const jarTargets_default = (() => {
|
||||||
const jarTargets: BuildContext["jarTargets"] = [];
|
const jarTargets: BuildContext["jarTargets"] = [];
|
||||||
|
|
||||||
if (recordIsImplementedByThemeType.account) {
|
if (!doUseAccountV3 && recordIsImplementedByThemeType.account) {
|
||||||
for (const keycloakVersionRange of [
|
for (const keycloakVersionRange of [
|
||||||
"21-and-below",
|
"21-and-below",
|
||||||
"23",
|
"23",
|
||||||
@ -706,7 +712,7 @@ export function getBuildContext(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithAccountTheme
|
KeycloakVersionRange.WithAccountV1Theme
|
||||||
>
|
>
|
||||||
>(true);
|
>(true);
|
||||||
jarTargets.push({
|
jarTargets.push({
|
||||||
@ -723,7 +729,7 @@ export function getBuildContext(params: {
|
|||||||
assert<
|
assert<
|
||||||
Equals<
|
Equals<
|
||||||
typeof keycloakVersionRange,
|
typeof keycloakVersionRange,
|
||||||
KeycloakVersionRange.WithoutAccountTheme
|
KeycloakVersionRange.WithoutAccountV1Theme
|
||||||
>
|
>
|
||||||
>(true);
|
>(true);
|
||||||
jarTargets.push({
|
jarTargets.push({
|
||||||
@ -742,8 +748,9 @@ export function getBuildContext(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
buildOptions.keycloakVersionTargets.hasAccountTheme !==
|
buildOptions.keycloakVersionTargets.hasAccountTheme !== doUseAccountV3
|
||||||
recordIsImplementedByThemeType.account
|
? false
|
||||||
|
: recordIsImplementedByThemeType.account
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.red(
|
chalk.red(
|
||||||
@ -863,6 +870,7 @@ export function getBuildContext(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return jarTargets;
|
return jarTargets;
|
||||||
})()
|
})(),
|
||||||
|
doUseAccountV3
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -396,6 +396,7 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: "assets/",
|
cssFileRelativeDirPath: "assets/",
|
||||||
|
isAccountV3: false,
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: undefined
|
urlPathname: undefined
|
||||||
}
|
}
|
||||||
@ -434,6 +435,7 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: "assets/",
|
cssFileRelativeDirPath: "assets/",
|
||||||
|
isAccountV3: false,
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: "/a/b/"
|
urlPathname: "/a/b/"
|
||||||
}
|
}
|
||||||
@ -472,6 +474,7 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
|
isAccountV3: false,
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: "/a/b/"
|
urlPathname: "/a/b/"
|
||||||
}
|
}
|
||||||
@ -510,6 +513,7 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
|
isAccountV3: false,
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: undefined
|
urlPathname: undefined
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user