keycloakify 8.0.0 → 9.0.0-rc.0

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 (160) hide show
  1. package/README.md +14 -54
  2. package/account/kcContext/KcContext.js.map +1 -1
  3. package/account/kcContext/createGetKcContext.js +2 -6
  4. package/account/kcContext/createGetKcContext.js.map +1 -1
  5. package/account/kcContext/kcContextMocks.js +4 -3
  6. package/account/kcContext/kcContextMocks.js.map +1 -1
  7. package/bin/constants.d.ts +7 -0
  8. package/bin/constants.js +10 -0
  9. package/bin/constants.js.map +1 -0
  10. package/bin/copy-keycloak-resources-to-public.js +34 -22
  11. package/bin/copy-keycloak-resources-to-public.js.map +1 -1
  12. package/bin/download-builtin-keycloak-theme.d.ts +4 -1
  13. package/bin/download-builtin-keycloak-theme.js +8 -6
  14. package/bin/download-builtin-keycloak-theme.js.map +1 -1
  15. package/bin/eject-keycloak-page.js +5 -3
  16. package/bin/eject-keycloak-page.js.map +1 -1
  17. package/bin/getSrcDirPath.d.ts +1 -1
  18. package/bin/getSrcDirPath.js +4 -4
  19. package/bin/getSrcDirPath.js.map +1 -1
  20. package/bin/initialize-email-theme.js +9 -9
  21. package/bin/initialize-email-theme.js.map +1 -1
  22. package/bin/keycloakify/BuildOptions.d.ts +8 -6
  23. package/bin/keycloakify/BuildOptions.js +63 -71
  24. package/bin/keycloakify/BuildOptions.js.map +1 -1
  25. package/bin/keycloakify/generateFtl/generateFtl.d.ts +2 -3
  26. package/bin/keycloakify/generateFtl/generateFtl.js +3 -4
  27. package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
  28. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountPages.java +33 -0
  29. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProvider.java +76 -0
  30. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProviderFactory.java +25 -0
  31. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountSpi.java +50 -0
  32. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProvider.java +424 -0
  33. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProviderFactory.java +51 -0
  34. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/Templates.java +51 -0
  35. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountBean.java +91 -0
  36. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountFederatedIdentityBean.java +157 -0
  37. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ApplicationsBean.java +258 -0
  38. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AuthorizationBean.java +515 -0
  39. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/FeaturesBean.java +56 -0
  40. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/LogBean.java +95 -0
  41. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/PasswordBean.java +34 -0
  42. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/RealmBean.java +75 -0
  43. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ReferrerBean.java +38 -0
  44. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/SessionsBean.java +93 -0
  45. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/TotpBean.java +125 -0
  46. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/UrlBean.java +121 -0
  47. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/AccountUrls.java +115 -0
  48. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormService.java +1320 -0
  49. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormServiceFactory.java +64 -0
  50. package/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.d.ts +7 -0
  51. package/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.js +194 -0
  52. package/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.js.map +1 -0
  53. package/bin/keycloakify/{generateJavaStackFiles.d.ts → generateJavaStackFiles/generateJavaStackFiles.d.ts} +6 -6
  54. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js +276 -0
  55. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js.map +1 -0
  56. package/bin/keycloakify/generateJavaStackFiles/index.d.ts +1 -0
  57. package/bin/keycloakify/generateJavaStackFiles/index.js +18 -0
  58. package/bin/keycloakify/generateJavaStackFiles/index.js.map +1 -0
  59. package/bin/keycloakify/generateStartKeycloakTestingContainer.d.ts +1 -3
  60. package/bin/keycloakify/generateStartKeycloakTestingContainer.js +15 -6
  61. package/bin/keycloakify/generateStartKeycloakTestingContainer.js.map +1 -1
  62. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.d.ts +5 -2
  63. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js +11 -8
  64. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js.map +1 -1
  65. package/bin/keycloakify/generateTheme/generateMessageProperties.d.ts +1 -1
  66. package/bin/keycloakify/generateTheme/generateTheme.d.ts +6 -5
  67. package/bin/keycloakify/generateTheme/generateTheme.js +59 -49
  68. package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
  69. package/bin/keycloakify/generateTheme/readExtraPageNames.d.ts +1 -1
  70. package/bin/keycloakify/generateTheme/readExtraPageNames.js.map +1 -1
  71. package/bin/keycloakify/generateTheme/readFieldNameUsage.d.ts +1 -1
  72. package/bin/keycloakify/generateTheme/readStaticResourcesUsage.d.ts +1 -1
  73. package/bin/keycloakify/keycloakify.js +49 -90
  74. package/bin/keycloakify/keycloakify.js.map +1 -1
  75. package/bin/keycloakify/parsedPackageJson.d.ts +29 -31
  76. package/bin/keycloakify/parsedPackageJson.js +7 -8
  77. package/bin/keycloakify/parsedPackageJson.js.map +1 -1
  78. package/bin/promptKeycloakVersion.js +1 -1
  79. package/bin/promptKeycloakVersion.js.map +1 -1
  80. package/bin/tools/downloadAndUnzip.d.ts +1 -1
  81. package/bin/tools/downloadAndUnzip.js +24 -26
  82. package/bin/tools/downloadAndUnzip.js.map +1 -1
  83. package/bin/tools/getAbsoluteAndInOsFormatPath.d.ts +4 -0
  84. package/bin/tools/getAbsoluteAndInOsFormatPath.js +15 -0
  85. package/bin/tools/getAbsoluteAndInOsFormatPath.js.map +1 -0
  86. package/bin/tools/pathJoin.js +1 -1
  87. package/bin/tools/pathJoin.js.map +1 -1
  88. package/login/kcContext/KcContext.js.map +1 -1
  89. package/login/kcContext/createGetKcContext.js +2 -6
  90. package/login/kcContext/createGetKcContext.js.map +1 -1
  91. package/login/kcContext/kcContextMocks.js +5 -4
  92. package/login/kcContext/kcContextMocks.js.map +1 -1
  93. package/package.json +92 -21
  94. package/src/account/kcContext/KcContext.ts +2 -1
  95. package/src/account/kcContext/createGetKcContext.ts +2 -7
  96. package/src/account/kcContext/kcContextMocks.ts +5 -3
  97. package/src/bin/constants.ts +9 -0
  98. package/src/bin/copy-keycloak-resources-to-public.ts +20 -19
  99. package/src/bin/download-builtin-keycloak-theme.ts +14 -6
  100. package/src/bin/eject-keycloak-page.ts +5 -9
  101. package/src/bin/getSrcDirPath.ts +4 -4
  102. package/src/bin/initialize-email-theme.ts +7 -7
  103. package/src/bin/keycloakify/BuildOptions.ts +78 -59
  104. package/src/bin/keycloakify/generateFtl/generateFtl.ts +4 -7
  105. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountPages.java +33 -0
  106. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProvider.java +76 -0
  107. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProviderFactory.java +25 -0
  108. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountSpi.java +50 -0
  109. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProvider.java +424 -0
  110. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProviderFactory.java +51 -0
  111. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/Templates.java +51 -0
  112. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountBean.java +91 -0
  113. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountFederatedIdentityBean.java +157 -0
  114. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ApplicationsBean.java +258 -0
  115. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AuthorizationBean.java +515 -0
  116. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/FeaturesBean.java +56 -0
  117. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/LogBean.java +95 -0
  118. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/PasswordBean.java +34 -0
  119. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/RealmBean.java +75 -0
  120. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ReferrerBean.java +38 -0
  121. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/SessionsBean.java +93 -0
  122. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/TotpBean.java +125 -0
  123. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/UrlBean.java +121 -0
  124. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/AccountUrls.java +115 -0
  125. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormService.java +1320 -0
  126. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormServiceFactory.java +64 -0
  127. package/src/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.ts +92 -0
  128. package/src/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.ts +211 -0
  129. package/src/bin/keycloakify/generateJavaStackFiles/index.ts +1 -0
  130. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +21 -22
  131. package/src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts +19 -15
  132. package/src/bin/keycloakify/generateTheme/generateMessageProperties.ts +1 -1
  133. package/src/bin/keycloakify/generateTheme/generateTheme.ts +78 -72
  134. package/src/bin/keycloakify/generateTheme/readExtraPageNames.ts +2 -1
  135. package/src/bin/keycloakify/generateTheme/readFieldNameUsage.ts +1 -1
  136. package/src/bin/keycloakify/generateTheme/readStaticResourcesUsage.ts +1 -1
  137. package/src/bin/keycloakify/keycloakify.ts +21 -44
  138. package/src/bin/keycloakify/parsedPackageJson.ts +11 -13
  139. package/src/bin/promptKeycloakVersion.ts +1 -1
  140. package/src/bin/tools/downloadAndUnzip.ts +6 -7
  141. package/src/bin/tools/getAbsoluteAndInOsFormatPath.ts +15 -0
  142. package/src/bin/tools/pathJoin.ts +1 -1
  143. package/src/login/kcContext/KcContext.ts +2 -1
  144. package/src/login/kcContext/createGetKcContext.ts +2 -7
  145. package/src/login/kcContext/kcContextMocks.ts +7 -5
  146. package/bin/keycloakify/generateJavaStackFiles.js +0 -103
  147. package/bin/keycloakify/generateJavaStackFiles.js.map +0 -1
  148. package/bin/mockTestingResourcesPath.d.ts +0 -3
  149. package/bin/mockTestingResourcesPath.js +0 -8
  150. package/bin/mockTestingResourcesPath.js.map +0 -1
  151. package/bin/tools/jar.d.ts +0 -33
  152. package/bin/tools/jar.js +0 -241
  153. package/bin/tools/jar.js.map +0 -1
  154. package/bin/tools/walk.d.ts +0 -8
  155. package/bin/tools/walk.js +0 -125
  156. package/bin/tools/walk.js.map +0 -1
  157. package/src/bin/keycloakify/generateJavaStackFiles.ts +0 -84
  158. package/src/bin/mockTestingResourcesPath.ts +0 -5
  159. package/src/bin/tools/jar.ts +0 -99
  160. package/src/bin/tools/walk.ts +0 -19
@@ -0,0 +1,64 @@
1
+ package org.keycloak.services.resources.account;
2
+
3
+ import com.google.auto.service.AutoService;
4
+ import com.google.common.collect.ImmutableMap;
5
+ import com.google.common.collect.ImmutableSet;
6
+ import java.util.Map;
7
+ import lombok.extern.jbosslog.JBossLog;
8
+ import org.keycloak.Config.Scope;
9
+ import org.keycloak.events.EventBuilder;
10
+ import org.keycloak.models.ClientModel;
11
+ import org.keycloak.models.KeycloakSession;
12
+ import org.keycloak.models.KeycloakSessionFactory;
13
+ import org.keycloak.models.ProtocolMapperModel;
14
+ import org.keycloak.models.RealmModel;
15
+ import org.keycloak.provider.ProviderEvent;
16
+ import org.keycloak.services.resource.AccountResourceProvider;
17
+ import org.keycloak.services.resource.AccountResourceProviderFactory;
18
+ import jakarta.ws.rs.NotFoundException;
19
+ import org.keycloak.models.Constants;
20
+
21
+ @JBossLog
22
+ @AutoService(AccountResourceProviderFactory.class)
23
+ public class AccountFormServiceFactory implements AccountResourceProviderFactory {
24
+
25
+ public static final String ID = "account-v1";
26
+
27
+ @Override
28
+ public String getId() {
29
+ return ID;
30
+ }
31
+
32
+ private ClientModel getAccountManagementClient(RealmModel realm) {
33
+ ClientModel client = realm.getClientByClientId(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
34
+ if (client == null || !client.isEnabled()) {
35
+ log.debug("account management not enabled");
36
+ throw new NotFoundException("account management not enabled");
37
+ }
38
+ return client;
39
+ }
40
+
41
+ @Override
42
+ public AccountResourceProvider create(KeycloakSession session) {
43
+ log.info("create");
44
+ RealmModel realm = session.getContext().getRealm();
45
+ ClientModel client = getAccountManagementClient(realm);
46
+ EventBuilder event = new EventBuilder​(realm, session, session.getContext().getConnection());
47
+ return new AccountFormService(session, client, event);
48
+ }
49
+
50
+ @Override
51
+ public void init(Scope config) {
52
+ log.info("init");
53
+ }
54
+
55
+ @Override
56
+ public void postInit(KeycloakSessionFactory factory) {
57
+ log.info("postInit");
58
+ }
59
+
60
+ @Override
61
+ public void close() {
62
+ log.info("close");
63
+ }
64
+ }
@@ -0,0 +1,92 @@
1
+ import * as fs from "fs";
2
+ import { join as pathJoin, dirname as pathDirname } from "path";
3
+ import { assert } from "tsafe/assert";
4
+ import { Reflect } from "tsafe/Reflect";
5
+ import type { BuildOptions } from "../BuildOptions";
6
+ import { resources_common, lastKeycloakVersionWithAccountV1, accountV1 } from "../../constants";
7
+ import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
8
+ import { transformCodebase } from "../../tools/transformCodebase";
9
+
10
+ export type BuildOptionsLike = {
11
+ keycloakifyBuildDirPath: string;
12
+ cacheDirPath: string;
13
+ };
14
+
15
+ {
16
+ const buildOptions = Reflect<BuildOptions>();
17
+
18
+ assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
19
+ }
20
+
21
+ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike }) {
22
+ const { buildOptions } = params;
23
+
24
+ const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "..", "tmp_yxdE2_builtin_keycloak_theme");
25
+
26
+ await downloadBuiltinKeycloakTheme({
27
+ "destDirPath": builtinKeycloakThemeTmpDirPath,
28
+ "keycloakVersion": lastKeycloakVersionWithAccountV1,
29
+ buildOptions
30
+ });
31
+
32
+ const accountV1DirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme", accountV1, "account");
33
+
34
+ transformCodebase({
35
+ "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "base", "account"),
36
+ "destDirPath": accountV1DirPath
37
+ });
38
+
39
+ const commonResourceFilePaths = [
40
+ "node_modules/patternfly/dist/css/patternfly.min.css",
41
+ "node_modules/patternfly/dist/css/patternfly-additions.min.css"
42
+ ];
43
+
44
+ for (const relativeFilePath of commonResourceFilePaths.map(path => pathJoin(...path.split("/")))) {
45
+ const destFilePath = pathJoin(accountV1DirPath, "resources", resources_common, relativeFilePath);
46
+
47
+ fs.mkdirSync(pathDirname(destFilePath), { "recursive": true });
48
+
49
+ fs.cpSync(pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "common", "resources", relativeFilePath), destFilePath);
50
+ }
51
+
52
+ const resourceFilePaths = ["css/account.css"];
53
+
54
+ for (const relativeFilePath of resourceFilePaths.map(path => pathJoin(...path.split("/")))) {
55
+ const destFilePath = pathJoin(accountV1DirPath, "resources", relativeFilePath);
56
+
57
+ fs.mkdirSync(pathDirname(destFilePath), { "recursive": true });
58
+
59
+ fs.cpSync(pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "account", "resources", relativeFilePath), destFilePath);
60
+ }
61
+
62
+ fs.rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true });
63
+
64
+ fs.writeFileSync(
65
+ pathJoin(accountV1DirPath, "theme.properties"),
66
+ Buffer.from(
67
+ [
68
+ "accountResourceProvider=org.keycloak.services.resources.account.AccountFormService",
69
+ "",
70
+ "locales=ar,ca,cs,da,de,en,es,fr,fi,hu,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN",
71
+ "",
72
+ "styles=" + [...resourceFilePaths, ...commonResourceFilePaths.map(path => `resources_common/${path}`)].join(" "),
73
+ "",
74
+ "##### css classes for form buttons",
75
+ "# main class used for all buttons",
76
+ "kcButtonClass=btn",
77
+ "# classes defining priority of the button - primary or default (there is typically only one priority button for the form)",
78
+ "kcButtonPrimaryClass=btn-primary",
79
+ "kcButtonDefaultClass=btn-default",
80
+ "# classes defining size of the button",
81
+ "kcButtonLargeClass=btn-lg",
82
+ ""
83
+ ].join("\n"),
84
+ "utf8"
85
+ )
86
+ );
87
+
88
+ transformCodebase({
89
+ "srcDirPath": pathJoin(__dirname, "account-v1-java"),
90
+ "destDirPath": pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "java", "org", "keycloak")
91
+ });
92
+ }
@@ -0,0 +1,211 @@
1
+ import * as fs from "fs";
2
+ import { join as pathJoin, dirname as pathDirname } from "path";
3
+ import { assert } from "tsafe/assert";
4
+ import { Reflect } from "tsafe/Reflect";
5
+ import type { BuildOptions } from "../BuildOptions";
6
+ import { type ThemeType, retrocompatPostfix, accountV1 } from "../../constants";
7
+ import { bringInAccountV1 } from "./bringInAccountV1";
8
+
9
+ export type BuildOptionsLike = {
10
+ groupId: string;
11
+ artifactId: string;
12
+ themeVersion: string;
13
+ cacheDirPath: string;
14
+ keycloakifyBuildDirPath: string;
15
+ themeNames: string[];
16
+ };
17
+
18
+ {
19
+ const buildOptions = Reflect<BuildOptions>();
20
+
21
+ assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
22
+ }
23
+
24
+ export async function generateJavaStackFiles(params: {
25
+ implementedThemeTypes: Record<ThemeType | "email", boolean>;
26
+ buildOptions: BuildOptionsLike;
27
+ }): Promise<{
28
+ jarFilePath: string;
29
+ }> {
30
+ const { implementedThemeTypes, buildOptions } = params;
31
+
32
+ {
33
+ const { pomFileCode } = (function generatePomFileCode(): {
34
+ pomFileCode: string;
35
+ } {
36
+ const pomFileCode = [
37
+ `<?xml version="1.0"?>`,
38
+ `<project xmlns="http://maven.apache.org/POM/4.0.0"`,
39
+ ` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`,
40
+ ` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
41
+ ` <modelVersion>4.0.0</modelVersion>`,
42
+ ` <groupId>${buildOptions.groupId}</groupId>`,
43
+ ` <artifactId>${buildOptions.artifactId}</artifactId>`,
44
+ ` <version>${buildOptions.themeVersion}</version>`,
45
+ ` <name>${buildOptions.artifactId}</name>`,
46
+ ` <description />`,
47
+ ` <packaging>jar</packaging>`,
48
+ ` <properties>`,
49
+ ` <java.version>17</java.version>`,
50
+ ` <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>`,
51
+ ` <keycloak.version>999.0.0-SNAPSHOT</keycloak.version>`,
52
+ ` <guava.version>32.0.0-jre</guava.version>`,
53
+ ` <lombok.version>1.18.28</lombok.version>`,
54
+ ` <auto-service.version>1.1.1</auto-service.version>`,
55
+ ` </properties>`,
56
+ ` <build>`,
57
+ ` <plugins>`,
58
+ ` <plugin>`,
59
+ ` <artifactId>maven-compiler-plugin</artifactId>`,
60
+ ` <version>3.11.0</version>`,
61
+ ` <configuration>`,
62
+ ` <source>\${java.version}</source>`,
63
+ ` <target>\${java.version}</target>`,
64
+ ` <compilerArgument>-Xlint:unchecked</compilerArgument>`,
65
+ ` <compilerArgument>-Xlint:deprecation</compilerArgument>`,
66
+ ` <useIncrementalCompilation>false</useIncrementalCompilation>`,
67
+ ` <annotationProcessorPaths>`,
68
+ ` <path>`,
69
+ ` <groupId>com.google.auto.service</groupId>`,
70
+ ` <artifactId>auto-service</artifactId>`,
71
+ ` <version>\${auto-service.version}</version>`,
72
+ ` </path>`,
73
+ ` <path>`,
74
+ ` <groupId>org.projectlombok</groupId>`,
75
+ ` <artifactId>lombok</artifactId>`,
76
+ ` <version>\${lombok.version}</version>`,
77
+ ` </path>`,
78
+ ` </annotationProcessorPaths>`,
79
+ ` </configuration>`,
80
+ ` </plugin>`,
81
+ ` <plugin>`,
82
+ ` <groupId>org.apache.maven.plugins</groupId>`,
83
+ ` <artifactId>maven-jar-plugin</artifactId>`,
84
+ ` <version>3.2.0</version>`,
85
+ ` <configuration>`,
86
+ ` <archive>`,
87
+ ` <manifestEntries>`,
88
+ ` <Dependencies>`,
89
+ ` <![CDATA[org.keycloak.keycloak-common,org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi,org.keycloak.keycloak-server-spi-private,org.keycloak.keycloak-services,com.google.guava]]>`,
90
+ ` </Dependencies>`,
91
+ ` </manifestEntries>`,
92
+ ` </archive>`,
93
+ ` </configuration>`,
94
+ ` </plugin>`,
95
+ ` <plugin>`,
96
+ ` <groupId>com.spotify.fmt</groupId>`,
97
+ ` <artifactId>fmt-maven-plugin</artifactId>`,
98
+ ` <version>2.20</version>`,
99
+ ` </plugin>`,
100
+ ` </plugins>`,
101
+ ` </build>`,
102
+ ` <dependencies>`,
103
+ ` <dependency>`,
104
+ ` <groupId>org.projectlombok</groupId>`,
105
+ ` <artifactId>lombok</artifactId>`,
106
+ ` <version>\${lombok.version}</version>`,
107
+ ` <scope>provided</scope>`,
108
+ ` </dependency>`,
109
+ ` <dependency>`,
110
+ ` <groupId>com.google.auto.service</groupId>`,
111
+ ` <artifactId>auto-service</artifactId>`,
112
+ ` <version>\${auto-service.version}</version>`,
113
+ ` <scope>provided</scope>`,
114
+ ` </dependency>`,
115
+ ` <dependency>`,
116
+ ` <groupId>org.keycloak</groupId>`,
117
+ ` <artifactId>keycloak-server-spi</artifactId>`,
118
+ ` <version>\${keycloak.version}</version>`,
119
+ ` <scope>provided</scope>`,
120
+ ` </dependency>`,
121
+ ` <dependency>`,
122
+ ` <groupId>org.keycloak</groupId>`,
123
+ ` <artifactId>keycloak-server-spi-private</artifactId>`,
124
+ ` <version>\${keycloak.version}</version>`,
125
+ ` <scope>provided</scope>`,
126
+ ` </dependency>`,
127
+ ` <dependency>`,
128
+ ` <groupId>org.keycloak</groupId>`,
129
+ ` <artifactId>keycloak-services</artifactId>`,
130
+ ` <version>\${keycloak.version}</version>`,
131
+ ` <scope>provided</scope>`,
132
+ ` </dependency>`,
133
+ ` <dependency>`,
134
+ ` <groupId>jakarta.ws.rs</groupId>`,
135
+ ` <artifactId>jakarta.ws.rs-api</artifactId>`,
136
+ ` <version>3.1.0</version>`,
137
+ ` <scope>provided</scope>`,
138
+ ` </dependency>`,
139
+ ` <dependency>`,
140
+ ` <groupId>com.google.guava</groupId>`,
141
+ ` <artifactId>guava</artifactId>`,
142
+ ` <version>\${guava.version}</version>`,
143
+ ` <scope>provided</scope>`,
144
+ ` </dependency>`,
145
+ ` </dependencies>`,
146
+ `</project>`
147
+ ].join("\n");
148
+
149
+ return { pomFileCode };
150
+ })();
151
+
152
+ fs.writeFileSync(pathJoin(buildOptions.keycloakifyBuildDirPath, "pom.xml"), Buffer.from(pomFileCode, "utf8"));
153
+ }
154
+
155
+ if (implementedThemeTypes.account) {
156
+ await bringInAccountV1({ buildOptions });
157
+ }
158
+
159
+ {
160
+ const themeManifestFilePath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
161
+
162
+ try {
163
+ fs.mkdirSync(pathDirname(themeManifestFilePath));
164
+ } catch {}
165
+
166
+ fs.writeFileSync(
167
+ themeManifestFilePath,
168
+ Buffer.from(
169
+ JSON.stringify(
170
+ {
171
+ "themes": [
172
+ ...(!implementedThemeTypes.account
173
+ ? []
174
+ : [
175
+ {
176
+ "name": accountV1,
177
+ "types": ["account"]
178
+ }
179
+ ]),
180
+ ...buildOptions.themeNames
181
+ .map(themeName => [
182
+ {
183
+ "name": themeName,
184
+ "types": Object.entries(implementedThemeTypes)
185
+ .filter(([, isImplemented]) => isImplemented)
186
+ .map(([themeType]) => themeType)
187
+ },
188
+ ...(!implementedThemeTypes.account
189
+ ? []
190
+ : [
191
+ {
192
+ "name": `${themeName}${retrocompatPostfix}`,
193
+ "types": ["account"]
194
+ }
195
+ ])
196
+ ])
197
+ .flat()
198
+ ]
199
+ },
200
+ null,
201
+ 2
202
+ ),
203
+ "utf8"
204
+ )
205
+ );
206
+ }
207
+
208
+ return {
209
+ "jarFilePath": pathJoin(buildOptions.keycloakifyBuildDirPath, "target", `${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`)
210
+ };
211
+ }
@@ -0,0 +1 @@
1
+ export * from "./generateJavaStackFiles";
@@ -1,53 +1,52 @@
1
1
  import * as fs from "fs";
2
2
  import { join as pathJoin } from "path";
3
3
  import { assert } from "tsafe/assert";
4
+ import { Reflect } from "tsafe/Reflect";
4
5
  import type { BuildOptions } from "./BuildOptions";
5
6
 
6
7
  export type BuildOptionsLike = {
7
- themeName: string;
8
- extraThemeNames: string[];
8
+ keycloakifyBuildDirPath: string;
9
9
  };
10
10
 
11
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
11
+ {
12
+ const buildOptions = Reflect<BuildOptions>();
13
+
14
+ assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
15
+ }
12
16
 
13
17
  generateStartKeycloakTestingContainer.basename = "start_keycloak_testing_container.sh";
14
18
 
15
19
  const containerName = "keycloak-testing-container";
16
20
 
17
21
  /** Files for being able to run a hot reload keycloak container */
18
- export function generateStartKeycloakTestingContainer(params: {
19
- keycloakVersion: string;
20
- keycloakThemeBuildingDirPath: string;
21
- buildOptions: BuildOptionsLike;
22
- }) {
23
- const {
24
- keycloakThemeBuildingDirPath,
25
- keycloakVersion,
26
- buildOptions: { themeName, extraThemeNames }
27
- } = params;
22
+ export function generateStartKeycloakTestingContainer(params: { keycloakVersion: string; buildOptions: BuildOptionsLike }) {
23
+ const { keycloakVersion, buildOptions } = params;
24
+
25
+ const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme");
26
+ const themeDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, themeRelativeDirPath);
28
27
 
29
28
  fs.writeFileSync(
30
- pathJoin(keycloakThemeBuildingDirPath, generateStartKeycloakTestingContainer.basename),
29
+ pathJoin(buildOptions.keycloakifyBuildDirPath, generateStartKeycloakTestingContainer.basename),
31
30
  Buffer.from(
32
31
  [
33
32
  "#!/usr/bin/env bash",
34
33
  "",
35
34
  `docker rm ${containerName} || true`,
36
35
  "",
37
- `cd "${keycloakThemeBuildingDirPath.replace(/\\/g, "/")}"`,
36
+ `cd "${buildOptions.keycloakifyBuildDirPath}"`,
38
37
  "",
39
38
  "docker run \\",
40
39
  " -p 8080:8080 \\",
41
40
  ` --name ${containerName} \\`,
42
41
  " -e KEYCLOAK_ADMIN=admin \\",
43
42
  " -e KEYCLOAK_ADMIN_PASSWORD=admin \\",
44
- ...[themeName, ...extraThemeNames].map(
45
- themeName =>
46
- ` -v "${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName).replace(
47
- /\\/g,
48
- "/"
49
- )}":"/opt/keycloak/themes/${themeName}":rw \\`
50
- ),
43
+ ...fs
44
+ .readdirSync(themeDirPath)
45
+ .filter(name => fs.lstatSync(pathJoin(themeDirPath, name)).isDirectory())
46
+ .map(
47
+ themeName =>
48
+ ` -v "${pathJoin(".", themeRelativeDirPath, themeName).replace(/\\/g, "/")}":"/opt/keycloak/themes/${themeName}":rw \\`
49
+ ),
51
50
  ` -it quay.io/keycloak/keycloak:${keycloakVersion} \\`,
52
51
  ` start-dev --features=declarative-user-profile`,
53
52
  ""
@@ -1,45 +1,49 @@
1
1
  import { transformCodebase } from "../../tools/transformCodebase";
2
2
  import * as fs from "fs";
3
- import { join as pathJoin, relative as pathRelative } from "path";
4
- import type { ThemeType } from "../generateFtl";
3
+ import { join as pathJoin } from "path";
5
4
  import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
6
- import {
7
- resourcesCommonDirPathRelativeToPublicDir,
8
- resourcesDirPathRelativeToPublicDir,
9
- basenameOfKeycloakDirInPublicDir
10
- } from "../../mockTestingResourcesPath";
5
+ import { resources_common, type ThemeType } from "../../constants";
6
+ import { BuildOptions } from "../BuildOptions";
7
+ import { assert } from "tsafe/assert";
11
8
  import * as crypto from "crypto";
12
9
 
10
+ export type BuildOptionsLike = {
11
+ cacheDirPath: string;
12
+ };
13
+
14
+ assert<BuildOptions extends BuildOptionsLike ? true : false>();
15
+
13
16
  export async function downloadKeycloakStaticResources(
14
17
  // prettier-ignore
15
18
  params: {
16
- projectDirPath: string;
17
19
  themeType: ThemeType;
18
20
  themeDirPath: string;
19
21
  keycloakVersion: string;
20
22
  usedResources: {
21
23
  resourcesCommonFilePaths: string[];
22
24
  resourcesFilePaths: string[];
23
- } | undefined
25
+ } | undefined;
26
+ buildOptions: BuildOptionsLike;
24
27
  }
25
28
  ) {
26
- const { projectDirPath, themeType, themeDirPath, keycloakVersion, usedResources } = params;
29
+ const { themeType, themeDirPath, keycloakVersion, usedResources, buildOptions } = params;
27
30
 
28
31
  const tmpDirPath = pathJoin(
29
32
  themeDirPath,
30
- "..",
31
33
  `tmp_suLeKsxId_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
32
34
  );
33
35
 
34
36
  await downloadBuiltinKeycloakTheme({
35
- projectDirPath,
36
37
  keycloakVersion,
37
- "destDirPath": tmpDirPath
38
+ "destDirPath": tmpDirPath,
39
+ buildOptions
38
40
  });
39
41
 
42
+ const resourcesPath = pathJoin(themeDirPath, themeType, "resources");
43
+
40
44
  transformCodebase({
41
45
  "srcDirPath": pathJoin(tmpDirPath, "keycloak", themeType, "resources"),
42
- "destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesDirPathRelativeToPublicDir)),
46
+ "destDirPath": resourcesPath,
43
47
  "transformSourceCode":
44
48
  usedResources === undefined
45
49
  ? undefined
@@ -54,7 +58,7 @@ export async function downloadKeycloakStaticResources(
54
58
 
55
59
  transformCodebase({
56
60
  "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
57
- "destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesCommonDirPathRelativeToPublicDir)),
61
+ "destDirPath": pathJoin(resourcesPath, resources_common),
58
62
  "transformSourceCode":
59
63
  usedResources === undefined
60
64
  ? undefined
@@ -1,4 +1,4 @@
1
- import type { ThemeType } from "../generateFtl";
1
+ import type { ThemeType } from "../../constants";
2
2
  import { crawl } from "../../tools/crawl";
3
3
  import { join as pathJoin } from "path";
4
4
  import { readFileSync } from "fs";