keycloakify 10.0.0-rc.37 → 10.0.0-rc.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account/Fallback.d.ts +1 -2
- package/account/Fallback.js.map +1 -1
- package/account/KcContext/KcContext.d.ts +6 -6
- package/account/KcContext/getKcContextMock.d.ts +9 -9
- package/account/KcContext/getKcContextMock.js +3 -3
- package/account/KcContext/getKcContextMock.js.map +1 -1
- package/account/Template.d.ts +1 -2
- package/account/Template.js +7 -6
- package/account/Template.js.map +1 -1
- package/account/TemplateProps.d.ts +1 -3
- package/account/i18n/i18n.d.ts +9 -4
- package/account/i18n/i18n.js +132 -87
- package/account/i18n/i18n.js.map +1 -1
- package/account/i18n/index.d.ts +9 -2
- package/account/i18n/index.js +5 -1
- package/account/i18n/index.js.map +1 -1
- package/account/lib/kcClsx.d.ts +9 -0
- package/account/lib/{useGetClassName.js → kcClsx.js} +3 -3
- package/account/lib/kcClsx.js.map +1 -0
- package/account/pages/Account.d.ts +1 -2
- package/account/pages/Account.js +9 -7
- package/account/pages/Account.js.map +1 -1
- package/account/pages/Applications.d.ts +1 -2
- package/account/pages/Applications.js +7 -7
- package/account/pages/Applications.js.map +1 -1
- package/account/pages/FederatedIdentity.d.ts +1 -2
- package/account/pages/FederatedIdentity.js +4 -3
- package/account/pages/FederatedIdentity.js.map +1 -1
- package/account/pages/Log.d.ts +1 -2
- package/account/pages/Log.js +6 -5
- package/account/pages/Log.js.map +1 -1
- package/account/pages/PageProps.d.ts +2 -4
- package/account/pages/Password.d.ts +1 -2
- package/account/pages/Password.js +10 -9
- package/account/pages/Password.js.map +1 -1
- package/account/pages/Sessions.d.ts +1 -2
- package/account/pages/Sessions.js +6 -6
- package/account/pages/Sessions.js.map +1 -1
- package/account/pages/Totp.d.ts +1 -2
- package/account/pages/Totp.js +6 -5
- package/account/pages/Totp.js.map +1 -1
- package/bin/193.index.js +13 -13
- package/bin/{430.index.js → 214.index.js} +161 -2
- package/bin/3.index.js +165 -149
- package/bin/322.index.js +595 -0
- package/bin/453.index.js +3 -3
- package/bin/526.index.js +42 -632
- package/bin/538.index.js +563 -0
- package/bin/932.index.js +7 -7
- package/bin/{890.index.js → 941.index.js} +2 -159
- package/bin/944.index.js +621 -0
- package/bin/961.index.js +5 -5
- package/bin/97.index.js +3 -3
- package/bin/{314.index.js → 98.index.js} +217 -48
- package/bin/main.js +20 -8
- package/lib/getKcClsx.d.ts +11 -0
- package/lib/getKcClsx.js +55 -0
- package/lib/getKcClsx.js.map +1 -0
- package/login/Fallback.d.ts +2 -2
- package/login/Fallback.js.map +1 -1
- package/login/KcContext/KcContext.d.ts +6 -6
- package/login/KcContext/getKcContextMock.d.ts +9 -9
- package/login/KcContext/getKcContextMock.js +3 -3
- package/login/KcContext/getKcContextMock.js.map +1 -1
- package/login/Template.d.ts +1 -2
- package/login/Template.js +10 -9
- package/login/Template.js.map +1 -1
- package/login/TemplateProps.d.ts +1 -3
- package/login/UserProfileFormFields.d.ts +6 -5
- package/login/UserProfileFormFields.js +35 -36
- package/login/UserProfileFormFields.js.map +1 -1
- package/login/i18n/i18n.d.ts +9 -4
- package/login/i18n/i18n.js +136 -91
- package/login/i18n/i18n.js.map +1 -1
- package/login/i18n/index.d.ts +9 -2
- package/login/i18n/index.js +5 -1
- package/login/i18n/index.js.map +1 -1
- package/login/lib/kcClsx.d.ts +9 -0
- package/login/lib/{useGetClassName.js → kcClsx.js} +3 -3
- package/login/lib/kcClsx.js.map +1 -0
- package/login/lib/useUserProfileForm.d.ts +9 -6
- package/login/lib/useUserProfileForm.js +7 -5
- package/login/lib/useUserProfileForm.js.map +1 -1
- package/login/pages/Code.d.ts +1 -2
- package/login/pages/Code.js +6 -5
- package/login/pages/Code.js.map +1 -1
- package/login/pages/DeleteAccountConfirm.d.ts +1 -2
- package/login/pages/DeleteAccountConfirm.js +7 -7
- package/login/pages/DeleteAccountConfirm.js.map +1 -1
- package/login/pages/DeleteCredential.d.ts +1 -2
- package/login/pages/DeleteCredential.js +6 -6
- package/login/pages/DeleteCredential.js.map +1 -1
- package/login/pages/Error.d.ts +1 -2
- package/login/pages/Error.js +4 -3
- package/login/pages/Error.js.map +1 -1
- package/login/pages/FrontchannelLogout.d.ts +1 -2
- package/login/pages/FrontchannelLogout.js +4 -3
- package/login/pages/FrontchannelLogout.js.map +1 -1
- package/login/pages/IdpReviewUserProfile.d.ts +2 -2
- package/login/pages/IdpReviewUserProfile.js +6 -6
- package/login/pages/IdpReviewUserProfile.js.map +1 -1
- package/login/pages/Info.d.ts +1 -2
- package/login/pages/Info.js +4 -3
- package/login/pages/Info.js.map +1 -1
- package/login/pages/Login.d.ts +1 -2
- package/login/pages/Login.js +10 -8
- package/login/pages/Login.js.map +1 -1
- package/login/pages/LoginConfigTotp.d.ts +1 -2
- package/login/pages/LoginConfigTotp.js +8 -7
- package/login/pages/LoginConfigTotp.js.map +1 -1
- package/login/pages/LoginIdpLinkConfirm.d.ts +1 -2
- package/login/pages/LoginIdpLinkConfirm.js +6 -6
- package/login/pages/LoginIdpLinkConfirm.js.map +1 -1
- package/login/pages/LoginIdpLinkEmail.d.ts +1 -2
- package/login/pages/LoginIdpLinkEmail.js +4 -3
- package/login/pages/LoginIdpLinkEmail.js.map +1 -1
- package/login/pages/LoginOauth2DeviceVerifyUserCode.d.ts +1 -2
- package/login/pages/LoginOauth2DeviceVerifyUserCode.js +6 -6
- package/login/pages/LoginOauth2DeviceVerifyUserCode.js.map +1 -1
- package/login/pages/LoginOauthGrant.d.ts +1 -2
- package/login/pages/LoginOauthGrant.js +7 -7
- package/login/pages/LoginOauthGrant.js.map +1 -1
- package/login/pages/LoginOtp.d.ts +1 -2
- package/login/pages/LoginOtp.js +6 -6
- package/login/pages/LoginOtp.js.map +1 -1
- package/login/pages/LoginPageExpired.d.ts +1 -2
- package/login/pages/LoginPageExpired.js +4 -3
- package/login/pages/LoginPageExpired.js.map +1 -1
- package/login/pages/LoginPassword.d.ts +1 -2
- package/login/pages/LoginPassword.js +9 -7
- package/login/pages/LoginPassword.js.map +1 -1
- package/login/pages/LoginRecoveryAuthnCodeConfig.d.ts +1 -2
- package/login/pages/LoginRecoveryAuthnCodeConfig.js +9 -7
- package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
- package/login/pages/LoginRecoveryAuthnCodeInput.d.ts +1 -2
- package/login/pages/LoginRecoveryAuthnCodeInput.js +6 -6
- package/login/pages/LoginRecoveryAuthnCodeInput.js.map +1 -1
- package/login/pages/LoginResetOtp.d.ts +1 -2
- package/login/pages/LoginResetOtp.js +6 -6
- package/login/pages/LoginResetOtp.js.map +1 -1
- package/login/pages/LoginResetPassword.d.ts +1 -2
- package/login/pages/LoginResetPassword.js +7 -7
- package/login/pages/LoginResetPassword.js.map +1 -1
- package/login/pages/LoginUpdatePassword.d.ts +1 -2
- package/login/pages/LoginUpdatePassword.js +10 -9
- package/login/pages/LoginUpdatePassword.js.map +1 -1
- package/login/pages/LoginUpdateProfile.d.ts +2 -2
- package/login/pages/LoginUpdateProfile.js +7 -12
- package/login/pages/LoginUpdateProfile.js.map +1 -1
- package/login/pages/LoginUsername.d.ts +1 -2
- package/login/pages/LoginUsername.js +8 -7
- package/login/pages/LoginUsername.js.map +1 -1
- package/login/pages/LoginVerifyEmail.d.ts +1 -2
- package/login/pages/LoginVerifyEmail.js +4 -3
- package/login/pages/LoginVerifyEmail.js.map +1 -1
- package/login/pages/LoginX509Info.d.ts +1 -2
- package/login/pages/LoginX509Info.js +6 -6
- package/login/pages/LoginX509Info.js.map +1 -1
- package/login/pages/LogoutConfirm.d.ts +1 -2
- package/login/pages/LogoutConfirm.js +6 -6
- package/login/pages/LogoutConfirm.js.map +1 -1
- package/login/pages/PageProps.d.ts +2 -4
- package/login/pages/Register.d.ts +2 -2
- package/login/pages/Register.js +8 -16
- package/login/pages/Register.js.map +1 -1
- package/login/pages/SamlPostForm.d.ts +1 -2
- package/login/pages/SamlPostForm.js +4 -3
- package/login/pages/SamlPostForm.js.map +1 -1
- package/login/pages/SelectAuthenticator.d.ts +1 -2
- package/login/pages/SelectAuthenticator.js +6 -9
- package/login/pages/SelectAuthenticator.js.map +1 -1
- package/login/pages/Terms.d.ts +1 -2
- package/login/pages/Terms.js +6 -6
- package/login/pages/Terms.js.map +1 -1
- package/login/pages/UpdateEmail.d.ts +2 -2
- package/login/pages/UpdateEmail.js +8 -12
- package/login/pages/UpdateEmail.js.map +1 -1
- package/login/pages/WebauthnAuthenticate.d.ts +1 -2
- package/login/pages/WebauthnAuthenticate.js +13 -12
- package/login/pages/WebauthnAuthenticate.js.map +1 -1
- package/login/pages/WebauthnError.d.ts +1 -2
- package/login/pages/WebauthnError.js +7 -7
- package/login/pages/WebauthnError.js.map +1 -1
- package/login/pages/WebauthnRegister.d.ts +1 -2
- package/login/pages/WebauthnRegister.js +9 -8
- package/login/pages/WebauthnRegister.js.map +1 -1
- package/package.json +27 -22
- package/src/account/Fallback.tsx +1 -2
- package/src/account/KcContext/KcContext.ts +7 -7
- package/src/account/KcContext/getKcContextMock.ts +13 -24
- package/src/account/Template.tsx +8 -8
- package/src/account/TemplateProps.ts +1 -6
- package/src/account/i18n/i18n.tsx +204 -125
- package/src/account/i18n/index.ts +10 -2
- package/src/account/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
- package/src/account/pages/Account.tsx +15 -21
- package/src/account/pages/Applications.tsx +8 -9
- package/src/account/pages/FederatedIdentity.tsx +5 -5
- package/src/account/pages/Log.tsx +8 -8
- package/src/account/pages/PageProps.ts +2 -4
- package/src/account/pages/Password.tsx +13 -16
- package/src/account/pages/Sessions.tsx +9 -10
- package/src/account/pages/Totp.tsx +19 -28
- package/src/bin/add-story.ts +3 -3
- package/src/bin/copy-keycloak-resources-to-public.ts +3 -3
- package/src/bin/download-keycloak-default-theme.ts +5 -5
- package/src/bin/eject-page.ts +3 -3
- package/src/bin/initialize-email-theme.ts +5 -5
- package/src/bin/keycloakify/buildJars/buildJar.ts +14 -14
- package/src/bin/keycloakify/buildJars/buildJars.ts +8 -8
- package/src/bin/keycloakify/buildJars/generatePom.ts +9 -9
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +12 -12
- package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +7 -7
- package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +2 -66
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +9 -9
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +30 -24
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +8 -8
- package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +9 -9
- package/src/bin/keycloakify/keycloakify.ts +11 -11
- package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +6 -6
- package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +7 -7
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +10 -10
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +13 -13
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +11 -11
- package/src/bin/main.ts +17 -2
- package/src/bin/shared/{buildOptions.ts → buildContext.ts} +65 -51
- package/src/bin/shared/copyKeycloakResourcesToPublic.ts +12 -12
- package/src/bin/shared/downloadKeycloakDefaultTheme.ts +7 -7
- package/src/bin/shared/downloadKeycloakStaticResources.ts +7 -7
- package/src/bin/shared/generateKcGenTs.ts +61 -0
- package/src/bin/shared/getThemeSrcDirPath.ts +3 -3
- package/src/bin/start-keycloak/appBuild.ts +11 -11
- package/src/bin/start-keycloak/keycloakifyBuild.ts +7 -7
- package/src/bin/start-keycloak/start-keycloak.ts +34 -22
- package/src/bin/tools/escapeStringForPropertiesFile.ts +64 -0
- package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +3 -3
- package/src/bin/update-kc-gen.ts +13 -0
- package/src/lib/getKcClsx.ts +89 -0
- package/src/login/Fallback.tsx +2 -2
- package/src/login/KcContext/KcContext.ts +7 -7
- package/src/login/KcContext/getKcContextMock.ts +13 -24
- package/src/login/Template.tsx +36 -37
- package/src/login/TemplateProps.ts +1 -6
- package/src/login/UserProfileFormFields.tsx +67 -84
- package/src/login/i18n/i18n.tsx +208 -129
- package/src/login/i18n/index.ts +10 -2
- package/src/login/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
- package/src/login/lib/useUserProfileForm.tsx +29 -21
- package/src/login/pages/Code.tsx +10 -8
- package/src/login/pages/DeleteAccountConfirm.tsx +9 -10
- package/src/login/pages/DeleteCredential.tsx +11 -10
- package/src/login/pages/Error.tsx +5 -5
- package/src/login/pages/FrontchannelLogout.tsx +7 -5
- package/src/login/pages/IdpReviewUserProfile.tsx +18 -21
- package/src/login/pages/Info.tsx +7 -5
- package/src/login/pages/Login.tsx +34 -53
- package/src/login/pages/LoginConfigTotp.tsx +30 -38
- package/src/login/pages/LoginIdpLinkConfirm.tsx +10 -21
- package/src/login/pages/LoginIdpLinkEmail.tsx +5 -5
- package/src/login/pages/LoginOauth2DeviceVerifyUserCode.tsx +19 -24
- package/src/login/pages/LoginOauthGrant.tsx +14 -21
- package/src/login/pages/LoginOtp.tsx +29 -33
- package/src/login/pages/LoginPageExpired.tsx +5 -5
- package/src/login/pages/LoginPassword.tsx +23 -33
- package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +21 -25
- package/src/login/pages/LoginRecoveryAuthnCodeInput.tsx +21 -25
- package/src/login/pages/LoginResetOtp.tsx +21 -25
- package/src/login/pages/LoginResetPassword.tsx +21 -25
- package/src/login/pages/LoginUpdatePassword.tsx +42 -52
- package/src/login/pages/LoginUpdateProfile.tsx +29 -30
- package/src/login/pages/LoginUsername.tsx +23 -35
- package/src/login/pages/LoginVerifyEmail.tsx +7 -5
- package/src/login/pages/LoginX509Info.tsx +27 -36
- package/src/login/pages/LogoutConfirm.tsx +11 -17
- package/src/login/pages/PageProps.ts +2 -4
- package/src/login/pages/Register.tsx +27 -46
- package/src/login/pages/SamlPostForm.tsx +5 -5
- package/src/login/pages/SelectAuthenticator.tsx +24 -26
- package/src/login/pages/Terms.tsx +9 -16
- package/src/login/pages/UpdateEmail.tsx +29 -33
- package/src/login/pages/WebauthnAuthenticate.tsx +26 -32
- package/src/login/pages/WebauthnError.tsx +11 -22
- package/src/login/pages/WebauthnRegister.tsx +20 -28
- package/src/tools/clsx.ts +6 -48
- package/src/tools/clsx_withTransform.ts +55 -0
- package/src/vite-plugin/vite-plugin.ts +29 -21
- package/tools/clsx.d.ts +3 -2
- package/tools/clsx.js +5 -41
- package/tools/clsx.js.map +1 -1
- package/tools/clsx_withTransform.d.ts +5 -0
- package/tools/clsx_withTransform.js +43 -0
- package/tools/clsx_withTransform.js.map +1 -0
- package/vite-plugin/index.js +243 -102
- package/vite-plugin/vite-plugin.d.ts +3 -3
- package/account/lib/useGetClassName.d.ts +0 -7
- package/account/lib/useGetClassName.js.map +0 -1
- package/bin/795.index.js +0 -1197
- package/lib/isStorybook.d.ts +0 -1
- package/lib/isStorybook.js +0 -3
- package/lib/isStorybook.js.map +0 -1
- package/lib/useGetClassName.d.ts +0 -10
- package/lib/useGetClassName.js +0 -14
- package/lib/useGetClassName.js.map +0 -1
- package/login/lib/useGetClassName.d.ts +0 -7
- package/login/lib/useGetClassName.js.map +0 -1
- package/src/lib/isStorybook.ts +0 -3
- package/src/lib/useGetClassName.ts +0 -27
@@ -3,21 +3,21 @@ import {
|
|
3
3
|
basenameOfTheKeycloakifyResourcesDir
|
4
4
|
} from "../../../shared/constants";
|
5
5
|
import { assert } from "tsafe/assert";
|
6
|
-
import type {
|
6
|
+
import type { BuildContext } from "../../../shared/buildContext";
|
7
7
|
import * as nodePath from "path";
|
8
8
|
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
9
9
|
|
10
|
-
export type
|
11
|
-
|
10
|
+
export type BuildContextLike = {
|
11
|
+
projectBuildDirPath: string;
|
12
12
|
assetsDirPath: string;
|
13
13
|
urlPathname: string | undefined;
|
14
14
|
};
|
15
15
|
|
16
|
-
assert<
|
16
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
17
17
|
|
18
18
|
export function replaceImportsInJsCode_vite(params: {
|
19
19
|
jsCode: string;
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
basenameOfAssetsFiles: string[];
|
22
22
|
systemType?: "posix" | "win32";
|
23
23
|
}): {
|
@@ -25,7 +25,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|
25
25
|
} {
|
26
26
|
const {
|
27
27
|
jsCode,
|
28
|
-
|
28
|
+
buildContext,
|
29
29
|
basenameOfAssetsFiles,
|
30
30
|
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
31
31
|
} = params;
|
@@ -35,11 +35,11 @@ export function replaceImportsInJsCode_vite(params: {
|
|
35
35
|
let fixedJsCode = jsCode;
|
36
36
|
|
37
37
|
replace_base_javacript_import: {
|
38
|
-
if (
|
38
|
+
if (buildContext.urlPathname === undefined) {
|
39
39
|
break replace_base_javacript_import;
|
40
40
|
}
|
41
41
|
// Optimization
|
42
|
-
if (!jsCode.includes(
|
42
|
+
if (!jsCode.includes(buildContext.urlPathname)) {
|
43
43
|
break replace_base_javacript_import;
|
44
44
|
}
|
45
45
|
|
@@ -47,7 +47,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|
47
47
|
fixedJsCode = fixedJsCode.replace(
|
48
48
|
new RegExp(
|
49
49
|
`([\\w\\$][\\w\\d\\$]*)=function\\(([\\w\\$][\\w\\d\\$]*)\\)\\{return"${replaceAll(
|
50
|
-
|
50
|
+
buildContext.urlPathname,
|
51
51
|
"/",
|
52
52
|
"\\/"
|
53
53
|
)}"\\+\\2\\}`,
|
@@ -62,15 +62,15 @@ export function replaceImportsInJsCode_vite(params: {
|
|
62
62
|
// Example: "assets/ or "foo/bar/"
|
63
63
|
const staticDir = (() => {
|
64
64
|
let out = pathRelative(
|
65
|
-
|
66
|
-
|
65
|
+
buildContext.projectBuildDirPath,
|
66
|
+
buildContext.assetsDirPath
|
67
67
|
);
|
68
68
|
|
69
69
|
out = replaceAll(out, pathSep, "/") + "/";
|
70
70
|
|
71
71
|
if (out === "/") {
|
72
72
|
throw new Error(
|
73
|
-
`The assetsDirPath must be a subdirectory of
|
73
|
+
`The assetsDirPath must be a subdirectory of projectBuildDirPath`
|
74
74
|
);
|
75
75
|
}
|
76
76
|
|
@@ -93,7 +93,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|
93
93
|
|
94
94
|
fixedJsCode = replaceAll(
|
95
95
|
fixedJsCode,
|
96
|
-
`"${
|
96
|
+
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
97
97
|
`(window.${nameOfTheGlobal}.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
98
98
|
);
|
99
99
|
});
|
@@ -3,28 +3,28 @@ import {
|
|
3
3
|
basenameOfTheKeycloakifyResourcesDir
|
4
4
|
} from "../../../shared/constants";
|
5
5
|
import { assert } from "tsafe/assert";
|
6
|
-
import type {
|
6
|
+
import type { BuildContext } from "../../../shared/buildContext";
|
7
7
|
import * as nodePath from "path";
|
8
8
|
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
9
9
|
|
10
|
-
export type
|
11
|
-
|
10
|
+
export type BuildContextLike = {
|
11
|
+
projectBuildDirPath: string;
|
12
12
|
assetsDirPath: string;
|
13
13
|
urlPathname: string | undefined;
|
14
14
|
};
|
15
15
|
|
16
|
-
assert<
|
16
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
17
17
|
|
18
18
|
export function replaceImportsInJsCode_webpack(params: {
|
19
19
|
jsCode: string;
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
systemType?: "posix" | "win32";
|
22
22
|
}): {
|
23
23
|
fixedJsCode: string;
|
24
24
|
} {
|
25
25
|
const {
|
26
26
|
jsCode,
|
27
|
-
|
27
|
+
buildContext,
|
28
28
|
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
29
29
|
} = params;
|
30
30
|
|
@@ -32,12 +32,12 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
32
32
|
|
33
33
|
let fixedJsCode = jsCode;
|
34
34
|
|
35
|
-
if (
|
35
|
+
if (buildContext.urlPathname !== undefined) {
|
36
36
|
// "__esModule",{value:!0})},n.p="/foo-bar/",function(){if("undefined" -> ... n.p="/" ...
|
37
37
|
fixedJsCode = fixedJsCode.replace(
|
38
38
|
new RegExp(
|
39
39
|
`,([a-zA-Z]\\.[a-zA-Z])="${replaceAll(
|
40
|
-
|
40
|
+
buildContext.urlPathname,
|
41
41
|
"/",
|
42
42
|
"\\/"
|
43
43
|
)}",`,
|
@@ -50,15 +50,15 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
50
50
|
// Example: "static/ or "foo/bar/"
|
51
51
|
const staticDir = (() => {
|
52
52
|
let out = pathRelative(
|
53
|
-
|
54
|
-
|
53
|
+
buildContext.projectBuildDirPath,
|
54
|
+
buildContext.assetsDirPath
|
55
55
|
);
|
56
56
|
|
57
57
|
out = replaceAll(out, pathSep, "/") + "/";
|
58
58
|
|
59
59
|
if (out === "/") {
|
60
60
|
throw new Error(
|
61
|
-
`The assetsDirPath must be a subdirectory of
|
61
|
+
`The assetsDirPath must be a subdirectory of projectBuildDirPath`
|
62
62
|
);
|
63
63
|
}
|
64
64
|
|
package/src/bin/main.ts
CHANGED
@@ -5,7 +5,7 @@ import { readThisNpmPackageVersion } from "./tools/readThisNpmPackageVersion";
|
|
5
5
|
import * as child_process from "child_process";
|
6
6
|
|
7
7
|
export type CliCommandOptions = {
|
8
|
-
|
8
|
+
projectDirPath: string | undefined;
|
9
9
|
};
|
10
10
|
|
11
11
|
const program = termost<CliCommandOptions>(
|
@@ -25,7 +25,7 @@ const program = termost<CliCommandOptions>(
|
|
25
25
|
const optionsKeys: string[] = [];
|
26
26
|
|
27
27
|
program.option({
|
28
|
-
key: "
|
28
|
+
key: "projectDirPath",
|
29
29
|
name: (() => {
|
30
30
|
const long = "project";
|
31
31
|
const short = "p";
|
@@ -205,6 +205,21 @@ program
|
|
205
205
|
}
|
206
206
|
});
|
207
207
|
|
208
|
+
program
|
209
|
+
.command({
|
210
|
+
name: "update-kc-gen",
|
211
|
+
description:
|
212
|
+
"(Webpack/Create-React-App only) Create/update the kc.gen.ts file in your project."
|
213
|
+
})
|
214
|
+
.task({
|
215
|
+
skip,
|
216
|
+
handler: async cliCommandOptions => {
|
217
|
+
const { command } = await import("./update-kc-gen");
|
218
|
+
|
219
|
+
await command({ cliCommandOptions });
|
220
|
+
}
|
221
|
+
});
|
222
|
+
|
208
223
|
// Fallback to build command if no command is provided
|
209
224
|
{
|
210
225
|
const [, , ...rest] = process.argv;
|
@@ -9,8 +9,7 @@ import { assert } from "tsafe";
|
|
9
9
|
import * as child_process from "child_process";
|
10
10
|
import { vitePluginSubScriptEnvNames } from "./constants";
|
11
11
|
|
12
|
-
|
13
|
-
export type BuildOptions = {
|
12
|
+
export type BuildContext = {
|
14
13
|
bundler: "vite" | "webpack";
|
15
14
|
themeVersion: string;
|
16
15
|
themeNames: string[];
|
@@ -18,9 +17,8 @@ export type BuildOptions = {
|
|
18
17
|
groupId: string;
|
19
18
|
artifactId: string;
|
20
19
|
loginThemeResourcesFromKeycloakVersion: string;
|
21
|
-
|
22
|
-
|
23
|
-
reactAppBuildDirPath: string;
|
20
|
+
projectDirPath: string;
|
21
|
+
projectBuildDirPath: string;
|
24
22
|
/** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */
|
25
23
|
keycloakifyBuildDirPath: string;
|
26
24
|
publicDirPath: string;
|
@@ -31,16 +29,18 @@ export type BuildOptions = {
|
|
31
29
|
assetsDirPath: string;
|
32
30
|
npmWorkspaceRootDirPath: string;
|
33
31
|
kcContextExclusionsFtlCode: string | undefined;
|
32
|
+
environmentVariables: { name: string; default: string }[];
|
34
33
|
};
|
35
34
|
|
36
|
-
export type
|
35
|
+
export type BuildOptions = {
|
36
|
+
themeName?: string | string[];
|
37
|
+
environmentVariables?: { name: string; default: string }[];
|
37
38
|
extraThemeProperties?: string[];
|
38
39
|
artifactId?: string;
|
39
40
|
groupId?: string;
|
40
41
|
loginThemeResourcesFromKeycloakVersion?: string;
|
41
42
|
keycloakifyBuildDirPath?: string;
|
42
|
-
|
43
|
-
kcContextExclusionsFtlCode?: string;
|
43
|
+
kcContextExclusionsFtl?: string;
|
44
44
|
};
|
45
45
|
|
46
46
|
export type ResolvedViteConfig = {
|
@@ -48,21 +48,21 @@ export type ResolvedViteConfig = {
|
|
48
48
|
publicDir: string;
|
49
49
|
assetsDir: string;
|
50
50
|
urlPathname: string | undefined;
|
51
|
-
|
51
|
+
buildOptions: BuildOptions;
|
52
52
|
};
|
53
53
|
|
54
|
-
export function
|
54
|
+
export function getBuildContext(params: {
|
55
55
|
cliCommandOptions: CliCommandOptions;
|
56
|
-
}):
|
56
|
+
}): BuildContext {
|
57
57
|
const { cliCommandOptions } = params;
|
58
58
|
|
59
|
-
const
|
60
|
-
if (cliCommandOptions.
|
59
|
+
const projectDirPath = (() => {
|
60
|
+
if (cliCommandOptions.projectDirPath === undefined) {
|
61
61
|
return process.cwd();
|
62
62
|
}
|
63
63
|
|
64
64
|
return getAbsoluteAndInOsFormatPath({
|
65
|
-
pathIsh: cliCommandOptions.
|
65
|
+
pathIsh: cliCommandOptions.projectDirPath,
|
66
66
|
cwd: process.cwd()
|
67
67
|
});
|
68
68
|
})();
|
@@ -70,7 +70,7 @@ export function readBuildOptions(params: {
|
|
70
70
|
const { resolvedViteConfig } = (() => {
|
71
71
|
if (
|
72
72
|
fs
|
73
|
-
.readdirSync(
|
73
|
+
.readdirSync(projectDirPath)
|
74
74
|
.find(fileBasename => fileBasename.startsWith("vite.config")) ===
|
75
75
|
undefined
|
76
76
|
) {
|
@@ -79,7 +79,7 @@ export function readBuildOptions(params: {
|
|
79
79
|
|
80
80
|
const output = child_process
|
81
81
|
.execSync("npx vite", {
|
82
|
-
cwd:
|
82
|
+
cwd: projectDirPath,
|
83
83
|
env: {
|
84
84
|
...process.env,
|
85
85
|
[vitePluginSubScriptEnvNames.resolveViteConfig]: "true"
|
@@ -106,8 +106,8 @@ export function readBuildOptions(params: {
|
|
106
106
|
name: string;
|
107
107
|
version?: string;
|
108
108
|
homepage?: string;
|
109
|
-
keycloakify?:
|
110
|
-
|
109
|
+
keycloakify?: BuildOptions & {
|
110
|
+
projectBuildDirPath?: string;
|
111
111
|
};
|
112
112
|
};
|
113
113
|
|
@@ -121,7 +121,7 @@ export function readBuildOptions(params: {
|
|
121
121
|
artifactId: z.string().optional(),
|
122
122
|
groupId: z.string().optional(),
|
123
123
|
loginThemeResourcesFromKeycloakVersion: z.string().optional(),
|
124
|
-
|
124
|
+
projectBuildDirPath: z.string().optional(),
|
125
125
|
keycloakifyBuildDirPath: z.string().optional(),
|
126
126
|
themeName: z.union([z.string(), z.array(z.string())]).optional()
|
127
127
|
})
|
@@ -137,20 +137,18 @@ export function readBuildOptions(params: {
|
|
137
137
|
|
138
138
|
return zParsedPackageJson.parse(
|
139
139
|
JSON.parse(
|
140
|
-
fs
|
141
|
-
.readFileSync(pathJoin(reactAppRootDirPath, "package.json"))
|
142
|
-
.toString("utf8")
|
140
|
+
fs.readFileSync(pathJoin(projectDirPath, "package.json")).toString("utf8")
|
143
141
|
)
|
144
142
|
);
|
145
143
|
})();
|
146
144
|
|
147
|
-
const
|
145
|
+
const buildOptions: BuildOptions = {
|
148
146
|
...parsedPackageJson.keycloakify,
|
149
|
-
...resolvedViteConfig?.
|
147
|
+
...resolvedViteConfig?.buildOptions
|
150
148
|
};
|
151
149
|
|
152
150
|
const themeNames = (() => {
|
153
|
-
if (
|
151
|
+
if (buildOptions.themeName === undefined) {
|
154
152
|
return [
|
155
153
|
parsedPackageJson.name
|
156
154
|
.replace(/^@(.*)/, "$1")
|
@@ -159,34 +157,34 @@ export function readBuildOptions(params: {
|
|
159
157
|
];
|
160
158
|
}
|
161
159
|
|
162
|
-
if (typeof
|
163
|
-
return [
|
160
|
+
if (typeof buildOptions.themeName === "string") {
|
161
|
+
return [buildOptions.themeName];
|
164
162
|
}
|
165
163
|
|
166
|
-
return
|
164
|
+
return buildOptions.themeName;
|
167
165
|
})();
|
168
166
|
|
169
|
-
const
|
167
|
+
const projectBuildDirPath = (() => {
|
170
168
|
webpack: {
|
171
169
|
if (resolvedViteConfig !== undefined) {
|
172
170
|
break webpack;
|
173
171
|
}
|
174
172
|
|
175
|
-
if (parsedPackageJson.keycloakify?.
|
173
|
+
if (parsedPackageJson.keycloakify?.projectBuildDirPath !== undefined) {
|
176
174
|
return getAbsoluteAndInOsFormatPath({
|
177
|
-
pathIsh: parsedPackageJson.keycloakify.
|
178
|
-
cwd:
|
175
|
+
pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath,
|
176
|
+
cwd: projectDirPath
|
179
177
|
});
|
180
178
|
}
|
181
179
|
|
182
|
-
return pathJoin(
|
180
|
+
return pathJoin(projectDirPath, "build");
|
183
181
|
}
|
184
182
|
|
185
|
-
return pathJoin(
|
183
|
+
return pathJoin(projectDirPath, resolvedViteConfig.buildDir);
|
186
184
|
})();
|
187
185
|
|
188
186
|
const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({
|
189
|
-
|
187
|
+
projectDirPath,
|
190
188
|
dependencyExpected: "keycloakify"
|
191
189
|
});
|
192
190
|
|
@@ -195,13 +193,13 @@ export function readBuildOptions(params: {
|
|
195
193
|
themeVersion:
|
196
194
|
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
197
195
|
themeNames,
|
198
|
-
extraThemeProperties:
|
196
|
+
extraThemeProperties: buildOptions.extraThemeProperties,
|
199
197
|
groupId: (() => {
|
200
198
|
const fallbackGroupId = `${themeNames[0]}.keycloak`;
|
201
199
|
|
202
200
|
return (
|
203
201
|
process.env.KEYCLOAKIFY_GROUP_ID ??
|
204
|
-
|
202
|
+
buildOptions.groupId ??
|
205
203
|
(parsedPackageJson.homepage === undefined
|
206
204
|
? fallbackGroupId
|
207
205
|
: urlParse(parsedPackageJson.homepage)
|
@@ -213,22 +211,22 @@ export function readBuildOptions(params: {
|
|
213
211
|
})(),
|
214
212
|
artifactId:
|
215
213
|
process.env.KEYCLOAKIFY_ARTIFACT_ID ??
|
216
|
-
|
214
|
+
buildOptions.artifactId ??
|
217
215
|
`${themeNames[0]}-keycloak-theme`,
|
218
216
|
loginThemeResourcesFromKeycloakVersion:
|
219
|
-
|
220
|
-
|
221
|
-
|
217
|
+
buildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
|
218
|
+
projectDirPath,
|
219
|
+
projectBuildDirPath,
|
222
220
|
keycloakifyBuildDirPath: (() => {
|
223
|
-
if (
|
221
|
+
if (buildOptions.keycloakifyBuildDirPath !== undefined) {
|
224
222
|
return getAbsoluteAndInOsFormatPath({
|
225
|
-
pathIsh:
|
226
|
-
cwd:
|
223
|
+
pathIsh: buildOptions.keycloakifyBuildDirPath,
|
224
|
+
cwd: projectDirPath
|
227
225
|
});
|
228
226
|
}
|
229
227
|
|
230
228
|
return pathJoin(
|
231
|
-
|
229
|
+
projectDirPath,
|
232
230
|
resolvedViteConfig?.buildDir === undefined
|
233
231
|
? "build_keycloak"
|
234
232
|
: `${resolvedViteConfig.buildDir}_keycloak`
|
@@ -243,14 +241,14 @@ export function readBuildOptions(params: {
|
|
243
241
|
if (process.env.PUBLIC_DIR_PATH !== undefined) {
|
244
242
|
return getAbsoluteAndInOsFormatPath({
|
245
243
|
pathIsh: process.env.PUBLIC_DIR_PATH,
|
246
|
-
cwd:
|
244
|
+
cwd: projectDirPath
|
247
245
|
});
|
248
246
|
}
|
249
247
|
|
250
|
-
return pathJoin(
|
248
|
+
return pathJoin(projectDirPath, "public");
|
251
249
|
}
|
252
250
|
|
253
|
-
return pathJoin(
|
251
|
+
return pathJoin(projectDirPath, resolvedViteConfig.publicDir);
|
254
252
|
})(),
|
255
253
|
cacheDirPath: (() => {
|
256
254
|
const cacheDirPath = pathJoin(
|
@@ -299,12 +297,28 @@ export function readBuildOptions(params: {
|
|
299
297
|
break webpack;
|
300
298
|
}
|
301
299
|
|
302
|
-
return pathJoin(
|
300
|
+
return pathJoin(projectBuildDirPath, "static");
|
303
301
|
}
|
304
302
|
|
305
|
-
return pathJoin(
|
303
|
+
return pathJoin(projectBuildDirPath, resolvedViteConfig.assetsDir);
|
306
304
|
})(),
|
307
305
|
npmWorkspaceRootDirPath,
|
308
|
-
kcContextExclusionsFtlCode:
|
306
|
+
kcContextExclusionsFtlCode: (() => {
|
307
|
+
if (buildOptions.kcContextExclusionsFtl === undefined) {
|
308
|
+
return undefined;
|
309
|
+
}
|
310
|
+
|
311
|
+
if (buildOptions.kcContextExclusionsFtl.endsWith(".ftl")) {
|
312
|
+
const kcContextExclusionsFtlPath = getAbsoluteAndInOsFormatPath({
|
313
|
+
pathIsh: buildOptions.kcContextExclusionsFtl,
|
314
|
+
cwd: projectDirPath
|
315
|
+
});
|
316
|
+
|
317
|
+
return fs.readFileSync(kcContextExclusionsFtlPath).toString("utf8");
|
318
|
+
}
|
319
|
+
|
320
|
+
return buildOptions.kcContextExclusionsFtl;
|
321
|
+
})(),
|
322
|
+
environmentVariables: buildOptions.environmentVariables ?? []
|
309
323
|
};
|
310
324
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
downloadKeycloakStaticResources,
|
3
|
-
type
|
3
|
+
type BuildContextLike as BuildContextLike_downloadKeycloakStaticResources
|
4
4
|
} from "./downloadKeycloakStaticResources";
|
5
5
|
import { join as pathJoin, relative as pathRelative } from "path";
|
6
6
|
import {
|
@@ -12,21 +12,21 @@ import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
|
12
12
|
import { assert } from "tsafe/assert";
|
13
13
|
import * as fs from "fs";
|
14
14
|
import { rmSync } from "../tools/fs.rmSync";
|
15
|
-
import type {
|
15
|
+
import type { BuildContext } from "./buildContext";
|
16
16
|
|
17
|
-
export type
|
17
|
+
export type BuildContextLike = BuildContextLike_downloadKeycloakStaticResources & {
|
18
18
|
loginThemeResourcesFromKeycloakVersion: string;
|
19
19
|
publicDirPath: string;
|
20
20
|
};
|
21
21
|
|
22
|
-
assert<
|
22
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
23
23
|
|
24
24
|
export async function copyKeycloakResourcesToPublic(params: {
|
25
|
-
|
25
|
+
buildContext: BuildContextLike;
|
26
26
|
}) {
|
27
|
-
const {
|
27
|
+
const { buildContext } = params;
|
28
28
|
|
29
|
-
const destDirPath = pathJoin(
|
29
|
+
const destDirPath = pathJoin(buildContext.publicDirPath, keycloak_resources);
|
30
30
|
|
31
31
|
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
32
32
|
|
@@ -34,12 +34,12 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
34
34
|
{
|
35
35
|
destDirPath,
|
36
36
|
keycloakifyVersion: readThisNpmPackageVersion(),
|
37
|
-
|
37
|
+
buildContext: {
|
38
38
|
loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
|
39
|
-
cacheDirPath: pathRelative(destDirPath,
|
39
|
+
cacheDirPath: pathRelative(destDirPath, buildContext.cacheDirPath),
|
40
40
|
npmWorkspaceRootDirPath: pathRelative(
|
41
41
|
destDirPath,
|
42
|
-
|
42
|
+
buildContext.npmWorkspaceRootDirPath
|
43
43
|
)
|
44
44
|
}
|
45
45
|
},
|
@@ -74,14 +74,14 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
74
74
|
keycloakVersion: (() => {
|
75
75
|
switch (themeType) {
|
76
76
|
case "login":
|
77
|
-
return
|
77
|
+
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
78
78
|
case "account":
|
79
79
|
return lastKeycloakVersionWithAccountV1;
|
80
80
|
}
|
81
81
|
})(),
|
82
82
|
themeType,
|
83
83
|
themeDirPath: destDirPath,
|
84
|
-
|
84
|
+
buildContext
|
85
85
|
});
|
86
86
|
}
|
87
87
|
|
@@ -1,27 +1,27 @@
|
|
1
1
|
import { join as pathJoin, relative as pathRelative } from "path";
|
2
|
-
import { type
|
2
|
+
import { type BuildContext } from "./buildContext";
|
3
3
|
import { assert } from "tsafe/assert";
|
4
4
|
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
5
5
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
6
6
|
import { isInside } from "../tools/isInside";
|
7
7
|
|
8
|
-
export type
|
8
|
+
export type BuildContextLike = {
|
9
9
|
cacheDirPath: string;
|
10
10
|
npmWorkspaceRootDirPath: string;
|
11
11
|
};
|
12
12
|
|
13
|
-
assert<
|
13
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
14
14
|
|
15
15
|
export async function downloadKeycloakDefaultTheme(params: {
|
16
16
|
keycloakVersion: string;
|
17
|
-
|
17
|
+
buildContext: BuildContextLike;
|
18
18
|
}): Promise<{ defaultThemeDirPath: string }> {
|
19
|
-
const { keycloakVersion,
|
19
|
+
const { keycloakVersion, buildContext } = params;
|
20
20
|
|
21
21
|
const { extractedDirPath } = await downloadAndExtractArchive({
|
22
22
|
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
23
|
-
cacheDirPath:
|
24
|
-
npmWorkspaceRootDirPath:
|
23
|
+
cacheDirPath: buildContext.cacheDirPath,
|
24
|
+
npmWorkspaceRootDirPath: buildContext.npmWorkspaceRootDirPath,
|
25
25
|
uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
|
26
26
|
onArchiveFile: async params => {
|
27
27
|
if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
|
@@ -2,28 +2,28 @@ import { transformCodebase } from "../tools/transformCodebase";
|
|
2
2
|
import { join as pathJoin } from "path";
|
3
3
|
import {
|
4
4
|
downloadKeycloakDefaultTheme,
|
5
|
-
type
|
5
|
+
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
6
6
|
} from "./downloadKeycloakDefaultTheme";
|
7
7
|
import { resources_common, type ThemeType } from "./constants";
|
8
|
-
import type {
|
8
|
+
import type { BuildContext } from "./buildContext";
|
9
9
|
import { assert } from "tsafe/assert";
|
10
10
|
import { existsAsync } from "../tools/fs.existsAsync";
|
11
11
|
|
12
|
-
export type
|
12
|
+
export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
|
13
13
|
|
14
|
-
assert<
|
14
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
15
15
|
|
16
16
|
export async function downloadKeycloakStaticResources(params: {
|
17
17
|
themeType: ThemeType;
|
18
18
|
themeDirPath: string;
|
19
19
|
keycloakVersion: string;
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
}) {
|
22
|
-
const { themeType, themeDirPath, keycloakVersion,
|
22
|
+
const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
|
23
23
|
|
24
24
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
25
25
|
keycloakVersion,
|
26
|
-
|
26
|
+
buildContext
|
27
27
|
});
|
28
28
|
|
29
29
|
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { assert } from "tsafe/assert";
|
2
|
+
import type { BuildContext } from "./buildContext";
|
3
|
+
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
4
|
+
import * as fs from "fs/promises";
|
5
|
+
import { join as pathJoin } from "path";
|
6
|
+
|
7
|
+
export type BuildContextLike = {
|
8
|
+
projectDirPath: string;
|
9
|
+
themeNames: string[];
|
10
|
+
environmentVariables: { name: string; default: string }[];
|
11
|
+
};
|
12
|
+
|
13
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
14
|
+
|
15
|
+
export async function generateKcGenTs(params: {
|
16
|
+
buildContext: BuildContextLike;
|
17
|
+
}): Promise<void> {
|
18
|
+
const { buildContext } = params;
|
19
|
+
|
20
|
+
const { themeSrcDirPath } = getThemeSrcDirPath({
|
21
|
+
projectDirPath: buildContext.projectDirPath
|
22
|
+
});
|
23
|
+
|
24
|
+
await fs.writeFile(
|
25
|
+
pathJoin(themeSrcDirPath, "kc.gen.ts"),
|
26
|
+
Buffer.from(
|
27
|
+
[
|
28
|
+
`/* prettier-ignore-start */`,
|
29
|
+
``,
|
30
|
+
`/* eslint-disable */`,
|
31
|
+
``,
|
32
|
+
`// @ts-nocheck`,
|
33
|
+
``,
|
34
|
+
`// noinspection JSUnusedGlobalSymbols`,
|
35
|
+
``,
|
36
|
+
`// This file is auto-generated by Keycloakify`,
|
37
|
+
``,
|
38
|
+
`export type ThemeName = ${buildContext.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
39
|
+
``,
|
40
|
+
`export const themeNames: ThemeName[] = [${buildContext.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
41
|
+
``,
|
42
|
+
`export type KcEnvName = ${buildContext.environmentVariables.length === 0 ? "never" : buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
43
|
+
``,
|
44
|
+
`export const KcEnvNames: KcEnvName[] = [${buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
45
|
+
``,
|
46
|
+
`export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(
|
47
|
+
Object.fromEntries(
|
48
|
+
buildContext.environmentVariables.map(
|
49
|
+
({ name, default: defaultValue }) => [name, defaultValue]
|
50
|
+
)
|
51
|
+
),
|
52
|
+
null,
|
53
|
+
2
|
54
|
+
)};`,
|
55
|
+
``,
|
56
|
+
`/* prettier-ignore-end */`
|
57
|
+
].join("\n"),
|
58
|
+
"utf8"
|
59
|
+
)
|
60
|
+
);
|
61
|
+
}
|