Fix previous release
This commit is contained in:
parent
8f6c0d36d9
commit
7840c2a6f5
@ -6,8 +6,7 @@ import {
|
|||||||
join as pathJoin,
|
join as pathJoin,
|
||||||
relative as pathRelative,
|
relative as pathRelative,
|
||||||
dirname as pathDirname,
|
dirname as pathDirname,
|
||||||
extname as pathExtname,
|
basename as pathBasename
|
||||||
sep as pathSep
|
|
||||||
} from "path";
|
} from "path";
|
||||||
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
||||||
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
||||||
@ -37,6 +36,7 @@ import propertiesParser from "properties-parser";
|
|||||||
import { createObjectThatThrowsIfAccessed } from "../../tools/createObjectThatThrowsIfAccessed";
|
import { createObjectThatThrowsIfAccessed } from "../../tools/createObjectThatThrowsIfAccessed";
|
||||||
import { listInstalledModules } from "../../tools/listInstalledModules";
|
import { listInstalledModules } from "../../tools/listInstalledModules";
|
||||||
import { isInside } from "../../tools/isInside";
|
import { isInside } from "../../tools/isInside";
|
||||||
|
import { id } from "tsafe/id";
|
||||||
|
|
||||||
export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
|
export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
|
||||||
BuildContextLike_generateMessageProperties & {
|
BuildContextLike_generateMessageProperties & {
|
||||||
@ -663,7 +663,7 @@ export async function generateResources(params: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const themeVariantName of buildContext.themeNames) {
|
for (const themeVariantName of [...buildContext.themeNames].reverse()) {
|
||||||
for (const themeType of [...THEME_TYPES, "email"] as const) {
|
for (const themeType of [...THEME_TYPES, "email"] as const) {
|
||||||
copy_main_theme_to_theme_variant_theme: {
|
copy_main_theme_to_theme_variant_theme: {
|
||||||
let isNative: boolean;
|
let isNative: boolean;
|
||||||
@ -678,44 +678,59 @@ export async function generateResources(params: {
|
|||||||
isNative = !v.isImplemented && v.isImplemented_native;
|
isNative = !v.isImplemented && v.isImplemented_native;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (themeVariantName === themeName) {
|
if (!isNative && themeVariantName === themeName) {
|
||||||
break copy_main_theme_to_theme_variant_theme;
|
break copy_main_theme_to_theme_variant_theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: pathJoin(resourcesDirPath, "theme", themeName, themeType),
|
srcDirPath: getThemeTypeDirPath({ themeName, themeType }),
|
||||||
destDirPath: pathJoin(
|
destDirPath: getThemeTypeDirPath({
|
||||||
resourcesDirPath,
|
themeName: themeVariantName,
|
||||||
"theme",
|
|
||||||
themeVariantName,
|
|
||||||
themeType
|
themeType
|
||||||
),
|
}),
|
||||||
transformSourceCode: isNative
|
transformSourceCode: ({ fileRelativePath, sourceCode }) => {
|
||||||
? undefined
|
patch_xKeycloakify_themeName: {
|
||||||
: ({ fileRelativePath, sourceCode }) => {
|
if (!fileRelativePath.endsWith(".ftl")) {
|
||||||
if (
|
break patch_xKeycloakify_themeName;
|
||||||
pathExtname(fileRelativePath) === ".ftl" &&
|
}
|
||||||
fileRelativePath.split(pathSep).length === 1
|
|
||||||
) {
|
|
||||||
const modifiedSourceCode = Buffer.from(
|
|
||||||
Buffer.from(sourceCode)
|
|
||||||
.toString("utf-8")
|
|
||||||
.replace(
|
|
||||||
`"themeName": "${themeName}"`,
|
|
||||||
`"themeName": "${themeVariantName}"`
|
|
||||||
),
|
|
||||||
"utf8"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
if (
|
||||||
Buffer.compare(modifiedSourceCode, sourceCode) !== 0
|
!isNative &&
|
||||||
);
|
pathBasename(fileRelativePath) !== fileRelativePath
|
||||||
|
) {
|
||||||
|
break patch_xKeycloakify_themeName;
|
||||||
|
}
|
||||||
|
|
||||||
return { modifiedSourceCode };
|
const modifiedSourceCode = Buffer.from(
|
||||||
}
|
Buffer.from(sourceCode)
|
||||||
|
.toString("utf-8")
|
||||||
|
.replace(
|
||||||
|
...id<[string | RegExp, string]>(
|
||||||
|
isNative
|
||||||
|
? [
|
||||||
|
/xKeycloakify\.themeName/g,
|
||||||
|
`"${themeVariantName}"`
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
`"themeName": "${themeName}"`,
|
||||||
|
`"themeName": "${themeVariantName}"`
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
return { modifiedSourceCode: sourceCode };
|
if (!isNative) {
|
||||||
}
|
assert(
|
||||||
|
Buffer.compare(modifiedSourceCode, sourceCode) !== 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { modifiedSourceCode };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { modifiedSourceCode: sourceCode };
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run_writeMessagePropertiesFiles: {
|
run_writeMessagePropertiesFiles: {
|
||||||
@ -734,42 +749,6 @@ export async function generateResources(params: {
|
|||||||
themeName: themeVariantName
|
themeName: themeVariantName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
replace_xKeycloakify_themeName_in_native_ftl_files: {
|
|
||||||
{
|
|
||||||
const v = buildContext.implementedThemeTypes[themeType];
|
|
||||||
|
|
||||||
if (v.isImplemented || !v.isImplemented_native) {
|
|
||||||
break replace_xKeycloakify_themeName_in_native_ftl_files;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const emailThemeDirPath = getThemeTypeDirPath({
|
|
||||||
themeName: themeVariantName,
|
|
||||||
themeType
|
|
||||||
});
|
|
||||||
|
|
||||||
transformCodebase({
|
|
||||||
srcDirPath: emailThemeDirPath,
|
|
||||||
destDirPath: emailThemeDirPath,
|
|
||||||
transformSourceCode: ({ filePath, sourceCode }) => {
|
|
||||||
if (!filePath.endsWith(".ftl")) {
|
|
||||||
return { modifiedSourceCode: sourceCode };
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
modifiedSourceCode: Buffer.from(
|
|
||||||
sourceCode
|
|
||||||
.toString("utf8")
|
|
||||||
.replace(
|
|
||||||
/xKeycloakify\.themeName/g,
|
|
||||||
`"${themeVariantName}"`
|
|
||||||
),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user