keycloakify 10.0.0-rc.64 → 10.0.0-rc.66

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 (49) hide show
  1. package/account/KcContext/KcContext.d.ts +1 -0
  2. package/account/KcContext/KcContext.js.map +1 -1
  3. package/account/KcContext/kcContextMocks.js +2 -1
  4. package/account/KcContext/kcContextMocks.js.map +1 -1
  5. package/account/pages/Totp.js +2 -7
  6. package/account/pages/Totp.js.map +1 -1
  7. package/bin/193.index.js +0 -501
  8. package/bin/246.index.js +371 -75118
  9. package/bin/363.index.js +36 -665
  10. package/bin/453.index.js +603 -23
  11. package/bin/{890.index.js → 456.index.js} +1831 -3
  12. package/bin/490.index.js +75195 -0
  13. package/bin/526.index.js +311 -166
  14. package/bin/538.index.js +1 -509
  15. package/bin/{240.index.js → 751.index.js} +306 -322
  16. package/bin/772.index.js +1 -1
  17. package/bin/837.index.js +787 -0
  18. package/bin/932.index.js +1 -574
  19. package/bin/97.index.js +594 -14
  20. package/bin/main.js +8 -8
  21. package/bin/shared/buildContext.d.ts +16 -0
  22. package/bin/shared/constants.d.ts +1 -1
  23. package/bin/shared/constants.js +1 -1
  24. package/bin/shared/constants.js.map +1 -1
  25. package/package.json +5 -9
  26. package/src/account/KcContext/KcContext.ts +1 -0
  27. package/src/account/KcContext/kcContextMocks.ts +2 -1
  28. package/src/account/pages/Totp.tsx +1 -7
  29. package/src/bin/add-story.ts +1 -6
  30. package/src/bin/eject-page.ts +7 -8
  31. package/src/bin/initialize-email-theme.ts +1 -6
  32. package/src/bin/keycloakify/buildJars/buildJars.ts +23 -49
  33. package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +8 -6
  34. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +15 -20
  35. package/src/bin/keycloakify/keycloakify.ts +6 -8
  36. package/src/bin/shared/buildContext.ts +434 -42
  37. package/src/bin/shared/constants.ts +2 -1
  38. package/src/bin/shared/downloadKeycloakDefaultTheme.ts +135 -108
  39. package/src/bin/shared/generateKcGenTs.ts +2 -6
  40. package/src/bin/start-keycloak/keycloakifyBuild.ts +4 -4
  41. package/src/bin/start-keycloak/start-keycloak.ts +40 -83
  42. package/src/vite-plugin/vite-plugin.ts +5 -4
  43. package/vite-plugin/index.js +410 -187
  44. package/bin/480.index.js +0 -466
  45. package/bin/818.index.js +0 -1802
  46. package/bin/827.index.js +0 -1094
  47. package/src/bin/shared/getImplementedThemeTypes.ts +0 -23
  48. package/src/bin/shared/getJarFileBasename.ts +0 -11
  49. package/src/bin/shared/getThemeSrcDirPath.ts +0 -62
package/bin/main.js CHANGED
@@ -7666,7 +7666,7 @@ var _DefaultRenderer = class _DefaultRenderer {
7666
7666
  async render() {
7667
7667
  const { createLogUpdate } = await Promise.all(/* import() */[__nccwpck_require__.e(509), __nccwpck_require__.e(772)]).then(__nccwpck_require__.bind(__nccwpck_require__, 41772));
7668
7668
  const { default: truncate } = await Promise.all(/* import() */[__nccwpck_require__.e(509), __nccwpck_require__.e(420)]).then(__nccwpck_require__.bind(__nccwpck_require__, 32420));
7669
- const { default: wrap } = await Promise.all(/* import() */[__nccwpck_require__.e(509), __nccwpck_require__.e(480)]).then(__nccwpck_require__.bind(__nccwpck_require__, 19246));
7669
+ const { default: wrap } = await Promise.all(/* import() */[__nccwpck_require__.e(509), __nccwpck_require__.e(246)]).then(__nccwpck_require__.bind(__nccwpck_require__, 19246));
7670
7670
  this.updater = createLogUpdate(this.logger.process.stdout);
7671
7671
  this.truncate = truncate;
7672
7672
  this.wrap = wrap;
@@ -9213,7 +9213,7 @@ program
9213
9213
  .task({
9214
9214
  skip,
9215
9215
  handler: async (cliCommandOptions) => {
9216
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(246), __nccwpck_require__.e(240), __nccwpck_require__.e(363)]).then(__nccwpck_require__.bind(__nccwpck_require__, 52363));
9216
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(490), __nccwpck_require__.e(751), __nccwpck_require__.e(837), __nccwpck_require__.e(363)]).then(__nccwpck_require__.bind(__nccwpck_require__, 52363));
9217
9217
  await command({ cliCommandOptions });
9218
9218
  }
9219
9219
  });
@@ -9261,7 +9261,7 @@ program
9261
9261
  .task({
9262
9262
  skip,
9263
9263
  handler: async (cliCommandOptions) => {
9264
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(430), __nccwpck_require__.e(180), __nccwpck_require__.e(36), __nccwpck_require__.e(240), __nccwpck_require__.e(526)]).then(__nccwpck_require__.bind(__nccwpck_require__, 80526));
9264
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(430), __nccwpck_require__.e(180), __nccwpck_require__.e(36), __nccwpck_require__.e(751), __nccwpck_require__.e(526)]).then(__nccwpck_require__.bind(__nccwpck_require__, 80526));
9265
9265
  await command({ cliCommandOptions });
9266
9266
  }
9267
9267
  });
@@ -9273,7 +9273,7 @@ program
9273
9273
  .task({
9274
9274
  skip,
9275
9275
  handler: async (cliCommandOptions) => {
9276
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(827), __nccwpck_require__.e(453)]).then(__nccwpck_require__.bind(__nccwpck_require__, 93453));
9276
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(751), __nccwpck_require__.e(453)]).then(__nccwpck_require__.bind(__nccwpck_require__, 93453));
9277
9277
  await command({ cliCommandOptions });
9278
9278
  }
9279
9279
  });
@@ -9285,7 +9285,7 @@ program
9285
9285
  .task({
9286
9286
  skip,
9287
9287
  handler: async (cliCommandOptions) => {
9288
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(827), __nccwpck_require__.e(97)]).then(__nccwpck_require__.bind(__nccwpck_require__, 98097));
9288
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(751), __nccwpck_require__.e(97)]).then(__nccwpck_require__.bind(__nccwpck_require__, 98097));
9289
9289
  await command({ cliCommandOptions });
9290
9290
  }
9291
9291
  });
@@ -9297,7 +9297,7 @@ program
9297
9297
  .task({
9298
9298
  skip,
9299
9299
  handler: async (cliCommandOptions) => {
9300
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(180), __nccwpck_require__.e(240), __nccwpck_require__.e(932)]).then(__nccwpck_require__.bind(__nccwpck_require__, 16932));
9300
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(180), __nccwpck_require__.e(751), __nccwpck_require__.e(837), __nccwpck_require__.e(932)]).then(__nccwpck_require__.bind(__nccwpck_require__, 16932));
9301
9301
  await command({ cliCommandOptions });
9302
9302
  }
9303
9303
  });
@@ -9309,7 +9309,7 @@ program
9309
9309
  .task({
9310
9310
  skip,
9311
9311
  handler: async (cliCommandOptions) => {
9312
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(240), __nccwpck_require__.e(193)]).then(__nccwpck_require__.bind(__nccwpck_require__, 23193));
9312
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(430), __nccwpck_require__.e(525), __nccwpck_require__.e(751), __nccwpck_require__.e(837), __nccwpck_require__.e(193)]).then(__nccwpck_require__.bind(__nccwpck_require__, 23193));
9313
9313
  await command({ cliCommandOptions });
9314
9314
  }
9315
9315
  });
@@ -9321,7 +9321,7 @@ program
9321
9321
  .task({
9322
9322
  skip,
9323
9323
  handler: async (cliCommandOptions) => {
9324
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(890), __nccwpck_require__.e(818), __nccwpck_require__.e(538)]).then(__nccwpck_require__.bind(__nccwpck_require__, 1538));
9324
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(456), __nccwpck_require__.e(751), __nccwpck_require__.e(538)]).then(__nccwpck_require__.bind(__nccwpck_require__, 1538));
9325
9325
  await command({ cliCommandOptions });
9326
9326
  }
9327
9327
  });
@@ -1,4 +1,6 @@
1
1
  import type { CliCommandOptions } from "../main";
2
+ import type { KeycloakVersionRange } from "./KeycloakVersionRange";
3
+ import { type ThemeType } from "./constants";
2
4
  export type BuildContext = {
3
5
  bundler: "vite" | "webpack";
4
6
  themeVersion: string;
@@ -23,6 +25,12 @@ export type BuildContext = {
23
25
  name: string;
24
26
  default: string;
25
27
  }[];
28
+ themeSrcDirPath: string;
29
+ recordIsImplementedByThemeType: Readonly<Record<ThemeType | "email", boolean>>;
30
+ jarTargets: {
31
+ keycloakVersionRange: KeycloakVersionRange;
32
+ jarFileBasename: string;
33
+ }[];
26
34
  };
27
35
  export type BuildOptions = {
28
36
  themeName?: string | string[];
@@ -36,7 +44,15 @@ export type BuildOptions = {
36
44
  loginThemeResourcesFromKeycloakVersion?: string;
37
45
  keycloakifyBuildDirPath?: string;
38
46
  kcContextExclusionsFtl?: string;
47
+ keycloakVersionTargets?: BuildOptions.KeycloakVersionTargets;
39
48
  };
49
+ export declare namespace BuildOptions {
50
+ type KeycloakVersionTargets = ({
51
+ hasAccountTheme: true;
52
+ } & Record<KeycloakVersionRange.WithAccountTheme, string | boolean>) | ({
53
+ hasAccountTheme: false;
54
+ } & Record<KeycloakVersionRange.WithoutAccountTheme, string | boolean>);
55
+ }
40
56
  export type ResolvedViteConfig = {
41
57
  buildDir: string;
42
58
  publicDir: string;
@@ -10,7 +10,7 @@ export declare const vitePluginSubScriptEnvNames: {
10
10
  readonly runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT";
11
11
  readonly resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG";
12
12
  };
13
- export declare const onlyBuildJarFileBasenameEnvName = "KEYCLOAKIFY_ONLY_BUILD_JAR_FILE_BASENAME";
13
+ export declare const buildForKeycloakMajorVersionEnvName = "KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
14
14
  export declare const loginThemePageIds: readonly ["login.ftl", "login-username.ftl", "login-password.ftl", "webauthn-authenticate.ftl", "webauthn-register.ftl", "register.ftl", "info.ftl", "error.ftl", "login-reset-password.ftl", "login-verify-email.ftl", "terms.ftl", "login-oauth2-device-verify-user-code.ftl", "login-oauth-grant.ftl", "login-otp.ftl", "login-update-profile.ftl", "login-update-password.ftl", "login-idp-link-confirm.ftl", "login-idp-link-email.ftl", "login-page-expired.ftl", "login-config-totp.ftl", "logout-confirm.ftl", "idp-review-user-profile.ftl", "update-email.ftl", "select-authenticator.ftl", "saml-post-form.ftl", "delete-credential.ftl", "code.ftl", "delete-account-confirm.ftl", "frontchannel-logout.ftl", "login-recovery-authn-code-config.ftl", "login-recovery-authn-code-input.ftl", "login-reset-otp.ftl", "login-x509-info.ftl", "webauthn-error.ftl"];
15
15
  export declare const accountThemePageIds: readonly ["password.ftl", "account.ftl", "sessions.ftl", "totp.ftl", "applications.ftl", "log.ftl", "federatedIdentity.ftl"];
16
16
  export type LoginThemePageId = (typeof loginThemePageIds)[number];
@@ -9,7 +9,7 @@ export const vitePluginSubScriptEnvNames = {
9
9
  runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
10
10
  resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
11
11
  };
12
- export const onlyBuildJarFileBasenameEnvName = "KEYCLOAKIFY_ONLY_BUILD_JAR_FILE_BASENAME";
12
+ export const buildForKeycloakMajorVersionEnvName = "KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
13
13
  export const loginThemePageIds = [
14
14
  "login.ftl",
15
15
  "login-username.ftl",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/bin/shared/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sDAAsD,GAC/D,yCAAyC,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,MAAM,CAAC,MAAM,gCAAgC,GAAG,QAAQ,CAAC;AACzD,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAO,CAAC;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAI/C,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACvC,kBAAkB,EAAE,mCAAmC;IACvD,iBAAiB,EAAE,iCAAiC;CAC9C,CAAC;AAEX,MAAM,CAAC,MAAM,+BAA+B,GAAG,0CAA0C,CAAC;AAE1F,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,uBAAuB;IACvB,cAAc;IACd,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,0CAA0C;IAC1C,uBAAuB;IACvB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,oBAAoB;IACpB,6BAA6B;IAC7B,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,uBAAuB;IACvB,UAAU;IACV,4BAA4B;IAC5B,yBAAyB;IACzB,sCAAsC;IACtC,qCAAqC;IACrC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACd,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,cAAc;IACd,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,uBAAuB;CACjB,CAAC;AAKX,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/bin/shared/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sDAAsD,GAC/D,yCAAyC,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,MAAM,CAAC,MAAM,gCAAgC,GAAG,QAAQ,CAAC;AACzD,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAO,CAAC;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAI/C,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACvC,kBAAkB,EAAE,mCAAmC;IACvD,iBAAiB,EAAE,iCAAiC;CAC9C,CAAC;AAEX,MAAM,CAAC,MAAM,mCAAmC,GAC5C,8CAA8C,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,uBAAuB;IACvB,cAAc;IACd,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,0CAA0C;IAC1C,uBAAuB;IACvB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,oBAAoB;IACpB,6BAA6B;IAC7B,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,uBAAuB;IACvB,UAAU;IACV,4BAA4B;IAC5B,yBAAyB;IACzB,sCAAsC;IACtC,qCAAqC;IACrC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACd,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,cAAc;IACd,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,uBAAuB;CACjB,CAAC;AAKX,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "10.0.0-rc.64",
3
+ "version": "10.0.0-rc.66",
4
4
  "description": "Create Keycloak themes using React",
5
5
  "repository": {
6
6
  "type": "git",
@@ -491,9 +491,6 @@
491
491
  "src/bin/shared/downloadKeycloakDefaultTheme.ts",
492
492
  "src/bin/shared/downloadKeycloakStaticResources.ts",
493
493
  "src/bin/shared/generateKcGenTs.ts",
494
- "src/bin/shared/getImplementedThemeTypes.ts",
495
- "src/bin/shared/getJarFileBasename.ts",
496
- "src/bin/shared/getThemeSrcDirPath.ts",
497
494
  "src/bin/shared/metaInfKeycloakThemes.ts",
498
495
  "src/bin/shared/promptKeycloakVersion.ts",
499
496
  "src/bin/start-keycloak/appBuild.ts",
@@ -772,22 +769,21 @@
772
769
  "bin/main.js",
773
770
  "bin/180.index.js",
774
771
  "bin/193.index.js",
775
- "bin/240.index.js",
776
772
  "bin/246.index.js",
777
773
  "bin/36.index.js",
778
774
  "bin/363.index.js",
779
775
  "bin/420.index.js",
780
776
  "bin/430.index.js",
781
777
  "bin/453.index.js",
782
- "bin/480.index.js",
778
+ "bin/456.index.js",
779
+ "bin/490.index.js",
783
780
  "bin/509.index.js",
784
781
  "bin/525.index.js",
785
782
  "bin/526.index.js",
786
783
  "bin/538.index.js",
784
+ "bin/751.index.js",
787
785
  "bin/772.index.js",
788
- "bin/818.index.js",
789
- "bin/827.index.js",
790
- "bin/890.index.js",
786
+ "bin/837.index.js",
791
787
  "bin/932.index.js",
792
788
  "bin/97.index.js",
793
789
  "bin/shared/constants.js",
@@ -166,6 +166,7 @@ export declare namespace KcContext {
166
166
  algorithm: "HmacSHA1" | "HmacSHA256" | "HmacSHA512";
167
167
  digits: number;
168
168
  lookAheadWindow: number;
169
+ getAlgorithmKey: () => string;
169
170
  } & (
170
171
  | {
171
172
  type: "totp";
@@ -148,7 +148,8 @@ export const kcContextMocks: KcContext[] = [
148
148
  digits: 6,
149
149
  lookAheadWindow: 1,
150
150
  type: "totp",
151
- period: 30
151
+ period: 30,
152
+ getAlgorithmKey: () => "SHA1"
152
153
  }
153
154
  },
154
155
  mode: "qr",
@@ -16,12 +16,6 @@ export default function Totp(props: PageProps<Extract<KcContext, { pageId: "totp
16
16
 
17
17
  const { msg, msgStr, advancedMsg } = i18n;
18
18
 
19
- const algToKeyUriAlg: Record<(typeof kcContext)["totp"]["policy"]["algorithm"], string> = {
20
- HmacSHA1: "SHA1",
21
- HmacSHA256: "SHA256",
22
- HmacSHA512: "SHA512"
23
- };
24
-
25
19
  return (
26
20
  <Template {...{ kcContext, i18n, doUseDefaultCss, classes }} active="totp">
27
21
  <>
@@ -100,7 +94,7 @@ export default function Totp(props: PageProps<Extract<KcContext, { pageId: "totp
100
94
  {msg("totpType")}: {msg(`totp.${totp.policy.type}`)}
101
95
  </li>
102
96
  <li id="kc-totp-algorithm">
103
- {msg("totpAlgorithm")}: {algToKeyUriAlg?.[totp.policy.algorithm] ?? totp.policy.algorithm}
97
+ {msg("totpAlgorithm")}: {totp.policy.getAlgorithmKey()}
104
98
  </li>
105
99
  <li id="kc-totp-digits">
106
100
  {msg("totpDigits")}: {totp.policy.digits}
@@ -13,7 +13,6 @@ import * as fs from "fs";
13
13
  import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
14
14
  import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
15
15
  import { assert, Equals } from "tsafe/assert";
16
- import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
17
16
  import type { CliCommandOptions } from "./main";
18
17
  import { getBuildContext } from "./shared/buildContext";
19
18
  import chalk from "chalk";
@@ -53,17 +52,13 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
53
52
 
54
53
  console.log(`→ ${pageId}`);
55
54
 
56
- const { themeSrcDirPath } = getThemeSrcDirPath({
57
- projectDirPath: buildContext.projectDirPath
58
- });
59
-
60
55
  const componentBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
61
56
  /ftl$/,
62
57
  "stories.tsx"
63
58
  );
64
59
 
65
60
  const targetFilePath = pathJoin(
66
- themeSrcDirPath,
61
+ buildContext.themeSrcDirPath,
67
62
  themeType,
68
63
  "pages",
69
64
  componentBasename
@@ -15,7 +15,6 @@ import * as fs from "fs";
15
15
  import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
16
16
  import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
17
17
  import { assert, Equals } from "tsafe/assert";
18
- import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
19
18
  import type { CliCommandOptions } from "./main";
20
19
  import { getBuildContext } from "./shared/buildContext";
21
20
  import chalk from "chalk";
@@ -68,10 +67,6 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
68
67
 
69
68
  console.log(`→ ${pageIdOrComponent}`);
70
69
 
71
- const { themeSrcDirPath } = getThemeSrcDirPath({
72
- projectDirPath: buildContext.projectDirPath
73
- });
74
-
75
70
  const componentBasename = (() => {
76
71
  if (pageIdOrComponent === templateValue) {
77
72
  return "Template.tsx";
@@ -96,7 +91,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
96
91
  })();
97
92
 
98
93
  const targetFilePath = pathJoin(
99
- themeSrcDirPath,
94
+ buildContext.themeSrcDirPath,
100
95
  themeType,
101
96
  pagesOrDot,
102
97
  componentBasename
@@ -149,7 +144,11 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
149
144
  break edit_KcApp;
150
145
  }
151
146
 
152
- const kcAppTsxPath = pathJoin(themeSrcDirPath, themeType, "KcPage.tsx");
147
+ const kcAppTsxPath = pathJoin(
148
+ buildContext.themeSrcDirPath,
149
+ themeType,
150
+ "KcPage.tsx"
151
+ );
153
152
 
154
153
  const kcAppTsxCode = fs.readFileSync(kcAppTsxPath).toString("utf8");
155
154
 
@@ -199,7 +198,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
199
198
  `${chalk.bold(
200
199
  pathJoin(
201
200
  ".",
202
- pathRelative(process.cwd(), themeSrcDirPath),
201
+ pathRelative(process.cwd(), buildContext.themeSrcDirPath),
203
202
  themeType,
204
203
  "KcPage.tsx"
205
204
  )
@@ -4,7 +4,6 @@ import { transformCodebase } from "./tools/transformCodebase";
4
4
  import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
5
5
  import { getBuildContext } from "./shared/buildContext";
6
6
  import * as fs from "fs";
7
- import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
8
7
  import type { CliCommandOptions } from "./main";
9
8
 
10
9
  export async function command(params: { cliCommandOptions: CliCommandOptions }) {
@@ -12,11 +11,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
12
11
 
13
12
  const buildContext = getBuildContext({ cliCommandOptions });
14
13
 
15
- const { themeSrcDirPath } = getThemeSrcDirPath({
16
- projectDirPath: buildContext.projectDirPath
17
- });
18
-
19
- const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
14
+ const emailThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "email");
20
15
 
21
16
  if (fs.existsSync(emailThemeSrcDirPath)) {
22
17
  console.warn(
@@ -1,5 +1,4 @@
1
1
  import { assert } from "tsafe/assert";
2
- import { exclude } from "tsafe/exclude";
3
2
  import {
4
3
  keycloakAccountV1Versions,
5
4
  keycloakThemeAdditionalInfoExtensionVersions
@@ -7,32 +6,29 @@ import {
7
6
  import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
8
7
  import { buildJar, BuildContextLike as BuildContextLike_buildJar } from "./buildJar";
9
8
  import type { BuildContext } from "../../shared/buildContext";
10
- import { getJarFileBasename } from "../../shared/getJarFileBasename";
11
- import { getImplementedThemeTypes } from "../../shared/getImplementedThemeTypes";
12
9
 
13
10
  export type BuildContextLike = BuildContextLike_buildJar & {
14
11
  projectDirPath: string;
15
12
  keycloakifyBuildDirPath: string;
13
+ recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
14
+ jarTargets: BuildContext["jarTargets"];
16
15
  };
17
16
 
18
17
  assert<BuildContext extends BuildContextLike ? true : false>();
19
18
 
20
19
  export async function buildJars(params: {
21
20
  resourcesDirPath: string;
22
- onlyBuildJarFileBasename: string | undefined;
23
21
  buildContext: BuildContextLike;
24
22
  }): Promise<void> {
25
- const { onlyBuildJarFileBasename, resourcesDirPath, buildContext } = params;
23
+ const { resourcesDirPath, buildContext } = params;
26
24
 
27
- const doesImplementAccountTheme = getImplementedThemeTypes({
28
- projectDirPath: buildContext.projectDirPath
29
- }).implementedThemeTypes.account;
25
+ const doesImplementAccountTheme = buildContext.recordIsImplementedByThemeType.account;
30
26
 
31
27
  await Promise.all(
32
28
  keycloakAccountV1Versions
33
29
  .map(keycloakAccountV1Version =>
34
- keycloakThemeAdditionalInfoExtensionVersions
35
- .map(keycloakThemeAdditionalInfoExtensionVersion => {
30
+ keycloakThemeAdditionalInfoExtensionVersions.map(
31
+ keycloakThemeAdditionalInfoExtensionVersion => {
36
32
  const keycloakVersionRange = getKeycloakVersionRangeForJar({
37
33
  doesImplementAccountTheme,
38
34
  keycloakAccountV1Version,
@@ -43,48 +39,26 @@ export async function buildJars(params: {
43
39
  return undefined;
44
40
  }
45
41
 
46
- return {
47
- keycloakThemeAdditionalInfoExtensionVersion,
48
- keycloakVersionRange
49
- };
50
- })
51
- .filter(exclude(undefined))
52
- .map(
53
- ({
54
- keycloakThemeAdditionalInfoExtensionVersion,
55
- keycloakVersionRange
56
- }) => {
57
- const { jarFileBasename } = getJarFileBasename({
58
- keycloakVersionRange
59
- });
42
+ const jarTarget = buildContext.jarTargets.find(
43
+ jarTarget =>
44
+ jarTarget.keycloakVersionRange === keycloakVersionRange
45
+ );
60
46
 
61
- if (
62
- onlyBuildJarFileBasename !== undefined &&
63
- onlyBuildJarFileBasename !== jarFileBasename
64
- ) {
65
- return undefined;
66
- }
67
-
68
- return {
69
- keycloakThemeAdditionalInfoExtensionVersion,
70
- jarFileBasename
71
- };
47
+ if (jarTarget === undefined) {
48
+ return undefined;
72
49
  }
73
- )
74
- .filter(exclude(undefined))
75
- .map(
76
- ({
50
+
51
+ const { jarFileBasename } = jarTarget;
52
+
53
+ return buildJar({
54
+ jarFileBasename,
55
+ keycloakAccountV1Version,
77
56
  keycloakThemeAdditionalInfoExtensionVersion,
78
- jarFileBasename
79
- }) =>
80
- buildJar({
81
- jarFileBasename,
82
- keycloakAccountV1Version,
83
- keycloakThemeAdditionalInfoExtensionVersion,
84
- resourcesDirPath,
85
- buildContext
86
- })
87
- )
57
+ resourcesDirPath,
58
+ buildContext
59
+ });
60
+ }
61
+ )
88
62
  )
89
63
  .flat()
90
64
  );
@@ -305,12 +305,14 @@ function decodeHtmlEntities(htmlStr){
305
305
  </#if>
306
306
 
307
307
  <#if are_same_path(path, ["totp", "policy", "getAlgorithmKey"])>
308
- <#local returnValue = "">
309
- <#attempt>
310
- <#local returnValue = totp.policy.getAlgorithmKey()>
311
- <#recover>
312
- <#return "ABORT: Couldn't evaluate totp.policy.getAlgorithmKey()">
313
- </#attempt>
308
+ <#local returnValue = "error">
309
+ <#if mode?? && mode = "manual">
310
+ <#attempt>
311
+ <#local returnValue = totp.policy.getAlgorithmKey()>
312
+ <#recover>
313
+ <#return "ABORT: Couldn't evaluate totp.policy.getAlgorithmKey()">
314
+ </#attempt>
315
+ </#if>
314
316
  <#return 'function(){ return "' + returnValue + '"; }'>
315
317
  </#if>
316
318
 
@@ -29,7 +29,6 @@ import {
29
29
  bringInAccountV1,
30
30
  type BuildContextLike as BuildContextLike_bringInAccountV1
31
31
  } from "./bringInAccountV1";
32
- import { getThemeSrcDirPath } from "../../shared/getThemeSrcDirPath";
33
32
  import { rmSync } from "../../tools/fs.rmSync";
34
33
  import { readThisNpmPackageVersion } from "../../tools/readThisNpmPackageVersion";
35
34
  import {
@@ -38,7 +37,6 @@ import {
38
37
  } from "../../shared/metaInfKeycloakThemes";
39
38
  import { objectEntries } from "tsafe/objectEntries";
40
39
  import { escapeStringForPropertiesFile } from "../../tools/escapeStringForPropertiesFile";
41
- import { getImplementedThemeTypes } from "../../shared/getImplementedThemeTypes";
42
40
 
43
41
  export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
44
42
  BuildContextLike_downloadKeycloakStaticResources &
@@ -48,6 +46,8 @@ export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
48
46
  projectDirPath: string;
49
47
  projectBuildDirPath: string;
50
48
  environmentVariables: { name: string; default: string }[];
49
+ recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
50
+ themeSrcDirPath: string;
51
51
  };
52
52
 
53
53
  assert<BuildContext extends BuildContextLike ? true : false>();
@@ -59,14 +59,6 @@ export async function generateResourcesForMainTheme(params: {
59
59
  }): Promise<void> {
60
60
  const { themeName, resourcesDirPath, buildContext } = params;
61
61
 
62
- const { themeSrcDirPath } = getThemeSrcDirPath({
63
- projectDirPath: buildContext.projectDirPath
64
- });
65
-
66
- const { implementedThemeTypes } = getImplementedThemeTypes({
67
- projectDirPath: buildContext.projectDirPath
68
- });
69
-
70
62
  const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
71
63
  const { themeType } = params;
72
64
  return pathJoin(resourcesDirPath, "theme", themeName, themeType);
@@ -75,7 +67,7 @@ export async function generateResourcesForMainTheme(params: {
75
67
  const cssGlobalsToDefine: Record<string, string> = {};
76
68
 
77
69
  for (const themeType of ["login", "account"] as const) {
78
- if (!implementedThemeTypes[themeType]) {
70
+ if (!buildContext.recordIsImplementedByThemeType[themeType]) {
79
71
  continue;
80
72
  }
81
73
 
@@ -91,7 +83,10 @@ export async function generateResourcesForMainTheme(params: {
91
83
  // NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
92
84
  rmSync(destDirPath, { recursive: true, force: true });
93
85
 
94
- if (themeType === "account" && implementedThemeTypes.login) {
86
+ if (
87
+ themeType === "account" &&
88
+ buildContext.recordIsImplementedByThemeType.login
89
+ ) {
95
90
  // NOTE: We prevent doing it twice, it has been done for the login theme.
96
91
 
97
92
  transformCodebase({
@@ -178,7 +173,7 @@ export async function generateResourcesForMainTheme(params: {
178
173
  keycloakifyVersion: readThisNpmPackageVersion(),
179
174
  themeType,
180
175
  fieldNames: readFieldNameUsage({
181
- themeSrcDirPath,
176
+ themeSrcDirPath: buildContext.themeSrcDirPath,
182
177
  themeType
183
178
  })
184
179
  });
@@ -194,7 +189,7 @@ export async function generateResourcesForMainTheme(params: {
194
189
  })(),
195
190
  ...readExtraPagesNames({
196
191
  themeType,
197
- themeSrcDirPath
192
+ themeSrcDirPath: buildContext.themeSrcDirPath
198
193
  })
199
194
  ].forEach(pageId => {
200
195
  const { ftlCode } = generateFtlFilesCode({ pageId });
@@ -206,7 +201,7 @@ export async function generateResourcesForMainTheme(params: {
206
201
  });
207
202
 
208
203
  generateMessageProperties({
209
- themeSrcDirPath,
204
+ themeSrcDirPath: buildContext.themeSrcDirPath,
210
205
  themeType
211
206
  }).forEach(({ languageTag, propertiesFileSource }) => {
212
207
  const messagesDirPath = pathJoin(themeTypeDirPath, "messages");
@@ -265,11 +260,11 @@ export async function generateResourcesForMainTheme(params: {
265
260
  }
266
261
 
267
262
  email: {
268
- if (!implementedThemeTypes.email) {
263
+ if (!buildContext.recordIsImplementedByThemeType.email) {
269
264
  break email;
270
265
  }
271
266
 
272
- const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
267
+ const emailThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "email");
273
268
 
274
269
  transformCodebase({
275
270
  srcDirPath: emailThemeSrcDirPath,
@@ -277,7 +272,7 @@ export async function generateResourcesForMainTheme(params: {
277
272
  });
278
273
  }
279
274
 
280
- if (implementedThemeTypes.account) {
275
+ if (buildContext.recordIsImplementedByThemeType.account) {
281
276
  await bringInAccountV1({
282
277
  resourcesDirPath,
283
278
  buildContext
@@ -289,12 +284,12 @@ export async function generateResourcesForMainTheme(params: {
289
284
 
290
285
  metaInfKeycloakThemes.themes.push({
291
286
  name: themeName,
292
- types: objectEntries(implementedThemeTypes)
287
+ types: objectEntries(buildContext.recordIsImplementedByThemeType)
293
288
  .filter(([, isImplemented]) => isImplemented)
294
289
  .map(([themeType]) => themeType)
295
290
  });
296
291
 
297
- if (implementedThemeTypes.account) {
292
+ if (buildContext.recordIsImplementedByThemeType.account) {
298
293
  metaInfKeycloakThemes.themes.push({
299
294
  name: accountV1ThemeName,
300
295
  types: ["account"]
@@ -3,10 +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 {
7
- vitePluginSubScriptEnvNames,
8
- onlyBuildJarFileBasenameEnvName
9
- } from "../shared/constants";
6
+ import { vitePluginSubScriptEnvNames } from "../shared/constants";
10
7
  import { buildJars } from "./buildJars";
11
8
  import type { CliCommandOptions } from "../main";
12
9
  import chalk from "chalk";
@@ -96,16 +93,17 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
96
93
  cwd: buildContext.projectDirPath,
97
94
  env: {
98
95
  ...process.env,
99
- [vitePluginSubScriptEnvNames.runPostBuildScript]:
100
- JSON.stringify(buildContext)
96
+ [vitePluginSubScriptEnvNames.runPostBuildScript]: JSON.stringify({
97
+ resourcesDirPath,
98
+ buildContext
99
+ })
101
100
  }
102
101
  });
103
102
  }
104
103
 
105
104
  await buildJars({
106
105
  resourcesDirPath,
107
- buildContext,
108
- onlyBuildJarFileBasename: process.env[onlyBuildJarFileBasenameEnvName]
106
+ buildContext
109
107
  });
110
108
 
111
109
  rmSync(resourcesDirPath, { recursive: true });