2024-05-12 20:47:03 +02:00
|
|
|
import { join as pathJoin } from "path";
|
2024-05-15 05:14:01 +02:00
|
|
|
import type { BuildOptions } from "../../shared/buildOptions";
|
2024-05-12 20:47:03 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
2024-05-12 21:23:20 +02:00
|
|
|
import { generateSrcMainResources, type BuildOptionsLike as BuildOptionsLike_generateSrcMainResources } from "./generateSrcMainResources";
|
2024-05-12 20:47:03 +02:00
|
|
|
import { generateThemeVariations } from "./generateThemeVariants";
|
2022-08-16 14:41:06 +07:00
|
|
|
|
2024-05-12 21:23:20 +02:00
|
|
|
export type BuildOptionsLike = BuildOptionsLike_generateSrcMainResources & {
|
2023-09-03 23:26:34 +02:00
|
|
|
keycloakifyBuildDirPath: string;
|
2024-05-12 21:23:20 +02:00
|
|
|
themeNames: string[];
|
2023-08-21 05:54:17 +02:00
|
|
|
};
|
2022-08-16 14:41:06 +07:00
|
|
|
|
2023-04-01 13:31:35 +02:00
|
|
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
2021-03-22 20:54:28 +01:00
|
|
|
|
2023-04-18 03:10:29 +02:00
|
|
|
export async function generateTheme(params: {
|
2023-06-21 18:06:12 +02:00
|
|
|
themeSrcDirPath: string;
|
2023-06-19 00:09:21 +02:00
|
|
|
keycloakifySrcDirPath: string;
|
2022-08-16 14:41:06 +07:00
|
|
|
buildOptions: BuildOptionsLike;
|
2023-04-04 01:40:55 +02:00
|
|
|
keycloakifyVersion: string;
|
2024-05-12 21:23:20 +02:00
|
|
|
}): Promise<{ doesImplementAccountTheme: boolean }> {
|
2024-05-12 20:47:03 +02:00
|
|
|
const { themeSrcDirPath, keycloakifySrcDirPath, buildOptions, keycloakifyVersion } = params;
|
2023-03-16 22:13:46 +01:00
|
|
|
|
2024-05-12 20:47:03 +02:00
|
|
|
const [themeName, ...themeVariantNames] = buildOptions.themeNames;
|
2021-02-21 18:55:06 +01:00
|
|
|
|
2024-05-12 21:23:20 +02:00
|
|
|
const srcMainResourcesDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources");
|
|
|
|
|
|
|
|
const { doesImplementAccountTheme } = await generateSrcMainResources({
|
2024-05-12 20:47:03 +02:00
|
|
|
themeName,
|
2024-05-12 21:23:20 +02:00
|
|
|
srcMainResourcesDirPath,
|
2024-05-12 20:47:03 +02:00
|
|
|
themeSrcDirPath,
|
|
|
|
keycloakifySrcDirPath,
|
|
|
|
keycloakifyVersion,
|
|
|
|
buildOptions
|
|
|
|
});
|
2022-08-16 14:41:06 +07:00
|
|
|
|
2024-05-12 20:47:03 +02:00
|
|
|
for (const themeVariantName of themeVariantNames) {
|
|
|
|
generateThemeVariations({
|
2024-01-31 21:56:46 +01:00
|
|
|
themeName,
|
2024-05-12 20:47:03 +02:00
|
|
|
themeVariantName,
|
2024-05-12 21:23:20 +02:00
|
|
|
srcMainResourcesDirPath
|
2023-04-19 05:04:11 +02:00
|
|
|
});
|
2024-02-05 08:52:58 +01:00
|
|
|
}
|
2024-05-12 19:16:59 +02:00
|
|
|
|
2024-05-12 21:23:20 +02:00
|
|
|
return { doesImplementAccountTheme };
|
2021-02-21 18:55:06 +01:00
|
|
|
}
|