Refactor
This commit is contained in:
parent
9444b897ee
commit
c8ca598465
@ -225,11 +225,6 @@ export async function generateResources(params: {
|
|||||||
|
|
||||||
writeMessagePropertiesFilesByThemeType[themeType] =
|
writeMessagePropertiesFilesByThemeType[themeType] =
|
||||||
writeMessagePropertiesFiles;
|
writeMessagePropertiesFiles;
|
||||||
|
|
||||||
writeMessagePropertiesFiles({
|
|
||||||
messageDirPath: pathJoin(themeTypeDirPath, "messages"),
|
|
||||||
themeName
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bring_in_account_v3_i18n_messages: {
|
bring_in_account_v3_i18n_messages: {
|
||||||
@ -392,12 +387,14 @@ export async function generateResources(params: {
|
|||||||
{
|
{
|
||||||
const metaInfKeycloakThemes: MetaInfKeycloakTheme = { themes: [] };
|
const metaInfKeycloakThemes: MetaInfKeycloakTheme = { themes: [] };
|
||||||
|
|
||||||
|
for (const themeName of buildContext.themeNames) {
|
||||||
metaInfKeycloakThemes.themes.push({
|
metaInfKeycloakThemes.themes.push({
|
||||||
name: themeName,
|
name: themeName,
|
||||||
types: objectEntries(buildContext.implementedThemeTypes)
|
types: objectEntries(buildContext.implementedThemeTypes)
|
||||||
.filter(([, { isImplemented }]) => isImplemented)
|
.filter(([, { isImplemented }]) => isImplemented)
|
||||||
.map(([themeType]) => themeType)
|
.map(([themeType]) => themeType)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (buildContext.implementedThemeTypes.account.isImplemented) {
|
if (buildContext.implementedThemeTypes.account.isImplemented) {
|
||||||
metaInfKeycloakThemes.themes.push({
|
metaInfKeycloakThemes.themes.push({
|
||||||
@ -445,36 +442,22 @@ export async function generateResources(params: {
|
|||||||
return { modifiedSourceCode: sourceCode };
|
return { modifiedSourceCode: sourceCode };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
writeMetaInfKeycloakThemes({
|
|
||||||
resourcesDirPath,
|
|
||||||
getNewMetaInfKeycloakTheme: ({ metaInfKeycloakTheme }) => {
|
|
||||||
assert(metaInfKeycloakTheme !== undefined);
|
|
||||||
|
|
||||||
const newMetaInfKeycloakTheme = metaInfKeycloakTheme;
|
|
||||||
|
|
||||||
newMetaInfKeycloakTheme.themes.push({
|
|
||||||
name: themeVariantName,
|
|
||||||
types: (() => {
|
|
||||||
const theme = newMetaInfKeycloakTheme.themes.find(
|
|
||||||
({ name }) => name === themeName
|
|
||||||
);
|
|
||||||
assert(theme !== undefined);
|
|
||||||
return theme.types;
|
|
||||||
})()
|
|
||||||
});
|
|
||||||
|
|
||||||
return newMetaInfKeycloakTheme;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
for (const themeName of buildContext.themeNames) {
|
||||||
objectEntries(writeMessagePropertiesFilesByThemeType).forEach(
|
objectEntries(writeMessagePropertiesFilesByThemeType).forEach(
|
||||||
([themeType, writeMessagePropertiesFiles]) => {
|
([themeType, writeMessagePropertiesFiles]) => {
|
||||||
if (writeMessagePropertiesFiles === undefined) {
|
if (writeMessagePropertiesFiles === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
writeMessagePropertiesFiles({
|
writeMessagePropertiesFiles({
|
||||||
messageDirPath: pathJoin(themeVariantDirPath, themeType, "messages"),
|
messageDirPath: pathJoin(
|
||||||
|
resourcesDirPath,
|
||||||
|
"theme",
|
||||||
|
themeName,
|
||||||
|
themeType,
|
||||||
|
"messages"
|
||||||
|
),
|
||||||
themeName
|
themeName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -486,15 +469,14 @@ export async function generateResources(params: {
|
|||||||
break email;
|
break email;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const themeVariantName of buildContext.themeNames) {
|
for (const themeName of buildContext.themeNames) {
|
||||||
const themeVariantDirPath = pathJoin(
|
const emailThemeDirPath = pathJoin(
|
||||||
resourcesDirPath,
|
resourcesDirPath,
|
||||||
"theme",
|
"theme",
|
||||||
themeVariantName
|
themeName,
|
||||||
|
"email"
|
||||||
);
|
);
|
||||||
|
|
||||||
const emailThemeDirPath = pathJoin(themeVariantDirPath, "email");
|
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: emailThemeDirPath,
|
srcDirPath: emailThemeDirPath,
|
||||||
destDirPath: emailThemeDirPath,
|
destDirPath: emailThemeDirPath,
|
||||||
@ -507,10 +489,7 @@ export async function generateResources(params: {
|
|||||||
modifiedSourceCode: Buffer.from(
|
modifiedSourceCode: Buffer.from(
|
||||||
sourceCode
|
sourceCode
|
||||||
.toString("utf8")
|
.toString("utf8")
|
||||||
.replace(
|
.replace(/xKeycloakify.themeName/g, `"${themeName}"`),
|
||||||
/xKeycloakify.themeName/g,
|
|
||||||
`"${themeVariantName}"`
|
|
||||||
),
|
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user