Remove retrocompatiblity before re-introducing it
This commit is contained in:
parent
771322aa97
commit
d4f5a1fff4
@ -6,7 +6,6 @@ export const resolvedViteConfigJsonBasename = "vite.json";
|
|||||||
export const basenameOfTheKeycloakifyResourcesDir = "build";
|
export const basenameOfTheKeycloakifyResourcesDir = "build";
|
||||||
|
|
||||||
export const themeTypes = ["login", "account"] as const;
|
export const themeTypes = ["login", "account"] as const;
|
||||||
export const retrocompatPostfix = "_retrocompat";
|
|
||||||
export const accountV1ThemeName = "account-v1";
|
export const accountV1ThemeName = "account-v1";
|
||||||
|
|
||||||
export type ThemeType = (typeof themeTypes)[number];
|
export type ThemeType = (typeof themeTypes)[number];
|
||||||
|
@ -9,7 +9,6 @@ export type UserProvidedBuildOptions = {
|
|||||||
reactAppBuildDirPath?: string;
|
reactAppBuildDirPath?: string;
|
||||||
keycloakifyBuildDirPath?: string;
|
keycloakifyBuildDirPath?: string;
|
||||||
themeName?: string | string[];
|
themeName?: string | string[];
|
||||||
doBuildRetrocompatAccountTheme?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const zUserProvidedBuildOptions = z.object({
|
export const zUserProvidedBuildOptions = z.object({
|
||||||
@ -20,6 +19,5 @@ export const zUserProvidedBuildOptions = z.object({
|
|||||||
"loginThemeResourcesFromKeycloakVersion": z.string().optional(),
|
"loginThemeResourcesFromKeycloakVersion": z.string().optional(),
|
||||||
"reactAppBuildDirPath": z.string().optional(),
|
"reactAppBuildDirPath": z.string().optional(),
|
||||||
"keycloakifyBuildDirPath": z.string().optional(),
|
"keycloakifyBuildDirPath": z.string().optional(),
|
||||||
"themeName": z.union([z.string(), z.array(z.string())]).optional(),
|
"themeName": z.union([z.string(), z.array(z.string())]).optional()
|
||||||
"doBuildRetrocompatAccountTheme": z.boolean().optional()
|
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,6 @@ export type BuildOptions = {
|
|||||||
* In this case the urlPathname will be "/my-app/" */
|
* In this case the urlPathname will be "/my-app/" */
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
doBuildRetrocompatAccountTheme: boolean;
|
|
||||||
npmWorkspaceRootDirPath: string;
|
npmWorkspaceRootDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -187,7 +186,6 @@ export function readBuildOptions(params: { processArgv: string[] }): BuildOption
|
|||||||
|
|
||||||
return pathJoin(reactAppBuildDirPath, resolvedViteConfig.assetsDir);
|
return pathJoin(reactAppBuildDirPath, resolvedViteConfig.assetsDir);
|
||||||
})(),
|
})(),
|
||||||
"doBuildRetrocompatAccountTheme": userProvidedBuildOptions.doBuildRetrocompatAccountTheme ?? true,
|
|
||||||
npmWorkspaceRootDirPath
|
npmWorkspaceRootDirPath
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin, basename as pathBasename, resolve as pathResolve, dirname as pathDirname } from "path";
|
import { join as pathJoin, resolve as pathResolve, dirname as pathDirname } from "path";
|
||||||
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
||||||
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
||||||
import { generateFtlFilesCodeFactory, loginThemePageIds, accountThemePageIds } from "../generateFtl";
|
import { generateFtlFilesCodeFactory, loginThemePageIds, accountThemePageIds } from "../generateFtl";
|
||||||
@ -8,7 +8,6 @@ import {
|
|||||||
type ThemeType,
|
type ThemeType,
|
||||||
lastKeycloakVersionWithAccountV1,
|
lastKeycloakVersionWithAccountV1,
|
||||||
keycloak_resources,
|
keycloak_resources,
|
||||||
retrocompatPostfix,
|
|
||||||
accountV1ThemeName,
|
accountV1ThemeName,
|
||||||
basenameOfTheKeycloakifyResourcesDir
|
basenameOfTheKeycloakifyResourcesDir
|
||||||
} from "../../constants";
|
} from "../../constants";
|
||||||
@ -32,7 +31,6 @@ export type BuildOptionsLike = {
|
|||||||
cacheDirPath: string;
|
cacheDirPath: string;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
doBuildRetrocompatAccountTheme: boolean;
|
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
npmWorkspaceRootDirPath: string;
|
npmWorkspaceRootDirPath: string;
|
||||||
};
|
};
|
||||||
@ -48,17 +46,9 @@ export async function generateTheme(params: {
|
|||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { themeName, themeSrcDirPath, keycloakifySrcDirPath, buildOptions, keycloakifyVersion } = params;
|
const { themeName, themeSrcDirPath, keycloakifySrcDirPath, buildOptions, keycloakifyVersion } = params;
|
||||||
|
|
||||||
const getThemeTypeDirPath = (params: { themeType: ThemeType | "email"; isRetrocompat?: true }) => {
|
const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
|
||||||
const { themeType, isRetrocompat = false } = params;
|
const { themeType } = params;
|
||||||
return pathJoin(
|
return pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme", themeName, themeType);
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
|
||||||
"src",
|
|
||||||
"main",
|
|
||||||
"resources",
|
|
||||||
"theme",
|
|
||||||
`${themeName}${isRetrocompat ? retrocompatPostfix : ""}`,
|
|
||||||
themeType
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const cssGlobalsToDefine: Record<string, string> = {};
|
const cssGlobalsToDefine: Record<string, string> = {};
|
||||||
@ -222,25 +212,6 @@ export async function generateTheme(params: {
|
|||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (themeType === "account" && buildOptions.doBuildRetrocompatAccountTheme) {
|
|
||||||
transformCodebase({
|
|
||||||
"srcDirPath": themeTypeDirPath,
|
|
||||||
"destDirPath": getThemeTypeDirPath({ themeType, "isRetrocompat": true }),
|
|
||||||
"transformSourceCode": ({ filePath, sourceCode }) => {
|
|
||||||
if (pathBasename(filePath) === "theme.properties") {
|
|
||||||
return {
|
|
||||||
"modifiedSourceCode": Buffer.from(
|
|
||||||
sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { "modifiedSourceCode": sourceCode };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
email: {
|
email: {
|
||||||
@ -280,36 +251,6 @@ export async function generateTheme(params: {
|
|||||||
"name": accountV1ThemeName,
|
"name": accountV1ThemeName,
|
||||||
"types": ["account"]
|
"types": ["account"]
|
||||||
});
|
});
|
||||||
|
|
||||||
add_retrocompat_account_theme: {
|
|
||||||
if (!buildOptions.doBuildRetrocompatAccountTheme) {
|
|
||||||
break add_retrocompat_account_theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
transformCodebase({
|
|
||||||
"srcDirPath": getThemeTypeDirPath({ "themeType": "account" }),
|
|
||||||
"destDirPath": getThemeTypeDirPath({ "themeType": "account", "isRetrocompat": true }),
|
|
||||||
"transformSourceCode": ({ filePath, sourceCode }) => {
|
|
||||||
if (pathBasename(filePath) === "theme.properties") {
|
|
||||||
return {
|
|
||||||
"modifiedSourceCode": Buffer.from(
|
|
||||||
sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { "modifiedSourceCode": sourceCode };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buildOptions.themeNames.forEach(themeName =>
|
|
||||||
parsedKeycloakThemeJson.themes.push({
|
|
||||||
"name": `${themeName}${retrocompatPostfix}`,
|
|
||||||
"types": ["account"]
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { generateTheme } from "./generateTheme";
|
import { generateTheme } from "./generateTheme";
|
||||||
import { generatePom } from "./generatePom";
|
import { generatePom } from "./generatePom";
|
||||||
import { join as pathJoin, relative as pathRelative, basename as pathBasename, dirname as pathDirname, sep as pathSep } from "path";
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { generateStartKeycloakTestingContainer } from "./generateStartKeycloakTestingContainer";
|
import { generateStartKeycloakTestingContainer } from "./generateStartKeycloakTestingContainer";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
@ -69,23 +69,6 @@ export async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
child_process.execSync("mvn clean install", { "cwd": buildOptions.keycloakifyBuildDirPath });
|
child_process.execSync("mvn clean install", { "cwd": buildOptions.keycloakifyBuildDirPath });
|
||||||
|
|
||||||
const jarDirPath = pathDirname(jarFilePath);
|
|
||||||
const retrocompatJarFilePath = pathJoin(jarDirPath, "retrocompat-" + pathBasename(jarFilePath));
|
|
||||||
|
|
||||||
fs.renameSync(pathJoin(jarDirPath, "original-" + pathBasename(jarFilePath)), retrocompatJarFilePath);
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
pathJoin(jarDirPath, "README.md"),
|
|
||||||
Buffer.from(
|
|
||||||
[
|
|
||||||
`- The ${jarFilePath} is to be used in Keycloak 23 and up. `,
|
|
||||||
`- The ${retrocompatJarFilePath} is to be used in Keycloak 22 and below.`,
|
|
||||||
` Note that Keycloak 22 is only supported for login and email theme but not for account themes. `
|
|
||||||
].join("\n"),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log(
|
logger.log(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user