keycloakify 10.0.0-rc.16 → 10.0.0-rc.18

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 (205) hide show
  1. package/PUBLIC_URL.js.map +1 -1
  2. package/account/Template.js +5 -5
  3. package/account/Template.js.map +1 -1
  4. package/account/i18n/i18n.js +37 -29
  5. package/account/i18n/i18n.js.map +1 -1
  6. package/account/kcContext/KcContext.js.map +1 -1
  7. package/account/kcContext/createGetKcContext.js +20 -15
  8. package/account/kcContext/createGetKcContext.js.map +1 -1
  9. package/account/kcContext/getKcContext.js.map +1 -1
  10. package/account/kcContext/getKcContextFromWindow.d.ts +3 -1
  11. package/account/kcContext/getKcContextFromWindow.js.map +1 -1
  12. package/account/kcContext/kcContextMocks.js +148 -144
  13. package/account/kcContext/kcContextMocks.js.map +1 -1
  14. package/account/lib/useGetClassName.js +14 -14
  15. package/account/lib/useGetClassName.js.map +1 -1
  16. package/account/pages/Account.js +1 -1
  17. package/account/pages/Account.js.map +1 -1
  18. package/account/pages/Password.js +7 -7
  19. package/account/pages/Password.js.map +1 -1
  20. package/account/pages/Totp.js +4 -4
  21. package/account/pages/Totp.js.map +1 -1
  22. package/bin/main.js +12232 -2467
  23. package/bin/shared/constants.d.ts +2 -0
  24. package/bin/shared/constants.js +5 -3
  25. package/bin/shared/constants.js.map +1 -1
  26. package/lib/isStorybook.js +2 -1
  27. package/lib/isStorybook.js.map +1 -1
  28. package/lib/useGetClassName.js.map +1 -1
  29. package/login/Template.js +13 -13
  30. package/login/Template.js.map +1 -1
  31. package/login/UserProfileFormFields.js +43 -41
  32. package/login/UserProfileFormFields.js.map +1 -1
  33. package/login/i18n/baseMessages/ca.d.ts +1 -1
  34. package/login/i18n/baseMessages/ca.js +1 -1
  35. package/login/i18n/baseMessages/el.d.ts +0 -1
  36. package/login/i18n/baseMessages/el.js +0 -1
  37. package/login/i18n/baseMessages/el.js.map +1 -1
  38. package/login/i18n/baseMessages/en.d.ts +1 -1
  39. package/login/i18n/baseMessages/en.js +1 -1
  40. package/login/i18n/baseMessages/es.d.ts +1 -1
  41. package/login/i18n/baseMessages/es.js +1 -1
  42. package/login/i18n/baseMessages/fa.d.ts +0 -1
  43. package/login/i18n/baseMessages/fa.js +0 -1
  44. package/login/i18n/baseMessages/fa.js.map +1 -1
  45. package/login/i18n/baseMessages/hu.d.ts +1 -1
  46. package/login/i18n/baseMessages/hu.js +1 -1
  47. package/login/i18n/baseMessages/index.d.ts +1 -2
  48. package/login/i18n/baseMessages/zh-CN.d.ts +1 -1
  49. package/login/i18n/baseMessages/zh-CN.js +1 -1
  50. package/login/i18n/i18n.js +39 -31
  51. package/login/i18n/i18n.js.map +1 -1
  52. package/login/kcContext/KcContext.js.map +1 -1
  53. package/login/kcContext/createGetKcContext.js +30 -22
  54. package/login/kcContext/createGetKcContext.js.map +1 -1
  55. package/login/kcContext/getKcContext.js.map +1 -1
  56. package/login/kcContext/getKcContextFromWindow.d.ts +3 -1
  57. package/login/kcContext/getKcContextFromWindow.js.map +1 -1
  58. package/login/kcContext/kcContextMocks.js +233 -231
  59. package/login/kcContext/kcContextMocks.js.map +1 -1
  60. package/login/lib/useDownloadTerms.js.map +1 -1
  61. package/login/lib/useGetClassName.js +112 -112
  62. package/login/lib/useGetClassName.js.map +1 -1
  63. package/login/lib/useUserProfileForm.js +181 -181
  64. package/login/lib/useUserProfileForm.js.map +1 -1
  65. package/login/pages/DeleteAccountConfirm.js +5 -1
  66. package/login/pages/DeleteAccountConfirm.js.map +1 -1
  67. package/login/pages/FrontchannelLogout.js +1 -1
  68. package/login/pages/FrontchannelLogout.js.map +1 -1
  69. package/login/pages/Login.js.map +1 -1
  70. package/login/pages/LoginRecoveryAuthnCodeConfig.js +3 -3
  71. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
  72. package/login/pages/LoginResetPassword.js.map +1 -1
  73. package/login/pages/LoginUsername.js.map +1 -1
  74. package/login/pages/WebauthnAuthenticate.js +11 -8
  75. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  76. package/login/pages/WebauthnRegister.js +7 -7
  77. package/login/pages/WebauthnRegister.js.map +1 -1
  78. package/package.json +230 -226
  79. package/src/PUBLIC_URL.ts +4 -1
  80. package/src/account/Template.tsx +5 -5
  81. package/src/account/TemplateProps.ts +4 -1
  82. package/src/account/i18n/i18n.tsx +40 -30
  83. package/src/account/kcContext/KcContext.ts +4 -1
  84. package/src/account/kcContext/createGetKcContext.ts +48 -22
  85. package/src/account/kcContext/getKcContext.ts +3 -1
  86. package/src/account/kcContext/getKcContextFromWindow.ts +6 -2
  87. package/src/account/kcContext/kcContextMocks.ts +164 -160
  88. package/src/account/lib/useGetClassName.ts +15 -14
  89. package/src/account/pages/Account.tsx +2 -2
  90. package/src/account/pages/Password.tsx +8 -8
  91. package/src/account/pages/Totp.tsx +4 -6
  92. package/src/bin/copy-keycloak-resources-to-public.ts +2 -2
  93. package/src/bin/download-keycloak-default-theme.ts +33 -7
  94. package/src/bin/eject-page.ts +48 -11
  95. package/src/bin/initialize-email-theme.ts +25 -17
  96. package/src/bin/keycloakify/buildJars/buildJar.ts +188 -64
  97. package/src/bin/keycloakify/buildJars/buildJars.ts +35 -16
  98. package/src/bin/keycloakify/buildJars/extensionVersions.ts +2 -1
  99. package/src/bin/keycloakify/buildJars/generatePom.ts +11 -3
  100. package/src/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.ts +33 -8
  101. package/src/bin/keycloakify/generateFtl/generateFtl.ts +49 -12
  102. package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +29 -18
  103. package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +35 -12
  104. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +3 -1
  105. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +86 -41
  106. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +39 -15
  107. package/src/bin/keycloakify/generateSrcMainResources/readExtraPageNames.ts +21 -7
  108. package/src/bin/keycloakify/generateSrcMainResources/readFieldNameUsage.ts +34 -7
  109. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +19 -5
  110. package/src/bin/keycloakify/keycloakify.ts +36 -11
  111. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +24 -5
  112. package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +6 -2
  113. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +6 -3
  114. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +24 -6
  115. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +49 -11
  116. package/src/bin/main.ts +78 -41
  117. package/src/bin/shared/KeycloakVersionRange.ts +3 -1
  118. package/src/bin/shared/buildOptions.ts +73 -43
  119. package/src/bin/shared/constants.ts +6 -2
  120. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +27 -13
  121. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +161 -218
  122. package/src/bin/shared/downloadKeycloakStaticResources.ts +25 -21
  123. package/src/bin/shared/getJarFileBasename.ts +3 -1
  124. package/src/bin/shared/getThemeSrcDirPath.ts +5 -2
  125. package/src/bin/shared/metaInfKeycloakThemes.ts +35 -8
  126. package/src/bin/shared/promptKeycloakVersion.ts +33 -14
  127. package/src/bin/start-keycloak/index.ts +1 -0
  128. package/src/bin/start-keycloak/myrealm-realm-23.json +2142 -0
  129. package/src/bin/start-keycloak/myrealm-realm-24.json +2318 -0
  130. package/src/bin/start-keycloak/start-keycloak.ts +467 -0
  131. package/src/bin/tools/SemVer.ts +32 -13
  132. package/src/bin/tools/String.prototype.replaceAll.ts +9 -2
  133. package/src/bin/tools/crawl.ts +4 -1
  134. package/src/bin/tools/crc32.ts +42 -24
  135. package/src/bin/tools/downloadAndExtractArchive/downloadAndExtractArchive.ts +262 -0
  136. package/src/bin/tools/downloadAndExtractArchive/fetchProxyOptions.ts +96 -0
  137. package/src/bin/tools/downloadAndExtractArchive/index.ts +1 -0
  138. package/src/bin/tools/extractArchive.ts +120 -0
  139. package/src/bin/tools/fetchProxyOptions.ts +31 -8
  140. package/src/bin/tools/getAbsoluteAndInOsFormatPath.ts +10 -2
  141. package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +50 -4
  142. package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +8 -2
  143. package/src/bin/tools/octokit-addons/listTags.ts +15 -4
  144. package/src/bin/tools/partitionPromiseSettledResults.ts +12 -3
  145. package/src/bin/tools/readThisNpmPackageVersion.ts +5 -1
  146. package/src/bin/tools/transformCodebase.ts +29 -10
  147. package/src/bin/tools/trimIndent.ts +4 -1
  148. package/src/lib/isStorybook.ts +3 -1
  149. package/src/lib/useGetClassName.ts +12 -3
  150. package/src/login/Template.tsx +14 -14
  151. package/src/login/TemplateProps.ts +4 -1
  152. package/src/login/UserProfileFormFields.tsx +44 -42
  153. package/src/login/i18n/baseMessages/ca.ts +1 -1
  154. package/src/login/i18n/baseMessages/el.ts +0 -1
  155. package/src/login/i18n/baseMessages/en.ts +1 -1
  156. package/src/login/i18n/baseMessages/es.ts +1 -1
  157. package/src/login/i18n/baseMessages/fa.ts +0 -1
  158. package/src/login/i18n/baseMessages/hu.ts +1 -1
  159. package/src/login/i18n/baseMessages/zh-CN.ts +1 -1
  160. package/src/login/i18n/i18n.tsx +42 -32
  161. package/src/login/kcContext/KcContext.ts +8 -2
  162. package/src/login/kcContext/createGetKcContext.ts +84 -37
  163. package/src/login/kcContext/getKcContext.ts +3 -1
  164. package/src/login/kcContext/getKcContextFromWindow.ts +6 -2
  165. package/src/login/kcContext/kcContextMocks.ts +339 -325
  166. package/src/login/lib/useDownloadTerms.ts +6 -4
  167. package/src/login/lib/useGetClassName.ts +119 -112
  168. package/src/login/lib/useUserProfileForm.tsx +219 -205
  169. package/src/login/pages/DeleteAccountConfirm.tsx +9 -3
  170. package/src/login/pages/FrontchannelLogout.tsx +1 -1
  171. package/src/login/pages/Login.tsx +2 -2
  172. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +3 -3
  173. package/src/login/pages/LoginResetPassword.tsx +2 -2
  174. package/src/login/pages/LoginUsername.tsx +2 -2
  175. package/src/login/pages/WebauthnAuthenticate.tsx +11 -8
  176. package/src/login/pages/WebauthnRegister.tsx +7 -7
  177. package/src/tools/AndByDiscriminatingKey.ts +12 -6
  178. package/src/tools/Array.prototype.every.ts +4 -1
  179. package/src/tools/LazyOrNot.ts +3 -1
  180. package/src/tools/clsx.ts +7 -1
  181. package/src/tools/deepAssign.ts +15 -8
  182. package/src/tools/deepClone.ts +3 -1
  183. package/src/tools/formatNumber.ts +4 -1
  184. package/src/tools/useConstCallback.ts +3 -1
  185. package/src/tools/useInsertLinkTags.ts +20 -7
  186. package/src/tools/useInsertScriptTags.ts +7 -2
  187. package/src/tools/useSetClassName.ts +4 -1
  188. package/src/vite-plugin/vite-plugin.ts +45 -21
  189. package/tools/Array.prototype.every.js +2 -1
  190. package/tools/Array.prototype.every.js.map +1 -1
  191. package/tools/clsx.js.map +1 -1
  192. package/tools/deepAssign.js +9 -7
  193. package/tools/deepAssign.js.map +1 -1
  194. package/tools/deepClone.js.map +1 -1
  195. package/tools/formatNumber.js.map +1 -1
  196. package/tools/useConstCallback.js.map +1 -1
  197. package/tools/useInsertLinkTags.js +5 -4
  198. package/tools/useInsertLinkTags.js.map +1 -1
  199. package/tools/useInsertScriptTags.js +5 -2
  200. package/tools/useInsertScriptTags.js.map +1 -1
  201. package/tools/useSetClassName.js.map +1 -1
  202. package/vite-plugin/index.js +1033 -1661
  203. package/src/bin/shared/downloadAndUnzip.ts +0 -203
  204. package/src/bin/start-keycloak.ts +0 -236
  205. package/src/bin/tools/unzip.ts +0 -141
@@ -30,7 +30,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
30
30
  console.log(chalk.cyan("Theme type:"));
31
31
 
32
32
  const { value: themeType } = await cliSelect<ThemeType>({
33
- "values": [...themeTypes]
33
+ values: [...themeTypes]
34
34
  }).catch(() => {
35
35
  process.exit(-1);
36
36
  });
@@ -40,7 +40,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
40
40
  console.log(chalk.cyan("Select the page you want to customize:"));
41
41
 
42
42
  const { value: pageId } = await cliSelect<LoginThemePageId | AccountThemePageId>({
43
- "values": (() => {
43
+ values: (() => {
44
44
  switch (themeType) {
45
45
  case "login":
46
46
  return [...loginThemePageIds];
@@ -55,14 +55,29 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
55
55
 
56
56
  console.log(`→ ${pageId}`);
57
57
 
58
- const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(/ftl$/, "tsx");
58
+ const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
59
+ /ftl$/,
60
+ "tsx"
61
+ );
59
62
 
60
- const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
63
+ const { themeSrcDirPath } = getThemeSrcDirPath({
64
+ reactAppRootDirPath: buildOptions.reactAppRootDirPath
65
+ });
61
66
 
62
- const targetFilePath = pathJoin(themeSrcDirPath, themeType, "pages", componentPageBasename);
67
+ const targetFilePath = pathJoin(
68
+ themeSrcDirPath,
69
+ themeType,
70
+ "pages",
71
+ componentPageBasename
72
+ );
63
73
 
64
74
  if (fs.existsSync(targetFilePath)) {
65
- console.log(`${pageId} is already ejected, ${pathRelative(process.cwd(), targetFilePath)} already exists`);
75
+ console.log(
76
+ `${pageId} is already ejected, ${pathRelative(
77
+ process.cwd(),
78
+ targetFilePath
79
+ )} already exists`
80
+ );
66
81
 
67
82
  process.exit(-1);
68
83
  }
@@ -71,12 +86,20 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
71
86
  const targetDirPath = pathDirname(targetFilePath);
72
87
 
73
88
  if (!fs.existsSync(targetDirPath)) {
74
- fs.mkdirSync(targetDirPath, { "recursive": true });
89
+ fs.mkdirSync(targetDirPath, { recursive: true });
75
90
  }
76
91
  }
77
92
 
78
93
  const componentPageContent = fs
79
- .readFileSync(pathJoin(getThisCodebaseRootDirPath(), "src", themeType, "pages", componentPageBasename))
94
+ .readFileSync(
95
+ pathJoin(
96
+ getThisCodebaseRootDirPath(),
97
+ "src",
98
+ themeType,
99
+ "pages",
100
+ componentPageBasename
101
+ )
102
+ )
80
103
  .toString("utf8");
81
104
 
82
105
  fs.writeFileSync(targetFilePath, Buffer.from(componentPageContent, "utf8"));
@@ -92,11 +115,23 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
92
115
  ``,
93
116
  `You now need to update your page router:`,
94
117
  ``,
95
- `${chalk.bold(pathJoin(".", pathRelative(process.cwd(), themeSrcDirPath), themeType, "KcApp.tsx"))}:`,
118
+ `${chalk.bold(
119
+ pathJoin(
120
+ ".",
121
+ pathRelative(process.cwd(), themeSrcDirPath),
122
+ themeType,
123
+ "KcApp.tsx"
124
+ )
125
+ )}:`,
96
126
  chalk.grey("```"),
97
127
  `// ...`,
98
128
  ``,
99
- chalk.green(`+const ${componentPageBasename.replace(/.tsx$/, "")} = lazy(() => import("./pages/${componentPageBasename}"));`),
129
+ chalk.green(
130
+ `+const ${componentPageBasename.replace(
131
+ /.tsx$/,
132
+ ""
133
+ )} = lazy(() => import("./pages/${componentPageBasename}"));`
134
+ ),
100
135
  ...[
101
136
  ``,
102
137
  ` export default function KcApp(props: { kcContext: KcContext; }) {`,
@@ -114,7 +149,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
114
149
  `+ Template={Template}`,
115
150
  ...(!componentPageContent.includes(userProfileFormFieldComponentName)
116
151
  ? []
117
- : [`+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`]),
152
+ : [
153
+ `+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`
154
+ ]),
118
155
  `+ doUseDefaultCss={true}`,
119
156
  `+ />`,
120
157
  `+ );`,
@@ -5,7 +5,6 @@ import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
5
5
  import { readBuildOptions } from "./shared/buildOptions";
6
6
  import * as fs from "fs";
7
7
  import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
8
- import { rmSync } from "./tools/fs.rmSync";
9
8
  import type { CliCommandOptions } from "./main";
10
9
 
11
10
  export async function command(params: { cliCommandOptions: CliCommandOptions }) {
@@ -14,13 +13,18 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
14
13
  const buildOptions = readBuildOptions({ cliCommandOptions });
15
14
 
16
15
  const { themeSrcDirPath } = getThemeSrcDirPath({
17
- "reactAppRootDirPath": buildOptions.reactAppRootDirPath
16
+ reactAppRootDirPath: buildOptions.reactAppRootDirPath
18
17
  });
19
18
 
20
19
  const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
21
20
 
22
21
  if (fs.existsSync(emailThemeSrcDirPath)) {
23
- console.warn(`There is already a ${pathRelative(process.cwd(), emailThemeSrcDirPath)} directory in your project. Aborting.`);
22
+ console.warn(
23
+ `There is already a ${pathRelative(
24
+ process.cwd(),
25
+ emailThemeSrcDirPath
26
+ )} directory in your project. Aborting.`
27
+ );
24
28
 
25
29
  process.exit(-1);
26
30
  }
@@ -29,33 +33,37 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
29
33
 
30
34
  const { keycloakVersion } = await promptKeycloakVersion({
31
35
  // NOTE: This is arbitrary
32
- "startingFromMajor": 17,
33
- "cacheDirPath": buildOptions.cacheDirPath
36
+ startingFromMajor: 17,
37
+ cacheDirPath: buildOptions.cacheDirPath
34
38
  });
35
39
 
36
- const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "initialize-email-theme_tmp");
37
-
38
- rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
39
-
40
- await downloadKeycloakDefaultTheme({
40
+ const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
41
41
  keycloakVersion,
42
- "destDirPath": builtinKeycloakThemeTmpDirPath,
43
42
  buildOptions
44
43
  });
45
44
 
46
45
  transformCodebase({
47
- "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "base", "email"),
48
- "destDirPath": emailThemeSrcDirPath
46
+ srcDirPath: pathJoin(defaultThemeDirPath, "base", "email"),
47
+ destDirPath: emailThemeSrcDirPath
49
48
  });
50
49
 
51
50
  {
52
51
  const themePropertyFilePath = pathJoin(emailThemeSrcDirPath, "theme.properties");
53
52
 
54
- fs.writeFileSync(themePropertyFilePath, Buffer.from(`parent=base\n${fs.readFileSync(themePropertyFilePath).toString("utf8")}`, "utf8"));
53
+ fs.writeFileSync(
54
+ themePropertyFilePath,
55
+ Buffer.from(
56
+ `parent=base\n${fs.readFileSync(themePropertyFilePath).toString("utf8")}`,
57
+ "utf8"
58
+ )
59
+ );
55
60
  }
56
61
 
57
- console.log(`The \`${pathJoin(".", pathRelative(process.cwd(), emailThemeSrcDirPath))}\` directory have been created.`);
62
+ console.log(
63
+ `The \`${pathJoin(
64
+ ".",
65
+ pathRelative(process.cwd(), emailThemeSrcDirPath)
66
+ )}\` directory have been created.`
67
+ );
58
68
  console.log("You can delete any file you don't modify.");
59
-
60
- rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true });
61
69
  }
@@ -1,16 +1,22 @@
1
1
  import { assert, type Equals } from "tsafe/assert";
2
- import type { KeycloakAccountV1Version, KeycloakThemeAdditionalInfoExtensionVersion } from "./extensionVersions";
2
+ import type {
3
+ KeycloakAccountV1Version,
4
+ KeycloakThemeAdditionalInfoExtensionVersion
5
+ } from "./extensionVersions";
3
6
  import { join as pathJoin, dirname as pathDirname } from "path";
4
7
  import { transformCodebase } from "../../tools/transformCodebase";
5
8
  import type { BuildOptions } from "../../shared/buildOptions";
6
9
  import * as fs from "fs/promises";
7
10
  import { accountV1ThemeName } from "../../shared/constants";
8
- import { generatePom, BuildOptionsLike as BuildOptionsLike_generatePom } from "./generatePom";
11
+ import {
12
+ generatePom,
13
+ BuildOptionsLike as BuildOptionsLike_generatePom
14
+ } from "./generatePom";
9
15
  import { readFileSync } from "fs";
10
16
  import { isInside } from "../../tools/isInside";
11
17
  import child_process from "child_process";
12
18
  import { rmSync } from "../../tools/fs.rmSync";
13
- import { getMetaInfKeycloakThemesJsonPath } from "../../shared/metaInfKeycloakThemes";
19
+ import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
14
20
 
15
21
  export type BuildOptionsLike = BuildOptionsLike_generatePom & {
16
22
  keycloakifyBuildDirPath: string;
@@ -28,57 +34,152 @@ export async function buildJar(params: {
28
34
  keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
29
35
  buildOptions: BuildOptionsLike;
30
36
  }): Promise<void> {
31
- const { jarFileBasename, keycloakAccountV1Version, keycloakThemeAdditionalInfoExtensionVersion, buildOptions } = params;
37
+ const {
38
+ jarFileBasename,
39
+ keycloakAccountV1Version,
40
+ keycloakThemeAdditionalInfoExtensionVersion,
41
+ buildOptions
42
+ } = params;
32
43
 
33
- const keycloakifyBuildTmpDirPath = pathJoin(buildOptions.cacheDirPath, jarFileBasename.replace(".jar", ""));
44
+ const keycloakifyBuildTmpDirPath = pathJoin(
45
+ buildOptions.cacheDirPath,
46
+ jarFileBasename.replace(".jar", "")
47
+ );
34
48
 
35
- rmSync(keycloakifyBuildTmpDirPath, { "recursive": true, "force": true });
49
+ rmSync(keycloakifyBuildTmpDirPath, { recursive: true, force: true });
36
50
 
37
51
  {
38
- const keycloakThemesJsonFilePath = getMetaInfKeycloakThemesJsonPath({ "keycloakifyBuildDirPath": "" });
52
+ const transformCodebase_common = (params: {
53
+ fileRelativePath: string;
54
+ sourceCode: Buffer;
55
+ }): { modifiedSourceCode: Buffer } | undefined => {
56
+ const { fileRelativePath, sourceCode } = params;
39
57
 
40
- const themePropertiesFilePathSet = new Set(
41
- ...buildOptions.themeNames.map(themeName => pathJoin("src", "main", "resources", "theme", themeName, "account", "theme.properties"))
42
- );
58
+ if (
59
+ fileRelativePath ===
60
+ getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath: "." })
61
+ ) {
62
+ return { modifiedSourceCode: sourceCode };
63
+ }
43
64
 
44
- const accountV1RelativeDirPath = pathJoin("src", "main", "resources", "theme", accountV1ThemeName);
65
+ for (const themeName of [...buildOptions.themeNames, accountV1ThemeName]) {
66
+ if (
67
+ isInside({
68
+ dirPath: pathJoin("src", "main", "resources", "theme", themeName),
69
+ filePath: fileRelativePath
70
+ })
71
+ ) {
72
+ return { modifiedSourceCode: sourceCode };
73
+ }
74
+ }
45
75
 
46
- transformCodebase({
47
- "srcDirPath": buildOptions.keycloakifyBuildDirPath,
48
- "destDirPath": keycloakifyBuildTmpDirPath,
49
- "transformSourceCode":
50
- keycloakAccountV1Version !== null
51
- ? undefined
52
- : ({ fileRelativePath, sourceCode }) => {
53
- if (fileRelativePath === keycloakThemesJsonFilePath) {
54
- const keycloakThemesJsonParsed = JSON.parse(sourceCode.toString("utf8")) as {
55
- themes: { name: string; types: string[] }[];
56
- };
57
-
58
- keycloakThemesJsonParsed.themes = keycloakThemesJsonParsed.themes.filter(({ name }) => name !== accountV1ThemeName);
59
-
60
- return { "modifiedSourceCode": Buffer.from(JSON.stringify(keycloakThemesJsonParsed, null, 2), "utf8") };
61
- }
76
+ return undefined;
77
+ };
62
78
 
63
- if (isInside({ "dirPath": "target", "filePath": fileRelativePath })) {
64
- return undefined;
65
- }
79
+ const transformCodebase_patchForUsingBuiltinAccountV1 =
80
+ keycloakAccountV1Version !== null
81
+ ? undefined
82
+ : (params: {
83
+ fileRelativePath: string;
84
+ sourceCode: Buffer;
85
+ }): { modifiedSourceCode: Buffer } | undefined => {
86
+ const { fileRelativePath, sourceCode } = params;
66
87
 
67
- if (isInside({ "dirPath": accountV1RelativeDirPath, "filePath": fileRelativePath })) {
68
- return undefined;
69
- }
88
+ if (
89
+ isInside({
90
+ dirPath: pathJoin(
91
+ "src",
92
+ "main",
93
+ "resources",
94
+ "theme",
95
+ accountV1ThemeName
96
+ ),
97
+ filePath: fileRelativePath
98
+ })
99
+ ) {
100
+ return undefined;
101
+ }
70
102
 
71
- if (themePropertiesFilePathSet.has(fileRelativePath)) {
72
- return {
73
- "modifiedSourceCode": Buffer.from(
74
- sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
75
- "utf8"
76
- )
77
- };
78
- }
103
+ if (
104
+ fileRelativePath ===
105
+ getMetaInfKeycloakThemesJsonFilePath({
106
+ keycloakifyBuildDirPath: "."
107
+ })
108
+ ) {
109
+ const keycloakThemesJsonParsed = JSON.parse(
110
+ sourceCode.toString("utf8")
111
+ ) as {
112
+ themes: { name: string; types: string[] }[];
113
+ };
114
+
115
+ keycloakThemesJsonParsed.themes =
116
+ keycloakThemesJsonParsed.themes.filter(
117
+ ({ name }) => name !== accountV1ThemeName
118
+ );
119
+
120
+ return {
121
+ modifiedSourceCode: Buffer.from(
122
+ JSON.stringify(keycloakThemesJsonParsed, null, 2),
123
+ "utf8"
124
+ )
125
+ };
126
+ }
127
+
128
+ for (const themeName of buildOptions.themeNames) {
129
+ if (
130
+ fileRelativePath ===
131
+ pathJoin(
132
+ "src",
133
+ "main",
134
+ "resources",
135
+ "theme",
136
+ themeName,
137
+ "account",
138
+ "theme.properties"
139
+ )
140
+ ) {
141
+ const modifiedSourceCode = Buffer.from(
142
+ sourceCode
143
+ .toString("utf8")
144
+ .replace(
145
+ `parent=${accountV1ThemeName}`,
146
+ "parent=keycloak"
147
+ ),
148
+ "utf8"
149
+ );
79
150
 
80
- return { "modifiedSourceCode": sourceCode };
151
+ assert(
152
+ Buffer.compare(modifiedSourceCode, sourceCode) !== 0
153
+ );
154
+
155
+ return { modifiedSourceCode };
156
+ }
81
157
  }
158
+
159
+ return { modifiedSourceCode: sourceCode };
160
+ };
161
+
162
+ transformCodebase({
163
+ srcDirPath: buildOptions.keycloakifyBuildDirPath,
164
+ destDirPath: keycloakifyBuildTmpDirPath,
165
+ transformSourceCode: params => {
166
+ const resultCommon = transformCodebase_common(params);
167
+
168
+ if (transformCodebase_patchForUsingBuiltinAccountV1 === undefined) {
169
+ return resultCommon;
170
+ }
171
+
172
+ if (resultCommon === undefined) {
173
+ return undefined;
174
+ }
175
+
176
+ const { modifiedSourceCode } = resultCommon;
177
+
178
+ return transformCodebase_patchForUsingBuiltinAccountV1({
179
+ ...params,
180
+ sourceCode: modifiedSourceCode
181
+ });
182
+ }
82
183
  });
83
184
  }
84
185
 
@@ -103,7 +204,16 @@ export async function buildJar(params: {
103
204
 
104
205
  (["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
105
206
  buildOptions.themeNames.map(themeName => {
106
- const ftlFilePath = pathJoin(keycloakifyBuildTmpDirPath, "src", "main", "resources", "theme", themeName, "login", pageId);
207
+ const ftlFilePath = pathJoin(
208
+ keycloakifyBuildTmpDirPath,
209
+ "src",
210
+ "main",
211
+ "resources",
212
+ "theme",
213
+ themeName,
214
+ "login",
215
+ pageId
216
+ );
107
217
 
108
218
  const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
109
219
 
@@ -124,7 +234,10 @@ export async function buildJar(params: {
124
234
 
125
235
  assert(modifiedFtlFileContent !== ftlFileContent);
126
236
 
127
- fs.writeFile(pathJoin(pathDirname(ftlFilePath), realPageId), Buffer.from(modifiedFtlFileContent, "utf8"));
237
+ fs.writeFile(
238
+ pathJoin(pathDirname(ftlFilePath), realPageId),
239
+ Buffer.from(modifiedFtlFileContent, "utf8")
240
+ );
128
241
  })
129
242
  );
130
243
  }
@@ -136,35 +249,46 @@ export async function buildJar(params: {
136
249
  keycloakThemeAdditionalInfoExtensionVersion
137
250
  });
138
251
 
139
- await fs.writeFile(pathJoin(keycloakifyBuildTmpDirPath, "pom.xml"), Buffer.from(pomFileCode, "utf8"));
252
+ await fs.writeFile(
253
+ pathJoin(keycloakifyBuildTmpDirPath, "pom.xml"),
254
+ Buffer.from(pomFileCode, "utf8")
255
+ );
140
256
  }
141
257
 
142
258
  await new Promise<void>((resolve, reject) =>
143
- child_process.exec("mvn clean install", { "cwd": keycloakifyBuildTmpDirPath }, error => {
144
- if (error !== null) {
145
- console.error(
146
- `Build jar failed: ${JSON.stringify(
147
- {
148
- jarFileBasename,
149
- keycloakAccountV1Version,
150
- keycloakThemeAdditionalInfoExtensionVersion
151
- },
152
- null,
153
- 2
154
- )}`
155
- );
259
+ child_process.exec(
260
+ `mvn clean install -Dmaven.repo.local=${pathJoin(keycloakifyBuildTmpDirPath, ".m2")}`,
261
+ { cwd: keycloakifyBuildTmpDirPath },
262
+ error => {
263
+ if (error !== null) {
264
+ console.error(
265
+ `Build jar failed: ${JSON.stringify(
266
+ {
267
+ jarFileBasename,
268
+ keycloakAccountV1Version,
269
+ keycloakThemeAdditionalInfoExtensionVersion
270
+ },
271
+ null,
272
+ 2
273
+ )}`
274
+ );
156
275
 
157
- reject(error);
158
- return;
276
+ reject(error);
277
+ return;
278
+ }
279
+ resolve();
159
280
  }
160
- resolve();
161
- })
281
+ )
162
282
  );
163
283
 
164
284
  await fs.rename(
165
- pathJoin(keycloakifyBuildTmpDirPath, "target", `${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`),
285
+ pathJoin(
286
+ keycloakifyBuildTmpDirPath,
287
+ "target",
288
+ `${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`
289
+ ),
166
290
  pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename)
167
291
  );
168
292
 
169
- rmSync(keycloakifyBuildTmpDirPath, { "recursive": true });
293
+ rmSync(keycloakifyBuildTmpDirPath, { recursive: true });
170
294
  }
@@ -1,6 +1,9 @@
1
1
  import { assert } from "tsafe/assert";
2
2
  import { exclude } from "tsafe/exclude";
3
- import { keycloakAccountV1Versions, keycloakThemeAdditionalInfoExtensionVersions } from "./extensionVersions";
3
+ import {
4
+ keycloakAccountV1Versions,
5
+ keycloakThemeAdditionalInfoExtensionVersions
6
+ } from "./extensionVersions";
4
7
  import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
5
8
  import { buildJar, BuildOptionsLike as BuildOptionsLike_buildJar } from "./buildJar";
6
9
  import type { BuildOptions } from "../../shared/buildOptions";
@@ -14,11 +17,13 @@ export type BuildOptionsLike = BuildOptionsLike_buildJar & {
14
17
 
15
18
  assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
19
 
17
- export async function buildJars(params: { buildOptions: BuildOptionsLike }): Promise<void> {
20
+ export async function buildJars(params: {
21
+ buildOptions: BuildOptionsLike;
22
+ }): Promise<void> {
18
23
  const { buildOptions } = params;
19
24
 
20
25
  const doesImplementAccountTheme = readMetaInfKeycloakThemes({
21
- "keycloakifyBuildDirPath": buildOptions.keycloakifyBuildDirPath
26
+ keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
22
27
  }).themes.some(({ name }) => name === accountV1ThemeName);
23
28
 
24
29
  await Promise.all(
@@ -36,24 +41,38 @@ export async function buildJars(params: { buildOptions: BuildOptionsLike }): Pro
36
41
  return undefined;
37
42
  }
38
43
 
39
- return { keycloakThemeAdditionalInfoExtensionVersion, keycloakVersionRange };
40
- })
41
- .filter(exclude(undefined))
42
- .map(({ keycloakThemeAdditionalInfoExtensionVersion, keycloakVersionRange }) => {
43
- const { jarFileBasename } = getJarFileBasename({ keycloakVersionRange });
44
-
45
44
  return {
46
45
  keycloakThemeAdditionalInfoExtensionVersion,
47
- jarFileBasename
46
+ keycloakVersionRange
48
47
  };
49
48
  })
50
- .map(({ keycloakThemeAdditionalInfoExtensionVersion, jarFileBasename }) =>
51
- buildJar({
52
- jarFileBasename,
53
- keycloakAccountV1Version,
49
+ .filter(exclude(undefined))
50
+ .map(
51
+ ({
54
52
  keycloakThemeAdditionalInfoExtensionVersion,
55
- buildOptions
56
- })
53
+ keycloakVersionRange
54
+ }) => {
55
+ const { jarFileBasename } = getJarFileBasename({
56
+ keycloakVersionRange
57
+ });
58
+
59
+ return {
60
+ keycloakThemeAdditionalInfoExtensionVersion,
61
+ jarFileBasename
62
+ };
63
+ }
64
+ )
65
+ .map(
66
+ ({
67
+ keycloakThemeAdditionalInfoExtensionVersion,
68
+ jarFileBasename
69
+ }) =>
70
+ buildJar({
71
+ jarFileBasename,
72
+ keycloakAccountV1Version,
73
+ keycloakThemeAdditionalInfoExtensionVersion,
74
+ buildOptions
75
+ })
57
76
  )
58
77
  )
59
78
  .flat()
@@ -13,4 +13,5 @@ export const keycloakThemeAdditionalInfoExtensionVersions = [null, "1.1.5"] as c
13
13
  * https://central.sonatype.com/artifact/dev.jcputney/keycloak-theme-additional-info-extension
14
14
  * https://github.com/jcputney/keycloak-theme-additional-info-extension
15
15
  * */
16
- export type KeycloakThemeAdditionalInfoExtensionVersion = (typeof keycloakThemeAdditionalInfoExtensionVersions)[number];
16
+ export type KeycloakThemeAdditionalInfoExtensionVersion =
17
+ (typeof keycloakThemeAdditionalInfoExtensionVersions)[number];
@@ -1,6 +1,9 @@
1
1
  import { assert } from "tsafe/assert";
2
2
  import type { BuildOptions } from "../../shared/buildOptions";
3
- import type { KeycloakAccountV1Version, KeycloakThemeAdditionalInfoExtensionVersion } from "./extensionVersions";
3
+ import type {
4
+ KeycloakAccountV1Version,
5
+ KeycloakThemeAdditionalInfoExtensionVersion
6
+ } from "./extensionVersions";
4
7
 
5
8
  export type BuildOptionsLike = {
6
9
  groupId: string;
@@ -15,7 +18,11 @@ export function generatePom(params: {
15
18
  keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
16
19
  buildOptions: BuildOptionsLike;
17
20
  }) {
18
- const { keycloakAccountV1Version, keycloakThemeAdditionalInfoExtensionVersion, buildOptions } = params;
21
+ const {
22
+ keycloakAccountV1Version,
23
+ keycloakThemeAdditionalInfoExtensionVersion,
24
+ buildOptions
25
+ } = params;
19
26
 
20
27
  const { pomFileCode } = (function generatePomFileCode(): {
21
28
  pomFileCode: string;
@@ -35,7 +42,8 @@ export function generatePom(params: {
35
42
  ` <properties>`,
36
43
  ` <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>`,
37
44
  ` </properties>`,
38
- ...(keycloakAccountV1Version !== null && keycloakThemeAdditionalInfoExtensionVersion !== null
45
+ ...(keycloakAccountV1Version !== null &&
46
+ keycloakThemeAdditionalInfoExtensionVersion !== null
39
47
  ? [
40
48
  ` <build>`,
41
49
  ` <plugins>`,