From 7f5eabb639ea52c935ec6753644b8f4334ba8181 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 17 Nov 2024 19:25:53 +0100 Subject: [PATCH] Format page when ejecting for the account --- src/bin/eject-page.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/bin/eject-page.ts b/src/bin/eject-page.ts index f85491d5..e411c9a6 100644 --- a/src/bin/eject-page.ts +++ b/src/bin/eject-page.ts @@ -83,13 +83,13 @@ export async function command(params: { buildContext: BuildContext }) { pathDirname(buildContext.packageJsonFilePath), "node_modules", "@keycloakify", - `keycloak-${themeType}-ui`, + `keycloak-account-ui`, "src" ); 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:`, ``, `${chalk.bold(pathJoin(pathRelative(process.cwd(), srcDirPath)))}`, @@ -98,9 +98,9 @@ export async function command(params: { buildContext: BuildContext }) { ); 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); @@ -120,11 +120,22 @@ export async function command(params: { buildContext: BuildContext }) { "" ); - const modifiedKcPageTsxCode = kcPageTsxCode.replace( - `@keycloakify/keycloak-${themeType}-ui/${componentName}`, + let modifiedKcPageTsxCode = kcPageTsxCode.replace( + `@keycloakify/keycloak-account-ui/${componentName}`, `./${componentName}` ); + run_prettier: { + if (!(await getIsPrettierAvailable())) { + break run_prettier; + } + + modifiedKcPageTsxCode = await runPrettier({ + filePath: kcPageTsxFilePath, + sourceCode: modifiedKcPageTsxCode + }); + } + fs.writeFileSync( kcPageTsxFilePath, Buffer.from(modifiedKcPageTsxCode, "utf8")