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.
Files changed (53) hide show
  1. package/bin/193.index.js +51 -0
  2. package/bin/246.index.js +371 -75118
  3. package/bin/363.index.js +64 -165
  4. package/bin/453.index.js +603 -23
  5. package/bin/{890.index.js → 456.index.js} +1831 -3
  6. package/bin/490.index.js +75195 -0
  7. package/bin/526.index.js +294 -173
  8. package/bin/538.index.js +1 -509
  9. package/bin/{203.index.js → 751.index.js} +306 -305
  10. package/bin/772.index.js +1 -1
  11. package/bin/{190.index.js → 837.index.js} +259 -35
  12. package/bin/932.index.js +1 -578
  13. package/bin/97.index.js +594 -14
  14. package/bin/main.js +8 -8
  15. package/bin/shared/KeycloakVersionRange.d.ts +5 -0
  16. package/bin/shared/KeycloakVersionRange.js.map +1 -0
  17. package/bin/shared/buildContext.d.ts +16 -0
  18. package/bin/shared/buildContext.js.map +1 -0
  19. package/bin/shared/constants.d.ts +1 -1
  20. package/bin/shared/constants.js.map +1 -1
  21. package/bin/shared/copyKeycloakResourcesToPublic.d.ts +8 -0
  22. package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -0
  23. package/bin/shared/downloadKeycloakDefaultTheme.d.ts +10 -0
  24. package/bin/shared/downloadKeycloakDefaultTheme.js.map +1 -0
  25. package/bin/shared/downloadKeycloakStaticResources.d.ts +9 -0
  26. package/bin/shared/downloadKeycloakStaticResources.js.map +1 -0
  27. package/bin/shared/generateKcGenTs.d.ts +12 -0
  28. package/bin/shared/generateKcGenTs.js.map +1 -0
  29. package/bin/shared/metaInfKeycloakThemes.d.ts +13 -0
  30. package/bin/shared/metaInfKeycloakThemes.js.map +1 -0
  31. package/bin/shared/promptKeycloakVersion.d.ts +7 -0
  32. package/bin/shared/promptKeycloakVersion.js.map +1 -0
  33. package/package.json +21 -12
  34. package/src/bin/add-story.ts +1 -6
  35. package/src/bin/eject-page.ts +7 -8
  36. package/src/bin/initialize-email-theme.ts +1 -6
  37. package/src/bin/keycloakify/buildJars/buildJars.ts +23 -49
  38. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +15 -20
  39. package/src/bin/keycloakify/keycloakify.ts +6 -8
  40. package/src/bin/shared/buildContext.ts +434 -42
  41. package/src/bin/shared/constants.ts +2 -1
  42. package/src/bin/shared/generateKcGenTs.ts +2 -6
  43. package/src/bin/start-keycloak/keycloakifyBuild.ts +4 -4
  44. package/src/bin/start-keycloak/start-keycloak.ts +40 -83
  45. package/src/vite-plugin/vite-plugin.ts +5 -4
  46. package/vite-plugin/index.js +341 -117
  47. package/bin/480.index.js +0 -466
  48. package/bin/818.index.js +0 -1802
  49. package/bin/827.index.js +0 -1094
  50. package/bin/shared/constants.js +0 -59
  51. package/src/bin/shared/getImplementedThemeTypes.ts +0 -38
  52. package/src/bin/shared/getJarFileBasename.ts +0 -11
  53. package/src/bin/shared/getThemeSrcDirPath.ts +0 -62
@@ -2,12 +2,9 @@ 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 { getImplementedThemeTypes } from "../shared/getImplementedThemeTypes";
6
5
  import { accountV1ThemeName, containerName } from "../shared/constants";
7
6
  import { SemVer } from "../tools/SemVer";
8
- import type { KeycloakVersionRange } from "../shared/KeycloakVersionRange";
9
- import { getJarFileBasename } from "../shared/getJarFileBasename";
10
- import { assert, type Equals } from "tsafe/assert";
7
+ import { assert } from "tsafe/assert";
11
8
  import * as fs from "fs";
12
9
  import {
13
10
  join as pathJoin,
@@ -91,83 +88,30 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
91
88
 
92
89
  const buildContext = getBuildContext({ cliCommandOptions });
93
90
 
94
- const { keycloakVersion, keycloakMajorNumber: keycloakMajorVersionNumber } =
95
- await (async () => {
96
- if (cliCommandOptions.keycloakVersion !== undefined) {
97
- return {
98
- keycloakVersion: cliCommandOptions.keycloakVersion,
99
- keycloakMajorNumber: SemVer.parse(cliCommandOptions.keycloakVersion)
100
- .major
101
- };
102
- }
103
-
104
- console.log(
105
- chalk.cyan("On which version of Keycloak do you want to test your theme?")
106
- );
107
-
108
- const { keycloakVersion } = await promptKeycloakVersion({
109
- startingFromMajor: 18,
110
- excludeMajorVersions: [22],
111
- cacheDirPath: buildContext.cacheDirPath
112
- });
113
-
114
- console.log(`→ ${keycloakVersion}`);
115
-
116
- const keycloakMajorNumber = SemVer.parse(keycloakVersion).major;
117
-
118
- return { keycloakVersion, keycloakMajorNumber };
119
- })();
120
-
121
- const keycloakVersionRange: KeycloakVersionRange = (() => {
122
- const doesImplementAccountTheme = getImplementedThemeTypes({
123
- projectDirPath: buildContext.projectDirPath
124
- }).implementedThemeTypes.account;
125
-
126
- if (doesImplementAccountTheme) {
127
- const keycloakVersionRange = (() => {
128
- if (keycloakMajorVersionNumber <= 21) {
129
- return "21-and-below" as const;
130
- }
131
-
132
- assert(keycloakMajorVersionNumber !== 22);
133
-
134
- if (keycloakMajorVersionNumber === 23) {
135
- return "23" as const;
136
- }
137
-
138
- if (keycloakMajorVersionNumber === 24) {
139
- return "24" as const;
140
- }
141
-
142
- return "25-and-above" as const;
143
- })();
144
-
145
- assert<
146
- Equals<typeof keycloakVersionRange, KeycloakVersionRange.WithAccountTheme>
147
- >();
91
+ const { keycloakVersion } = await (async () => {
92
+ if (cliCommandOptions.keycloakVersion !== undefined) {
93
+ return {
94
+ keycloakVersion: cliCommandOptions.keycloakVersion,
95
+ keycloakMajorNumber: SemVer.parse(cliCommandOptions.keycloakVersion).major
96
+ };
97
+ }
148
98
 
149
- return keycloakVersionRange;
150
- } else {
151
- const keycloakVersionRange = (() => {
152
- if (keycloakMajorVersionNumber <= 21) {
153
- return "21-and-below" as const;
154
- }
99
+ console.log(
100
+ chalk.cyan("On which version of Keycloak do you want to test your theme?")
101
+ );
155
102
 
156
- return "22-and-above" as const;
157
- })();
103
+ const { keycloakVersion } = await promptKeycloakVersion({
104
+ startingFromMajor: 18,
105
+ excludeMajorVersions: [22],
106
+ cacheDirPath: buildContext.cacheDirPath
107
+ });
158
108
 
159
- assert<
160
- Equals<
161
- typeof keycloakVersionRange,
162
- KeycloakVersionRange.WithoutAccountTheme
163
- >
164
- >();
109
+ console.log(`→ ${keycloakVersion}`);
165
110
 
166
- return keycloakVersionRange;
167
- }
111
+ return { keycloakVersion };
168
112
  })();
169
113
 
170
- const { jarFileBasename } = getJarFileBasename({ keycloakVersionRange });
114
+ const keycloakMajorVersionNumber = SemVer.parse(keycloakVersion).major;
171
115
 
172
116
  {
173
117
  const { isAppBuildSuccess } = await appBuild({
@@ -177,28 +121,36 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
177
121
  if (!isAppBuildSuccess) {
178
122
  console.log(
179
123
  chalk.red(
180
- `App build failed, exiting. Try running 'npm run build-keycloak-theme' and see what's wrong.`
124
+ `App build failed, exiting. Try running 'npm run build' and see what's wrong.`
181
125
  )
182
126
  );
183
127
  process.exit(1);
184
128
  }
185
129
 
186
130
  const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
187
- onlyBuildJarFileBasename: jarFileBasename,
131
+ buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
188
132
  buildContext
189
133
  });
190
134
 
191
135
  if (!isKeycloakifyBuildSuccess) {
192
136
  console.log(
193
137
  chalk.red(
194
- `Keycloakify build failed, exiting. Try running 'npm run build-keycloak-theme' and see what's wrong.`
138
+ `Keycloakify build failed, exiting. Try running 'npx keycloakify build' and see what's wrong.`
195
139
  )
196
140
  );
197
141
  process.exit(1);
198
142
  }
199
143
  }
200
144
 
201
- console.log(`Using Keycloak ${chalk.bold(jarFileBasename)}`);
145
+ const jarFilePath = fs
146
+ .readdirSync(buildContext.keycloakifyBuildDirPath)
147
+ .filter(fileBasename => fileBasename.endsWith(".jar"))
148
+ .map(fileBasename => pathJoin(buildContext.keycloakifyBuildDirPath, fileBasename))
149
+ .sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs)[0];
150
+
151
+ assert(jarFilePath !== undefined);
152
+
153
+ console.log(`Using ${chalk.bold(pathBasename(jarFilePath))}`);
202
154
 
203
155
  const realmJsonFilePath = await (async () => {
204
156
  if (cliCommandOptions.realmJsonFilePath !== undefined) {
@@ -284,8 +236,6 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
284
236
  return filePath;
285
237
  })();
286
238
 
287
- const jarFilePath = pathJoin(buildContext.keycloakifyBuildDirPath, jarFileBasename);
288
-
289
239
  async function extractThemeResourcesFromJar() {
290
240
  await extractArchive({
291
241
  archiveFilePath: jarFilePath,
@@ -311,7 +261,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
311
261
 
312
262
  await extractThemeResourcesFromJar();
313
263
 
314
- const jarFilePath_cacheDir = pathJoin(buildContext.cacheDirPath, jarFileBasename);
264
+ const jarFilePath_cacheDir = pathJoin(
265
+ buildContext.cacheDirPath,
266
+ pathBasename(jarFilePath)
267
+ );
315
268
 
316
269
  fs.copyFileSync(jarFilePath, jarFilePath_cacheDir);
317
270
 
@@ -413,6 +366,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
413
366
 
414
367
  console.log(
415
368
  [
369
+ "",
370
+ `The ftl files from ${chalk.bold(
371
+ `.${pathSep}${pathRelative(process.cwd(), pathJoin(buildContext.keycloakifyBuildDirPath, "theme"))}`
372
+ )} are mounted in the Keycloak container.`,
416
373
  "",
417
374
  `Keycloak Admin console: ${chalk.cyan.bold(
418
375
  `http://localhost:${cliCommandOptions.port}`
@@ -453,7 +410,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
453
410
  }
454
411
 
455
412
  const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
456
- onlyBuildJarFileBasename: jarFileBasename,
413
+ buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
457
414
  buildContext
458
415
  });
459
416
 
@@ -44,11 +44,12 @@ export function keycloakify(params?: Params) {
44
44
  break run_post_build_script_case;
45
45
  }
46
46
 
47
- const buildContext = JSON.parse(envValue) as BuildContext;
47
+ const { buildContext, resourcesDirPath } = JSON.parse(envValue) as {
48
+ buildContext: BuildContext;
49
+ resourcesDirPath: string;
50
+ };
48
51
 
49
- process.chdir(
50
- pathJoin(buildContext.keycloakifyBuildDirPath, "resources")
51
- );
52
+ process.chdir(resourcesDirPath);
52
53
 
53
54
  await postBuild?.(buildContext);
54
55