2024-09-08 00:06:47 +02:00
|
|
|
import * as fs from "fs";
|
|
|
|
import { join as pathJoin } from "path";
|
2024-09-08 12:00:07 +02:00
|
|
|
import { KEYCLOAK_VERSION } from "../shared/constants";
|
2024-09-08 00:06:47 +02:00
|
|
|
import { transformCodebase } from "../../src/bin/tools/transformCodebase";
|
2024-09-08 12:00:07 +02:00
|
|
|
import { downloadKeycloakDefaultTheme } from "../shared/downloadKeycloakDefaultTheme";
|
2024-09-08 00:06:47 +02:00
|
|
|
import { WELL_KNOWN_DIRECTORY_BASE_NAME } from "../../src/bin/shared/constants";
|
|
|
|
import { getThisCodebaseRootDirPath } from "../../src/bin/tools/getThisCodebaseRootDirPath";
|
2024-09-08 12:00:07 +02:00
|
|
|
import { accountMultiPageSupportedLanguages } from "../generate-i18n-messages";
|
|
|
|
import * as fsPr from "fs/promises";
|
2024-09-08 00:06:47 +02:00
|
|
|
|
|
|
|
export async function createAccountV1Dir() {
|
|
|
|
const { extractedDirPath } = await downloadKeycloakDefaultTheme({
|
|
|
|
keycloakVersion: KEYCLOAK_VERSION.FOR_ACCOUNT_MULTI_PAGE
|
|
|
|
});
|
|
|
|
|
2024-09-08 12:06:49 +02:00
|
|
|
const destDirPath = pathJoin(
|
|
|
|
getThisCodebaseRootDirPath(),
|
|
|
|
"dist",
|
|
|
|
"res",
|
|
|
|
"account-v1"
|
|
|
|
);
|
2024-09-08 00:06:47 +02:00
|
|
|
|
2024-09-08 12:00:07 +02:00
|
|
|
await fsPr.rm(destDirPath, { recursive: true, force: true });
|
2024-09-08 00:06:47 +02:00
|
|
|
|
|
|
|
transformCodebase({
|
|
|
|
srcDirPath: pathJoin(extractedDirPath, "base", "account"),
|
|
|
|
destDirPath
|
|
|
|
});
|
|
|
|
|
|
|
|
transformCodebase({
|
|
|
|
srcDirPath: pathJoin(extractedDirPath, "keycloak", "account", "resources"),
|
|
|
|
destDirPath: pathJoin(destDirPath, "resources")
|
|
|
|
});
|
|
|
|
|
|
|
|
transformCodebase({
|
|
|
|
srcDirPath: pathJoin(extractedDirPath, "keycloak", "common", "resources"),
|
|
|
|
destDirPath: pathJoin(
|
|
|
|
destDirPath,
|
|
|
|
"resources",
|
|
|
|
WELL_KNOWN_DIRECTORY_BASE_NAME.RESOURCES_COMMON
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
pathJoin(destDirPath, "theme.properties"),
|
|
|
|
Buffer.from(
|
|
|
|
[
|
|
|
|
"accountResourceProvider=account-v1",
|
|
|
|
"",
|
|
|
|
`locales=${accountMultiPageSupportedLanguages.join(",")}`,
|
|
|
|
"",
|
|
|
|
"styles=" +
|
|
|
|
[
|
|
|
|
"css/account.css",
|
|
|
|
"img/icon-sidebar-active.png",
|
|
|
|
"img/logo.png",
|
|
|
|
...[
|
|
|
|
"patternfly.min.css",
|
|
|
|
"patternfly-additions.min.css",
|
|
|
|
"patternfly-additions.min.css"
|
|
|
|
].map(
|
|
|
|
fileBasename =>
|
|
|
|
`${WELL_KNOWN_DIRECTORY_BASE_NAME.RESOURCES_COMMON}/node_modules/patternfly/dist/css/${fileBasename}`
|
|
|
|
)
|
|
|
|
].join(" "),
|
|
|
|
"",
|
|
|
|
"##### 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"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|