keycloakify 10.0.0-rc.110 → 10.0.0-rc.112

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 (61) hide show
  1. package/PUBLIC_URL.js +2 -2
  2. package/PUBLIC_URL.js.map +1 -1
  3. package/account/KcContext/kcContextMocks.js +3 -3
  4. package/account/i18n/i18n.js +4 -4
  5. package/account/i18n/i18n.js.map +1 -1
  6. package/account/i18n/useI18n.d.ts +1 -1
  7. package/account/i18n/useI18n.js +16 -5
  8. package/account/i18n/useI18n.js.map +1 -1
  9. package/bin/193.index.js +4 -4
  10. package/bin/31.index.js +31 -31
  11. package/bin/440.index.js +52 -51
  12. package/bin/453.index.js +3 -3
  13. package/bin/526.index.js +5 -5
  14. package/bin/622.index.js +1 -1
  15. package/bin/97.index.js +3 -3
  16. package/bin/shared/buildContext.js.map +1 -1
  17. package/bin/shared/constants.d.ts +17 -17
  18. package/bin/shared/constants.js +14 -14
  19. package/bin/shared/constants.js.map +1 -1
  20. package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -1
  21. package/bin/shared/downloadKeycloakDefaultTheme.js.map +1 -1
  22. package/lib/getKcClsx.js +4 -1
  23. package/lib/getKcClsx.js.map +1 -1
  24. package/login/KcContext/kcContextMocks.js +3 -3
  25. package/login/i18n/i18n.js +4 -4
  26. package/login/i18n/i18n.js.map +1 -1
  27. package/login/i18n/useI18n.d.ts +1 -1
  28. package/login/i18n/useI18n.js +16 -14
  29. package/login/i18n/useI18n.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/PUBLIC_URL.ts +2 -2
  32. package/src/account/KcContext/kcContextMocks.ts +3 -3
  33. package/src/account/i18n/i18n.tsx +4 -4
  34. package/src/account/i18n/useI18n.tsx +20 -6
  35. package/src/bin/add-story.ts +6 -6
  36. package/src/bin/eject-page.ts +6 -6
  37. package/src/bin/keycloakify/buildJars/buildJar.ts +13 -8
  38. package/src/bin/keycloakify/generateFtl/generateFtl.ts +15 -19
  39. package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +386 -375
  40. package/src/bin/keycloakify/generateResources/bringInAccountV1.ts +7 -7
  41. package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +2 -2
  42. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +17 -19
  43. package/src/bin/keycloakify/generateResources/generateResourcesForThemeVariant.ts +2 -2
  44. package/src/bin/keycloakify/generateResources/readExtraPageNames.ts +4 -4
  45. package/src/bin/keycloakify/keycloakify.ts +7 -5
  46. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +3 -4
  47. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +6 -6
  48. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +4 -4
  49. package/src/bin/shared/buildContext.ts +9 -8
  50. package/src/bin/shared/constants.ts +17 -17
  51. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +6 -6
  52. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +2 -2
  53. package/src/bin/shared/downloadKeycloakStaticResources.ts +2 -2
  54. package/src/bin/start-keycloak/keycloakifyBuild.ts +2 -2
  55. package/src/bin/start-keycloak/start-keycloak.ts +5 -5
  56. package/src/lib/getKcClsx.ts +6 -2
  57. package/src/login/KcContext/kcContextMocks.ts +4 -4
  58. package/src/login/i18n/i18n.tsx +4 -4
  59. package/src/login/i18n/useI18n.tsx +20 -15
  60. package/src/vite-plugin/vite-plugin.ts +8 -8
  61. package/vite-plugin/index.js +42 -42
@@ -3,9 +3,9 @@ import { join as pathJoin } from "path";
3
3
  import { assert } from "tsafe/assert";
4
4
  import type { BuildContext } from "../../shared/buildContext";
5
5
  import {
6
- resources_common,
7
- lastKeycloakVersionWithAccountV1,
8
- accountV1ThemeName
6
+ RESOURCES_COMMON,
7
+ LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
8
+ ACCOUNT_V1_THEME_NAME
9
9
  } from "../../shared/constants";
10
10
  import {
11
11
  downloadKeycloakDefaultTheme,
@@ -24,14 +24,14 @@ export async function bringInAccountV1(params: {
24
24
  const { resourcesDirPath, buildContext } = params;
25
25
 
26
26
  const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
27
- keycloakVersion: lastKeycloakVersionWithAccountV1,
27
+ keycloakVersion: LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
28
28
  buildContext
29
29
  });
30
30
 
31
31
  const accountV1DirPath = pathJoin(
32
32
  resourcesDirPath,
33
33
  "theme",
34
- accountV1ThemeName,
34
+ ACCOUNT_V1_THEME_NAME,
35
35
  "account"
36
36
  );
37
37
 
@@ -47,7 +47,7 @@ export async function bringInAccountV1(params: {
47
47
 
48
48
  transformCodebase({
49
49
  srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
50
- destDirPath: pathJoin(accountV1DirPath, "resources", resources_common)
50
+ destDirPath: pathJoin(accountV1DirPath, "resources", RESOURCES_COMMON)
51
51
  });
52
52
 
53
53
  fs.writeFileSync(
@@ -69,7 +69,7 @@ export async function bringInAccountV1(params: {
69
69
  "patternfly-additions.min.css"
70
70
  ].map(
71
71
  fileBasename =>
72
- `${resources_common}/node_modules/patternfly/dist/css/${fileBasename}`
72
+ `${RESOURCES_COMMON}/node_modules/patternfly/dist/css/${fileBasename}`
73
73
  )
74
74
  ].join(" "),
75
75
  "",
@@ -1,4 +1,4 @@
1
- import { type ThemeType, fallbackLanguageTag } from "../../shared/constants";
1
+ import { type ThemeType, FALLBACK_LANGUAGE_TAG } from "../../shared/constants";
2
2
  import { crawl } from "../../tools/crawl";
3
3
  import { join as pathJoin } from "path";
4
4
  import { symToStr } from "tsafe/symToStr";
@@ -168,7 +168,7 @@ export function generateMessageProperties(params: {
168
168
  ...(messageBundle === undefined
169
169
  ? {}
170
170
  : messageBundle[languageTag] ??
171
- messageBundle[fallbackLanguageTag] ??
171
+ messageBundle[FALLBACK_LANGUAGE_TAG] ??
172
172
  messageBundle[Object.keys(messageBundle)[0]] ??
173
173
  {})
174
174
  }
@@ -15,12 +15,12 @@ import {
15
15
  } from "../generateFtl";
16
16
  import {
17
17
  type ThemeType,
18
- lastKeycloakVersionWithAccountV1,
19
- keycloak_resources,
20
- accountV1ThemeName,
21
- basenameOfTheKeycloakifyResourcesDir,
22
- loginThemePageIds,
23
- accountThemePageIds
18
+ LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
19
+ KEYCLOAK_RESOURCES,
20
+ ACCOUNT_V1_THEME_NAME,
21
+ BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR,
22
+ LOGIN_THEME_PAGE_IDS,
23
+ ACCOUNT_THEME_PAGE_IDS
24
24
  } from "../../shared/constants";
25
25
  import type { BuildContext } from "../../shared/buildContext";
26
26
  import { assert, type Equals } from "tsafe/assert";
@@ -85,7 +85,7 @@ export async function generateResourcesForMainTheme(params: {
85
85
  const destDirPath = pathJoin(
86
86
  themeTypeDirPath,
87
87
  "resources",
88
- basenameOfTheKeycloakifyResourcesDir
88
+ BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
89
89
  );
90
90
 
91
91
  // NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
@@ -103,7 +103,7 @@ export async function generateResourcesForMainTheme(params: {
103
103
  themeType: "login"
104
104
  }),
105
105
  "resources",
106
- basenameOfTheKeycloakifyResourcesDir
106
+ BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
107
107
  ),
108
108
  destDirPath
109
109
  });
@@ -114,7 +114,7 @@ export async function generateResourcesForMainTheme(params: {
114
114
  {
115
115
  const dirPath = pathJoin(
116
116
  buildContext.projectBuildDirPath,
117
- keycloak_resources
117
+ KEYCLOAK_RESOURCES
118
118
  );
119
119
 
120
120
  if (fs.existsSync(dirPath)) {
@@ -122,7 +122,7 @@ export async function generateResourcesForMainTheme(params: {
122
122
 
123
123
  throw new Error(
124
124
  [
125
- `Keycloakify build error: The ${keycloak_resources} directory shouldn't exist in your build directory.`,
125
+ `Keycloakify build error: The ${KEYCLOAK_RESOURCES} directory shouldn't exist in your build directory.`,
126
126
  `(${pathRelative(process.cwd(), dirPath)}).\n`,
127
127
  `Theses assets are only required for local development with Storybook.",
128
128
  "Please remove this directory as an additional step of your command.\n`,
@@ -140,8 +140,7 @@ export async function generateResourcesForMainTheme(params: {
140
140
  const { fixedCssCode } = replaceImportsInCssCode({
141
141
  cssCode: sourceCode.toString("utf8"),
142
142
  cssFileRelativeDirPath: pathDirname(fileRelativePath),
143
- buildContext,
144
- isAccountV3
143
+ buildContext
145
144
  });
146
145
 
147
146
  return {
@@ -176,17 +175,16 @@ export async function generateResourcesForMainTheme(params: {
176
175
  fieldNames: readFieldNameUsage({
177
176
  themeSrcDirPath: buildContext.themeSrcDirPath,
178
177
  themeType
179
- }),
180
- isAccountV3
178
+ })
181
179
  });
182
180
 
183
181
  [
184
182
  ...(() => {
185
183
  switch (themeType) {
186
184
  case "login":
187
- return loginThemePageIds;
185
+ return LOGIN_THEME_PAGE_IDS;
188
186
  case "account":
189
- return isAccountV3 ? ["index.ftl"] : accountThemePageIds;
187
+ return isAccountV3 ? ["index.ftl"] : ACCOUNT_THEME_PAGE_IDS;
190
188
  }
191
189
  })(),
192
190
  ...(isAccountV3
@@ -240,7 +238,7 @@ export async function generateResourcesForMainTheme(params: {
240
238
  keycloakVersion: (() => {
241
239
  switch (themeType) {
242
240
  case "account":
243
- return lastKeycloakVersionWithAccountV1;
241
+ return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
244
242
  case "login":
245
243
  return buildContext.loginThemeResourcesFromKeycloakVersion;
246
244
  }
@@ -258,7 +256,7 @@ export async function generateResourcesForMainTheme(params: {
258
256
  `parent=${(() => {
259
257
  switch (themeType) {
260
258
  case "account":
261
- return isAccountV3 ? "base" : accountV1ThemeName;
259
+ return isAccountV3 ? "base" : ACCOUNT_V1_THEME_NAME;
262
260
  case "login":
263
261
  return "keycloak";
264
262
  }
@@ -349,7 +347,7 @@ export async function generateResourcesForMainTheme(params: {
349
347
 
350
348
  if (buildContext.recordIsImplementedByThemeType.account) {
351
349
  metaInfKeycloakThemes.themes.push({
352
- name: accountV1ThemeName,
350
+ name: ACCOUNT_V1_THEME_NAME,
353
351
  types: ["account"]
354
352
  });
355
353
  }
@@ -31,8 +31,8 @@ export function generateResourcesForThemeVariant(params: {
31
31
  Buffer.from(sourceCode)
32
32
  .toString("utf-8")
33
33
  .replace(
34
- `kcContext.themeName = "${themeName}";`,
35
- `kcContext.themeName = "${themeVariantName}";`
34
+ `"themeName": "${themeName}"`,
35
+ `"themeName": "${themeVariantName}"`
36
36
  ),
37
37
  "utf8"
38
38
  );
@@ -5,8 +5,8 @@ import * as fs from "fs";
5
5
  import { join as pathJoin } from "path";
6
6
  import {
7
7
  type ThemeType,
8
- accountThemePageIds,
9
- loginThemePageIds
8
+ ACCOUNT_THEME_PAGE_IDS,
9
+ LOGIN_THEME_PAGE_IDS
10
10
  } from "../../shared/constants";
11
11
 
12
12
  export function readExtraPagesNames(params: {
@@ -41,9 +41,9 @@ export function readExtraPagesNames(params: {
41
41
  return extraPages.reduce(...removeDuplicates<string>()).filter(pageId => {
42
42
  switch (themeType) {
43
43
  case "account":
44
- return !id<readonly string[]>(accountThemePageIds).includes(pageId);
44
+ return !id<readonly string[]>(ACCOUNT_THEME_PAGE_IDS).includes(pageId);
45
45
  case "login":
46
- return !id<readonly string[]>(loginThemePageIds).includes(pageId);
46
+ return !id<readonly string[]>(LOGIN_THEME_PAGE_IDS).includes(pageId);
47
47
  }
48
48
  });
49
49
  }
@@ -3,7 +3,7 @@ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path
3
3
  import * as child_process from "child_process";
4
4
  import * as fs from "fs";
5
5
  import { getBuildContext } from "../shared/buildContext";
6
- import { vitePluginSubScriptEnvNames } from "../shared/constants";
6
+ import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
7
7
  import { buildJars } from "./buildJars";
8
8
  import type { CliCommandOptions } from "../main";
9
9
  import chalk from "chalk";
@@ -93,10 +93,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
93
93
  cwd: buildContext.projectDirPath,
94
94
  env: {
95
95
  ...process.env,
96
- [vitePluginSubScriptEnvNames.runPostBuildScript]: JSON.stringify({
97
- resourcesDirPath,
98
- buildContext
99
- })
96
+ [VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RUN_POST_BUILD_SCRIPT]: JSON.stringify(
97
+ {
98
+ resourcesDirPath,
99
+ buildContext
100
+ }
101
+ )
100
102
  }
101
103
  });
102
104
  }
@@ -1,5 +1,5 @@
1
1
  import type { BuildContext } from "../../shared/buildContext";
2
- import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
2
+ import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../shared/constants";
3
3
  import { assert } from "tsafe/assert";
4
4
  import { posix } from "path";
5
5
 
@@ -12,12 +12,11 @@ assert<BuildContext extends BuildContextLike ? true : false>();
12
12
  export function replaceImportsInCssCode(params: {
13
13
  cssCode: string;
14
14
  cssFileRelativeDirPath: string | undefined;
15
- isAccountV3: boolean;
16
15
  buildContext: BuildContextLike;
17
16
  }): {
18
17
  fixedCssCode: string;
19
18
  } {
20
- const { cssCode, cssFileRelativeDirPath, buildContext, isAccountV3 } = params;
19
+ const { cssCode, cssFileRelativeDirPath, buildContext } = params;
21
20
 
22
21
  const fixedCssCode = cssCode.replace(
23
22
  /url\(["']?(\/[^/][^)"']+)["']?\)/g,
@@ -38,7 +37,7 @@ export function replaceImportsInCssCode(params: {
38
37
  break inline_style_in_html;
39
38
  }
40
39
 
41
- return `url(\${${!isAccountV3 ? "url.resourcesPath" : "resourceUrl"}}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
40
+ return `url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}${assetFileAbsoluteUrlPathname})`;
42
41
  }
43
42
 
44
43
  const assetFileRelativeUrlPathname = posix.relative(
@@ -1,4 +1,4 @@
1
- import { basenameOfTheKeycloakifyResourcesDir } from "../../../shared/constants";
1
+ import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
2
2
  import { assert } from "tsafe/assert";
3
3
  import type { BuildContext } from "../../../shared/buildContext";
4
4
  import * as nodePath from "path";
@@ -31,13 +31,13 @@ export function replaceImportsInJsCode_vite(params: {
31
31
 
32
32
  let fixedJsCode = jsCode;
33
33
 
34
- replace_base_javacript_import: {
34
+ replace_base_js_import: {
35
35
  if (buildContext.urlPathname === undefined) {
36
- break replace_base_javacript_import;
36
+ break replace_base_js_import;
37
37
  }
38
38
  // Optimization
39
39
  if (!jsCode.includes(buildContext.urlPathname)) {
40
- break replace_base_javacript_import;
40
+ break replace_base_js_import;
41
41
  }
42
42
 
43
43
  // Replace `Hv=function(e){return"/abcde12345/"+e}` by `Hv=function(e){return"/"+e}`
@@ -85,13 +85,13 @@ export function replaceImportsInJsCode_vite(params: {
85
85
  fixedJsCode = replaceAll(
86
86
  fixedJsCode,
87
87
  `"${relativePathOfAssetFile}"`,
88
- `(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
88
+ `(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
89
89
  );
90
90
 
91
91
  fixedJsCode = replaceAll(
92
92
  fixedJsCode,
93
93
  `"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
94
- `(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
94
+ `(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
95
95
  );
96
96
  });
97
97
  }
@@ -1,4 +1,4 @@
1
- import { basenameOfTheKeycloakifyResourcesDir } from "../../../shared/constants";
1
+ import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
2
2
  import { assert } from "tsafe/assert";
3
3
  import type { BuildContext } from "../../../shared/buildContext";
4
4
  import * as nodePath from "path";
@@ -83,14 +83,14 @@ export function replaceImportsInJsCode_webpack(params: {
83
83
  var pd = Object.getOwnPropertyDescriptor(${n}, "p");
84
84
  if( pd === undefined || pd.configurable ){
85
85
  Object.defineProperty(${n}, "p", {
86
- get: function() { return window.kcContext.url.resourcesPath; },
86
+ get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
87
87
  set: function() {}
88
88
  });
89
89
  }
90
90
  return "${u}";
91
91
  })()] = ${
92
92
  isArrowFunction ? `${e} =>` : `function(${e}) { return `
93
- } "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}${language}/"`
93
+ } "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}${language}/"`
94
94
  .replace(/\s+/g, " ")
95
95
  .trim();
96
96
  }
@@ -104,7 +104,7 @@ export function replaceImportsInJsCode_webpack(params: {
104
104
  `[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
105
105
  "g"
106
106
  ),
107
- `window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}`
107
+ `window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}`
108
108
  );
109
109
 
110
110
  return { fixedJsCode };
@@ -13,13 +13,13 @@ import * as fs from "fs";
13
13
  import { assert, type Equals } from "tsafe/assert";
14
14
  import * as child_process from "child_process";
15
15
  import {
16
- vitePluginSubScriptEnvNames,
17
- buildForKeycloakMajorVersionEnvName
16
+ VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES,
17
+ BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME
18
18
  } from "./constants";
19
19
  import type { KeycloakVersionRange } from "./KeycloakVersionRange";
20
20
  import { exclude } from "tsafe";
21
21
  import { crawl } from "../tools/crawl";
22
- import { themeTypes } from "./constants";
22
+ import { THEME_TYPES } from "./constants";
23
23
  import { objectFromEntries } from "tsafe/objectFromEntries";
24
24
  import { objectEntries } from "tsafe/objectEntries";
25
25
  import { type ThemeType } from "./constants";
@@ -136,7 +136,7 @@ export function getBuildContext(params: {
136
136
  return { themeSrcDirPath };
137
137
  }
138
138
 
139
- for (const themeType of [...themeTypes, "email"]) {
139
+ for (const themeType of [...THEME_TYPES, "email"]) {
140
140
  if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
141
141
  continue;
142
142
  }
@@ -171,18 +171,18 @@ export function getBuildContext(params: {
171
171
  cwd: projectDirPath,
172
172
  env: {
173
173
  ...process.env,
174
- [vitePluginSubScriptEnvNames.resolveViteConfig]: "true"
174
+ [VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG]: "true"
175
175
  }
176
176
  })
177
177
  .toString("utf8");
178
178
 
179
179
  assert(
180
- output.includes(vitePluginSubScriptEnvNames.resolveViteConfig),
180
+ output.includes(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG),
181
181
  "Seems like the Keycloakify's Vite plugin is not installed."
182
182
  );
183
183
 
184
184
  const resolvedViteConfigStr = output
185
- .split(vitePluginSubScriptEnvNames.resolveViteConfig)
185
+ .split(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG)
186
186
  .reverse()[0];
187
187
 
188
188
  const resolvedViteConfig: ResolvedViteConfig = JSON.parse(resolvedViteConfigStr);
@@ -594,7 +594,8 @@ export function getBuildContext(params: {
594
594
 
595
595
  build_for_specific_keycloak_major_version: {
596
596
  const buildForKeycloakMajorVersionNumber = (() => {
597
- const envValue = process.env[buildForKeycloakMajorVersionEnvName];
597
+ const envValue =
598
+ process.env[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME];
598
599
 
599
600
  if (envValue === undefined) {
600
601
  return undefined;
@@ -1,22 +1,22 @@
1
- export const keycloak_resources = "keycloak-resources";
2
- export const resources_common = "resources-common";
3
- export const lastKeycloakVersionWithAccountV1 = "21.1.2";
4
- export const basenameOfTheKeycloakifyResourcesDir = "dist";
1
+ export const KEYCLOAK_RESOURCES = "keycloak-resources";
2
+ export const RESOURCES_COMMON = "resources-common";
3
+ export const LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 = "21.1.2";
4
+ export const BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR = "dist";
5
5
 
6
- export const themeTypes = ["login", "account"] as const;
7
- export const accountV1ThemeName = "account-v1";
6
+ export const THEME_TYPES = ["login", "account"] as const;
7
+ export const ACCOUNT_V1_THEME_NAME = "account-v1";
8
8
 
9
- export type ThemeType = (typeof themeTypes)[number];
9
+ export type ThemeType = (typeof THEME_TYPES)[number];
10
10
 
11
- export const vitePluginSubScriptEnvNames = {
12
- runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
13
- resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
11
+ export const VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES = {
12
+ RUN_POST_BUILD_SCRIPT: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
13
+ RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
14
14
  } as const;
15
15
 
16
- export const buildForKeycloakMajorVersionEnvName =
16
+ export const BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME =
17
17
  "KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
18
18
 
19
- export const loginThemePageIds = [
19
+ export const LOGIN_THEME_PAGE_IDS = [
20
20
  "login.ftl",
21
21
  "login-username.ftl",
22
22
  "login-password.ftl",
@@ -53,7 +53,7 @@ export const loginThemePageIds = [
53
53
  "webauthn-error.ftl"
54
54
  ] as const;
55
55
 
56
- export const accountThemePageIds = [
56
+ export const ACCOUNT_THEME_PAGE_IDS = [
57
57
  "password.ftl",
58
58
  "account.ftl",
59
59
  "sessions.ftl",
@@ -63,9 +63,9 @@ export const accountThemePageIds = [
63
63
  "federatedIdentity.ftl"
64
64
  ] as const;
65
65
 
66
- export type LoginThemePageId = (typeof loginThemePageIds)[number];
67
- export type AccountThemePageId = (typeof accountThemePageIds)[number];
66
+ export type LoginThemePageId = (typeof LOGIN_THEME_PAGE_IDS)[number];
67
+ export type AccountThemePageId = (typeof ACCOUNT_THEME_PAGE_IDS)[number];
68
68
 
69
- export const containerName = "keycloak-keycloakify";
69
+ export const CONTAINER_NAME = "keycloak-keycloakify";
70
70
 
71
- export const fallbackLanguageTag = "en";
71
+ export const FALLBACK_LANGUAGE_TAG = "en";
@@ -4,9 +4,9 @@ import {
4
4
  } from "./downloadKeycloakStaticResources";
5
5
  import { join as pathJoin, relative as pathRelative } from "path";
6
6
  import {
7
- themeTypes,
8
- keycloak_resources,
9
- lastKeycloakVersionWithAccountV1
7
+ THEME_TYPES,
8
+ KEYCLOAK_RESOURCES,
9
+ LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1
10
10
  } from "../shared/constants";
11
11
  import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
12
12
  import { assert } from "tsafe/assert";
@@ -26,7 +26,7 @@ export async function copyKeycloakResourcesToPublic(params: {
26
26
  }) {
27
27
  const { buildContext } = params;
28
28
 
29
- const destDirPath = pathJoin(buildContext.publicDirPath, keycloak_resources);
29
+ const destDirPath = pathJoin(buildContext.publicDirPath, KEYCLOAK_RESOURCES);
30
30
 
31
31
  const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
32
32
 
@@ -66,14 +66,14 @@ export async function copyKeycloakResourcesToPublic(params: {
66
66
 
67
67
  fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
68
68
 
69
- for (const themeType of themeTypes) {
69
+ for (const themeType of THEME_TYPES) {
70
70
  await downloadKeycloakStaticResources({
71
71
  keycloakVersion: (() => {
72
72
  switch (themeType) {
73
73
  case "login":
74
74
  return buildContext.loginThemeResourcesFromKeycloakVersion;
75
75
  case "account":
76
- return lastKeycloakVersionWithAccountV1;
76
+ return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
77
77
  }
78
78
  })(),
79
79
  themeType,
@@ -1,7 +1,7 @@
1
1
  import { join as pathJoin, relative as pathRelative } from "path";
2
2
  import { type BuildContext } from "./buildContext";
3
3
  import { assert } from "tsafe/assert";
4
- import { lastKeycloakVersionWithAccountV1 } from "./constants";
4
+ import { LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 } from "./constants";
5
5
  import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
6
6
 
7
7
  export type BuildContextLike = {
@@ -43,7 +43,7 @@ export async function downloadKeycloakDefaultTheme(params: {
43
43
  }
44
44
 
45
45
  last_account_v1_transformations: {
46
- if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
46
+ if (LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 !== keycloakVersion) {
47
47
  break last_account_v1_transformations;
48
48
  }
49
49
 
@@ -4,7 +4,7 @@ import {
4
4
  downloadKeycloakDefaultTheme,
5
5
  type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
6
6
  } from "./downloadKeycloakDefaultTheme";
7
- import { resources_common, type ThemeType } from "./constants";
7
+ import { RESOURCES_COMMON, type ThemeType } from "./constants";
8
8
  import type { BuildContext } from "./buildContext";
9
9
  import { assert } from "tsafe/assert";
10
10
  import { existsAsync } from "../tools/fs.existsAsync";
@@ -48,6 +48,6 @@ export async function downloadKeycloakStaticResources(params: {
48
48
 
49
49
  transformCodebase({
50
50
  srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
51
- destDirPath: pathJoin(resourcesDirPath, resources_common)
51
+ destDirPath: pathJoin(resourcesDirPath, RESOURCES_COMMON)
52
52
  });
53
53
  }
@@ -1,4 +1,4 @@
1
- import { buildForKeycloakMajorVersionEnvName } from "../shared/constants";
1
+ import { BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME } from "../shared/constants";
2
2
  import * as child_process from "child_process";
3
3
  import { Deferred } from "evt/tools/Deferred";
4
4
  import { assert } from "tsafe/assert";
@@ -26,7 +26,7 @@ export async function keycloakifyBuild(params: {
26
26
  cwd: buildContext.projectDirPath,
27
27
  env: {
28
28
  ...process.env,
29
- [buildForKeycloakMajorVersionEnvName]: `${buildForKeycloakMajorVersionNumber}`
29
+ [BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME]: `${buildForKeycloakMajorVersionNumber}`
30
30
  },
31
31
  shell: true
32
32
  });
@@ -2,7 +2,7 @@ import { getBuildContext } from "../shared/buildContext";
2
2
  import { exclude } from "tsafe/exclude";
3
3
  import type { CliCommandOptions as CliCommandOptions_common } from "../main";
4
4
  import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
5
- import { accountV1ThemeName, containerName } from "../shared/constants";
5
+ import { ACCOUNT_V1_THEME_NAME, CONTAINER_NAME } from "../shared/constants";
6
6
  import { SemVer } from "../tools/SemVer";
7
7
  import { assert } from "tsafe/assert";
8
8
  import * as fs from "fs";
@@ -269,7 +269,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
269
269
  fs.copyFileSync(jarFilePath, jarFilePath_cacheDir);
270
270
 
271
271
  try {
272
- child_process.execSync(`docker rm --force ${containerName}`, {
272
+ child_process.execSync(`docker rm --force ${CONTAINER_NAME}`, {
273
273
  stdio: "ignore"
274
274
  });
275
275
  } catch {}
@@ -279,7 +279,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
279
279
  [
280
280
  "run",
281
281
  ...["-p", `${cliCommandOptions.port}:8080`],
282
- ...["--name", containerName],
282
+ ...["--name", CONTAINER_NAME],
283
283
  ...["-e", "KEYCLOAK_ADMIN=admin"],
284
284
  ...["-e", "KEYCLOAK_ADMIN_PASSWORD=admin"],
285
285
  ...(realmJsonFilePath === undefined
@@ -301,10 +301,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
301
301
  pathJoin(
302
302
  buildContext.keycloakifyBuildDirPath,
303
303
  "theme",
304
- accountV1ThemeName
304
+ ACCOUNT_V1_THEME_NAME
305
305
  )
306
306
  )
307
- ? [accountV1ThemeName]
307
+ ? [ACCOUNT_V1_THEME_NAME]
308
308
  : [])
309
309
  ]
310
310
  .map(themeName => ({
@@ -71,10 +71,14 @@ export function createGetKcClsx<ClassKey extends string>(params: {
71
71
  transform: classKey => {
72
72
  assert(is<ClassKey>(classKey));
73
73
 
74
+ const className = classes?.[classKey];
75
+
74
76
  return clsx(
75
77
  classKey,
76
- doUseDefaultCss ? defaultClasses[classKey] : undefined,
77
- classes?.[classKey]
78
+ doUseDefaultCss && !className?.split(" ").includes("CLEAR")
79
+ ? defaultClasses[classKey]
80
+ : undefined,
81
+ className
78
82
  );
79
83
  }
80
84
  });
@@ -1,8 +1,8 @@
1
1
  import "keycloakify/tools/Object.fromEntries";
2
2
  import type { KcContext, Attribute } from "./KcContext";
3
3
  import {
4
- resources_common,
5
- keycloak_resources,
4
+ RESOURCES_COMMON,
5
+ KEYCLOAK_RESOURCES,
6
6
  type LoginThemePageId
7
7
  } from "keycloakify/bin/shared/constants";
8
8
  import { id } from "tsafe/id";
@@ -76,7 +76,7 @@ const attributesByName = Object.fromEntries(
76
76
  ]).map(attribute => [attribute.name, attribute])
77
77
  );
78
78
 
79
- const resourcesPath = `${BASE_URL}${keycloak_resources}/login/resources`;
79
+ const resourcesPath = `${BASE_URL}${KEYCLOAK_RESOURCES}/login/resources`;
80
80
 
81
81
  export const kcContextCommonMock: KcContext.Common = {
82
82
  themeVersion: "0.0.0",
@@ -86,7 +86,7 @@ export const kcContextCommonMock: KcContext.Common = {
86
86
  url: {
87
87
  loginAction: "#",
88
88
  resourcesPath,
89
- resourcesCommonPath: `${resourcesPath}/${resources_common}`,
89
+ resourcesCommonPath: `${resourcesPath}/${RESOURCES_COMMON}`,
90
90
  loginRestartFlowUrl: "#",
91
91
  loginUrl: "#",
92
92
  ssoLoginInOtherTabsUrl: "#"