Compare commits
31 Commits
v10.0.0-rc
...
v10.0.0-rc
Author | SHA1 | Date | |
---|---|---|---|
dcaee9cb7f | |||
1d8b6c7792 | |||
c98dbe84c6 | |||
1785916d32 | |||
c6cf564842 | |||
380b739017 | |||
c3f3c55303 | |||
2c01018529 | |||
dd2edf3013 | |||
7f3cdf9fac | |||
f75a91fbc1 | |||
f151086bb1 | |||
7c833e6f10 | |||
885e8314e8 | |||
3bdd955ab6 | |||
9499587bad | |||
0879ddba7c | |||
106a1dd4c7 | |||
5580248bcd | |||
c9c10b8fba | |||
ed254922e9 | |||
4b7d1e2cec | |||
775ae57258 | |||
96e4cd79ee | |||
bb70f7df4f | |||
602de2e407 | |||
225ced989c | |||
ab53698f34 | |||
02f2124126 | |||
66623e3324 | |||
4cc886fd04 |
@ -240,6 +240,15 @@
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "oliviergoulet5",
|
||||
"name": "Olivier Goulet",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/17685861?v=4",
|
||||
"profile": "https://github.com/oliviergoulet5",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
@ -43,7 +43,8 @@
|
||||
|
||||
Keycloakify is fully compatible with Keycloak 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, [~~22~~](https://github.com/keycloakify/keycloakify/issues/389#issuecomment-1822509763), 23, 24, 25...[and beyond](https://github.com/keycloakify/keycloakify/discussions/346#discussioncomment-5889791)
|
||||
|
||||
> NOTE: Keycloakify 10 is still in release-candidate state. [Follow progress](https://github.com/keycloakify/keycloakify/pull/538).
|
||||
> NOTE: Keycloakify 10, while still being tagged as release candidate is the version you should use if you are starting today.
|
||||
> Use `yarn add keycloakify@next` or pin [the latest version candidate](https://www.npmjs.com/package/keycloakify?activeTab=versions).
|
||||
|
||||
## Sponsors
|
||||
|
||||
@ -131,6 +132,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/law108000"><img src="https://avatars.githubusercontent.com/u/8112024?v=4?s=100" width="100px;" alt="Rlok"/><br /><sub><b>Rlok</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=law108000" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Moulyy"><img src="https://avatars.githubusercontent.com/u/115405804?v=4?s=100" width="100px;" alt="Moulyy"/><br /><sub><b>Moulyy</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=Moulyy" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/madmadson"><img src="https://avatars.githubusercontent.com/u/798831?v=4?s=100" width="100px;" alt="Tobias Matt"/><br /><sub><b>Tobias Matt</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=madmadson" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oliviergoulet5"><img src="https://avatars.githubusercontent.com/u/17685861?v=4?s=100" width="100px;" alt="Olivier Goulet"/><br /><sub><b>Olivier Goulet</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=oliviergoulet5" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "keycloakify",
|
||||
"version": "10.0.0-rc.136",
|
||||
"version": "10.0.0-rc.148",
|
||||
"description": "Create Keycloak themes using React",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -78,7 +78,7 @@ program
|
||||
|
||||
program
|
||||
.command<{
|
||||
port: number;
|
||||
port: number | undefined;
|
||||
keycloakVersion: string | undefined;
|
||||
realmJsonFilePath: string | undefined;
|
||||
}>({
|
||||
@ -96,7 +96,7 @@ program
|
||||
return name;
|
||||
})(),
|
||||
description: ["Keycloak server port.", "Example `--port 8085`"].join(" "),
|
||||
defaultValue: 8080
|
||||
defaultValue: undefined
|
||||
})
|
||||
.option({
|
||||
key: "keycloakVersion",
|
||||
|
@ -61,6 +61,19 @@ export type BuildContext = {
|
||||
keycloakVersionRange: KeycloakVersionRange;
|
||||
jarFileBasename: string;
|
||||
}[];
|
||||
startKeycloakOptions: {
|
||||
dockerImage:
|
||||
| {
|
||||
reference: string;
|
||||
tag: string;
|
||||
}
|
||||
| undefined;
|
||||
dockerExtraArgs: string[];
|
||||
keycloakExtraArgs: string[];
|
||||
extensionJars: ({ type: "path"; path: string } | { type: "url"; url: string })[];
|
||||
realmJsonFilePath: string | undefined;
|
||||
port: number | undefined;
|
||||
};
|
||||
};
|
||||
|
||||
assert<Equals<keyof BuildContext["implementedThemeTypes"], ThemeType | "email">>();
|
||||
@ -75,6 +88,14 @@ export type BuildOptions = {
|
||||
loginThemeResourcesFromKeycloakVersion?: string;
|
||||
keycloakifyBuildDirPath?: string;
|
||||
kcContextExclusionsFtl?: string;
|
||||
startKeycloakOptions?: {
|
||||
dockerImage?: string;
|
||||
dockerExtraArgs?: string[];
|
||||
keycloakExtraArgs?: string[];
|
||||
extensionJars?: string[];
|
||||
realmJsonFilePath?: string;
|
||||
port?: number;
|
||||
};
|
||||
} & BuildOptions.AccountThemeImplAndKeycloakVersionTargets;
|
||||
|
||||
export namespace BuildOptions {
|
||||
@ -301,6 +322,23 @@ export function getBuildContext(params: {
|
||||
return id<z.ZodType<TargetType>>(zTargetType);
|
||||
})();
|
||||
|
||||
const zStartKeycloakOptions = (() => {
|
||||
type TargetType = NonNullable<BuildOptions["startKeycloakOptions"]>;
|
||||
|
||||
const zTargetType = z.object({
|
||||
dockerImage: z.string().optional(),
|
||||
extensionJars: z.array(z.string()).optional(),
|
||||
realmJsonFilePath: z.string().optional(),
|
||||
dockerExtraArgs: z.array(z.string()).optional(),
|
||||
keycloakExtraArgs: z.array(z.string()).optional(),
|
||||
port: z.number().optional()
|
||||
});
|
||||
|
||||
assert<Equals<z.infer<typeof zTargetType>, TargetType>>();
|
||||
|
||||
return id<z.ZodType<TargetType>>(zTargetType);
|
||||
})();
|
||||
|
||||
const zBuildOptions = (() => {
|
||||
type TargetType = BuildOptions;
|
||||
|
||||
@ -321,7 +359,8 @@ export function getBuildContext(params: {
|
||||
groupId: z.string().optional(),
|
||||
loginThemeResourcesFromKeycloakVersion: z.string().optional(),
|
||||
keycloakifyBuildDirPath: z.string().optional(),
|
||||
kcContextExclusionsFtl: z.string().optional()
|
||||
kcContextExclusionsFtl: z.string().optional(),
|
||||
startKeycloakOptions: zStartKeycloakOptions.optional()
|
||||
}),
|
||||
zAccountThemeImplAndKeycloakVersionTargets
|
||||
);
|
||||
@ -891,6 +930,48 @@ export function getBuildContext(params: {
|
||||
}
|
||||
|
||||
return jarTargets;
|
||||
})()
|
||||
})(),
|
||||
startKeycloakOptions: {
|
||||
dockerImage: (() => {
|
||||
if (buildOptions.startKeycloakOptions?.dockerImage === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const [reference, tag, ...rest] =
|
||||
buildOptions.startKeycloakOptions.dockerImage.split(":");
|
||||
|
||||
assert(
|
||||
reference !== undefined && tag !== undefined && rest.length === 0,
|
||||
`Invalid docker image: ${buildOptions.startKeycloakOptions.dockerImage}`
|
||||
);
|
||||
|
||||
return { reference, tag };
|
||||
})(),
|
||||
dockerExtraArgs: buildOptions.startKeycloakOptions?.dockerExtraArgs ?? [],
|
||||
keycloakExtraArgs: buildOptions.startKeycloakOptions?.keycloakExtraArgs ?? [],
|
||||
extensionJars: (buildOptions.startKeycloakOptions?.extensionJars ?? []).map(
|
||||
urlOrPath => {
|
||||
if (/^https?:\/\//.test(urlOrPath)) {
|
||||
return { type: "url", url: urlOrPath };
|
||||
}
|
||||
|
||||
return {
|
||||
type: "path",
|
||||
path: getAbsoluteAndInOsFormatPath({
|
||||
pathIsh: urlOrPath,
|
||||
cwd: projectDirPath
|
||||
})
|
||||
};
|
||||
}
|
||||
),
|
||||
realmJsonFilePath:
|
||||
buildOptions.startKeycloakOptions?.realmJsonFilePath === undefined
|
||||
? undefined
|
||||
: getAbsoluteAndInOsFormatPath({
|
||||
pathIsh: buildOptions.startKeycloakOptions.realmJsonFilePath,
|
||||
cwd: projectDirPath
|
||||
}),
|
||||
port: buildOptions.startKeycloakOptions?.port
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export async function promptKeycloakVersion(params: {
|
||||
});
|
||||
|
||||
const lastMajorVersions = Array.from(semVersionedTagByMajor.values()).map(
|
||||
({ tag }) => tag
|
||||
({ version }) => `${version.major}.${version.minor}`
|
||||
);
|
||||
|
||||
const { value } = await cliSelect<string>({
|
||||
|
@ -40,7 +40,7 @@ async function appBuild_vite(params: {
|
||||
|
||||
const dIsSuccess = new Deferred<boolean>();
|
||||
|
||||
console.log(chalk.blue("Running: 'npx vite build'"));
|
||||
console.log(chalk.blue("$ npx vite build"));
|
||||
|
||||
const child = child_process.spawn("npx", ["vite", "build"], {
|
||||
cwd: buildContext.projectDirPath,
|
||||
@ -145,7 +145,7 @@ async function appBuild_webpack(params: {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(chalk.blue(`Running: '${subCommand}'`));
|
||||
console.log(chalk.blue(`$ ${subCommand}`));
|
||||
|
||||
const child = child_process.spawn(command, args, {
|
||||
cwd: commandCwd,
|
||||
|
@ -20,7 +20,7 @@ export async function keycloakifyBuild(params: {
|
||||
|
||||
const dResult = new Deferred<{ isSuccess: boolean }>();
|
||||
|
||||
console.log(chalk.blue("Running: 'npx keycloakify build'"));
|
||||
console.log(chalk.blue("$ npx keycloakify build"));
|
||||
|
||||
const child = child_process.spawn("npx", ["keycloakify", "build"], {
|
||||
cwd: buildContext.projectDirPath,
|
||||
|
@ -4,7 +4,7 @@ import type { CliCommandOptions as CliCommandOptions_common } from "../main";
|
||||
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
||||
import { ACCOUNT_V1_THEME_NAME, CONTAINER_NAME } from "../shared/constants";
|
||||
import { SemVer } from "../tools/SemVer";
|
||||
import { assert } from "tsafe/assert";
|
||||
import { assert, type Equals } from "tsafe/assert";
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
join as pathJoin,
|
||||
@ -26,9 +26,10 @@ import { keycloakifyBuild } from "./keycloakifyBuild";
|
||||
import { isInside } from "../tools/isInside";
|
||||
import { existsAsync } from "../tools/fs.existsAsync";
|
||||
import { rm } from "../tools/fs.rm";
|
||||
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
||||
|
||||
export type CliCommandOptions = CliCommandOptions_common & {
|
||||
port: number;
|
||||
port: number | undefined;
|
||||
keycloakVersion: string | undefined;
|
||||
realmJsonFilePath: string | undefined;
|
||||
};
|
||||
@ -88,11 +89,14 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
|
||||
const buildContext = getBuildContext({ cliCommandOptions });
|
||||
|
||||
const { keycloakVersion } = await (async () => {
|
||||
const { dockerImageTag } = await (async () => {
|
||||
if (cliCommandOptions.keycloakVersion !== undefined) {
|
||||
return { dockerImageTag: cliCommandOptions.keycloakVersion };
|
||||
}
|
||||
|
||||
if (buildContext.startKeycloakOptions.dockerImage !== undefined) {
|
||||
return {
|
||||
keycloakVersion: cliCommandOptions.keycloakVersion,
|
||||
keycloakMajorNumber: SemVer.parse(cliCommandOptions.keycloakVersion).major
|
||||
dockerImageTag: buildContext.startKeycloakOptions.dockerImage.tag
|
||||
};
|
||||
}
|
||||
|
||||
@ -115,10 +119,35 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
|
||||
console.log(`→ ${keycloakVersion}`);
|
||||
|
||||
return { keycloakVersion };
|
||||
return { dockerImageTag: keycloakVersion };
|
||||
})();
|
||||
|
||||
const keycloakMajorVersionNumber = SemVer.parse(keycloakVersion).major;
|
||||
const keycloakMajorVersionNumber = (() => {
|
||||
if (buildContext.startKeycloakOptions.dockerImage === undefined) {
|
||||
return SemVer.parse(dockerImageTag).major;
|
||||
}
|
||||
|
||||
const { tag } = buildContext.startKeycloakOptions.dockerImage;
|
||||
|
||||
const [wrap] = [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
|
||||
.map(majorVersionNumber => ({
|
||||
majorVersionNumber,
|
||||
index: tag.indexOf(`${majorVersionNumber}`)
|
||||
}))
|
||||
.filter(({ index }) => index !== -1)
|
||||
.sort((a, b) => a.index - b.index);
|
||||
|
||||
if (wrap === undefined) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
`Could not determine the major Keycloak version number from the docker image tag ${tag}. Assuming 25`
|
||||
)
|
||||
);
|
||||
return 25;
|
||||
}
|
||||
|
||||
return wrap.majorVersionNumber;
|
||||
})();
|
||||
|
||||
{
|
||||
const { isAppBuildSuccess } = await appBuild({
|
||||
@ -157,26 +186,50 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
|
||||
assert(jarFilePath !== undefined);
|
||||
|
||||
console.log(`Using ${chalk.bold(pathBasename(jarFilePath))}`);
|
||||
const extensionJarFilePaths = await Promise.all(
|
||||
buildContext.startKeycloakOptions.extensionJars.map(async extensionJar => {
|
||||
switch (extensionJar.type) {
|
||||
case "path": {
|
||||
assert(
|
||||
await existsAsync(extensionJar.path),
|
||||
`${extensionJar.path} does not exist`
|
||||
);
|
||||
return extensionJar.path;
|
||||
}
|
||||
case "url": {
|
||||
const { archiveFilePath } = await downloadAndExtractArchive({
|
||||
cacheDirPath: buildContext.cacheDirPath,
|
||||
fetchOptions: buildContext.fetchOptions,
|
||||
url: extensionJar.url,
|
||||
uniqueIdOfOnArchiveFile: "no extraction",
|
||||
onArchiveFile: async () => {}
|
||||
});
|
||||
return archiveFilePath;
|
||||
}
|
||||
}
|
||||
assert<Equals<typeof extensionJar, never>>(false);
|
||||
})
|
||||
);
|
||||
|
||||
const realmJsonFilePath = await (async () => {
|
||||
if (cliCommandOptions.realmJsonFilePath !== undefined) {
|
||||
if (cliCommandOptions.realmJsonFilePath === "none") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
console.log(
|
||||
chalk.green(
|
||||
`Using realm json file: ${cliCommandOptions.realmJsonFilePath}`
|
||||
)
|
||||
);
|
||||
|
||||
return getAbsoluteAndInOsFormatPath({
|
||||
pathIsh: cliCommandOptions.realmJsonFilePath,
|
||||
cwd: process.cwd()
|
||||
});
|
||||
}
|
||||
|
||||
if (buildContext.startKeycloakOptions.realmJsonFilePath !== undefined) {
|
||||
assert(
|
||||
await existsAsync(buildContext.startKeycloakOptions.realmJsonFilePath),
|
||||
`${pathRelative(process.cwd(), buildContext.startKeycloakOptions.realmJsonFilePath)} does not exist`
|
||||
);
|
||||
return buildContext.startKeycloakOptions.realmJsonFilePath;
|
||||
}
|
||||
|
||||
const internalFilePath = await (async () => {
|
||||
const dirPath = pathJoin(
|
||||
getThisCodebaseRootDirPath(),
|
||||
@ -281,77 +334,105 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
});
|
||||
} catch {}
|
||||
|
||||
const spawnArgs = [
|
||||
"docker",
|
||||
[
|
||||
"run",
|
||||
...["-p", `${cliCommandOptions.port}:8080`],
|
||||
...["--name", CONTAINER_NAME],
|
||||
...["-e", "KEYCLOAK_ADMIN=admin"],
|
||||
...["-e", "KEYCLOAK_ADMIN_PASSWORD=admin"],
|
||||
...(realmJsonFilePath === undefined
|
||||
? []
|
||||
: [
|
||||
"-v",
|
||||
`"${realmJsonFilePath}":/opt/keycloak/data/import/myrealm-realm.json`
|
||||
]),
|
||||
...[
|
||||
"-v",
|
||||
`"${jarFilePath_cacheDir}":/opt/keycloak/providers/keycloak-theme.jar`
|
||||
],
|
||||
...(keycloakMajorVersionNumber <= 20
|
||||
? ["-e", "JAVA_OPTS=-Dkeycloak.profile=preview"]
|
||||
: []),
|
||||
...[
|
||||
...buildContext.themeNames,
|
||||
...(fs.existsSync(
|
||||
pathJoin(
|
||||
buildContext.keycloakifyBuildDirPath,
|
||||
"theme",
|
||||
ACCOUNT_V1_THEME_NAME
|
||||
)
|
||||
)
|
||||
? [ACCOUNT_V1_THEME_NAME]
|
||||
: [])
|
||||
]
|
||||
.map(themeName => ({
|
||||
localDirPath: pathJoin(
|
||||
buildContext.keycloakifyBuildDirPath,
|
||||
"theme",
|
||||
themeName
|
||||
),
|
||||
containerDirPath: `/opt/keycloak/themes/${themeName}`
|
||||
}))
|
||||
.map(({ localDirPath, containerDirPath }) => [
|
||||
"-v",
|
||||
`"${localDirPath}":${containerDirPath}:rw`
|
||||
])
|
||||
.flat(),
|
||||
...buildContext.environmentVariables
|
||||
.map(({ name }) => ({ name, envValue: process.env[name] }))
|
||||
.map(({ name, envValue }) =>
|
||||
envValue === undefined ? undefined : { name, envValue }
|
||||
)
|
||||
.filter(exclude(undefined))
|
||||
.map(({ name, envValue }) => [
|
||||
"--env",
|
||||
`${name}='${envValue.replace(/'/g, "'\\''")}'`
|
||||
])
|
||||
.flat(),
|
||||
`quay.io/keycloak/keycloak:${keycloakVersion}`,
|
||||
"start-dev",
|
||||
...(21 <= keycloakMajorVersionNumber && keycloakMajorVersionNumber < 24
|
||||
? ["--features=declarative-user-profile"]
|
||||
: []),
|
||||
...(realmJsonFilePath === undefined ? [] : ["--import-realm"])
|
||||
],
|
||||
{
|
||||
cwd: buildContext.keycloakifyBuildDirPath,
|
||||
shell: true
|
||||
}
|
||||
] as const;
|
||||
const DEFAULT_PORT = 8080;
|
||||
const port =
|
||||
cliCommandOptions.port ?? buildContext.startKeycloakOptions.port ?? DEFAULT_PORT;
|
||||
|
||||
const child = child_process.spawn(...spawnArgs);
|
||||
const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
|
||||
|
||||
const dockerRunArgs: string[] = [
|
||||
`-p${SPACE_PLACEHOLDER}${port}:8080`,
|
||||
`--name${SPACE_PLACEHOLDER}${CONTAINER_NAME}`,
|
||||
`-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN=admin`,
|
||||
`-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN_PASSWORD=admin`,
|
||||
...(buildContext.startKeycloakOptions.dockerExtraArgs.length === 0
|
||||
? []
|
||||
: [
|
||||
buildContext.startKeycloakOptions.dockerExtraArgs.join(
|
||||
SPACE_PLACEHOLDER
|
||||
)
|
||||
]),
|
||||
...(realmJsonFilePath === undefined
|
||||
? []
|
||||
: [
|
||||
`-v${SPACE_PLACEHOLDER}".${pathSep}${pathRelative(process.cwd(), realmJsonFilePath)}":/opt/keycloak/data/import/myrealm-realm.json`
|
||||
]),
|
||||
`-v${SPACE_PLACEHOLDER}".${pathSep}${pathRelative(process.cwd(), jarFilePath_cacheDir)}":/opt/keycloak/providers/keycloak-theme.jar`,
|
||||
...extensionJarFilePaths.map(
|
||||
jarFilePath =>
|
||||
`-v${SPACE_PLACEHOLDER}".${pathSep}${pathRelative(process.cwd(), jarFilePath)}":/opt/keycloak/providers/${pathBasename(jarFilePath)}`
|
||||
),
|
||||
...(keycloakMajorVersionNumber <= 20
|
||||
? [`-e${SPACE_PLACEHOLDER}JAVA_OPTS=-Dkeycloak.profile=preview`]
|
||||
: []),
|
||||
...[
|
||||
...buildContext.themeNames,
|
||||
...(fs.existsSync(
|
||||
pathJoin(
|
||||
buildContext.keycloakifyBuildDirPath,
|
||||
"theme",
|
||||
ACCOUNT_V1_THEME_NAME
|
||||
)
|
||||
)
|
||||
? [ACCOUNT_V1_THEME_NAME]
|
||||
: [])
|
||||
]
|
||||
.map(themeName => ({
|
||||
localDirPath: pathJoin(
|
||||
buildContext.keycloakifyBuildDirPath,
|
||||
"theme",
|
||||
themeName
|
||||
),
|
||||
containerDirPath: `/opt/keycloak/themes/${themeName}`
|
||||
}))
|
||||
.map(
|
||||
({ localDirPath, containerDirPath }) =>
|
||||
`-v${SPACE_PLACEHOLDER}".${pathSep}${pathRelative(process.cwd(), localDirPath)}":${containerDirPath}:rw`
|
||||
),
|
||||
...buildContext.environmentVariables
|
||||
.map(({ name }) => ({ name, envValue: process.env[name] }))
|
||||
.map(({ name, envValue }) =>
|
||||
envValue === undefined ? undefined : { name, envValue }
|
||||
)
|
||||
.filter(exclude(undefined))
|
||||
.map(
|
||||
({ name, envValue }) =>
|
||||
`--env${SPACE_PLACEHOLDER}${name}='${envValue.replace(/'/g, "'\\''")}'`
|
||||
),
|
||||
`${buildContext.startKeycloakOptions.dockerImage?.reference ?? "quay.io/keycloak/keycloak"}:${dockerImageTag}`,
|
||||
"start-dev",
|
||||
...(21 <= keycloakMajorVersionNumber && keycloakMajorVersionNumber < 24
|
||||
? ["--features=declarative-user-profile"]
|
||||
: []),
|
||||
...(realmJsonFilePath === undefined ? [] : ["--import-realm"]),
|
||||
...(buildContext.startKeycloakOptions.keycloakExtraArgs.length === 0
|
||||
? []
|
||||
: [
|
||||
buildContext.startKeycloakOptions.keycloakExtraArgs.join(
|
||||
SPACE_PLACEHOLDER
|
||||
)
|
||||
])
|
||||
];
|
||||
|
||||
console.log(
|
||||
chalk.blue(
|
||||
[
|
||||
`$ docker run \\`,
|
||||
...dockerRunArgs
|
||||
.map(arg => arg.replace(new RegExp(SPACE_PLACEHOLDER, "g"), " "))
|
||||
.map(
|
||||
(line, i, arr) =>
|
||||
` ${line}${arr.length - 1 === i ? "" : " \\"}`
|
||||
)
|
||||
].join("\n")
|
||||
)
|
||||
);
|
||||
|
||||
const child = child_process.spawn(
|
||||
"docker",
|
||||
["run", ...dockerRunArgs.map(line => line.split(SPACE_PLACEHOLDER)).flat()],
|
||||
{ shell: true }
|
||||
);
|
||||
|
||||
child.stdout.on("data", data => process.stdout.write(data));
|
||||
|
||||
@ -362,6 +443,18 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
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) => {
|
||||
if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) {
|
||||
return;
|
||||
@ -379,7 +472,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
)} are mounted in the Keycloak container.`,
|
||||
"",
|
||||
`Keycloak Admin console: ${chalk.cyan.bold(
|
||||
`http://localhost:${cliCommandOptions.port}`
|
||||
`http://localhost:${port}${kcHttpRelativePath ?? ""}`
|
||||
)}`,
|
||||
`- user: ${chalk.cyan.bold("admin")}`,
|
||||
`- password: ${chalk.cyan.bold("admin")}`,
|
||||
@ -387,7 +480,21 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
"",
|
||||
`${chalk.green("Your theme is accessible at:")}`,
|
||||
`${chalk.green("➜")} ${chalk.cyan.bold(
|
||||
`https://my-theme.keycloakify.dev${cliCommandOptions.port === 8080 ? "" : `?port=${cliCommandOptions.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:",
|
||||
|
@ -4,7 +4,6 @@ import { dirname as pathDirname, join as pathJoin } from "path";
|
||||
import { assert } from "tsafe/assert";
|
||||
import { extractArchive } from "./extractArchive";
|
||||
import { existsAsync } from "./fs.existsAsync";
|
||||
|
||||
import * as crypto from "crypto";
|
||||
import { rm } from "./fs.rm";
|
||||
|
||||
@ -21,7 +20,7 @@ export async function downloadAndExtractArchive(params: {
|
||||
}) => Promise<void>;
|
||||
cacheDirPath: string;
|
||||
fetchOptions: FetchOptions | undefined;
|
||||
}): Promise<{ extractedDirPath: string }> {
|
||||
}): Promise<{ extractedDirPath: string; archiveFilePath: string }> {
|
||||
const { url, uniqueIdOfOnArchiveFile, onArchiveFile, cacheDirPath, fetchOptions } =
|
||||
params;
|
||||
|
||||
@ -30,6 +29,8 @@ export async function downloadAndExtractArchive(params: {
|
||||
const archiveFilePath = pathJoin(cacheDirPath, archiveFileBasename);
|
||||
|
||||
download: {
|
||||
await mkdir(pathDirname(archiveFilePath), { recursive: true });
|
||||
|
||||
if (await existsAsync(archiveFilePath)) {
|
||||
const isDownloaded = await SuccessTracker.getIsDownloaded({
|
||||
cacheDirPath,
|
||||
@ -48,8 +49,6 @@ export async function downloadAndExtractArchive(params: {
|
||||
});
|
||||
}
|
||||
|
||||
await mkdir(pathDirname(archiveFilePath), { recursive: true });
|
||||
|
||||
const response = await fetch(url, fetchOptions);
|
||||
|
||||
response.body?.setMaxListeners(Number.MAX_VALUE);
|
||||
@ -136,7 +135,7 @@ export async function downloadAndExtractArchive(params: {
|
||||
});
|
||||
}
|
||||
|
||||
return { extractedDirPath };
|
||||
return { extractedDirPath, archiveFilePath };
|
||||
}
|
||||
|
||||
type SuccessTracker = {
|
||||
|
@ -58,7 +58,7 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps<
|
||||
<label htmlFor={attribute.name} className={kcClsx("kcLabelClass")}>
|
||||
{advancedMsg(attribute.displayName ?? "")}
|
||||
</label>
|
||||
{attribute.required && <>*</>}
|
||||
{attribute.required && <> *</>}
|
||||
</div>
|
||||
<div className={kcClsx("kcInputWrapperClass")}>
|
||||
{attribute.annotations.inputHelperTextBefore !== undefined && (
|
||||
|
@ -1394,14 +1394,10 @@ export function getButtonToDisplayForMultivaluedAttributeField(params: { attribu
|
||||
})();
|
||||
|
||||
if (maxCount === undefined) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (values.length === maxCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return values.length !== maxCount;
|
||||
})();
|
||||
|
||||
return { hasRemove, hasAdd };
|
||||
|
@ -153,7 +153,7 @@ export default function WebauthnRegister(props: PageProps<Extract<KcContext, { p
|
||||
|
||||
function getPubKeyCredParams(signatureAlgorithmsList) {
|
||||
let pubKeyCredParams = [];
|
||||
if (signatureAlgorithmsList === []) {
|
||||
if (signatureAlgorithmsList.length === 0) {
|
||||
pubKeyCredParams.push({type: "public-key", alg: -7});
|
||||
return pubKeyCredParams;
|
||||
}
|
||||
@ -184,7 +184,7 @@ export default function WebauthnRegister(props: PageProps<Extract<KcContext, { p
|
||||
}
|
||||
|
||||
function getTransportsAsString(transportsList) {
|
||||
if (transportsList === '' || transportsList.constructor !== Array) return "";
|
||||
if (transportsList === '' || Array.isArray(transportsList)) return "";
|
||||
|
||||
let transportsString = "";
|
||||
|
||||
|
Reference in New Issue
Block a user