keycloakify 7.15.7 → 7.16.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 (64) hide show
  1. package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +1 -1
  2. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountPages.java +33 -0
  3. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProvider.java +76 -0
  4. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProviderFactory.java +25 -0
  5. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountSpi.java +50 -0
  6. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProvider.java +424 -0
  7. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProviderFactory.java +51 -0
  8. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/Templates.java +51 -0
  9. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountBean.java +91 -0
  10. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountFederatedIdentityBean.java +157 -0
  11. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ApplicationsBean.java +258 -0
  12. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AuthorizationBean.java +515 -0
  13. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/FeaturesBean.java +56 -0
  14. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/LogBean.java +95 -0
  15. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/PasswordBean.java +34 -0
  16. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/RealmBean.java +75 -0
  17. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ReferrerBean.java +38 -0
  18. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/SessionsBean.java +93 -0
  19. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/TotpBean.java +125 -0
  20. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/UrlBean.java +121 -0
  21. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/AccountUrls.java +115 -0
  22. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormService.java +1320 -0
  23. package/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormServiceFactory.java +64 -0
  24. package/bin/keycloakify/{generateJavaStackFiles.d.ts → generateJavaStackFiles/generateJavaStackFiles.d.ts} +4 -3
  25. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js +298 -0
  26. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js.map +1 -0
  27. package/bin/keycloakify/generateJavaStackFiles/index.d.ts +1 -0
  28. package/bin/keycloakify/generateJavaStackFiles/index.js +18 -0
  29. package/bin/keycloakify/generateJavaStackFiles/index.js.map +1 -0
  30. package/bin/keycloakify/generateTheme/generateTheme.js +11 -1
  31. package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
  32. package/bin/keycloakify/keycloakify.js +17 -16
  33. package/bin/keycloakify/keycloakify.js.map +1 -1
  34. package/package.json +77 -6
  35. package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +1 -1
  36. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountPages.java +33 -0
  37. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProvider.java +76 -0
  38. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountProviderFactory.java +25 -0
  39. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/AccountSpi.java +50 -0
  40. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProvider.java +424 -0
  41. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/FreeMarkerAccountProviderFactory.java +51 -0
  42. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/Templates.java +51 -0
  43. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountBean.java +91 -0
  44. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AccountFederatedIdentityBean.java +157 -0
  45. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ApplicationsBean.java +258 -0
  46. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/AuthorizationBean.java +515 -0
  47. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/FeaturesBean.java +56 -0
  48. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/LogBean.java +95 -0
  49. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/PasswordBean.java +34 -0
  50. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/RealmBean.java +75 -0
  51. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/ReferrerBean.java +38 -0
  52. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/SessionsBean.java +93 -0
  53. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/TotpBean.java +125 -0
  54. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/forms/account/freemarker/model/UrlBean.java +121 -0
  55. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/AccountUrls.java +115 -0
  56. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormService.java +1320 -0
  57. package/src/bin/keycloakify/generateJavaStackFiles/account-v1-java/services/resources/account/AccountFormServiceFactory.java +64 -0
  58. package/src/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.ts +249 -0
  59. package/src/bin/keycloakify/generateJavaStackFiles/index.ts +1 -0
  60. package/src/bin/keycloakify/generateTheme/generateTheme.ts +15 -1
  61. package/src/bin/keycloakify/keycloakify.ts +1 -1
  62. package/bin/keycloakify/generateJavaStackFiles.js +0 -107
  63. package/bin/keycloakify/generateJavaStackFiles.js.map +0 -1
  64. package/src/bin/keycloakify/generateJavaStackFiles.ts +0 -89
@@ -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,249 @@
1
+ import * as fs from "fs";
2
+ import { join as pathJoin, dirname as pathDirname, basename as pathBasename } from "path";
3
+ import { assert } from "tsafe/assert";
4
+ import { Reflect } from "tsafe/Reflect";
5
+ import type { BuildOptions } from "../BuildOptions";
6
+ import type { ThemeType } from "../generateFtl";
7
+ import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
8
+ import { transformCodebase } from "../../tools/transformCodebase";
9
+
10
+ export type BuildOptionsLike = {
11
+ themeName: string;
12
+ extraThemeNames: string[];
13
+ groupId: string;
14
+ artifactId: string;
15
+ themeVersion: string;
16
+ };
17
+
18
+ {
19
+ const buildOptions = Reflect<BuildOptions>();
20
+
21
+ assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
22
+ }
23
+
24
+ export const accountV1Keycloak = "account-v1-keycloak";
25
+
26
+ export async function generateJavaStackFiles(params: {
27
+ keycloakThemeBuildingDirPath: string;
28
+ implementedThemeTypes: Record<ThemeType | "email", boolean>;
29
+ buildOptions: BuildOptionsLike;
30
+ }): Promise<{
31
+ jarFilePath: string;
32
+ }> {
33
+ const {
34
+ buildOptions: { groupId, themeName, extraThemeNames, themeVersion, artifactId },
35
+ keycloakThemeBuildingDirPath,
36
+ implementedThemeTypes
37
+ } = params;
38
+
39
+ {
40
+ const { pomFileCode } = (function generatePomFileCode(): {
41
+ pomFileCode: string;
42
+ } {
43
+ const pomFileCode = [
44
+ `<?xml version="1.0"?>`,
45
+ `<project xmlns="http://maven.apache.org/POM/4.0.0"`,
46
+ ` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`,
47
+ ` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
48
+ ` <modelVersion>4.0.0</modelVersion>`,
49
+ ` <groupId>${groupId}</groupId>`,
50
+ ` <artifactId>${artifactId}</artifactId>`,
51
+ ` <version>${themeVersion}</version>`,
52
+ ` <name>${artifactId}</name>`,
53
+ ` <description />`,
54
+ ` <packaging>jar</packaging>`,
55
+ ` <properties>`,
56
+ ` <java.version>17</java.version>`,
57
+ ` <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>`,
58
+ ` <keycloak.version>999.0.0-SNAPSHOT</keycloak.version>`,
59
+ ` <guava.version>32.0.0-jre</guava.version>`,
60
+ ` <lombok.version>1.18.28</lombok.version>`,
61
+ ` <auto-service.version>1.1.1</auto-service.version>`,
62
+ ` </properties>`,
63
+ ` <build>`,
64
+ ` <plugins>`,
65
+ ` <plugin>`,
66
+ ` <artifactId>maven-compiler-plugin</artifactId>`,
67
+ ` <version>3.11.0</version>`,
68
+ ` <configuration>`,
69
+ ` <source>\${java.version}</source>`,
70
+ ` <target>\${java.version}</target>`,
71
+ ` <compilerArgument>-Xlint:unchecked</compilerArgument>`,
72
+ ` <compilerArgument>-Xlint:deprecation</compilerArgument>`,
73
+ ` <useIncrementalCompilation>false</useIncrementalCompilation>`,
74
+ ` <annotationProcessorPaths>`,
75
+ ` <path>`,
76
+ ` <groupId>com.google.auto.service</groupId>`,
77
+ ` <artifactId>auto-service</artifactId>`,
78
+ ` <version>\${auto-service.version}</version>`,
79
+ ` </path>`,
80
+ ` <path>`,
81
+ ` <groupId>org.projectlombok</groupId>`,
82
+ ` <artifactId>lombok</artifactId>`,
83
+ ` <version>\${lombok.version}</version>`,
84
+ ` </path>`,
85
+ ` </annotationProcessorPaths>`,
86
+ ` </configuration>`,
87
+ ` </plugin>`,
88
+ ` <plugin>`,
89
+ ` <groupId>org.apache.maven.plugins</groupId>`,
90
+ ` <artifactId>maven-jar-plugin</artifactId>`,
91
+ ` <version>3.2.0</version>`,
92
+ ` <configuration>`,
93
+ ` <archive>`,
94
+ ` <manifestEntries>`,
95
+ ` <Dependencies>`,
96
+ ` <![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]]>`,
97
+ ` </Dependencies>`,
98
+ ` </manifestEntries>`,
99
+ ` </archive>`,
100
+ ` </configuration>`,
101
+ ` </plugin>`,
102
+ ` <plugin>`,
103
+ ` <groupId>com.spotify.fmt</groupId>`,
104
+ ` <artifactId>fmt-maven-plugin</artifactId>`,
105
+ ` <version>2.20</version>`,
106
+ ` </plugin>`,
107
+ ` </plugins>`,
108
+ ` </build>`,
109
+ ` <dependencies>`,
110
+ ` <dependency>`,
111
+ ` <groupId>org.projectlombok</groupId>`,
112
+ ` <artifactId>lombok</artifactId>`,
113
+ ` <version>\${lombok.version}</version>`,
114
+ ` <scope>provided</scope>`,
115
+ ` </dependency>`,
116
+ ` <dependency>`,
117
+ ` <groupId>com.google.auto.service</groupId>`,
118
+ ` <artifactId>auto-service</artifactId>`,
119
+ ` <version>\${auto-service.version}</version>`,
120
+ ` <scope>provided</scope>`,
121
+ ` </dependency>`,
122
+ ` <dependency>`,
123
+ ` <groupId>org.keycloak</groupId>`,
124
+ ` <artifactId>keycloak-server-spi</artifactId>`,
125
+ ` <version>\${keycloak.version}</version>`,
126
+ ` <scope>provided</scope>`,
127
+ ` </dependency>`,
128
+ ` <dependency>`,
129
+ ` <groupId>org.keycloak</groupId>`,
130
+ ` <artifactId>keycloak-server-spi-private</artifactId>`,
131
+ ` <version>\${keycloak.version}</version>`,
132
+ ` <scope>provided</scope>`,
133
+ ` </dependency>`,
134
+ ` <dependency>`,
135
+ ` <groupId>org.keycloak</groupId>`,
136
+ ` <artifactId>keycloak-services</artifactId>`,
137
+ ` <version>\${keycloak.version}</version>`,
138
+ ` <scope>provided</scope>`,
139
+ ` </dependency>`,
140
+ ` <dependency>`,
141
+ ` <groupId>jakarta.ws.rs</groupId>`,
142
+ ` <artifactId>jakarta.ws.rs-api</artifactId>`,
143
+ ` <version>3.1.0</version>`,
144
+ ` <scope>provided</scope>`,
145
+ ` </dependency>`,
146
+ ` <dependency>`,
147
+ ` <groupId>com.google.guava</groupId>`,
148
+ ` <artifactId>guava</artifactId>`,
149
+ ` <version>\${guava.version}</version>`,
150
+ ` <scope>provided</scope>`,
151
+ ` </dependency>`,
152
+ ` </dependencies>`,
153
+ `</project>`
154
+ ].join("\n");
155
+
156
+ return { pomFileCode };
157
+ })();
158
+
159
+ fs.writeFileSync(pathJoin(keycloakThemeBuildingDirPath, "pom.xml"), Buffer.from(pomFileCode, "utf8"));
160
+ }
161
+
162
+ const accountV1 = "account-v1";
163
+
164
+ {
165
+ const builtinKeycloakThemeTmpDirPath = pathJoin(keycloakThemeBuildingDirPath, "..", "tmp_yxdE2_builtin_keycloak_theme");
166
+
167
+ await downloadBuiltinKeycloakTheme({
168
+ "destDirPath": builtinKeycloakThemeTmpDirPath,
169
+ "isSilent": true,
170
+ "keycloakVersion": "21.1.2"
171
+ });
172
+
173
+ transformCodebase({
174
+ "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "base", "account"),
175
+ "destDirPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", accountV1, "account")
176
+ });
177
+
178
+ transformCodebase({
179
+ "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "common"),
180
+ "destDirPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", accountV1Keycloak, "common")
181
+ });
182
+
183
+ transformCodebase({
184
+ "srcDirPath": pathJoin(builtinKeycloakThemeTmpDirPath, "keycloak", "account"),
185
+ "destDirPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", accountV1Keycloak, "account"),
186
+ "transformSourceCode": ({ sourceCode, filePath }) => {
187
+ if (pathBasename(filePath) !== "theme.properties") {
188
+ sourceCode = Buffer.from(sourceCode.toString("utf8").replace("parent=base", `parent=${accountV1}`), "utf8");
189
+ sourceCode = Buffer.from(
190
+ sourceCode.toString("utf8").replace("import=common/keycloak", `import=common/${accountV1Keycloak}`),
191
+ "utf8"
192
+ );
193
+ }
194
+
195
+ return {
196
+ "modifiedSourceCode": sourceCode
197
+ };
198
+ }
199
+ });
200
+
201
+ fs.rmdirSync(builtinKeycloakThemeTmpDirPath, { "recursive": true });
202
+ }
203
+
204
+ transformCodebase({
205
+ "srcDirPath": pathJoin(__dirname, "account-v1-java"),
206
+ "destDirPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "java", "org", "keycloak")
207
+ });
208
+
209
+ {
210
+ const themeManifestFilePath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
211
+
212
+ try {
213
+ fs.mkdirSync(pathDirname(themeManifestFilePath));
214
+ } catch {}
215
+
216
+ fs.writeFileSync(
217
+ themeManifestFilePath,
218
+ Buffer.from(
219
+ JSON.stringify(
220
+ {
221
+ "themes": [
222
+ {
223
+ "name": "account-v1",
224
+ "types": ["account"]
225
+ },
226
+ {
227
+ "name": "account-v1-keycloak",
228
+ "types": ["account"]
229
+ },
230
+ ...[themeName, ...extraThemeNames].map(themeName => ({
231
+ "name": themeName,
232
+ "types": Object.entries(implementedThemeTypes)
233
+ .filter(([, isImplemented]) => isImplemented)
234
+ .map(([themeType]) => themeType)
235
+ }))
236
+ ]
237
+ },
238
+ null,
239
+ 2
240
+ ),
241
+ "utf8"
242
+ )
243
+ );
244
+ }
245
+
246
+ return {
247
+ "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${artifactId}-${themeVersion}.jar`)
248
+ };
249
+ }
@@ -0,0 +1 @@
1
+ export * from "./generateJavaStackFiles";
@@ -12,6 +12,7 @@ import { downloadKeycloakStaticResources } from "./downloadKeycloakStaticResourc
12
12
  import { readFieldNameUsage } from "./readFieldNameUsage";
13
13
  import { readExtraPagesNames } from "./readExtraPageNames";
14
14
  import { generateMessageProperties } from "./generateMessageProperties";
15
+ import { accountV1Keycloak } from "../generateJavaStackFiles/generateJavaStackFiles";
15
16
 
16
17
  export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
17
18
 
@@ -230,7 +231,20 @@ export async function generateTheme(params: {
230
231
 
231
232
  fs.writeFileSync(
232
233
  pathJoin(themeDirPath, "theme.properties"),
233
- Buffer.from([`parent=keycloak`, ...(buildOptions.extraThemeProperties ?? [])].join("\n\n"), "utf8")
234
+ Buffer.from(
235
+ [
236
+ `parent=${(() => {
237
+ switch (themeType) {
238
+ case "login":
239
+ return "keycloak";
240
+ case "account":
241
+ return accountV1Keycloak;
242
+ }
243
+ })()}`,
244
+ ...(buildOptions.extraThemeProperties ?? [])
245
+ ].join("\n\n"),
246
+ "utf8"
247
+ )
234
248
  );
235
249
  }
236
250
 
@@ -48,7 +48,7 @@ export async function main() {
48
48
  });
49
49
  }
50
50
 
51
- const { jarFilePath } = generateJavaStackFiles({
51
+ const { jarFilePath } = await generateJavaStackFiles({
52
52
  "keycloakThemeBuildingDirPath": buildOptions.keycloakifyBuildDirPath,
53
53
  "implementedThemeTypes": (() => {
54
54
  const implementedThemeTypes = {
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __read = (this && this.__read) || function (o, n) {
26
- var m = typeof Symbol === "function" && o[Symbol.iterator];
27
- if (!m) return o;
28
- var i = m.call(o), r, ar = [], e;
29
- try {
30
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
- }
32
- catch (error) { e = { error: error }; }
33
- finally {
34
- try {
35
- if (r && !r.done && (m = i["return"])) m.call(i);
36
- }
37
- finally { if (e) throw e.error; }
38
- }
39
- return ar;
40
- };
41
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
42
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43
- if (ar || !(i in from)) {
44
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
45
- ar[i] = from[i];
46
- }
47
- }
48
- return to.concat(ar || Array.prototype.slice.call(from));
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.generateJavaStackFiles = void 0;
52
- var fs = __importStar(require("fs"));
53
- var path_1 = require("path");
54
- var assert_1 = require("tsafe/assert");
55
- var Reflect_1 = require("tsafe/Reflect");
56
- {
57
- var buildOptions = (0, Reflect_1.Reflect)();
58
- (0, assert_1.assert)();
59
- }
60
- function generateJavaStackFiles(params) {
61
- var _a = params.buildOptions, groupId = _a.groupId, themeName = _a.themeName, extraThemeNames = _a.extraThemeNames, themeVersion = _a.themeVersion, artifactId = _a.artifactId, keycloakThemeBuildingDirPath = params.keycloakThemeBuildingDirPath, implementedThemeTypes = params.implementedThemeTypes;
62
- {
63
- var pomFileCode = (function generatePomFileCode() {
64
- var pomFileCode = [
65
- "<?xml version=\"1.0\"?>",
66
- "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"",
67
- "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"",
68
- "\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">",
69
- "\t<modelVersion>4.0.0</modelVersion>",
70
- "\t<groupId>".concat(groupId, "</groupId>"),
71
- "\t<artifactId>".concat(artifactId, "</artifactId>"),
72
- "\t<version>".concat(themeVersion, "</version>"),
73
- "\t<name>".concat(artifactId, "</name>"),
74
- "\t<description />",
75
- "</project>"
76
- ].join("\n");
77
- return { pomFileCode: pomFileCode };
78
- })().pomFileCode;
79
- fs.writeFileSync((0, path_1.join)(keycloakThemeBuildingDirPath, "pom.xml"), Buffer.from(pomFileCode, "utf8"));
80
- }
81
- {
82
- var themeManifestFilePath = (0, path_1.join)(keycloakThemeBuildingDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
83
- try {
84
- fs.mkdirSync((0, path_1.dirname)(themeManifestFilePath));
85
- }
86
- catch (_b) { }
87
- fs.writeFileSync(themeManifestFilePath, Buffer.from(JSON.stringify({
88
- "themes": __spreadArray([themeName], __read(extraThemeNames), false).map(function (themeName) { return ({
89
- "name": themeName,
90
- "types": Object.entries(implementedThemeTypes)
91
- .filter(function (_a) {
92
- var _b = __read(_a, 2), isImplemented = _b[1];
93
- return isImplemented;
94
- })
95
- .map(function (_a) {
96
- var _b = __read(_a, 1), themeType = _b[0];
97
- return themeType;
98
- })
99
- }); })
100
- }, null, 2), "utf8"));
101
- }
102
- return {
103
- "jarFilePath": (0, path_1.join)(keycloakThemeBuildingDirPath, "target", "".concat(artifactId, "-").concat(themeVersion, ".jar"))
104
- };
105
- }
106
- exports.generateJavaStackFiles = generateJavaStackFiles;
107
- //# sourceMappingURL=generateJavaStackFiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateJavaStackFiles.js","sourceRoot":"","sources":["../../src/bin/keycloakify/generateJavaStackFiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,6BAAgE;AAChE,uCAAsC;AACtC,yCAAwC;AAYxC;IACI,IAAM,YAAY,GAAG,IAAA,iBAAO,GAAgB,CAAC;IAE7C,IAAA,eAAM,GAA+D,CAAC;CACzE;AAED,SAAgB,sBAAsB,CAAC,MAItC;IAIO,IAAA,KAGA,MAAM,aAHyE,EAA/D,OAAO,aAAA,EAAE,SAAS,eAAA,EAAE,eAAe,qBAAA,EAAE,YAAY,kBAAA,EAAE,UAAU,gBAAA,EAC7E,4BAA4B,GAE5B,MAAM,6BAFsB,EAC5B,qBAAqB,GACrB,MAAM,sBADe,CACd;IAEX;QACY,IAAA,WAAW,GAAK,CAAC,SAAS,mBAAmB;YAGjD,IAAM,WAAW,GAAG;gBAChB,yBAAuB;gBACvB,sDAAoD;gBACpD,2DAAwD;gBACxD,sGAAmG;gBACnG,sCAAqC;gBACrC,qBAAa,OAAO,eAAY;gBAChC,wBAAgB,UAAU,kBAAe;gBACzC,qBAAa,YAAY,eAAY;gBACrC,kBAAU,UAAU,YAAS;gBAC7B,mBAAkB;gBAClB,YAAY;aACf,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEb,OAAO,EAAE,WAAW,aAAA,EAAE,CAAC;QAC3B,CAAC,CAAC,EAAE,YAlBe,CAkBd;QAEL,EAAE,CAAC,aAAa,CAAC,IAAA,WAAQ,EAAC,4BAA4B,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;KACzG;IAED;QACI,IAAM,qBAAqB,GAAG,IAAA,WAAQ,EAAC,4BAA4B,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;QAErI,IAAI;YACA,EAAE,CAAC,SAAS,CAAC,IAAA,cAAW,EAAC,qBAAqB,CAAC,CAAC,CAAC;SACpD;QAAC,WAAM,GAAE;QAEV,EAAE,CAAC,aAAa,CACZ,qBAAqB,EACrB,MAAM,CAAC,IAAI,CACP,IAAI,CAAC,SAAS,CACV;YACI,QAAQ,EAAE,eAAC,SAAS,UAAK,eAAe,UAAE,GAAG,CAAC,UAAA,SAAS,IAAI,OAAA,CAAC;gBACxD,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;qBACzC,MAAM,CAAC,UAAC,EAAiB;wBAAjB,KAAA,aAAiB,EAAd,aAAa,QAAA;oBAAM,OAAA,aAAa;gBAAb,CAAa,CAAC;qBAC5C,GAAG,CAAC,UAAC,EAAW;wBAAX,KAAA,aAAW,EAAV,SAAS,QAAA;oBAAM,OAAA,SAAS;gBAAT,CAAS,CAAC;aACvC,CAAC,EALyD,CAKzD,CAAC;SACN,EACD,IAAI,EACJ,CAAC,CACJ,EACD,MAAM,CACT,CACJ,CAAC;KACL;IAED,OAAO;QACH,aAAa,EAAE,IAAA,WAAQ,EAAC,4BAA4B,EAAE,QAAQ,EAAE,UAAG,UAAU,cAAI,YAAY,SAAM,CAAC;KACvG,CAAC;AACN,CAAC;AAnED,wDAmEC"}
@@ -1,89 +0,0 @@
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 } from "./generateFtl";
7
-
8
- export type BuildOptionsLike = {
9
- themeName: string;
10
- extraThemeNames: string[];
11
- groupId: string;
12
- artifactId: string;
13
- themeVersion: string;
14
- };
15
-
16
- {
17
- const buildOptions = Reflect<BuildOptions>();
18
-
19
- assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
20
- }
21
-
22
- export function generateJavaStackFiles(params: {
23
- keycloakThemeBuildingDirPath: string;
24
- implementedThemeTypes: Record<ThemeType | "email", boolean>;
25
- buildOptions: BuildOptionsLike;
26
- }): {
27
- jarFilePath: string;
28
- } {
29
- const {
30
- buildOptions: { groupId, themeName, extraThemeNames, themeVersion, artifactId },
31
- keycloakThemeBuildingDirPath,
32
- implementedThemeTypes
33
- } = params;
34
-
35
- {
36
- const { pomFileCode } = (function generatePomFileCode(): {
37
- pomFileCode: string;
38
- } {
39
- const pomFileCode = [
40
- `<?xml version="1.0"?>`,
41
- `<project xmlns="http://maven.apache.org/POM/4.0.0"`,
42
- ` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`,
43
- ` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
44
- ` <modelVersion>4.0.0</modelVersion>`,
45
- ` <groupId>${groupId}</groupId>`,
46
- ` <artifactId>${artifactId}</artifactId>`,
47
- ` <version>${themeVersion}</version>`,
48
- ` <name>${artifactId}</name>`,
49
- ` <description />`,
50
- `</project>`
51
- ].join("\n");
52
-
53
- return { pomFileCode };
54
- })();
55
-
56
- fs.writeFileSync(pathJoin(keycloakThemeBuildingDirPath, "pom.xml"), Buffer.from(pomFileCode, "utf8"));
57
- }
58
-
59
- {
60
- const themeManifestFilePath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
61
-
62
- try {
63
- fs.mkdirSync(pathDirname(themeManifestFilePath));
64
- } catch {}
65
-
66
- fs.writeFileSync(
67
- themeManifestFilePath,
68
- Buffer.from(
69
- JSON.stringify(
70
- {
71
- "themes": [themeName, ...extraThemeNames].map(themeName => ({
72
- "name": themeName,
73
- "types": Object.entries(implementedThemeTypes)
74
- .filter(([, isImplemented]) => isImplemented)
75
- .map(([themeType]) => themeType)
76
- }))
77
- },
78
- null,
79
- 2
80
- ),
81
- "utf8"
82
- )
83
- );
84
- }
85
-
86
- return {
87
- "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${artifactId}-${themeVersion}.jar`)
88
- };
89
- }