keycloakify 10.0.0-rc.148 → 10.0.0-rc.149
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/526.index.js +24 -4
- package/package.json +1 -1
- package/src/bin/start-keycloak/start-keycloak.ts +53 -13
package/bin/526.index.js
CHANGED
@@ -663,6 +663,7 @@ async function command(params) {
|
|
663
663
|
}
|
664
664
|
(0,assert.assert)(false);
|
665
665
|
}));
|
666
|
+
const getRealmJsonFilePath_defaultForKeycloakMajor = (keycloakMajorVersionNumber) => (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", `myrealm-realm-${keycloakMajorVersionNumber}.json`);
|
666
667
|
const realmJsonFilePath = await (async () => {
|
667
668
|
if (cliCommandOptions.realmJsonFilePath !== undefined) {
|
668
669
|
if (cliCommandOptions.realmJsonFilePath === "none") {
|
@@ -678,13 +679,13 @@ async function command(params) {
|
|
678
679
|
return buildContext.startKeycloakOptions.realmJsonFilePath;
|
679
680
|
}
|
680
681
|
const internalFilePath = await (async () => {
|
681
|
-
const
|
682
|
-
|
683
|
-
|
684
|
-
return filePath;
|
682
|
+
const defaultFilePath = getRealmJsonFilePath_defaultForKeycloakMajor(keycloakMajorVersionNumber);
|
683
|
+
if (external_fs_.existsSync(defaultFilePath)) {
|
684
|
+
return defaultFilePath;
|
685
685
|
}
|
686
686
|
console.log(`${source_default().yellow(`Keycloakify do not have a realm configuration for Keycloak ${keycloakMajorVersionNumber} yet.`)}`);
|
687
687
|
console.log(source_default().cyan("Select what configuration to use:"));
|
688
|
+
const dirPath = (0,external_path_.dirname)(defaultFilePath);
|
688
689
|
const { value } = await dist_default()({
|
689
690
|
values: [
|
690
691
|
...external_fs_.readdirSync(dirPath)
|
@@ -708,6 +709,25 @@ async function command(params) {
|
|
708
709
|
.replace(/keycloakify\-starter/g, buildContext.themeNames[0])), "utf8");
|
709
710
|
return filePath;
|
710
711
|
})();
|
712
|
+
add_test_user_if_missing: {
|
713
|
+
if (realmJsonFilePath === undefined) {
|
714
|
+
break add_test_user_if_missing;
|
715
|
+
}
|
716
|
+
const realm = JSON.parse(external_fs_.readFileSync(realmJsonFilePath).toString("utf8"));
|
717
|
+
if (realm.users !== undefined) {
|
718
|
+
break add_test_user_if_missing;
|
719
|
+
}
|
720
|
+
const realmJsonFilePath_internal = (() => {
|
721
|
+
const filePath = getRealmJsonFilePath_defaultForKeycloakMajor(keycloakMajorVersionNumber);
|
722
|
+
if (!external_fs_.existsSync(filePath)) {
|
723
|
+
return getRealmJsonFilePath_defaultForKeycloakMajor(25);
|
724
|
+
}
|
725
|
+
return filePath;
|
726
|
+
})();
|
727
|
+
const users = JSON.parse(external_fs_.readFileSync(realmJsonFilePath_internal).toString("utf8")).users;
|
728
|
+
realm.users = users;
|
729
|
+
external_fs_.writeFileSync(realmJsonFilePath, JSON.stringify(realm, null, 2), "utf8");
|
730
|
+
}
|
711
731
|
async function extractThemeResourcesFromJar() {
|
712
732
|
await (0,extractArchive/* extractArchive */.N)({
|
713
733
|
archiveFilePath: jarFilePath,
|
package/package.json
CHANGED
@@ -10,7 +10,8 @@ import {
|
|
10
10
|
join as pathJoin,
|
11
11
|
relative as pathRelative,
|
12
12
|
sep as pathSep,
|
13
|
-
basename as pathBasename
|
13
|
+
basename as pathBasename,
|
14
|
+
dirname as pathDirname
|
14
15
|
} from "path";
|
15
16
|
import * as child_process from "child_process";
|
16
17
|
import chalk from "chalk";
|
@@ -211,6 +212,17 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
211
212
|
})
|
212
213
|
);
|
213
214
|
|
215
|
+
const getRealmJsonFilePath_defaultForKeycloakMajor = (
|
216
|
+
keycloakMajorVersionNumber: number
|
217
|
+
) =>
|
218
|
+
pathJoin(
|
219
|
+
getThisCodebaseRootDirPath(),
|
220
|
+
"src",
|
221
|
+
"bin",
|
222
|
+
"start-keycloak",
|
223
|
+
`myrealm-realm-${keycloakMajorVersionNumber}.json`
|
224
|
+
);
|
225
|
+
|
214
226
|
const realmJsonFilePath = await (async () => {
|
215
227
|
if (cliCommandOptions.realmJsonFilePath !== undefined) {
|
216
228
|
if (cliCommandOptions.realmJsonFilePath === "none") {
|
@@ -231,20 +243,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
231
243
|
}
|
232
244
|
|
233
245
|
const internalFilePath = await (async () => {
|
234
|
-
const
|
235
|
-
|
236
|
-
"src",
|
237
|
-
"bin",
|
238
|
-
"start-keycloak"
|
239
|
-
);
|
240
|
-
|
241
|
-
const filePath = pathJoin(
|
242
|
-
dirPath,
|
243
|
-
`myrealm-realm-${keycloakMajorVersionNumber}.json`
|
246
|
+
const defaultFilePath = getRealmJsonFilePath_defaultForKeycloakMajor(
|
247
|
+
keycloakMajorVersionNumber
|
244
248
|
);
|
245
249
|
|
246
|
-
if (fs.existsSync(
|
247
|
-
return
|
250
|
+
if (fs.existsSync(defaultFilePath)) {
|
251
|
+
return defaultFilePath;
|
248
252
|
}
|
249
253
|
|
250
254
|
console.log(
|
@@ -255,6 +259,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
255
259
|
|
256
260
|
console.log(chalk.cyan("Select what configuration to use:"));
|
257
261
|
|
262
|
+
const dirPath = pathDirname(defaultFilePath);
|
263
|
+
|
258
264
|
const { value } = await cliSelect<string>({
|
259
265
|
values: [
|
260
266
|
...fs
|
@@ -296,6 +302,40 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
296
302
|
return filePath;
|
297
303
|
})();
|
298
304
|
|
305
|
+
add_test_user_if_missing: {
|
306
|
+
if (realmJsonFilePath === undefined) {
|
307
|
+
break add_test_user_if_missing;
|
308
|
+
}
|
309
|
+
|
310
|
+
const realm: Record<string, unknown> = JSON.parse(
|
311
|
+
fs.readFileSync(realmJsonFilePath).toString("utf8")
|
312
|
+
);
|
313
|
+
|
314
|
+
if (realm.users !== undefined) {
|
315
|
+
break add_test_user_if_missing;
|
316
|
+
}
|
317
|
+
|
318
|
+
const realmJsonFilePath_internal = (() => {
|
319
|
+
const filePath = getRealmJsonFilePath_defaultForKeycloakMajor(
|
320
|
+
keycloakMajorVersionNumber
|
321
|
+
);
|
322
|
+
|
323
|
+
if (!fs.existsSync(filePath)) {
|
324
|
+
return getRealmJsonFilePath_defaultForKeycloakMajor(25);
|
325
|
+
}
|
326
|
+
|
327
|
+
return filePath;
|
328
|
+
})();
|
329
|
+
|
330
|
+
const users = JSON.parse(
|
331
|
+
fs.readFileSync(realmJsonFilePath_internal).toString("utf8")
|
332
|
+
).users;
|
333
|
+
|
334
|
+
realm.users = users;
|
335
|
+
|
336
|
+
fs.writeFileSync(realmJsonFilePath, JSON.stringify(realm, null, 2), "utf8");
|
337
|
+
}
|
338
|
+
|
299
339
|
async function extractThemeResourcesFromJar() {
|
300
340
|
await extractArchive({
|
301
341
|
archiveFilePath: jarFilePath,
|