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.
Files changed (307) hide show
  1. package/account/Fallback.d.ts +1 -2
  2. package/account/Fallback.js.map +1 -1
  3. package/account/KcContext/KcContext.d.ts +6 -6
  4. package/account/KcContext/getKcContextMock.d.ts +9 -9
  5. package/account/KcContext/getKcContextMock.js +3 -3
  6. package/account/KcContext/getKcContextMock.js.map +1 -1
  7. package/account/Template.d.ts +1 -2
  8. package/account/Template.js +7 -6
  9. package/account/Template.js.map +1 -1
  10. package/account/TemplateProps.d.ts +1 -3
  11. package/account/i18n/i18n.d.ts +9 -4
  12. package/account/i18n/i18n.js +132 -87
  13. package/account/i18n/i18n.js.map +1 -1
  14. package/account/i18n/index.d.ts +9 -2
  15. package/account/i18n/index.js +5 -1
  16. package/account/i18n/index.js.map +1 -1
  17. package/account/lib/kcClsx.d.ts +9 -0
  18. package/account/lib/{useGetClassName.js → kcClsx.js} +3 -3
  19. package/account/lib/kcClsx.js.map +1 -0
  20. package/account/pages/Account.d.ts +1 -2
  21. package/account/pages/Account.js +9 -7
  22. package/account/pages/Account.js.map +1 -1
  23. package/account/pages/Applications.d.ts +1 -2
  24. package/account/pages/Applications.js +7 -7
  25. package/account/pages/Applications.js.map +1 -1
  26. package/account/pages/FederatedIdentity.d.ts +1 -2
  27. package/account/pages/FederatedIdentity.js +4 -3
  28. package/account/pages/FederatedIdentity.js.map +1 -1
  29. package/account/pages/Log.d.ts +1 -2
  30. package/account/pages/Log.js +6 -5
  31. package/account/pages/Log.js.map +1 -1
  32. package/account/pages/PageProps.d.ts +2 -4
  33. package/account/pages/Password.d.ts +1 -2
  34. package/account/pages/Password.js +10 -9
  35. package/account/pages/Password.js.map +1 -1
  36. package/account/pages/Sessions.d.ts +1 -2
  37. package/account/pages/Sessions.js +6 -6
  38. package/account/pages/Sessions.js.map +1 -1
  39. package/account/pages/Totp.d.ts +1 -2
  40. package/account/pages/Totp.js +6 -5
  41. package/account/pages/Totp.js.map +1 -1
  42. package/bin/193.index.js +13 -13
  43. package/bin/{430.index.js → 214.index.js} +161 -2
  44. package/bin/3.index.js +165 -149
  45. package/bin/322.index.js +595 -0
  46. package/bin/453.index.js +3 -3
  47. package/bin/526.index.js +42 -632
  48. package/bin/538.index.js +563 -0
  49. package/bin/932.index.js +7 -7
  50. package/bin/{890.index.js → 941.index.js} +2 -159
  51. package/bin/944.index.js +621 -0
  52. package/bin/961.index.js +5 -5
  53. package/bin/97.index.js +3 -3
  54. package/bin/{314.index.js → 98.index.js} +217 -48
  55. package/bin/main.js +20 -8
  56. package/lib/getKcClsx.d.ts +11 -0
  57. package/lib/getKcClsx.js +55 -0
  58. package/lib/getKcClsx.js.map +1 -0
  59. package/login/Fallback.d.ts +2 -2
  60. package/login/Fallback.js.map +1 -1
  61. package/login/KcContext/KcContext.d.ts +6 -6
  62. package/login/KcContext/getKcContextMock.d.ts +9 -9
  63. package/login/KcContext/getKcContextMock.js +3 -3
  64. package/login/KcContext/getKcContextMock.js.map +1 -1
  65. package/login/Template.d.ts +1 -2
  66. package/login/Template.js +10 -9
  67. package/login/Template.js.map +1 -1
  68. package/login/TemplateProps.d.ts +1 -3
  69. package/login/UserProfileFormFields.d.ts +6 -5
  70. package/login/UserProfileFormFields.js +35 -36
  71. package/login/UserProfileFormFields.js.map +1 -1
  72. package/login/i18n/i18n.d.ts +9 -4
  73. package/login/i18n/i18n.js +136 -91
  74. package/login/i18n/i18n.js.map +1 -1
  75. package/login/i18n/index.d.ts +9 -2
  76. package/login/i18n/index.js +5 -1
  77. package/login/i18n/index.js.map +1 -1
  78. package/login/lib/kcClsx.d.ts +9 -0
  79. package/login/lib/{useGetClassName.js → kcClsx.js} +3 -3
  80. package/login/lib/kcClsx.js.map +1 -0
  81. package/login/lib/useUserProfileForm.d.ts +9 -6
  82. package/login/lib/useUserProfileForm.js +7 -5
  83. package/login/lib/useUserProfileForm.js.map +1 -1
  84. package/login/pages/Code.d.ts +1 -2
  85. package/login/pages/Code.js +6 -5
  86. package/login/pages/Code.js.map +1 -1
  87. package/login/pages/DeleteAccountConfirm.d.ts +1 -2
  88. package/login/pages/DeleteAccountConfirm.js +7 -7
  89. package/login/pages/DeleteAccountConfirm.js.map +1 -1
  90. package/login/pages/DeleteCredential.d.ts +1 -2
  91. package/login/pages/DeleteCredential.js +6 -6
  92. package/login/pages/DeleteCredential.js.map +1 -1
  93. package/login/pages/Error.d.ts +1 -2
  94. package/login/pages/Error.js +4 -3
  95. package/login/pages/Error.js.map +1 -1
  96. package/login/pages/FrontchannelLogout.d.ts +1 -2
  97. package/login/pages/FrontchannelLogout.js +4 -3
  98. package/login/pages/FrontchannelLogout.js.map +1 -1
  99. package/login/pages/IdpReviewUserProfile.d.ts +2 -2
  100. package/login/pages/IdpReviewUserProfile.js +6 -6
  101. package/login/pages/IdpReviewUserProfile.js.map +1 -1
  102. package/login/pages/Info.d.ts +1 -2
  103. package/login/pages/Info.js +4 -3
  104. package/login/pages/Info.js.map +1 -1
  105. package/login/pages/Login.d.ts +1 -2
  106. package/login/pages/Login.js +10 -8
  107. package/login/pages/Login.js.map +1 -1
  108. package/login/pages/LoginConfigTotp.d.ts +1 -2
  109. package/login/pages/LoginConfigTotp.js +8 -7
  110. package/login/pages/LoginConfigTotp.js.map +1 -1
  111. package/login/pages/LoginIdpLinkConfirm.d.ts +1 -2
  112. package/login/pages/LoginIdpLinkConfirm.js +6 -6
  113. package/login/pages/LoginIdpLinkConfirm.js.map +1 -1
  114. package/login/pages/LoginIdpLinkEmail.d.ts +1 -2
  115. package/login/pages/LoginIdpLinkEmail.js +4 -3
  116. package/login/pages/LoginIdpLinkEmail.js.map +1 -1
  117. package/login/pages/LoginOauth2DeviceVerifyUserCode.d.ts +1 -2
  118. package/login/pages/LoginOauth2DeviceVerifyUserCode.js +6 -6
  119. package/login/pages/LoginOauth2DeviceVerifyUserCode.js.map +1 -1
  120. package/login/pages/LoginOauthGrant.d.ts +1 -2
  121. package/login/pages/LoginOauthGrant.js +7 -7
  122. package/login/pages/LoginOauthGrant.js.map +1 -1
  123. package/login/pages/LoginOtp.d.ts +1 -2
  124. package/login/pages/LoginOtp.js +6 -6
  125. package/login/pages/LoginOtp.js.map +1 -1
  126. package/login/pages/LoginPageExpired.d.ts +1 -2
  127. package/login/pages/LoginPageExpired.js +4 -3
  128. package/login/pages/LoginPageExpired.js.map +1 -1
  129. package/login/pages/LoginPassword.d.ts +1 -2
  130. package/login/pages/LoginPassword.js +9 -7
  131. package/login/pages/LoginPassword.js.map +1 -1
  132. package/login/pages/LoginRecoveryAuthnCodeConfig.d.ts +1 -2
  133. package/login/pages/LoginRecoveryAuthnCodeConfig.js +9 -7
  134. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
  135. package/login/pages/LoginRecoveryAuthnCodeInput.d.ts +1 -2
  136. package/login/pages/LoginRecoveryAuthnCodeInput.js +6 -6
  137. package/login/pages/LoginRecoveryAuthnCodeInput.js.map +1 -1
  138. package/login/pages/LoginResetOtp.d.ts +1 -2
  139. package/login/pages/LoginResetOtp.js +6 -6
  140. package/login/pages/LoginResetOtp.js.map +1 -1
  141. package/login/pages/LoginResetPassword.d.ts +1 -2
  142. package/login/pages/LoginResetPassword.js +7 -7
  143. package/login/pages/LoginResetPassword.js.map +1 -1
  144. package/login/pages/LoginUpdatePassword.d.ts +1 -2
  145. package/login/pages/LoginUpdatePassword.js +10 -9
  146. package/login/pages/LoginUpdatePassword.js.map +1 -1
  147. package/login/pages/LoginUpdateProfile.d.ts +2 -2
  148. package/login/pages/LoginUpdateProfile.js +7 -12
  149. package/login/pages/LoginUpdateProfile.js.map +1 -1
  150. package/login/pages/LoginUsername.d.ts +1 -2
  151. package/login/pages/LoginUsername.js +8 -7
  152. package/login/pages/LoginUsername.js.map +1 -1
  153. package/login/pages/LoginVerifyEmail.d.ts +1 -2
  154. package/login/pages/LoginVerifyEmail.js +4 -3
  155. package/login/pages/LoginVerifyEmail.js.map +1 -1
  156. package/login/pages/LoginX509Info.d.ts +1 -2
  157. package/login/pages/LoginX509Info.js +6 -6
  158. package/login/pages/LoginX509Info.js.map +1 -1
  159. package/login/pages/LogoutConfirm.d.ts +1 -2
  160. package/login/pages/LogoutConfirm.js +6 -6
  161. package/login/pages/LogoutConfirm.js.map +1 -1
  162. package/login/pages/PageProps.d.ts +2 -4
  163. package/login/pages/Register.d.ts +2 -2
  164. package/login/pages/Register.js +8 -16
  165. package/login/pages/Register.js.map +1 -1
  166. package/login/pages/SamlPostForm.d.ts +1 -2
  167. package/login/pages/SamlPostForm.js +4 -3
  168. package/login/pages/SamlPostForm.js.map +1 -1
  169. package/login/pages/SelectAuthenticator.d.ts +1 -2
  170. package/login/pages/SelectAuthenticator.js +6 -9
  171. package/login/pages/SelectAuthenticator.js.map +1 -1
  172. package/login/pages/Terms.d.ts +1 -2
  173. package/login/pages/Terms.js +6 -6
  174. package/login/pages/Terms.js.map +1 -1
  175. package/login/pages/UpdateEmail.d.ts +2 -2
  176. package/login/pages/UpdateEmail.js +8 -12
  177. package/login/pages/UpdateEmail.js.map +1 -1
  178. package/login/pages/WebauthnAuthenticate.d.ts +1 -2
  179. package/login/pages/WebauthnAuthenticate.js +13 -12
  180. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  181. package/login/pages/WebauthnError.d.ts +1 -2
  182. package/login/pages/WebauthnError.js +7 -7
  183. package/login/pages/WebauthnError.js.map +1 -1
  184. package/login/pages/WebauthnRegister.d.ts +1 -2
  185. package/login/pages/WebauthnRegister.js +9 -8
  186. package/login/pages/WebauthnRegister.js.map +1 -1
  187. package/package.json +27 -22
  188. package/src/account/Fallback.tsx +1 -2
  189. package/src/account/KcContext/KcContext.ts +7 -7
  190. package/src/account/KcContext/getKcContextMock.ts +13 -24
  191. package/src/account/Template.tsx +8 -8
  192. package/src/account/TemplateProps.ts +1 -6
  193. package/src/account/i18n/i18n.tsx +204 -125
  194. package/src/account/i18n/index.ts +10 -2
  195. package/src/account/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
  196. package/src/account/pages/Account.tsx +15 -21
  197. package/src/account/pages/Applications.tsx +8 -9
  198. package/src/account/pages/FederatedIdentity.tsx +5 -5
  199. package/src/account/pages/Log.tsx +8 -8
  200. package/src/account/pages/PageProps.ts +2 -4
  201. package/src/account/pages/Password.tsx +13 -16
  202. package/src/account/pages/Sessions.tsx +9 -10
  203. package/src/account/pages/Totp.tsx +19 -28
  204. package/src/bin/add-story.ts +3 -3
  205. package/src/bin/copy-keycloak-resources-to-public.ts +3 -3
  206. package/src/bin/download-keycloak-default-theme.ts +5 -5
  207. package/src/bin/eject-page.ts +3 -3
  208. package/src/bin/initialize-email-theme.ts +5 -5
  209. package/src/bin/keycloakify/buildJars/buildJar.ts +14 -14
  210. package/src/bin/keycloakify/buildJars/buildJars.ts +8 -8
  211. package/src/bin/keycloakify/buildJars/generatePom.ts +9 -9
  212. package/src/bin/keycloakify/generateFtl/generateFtl.ts +12 -12
  213. package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +7 -7
  214. package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +2 -66
  215. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +9 -9
  216. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +30 -24
  217. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +8 -8
  218. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +9 -9
  219. package/src/bin/keycloakify/keycloakify.ts +11 -11
  220. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +6 -6
  221. package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +7 -7
  222. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +10 -10
  223. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +13 -13
  224. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +11 -11
  225. package/src/bin/main.ts +17 -2
  226. package/src/bin/shared/{buildOptions.ts → buildContext.ts} +65 -51
  227. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +12 -12
  228. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +7 -7
  229. package/src/bin/shared/downloadKeycloakStaticResources.ts +7 -7
  230. package/src/bin/shared/generateKcGenTs.ts +61 -0
  231. package/src/bin/shared/getThemeSrcDirPath.ts +3 -3
  232. package/src/bin/start-keycloak/appBuild.ts +11 -11
  233. package/src/bin/start-keycloak/keycloakifyBuild.ts +7 -7
  234. package/src/bin/start-keycloak/start-keycloak.ts +34 -22
  235. package/src/bin/tools/escapeStringForPropertiesFile.ts +64 -0
  236. package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +3 -3
  237. package/src/bin/update-kc-gen.ts +13 -0
  238. package/src/lib/getKcClsx.ts +89 -0
  239. package/src/login/Fallback.tsx +2 -2
  240. package/src/login/KcContext/KcContext.ts +7 -7
  241. package/src/login/KcContext/getKcContextMock.ts +13 -24
  242. package/src/login/Template.tsx +36 -37
  243. package/src/login/TemplateProps.ts +1 -6
  244. package/src/login/UserProfileFormFields.tsx +67 -84
  245. package/src/login/i18n/i18n.tsx +208 -129
  246. package/src/login/i18n/index.ts +10 -2
  247. package/src/login/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
  248. package/src/login/lib/useUserProfileForm.tsx +29 -21
  249. package/src/login/pages/Code.tsx +10 -8
  250. package/src/login/pages/DeleteAccountConfirm.tsx +9 -10
  251. package/src/login/pages/DeleteCredential.tsx +11 -10
  252. package/src/login/pages/Error.tsx +5 -5
  253. package/src/login/pages/FrontchannelLogout.tsx +7 -5
  254. package/src/login/pages/IdpReviewUserProfile.tsx +18 -21
  255. package/src/login/pages/Info.tsx +7 -5
  256. package/src/login/pages/Login.tsx +34 -53
  257. package/src/login/pages/LoginConfigTotp.tsx +30 -38
  258. package/src/login/pages/LoginIdpLinkConfirm.tsx +10 -21
  259. package/src/login/pages/LoginIdpLinkEmail.tsx +5 -5
  260. package/src/login/pages/LoginOauth2DeviceVerifyUserCode.tsx +19 -24
  261. package/src/login/pages/LoginOauthGrant.tsx +14 -21
  262. package/src/login/pages/LoginOtp.tsx +29 -33
  263. package/src/login/pages/LoginPageExpired.tsx +5 -5
  264. package/src/login/pages/LoginPassword.tsx +23 -33
  265. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +21 -25
  266. package/src/login/pages/LoginRecoveryAuthnCodeInput.tsx +21 -25
  267. package/src/login/pages/LoginResetOtp.tsx +21 -25
  268. package/src/login/pages/LoginResetPassword.tsx +21 -25
  269. package/src/login/pages/LoginUpdatePassword.tsx +42 -52
  270. package/src/login/pages/LoginUpdateProfile.tsx +29 -30
  271. package/src/login/pages/LoginUsername.tsx +23 -35
  272. package/src/login/pages/LoginVerifyEmail.tsx +7 -5
  273. package/src/login/pages/LoginX509Info.tsx +27 -36
  274. package/src/login/pages/LogoutConfirm.tsx +11 -17
  275. package/src/login/pages/PageProps.ts +2 -4
  276. package/src/login/pages/Register.tsx +27 -46
  277. package/src/login/pages/SamlPostForm.tsx +5 -5
  278. package/src/login/pages/SelectAuthenticator.tsx +24 -26
  279. package/src/login/pages/Terms.tsx +9 -16
  280. package/src/login/pages/UpdateEmail.tsx +29 -33
  281. package/src/login/pages/WebauthnAuthenticate.tsx +26 -32
  282. package/src/login/pages/WebauthnError.tsx +11 -22
  283. package/src/login/pages/WebauthnRegister.tsx +20 -28
  284. package/src/tools/clsx.ts +6 -48
  285. package/src/tools/clsx_withTransform.ts +55 -0
  286. package/src/vite-plugin/vite-plugin.ts +29 -21
  287. package/tools/clsx.d.ts +3 -2
  288. package/tools/clsx.js +5 -41
  289. package/tools/clsx.js.map +1 -1
  290. package/tools/clsx_withTransform.d.ts +5 -0
  291. package/tools/clsx_withTransform.js +43 -0
  292. package/tools/clsx_withTransform.js.map +1 -0
  293. package/vite-plugin/index.js +243 -102
  294. package/vite-plugin/vite-plugin.d.ts +3 -3
  295. package/account/lib/useGetClassName.d.ts +0 -7
  296. package/account/lib/useGetClassName.js.map +0 -1
  297. package/bin/795.index.js +0 -1197
  298. package/lib/isStorybook.d.ts +0 -1
  299. package/lib/isStorybook.js +0 -3
  300. package/lib/isStorybook.js.map +0 -1
  301. package/lib/useGetClassName.d.ts +0 -10
  302. package/lib/useGetClassName.js +0 -14
  303. package/lib/useGetClassName.js.map +0 -1
  304. package/login/lib/useGetClassName.d.ts +0 -7
  305. package/login/lib/useGetClassName.js.map +0 -1
  306. package/src/lib/isStorybook.ts +0 -3
  307. 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 { BuildOptions } from "../../../shared/buildOptions";
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 BuildOptionsLike = {
11
- reactAppBuildDirPath: string;
10
+ export type BuildContextLike = {
11
+ projectBuildDirPath: string;
12
12
  assetsDirPath: string;
13
13
  urlPathname: string | undefined;
14
14
  };
15
15
 
16
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
+ assert<BuildContext extends BuildContextLike ? true : false>();
17
17
 
18
18
  export function replaceImportsInJsCode_vite(params: {
19
19
  jsCode: string;
20
- buildOptions: BuildOptionsLike;
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
- buildOptions,
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 (buildOptions.urlPathname === undefined) {
38
+ if (buildContext.urlPathname === undefined) {
39
39
  break replace_base_javacript_import;
40
40
  }
41
41
  // Optimization
42
- if (!jsCode.includes(buildOptions.urlPathname)) {
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
- buildOptions.urlPathname,
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
- buildOptions.reactAppBuildDirPath,
66
- buildOptions.assetsDirPath
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 reactAppBuildDirPath`
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
- `"${buildOptions.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
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 { BuildOptions } from "../../../shared/buildOptions";
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 BuildOptionsLike = {
11
- reactAppBuildDirPath: string;
10
+ export type BuildContextLike = {
11
+ projectBuildDirPath: string;
12
12
  assetsDirPath: string;
13
13
  urlPathname: string | undefined;
14
14
  };
15
15
 
16
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
+ assert<BuildContext extends BuildContextLike ? true : false>();
17
17
 
18
18
  export function replaceImportsInJsCode_webpack(params: {
19
19
  jsCode: string;
20
- buildOptions: BuildOptionsLike;
20
+ buildContext: BuildContextLike;
21
21
  systemType?: "posix" | "win32";
22
22
  }): {
23
23
  fixedJsCode: string;
24
24
  } {
25
25
  const {
26
26
  jsCode,
27
- buildOptions,
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 (buildOptions.urlPathname !== undefined) {
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
- buildOptions.urlPathname,
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
- buildOptions.reactAppBuildDirPath,
54
- buildOptions.assetsDirPath
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 reactAppBuildDirPath`
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
- reactAppRootDirPath: string | undefined;
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: "reactAppRootDirPath",
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
- /** Consolidated build option gathered form CLI arguments and config in package.json */
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
- reactAppRootDirPath: string;
22
- // TODO: Remove from vite type
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 UserProvidedBuildOptions = {
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
- themeName?: string | string[];
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
- userProvidedBuildOptions: UserProvidedBuildOptions;
51
+ buildOptions: BuildOptions;
52
52
  };
53
53
 
54
- export function readBuildOptions(params: {
54
+ export function getBuildContext(params: {
55
55
  cliCommandOptions: CliCommandOptions;
56
- }): BuildOptions {
56
+ }): BuildContext {
57
57
  const { cliCommandOptions } = params;
58
58
 
59
- const reactAppRootDirPath = (() => {
60
- if (cliCommandOptions.reactAppRootDirPath === undefined) {
59
+ const projectDirPath = (() => {
60
+ if (cliCommandOptions.projectDirPath === undefined) {
61
61
  return process.cwd();
62
62
  }
63
63
 
64
64
  return getAbsoluteAndInOsFormatPath({
65
- pathIsh: cliCommandOptions.reactAppRootDirPath,
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(reactAppRootDirPath)
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: reactAppRootDirPath,
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?: UserProvidedBuildOptions & {
110
- reactAppBuildDirPath?: string;
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
- reactAppBuildDirPath: z.string().optional(),
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 userProvidedBuildOptions: UserProvidedBuildOptions = {
145
+ const buildOptions: BuildOptions = {
148
146
  ...parsedPackageJson.keycloakify,
149
- ...resolvedViteConfig?.userProvidedBuildOptions
147
+ ...resolvedViteConfig?.buildOptions
150
148
  };
151
149
 
152
150
  const themeNames = (() => {
153
- if (userProvidedBuildOptions.themeName === undefined) {
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 userProvidedBuildOptions.themeName === "string") {
163
- return [userProvidedBuildOptions.themeName];
160
+ if (typeof buildOptions.themeName === "string") {
161
+ return [buildOptions.themeName];
164
162
  }
165
163
 
166
- return userProvidedBuildOptions.themeName;
164
+ return buildOptions.themeName;
167
165
  })();
168
166
 
169
- const reactAppBuildDirPath = (() => {
167
+ const projectBuildDirPath = (() => {
170
168
  webpack: {
171
169
  if (resolvedViteConfig !== undefined) {
172
170
  break webpack;
173
171
  }
174
172
 
175
- if (parsedPackageJson.keycloakify?.reactAppBuildDirPath !== undefined) {
173
+ if (parsedPackageJson.keycloakify?.projectBuildDirPath !== undefined) {
176
174
  return getAbsoluteAndInOsFormatPath({
177
- pathIsh: parsedPackageJson.keycloakify.reactAppBuildDirPath,
178
- cwd: reactAppRootDirPath
175
+ pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath,
176
+ cwd: projectDirPath
179
177
  });
180
178
  }
181
179
 
182
- return pathJoin(reactAppRootDirPath, "build");
180
+ return pathJoin(projectDirPath, "build");
183
181
  }
184
182
 
185
- return pathJoin(reactAppRootDirPath, resolvedViteConfig.buildDir);
183
+ return pathJoin(projectDirPath, resolvedViteConfig.buildDir);
186
184
  })();
187
185
 
188
186
  const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({
189
- reactAppRootDirPath,
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: userProvidedBuildOptions.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
- userProvidedBuildOptions.groupId ??
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
- userProvidedBuildOptions.artifactId ??
214
+ buildOptions.artifactId ??
217
215
  `${themeNames[0]}-keycloak-theme`,
218
216
  loginThemeResourcesFromKeycloakVersion:
219
- userProvidedBuildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
220
- reactAppRootDirPath,
221
- reactAppBuildDirPath,
217
+ buildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
218
+ projectDirPath,
219
+ projectBuildDirPath,
222
220
  keycloakifyBuildDirPath: (() => {
223
- if (userProvidedBuildOptions.keycloakifyBuildDirPath !== undefined) {
221
+ if (buildOptions.keycloakifyBuildDirPath !== undefined) {
224
222
  return getAbsoluteAndInOsFormatPath({
225
- pathIsh: userProvidedBuildOptions.keycloakifyBuildDirPath,
226
- cwd: reactAppRootDirPath
223
+ pathIsh: buildOptions.keycloakifyBuildDirPath,
224
+ cwd: projectDirPath
227
225
  });
228
226
  }
229
227
 
230
228
  return pathJoin(
231
- reactAppRootDirPath,
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: reactAppRootDirPath
244
+ cwd: projectDirPath
247
245
  });
248
246
  }
249
247
 
250
- return pathJoin(reactAppRootDirPath, "public");
248
+ return pathJoin(projectDirPath, "public");
251
249
  }
252
250
 
253
- return pathJoin(reactAppRootDirPath, resolvedViteConfig.publicDir);
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(reactAppBuildDirPath, "static");
300
+ return pathJoin(projectBuildDirPath, "static");
303
301
  }
304
302
 
305
- return pathJoin(reactAppBuildDirPath, resolvedViteConfig.assetsDir);
303
+ return pathJoin(projectBuildDirPath, resolvedViteConfig.assetsDir);
306
304
  })(),
307
305
  npmWorkspaceRootDirPath,
308
- kcContextExclusionsFtlCode: userProvidedBuildOptions.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 BuildOptionsLike as BuildOptionsLike_downloadKeycloakStaticResources
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 { BuildOptions } from "./buildOptions";
15
+ import type { BuildContext } from "./buildContext";
16
16
 
17
- export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakStaticResources & {
17
+ export type BuildContextLike = BuildContextLike_downloadKeycloakStaticResources & {
18
18
  loginThemeResourcesFromKeycloakVersion: string;
19
19
  publicDirPath: string;
20
20
  };
21
21
 
22
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
22
+ assert<BuildContext extends BuildContextLike ? true : false>();
23
23
 
24
24
  export async function copyKeycloakResourcesToPublic(params: {
25
- buildOptions: BuildOptionsLike;
25
+ buildContext: BuildContextLike;
26
26
  }) {
27
- const { buildOptions } = params;
27
+ const { buildContext } = params;
28
28
 
29
- const destDirPath = pathJoin(buildOptions.publicDirPath, keycloak_resources);
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
- buildOptions: {
37
+ buildContext: {
38
38
  loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
39
- cacheDirPath: pathRelative(destDirPath, buildOptions.cacheDirPath),
39
+ cacheDirPath: pathRelative(destDirPath, buildContext.cacheDirPath),
40
40
  npmWorkspaceRootDirPath: pathRelative(
41
41
  destDirPath,
42
- buildOptions.npmWorkspaceRootDirPath
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 buildOptions.loginThemeResourcesFromKeycloakVersion;
77
+ return buildContext.loginThemeResourcesFromKeycloakVersion;
78
78
  case "account":
79
79
  return lastKeycloakVersionWithAccountV1;
80
80
  }
81
81
  })(),
82
82
  themeType,
83
83
  themeDirPath: destDirPath,
84
- buildOptions
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 BuildOptions } from "./buildOptions";
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 BuildOptionsLike = {
8
+ export type BuildContextLike = {
9
9
  cacheDirPath: string;
10
10
  npmWorkspaceRootDirPath: string;
11
11
  };
12
12
 
13
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
13
+ assert<BuildContext extends BuildContextLike ? true : false>();
14
14
 
15
15
  export async function downloadKeycloakDefaultTheme(params: {
16
16
  keycloakVersion: string;
17
- buildOptions: BuildOptionsLike;
17
+ buildContext: BuildContextLike;
18
18
  }): Promise<{ defaultThemeDirPath: string }> {
19
- const { keycloakVersion, buildOptions } = params;
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: buildOptions.cacheDirPath,
24
- npmWorkspaceRootDirPath: buildOptions.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 BuildOptionsLike as BuildOptionsLike_downloadKeycloakDefaultTheme
5
+ type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
6
6
  } from "./downloadKeycloakDefaultTheme";
7
7
  import { resources_common, type ThemeType } from "./constants";
8
- import type { BuildOptions } from "./buildOptions";
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 BuildOptionsLike = BuildOptionsLike_downloadKeycloakDefaultTheme & {};
12
+ export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
13
13
 
14
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
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
- buildOptions: BuildOptionsLike;
20
+ buildContext: BuildContextLike;
21
21
  }) {
22
- const { themeType, themeDirPath, keycloakVersion, buildOptions } = params;
22
+ const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
23
23
 
24
24
  const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
25
25
  keycloakVersion,
26
- buildOptions
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
+ }