keycloakify 10.0.0-rc.17 → 10.0.0-rc.19

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 (208) 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 +2265 -2028
  23. package/bin/shared/constants.d.ts +1 -0
  24. package/bin/shared/constants.js +4 -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 +232 -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 +30 -8
  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 +179 -104
  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/ftl_object_to_js_code_declaring_an_object.ftl +20 -2
  102. package/src/bin/keycloakify/generateFtl/generateFtl.ts +49 -12
  103. package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +29 -18
  104. package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +35 -12
  105. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +3 -1
  106. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +86 -41
  107. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +39 -15
  108. package/src/bin/keycloakify/generateSrcMainResources/readExtraPageNames.ts +21 -7
  109. package/src/bin/keycloakify/generateSrcMainResources/readFieldNameUsage.ts +34 -7
  110. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +19 -5
  111. package/src/bin/keycloakify/keycloakify.ts +28 -9
  112. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +24 -5
  113. package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +6 -2
  114. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +6 -3
  115. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +24 -6
  116. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +49 -11
  117. package/src/bin/main.ts +78 -41
  118. package/src/bin/shared/KeycloakVersionRange.ts +3 -1
  119. package/src/bin/shared/buildOptions.ts +70 -43
  120. package/src/bin/shared/constants.ts +4 -2
  121. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +27 -13
  122. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +161 -218
  123. package/src/bin/shared/downloadKeycloakStaticResources.ts +25 -21
  124. package/src/bin/shared/getJarFileBasename.ts +3 -1
  125. package/src/bin/shared/getThemeSrcDirPath.ts +5 -2
  126. package/src/bin/shared/metaInfKeycloakThemes.ts +35 -8
  127. package/src/bin/shared/promptKeycloakVersion.ts +33 -14
  128. package/src/bin/start-keycloak/appBuild.ts +128 -0
  129. package/src/bin/start-keycloak/index.ts +1 -0
  130. package/src/bin/start-keycloak/keycloakifyBuild.ts +41 -0
  131. package/src/bin/start-keycloak/myrealm-realm-23.json +2142 -0
  132. package/src/bin/start-keycloak/myrealm-realm-24.json +2318 -0
  133. package/src/bin/start-keycloak/start-keycloak.ts +469 -0
  134. package/src/bin/tools/SemVer.ts +32 -13
  135. package/src/bin/tools/String.prototype.replaceAll.ts +9 -2
  136. package/src/bin/tools/crawl.ts +4 -1
  137. package/src/bin/tools/crc32.ts +42 -24
  138. package/src/bin/tools/downloadAndExtractArchive/downloadAndExtractArchive.ts +262 -0
  139. package/src/bin/tools/downloadAndExtractArchive/fetchProxyOptions.ts +96 -0
  140. package/src/bin/tools/downloadAndExtractArchive/index.ts +1 -0
  141. package/src/bin/tools/extractArchive.ts +132 -0
  142. package/src/bin/tools/fetchProxyOptions.ts +31 -8
  143. package/src/bin/tools/getAbsoluteAndInOsFormatPath.ts +10 -2
  144. package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +18 -5
  145. package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +8 -2
  146. package/src/bin/tools/octokit-addons/listTags.ts +15 -4
  147. package/src/bin/tools/partitionPromiseSettledResults.ts +12 -3
  148. package/src/bin/tools/readThisNpmPackageVersion.ts +5 -1
  149. package/src/bin/tools/transformCodebase.ts +29 -10
  150. package/src/bin/tools/trimIndent.ts +4 -1
  151. package/src/lib/isStorybook.ts +3 -1
  152. package/src/lib/useGetClassName.ts +12 -3
  153. package/src/login/Template.tsx +14 -14
  154. package/src/login/TemplateProps.ts +4 -1
  155. package/src/login/UserProfileFormFields.tsx +44 -42
  156. package/src/login/i18n/baseMessages/ca.ts +1 -1
  157. package/src/login/i18n/baseMessages/el.ts +0 -1
  158. package/src/login/i18n/baseMessages/en.ts +1 -1
  159. package/src/login/i18n/baseMessages/es.ts +1 -1
  160. package/src/login/i18n/baseMessages/fa.ts +0 -1
  161. package/src/login/i18n/baseMessages/hu.ts +1 -1
  162. package/src/login/i18n/baseMessages/zh-CN.ts +1 -1
  163. package/src/login/i18n/i18n.tsx +42 -32
  164. package/src/login/kcContext/KcContext.ts +8 -2
  165. package/src/login/kcContext/createGetKcContext.ts +84 -37
  166. package/src/login/kcContext/getKcContext.ts +3 -1
  167. package/src/login/kcContext/getKcContextFromWindow.ts +6 -2
  168. package/src/login/kcContext/kcContextMocks.ts +339 -325
  169. package/src/login/lib/useDownloadTerms.ts +6 -4
  170. package/src/login/lib/useGetClassName.ts +119 -112
  171. package/src/login/lib/useUserProfileForm.tsx +219 -205
  172. package/src/login/pages/DeleteAccountConfirm.tsx +9 -3
  173. package/src/login/pages/FrontchannelLogout.tsx +1 -1
  174. package/src/login/pages/Login.tsx +2 -2
  175. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +3 -3
  176. package/src/login/pages/LoginResetPassword.tsx +2 -2
  177. package/src/login/pages/LoginUsername.tsx +2 -2
  178. package/src/login/pages/WebauthnAuthenticate.tsx +11 -8
  179. package/src/login/pages/WebauthnRegister.tsx +7 -7
  180. package/src/tools/AndByDiscriminatingKey.ts +12 -6
  181. package/src/tools/Array.prototype.every.ts +4 -1
  182. package/src/tools/LazyOrNot.ts +3 -1
  183. package/src/tools/clsx.ts +7 -1
  184. package/src/tools/deepAssign.ts +15 -8
  185. package/src/tools/deepClone.ts +3 -1
  186. package/src/tools/formatNumber.ts +4 -1
  187. package/src/tools/useConstCallback.ts +3 -1
  188. package/src/tools/useInsertLinkTags.ts +20 -7
  189. package/src/tools/useInsertScriptTags.ts +7 -2
  190. package/src/tools/useSetClassName.ts +4 -1
  191. package/src/vite-plugin/vite-plugin.ts +45 -21
  192. package/tools/Array.prototype.every.js +2 -1
  193. package/tools/Array.prototype.every.js.map +1 -1
  194. package/tools/clsx.js.map +1 -1
  195. package/tools/deepAssign.js +9 -7
  196. package/tools/deepAssign.js.map +1 -1
  197. package/tools/deepClone.js.map +1 -1
  198. package/tools/formatNumber.js.map +1 -1
  199. package/tools/useConstCallback.js.map +1 -1
  200. package/tools/useInsertLinkTags.js +5 -4
  201. package/tools/useInsertLinkTags.js.map +1 -1
  202. package/tools/useInsertScriptTags.js +5 -2
  203. package/tools/useInsertScriptTags.js.map +1 -1
  204. package/tools/useSetClassName.js.map +1 -1
  205. package/vite-plugin/index.js +985 -1651
  206. package/src/bin/shared/downloadAndUnzip.ts +0 -203
  207. package/src/bin/start-keycloak.ts +0 -309
  208. package/src/bin/tools/unzip.ts +0 -141
@@ -1,12 +1,9 @@
1
- import { join as pathJoin } from "path";
2
- import { downloadAndUnzip } from "./downloadAndUnzip";
1
+ import { join as pathJoin, relative as pathRelative } from "path";
3
2
  import { type BuildOptions } from "./buildOptions";
4
3
  import { assert } from "tsafe/assert";
5
- import * as child_process from "child_process";
6
- import * as fs from "fs";
7
- import { rmSync } from "../tools/fs.rmSync";
8
4
  import { lastKeycloakVersionWithAccountV1 } from "./constants";
9
- import { transformCodebase } from "../tools/transformCodebase";
5
+ import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
6
+ import { isInside } from "../tools/isInside";
10
7
 
11
8
  export type BuildOptionsLike = {
12
9
  cacheDirPath: string;
@@ -15,250 +12,196 @@ export type BuildOptionsLike = {
15
12
 
16
13
  assert<BuildOptions extends BuildOptionsLike ? true : false>();
17
14
 
18
- export async function downloadKeycloakDefaultTheme(params: { keycloakVersion: string; destDirPath: string; buildOptions: BuildOptionsLike }) {
19
- const { keycloakVersion, destDirPath, buildOptions } = params;
20
-
21
- await downloadAndUnzip({
22
- destDirPath,
23
- "url": `https://github.com/keycloak/keycloak/archive/refs/tags/${keycloakVersion}.zip`,
24
- "specificDirsToExtract": ["", "-community"].map(ext => `keycloak-${keycloakVersion}/themes/src/main/resources${ext}/theme`),
25
- buildOptions,
26
- "preCacheTransform": {
27
- "actionCacheId": "npm install and build",
28
- "action": async ({ destDirPath }) => {
29
- install_common_node_modules: {
30
- const commonResourcesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources");
15
+ export async function downloadKeycloakDefaultTheme(params: {
16
+ keycloakVersion: string;
17
+ buildOptions: BuildOptionsLike;
18
+ }): Promise<{ defaultThemeDirPath: string }> {
19
+ const { keycloakVersion, buildOptions } = params;
20
+
21
+ const { extractedDirPath } = await downloadAndExtractArchive({
22
+ url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
23
+ cacheDirPath: buildOptions.cacheDirPath,
24
+ npmWorkspaceRootDirPath: buildOptions.npmWorkspaceRootDirPath,
25
+ uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
26
+ onArchiveFile: async params => {
27
+ if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
28
+ return;
29
+ }
31
30
 
32
- if (!fs.existsSync(commonResourcesDirPath)) {
33
- break install_common_node_modules;
34
- }
31
+ const { readFile, writeFile } = params;
35
32
 
36
- if (!fs.existsSync(pathJoin(commonResourcesDirPath, "package.json"))) {
37
- break install_common_node_modules;
38
- }
33
+ const fileRelativePath = pathRelative("theme", params.fileRelativePath);
39
34
 
40
- if (fs.existsSync(pathJoin(commonResourcesDirPath, "node_modules"))) {
41
- break install_common_node_modules;
42
- }
43
-
44
- child_process.execSync("npm install --omit=dev", {
45
- "cwd": commonResourcesDirPath,
46
- "stdio": "ignore"
47
- });
35
+ skip_keycloak_v2: {
36
+ if (
37
+ !isInside({
38
+ dirPath: pathJoin("keycloak.v2"),
39
+ filePath: fileRelativePath
40
+ })
41
+ ) {
42
+ break skip_keycloak_v2;
48
43
  }
49
44
 
50
- repatriate_common_resources_from_base_login_theme: {
51
- const baseLoginThemeResourceDir = pathJoin(destDirPath, "base", "login", "resources");
52
-
53
- if (!fs.existsSync(baseLoginThemeResourceDir)) {
54
- break repatriate_common_resources_from_base_login_theme;
55
- }
45
+ return;
46
+ }
56
47
 
57
- transformCodebase({
58
- "srcDirPath": baseLoginThemeResourceDir,
59
- "destDirPath": pathJoin(destDirPath, "keycloak", "login", "resources")
60
- });
48
+ last_account_v1_transformations: {
49
+ if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
50
+ break last_account_v1_transformations;
61
51
  }
62
52
 
63
- install_and_move_to_common_resources_generated_in_keycloak_v2: {
64
- if (!fs.readFileSync(pathJoin(destDirPath, "keycloak", "login", "theme.properties")).toString("utf8").includes("web_modules")) {
65
- break install_and_move_to_common_resources_generated_in_keycloak_v2;
66
- }
67
-
68
- const accountV2DirSrcDirPath = pathJoin(destDirPath, "keycloak.v2", "account", "src");
69
-
70
- if (!fs.existsSync(accountV2DirSrcDirPath)) {
71
- break install_and_move_to_common_resources_generated_in_keycloak_v2;
72
- }
73
-
74
- const packageManager = fs.existsSync(pathJoin(accountV2DirSrcDirPath, "pnpm-lock.yaml")) ? "pnpm" : "npm";
75
-
76
- if (packageManager === "pnpm") {
77
- try {
78
- child_process.execSync(`which pnpm`);
79
- } catch {
80
- console.log(`Installing pnpm globally`);
81
- child_process.execSync(`npm install -g pnpm`);
82
- }
53
+ patch_account_css: {
54
+ if (
55
+ fileRelativePath !==
56
+ pathJoin("keycloak", "account", "resources", "css", "account.css")
57
+ ) {
58
+ break patch_account_css;
83
59
  }
84
60
 
85
- child_process.execSync(`${packageManager} install`, { "cwd": accountV2DirSrcDirPath, "stdio": "ignore" });
86
-
87
- const packageJsonFilePath = pathJoin(accountV2DirSrcDirPath, "package.json");
88
-
89
- const packageJsonRaw = fs.readFileSync(packageJsonFilePath);
90
-
91
- const parsedPackageJson = JSON.parse(packageJsonRaw.toString("utf8"));
92
-
93
- parsedPackageJson.scripts.build = parsedPackageJson.scripts.build
94
- .replace(`${packageManager} run check-types`, "true")
95
- .replace(`${packageManager} run babel`, "true");
96
-
97
- fs.writeFileSync(packageJsonFilePath, Buffer.from(JSON.stringify(parsedPackageJson, null, 2), "utf8"));
98
-
99
- child_process.execSync(`${packageManager} run build`, { "cwd": accountV2DirSrcDirPath, "stdio": "ignore" });
100
-
101
- fs.writeFileSync(packageJsonFilePath, packageJsonRaw);
61
+ await writeFile({
62
+ fileRelativePath,
63
+ modifiedData: Buffer.from(
64
+ (await readFile())
65
+ .toString("utf8")
66
+ .replace("top: -34px;", "top: -34px !important;"),
67
+ "utf8"
68
+ )
69
+ });
102
70
 
103
- fs.rmSync(pathJoin(accountV2DirSrcDirPath, "node_modules"), { "recursive": true });
71
+ return;
104
72
  }
105
73
 
106
- remove_keycloak_v2: {
107
- const keycloakV2DirPath = pathJoin(destDirPath, "keycloak.v2");
108
-
109
- if (!fs.existsSync(keycloakV2DirPath)) {
110
- break remove_keycloak_v2;
74
+ skip_web_modules: {
75
+ if (
76
+ !isInside({
77
+ dirPath: pathJoin(
78
+ "keycloak",
79
+ "common",
80
+ "resources",
81
+ "web_modules"
82
+ ),
83
+ filePath: fileRelativePath
84
+ })
85
+ ) {
86
+ break skip_web_modules;
111
87
  }
112
88
 
113
- rmSync(keycloakV2DirPath, { "recursive": true });
89
+ return;
114
90
  }
115
91
 
116
- // Note, this is an optimization for reducing the size of the jar
117
- remove_unused_node_modules: {
118
- const nodeModuleDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
119
-
120
- if (!fs.existsSync(nodeModuleDirPath)) {
121
- break remove_unused_node_modules;
92
+ skip_unused_node_modules: {
93
+ const nodeModulesDirPath = pathJoin(
94
+ "keycloak",
95
+ "common",
96
+ "resources",
97
+ "node_modules"
98
+ );
99
+
100
+ if (
101
+ !isInside({
102
+ dirPath: nodeModulesDirPath,
103
+ filePath: fileRelativePath
104
+ })
105
+ ) {
106
+ break skip_unused_node_modules;
122
107
  }
123
108
 
124
- const toDeletePerfixes = [
125
- "angular",
126
- "bootstrap",
127
- "rcue",
128
- "font-awesome",
129
- "ng-file-upload",
130
- pathJoin("patternfly", "dist", "sass"),
131
- pathJoin("patternfly", "dist", "less"),
132
- pathJoin("patternfly", "dist", "js"),
133
- "d3",
134
- pathJoin("jquery", "src"),
135
- "c3",
136
- "core-js",
137
- "eonasdan-bootstrap-datetimepicker",
138
- "moment",
139
- "react",
140
- "patternfly-bootstrap-treeview",
141
- "popper.js",
142
- "tippy.js",
143
- "jquery-match-height",
144
- "google-code-prettify",
145
- "patternfly-bootstrap-combobox",
146
- "focus-trap",
147
- "tabbable",
148
- "scheduler",
149
- "@types",
150
- "datatables.net",
151
- "datatables.net-colreorder",
152
- "tslib",
153
- "prop-types",
154
- "file-selector",
155
- "datatables.net-colreorder-bs",
156
- "object-assign",
157
- "warning",
158
- "js-tokens",
159
- "loose-envify",
160
- "prop-types-extra",
161
- "attr-accept",
162
- "datatables.net-select",
163
- "drmonty-datatables-colvis",
164
- "datatables.net-bs",
165
- pathJoin("@patternfly", "react"),
166
- pathJoin("@patternfly", "patternfly", "docs")
109
+ const toKeepPrefixes = [
110
+ ...[
111
+ "patternfly.min.css",
112
+ "patternfly-additions.min.css",
113
+ "patternfly-additions.min.css"
114
+ ].map(fileBasename =>
115
+ pathJoin(
116
+ nodeModulesDirPath,
117
+ "patternfly",
118
+ "dist",
119
+ "css",
120
+ fileBasename
121
+ )
122
+ ),
123
+ pathJoin(nodeModulesDirPath, "patternfly", "dist", "fonts")
167
124
  ];
168
125
 
169
- transformCodebase({
170
- "srcDirPath": nodeModuleDirPath,
171
- "destDirPath": nodeModuleDirPath,
172
- "transformSourceCode": ({ sourceCode, fileRelativePath }) => {
173
- if (fileRelativePath.endsWith(".map")) {
174
- return undefined;
175
- }
176
-
177
- if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
178
- return undefined;
179
- }
180
-
181
- if (fileRelativePath.startsWith(pathJoin("patternfly", "dist", "fonts"))) {
182
- if (
183
- !fileRelativePath.endsWith(".woff2") &&
184
- !fileRelativePath.endsWith(".woff") &&
185
- !fileRelativePath.endsWith(".ttf")
186
- ) {
187
- return undefined;
188
- }
189
- }
190
-
191
- return { "modifiedSourceCode": sourceCode };
192
- }
193
- });
194
- }
195
-
196
- // Just like node_modules
197
- remove_unused_lib: {
198
- const libDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "lib");
199
-
200
- if (!fs.existsSync(libDirPath)) {
201
- break remove_unused_lib;
126
+ if (
127
+ toKeepPrefixes.find(prefix =>
128
+ fileRelativePath.startsWith(prefix)
129
+ ) !== undefined
130
+ ) {
131
+ break skip_unused_node_modules;
202
132
  }
203
133
 
204
- const toDeletePerfixes = ["ui-ace", "filesaver", "fileupload", "angular", "ui-ace"];
205
-
206
- transformCodebase({
207
- "srcDirPath": libDirPath,
208
- "destDirPath": libDirPath,
209
- "transformSourceCode": ({ sourceCode, fileRelativePath }) => {
210
- if (fileRelativePath.endsWith(".map")) {
211
- return undefined;
212
- }
213
-
214
- if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
215
- return undefined;
216
- }
217
-
218
- return { "modifiedSourceCode": sourceCode };
219
- }
220
- });
134
+ return;
221
135
  }
136
+ }
222
137
 
223
- last_account_v1_transformations: {
224
- if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
225
- break last_account_v1_transformations;
226
- }
227
-
228
- {
229
- const accountCssFilePath = pathJoin(destDirPath, "keycloak", "account", "resources", "css", "account.css");
138
+ skip_unused_resources: {
139
+ if (keycloakVersion !== "24.0.4") {
140
+ break skip_unused_resources;
141
+ }
230
142
 
231
- fs.writeFileSync(
232
- accountCssFilePath,
233
- Buffer.from(fs.readFileSync(accountCssFilePath).toString("utf8").replace("top: -34px;", "top: -34px !important;"), "utf8")
234
- );
143
+ for (const dirBasename of [
144
+ "@patternfly-v5",
145
+ "@rollup",
146
+ "rollup",
147
+ "react",
148
+ "react-dom",
149
+ "shx",
150
+ ".pnpm"
151
+ ]) {
152
+ if (
153
+ isInside({
154
+ dirPath: pathJoin(
155
+ "keycloak",
156
+ "common",
157
+ "resources",
158
+ "node_modules",
159
+ dirBasename
160
+ ),
161
+ filePath: fileRelativePath
162
+ })
163
+ ) {
164
+ return;
235
165
  }
166
+ }
236
167
 
237
- // Note, this is an optimization for reducing the size of the jar,
238
- // For this version we know exactly which resources are used.
239
- {
240
- const nodeModulesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
241
-
242
- const toKeepPrefixes = [
243
- ...["patternfly.min.css", "patternfly-additions.min.css", "patternfly-additions.min.css"].map(fileBasename =>
244
- pathJoin("patternfly", "dist", "css", fileBasename)
168
+ for (const dirBasename of ["react", "react-dom"]) {
169
+ if (
170
+ isInside({
171
+ dirPath: pathJoin(
172
+ "keycloak",
173
+ "common",
174
+ "resources",
175
+ "vendor",
176
+ dirBasename
245
177
  ),
246
- pathJoin("patternfly", "dist", "fonts")
247
- ];
248
-
249
- transformCodebase({
250
- "srcDirPath": nodeModulesDirPath,
251
- "destDirPath": nodeModulesDirPath,
252
- "transformSourceCode": ({ sourceCode, fileRelativePath }) => {
253
- if (toKeepPrefixes.find(prefix => fileRelativePath.startsWith(prefix)) === undefined) {
254
- return undefined;
255
- }
256
- return { "modifiedSourceCode": sourceCode };
257
- }
258
- });
178
+ filePath: fileRelativePath
179
+ })
180
+ ) {
181
+ return;
259
182
  }
260
183
  }
184
+
185
+ if (
186
+ isInside({
187
+ dirPath: pathJoin(
188
+ "keycloak",
189
+ "common",
190
+ "resources",
191
+ "node_modules",
192
+ "@patternfly",
193
+ "react-core"
194
+ ),
195
+ filePath: fileRelativePath
196
+ })
197
+ ) {
198
+ return;
199
+ }
261
200
  }
201
+
202
+ await writeFile({ fileRelativePath });
262
203
  }
263
204
  });
205
+
206
+ return { defaultThemeDirPath: extractedDirPath };
264
207
  }
@@ -1,16 +1,15 @@
1
1
  import { transformCodebase } from "../tools/transformCodebase";
2
2
  import { join as pathJoin } from "path";
3
- import { downloadKeycloakDefaultTheme } from "./downloadKeycloakDefaultTheme";
3
+ import {
4
+ downloadKeycloakDefaultTheme,
5
+ type BuildOptionsLike as BuildOptionsLike_downloadKeycloakDefaultTheme
6
+ } from "./downloadKeycloakDefaultTheme";
4
7
  import { resources_common, type ThemeType } from "./constants";
5
8
  import type { BuildOptions } from "./buildOptions";
6
9
  import { assert } from "tsafe/assert";
7
- import * as crypto from "crypto";
8
- import { rmSync } from "../tools/fs.rmSync";
10
+ import { existsAsync } from "../tools/fs.existsAsync";
9
11
 
10
- export type BuildOptionsLike = {
11
- cacheDirPath: string;
12
- npmWorkspaceRootDirPath: string;
13
- };
12
+ export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakDefaultTheme & {};
14
13
 
15
14
  assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
15
 
@@ -22,28 +21,33 @@ export async function downloadKeycloakStaticResources(params: {
22
21
  }) {
23
22
  const { themeType, themeDirPath, keycloakVersion, buildOptions } = params;
24
23
 
25
- const tmpDirPath = pathJoin(
26
- buildOptions.cacheDirPath,
27
- `downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
28
- );
29
-
30
- await downloadKeycloakDefaultTheme({
24
+ const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
31
25
  keycloakVersion,
32
- "destDirPath": tmpDirPath,
33
26
  buildOptions
34
27
  });
35
28
 
36
- const resourcesPath = pathJoin(themeDirPath, themeType, "resources");
29
+ const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
30
+
31
+ repatriate_base_resources: {
32
+ const srcDirPath = pathJoin(defaultThemeDirPath, "base", themeType, "resources");
33
+
34
+ if (!(await existsAsync(srcDirPath))) {
35
+ break repatriate_base_resources;
36
+ }
37
+
38
+ transformCodebase({
39
+ srcDirPath,
40
+ destDirPath: resourcesDirPath
41
+ });
42
+ }
37
43
 
38
44
  transformCodebase({
39
- "srcDirPath": pathJoin(tmpDirPath, "keycloak", themeType, "resources"),
40
- "destDirPath": resourcesPath
45
+ srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", themeType, "resources"),
46
+ destDirPath: resourcesDirPath
41
47
  });
42
48
 
43
49
  transformCodebase({
44
- "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
45
- "destDirPath": pathJoin(resourcesPath, resources_common)
50
+ srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
51
+ destDirPath: pathJoin(resourcesDirPath, resources_common)
46
52
  });
47
-
48
- rmSync(tmpDirPath, { "recursive": true });
49
53
  }
@@ -1,6 +1,8 @@
1
1
  import type { KeycloakVersionRange } from "./KeycloakVersionRange";
2
2
 
3
- export function getJarFileBasename(params: { keycloakVersionRange: KeycloakVersionRange }) {
3
+ export function getJarFileBasename(params: {
4
+ keycloakVersionRange: KeycloakVersionRange;
5
+ }) {
4
6
  const { keycloakVersionRange } = params;
5
7
 
6
8
  const jarFileBasename = `keycloak-theme-for-kc-${keycloakVersionRange}.jar`;
@@ -12,7 +12,10 @@ export function getThemeSrcDirPath(params: { reactAppRootDirPath: string }) {
12
12
 
13
13
  const srcDirPath = pathJoin(reactAppRootDirPath, "src");
14
14
 
15
- const themeSrcDirPath: string | undefined = crawl({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" })
15
+ const themeSrcDirPath: string | undefined = crawl({
16
+ dirPath: srcDirPath,
17
+ returnedPathsType: "relative to dirPath"
18
+ })
16
19
  .map(fileRelativePath => {
17
20
  for (const themeSrcDirBasename of themeSrcDirBasenames) {
18
21
  const split = fileRelativePath.split(themeSrcDirBasename);
@@ -32,7 +35,7 @@ export function getThemeSrcDirPath(params: { reactAppRootDirPath: string }) {
32
35
  if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
33
36
  continue;
34
37
  }
35
- return { "themeSrcDirPath": srcDirPath };
38
+ return { themeSrcDirPath: srcDirPath };
36
39
  }
37
40
 
38
41
  console.error(
@@ -6,29 +6,56 @@ export type MetaInfKeycloakTheme = {
6
6
  themes: { name: string; types: (ThemeType | "email")[] }[];
7
7
  };
8
8
 
9
- export function getMetaInfKeycloakThemesJsonFilePath(params: { keycloakifyBuildDirPath: string }) {
9
+ export function getMetaInfKeycloakThemesJsonFilePath(params: {
10
+ keycloakifyBuildDirPath: string;
11
+ }) {
10
12
  const { keycloakifyBuildDirPath } = params;
11
13
 
12
- return pathJoin(keycloakifyBuildDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
14
+ return pathJoin(
15
+ keycloakifyBuildDirPath === "." ? "" : keycloakifyBuildDirPath,
16
+ "src",
17
+ "main",
18
+ "resources",
19
+ "META-INF",
20
+ "keycloak-themes.json"
21
+ );
13
22
  }
14
23
 
15
- export function readMetaInfKeycloakThemes(params: { keycloakifyBuildDirPath: string }): MetaInfKeycloakTheme {
24
+ export function readMetaInfKeycloakThemes(params: {
25
+ keycloakifyBuildDirPath: string;
26
+ }): MetaInfKeycloakTheme {
16
27
  const { keycloakifyBuildDirPath } = params;
17
28
 
18
- return JSON.parse(fs.readFileSync(getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath })).toString("utf8")) as MetaInfKeycloakTheme;
29
+ return JSON.parse(
30
+ fs
31
+ .readFileSync(
32
+ getMetaInfKeycloakThemesJsonFilePath({
33
+ keycloakifyBuildDirPath
34
+ })
35
+ )
36
+ .toString("utf8")
37
+ ) as MetaInfKeycloakTheme;
19
38
  }
20
39
 
21
- export function writeMetaInfKeycloakThemes(params: { keycloakifyBuildDirPath: string; metaInfKeycloakThemes: MetaInfKeycloakTheme }) {
40
+ export function writeMetaInfKeycloakThemes(params: {
41
+ keycloakifyBuildDirPath: string;
42
+ metaInfKeycloakThemes: MetaInfKeycloakTheme;
43
+ }) {
22
44
  const { keycloakifyBuildDirPath, metaInfKeycloakThemes } = params;
23
45
 
24
- const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath });
46
+ const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonFilePath({
47
+ keycloakifyBuildDirPath
48
+ });
25
49
 
26
50
  {
27
51
  const dirPath = pathDirname(metaInfKeycloakThemesJsonPath);
28
52
  if (!fs.existsSync(dirPath)) {
29
- fs.mkdirSync(dirPath, { "recursive": true });
53
+ fs.mkdirSync(dirPath, { recursive: true });
30
54
  }
31
55
  }
32
56
 
33
- fs.writeFileSync(metaInfKeycloakThemesJsonPath, Buffer.from(JSON.stringify(metaInfKeycloakThemes, null, 2), "utf8"));
57
+ fs.writeFileSync(
58
+ metaInfKeycloakThemesJsonPath,
59
+ Buffer.from(JSON.stringify(metaInfKeycloakThemes, null, 2), "utf8")
60
+ );
34
61
  }