keycloakify 10.0.0-rc.65 → 10.0.0-rc.67
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.
- package/bin/193.index.js +51 -0
- package/bin/246.index.js +371 -75118
- package/bin/363.index.js +64 -165
- package/bin/453.index.js +603 -23
- package/bin/{890.index.js → 456.index.js} +1831 -3
- package/bin/490.index.js +75195 -0
- package/bin/526.index.js +294 -173
- package/bin/538.index.js +1 -509
- package/bin/{203.index.js → 751.index.js} +306 -305
- package/bin/772.index.js +1 -1
- package/bin/{190.index.js → 837.index.js} +259 -35
- package/bin/932.index.js +1 -578
- package/bin/97.index.js +594 -14
- package/bin/main.js +8 -8
- package/bin/shared/KeycloakVersionRange.d.ts +5 -0
- package/bin/shared/KeycloakVersionRange.js.map +1 -0
- package/bin/shared/buildContext.d.ts +16 -0
- package/bin/shared/buildContext.js.map +1 -0
- package/bin/shared/constants.d.ts +1 -1
- package/bin/shared/constants.js.map +1 -1
- package/bin/shared/copyKeycloakResourcesToPublic.d.ts +8 -0
- package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -0
- package/bin/shared/downloadKeycloakDefaultTheme.d.ts +10 -0
- package/bin/shared/downloadKeycloakDefaultTheme.js.map +1 -0
- package/bin/shared/downloadKeycloakStaticResources.d.ts +9 -0
- package/bin/shared/downloadKeycloakStaticResources.js.map +1 -0
- package/bin/shared/generateKcGenTs.d.ts +12 -0
- package/bin/shared/generateKcGenTs.js.map +1 -0
- package/bin/shared/metaInfKeycloakThemes.d.ts +13 -0
- package/bin/shared/metaInfKeycloakThemes.js.map +1 -0
- package/bin/shared/promptKeycloakVersion.d.ts +7 -0
- package/bin/shared/promptKeycloakVersion.js.map +1 -0
- package/package.json +21 -12
- package/src/bin/add-story.ts +1 -6
- package/src/bin/eject-page.ts +7 -8
- package/src/bin/initialize-email-theme.ts +1 -6
- package/src/bin/keycloakify/buildJars/buildJars.ts +23 -49
- package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +15 -20
- package/src/bin/keycloakify/keycloakify.ts +6 -8
- package/src/bin/shared/buildContext.ts +434 -42
- package/src/bin/shared/constants.ts +2 -1
- package/src/bin/shared/generateKcGenTs.ts +2 -6
- package/src/bin/start-keycloak/keycloakifyBuild.ts +4 -4
- package/src/bin/start-keycloak/start-keycloak.ts +40 -83
- package/src/vite-plugin/vite-plugin.ts +5 -4
- package/vite-plugin/index.js +341 -117
- package/bin/480.index.js +0 -466
- package/bin/818.index.js +0 -1802
- package/bin/827.index.js +0 -1094
- package/bin/shared/constants.js +0 -59
- package/src/bin/shared/getImplementedThemeTypes.ts +0 -38
- package/src/bin/shared/getJarFileBasename.ts +0 -11
- package/src/bin/shared/getThemeSrcDirPath.ts +0 -62
@@ -5,9 +5,22 @@ import { getNpmWorkspaceRootDirPath } from "../tools/getNpmWorkspaceRootDirPath"
|
|
5
5
|
import type { CliCommandOptions } from "../main";
|
6
6
|
import { z } from "zod";
|
7
7
|
import * as fs from "fs";
|
8
|
-
import { assert, type Equals } from "tsafe";
|
8
|
+
import { assert, type Equals } from "tsafe/assert";
|
9
9
|
import * as child_process from "child_process";
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
vitePluginSubScriptEnvNames,
|
12
|
+
buildForKeycloakMajorVersionEnvName
|
13
|
+
} from "./constants";
|
14
|
+
import type { KeycloakVersionRange } from "./KeycloakVersionRange";
|
15
|
+
import { exclude } from "tsafe";
|
16
|
+
import { crawl } from "../tools/crawl";
|
17
|
+
import { themeTypes } from "./constants";
|
18
|
+
import { objectFromEntries } from "tsafe/objectFromEntries";
|
19
|
+
import { objectEntries } from "tsafe/objectEntries";
|
20
|
+
import { type ThemeType } from "./constants";
|
21
|
+
import { id } from "tsafe/id";
|
22
|
+
import { symToStr } from "tsafe/symToStr";
|
23
|
+
import chalk from "chalk";
|
11
24
|
|
12
25
|
export type BuildContext = {
|
13
26
|
bundler: "vite" | "webpack";
|
@@ -30,6 +43,12 @@ export type BuildContext = {
|
|
30
43
|
npmWorkspaceRootDirPath: string;
|
31
44
|
kcContextExclusionsFtlCode: string | undefined;
|
32
45
|
environmentVariables: { name: string; default: string }[];
|
46
|
+
themeSrcDirPath: string;
|
47
|
+
recordIsImplementedByThemeType: Readonly<Record<ThemeType | "email", boolean>>;
|
48
|
+
jarTargets: {
|
49
|
+
keycloakVersionRange: KeycloakVersionRange;
|
50
|
+
jarFileBasename: string;
|
51
|
+
}[];
|
33
52
|
};
|
34
53
|
|
35
54
|
export type BuildOptions = {
|
@@ -41,8 +60,21 @@ export type BuildOptions = {
|
|
41
60
|
loginThemeResourcesFromKeycloakVersion?: string;
|
42
61
|
keycloakifyBuildDirPath?: string;
|
43
62
|
kcContextExclusionsFtl?: string;
|
63
|
+
keycloakVersionTargets?: BuildOptions.KeycloakVersionTargets;
|
44
64
|
};
|
45
65
|
|
66
|
+
export namespace BuildOptions {
|
67
|
+
export type KeycloakVersionTargets =
|
68
|
+
| ({ hasAccountTheme: true } & Record<
|
69
|
+
KeycloakVersionRange.WithAccountTheme,
|
70
|
+
string | boolean
|
71
|
+
>)
|
72
|
+
| ({ hasAccountTheme: false } & Record<
|
73
|
+
KeycloakVersionRange.WithoutAccountTheme,
|
74
|
+
string | boolean
|
75
|
+
>);
|
76
|
+
}
|
77
|
+
|
46
78
|
export type ResolvedViteConfig = {
|
47
79
|
buildDir: string;
|
48
80
|
publicDir: string;
|
@@ -102,7 +134,7 @@ export function getBuildContext(params: {
|
|
102
134
|
})();
|
103
135
|
|
104
136
|
const parsedPackageJson = (() => {
|
105
|
-
type
|
137
|
+
type BuildOptions_packageJson = BuildOptions & {
|
106
138
|
projectBuildDirPath?: string;
|
107
139
|
};
|
108
140
|
|
@@ -110,49 +142,77 @@ export function getBuildContext(params: {
|
|
110
142
|
name: string;
|
111
143
|
version?: string;
|
112
144
|
homepage?: string;
|
113
|
-
keycloakify?:
|
114
|
-
themeName?: string | string[];
|
115
|
-
environmentVariables?: { name: string; default: string }[];
|
116
|
-
extraThemeProperties?: string[];
|
117
|
-
artifactId?: string;
|
118
|
-
groupId?: string;
|
119
|
-
loginThemeResourcesFromKeycloakVersion?: string;
|
120
|
-
keycloakifyBuildDirPath?: string;
|
121
|
-
kcContextExclusionsFtl?: string;
|
122
|
-
projectBuildDirPath?: string;
|
123
|
-
};
|
145
|
+
keycloakify?: BuildOptions_packageJson;
|
124
146
|
};
|
125
147
|
|
126
|
-
{
|
127
|
-
type Got = NonNullable<ParsedPackageJson["keycloakify"]>;
|
128
|
-
type Expected = BuildOptions & WebpackSpecificBuildOptions;
|
129
|
-
assert<Equals<Got, Expected>>();
|
130
|
-
}
|
131
|
-
|
132
148
|
const zParsedPackageJson = z.object({
|
133
149
|
name: z.string(),
|
134
150
|
version: z.string().optional(),
|
135
151
|
homepage: z.string().optional(),
|
136
|
-
keycloakify: z
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
keycloakify: id<z.ZodType<BuildOptions_packageJson>>(
|
153
|
+
(() => {
|
154
|
+
const zBuildOptions_packageJson = z.object({
|
155
|
+
extraThemeProperties: z.array(z.string()).optional(),
|
156
|
+
artifactId: z.string().optional(),
|
157
|
+
groupId: z.string().optional(),
|
158
|
+
loginThemeResourcesFromKeycloakVersion: z.string().optional(),
|
159
|
+
projectBuildDirPath: z.string().optional(),
|
160
|
+
keycloakifyBuildDirPath: z.string().optional(),
|
161
|
+
kcContextExclusionsFtl: z.string().optional(),
|
162
|
+
environmentVariables: z
|
163
|
+
.array(
|
164
|
+
z.object({
|
165
|
+
name: z.string(),
|
166
|
+
default: z.string()
|
167
|
+
})
|
168
|
+
)
|
169
|
+
.optional(),
|
170
|
+
themeName: z.union([z.string(), z.array(z.string())]).optional(),
|
171
|
+
keycloakVersionTargets: id<
|
172
|
+
z.ZodType<BuildOptions.KeycloakVersionTargets>
|
173
|
+
>(
|
174
|
+
(() => {
|
175
|
+
const zKeycloakVersionTargets = z.union([
|
176
|
+
z.object({
|
177
|
+
hasAccountTheme: z.literal(true),
|
178
|
+
"21-and-below": z.union([
|
179
|
+
z.boolean(),
|
180
|
+
z.string()
|
181
|
+
]),
|
182
|
+
"23": z.union([z.boolean(), z.string()]),
|
183
|
+
"24": z.union([z.boolean(), z.string()]),
|
184
|
+
"25-and-above": z.union([z.boolean(), z.string()])
|
185
|
+
}),
|
186
|
+
z.object({
|
187
|
+
hasAccountTheme: z.literal(false),
|
188
|
+
"21-and-below": z.union([
|
189
|
+
z.boolean(),
|
190
|
+
z.string()
|
191
|
+
]),
|
192
|
+
"22-and-above": z.union([z.boolean(), z.string()])
|
193
|
+
})
|
194
|
+
]);
|
195
|
+
|
196
|
+
{
|
197
|
+
type Got = z.infer<typeof zKeycloakVersionTargets>;
|
198
|
+
type Expected = BuildOptions.KeycloakVersionTargets;
|
199
|
+
assert<Equals<Got, Expected>>();
|
200
|
+
}
|
201
|
+
|
202
|
+
return zKeycloakVersionTargets;
|
203
|
+
})()
|
204
|
+
).optional()
|
205
|
+
});
|
206
|
+
|
207
|
+
{
|
208
|
+
type Got = z.infer<typeof zBuildOptions_packageJson>;
|
209
|
+
type Expected = BuildOptions_packageJson;
|
210
|
+
assert<Equals<Got, Expected>>();
|
211
|
+
}
|
212
|
+
|
213
|
+
return zBuildOptions_packageJson;
|
214
|
+
})()
|
215
|
+
).optional()
|
156
216
|
});
|
157
217
|
|
158
218
|
{
|
@@ -173,6 +233,54 @@ export function getBuildContext(params: {
|
|
173
233
|
...resolvedViteConfig?.buildOptions
|
174
234
|
};
|
175
235
|
|
236
|
+
const { themeSrcDirPath } = (() => {
|
237
|
+
const srcDirPath = pathJoin(projectDirPath, "src");
|
238
|
+
|
239
|
+
const themeSrcDirPath: string | undefined = crawl({
|
240
|
+
dirPath: srcDirPath,
|
241
|
+
returnedPathsType: "relative to dirPath"
|
242
|
+
})
|
243
|
+
.map(fileRelativePath => {
|
244
|
+
for (const themeSrcDirBasename of ["keycloak-theme", "keycloak_theme"]) {
|
245
|
+
const split = fileRelativePath.split(themeSrcDirBasename);
|
246
|
+
if (split.length === 2) {
|
247
|
+
return pathJoin(srcDirPath, split[0] + themeSrcDirBasename);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
return undefined;
|
251
|
+
})
|
252
|
+
.filter(exclude(undefined))[0];
|
253
|
+
|
254
|
+
if (themeSrcDirPath !== undefined) {
|
255
|
+
return { themeSrcDirPath };
|
256
|
+
}
|
257
|
+
|
258
|
+
for (const themeType of [...themeTypes, "email"]) {
|
259
|
+
if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
|
260
|
+
continue;
|
261
|
+
}
|
262
|
+
return { themeSrcDirPath: srcDirPath };
|
263
|
+
}
|
264
|
+
|
265
|
+
console.log(
|
266
|
+
chalk.red(
|
267
|
+
[
|
268
|
+
"Can't locate your keycloak theme source directory.",
|
269
|
+
"See: https://docs.keycloakify.dev/v/v10/keycloakify-in-my-app/collocation"
|
270
|
+
].join("\n")
|
271
|
+
)
|
272
|
+
);
|
273
|
+
|
274
|
+
process.exit(1);
|
275
|
+
})();
|
276
|
+
|
277
|
+
const recordIsImplementedByThemeType = objectFromEntries(
|
278
|
+
(["login", "account", "email"] as const).map(themeType => [
|
279
|
+
themeType,
|
280
|
+
fs.existsSync(pathJoin(themeSrcDirPath, themeType))
|
281
|
+
])
|
282
|
+
);
|
283
|
+
|
176
284
|
const themeNames = ((): [string, ...string[]] => {
|
177
285
|
if (buildOptions.themeName === undefined) {
|
178
286
|
return [
|
@@ -218,8 +326,10 @@ export function getBuildContext(params: {
|
|
218
326
|
dependencyExpected: "keycloakify"
|
219
327
|
});
|
220
328
|
|
329
|
+
const bundler = resolvedViteConfig !== undefined ? "vite" : "webpack";
|
330
|
+
|
221
331
|
return {
|
222
|
-
bundler
|
332
|
+
bundler,
|
223
333
|
themeVersion:
|
224
334
|
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
225
335
|
themeNames,
|
@@ -349,6 +459,288 @@ export function getBuildContext(params: {
|
|
349
459
|
|
350
460
|
return buildOptions.kcContextExclusionsFtl;
|
351
461
|
})(),
|
352
|
-
environmentVariables: buildOptions.environmentVariables ?? []
|
462
|
+
environmentVariables: buildOptions.environmentVariables ?? [],
|
463
|
+
recordIsImplementedByThemeType,
|
464
|
+
themeSrcDirPath,
|
465
|
+
jarTargets: (() => {
|
466
|
+
const getDefaultJarFileBasename = (range: string) =>
|
467
|
+
`keycloak-theme-for-kc-${range}.jar`;
|
468
|
+
|
469
|
+
build_for_specific_keycloak_major_version: {
|
470
|
+
const buildForKeycloakMajorVersionNumber = (() => {
|
471
|
+
const envValue = process.env[buildForKeycloakMajorVersionEnvName];
|
472
|
+
|
473
|
+
if (envValue === undefined) {
|
474
|
+
return undefined;
|
475
|
+
}
|
476
|
+
|
477
|
+
const major = parseInt(envValue);
|
478
|
+
|
479
|
+
assert(!isNaN(major));
|
480
|
+
|
481
|
+
return major;
|
482
|
+
})();
|
483
|
+
|
484
|
+
if (buildForKeycloakMajorVersionNumber === undefined) {
|
485
|
+
break build_for_specific_keycloak_major_version;
|
486
|
+
}
|
487
|
+
|
488
|
+
const keycloakVersionRange: KeycloakVersionRange = (() => {
|
489
|
+
const doesImplementAccountTheme =
|
490
|
+
recordIsImplementedByThemeType.account;
|
491
|
+
|
492
|
+
if (doesImplementAccountTheme) {
|
493
|
+
const keycloakVersionRange = (() => {
|
494
|
+
if (buildForKeycloakMajorVersionNumber <= 21) {
|
495
|
+
return "21-and-below" as const;
|
496
|
+
}
|
497
|
+
|
498
|
+
assert(buildForKeycloakMajorVersionNumber !== 22);
|
499
|
+
|
500
|
+
if (buildForKeycloakMajorVersionNumber === 23) {
|
501
|
+
return "23" as const;
|
502
|
+
}
|
503
|
+
|
504
|
+
if (buildForKeycloakMajorVersionNumber === 24) {
|
505
|
+
return "24" as const;
|
506
|
+
}
|
507
|
+
|
508
|
+
return "25-and-above" as const;
|
509
|
+
})();
|
510
|
+
|
511
|
+
assert<
|
512
|
+
Equals<
|
513
|
+
typeof keycloakVersionRange,
|
514
|
+
KeycloakVersionRange.WithAccountTheme
|
515
|
+
>
|
516
|
+
>();
|
517
|
+
|
518
|
+
return keycloakVersionRange;
|
519
|
+
} else {
|
520
|
+
const keycloakVersionRange = (() => {
|
521
|
+
if (buildForKeycloakMajorVersionNumber <= 21) {
|
522
|
+
return "21-and-below" as const;
|
523
|
+
}
|
524
|
+
|
525
|
+
return "22-and-above" as const;
|
526
|
+
})();
|
527
|
+
|
528
|
+
assert<
|
529
|
+
Equals<
|
530
|
+
typeof keycloakVersionRange,
|
531
|
+
KeycloakVersionRange.WithoutAccountTheme
|
532
|
+
>
|
533
|
+
>();
|
534
|
+
|
535
|
+
return keycloakVersionRange;
|
536
|
+
}
|
537
|
+
})();
|
538
|
+
|
539
|
+
const jarFileBasename = (() => {
|
540
|
+
use_custom_jar_basename: {
|
541
|
+
const { keycloakVersionTargets } = buildOptions;
|
542
|
+
|
543
|
+
if (keycloakVersionTargets === undefined) {
|
544
|
+
break use_custom_jar_basename;
|
545
|
+
}
|
546
|
+
|
547
|
+
const entry = objectEntries(keycloakVersionTargets).find(
|
548
|
+
([keycloakVersionRange_entry]) =>
|
549
|
+
keycloakVersionRange_entry === keycloakVersionRange
|
550
|
+
);
|
551
|
+
|
552
|
+
if (entry === undefined) {
|
553
|
+
break use_custom_jar_basename;
|
554
|
+
}
|
555
|
+
|
556
|
+
const maybeJarFileBasename = entry[1];
|
557
|
+
|
558
|
+
if (typeof maybeJarFileBasename !== "string") {
|
559
|
+
break use_custom_jar_basename;
|
560
|
+
}
|
561
|
+
|
562
|
+
return maybeJarFileBasename;
|
563
|
+
}
|
564
|
+
|
565
|
+
return getDefaultJarFileBasename(keycloakVersionRange);
|
566
|
+
})();
|
567
|
+
|
568
|
+
return [
|
569
|
+
{
|
570
|
+
keycloakVersionRange,
|
571
|
+
jarFileBasename
|
572
|
+
}
|
573
|
+
];
|
574
|
+
}
|
575
|
+
|
576
|
+
const jarTargets_default = (() => {
|
577
|
+
const jarTargets: BuildContext["jarTargets"] = [];
|
578
|
+
|
579
|
+
if (recordIsImplementedByThemeType.account) {
|
580
|
+
for (const keycloakVersionRange of [
|
581
|
+
"21-and-below",
|
582
|
+
"23",
|
583
|
+
"24",
|
584
|
+
"25-and-above"
|
585
|
+
] as const) {
|
586
|
+
assert<
|
587
|
+
Equals<
|
588
|
+
typeof keycloakVersionRange,
|
589
|
+
KeycloakVersionRange.WithAccountTheme
|
590
|
+
>
|
591
|
+
>(true);
|
592
|
+
jarTargets.push({
|
593
|
+
keycloakVersionRange,
|
594
|
+
jarFileBasename:
|
595
|
+
getDefaultJarFileBasename(keycloakVersionRange)
|
596
|
+
});
|
597
|
+
}
|
598
|
+
} else {
|
599
|
+
for (const keycloakVersionRange of [
|
600
|
+
"21-and-below",
|
601
|
+
"22-and-above"
|
602
|
+
] as const) {
|
603
|
+
assert<
|
604
|
+
Equals<
|
605
|
+
typeof keycloakVersionRange,
|
606
|
+
KeycloakVersionRange.WithoutAccountTheme
|
607
|
+
>
|
608
|
+
>(true);
|
609
|
+
jarTargets.push({
|
610
|
+
keycloakVersionRange,
|
611
|
+
jarFileBasename:
|
612
|
+
getDefaultJarFileBasename(keycloakVersionRange)
|
613
|
+
});
|
614
|
+
}
|
615
|
+
}
|
616
|
+
|
617
|
+
return jarTargets;
|
618
|
+
})();
|
619
|
+
|
620
|
+
if (buildOptions.keycloakVersionTargets === undefined) {
|
621
|
+
return jarTargets_default;
|
622
|
+
}
|
623
|
+
|
624
|
+
if (
|
625
|
+
buildOptions.keycloakVersionTargets.hasAccountTheme !==
|
626
|
+
recordIsImplementedByThemeType.account
|
627
|
+
) {
|
628
|
+
console.log(
|
629
|
+
chalk.red(
|
630
|
+
(() => {
|
631
|
+
const { keycloakVersionTargets } = buildOptions;
|
632
|
+
|
633
|
+
let message = `Bad ${symToStr({ keycloakVersionTargets })} configuration.\n`;
|
634
|
+
|
635
|
+
if (keycloakVersionTargets.hasAccountTheme) {
|
636
|
+
message +=
|
637
|
+
"Your codebase does not seem to implement an account theme ";
|
638
|
+
} else {
|
639
|
+
message += "Your codebase implements an account theme ";
|
640
|
+
}
|
641
|
+
|
642
|
+
const { hasAccountTheme } = keycloakVersionTargets;
|
643
|
+
|
644
|
+
message += `but you have set ${symToStr({ keycloakVersionTargets })}.${symToStr({ hasAccountTheme })}`;
|
645
|
+
message += ` to ${hasAccountTheme} in your `;
|
646
|
+
message += (() => {
|
647
|
+
switch (bundler) {
|
648
|
+
case "vite":
|
649
|
+
return "vite.config.ts";
|
650
|
+
case "webpack":
|
651
|
+
return "package.json";
|
652
|
+
}
|
653
|
+
assert<Equals<typeof bundler, never>>(false);
|
654
|
+
})();
|
655
|
+
message += `. Please set it to ${!hasAccountTheme} `;
|
656
|
+
message +=
|
657
|
+
"and fill up the relevant keycloak version ranges.\n";
|
658
|
+
message += "Example:\n";
|
659
|
+
message += JSON.stringify(
|
660
|
+
id<Pick<BuildOptions, "keycloakVersionTargets">>({
|
661
|
+
keycloakVersionTargets: {
|
662
|
+
hasAccountTheme:
|
663
|
+
recordIsImplementedByThemeType.account,
|
664
|
+
...objectFromEntries(
|
665
|
+
jarTargets_default.map(
|
666
|
+
({
|
667
|
+
keycloakVersionRange,
|
668
|
+
jarFileBasename
|
669
|
+
}) => [
|
670
|
+
keycloakVersionRange,
|
671
|
+
jarFileBasename
|
672
|
+
]
|
673
|
+
)
|
674
|
+
)
|
675
|
+
}
|
676
|
+
}),
|
677
|
+
null,
|
678
|
+
2
|
679
|
+
);
|
680
|
+
|
681
|
+
return message;
|
682
|
+
})()
|
683
|
+
)
|
684
|
+
);
|
685
|
+
|
686
|
+
process.exit(1);
|
687
|
+
}
|
688
|
+
|
689
|
+
const jarTargets: BuildContext["jarTargets"] = [];
|
690
|
+
|
691
|
+
const { hasAccountTheme, ...rest } = buildOptions.keycloakVersionTargets;
|
692
|
+
|
693
|
+
for (const [keycloakVersionRange, jarNameOrBoolean] of objectEntries(rest)) {
|
694
|
+
if (jarNameOrBoolean === false) {
|
695
|
+
continue;
|
696
|
+
}
|
697
|
+
|
698
|
+
if (jarNameOrBoolean === true) {
|
699
|
+
jarTargets.push({
|
700
|
+
keycloakVersionRange: keycloakVersionRange,
|
701
|
+
jarFileBasename: getDefaultJarFileBasename(keycloakVersionRange)
|
702
|
+
});
|
703
|
+
continue;
|
704
|
+
}
|
705
|
+
|
706
|
+
const jarFileBasename = jarNameOrBoolean;
|
707
|
+
|
708
|
+
if (!jarFileBasename.endsWith(".jar")) {
|
709
|
+
console.log(
|
710
|
+
chalk.red(`Bad ${jarFileBasename} should end with '.jar'\n`)
|
711
|
+
);
|
712
|
+
process.exit(1);
|
713
|
+
}
|
714
|
+
|
715
|
+
if (jarFileBasename.includes("/") || jarFileBasename.includes("\\")) {
|
716
|
+
console.log(
|
717
|
+
chalk.red(
|
718
|
+
[
|
719
|
+
`Invalid ${jarFileBasename}. It's not supposed to be a path,`,
|
720
|
+
`Only the basename of the jar file is expected.`,
|
721
|
+
`Example: keycloak-theme.jar`
|
722
|
+
].join(" ")
|
723
|
+
)
|
724
|
+
);
|
725
|
+
process.exit(1);
|
726
|
+
}
|
727
|
+
|
728
|
+
jarTargets.push({
|
729
|
+
keycloakVersionRange: keycloakVersionRange,
|
730
|
+
jarFileBasename: jarNameOrBoolean
|
731
|
+
});
|
732
|
+
}
|
733
|
+
|
734
|
+
if (jarTargets.length === 0) {
|
735
|
+
console.log(
|
736
|
+
chalk.red(
|
737
|
+
"All jar targets are disabled. Please enable at least one jar target."
|
738
|
+
)
|
739
|
+
);
|
740
|
+
process.exit(1);
|
741
|
+
}
|
742
|
+
|
743
|
+
return jarTargets;
|
744
|
+
})()
|
353
745
|
};
|
354
746
|
}
|
@@ -15,7 +15,8 @@ export const vitePluginSubScriptEnvNames = {
|
|
15
15
|
resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
|
16
16
|
} as const;
|
17
17
|
|
18
|
-
export const
|
18
|
+
export const buildForKeycloakMajorVersionEnvName =
|
19
|
+
"KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
|
19
20
|
|
20
21
|
export const loginThemePageIds = [
|
21
22
|
"login.ftl",
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { assert } from "tsafe/assert";
|
2
2
|
import type { BuildContext } from "./buildContext";
|
3
|
-
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
4
3
|
import * as fs from "fs/promises";
|
5
4
|
import { join as pathJoin } from "path";
|
6
5
|
import { existsAsync } from "../tools/fs.existsAsync";
|
@@ -9,6 +8,7 @@ export type BuildContextLike = {
|
|
9
8
|
projectDirPath: string;
|
10
9
|
themeNames: string[];
|
11
10
|
environmentVariables: { name: string; default: string }[];
|
11
|
+
themeSrcDirPath: string;
|
12
12
|
};
|
13
13
|
|
14
14
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
@@ -18,11 +18,7 @@ export async function generateKcGenTs(params: {
|
|
18
18
|
}): Promise<void> {
|
19
19
|
const { buildContext } = params;
|
20
20
|
|
21
|
-
const
|
22
|
-
projectDirPath: buildContext.projectDirPath
|
23
|
-
});
|
24
|
-
|
25
|
-
const filePath = pathJoin(themeSrcDirPath, "kc.gen.ts");
|
21
|
+
const filePath = pathJoin(buildContext.themeSrcDirPath, "kc.gen.ts");
|
26
22
|
|
27
23
|
const currentContent = (await existsAsync(filePath))
|
28
24
|
? await fs.readFile(filePath)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { buildForKeycloakMajorVersionEnvName } 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";
|
@@ -14,10 +14,10 @@ export type BuildContextLike = {
|
|
14
14
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
15
15
|
|
16
16
|
export async function keycloakifyBuild(params: {
|
17
|
-
|
17
|
+
buildForKeycloakMajorVersionNumber: number;
|
18
18
|
buildContext: BuildContextLike;
|
19
19
|
}): Promise<{ isKeycloakifyBuildSuccess: boolean }> {
|
20
|
-
const {
|
20
|
+
const { buildForKeycloakMajorVersionNumber, buildContext } = params;
|
21
21
|
|
22
22
|
const dResult = new Deferred<{ isSuccess: boolean }>();
|
23
23
|
|
@@ -25,7 +25,7 @@ export async function keycloakifyBuild(params: {
|
|
25
25
|
cwd: buildContext.projectDirPath,
|
26
26
|
env: {
|
27
27
|
...process.env,
|
28
|
-
[
|
28
|
+
[buildForKeycloakMajorVersionEnvName]: `${buildForKeycloakMajorVersionNumber}`
|
29
29
|
},
|
30
30
|
shell: true
|
31
31
|
});
|