up
This commit is contained in:
parent
b0aa0feab5
commit
db37320280
@ -91,36 +91,27 @@ export async function command(params: { buildContext: BuildContext }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
eject_entrypoint: {
|
eject_entrypoint: {
|
||||||
const kcAccountUiTsxFileRelativePath =
|
const kcUiTsxFileRelativePath = `Kc${capitalize(themeType)}Ui.tsx` as const;
|
||||||
`Kc${capitalize(themeType)}Ui.tsx` as const;
|
|
||||||
|
|
||||||
const accountThemeSrcDirPath = pathJoin(
|
const themeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, themeType);
|
||||||
buildContext.themeSrcDirPath,
|
|
||||||
"account"
|
|
||||||
);
|
|
||||||
|
|
||||||
const targetFilePath = pathJoin(
|
const targetFilePath = pathJoin(themeSrcDirPath, kcUiTsxFileRelativePath);
|
||||||
accountThemeSrcDirPath,
|
|
||||||
kcAccountUiTsxFileRelativePath
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fs.existsSync(targetFilePath)) {
|
if (fs.existsSync(targetFilePath)) {
|
||||||
break eject_entrypoint;
|
break eject_entrypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.cpSync(
|
fs.cpSync(pathJoin(srcDirPath, kcUiTsxFileRelativePath), targetFilePath);
|
||||||
pathJoin(srcDirPath, kcAccountUiTsxFileRelativePath),
|
|
||||||
targetFilePath
|
|
||||||
);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const kcPageTsxFilePath = pathJoin(accountThemeSrcDirPath, "KcPage.tsx");
|
const kcPageTsxFilePath = pathJoin(themeSrcDirPath, "KcPage.tsx");
|
||||||
|
|
||||||
const kcPageTsxCode = fs.readFileSync(kcPageTsxFilePath).toString("utf8");
|
const kcPageTsxCode = fs.readFileSync(kcPageTsxFilePath).toString("utf8");
|
||||||
|
|
||||||
const componentName = pathBasename(
|
const componentName = pathBasename(kcUiTsxFileRelativePath).replace(
|
||||||
kcAccountUiTsxFileRelativePath
|
/.tsx$/,
|
||||||
).replace(/.tsx$/, "");
|
""
|
||||||
|
);
|
||||||
|
|
||||||
const modifiedKcPageTsxCode = kcPageTsxCode.replace(
|
const modifiedKcPageTsxCode = kcPageTsxCode.replace(
|
||||||
`@keycloakify/keycloak-${themeType}-ui/${componentName}`,
|
`@keycloakify/keycloak-${themeType}-ui/${componentName}`,
|
||||||
@ -142,8 +133,8 @@ export async function command(params: { buildContext: BuildContext }) {
|
|||||||
[
|
[
|
||||||
`To help you get started ${chalk.bold(pathRelative(process.cwd(), targetFilePath))} has been copied into your project.`,
|
`To help you get started ${chalk.bold(pathRelative(process.cwd(), targetFilePath))} has been copied into your project.`,
|
||||||
`The next step is usually to eject ${chalk.bold(routesTsxFilePath)}`,
|
`The next step is usually to eject ${chalk.bold(routesTsxFilePath)}`,
|
||||||
`with \`cp ${routesTsxFilePath} ${pathRelative(process.cwd(), accountThemeSrcDirPath)}\``,
|
`with \`cp ${routesTsxFilePath} ${pathRelative(process.cwd(), themeSrcDirPath)}\``,
|
||||||
`then update the import of routes in ${kcAccountUiTsxFileRelativePath}.`
|
`then update the import of routes in ${kcUiTsxFileRelativePath}.`
|
||||||
].join("\n")
|
].join("\n")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user