Support parsing of the KC_HTTP_RELATIVE_PATH option

This commit is contained in:
Joseph Garrone 2024-08-19 00:25:41 +02:00
parent 5580248bcd
commit 106a1dd4c7
3 changed files with 31 additions and 4 deletions

View File

@ -314,7 +314,8 @@ export async function generateResourcesForMainTheme(params: {
} }
const { extractedDirPath } = await downloadAndExtractArchive({ const { extractedDirPath } = await downloadAndExtractArchive({
urlOrPath: "https://repo1.maven.org/maven2/org/keycloak/keycloak-account-ui/25.0.1/keycloak-account-ui-25.0.1.jar", urlOrPath:
"https://repo1.maven.org/maven2/org/keycloak/keycloak-account-ui/25.0.1/keycloak-account-ui-25.0.1.jar",
cacheDirPath: buildContext.cacheDirPath, cacheDirPath: buildContext.cacheDirPath,
fetchOptions: buildContext.fetchOptions, fetchOptions: buildContext.fetchOptions,
uniqueIdOfOnArchiveFile: "bring_in_account_v3_i18n_messages", uniqueIdOfOnArchiveFile: "bring_in_account_v3_i18n_messages",

View File

@ -431,6 +431,18 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
const srcDirPath = pathJoin(buildContext.projectDirPath, "src"); const srcDirPath = pathJoin(buildContext.projectDirPath, "src");
{ {
const kcHttpRelativePath = (() => {
const match = buildContext.startKeycloakOptions.dockerExtraArgs
.join(" ")
.match(/KC_HTTP_RELATIVE_PATH=([^ ]+)/);
if (match === null) {
return undefined;
}
return match[1];
})();
const handler = async (data: Buffer) => { const handler = async (data: Buffer) => {
if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) { if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) {
return; return;
@ -448,7 +460,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
)} are mounted in the Keycloak container.`, )} are mounted in the Keycloak container.`,
"", "",
`Keycloak Admin console: ${chalk.cyan.bold( `Keycloak Admin console: ${chalk.cyan.bold(
`http://localhost:${port}` `http://localhost:${port}${kcHttpRelativePath ?? ""}`
)}`, )}`,
`- user: ${chalk.cyan.bold("admin")}`, `- user: ${chalk.cyan.bold("admin")}`,
`- password: ${chalk.cyan.bold("admin")}`, `- password: ${chalk.cyan.bold("admin")}`,
@ -456,7 +468,21 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
"", "",
`${chalk.green("Your theme is accessible at:")}`, `${chalk.green("Your theme is accessible at:")}`,
`${chalk.green("➜")} ${chalk.cyan.bold( `${chalk.green("➜")} ${chalk.cyan.bold(
`https://my-theme.keycloakify.dev${port === DEFAULT_PORT ? "" : `?port=${port}`}` (() => {
const url = new URL("https://my-theme.keycloakify.dev");
if (port !== DEFAULT_PORT) {
url.searchParams.set("port", `${port}`);
}
if (kcHttpRelativePath !== undefined) {
url.searchParams.set(
"kcHttpRelativePath",
kcHttpRelativePath
);
}
return url.href;
})()
)}`, )}`,
"", "",
"You can login with the following credentials:", "You can login with the following credentials:",

View File

@ -21,7 +21,7 @@ export async function downloadAndExtractArchive(params: {
}) => Promise<void>; }) => Promise<void>;
cacheDirPath: string; cacheDirPath: string;
fetchOptions: FetchOptions | undefined; fetchOptions: FetchOptions | undefined;
}): Promise<{ extractedDirPath: string; archiveFilePath: string; }> { }): Promise<{ extractedDirPath: string; archiveFilePath: string }> {
const { const {
urlOrPath, urlOrPath,
uniqueIdOfOnArchiveFile, uniqueIdOfOnArchiveFile,