2024-07-13 19:33:59 +02:00
|
|
|
import { CONTAINER_NAME } from "../src/bin/shared/constants";
|
2024-05-20 15:34:07 +02:00
|
|
|
import child_process from "child_process";
|
|
|
|
import { SemVer } from "../src/bin/tools/SemVer";
|
2024-12-15 13:27:49 +01:00
|
|
|
import { dumpContainerConfig } from "../src/bin/start-keycloak/realmConfig/dumpContainerConfig";
|
|
|
|
import { cacheDirPath } from "./shared/cacheDirPath";
|
|
|
|
import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath";
|
2024-12-19 17:42:26 +01:00
|
|
|
import { writeRealmJsonFile } from "../src/bin/start-keycloak/realmConfig/ParsedRealmJson";
|
2024-12-15 13:27:49 +01:00
|
|
|
import { join as pathJoin } from "path";
|
2024-05-20 15:34:07 +02:00
|
|
|
import chalk from "chalk";
|
|
|
|
|
2024-06-10 20:51:00 +02:00
|
|
|
(async () => {
|
2024-12-10 04:12:28 +01:00
|
|
|
const keycloakMajorVersionNumber = SemVer.parse(
|
|
|
|
child_process
|
|
|
|
.execSync(`docker inspect --format '{{.Config.Image}}' ${CONTAINER_NAME}`)
|
|
|
|
.toString("utf8")
|
|
|
|
.trim()
|
|
|
|
.split(":")[1]
|
|
|
|
).major;
|
|
|
|
|
2024-12-15 13:27:49 +01:00
|
|
|
const parsedRealmJson = await dumpContainerConfig({
|
|
|
|
buildContext: {
|
|
|
|
cacheDirPath
|
|
|
|
},
|
|
|
|
keycloakMajorVersionNumber,
|
|
|
|
realmName: "myrealm"
|
|
|
|
});
|
|
|
|
|
2024-12-19 17:42:26 +01:00
|
|
|
const realmJsonFilePath = pathJoin(
|
2024-12-15 13:27:49 +01:00
|
|
|
getThisCodebaseRootDirPath(),
|
|
|
|
"src",
|
|
|
|
"bin",
|
|
|
|
"start-keycloak",
|
|
|
|
"realmConfig",
|
|
|
|
"defaultConfig",
|
|
|
|
`realm-kc-${keycloakMajorVersionNumber}.json`
|
2024-06-10 20:51:00 +02:00
|
|
|
);
|
|
|
|
|
2024-12-19 17:42:26 +01:00
|
|
|
await writeRealmJsonFile({
|
|
|
|
parsedRealmJson,
|
|
|
|
realmJsonFilePath,
|
|
|
|
keycloakMajorVersionNumber
|
2024-12-15 13:27:49 +01:00
|
|
|
});
|
|
|
|
|
2024-12-19 17:42:26 +01:00
|
|
|
console.log(chalk.green(`Realm config dumped to ${realmJsonFilePath}`));
|
2024-06-10 20:51:00 +02:00
|
|
|
})();
|