2024-05-12 19:16:59 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
|
|
|
import { exclude } from "tsafe/exclude";
|
2024-05-20 15:48:51 +02:00
|
|
|
import {
|
|
|
|
keycloakAccountV1Versions,
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersions
|
|
|
|
} from "./extensionVersions";
|
2024-05-12 19:16:59 +02:00
|
|
|
import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
|
2024-06-09 09:15:16 +02:00
|
|
|
import { buildJar, BuildContextLike as BuildContextLike_buildJar } from "./buildJar";
|
|
|
|
import type { BuildContext } from "../../shared/buildContext";
|
2024-05-17 05:13:41 +02:00
|
|
|
import { getJarFileBasename } from "../../shared/getJarFileBasename";
|
2024-05-17 02:05:14 +02:00
|
|
|
import { readMetaInfKeycloakThemes } from "../../shared/metaInfKeycloakThemes";
|
|
|
|
import { accountV1ThemeName } from "../../shared/constants";
|
2024-05-13 00:40:16 +02:00
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
export type BuildContextLike = BuildContextLike_buildJar & {
|
2024-05-13 00:40:16 +02:00
|
|
|
keycloakifyBuildDirPath: string;
|
|
|
|
};
|
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
2024-05-12 19:16:59 +02:00
|
|
|
|
2024-05-20 15:48:51 +02:00
|
|
|
export async function buildJars(params: {
|
2024-06-09 09:15:16 +02:00
|
|
|
buildContext: BuildContextLike;
|
2024-05-20 15:48:51 +02:00
|
|
|
}): Promise<void> {
|
2024-06-09 09:15:16 +02:00
|
|
|
const { buildContext } = params;
|
2024-05-17 01:21:26 +02:00
|
|
|
|
2024-05-17 02:05:14 +02:00
|
|
|
const doesImplementAccountTheme = readMetaInfKeycloakThemes({
|
2024-06-09 09:15:16 +02:00
|
|
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath
|
2024-05-17 02:05:14 +02:00
|
|
|
}).themes.some(({ name }) => name === accountV1ThemeName);
|
2024-05-12 19:16:59 +02:00
|
|
|
|
|
|
|
await Promise.all(
|
|
|
|
keycloakAccountV1Versions
|
|
|
|
.map(keycloakAccountV1Version =>
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersions
|
|
|
|
.map(keycloakThemeAdditionalInfoExtensionVersion => {
|
|
|
|
const keycloakVersionRange = getKeycloakVersionRangeForJar({
|
2024-05-12 21:23:20 +02:00
|
|
|
doesImplementAccountTheme,
|
2024-05-12 19:16:59 +02:00
|
|
|
keycloakAccountV1Version,
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion
|
|
|
|
});
|
|
|
|
|
|
|
|
if (keycloakVersionRange === undefined) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2024-05-16 09:20:37 +02:00
|
|
|
return {
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion,
|
2024-05-20 15:48:51 +02:00
|
|
|
keycloakVersionRange
|
2024-05-16 09:20:37 +02:00
|
|
|
};
|
2024-05-12 19:16:59 +02:00
|
|
|
})
|
2024-05-20 15:48:51 +02:00
|
|
|
.filter(exclude(undefined))
|
|
|
|
.map(
|
|
|
|
({
|
2024-05-12 19:16:59 +02:00
|
|
|
keycloakThemeAdditionalInfoExtensionVersion,
|
2024-05-20 15:48:51 +02:00
|
|
|
keycloakVersionRange
|
|
|
|
}) => {
|
|
|
|
const { jarFileBasename } = getJarFileBasename({
|
|
|
|
keycloakVersionRange
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion,
|
|
|
|
jarFileBasename
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.map(
|
|
|
|
({
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion,
|
|
|
|
jarFileBasename
|
|
|
|
}) =>
|
|
|
|
buildJar({
|
|
|
|
jarFileBasename,
|
|
|
|
keycloakAccountV1Version,
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion,
|
2024-06-09 09:15:16 +02:00
|
|
|
buildContext
|
2024-05-20 15:48:51 +02:00
|
|
|
})
|
2024-05-12 19:16:59 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
.flat()
|
|
|
|
);
|
|
|
|
}
|