45 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-05-12 20:47:03 +02:00
import { join as pathJoin } from "path";
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
export async function generateTheme(params: {
2023-06-21 18:06:12 +02:00
themeSrcDirPath: string;
keycloakifySrcDirPath: string;
2022-08-16 14:41:06 +07:00
buildOptions: BuildOptionsLike;
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;
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
});
2024-02-05 08:52:58 +01:00
}
2024-05-12 21:23:20 +02:00
return { doesImplementAccountTheme };
2021-02-21 18:55:06 +01:00
}