From 014f7cdb234e28b27c416553821d92ddaf4a5811 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 25 Jul 2024 17:53:02 +0200 Subject: [PATCH 1/3] Make the account theme initialized by a cli command --- src/account/KcContext.ts | 12 ----------- src/account/KcPage.tsx | 33 ----------------------------- src/account/KcPageStory.tsx | 42 ------------------------------------- src/account/i18n.ts | 5 ----- vite.config.ts | 4 +++- 5 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 src/account/KcContext.ts delete mode 100644 src/account/KcPage.tsx delete mode 100644 src/account/KcPageStory.tsx delete mode 100644 src/account/i18n.ts diff --git a/src/account/KcContext.ts b/src/account/KcContext.ts deleted file mode 100644 index a043f25..0000000 --- a/src/account/KcContext.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ -import type { ExtendKcContext } from "keycloakify/account"; -import type { KcEnvName, ThemeName } from "../kc.gen"; - -export type KcContextExtension = { - themeName: ThemeName; - properties: Record & {}; -}; - -export type KcContextExtensionPerPage = {}; - -export type KcContext = ExtendKcContext; diff --git a/src/account/KcPage.tsx b/src/account/KcPage.tsx deleted file mode 100644 index f743327..0000000 --- a/src/account/KcPage.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Suspense } from "react"; -import type { ClassKey } from "keycloakify/account"; -import type { KcContext } from "./KcContext"; -import { useI18n } from "./i18n"; -import DefaultPage from "keycloakify/account/DefaultPage"; -import Template from "keycloakify/account/Template"; - -export default function KcPage(props: { kcContext: KcContext }) { - const { kcContext } = props; - - const { i18n } = useI18n({ kcContext }); - - return ( - - {(() => { - switch (kcContext.pageId) { - default: - return ( - - ); - } - })()} - - ); -} - -const classes = {} satisfies { [key in ClassKey]?: string }; diff --git a/src/account/KcPageStory.tsx b/src/account/KcPageStory.tsx deleted file mode 100644 index f9656b2..0000000 --- a/src/account/KcPageStory.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import type { DeepPartial } from "keycloakify/tools/DeepPartial"; -import type { KcContext } from "./KcContext"; -import { createGetKcContextMock } from "keycloakify/account/KcContext"; -import type { KcContextExtension, KcContextExtensionPerPage } from "./KcContext"; -import KcPage from "./KcPage"; -import { themeNames, kcEnvDefaults } from "../kc.gen"; - -const kcContextExtension: KcContextExtension = { - themeName: themeNames[0], - properties: { - ...kcEnvDefaults - } -}; -const kcContextExtensionPerPage: KcContextExtensionPerPage = {}; - -export const { getKcContextMock } = createGetKcContextMock({ - kcContextExtension, - kcContextExtensionPerPage, - overrides: {}, - overridesPerPage: {} -}); - -export function createKcPageStory(params: { - pageId: PageId; -}) { - const { pageId } = params; - - function KcPageStory(props: { - kcContext?: DeepPartial>; - }) { - const { kcContext: overrides } = props; - - const kcContextMock = getKcContextMock({ - pageId, - overrides - }); - - return ; - } - - return { KcPageStory }; -} diff --git a/src/account/i18n.ts b/src/account/i18n.ts deleted file mode 100644 index c4ad70c..0000000 --- a/src/account/i18n.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createUseI18n } from "keycloakify/account"; - -export const { useI18n, ofTypeI18n } = createUseI18n({}); - -export type I18n = typeof ofTypeI18n; diff --git a/vite.config.ts b/vite.config.ts index 5b465e7..cb8365c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,5 +4,7 @@ import { keycloakify } from "keycloakify/vite-plugin"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), keycloakify({})] + plugins: [react(), keycloakify({ + accountThemeImplementation: "none" + })] }); From 91e5c92b79fe5a0ad974906a666b33ff3f3ea7b1 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 25 Jul 2024 20:12:55 +0200 Subject: [PATCH 2/3] Update keycloakify --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 510126c..b267ce1 100755 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "license": "MIT", "keywords": [], "dependencies": { - "keycloakify": "10.0.0-rc.117", + "keycloakify": "10.0.0-rc.119", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/yarn.lock b/yarn.lock index 838657c..614cabe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4015,10 +4015,10 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -keycloakify@10.0.0-rc.117: - version "10.0.0-rc.117" - resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.117.tgz#f72454dedcd5a4a5f49c50af3d9284fceadcd345" - integrity sha512-YopVW4sLLIz/9Iia/Hfvt1ZI4DpPPg724IN2LP9pKGU1UDsjU/zFyF9J6Aqv/gXUua+Kz2oNcD0bNiig1DmalA== +keycloakify@10.0.0-rc.119: + version "10.0.0-rc.119" + resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.119.tgz#511a2ae2c2e8ae9116de27e2ff51424beea8807c" + integrity sha512-PCTgJEg+hMcFdR0tfxG1eXGbCeLRNRVmzGqb3O8Wg/NGgcP5Snt8WLzIDhIaKiLpXJq8NuKam2VZxOWT+UEbfA== dependencies: tsafe "^1.6.6" From 4962e163957e25550deef99b278f917aaea511e8 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 25 Jul 2024 20:28:20 +0200 Subject: [PATCH 3/3] Add instructions on how to initialize the account theme --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8122560..aa9fb9c 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,18 @@ npm run build-keycloak-theme Note that by default Keycloakify generates multiple .jar files for different versions of Keycloak. You can customize this behavior, see documentation [here](https://docs.keycloakify.dev/v/v10/targetting-specific-keycloak-versions). +# Initializing the account theme + +```bash +npx keycloakify initialize-account-theme +``` + +# Initializing the email theme + +```bash +npx keycloakify initialize-email-theme +``` + # GitHub Actions The starter comes with a generic GitHub Actions workflow that builds the theme and publishes