2023-09-04 00:25:36 +02:00
|
|
|
import * as fs from "fs";
|
2024-02-05 08:52:58 +01:00
|
|
|
import { join as pathJoin } from "path";
|
2023-09-04 00:25:36 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
2024-05-15 05:14:01 +02:00
|
|
|
import type { BuildOptions } from "../../shared/buildOptions";
|
2024-05-20 15:48:51 +02:00
|
|
|
import {
|
|
|
|
resources_common,
|
|
|
|
lastKeycloakVersionWithAccountV1,
|
|
|
|
accountV1ThemeName
|
|
|
|
} from "../../shared/constants";
|
2024-05-19 10:46:26 +02:00
|
|
|
import { downloadKeycloakDefaultTheme } from "../../shared/downloadKeycloakDefaultTheme";
|
2023-09-04 00:25:36 +02:00
|
|
|
import { transformCodebase } from "../../tools/transformCodebase";
|
|
|
|
|
2024-06-06 01:31:00 +02:00
|
|
|
export type BuildOptionsLike = {
|
2023-09-04 00:25:36 +02:00
|
|
|
cacheDirPath: string;
|
2024-02-11 18:28:58 +01:00
|
|
|
npmWorkspaceRootDirPath: string;
|
2024-05-17 00:39:05 +02:00
|
|
|
keycloakifyBuildDirPath: string;
|
2023-09-04 00:25:36 +02:00
|
|
|
};
|
|
|
|
|
2024-05-13 00:40:16 +02:00
|
|
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
2023-09-04 00:25:36 +02:00
|
|
|
|
2024-05-17 00:39:05 +02:00
|
|
|
export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike }) {
|
|
|
|
const { buildOptions } = params;
|
2023-09-04 00:25:36 +02:00
|
|
|
|
2024-05-24 17:26:38 +02:00
|
|
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
2024-05-20 15:48:51 +02:00
|
|
|
keycloakVersion: lastKeycloakVersionWithAccountV1,
|
2023-09-04 00:25:36 +02:00
|
|
|
buildOptions
|
|
|
|
});
|
|
|
|
|
2024-05-20 15:48:51 +02:00
|
|
|
const accountV1DirPath = pathJoin(
|
|
|
|
buildOptions.keycloakifyBuildDirPath,
|
|
|
|
"src",
|
|
|
|
"main",
|
|
|
|
"resources",
|
|
|
|
"theme",
|
|
|
|
accountV1ThemeName,
|
|
|
|
"account"
|
|
|
|
);
|
2023-09-04 00:25:36 +02:00
|
|
|
|
|
|
|
transformCodebase({
|
2024-05-24 17:26:38 +02:00
|
|
|
srcDirPath: pathJoin(defaultThemeDirPath, "base", "account"),
|
2024-05-20 15:48:51 +02:00
|
|
|
destDirPath: accountV1DirPath
|
2023-09-04 00:25:36 +02:00
|
|
|
});
|
|
|
|
|
2024-02-05 08:52:58 +01:00
|
|
|
transformCodebase({
|
2024-05-24 17:26:38 +02:00
|
|
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "account", "resources"),
|
2024-05-20 15:48:51 +02:00
|
|
|
destDirPath: pathJoin(accountV1DirPath, "resources")
|
2024-02-05 08:52:58 +01:00
|
|
|
});
|
2023-09-04 00:25:36 +02:00
|
|
|
|
2024-02-05 08:52:58 +01:00
|
|
|
transformCodebase({
|
2024-05-24 17:26:38 +02:00
|
|
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
2024-05-20 15:48:51 +02:00
|
|
|
destDirPath: pathJoin(accountV1DirPath, "resources", resources_common)
|
2024-02-05 08:52:58 +01:00
|
|
|
});
|
2023-09-04 00:25:36 +02:00
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
pathJoin(accountV1DirPath, "theme.properties"),
|
|
|
|
Buffer.from(
|
|
|
|
[
|
2023-11-26 16:10:34 +01:00
|
|
|
"accountResourceProvider=account-v1",
|
2023-09-04 00:25:36 +02:00
|
|
|
"",
|
|
|
|
"locales=ar,ca,cs,da,de,en,es,fr,fi,hu,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN",
|
|
|
|
"",
|
2024-02-05 08:52:58 +01:00
|
|
|
"styles=" +
|
|
|
|
[
|
|
|
|
"css/account.css",
|
|
|
|
"img/icon-sidebar-active.png",
|
|
|
|
"img/logo.png",
|
2024-05-20 15:48:51 +02:00
|
|
|
...[
|
|
|
|
"patternfly.min.css",
|
|
|
|
"patternfly-additions.min.css",
|
|
|
|
"patternfly-additions.min.css"
|
|
|
|
].map(
|
|
|
|
fileBasename =>
|
|
|
|
`${resources_common}/node_modules/patternfly/dist/css/${fileBasename}`
|
2024-02-05 08:52:58 +01:00
|
|
|
)
|
|
|
|
].join(" "),
|
2023-09-04 00:25:36 +02:00
|
|
|
"",
|
|
|
|
"##### css classes for form buttons",
|
|
|
|
"# main class used for all buttons",
|
|
|
|
"kcButtonClass=btn",
|
|
|
|
"# classes defining priority of the button - primary or default (there is typically only one priority button for the form)",
|
|
|
|
"kcButtonPrimaryClass=btn-primary",
|
|
|
|
"kcButtonDefaultClass=btn-default",
|
|
|
|
"# classes defining size of the button",
|
|
|
|
"kcButtonLargeClass=btn-lg",
|
|
|
|
""
|
|
|
|
].join("\n"),
|
|
|
|
"utf8"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|