2024-05-15 05:14:01 +02:00
|
|
|
import { transformCodebase } from "../tools/transformCodebase";
|
2024-02-05 08:52:58 +01:00
|
|
|
import { join as pathJoin } from "path";
|
2024-05-24 17:26:38 +02:00
|
|
|
import {
|
|
|
|
downloadKeycloakDefaultTheme,
|
2024-06-09 09:15:16 +02:00
|
|
|
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
2024-05-24 17:26:38 +02:00
|
|
|
} from "./downloadKeycloakDefaultTheme";
|
2024-05-15 05:14:01 +02:00
|
|
|
import { resources_common, type ThemeType } from "./constants";
|
2024-06-09 09:15:16 +02:00
|
|
|
import type { BuildContext } from "./buildContext";
|
2023-10-02 22:49:04 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
2024-05-24 17:26:38 +02:00
|
|
|
import { existsAsync } from "../tools/fs.existsAsync";
|
2023-04-18 03:10:29 +02:00
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
|
2023-09-03 23:26:34 +02:00
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
2023-04-18 03:10:29 +02:00
|
|
|
|
2024-02-05 08:52:58 +01:00
|
|
|
export async function downloadKeycloakStaticResources(params: {
|
|
|
|
themeType: ThemeType;
|
|
|
|
themeDirPath: string;
|
|
|
|
keycloakVersion: string;
|
2024-06-09 09:15:16 +02:00
|
|
|
buildContext: BuildContextLike;
|
2024-02-05 08:52:58 +01:00
|
|
|
}) {
|
2024-06-09 09:15:16 +02:00
|
|
|
const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
|
2023-11-26 15:07:27 +01:00
|
|
|
|
2024-05-24 17:26:38 +02:00
|
|
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
2023-04-18 03:10:29 +02:00
|
|
|
keycloakVersion,
|
2024-06-09 09:15:16 +02:00
|
|
|
buildContext
|
2023-04-18 03:10:29 +02:00
|
|
|
});
|
|
|
|
|
2024-05-24 17:26:38 +02:00
|
|
|
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
|
|
|
|
|
|
|
repatriate_base_resources: {
|
|
|
|
const srcDirPath = pathJoin(defaultThemeDirPath, "base", themeType, "resources");
|
|
|
|
|
|
|
|
if (!(await existsAsync(srcDirPath))) {
|
|
|
|
break repatriate_base_resources;
|
|
|
|
}
|
|
|
|
|
|
|
|
transformCodebase({
|
|
|
|
srcDirPath,
|
|
|
|
destDirPath: resourcesDirPath
|
|
|
|
});
|
|
|
|
}
|
2023-09-03 07:14:57 +02:00
|
|
|
|
2023-04-18 03:10:29 +02:00
|
|
|
transformCodebase({
|
2024-05-24 17:26:38 +02:00
|
|
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", themeType, "resources"),
|
|
|
|
destDirPath: resourcesDirPath
|
2023-04-18 03:10:29 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
transformCodebase({
|
2024-05-24 17:26:38 +02:00
|
|
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
|
|
|
destDirPath: pathJoin(resourcesDirPath, resources_common)
|
2023-04-18 03:10:29 +02:00
|
|
|
});
|
2023-11-26 15:07:27 +01:00
|
|
|
}
|