Format page when ejecting for the account

This commit is contained in:
Joseph Garrone 2024-11-17 19:25:53 +01:00
parent 32fb1e2f71
commit 7f5eabb639

View File

@ -83,13 +83,13 @@ export async function command(params: { buildContext: BuildContext }) {
pathDirname(buildContext.packageJsonFilePath), pathDirname(buildContext.packageJsonFilePath),
"node_modules", "node_modules",
"@keycloakify", "@keycloakify",
`keycloak-${themeType}-ui`, `keycloak-account-ui`,
"src" "src"
); );
console.log( console.log(
[ [
`There isn't an interactive CLI to eject components of the ${themeType} UI.`, `There isn't an interactive CLI to eject components of the Account SPA UI.`,
`You can however copy paste into your codebase the any file or directory from the following source directory:`, `You can however copy paste into your codebase the any file or directory from the following source directory:`,
``, ``,
`${chalk.bold(pathJoin(pathRelative(process.cwd(), srcDirPath)))}`, `${chalk.bold(pathJoin(pathRelative(process.cwd(), srcDirPath)))}`,
@ -98,9 +98,9 @@ export async function command(params: { buildContext: BuildContext }) {
); );
eject_entrypoint: { eject_entrypoint: {
const kcUiTsxFileRelativePath = `Kc${capitalize(themeType)}Ui.tsx` as const; const kcUiTsxFileRelativePath = `KcAccountUi.tsx` as const;
const themeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, themeType); const themeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "account");
const targetFilePath = pathJoin(themeSrcDirPath, kcUiTsxFileRelativePath); const targetFilePath = pathJoin(themeSrcDirPath, kcUiTsxFileRelativePath);
@ -120,11 +120,22 @@ export async function command(params: { buildContext: BuildContext }) {
"" ""
); );
const modifiedKcPageTsxCode = kcPageTsxCode.replace( let modifiedKcPageTsxCode = kcPageTsxCode.replace(
`@keycloakify/keycloak-${themeType}-ui/${componentName}`, `@keycloakify/keycloak-account-ui/${componentName}`,
`./${componentName}` `./${componentName}`
); );
run_prettier: {
if (!(await getIsPrettierAvailable())) {
break run_prettier;
}
modifiedKcPageTsxCode = await runPrettier({
filePath: kcPageTsxFilePath,
sourceCode: modifiedKcPageTsxCode
});
}
fs.writeFileSync( fs.writeFileSync(
kcPageTsxFilePath, kcPageTsxFilePath,
Buffer.from(modifiedKcPageTsxCode, "utf8") Buffer.from(modifiedKcPageTsxCode, "utf8")