keycloakify 7.14.0 → 7.14.2

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.
@@ -52,7 +52,7 @@ assert<BuildOptions extends BuildOptionsLike ? true : false>();
52
52
  export async function generateTheme(params: {
53
53
  reactAppBuildDirPath: string;
54
54
  keycloakThemeBuildingDirPath: string;
55
- themeSrcDirPath: string | undefined;
55
+ themeSrcDirPath: string;
56
56
  keycloakifySrcDirPath: string;
57
57
  buildOptions: BuildOptionsLike;
58
58
  keycloakifyVersion: string;
@@ -67,6 +67,10 @@ export async function generateTheme(params: {
67
67
  let generateFtlFilesCode_glob: ReturnType<typeof generateFtlFilesCodeFactory>["generateFtlFilesCode"] | undefined = undefined;
68
68
 
69
69
  for (const themeType of themeTypes) {
70
+ if (!fs.existsSync(pathJoin(themeSrcDirPath, themeType))) {
71
+ continue;
72
+ }
73
+
70
74
  const themeDirPath = getThemeDirPath(themeType);
71
75
 
72
76
  copy_app_resources_to_theme_path: {
@@ -132,26 +136,21 @@ export async function generateTheme(params: {
132
136
  });
133
137
  }
134
138
 
135
- const generateFtlFilesCode = (() => {
136
- if (generateFtlFilesCode_glob !== undefined) {
137
- return generateFtlFilesCode_glob;
138
- }
139
-
140
- const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
141
- "indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
142
- "cssGlobalsToDefine": allCssGlobalsToDefine,
143
- buildOptions,
144
- keycloakifyVersion,
145
- themeType,
146
- "fieldNames": readFieldNameUsage({
147
- keycloakifySrcDirPath,
148
- themeSrcDirPath,
149
- themeType
150
- })
151
- });
152
-
153
- return generateFtlFilesCode;
154
- })();
139
+ const generateFtlFilesCode =
140
+ generateFtlFilesCode_glob !== undefined
141
+ ? generateFtlFilesCode_glob
142
+ : generateFtlFilesCodeFactory({
143
+ "indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
144
+ "cssGlobalsToDefine": allCssGlobalsToDefine,
145
+ buildOptions,
146
+ keycloakifyVersion,
147
+ themeType,
148
+ "fieldNames": readFieldNameUsage({
149
+ keycloakifySrcDirPath,
150
+ themeSrcDirPath,
151
+ themeType
152
+ })
153
+ }).generateFtlFilesCode;
155
154
 
156
155
  [
157
156
  ...(() => {
@@ -162,12 +161,10 @@ export async function generateTheme(params: {
162
161
  return accountThemePageIds;
163
162
  }
164
163
  })(),
165
- ...(themeSrcDirPath === undefined
166
- ? []
167
- : readExtraPagesNames({
168
- themeType,
169
- themeSrcDirPath
170
- }))
164
+ ...readExtraPagesNames({
165
+ themeType,
166
+ themeSrcDirPath
167
+ })
171
168
  ].forEach(pageId => {
172
169
  const { ftlCode } = generateFtlFilesCode({ pageId });
173
170
 
@@ -224,10 +221,6 @@ export async function generateTheme(params: {
224
221
  }
225
222
 
226
223
  email: {
227
- if (themeSrcDirPath === undefined) {
228
- break email;
229
- }
230
-
231
224
  const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
232
225
 
233
226
  if (!fs.existsSync(emailThemeSrcDirPath)) {
@@ -5,74 +5,15 @@ import * as fs from "fs";
5
5
  import type { ThemeType } from "../generateFtl";
6
6
  import { exclude } from "tsafe/exclude";
7
7
 
8
- export function readFieldNameUsage(params: {
9
- keycloakifySrcDirPath: string;
10
- themeSrcDirPath: string | undefined;
11
- themeType: ThemeType | "email";
12
- }): string[] {
8
+ /** Assumes the theme type exists */
9
+ export function readFieldNameUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): string[] {
13
10
  const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params;
14
11
 
15
12
  const fieldNames: string[] = [];
16
13
 
17
- if (themeSrcDirPath === undefined) {
18
- //If we can't detect the user theme directory we restore the fieldNames we had previously to prevent errors.
19
- fieldNames.push(
20
- ...[
21
- "global",
22
- "userLabel",
23
- "username",
24
- "email",
25
- "firstName",
26
- "lastName",
27
- "password",
28
- "password-confirm",
29
- "totp",
30
- "totpSecret",
31
- "SAMLRequest",
32
- "SAMLResponse",
33
- "relayState",
34
- "device_user_code",
35
- "code",
36
- "password-new",
37
- "rememberMe",
38
- "login",
39
- "authenticationExecution",
40
- "cancel-aia",
41
- "clientDataJSON",
42
- "authenticatorData",
43
- "signature",
44
- "credentialId",
45
- "userHandle",
46
- "error",
47
- "authn_use_chk",
48
- "authenticationExecution",
49
- "isSetRetry",
50
- "try-again",
51
- "attestationObject",
52
- "publicKeyCredentialId",
53
- "authenticatorLabel"
54
- ]
55
- );
56
- }
57
-
58
- for (const srcDirPath of (
59
- [
60
- pathJoin(keycloakifySrcDirPath, themeType),
61
- (() => {
62
- if (themeSrcDirPath === undefined) {
63
- return undefined;
64
- }
65
-
66
- const srcDirPath = pathJoin(themeSrcDirPath, themeType);
67
-
68
- if (!fs.existsSync(srcDirPath)) {
69
- return undefined;
70
- }
71
-
72
- return srcDirPath;
73
- })()
74
- ] as const
75
- ).filter(exclude(undefined))) {
14
+ for (const srcDirPath of ([pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)] as const).filter(
15
+ exclude(undefined)
16
+ )) {
76
17
  const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
77
18
 
78
19
  for (const filePath of filePaths) {
@@ -57,12 +57,6 @@ export async function main() {
57
57
  "email": false
58
58
  };
59
59
 
60
- if (themeSrcDirPath === undefined) {
61
- implementedThemeTypes["login"] = true;
62
- implementedThemeTypes["account"] = true;
63
- return implementedThemeTypes;
64
- }
65
-
66
60
  for (const themeType of objectKeys(implementedThemeTypes)) {
67
61
  if (!fs.existsSync(pathJoin(themeSrcDirPath, themeType))) {
68
62
  continue;