keycloakify 10.0.0-rc.38 → 10.0.0-rc.39

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 (81) hide show
  1. package/bin/193.index.js +13 -13
  2. package/bin/3.index.js +86 -86
  3. package/bin/322.index.js +595 -0
  4. package/bin/453.index.js +3 -3
  5. package/bin/526.index.js +42 -633
  6. package/bin/538.index.js +68 -57
  7. package/bin/932.index.js +7 -7
  8. package/bin/944.index.js +621 -0
  9. package/bin/961.index.js +5 -5
  10. package/bin/97.index.js +3 -3
  11. package/bin/{21.index.js → 98.index.js} +59 -48
  12. package/bin/main.js +8 -8
  13. package/lib/getKcClsx.js +12 -1
  14. package/lib/getKcClsx.js.map +1 -1
  15. package/login/Fallback.d.ts +1 -0
  16. package/login/Fallback.js.map +1 -1
  17. package/login/UserProfileFormFields.d.ts +1 -0
  18. package/login/UserProfileFormFields.js +1 -3
  19. package/login/UserProfileFormFields.js.map +1 -1
  20. package/login/i18n/i18n.js +1 -1
  21. package/login/pages/IdpReviewUserProfile.d.ts +1 -0
  22. package/login/pages/IdpReviewUserProfile.js +2 -2
  23. package/login/pages/IdpReviewUserProfile.js.map +1 -1
  24. package/login/pages/LoginUpdateProfile.d.ts +1 -0
  25. package/login/pages/LoginUpdateProfile.js +2 -2
  26. package/login/pages/LoginUpdateProfile.js.map +1 -1
  27. package/login/pages/Register.d.ts +1 -0
  28. package/login/pages/Register.js +2 -2
  29. package/login/pages/Register.js.map +1 -1
  30. package/login/pages/UpdateEmail.d.ts +1 -0
  31. package/login/pages/UpdateEmail.js +2 -2
  32. package/login/pages/UpdateEmail.js.map +1 -1
  33. package/package.json +5 -8
  34. package/src/bin/add-story.ts +3 -3
  35. package/src/bin/copy-keycloak-resources-to-public.ts +3 -3
  36. package/src/bin/download-keycloak-default-theme.ts +5 -5
  37. package/src/bin/eject-page.ts +3 -3
  38. package/src/bin/initialize-email-theme.ts +5 -5
  39. package/src/bin/keycloakify/buildJars/buildJar.ts +14 -14
  40. package/src/bin/keycloakify/buildJars/buildJars.ts +8 -8
  41. package/src/bin/keycloakify/buildJars/generatePom.ts +9 -9
  42. package/src/bin/keycloakify/generateFtl/generateFtl.ts +12 -12
  43. package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +7 -7
  44. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +9 -9
  45. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +25 -25
  46. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +8 -8
  47. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +9 -9
  48. package/src/bin/keycloakify/keycloakify.ts +11 -11
  49. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +6 -6
  50. package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +7 -7
  51. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +10 -10
  52. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +13 -13
  53. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +11 -11
  54. package/src/bin/main.ts +2 -2
  55. package/src/bin/shared/{buildOptions.ts → buildContext.ts} +62 -51
  56. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +12 -12
  57. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +7 -7
  58. package/src/bin/shared/downloadKeycloakStaticResources.ts +7 -7
  59. package/src/bin/shared/generateKcGenTs.ts +12 -12
  60. package/src/bin/shared/getThemeSrcDirPath.ts +3 -3
  61. package/src/bin/start-keycloak/appBuild.ts +11 -11
  62. package/src/bin/start-keycloak/keycloakifyBuild.ts +7 -7
  63. package/src/bin/start-keycloak/start-keycloak.ts +34 -22
  64. package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +3 -3
  65. package/src/bin/update-kc-gen.ts +3 -3
  66. package/src/lib/getKcClsx.ts +15 -1
  67. package/src/login/Fallback.tsx +1 -0
  68. package/src/login/UserProfileFormFields.tsx +2 -4
  69. package/src/login/i18n/i18n.tsx +1 -1
  70. package/src/login/pages/IdpReviewUserProfile.tsx +8 -2
  71. package/src/login/pages/LoginUpdateProfile.tsx +8 -2
  72. package/src/login/pages/Register.tsx +8 -2
  73. package/src/login/pages/UpdateEmail.tsx +8 -2
  74. package/src/vite-plugin/vite-plugin.ts +19 -19
  75. package/vite-plugin/index.js +91 -80
  76. package/vite-plugin/vite-plugin.d.ts +3 -3
  77. package/bin/795.index.js +0 -1198
  78. package/lib/isStorybook.d.ts +0 -1
  79. package/lib/isStorybook.js +0 -3
  80. package/lib/isStorybook.js.map +0 -1
  81. package/src/lib/isStorybook.ts +0 -3
@@ -1,34 +1,34 @@
1
- import type { BuildOptions } from "../../shared/buildOptions";
1
+ import type { BuildContext } from "../../shared/buildContext";
2
2
  import { assert } from "tsafe/assert";
3
3
  import {
4
4
  generateSrcMainResourcesForMainTheme,
5
- type BuildOptionsLike as BuildOptionsLike_generateSrcMainResourcesForMainTheme
5
+ type BuildContextLike as BuildContextLike_generateSrcMainResourcesForMainTheme
6
6
  } from "./generateSrcMainResourcesForMainTheme";
7
7
  import { generateSrcMainResourcesForThemeVariant } from "./generateSrcMainResourcesForThemeVariant";
8
8
 
9
- export type BuildOptionsLike = BuildOptionsLike_generateSrcMainResourcesForMainTheme & {
9
+ export type BuildContextLike = BuildContextLike_generateSrcMainResourcesForMainTheme & {
10
10
  themeNames: string[];
11
11
  };
12
12
 
13
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
13
+ assert<BuildContext extends BuildContextLike ? true : false>();
14
14
 
15
15
  export async function generateSrcMainResources(params: {
16
- buildOptions: BuildOptionsLike;
16
+ buildContext: BuildContextLike;
17
17
  }): Promise<void> {
18
- const { buildOptions } = params;
18
+ const { buildContext } = params;
19
19
 
20
- const [themeName, ...themeVariantNames] = buildOptions.themeNames;
20
+ const [themeName, ...themeVariantNames] = buildContext.themeNames;
21
21
 
22
22
  await generateSrcMainResourcesForMainTheme({
23
23
  themeName,
24
- buildOptions
24
+ buildContext
25
25
  });
26
26
 
27
27
  for (const themeVariantName of themeVariantNames) {
28
28
  generateSrcMainResourcesForThemeVariant({
29
29
  themeName,
30
30
  themeVariantName,
31
- buildOptions
31
+ buildContext
32
32
  });
33
33
  }
34
34
  }
@@ -5,7 +5,7 @@ import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
5
5
  import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
6
6
  import {
7
7
  generateFtlFilesCodeFactory,
8
- type BuildOptionsLike as BuildOptionsLike_kcContextExclusionsFtlCode
8
+ type BuildContextLike as BuildContextLike_kcContextExclusionsFtlCode
9
9
  } from "../generateFtl";
10
10
  import {
11
11
  type ThemeType,
@@ -17,18 +17,18 @@ import {
17
17
  accountThemePageIds
18
18
  } from "../../shared/constants";
19
19
  import { isInside } from "../../tools/isInside";
20
- import type { BuildOptions } from "../../shared/buildOptions";
20
+ import type { BuildContext } from "../../shared/buildContext";
21
21
  import { assert, type Equals } from "tsafe/assert";
22
22
  import {
23
23
  downloadKeycloakStaticResources,
24
- type BuildOptionsLike as BuildOptionsLike_downloadKeycloakStaticResources
24
+ type BuildContextLike as BuildContextLike_downloadKeycloakStaticResources
25
25
  } from "../../shared/downloadKeycloakStaticResources";
26
26
  import { readFieldNameUsage } from "./readFieldNameUsage";
27
27
  import { readExtraPagesNames } from "./readExtraPageNames";
28
28
  import { generateMessageProperties } from "./generateMessageProperties";
29
29
  import {
30
30
  bringInAccountV1,
31
- type BuildOptionsLike as BuildOptionsLike_bringInAccountV1
31
+ type BuildContextLike as BuildContextLike_bringInAccountV1
32
32
  } from "./bringInAccountV1";
33
33
  import { getThemeSrcDirPath } from "../../shared/getThemeSrcDirPath";
34
34
  import { rmSync } from "../../tools/fs.rmSync";
@@ -40,36 +40,36 @@ import {
40
40
  import { objectEntries } from "tsafe/objectEntries";
41
41
  import { escapeStringForPropertiesFile } from "../../tools/escapeStringForPropertiesFile";
42
42
 
43
- export type BuildOptionsLike = BuildOptionsLike_kcContextExclusionsFtlCode &
44
- BuildOptionsLike_downloadKeycloakStaticResources &
45
- BuildOptionsLike_bringInAccountV1 & {
43
+ export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
44
+ BuildContextLike_downloadKeycloakStaticResources &
45
+ BuildContextLike_bringInAccountV1 & {
46
46
  bundler: "vite" | "webpack";
47
47
  extraThemeProperties: string[] | undefined;
48
48
  loginThemeResourcesFromKeycloakVersion: string;
49
- reactAppBuildDirPath: string;
49
+ projectBuildDirPath: string;
50
50
  assetsDirPath: string;
51
51
  urlPathname: string | undefined;
52
- reactAppRootDirPath: string;
52
+ projectDirPath: string;
53
53
  keycloakifyBuildDirPath: string;
54
54
  environmentVariables: { name: string; default: string }[];
55
55
  };
56
56
 
57
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
57
+ assert<BuildContext extends BuildContextLike ? true : false>();
58
58
 
59
59
  export async function generateSrcMainResourcesForMainTheme(params: {
60
60
  themeName: string;
61
- buildOptions: BuildOptionsLike;
61
+ buildContext: BuildContextLike;
62
62
  }): Promise<void> {
63
- const { themeName, buildOptions } = params;
63
+ const { themeName, buildContext } = params;
64
64
 
65
65
  const { themeSrcDirPath } = getThemeSrcDirPath({
66
- reactAppRootDirPath: buildOptions.reactAppRootDirPath
66
+ projectDirPath: buildContext.projectDirPath
67
67
  });
68
68
 
69
69
  const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
70
70
  const { themeType } = params;
71
71
  return pathJoin(
72
- buildOptions.keycloakifyBuildDirPath,
72
+ buildContext.keycloakifyBuildDirPath,
73
73
  "src",
74
74
  "main",
75
75
  "resources",
@@ -124,7 +124,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
124
124
  }
125
125
 
126
126
  transformCodebase({
127
- srcDirPath: buildOptions.reactAppBuildDirPath,
127
+ srcDirPath: buildContext.projectBuildDirPath,
128
128
  destDirPath,
129
129
  transformSourceCode: ({ filePath, sourceCode }) => {
130
130
  //NOTE: Prevent cycles, excludes the folder we generated for debug in public/
@@ -132,7 +132,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
132
132
  if (
133
133
  isInside({
134
134
  dirPath: pathJoin(
135
- buildOptions.reactAppBuildDirPath,
135
+ buildContext.projectBuildDirPath,
136
136
  keycloak_resources
137
137
  ),
138
138
  filePath
@@ -163,7 +163,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
163
163
  if (/\.js?$/i.test(filePath)) {
164
164
  const { fixedJsCode } = replaceImportsInJsCode({
165
165
  jsCode: sourceCode.toString("utf8"),
166
- buildOptions
166
+ buildContext
167
167
  });
168
168
 
169
169
  return {
@@ -179,10 +179,10 @@ export async function generateSrcMainResourcesForMainTheme(params: {
179
179
  const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
180
180
  themeName,
181
181
  indexHtmlCode: fs
182
- .readFileSync(pathJoin(buildOptions.reactAppBuildDirPath, "index.html"))
182
+ .readFileSync(pathJoin(buildContext.projectBuildDirPath, "index.html"))
183
183
  .toString("utf8"),
184
184
  cssGlobalsToDefine,
185
- buildOptions,
185
+ buildContext,
186
186
  keycloakifyVersion: readThisNpmPackageVersion(),
187
187
  themeType,
188
188
  fieldNames: readFieldNameUsage({
@@ -242,12 +242,12 @@ export async function generateSrcMainResourcesForMainTheme(params: {
242
242
  case "account":
243
243
  return lastKeycloakVersionWithAccountV1;
244
244
  case "login":
245
- return buildOptions.loginThemeResourcesFromKeycloakVersion;
245
+ return buildContext.loginThemeResourcesFromKeycloakVersion;
246
246
  }
247
247
  })(),
248
248
  themeDirPath: pathResolve(pathJoin(themeTypeDirPath, "..")),
249
249
  themeType,
250
- buildOptions
250
+ buildContext
251
251
  });
252
252
 
253
253
  fs.writeFileSync(
@@ -263,8 +263,8 @@ export async function generateSrcMainResourcesForMainTheme(params: {
263
263
  }
264
264
  assert<Equals<typeof themeType, never>>(false);
265
265
  })()}`,
266
- ...(buildOptions.extraThemeProperties ?? []),
267
- buildOptions.environmentVariables.map(
266
+ ...(buildContext.extraThemeProperties ?? []),
267
+ buildContext.environmentVariables.map(
268
268
  ({ name, default: defaultValue }) =>
269
269
  `${name}=\${env.${name}:${escapeStringForPropertiesFile(defaultValue)}}`
270
270
  )
@@ -291,7 +291,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
291
291
 
292
292
  if (implementedThemeTypes.account) {
293
293
  await bringInAccountV1({
294
- buildOptions
294
+ buildContext
295
295
  });
296
296
  }
297
297
 
@@ -313,7 +313,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
313
313
  }
314
314
 
315
315
  writeMetaInfKeycloakThemes({
316
- keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath,
316
+ keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath,
317
317
  metaInfKeycloakThemes
318
318
  });
319
319
  }
@@ -1,27 +1,27 @@
1
1
  import { join as pathJoin, extname as pathExtname, sep as pathSep } from "path";
2
2
  import { transformCodebase } from "../../tools/transformCodebase";
3
- import type { BuildOptions } from "../../shared/buildOptions";
3
+ import type { BuildContext } from "../../shared/buildContext";
4
4
  import {
5
5
  readMetaInfKeycloakThemes,
6
6
  writeMetaInfKeycloakThemes
7
7
  } from "../../shared/metaInfKeycloakThemes";
8
8
  import { assert } from "tsafe/assert";
9
9
 
10
- export type BuildOptionsLike = {
10
+ export type BuildContextLike = {
11
11
  keycloakifyBuildDirPath: string;
12
12
  };
13
13
 
14
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
14
+ assert<BuildContext extends BuildContextLike ? true : false>();
15
15
 
16
16
  export function generateSrcMainResourcesForThemeVariant(params: {
17
17
  themeName: string;
18
18
  themeVariantName: string;
19
- buildOptions: BuildOptionsLike;
19
+ buildContext: BuildContextLike;
20
20
  }) {
21
- const { themeName, themeVariantName, buildOptions } = params;
21
+ const { themeName, themeVariantName, buildContext } = params;
22
22
 
23
23
  const mainThemeDirPath = pathJoin(
24
- buildOptions.keycloakifyBuildDirPath,
24
+ buildContext.keycloakifyBuildDirPath,
25
25
  "src",
26
26
  "main",
27
27
  "resources",
@@ -58,7 +58,7 @@ export function generateSrcMainResourcesForThemeVariant(params: {
58
58
 
59
59
  {
60
60
  const updatedMetaInfKeycloakThemes = readMetaInfKeycloakThemes({
61
- keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
61
+ keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath
62
62
  });
63
63
 
64
64
  updatedMetaInfKeycloakThemes.themes.push({
@@ -73,7 +73,7 @@ export function generateSrcMainResourcesForThemeVariant(params: {
73
73
  });
74
74
 
75
75
  writeMetaInfKeycloakThemes({
76
- keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath,
76
+ keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath,
77
77
  metaInfKeycloakThemes: updatedMetaInfKeycloakThemes
78
78
  });
79
79
  }
@@ -5,15 +5,15 @@ import {
5
5
  basename as pathBasename
6
6
  } from "path";
7
7
  import { assert } from "tsafe/assert";
8
- import type { BuildOptions } from "../shared/buildOptions";
8
+ import type { BuildContext } from "../shared/buildContext";
9
9
  import { accountV1ThemeName } from "../shared/constants";
10
10
 
11
- export type BuildOptionsLike = {
11
+ export type BuildContextLike = {
12
12
  keycloakifyBuildDirPath: string;
13
13
  themeNames: string[];
14
14
  };
15
15
 
16
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
+ assert<BuildContext extends BuildContextLike ? true : false>();
17
17
 
18
18
  generateStartKeycloakTestingContainer.basename = "start_keycloak_testing_container.sh";
19
19
 
@@ -24,15 +24,15 @@ const keycloakVersion = "24.0.4";
24
24
  export function generateStartKeycloakTestingContainer(params: {
25
25
  jarFilePath: string;
26
26
  doesImplementAccountTheme: boolean;
27
- buildOptions: BuildOptionsLike;
27
+ buildContext: BuildContextLike;
28
28
  }) {
29
- const { jarFilePath, doesImplementAccountTheme, buildOptions } = params;
29
+ const { jarFilePath, doesImplementAccountTheme, buildContext } = params;
30
30
 
31
31
  const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme");
32
32
 
33
33
  fs.writeFileSync(
34
34
  pathJoin(
35
- buildOptions.keycloakifyBuildDirPath,
35
+ buildContext.keycloakifyBuildDirPath,
36
36
  generateStartKeycloakTestingContainer.basename
37
37
  ),
38
38
  Buffer.from(
@@ -41,7 +41,7 @@ export function generateStartKeycloakTestingContainer(params: {
41
41
  "",
42
42
  `docker rm ${containerName} || true`,
43
43
  "",
44
- `cd "${buildOptions.keycloakifyBuildDirPath}"`,
44
+ `cd "${buildContext.keycloakifyBuildDirPath}"`,
45
45
  "",
46
46
  "docker run \\",
47
47
  " -p 8080:8080 \\",
@@ -50,11 +50,11 @@ export function generateStartKeycloakTestingContainer(params: {
50
50
  " -e KEYCLOAK_ADMIN_PASSWORD=admin \\",
51
51
  ` -v "${pathJoin(
52
52
  "$(pwd)",
53
- pathRelative(buildOptions.keycloakifyBuildDirPath, jarFilePath)
53
+ pathRelative(buildContext.keycloakifyBuildDirPath, jarFilePath)
54
54
  )}":"/opt/keycloak/providers/${pathBasename(jarFilePath)}" \\`,
55
55
  [
56
56
  ...(doesImplementAccountTheme ? [accountV1ThemeName] : []),
57
- ...buildOptions.themeNames
57
+ ...buildContext.themeNames
58
58
  ].map(
59
59
  themeName =>
60
60
  ` -v "${pathJoin(
@@ -2,7 +2,7 @@ import { generateSrcMainResources } from "./generateSrcMainResources";
2
2
  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
- import { readBuildOptions } from "../shared/buildOptions";
5
+ import { getBuildContext } from "../shared/buildContext";
6
6
  import { vitePluginSubScriptEnvNames, skipBuildJarsEnvName } from "../shared/constants";
7
7
  import { buildJars } from "./buildJars";
8
8
  import type { CliCommandOptions } from "../main";
@@ -47,7 +47,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
47
47
 
48
48
  const { cliCommandOptions } = params;
49
49
 
50
- const buildOptions = readBuildOptions({ cliCommandOptions });
50
+ const buildContext = getBuildContext({ cliCommandOptions });
51
51
 
52
52
  console.log(
53
53
  [
@@ -55,7 +55,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
55
55
  chalk.green(
56
56
  `Building the keycloak theme in .${pathSep}${pathRelative(
57
57
  process.cwd(),
58
- buildOptions.keycloakifyBuildDirPath
58
+ buildContext.keycloakifyBuildDirPath
59
59
  )} ...`
60
60
  )
61
61
  ].join(" ")
@@ -64,31 +64,31 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
64
64
  const startTime = Date.now();
65
65
 
66
66
  {
67
- if (!fs.existsSync(buildOptions.keycloakifyBuildDirPath)) {
68
- fs.mkdirSync(buildOptions.keycloakifyBuildDirPath, {
67
+ if (!fs.existsSync(buildContext.keycloakifyBuildDirPath)) {
68
+ fs.mkdirSync(buildContext.keycloakifyBuildDirPath, {
69
69
  recursive: true
70
70
  });
71
71
  }
72
72
 
73
73
  fs.writeFileSync(
74
- pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"),
74
+ pathJoin(buildContext.keycloakifyBuildDirPath, ".gitignore"),
75
75
  Buffer.from("*", "utf8")
76
76
  );
77
77
  }
78
78
 
79
- await generateSrcMainResources({ buildOptions });
79
+ await generateSrcMainResources({ buildContext });
80
80
 
81
81
  run_post_build_script: {
82
- if (buildOptions.bundler !== "vite") {
82
+ if (buildContext.bundler !== "vite") {
83
83
  break run_post_build_script;
84
84
  }
85
85
 
86
86
  child_process.execSync("npx vite", {
87
- cwd: buildOptions.reactAppRootDirPath,
87
+ cwd: buildContext.projectDirPath,
88
88
  env: {
89
89
  ...process.env,
90
90
  [vitePluginSubScriptEnvNames.runPostBuildScript]:
91
- JSON.stringify(buildOptions)
91
+ JSON.stringify(buildContext)
92
92
  }
93
93
  });
94
94
  }
@@ -98,7 +98,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
98
98
  break build_jars;
99
99
  }
100
100
 
101
- await buildJars({ buildOptions });
101
+ await buildJars({ buildContext });
102
102
  }
103
103
 
104
104
  console.log(
@@ -1,13 +1,13 @@
1
1
  import * as crypto from "crypto";
2
- import type { BuildOptions } from "../../shared/buildOptions";
2
+ import type { BuildContext } from "../../shared/buildContext";
3
3
  import { assert } from "tsafe/assert";
4
4
  import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
5
5
 
6
- export type BuildOptionsLike = {
6
+ export type BuildContextLike = {
7
7
  urlPathname: string | undefined;
8
8
  };
9
9
 
10
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
10
+ assert<BuildContext extends BuildContextLike ? true : false>();
11
11
 
12
12
  export function replaceImportsInCssCode(params: { cssCode: string }): {
13
13
  fixedCssCode: string;
@@ -44,11 +44,11 @@ export function replaceImportsInCssCode(params: { cssCode: string }): {
44
44
 
45
45
  export function generateCssCodeToDefineGlobals(params: {
46
46
  cssGlobalsToDefine: Record<string, string>;
47
- buildOptions: BuildOptionsLike;
47
+ buildContext: BuildContextLike;
48
48
  }): {
49
49
  cssCodeToPrependInHead: string;
50
50
  } {
51
- const { cssGlobalsToDefine, buildOptions } = params;
51
+ const { cssGlobalsToDefine, buildContext } = params;
52
52
 
53
53
  return {
54
54
  cssCodeToPrependInHead: [
@@ -59,7 +59,7 @@ export function generateCssCodeToDefineGlobals(params: {
59
59
  `--${cssVariableName}:`,
60
60
  cssGlobalsToDefine[cssVariableName].replace(
61
61
  new RegExp(
62
- `url\\(${(buildOptions.urlPathname ?? "/").replace(
62
+ `url\\(${(buildContext.urlPathname ?? "/").replace(
63
63
  /\//g,
64
64
  "\\/"
65
65
  )}`,
@@ -1,25 +1,25 @@
1
- import type { BuildOptions } from "../../shared/buildOptions";
1
+ import type { BuildContext } from "../../shared/buildContext";
2
2
  import { assert } from "tsafe/assert";
3
3
  import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
4
4
 
5
- export type BuildOptionsLike = {
5
+ export type BuildContextLike = {
6
6
  urlPathname: string | undefined;
7
7
  };
8
8
 
9
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
9
+ assert<BuildContext extends BuildContextLike ? true : false>();
10
10
 
11
11
  export function replaceImportsInInlineCssCode(params: {
12
12
  cssCode: string;
13
- buildOptions: BuildOptionsLike;
13
+ buildContext: BuildContextLike;
14
14
  }): {
15
15
  fixedCssCode: string;
16
16
  } {
17
- const { cssCode, buildOptions } = params;
17
+ const { cssCode, buildContext } = params;
18
18
 
19
19
  const fixedCssCode = cssCode.replace(
20
- buildOptions.urlPathname === undefined
20
+ buildContext.urlPathname === undefined
21
21
  ? /url\(["']?\/([^/][^)"']+)["']?\)/g
22
- : new RegExp(`url\\(["']?${buildOptions.urlPathname}([^)"']+)["']?\\)`, "g"),
22
+ : new RegExp(`url\\(["']?${buildContext.urlPathname}([^)"']+)["']?\\)`, "g"),
23
23
  (...[, group]) =>
24
24
  `url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/${group})`
25
25
  );
@@ -1,38 +1,38 @@
1
1
  import { assert } from "tsafe/assert";
2
- import type { BuildOptions } from "../../../shared/buildOptions";
2
+ import type { BuildContext } from "../../../shared/buildContext";
3
3
  import { replaceImportsInJsCode_vite } from "./vite";
4
4
  import { replaceImportsInJsCode_webpack } from "./webpack";
5
5
  import * as fs from "fs";
6
6
 
7
- export type BuildOptionsLike = {
8
- reactAppBuildDirPath: string;
7
+ export type BuildContextLike = {
8
+ projectBuildDirPath: string;
9
9
  assetsDirPath: string;
10
10
  urlPathname: string | undefined;
11
11
  bundler: "vite" | "webpack";
12
12
  };
13
13
 
14
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
14
+ assert<BuildContext extends BuildContextLike ? true : false>();
15
15
 
16
16
  export function replaceImportsInJsCode(params: {
17
17
  jsCode: string;
18
- buildOptions: BuildOptionsLike;
18
+ buildContext: BuildContextLike;
19
19
  }) {
20
- const { jsCode, buildOptions } = params;
20
+ const { jsCode, buildContext } = params;
21
21
 
22
22
  const { fixedJsCode } = (() => {
23
- switch (buildOptions.bundler) {
23
+ switch (buildContext.bundler) {
24
24
  case "vite":
25
25
  return replaceImportsInJsCode_vite({
26
26
  jsCode,
27
- buildOptions,
27
+ buildContext,
28
28
  basenameOfAssetsFiles: readAssetsDirSync({
29
- assetsDirPath: params.buildOptions.assetsDirPath
29
+ assetsDirPath: params.buildContext.assetsDirPath
30
30
  })
31
31
  });
32
32
  case "webpack":
33
33
  return replaceImportsInJsCode_webpack({
34
34
  jsCode,
35
- buildOptions
35
+ buildContext
36
36
  });
37
37
  }
38
38
  })();
@@ -3,21 +3,21 @@ import {
3
3
  basenameOfTheKeycloakifyResourcesDir
4
4
  } from "../../../shared/constants";
5
5
  import { assert } from "tsafe/assert";
6
- import type { BuildOptions } from "../../../shared/buildOptions";
6
+ import type { BuildContext } from "../../../shared/buildContext";
7
7
  import * as nodePath from "path";
8
8
  import { replaceAll } from "../../../tools/String.prototype.replaceAll";
9
9
 
10
- export type BuildOptionsLike = {
11
- reactAppBuildDirPath: string;
10
+ export type BuildContextLike = {
11
+ projectBuildDirPath: string;
12
12
  assetsDirPath: string;
13
13
  urlPathname: string | undefined;
14
14
  };
15
15
 
16
- assert<BuildOptions extends BuildOptionsLike ? true : false>();
16
+ assert<BuildContext extends BuildContextLike ? true : false>();
17
17
 
18
18
  export function replaceImportsInJsCode_vite(params: {
19
19
  jsCode: string;
20
- buildOptions: BuildOptionsLike;
20
+ buildContext: BuildContextLike;
21
21
  basenameOfAssetsFiles: string[];
22
22
  systemType?: "posix" | "win32";
23
23
  }): {
@@ -25,7 +25,7 @@ export function replaceImportsInJsCode_vite(params: {
25
25
  } {
26
26
  const {
27
27
  jsCode,
28
- buildOptions,
28
+ buildContext,
29
29
  basenameOfAssetsFiles,
30
30
  systemType = nodePath.sep === "/" ? "posix" : "win32"
31
31
  } = params;
@@ -35,11 +35,11 @@ export function replaceImportsInJsCode_vite(params: {
35
35
  let fixedJsCode = jsCode;
36
36
 
37
37
  replace_base_javacript_import: {
38
- if (buildOptions.urlPathname === undefined) {
38
+ if (buildContext.urlPathname === undefined) {
39
39
  break replace_base_javacript_import;
40
40
  }
41
41
  // Optimization
42
- if (!jsCode.includes(buildOptions.urlPathname)) {
42
+ if (!jsCode.includes(buildContext.urlPathname)) {
43
43
  break replace_base_javacript_import;
44
44
  }
45
45
 
@@ -47,7 +47,7 @@ export function replaceImportsInJsCode_vite(params: {
47
47
  fixedJsCode = fixedJsCode.replace(
48
48
  new RegExp(
49
49
  `([\\w\\$][\\w\\d\\$]*)=function\\(([\\w\\$][\\w\\d\\$]*)\\)\\{return"${replaceAll(
50
- buildOptions.urlPathname,
50
+ buildContext.urlPathname,
51
51
  "/",
52
52
  "\\/"
53
53
  )}"\\+\\2\\}`,
@@ -62,15 +62,15 @@ export function replaceImportsInJsCode_vite(params: {
62
62
  // Example: "assets/ or "foo/bar/"
63
63
  const staticDir = (() => {
64
64
  let out = pathRelative(
65
- buildOptions.reactAppBuildDirPath,
66
- buildOptions.assetsDirPath
65
+ buildContext.projectBuildDirPath,
66
+ buildContext.assetsDirPath
67
67
  );
68
68
 
69
69
  out = replaceAll(out, pathSep, "/") + "/";
70
70
 
71
71
  if (out === "/") {
72
72
  throw new Error(
73
- `The assetsDirPath must be a subdirectory of reactAppBuildDirPath`
73
+ `The assetsDirPath must be a subdirectory of projectBuildDirPath`
74
74
  );
75
75
  }
76
76
 
@@ -93,7 +93,7 @@ export function replaceImportsInJsCode_vite(params: {
93
93
 
94
94
  fixedJsCode = replaceAll(
95
95
  fixedJsCode,
96
- `"${buildOptions.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
96
+ `"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
97
97
  `(window.${nameOfTheGlobal}.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
98
98
  );
99
99
  });