From 532655d2d5640687ea4699418395166bf577a1a5 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 16 Jun 2024 01:34:06 +0200 Subject: [PATCH] Rename jarTargets -> keycloakVersionTargets --- src/bin/shared/buildContext.ts | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/bin/shared/buildContext.ts b/src/bin/shared/buildContext.ts index 0da4186a..1ebd03f5 100644 --- a/src/bin/shared/buildContext.ts +++ b/src/bin/shared/buildContext.ts @@ -60,11 +60,11 @@ export type BuildOptions = { loginThemeResourcesFromKeycloakVersion?: string; keycloakifyBuildDirPath?: string; kcContextExclusionsFtl?: string; - jarTargets?: BuildOptions.JarTargets; + keycloakVersionTargets?: BuildOptions.KeycloakVersionTargets; }; export namespace BuildOptions { - export type JarTargets = + export type KeycloakVersionTargets = | ({ hasAccountTheme: true } & Record< KeycloakVersionRange.WithAccountTheme, string | boolean @@ -168,9 +168,11 @@ export function getBuildContext(params: { ) .optional(), themeName: z.union([z.string(), z.array(z.string())]).optional(), - jarTargets: id>( + keycloakVersionTargets: id< + z.ZodType + >( (() => { - const zJarTargets = z.union([ + const zKeycloakVersionTargets = z.union([ z.object({ hasAccountTheme: z.literal(true), "21-and-below": z.union([ @@ -192,12 +194,12 @@ export function getBuildContext(params: { ]); { - type Got = z.infer; - type Expected = BuildOptions.JarTargets; + type Got = z.infer; + type Expected = BuildOptions.KeycloakVersionTargets; assert>(); } - return zJarTargets; + return zKeycloakVersionTargets; })() ).optional() }); @@ -584,31 +586,31 @@ export function getBuildContext(params: { return jarTargets; })(); - if (buildOptions.jarTargets === undefined) { + if (buildOptions.keycloakVersionTargets === undefined) { return jarTargets_default; } if ( - buildOptions.jarTargets.hasAccountTheme !== + buildOptions.keycloakVersionTargets.hasAccountTheme !== recordIsImplementedByThemeType.account ) { console.log( chalk.red( (() => { - const { jarTargets } = buildOptions; + const { keycloakVersionTargets } = buildOptions; - let message = `Bad ${symToStr({ jarTargets })} configuration.\n`; + let message = `Bad ${symToStr({ keycloakVersionTargets })} configuration.\n`; - if (jarTargets.hasAccountTheme) { + if (keycloakVersionTargets.hasAccountTheme) { message += "Your codebase does not seem to implement an account theme "; } else { message += "Your codebase implements an account theme "; } - const { hasAccountTheme } = jarTargets; + const { hasAccountTheme } = keycloakVersionTargets; - message += `but you have set ${symToStr({ jarTargets })}.${symToStr({ hasAccountTheme })}`; + message += `but you have set ${symToStr({ keycloakVersionTargets })}.${symToStr({ hasAccountTheme })}`; message += ` to ${hasAccountTheme} in your `; message += (() => { switch (bundler) { @@ -624,8 +626,8 @@ export function getBuildContext(params: { "and fill up the relevant keycloak version ranges.\n"; message += "Example:\n"; message += JSON.stringify( - id>({ - jarTargets: { + id>({ + keycloakVersionTargets: { hasAccountTheme: recordIsImplementedByThemeType.account, ...objectFromEntries( @@ -655,7 +657,7 @@ export function getBuildContext(params: { const jarTargets: BuildContext["jarTargets"] = []; - const { hasAccountTheme, ...rest } = buildOptions.jarTargets; + const { hasAccountTheme, ...rest } = buildOptions.keycloakVersionTargets; for (const [keycloakVersionRange, jarNameOrBoolean] of objectEntries(rest)) { if (jarNameOrBoolean === false) {