keycloakify 10.0.0-rc.62 → 10.0.0-rc.64

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.
@@ -2,7 +2,7 @@ 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 { readMetaInfKeycloakThemes_fromJar } from "../shared/metaInfKeycloakThemes";
5
+ import { getImplementedThemeTypes } from "../shared/getImplementedThemeTypes";
6
6
  import { accountV1ThemeName, containerName } from "../shared/constants";
7
7
  import { SemVer } from "../tools/SemVer";
8
8
  import type { KeycloakVersionRange } from "../shared/KeycloakVersionRange";
@@ -91,66 +91,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
91
91
 
92
92
  const buildContext = getBuildContext({ cliCommandOptions });
93
93
 
94
- {
95
- const { isAppBuildSuccess } = await appBuild({
96
- buildContext
97
- });
98
-
99
- if (!isAppBuildSuccess) {
100
- console.log(
101
- chalk.red(
102
- `App build failed, exiting. Try running 'yarn build-keycloak-theme' and see what's wrong.`
103
- )
104
- );
105
- process.exit(1);
106
- }
107
-
108
- const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
109
- onlyBuildJarFileBasename: undefined,
110
- buildContext
111
- });
112
-
113
- if (!isKeycloakifyBuildSuccess) {
114
- console.log(
115
- chalk.red(
116
- `Keycloakify build failed, exiting. Try running 'yarn build-keycloak-theme' and see what's wrong.`
117
- )
118
- );
119
- process.exit(1);
120
- }
121
- }
122
-
123
- const { doesImplementAccountTheme } = await (async () => {
124
- const latestJarFilePath = fs
125
- .readdirSync(buildContext.keycloakifyBuildDirPath)
126
- .filter(fileBasename => fileBasename.endsWith(".jar"))
127
- .map(fileBasename =>
128
- pathJoin(buildContext.keycloakifyBuildDirPath, fileBasename)
129
- )
130
- .sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs)[0];
131
-
132
- assert(latestJarFilePath !== undefined);
133
-
134
- const metaInfKeycloakThemes = await readMetaInfKeycloakThemes_fromJar({
135
- jarFilePath: latestJarFilePath
136
- });
137
-
138
- const mainThemeEntry = metaInfKeycloakThemes.themes.find(
139
- ({ name }) => name === buildContext.themeNames[0]
140
- );
141
-
142
- assert(mainThemeEntry !== undefined);
143
-
144
- const doesImplementAccountTheme = mainThemeEntry.types.includes("account");
145
-
146
- return { doesImplementAccountTheme };
147
- })();
148
-
149
94
  const { keycloakVersion, keycloakMajorNumber: keycloakMajorVersionNumber } =
150
- await (async function getKeycloakMajor(): Promise<{
151
- keycloakVersion: string;
152
- keycloakMajorNumber: number;
153
- }> {
95
+ await (async () => {
154
96
  if (cliCommandOptions.keycloakVersion !== undefined) {
155
97
  return {
156
98
  keycloakVersion: cliCommandOptions.keycloakVersion,
@@ -173,20 +115,14 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
173
115
 
174
116
  const keycloakMajorNumber = SemVer.parse(keycloakVersion).major;
175
117
 
176
- if (doesImplementAccountTheme && keycloakMajorNumber === 22) {
177
- console.log(
178
- [
179
- "Unfortunately, Keycloakify themes that implements an account theme do not work on Keycloak 22",
180
- "Please select any other Keycloak version"
181
- ].join(" ")
182
- );
183
- return getKeycloakMajor();
184
- }
185
-
186
118
  return { keycloakVersion, keycloakMajorNumber };
187
119
  })();
188
120
 
189
121
  const keycloakVersionRange: KeycloakVersionRange = (() => {
122
+ const doesImplementAccountTheme = getImplementedThemeTypes({
123
+ projectDirPath: buildContext.projectDirPath
124
+ }).implementedThemeTypes.account;
125
+
190
126
  if (doesImplementAccountTheme) {
191
127
  const keycloakVersionRange = (() => {
192
128
  if (keycloakMajorVersionNumber <= 21) {
@@ -233,6 +169,35 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
233
169
 
234
170
  const { jarFileBasename } = getJarFileBasename({ keycloakVersionRange });
235
171
 
172
+ {
173
+ const { isAppBuildSuccess } = await appBuild({
174
+ buildContext
175
+ });
176
+
177
+ if (!isAppBuildSuccess) {
178
+ console.log(
179
+ chalk.red(
180
+ `App build failed, exiting. Try running 'npm run build-keycloak-theme' and see what's wrong.`
181
+ )
182
+ );
183
+ process.exit(1);
184
+ }
185
+
186
+ const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
187
+ onlyBuildJarFileBasename: jarFileBasename,
188
+ buildContext
189
+ });
190
+
191
+ if (!isKeycloakifyBuildSuccess) {
192
+ console.log(
193
+ chalk.red(
194
+ `Keycloakify build failed, exiting. Try running 'npm run build-keycloak-theme' and see what's wrong.`
195
+ )
196
+ );
197
+ process.exit(1);
198
+ }
199
+ }
200
+
236
201
  console.log(`Using Keycloak ${chalk.bold(jarFileBasename)}`);
237
202
 
238
203
  const realmJsonFilePath = await (async () => {
@@ -421,7 +386,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
421
386
  ...(realmJsonFilePath === undefined ? [] : ["--import-realm"])
422
387
  ],
423
388
  {
424
- cwd: buildContext.keycloakifyBuildDirPath
389
+ cwd: buildContext.keycloakifyBuildDirPath,
390
+ shell: true
425
391
  }
426
392
  ] as const;
427
393