Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
1c2a55f2fd | |||
8aa0bd189e | |||
d648caa37f | |||
34263661d7 | |||
f4a6fd5c5e | |||
fc9ddfb8d8 | |||
f8d0aff386 | |||
ac100d74bf | |||
9b1e4e9111 | |||
3e54b64bc4 |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,3 +1,18 @@
|
|||||||
|
### **2.0.13** (2021-08-04)
|
||||||
|
|
||||||
|
- Merge pull request #28 from marcmrf/main
|
||||||
|
|
||||||
|
fix(mvn): scoped packages compatibility
|
||||||
|
- fix(mvn): scoped packages compatibility
|
||||||
|
|
||||||
|
### **2.0.12** (2021-07-28)
|
||||||
|
|
||||||
|
- Merge pull request #27 from jchn-codes/patch-1
|
||||||
|
|
||||||
|
add maven to requirements
|
||||||
|
- add maven to requirements
|
||||||
|
- Add #bluehats in the keyworks
|
||||||
|
|
||||||
### **2.0.11** (2021-07-21)
|
### **2.0.11** (2021-07-21)
|
||||||
|
|
||||||
- Spaces in file path #22
|
- Spaces in file path #22
|
||||||
|
15
README.md
15
README.md
@ -91,6 +91,14 @@ This tool assumes you are bundling your app with Webpack (tested with 4.44.2) .
|
|||||||
It assumes there is a `build/` directory at the root of your react project directory containing a `index.html` file
|
It assumes there is a `build/` directory at the root of your react project directory containing a `index.html` file
|
||||||
and a `build/static/` directory generated by webpack.
|
and a `build/static/` directory generated by webpack.
|
||||||
For more information see [this issue](https://github.com/InseeFrLab/keycloakify/issues/5#issuecomment-832296432)
|
For more information see [this issue](https://github.com/InseeFrLab/keycloakify/issues/5#issuecomment-832296432)
|
||||||
|
|
||||||
|
**All this is defaults with [`create-react-app`](https://create-react-app.dev)** (tested with 4.0.3)
|
||||||
|
|
||||||
|
- `mvn` ([Maven](https://maven.apache.org/)), `rm`, `mkdir`, `wget`, `unzip` are assumed to be available.
|
||||||
|
- `docker` must be up and running when running `yarn keycloak`.
|
||||||
|
|
||||||
|
On Windows you'll have to use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
|
||||||
|
|
||||||
## My framework doesn’t seem to be supported, what can I do?
|
## My framework doesn’t seem to be supported, what can I do?
|
||||||
|
|
||||||
Currently Keycloakify is only compatible with `create-react-app` apps.
|
Currently Keycloakify is only compatible with `create-react-app` apps.
|
||||||
@ -299,13 +307,6 @@ If you need to customize pages that are not supported yet or if you need to impl
|
|||||||
|
|
||||||
[Here is a demo repo](https://github.com/garronej/keycloakify-demo-app) to show how to automate
|
[Here is a demo repo](https://github.com/garronej/keycloakify-demo-app) to show how to automate
|
||||||
the building and publishing of the theme (the .jar file).
|
the building and publishing of the theme (the .jar file).
|
||||||
|
|
||||||
|
|
||||||
**All this is defaults with [`create-react-app`](https://create-react-app.dev)** (tested with 4.0.3)
|
|
||||||
|
|
||||||
- For building the theme: `mvn` (Maven) must be installed (but you can build the theme in the CI)
|
|
||||||
- For testing the theme in a local Keycloak container (which is not mandatory for development):
|
|
||||||
`rm`, `mkdir`, `wget`, `unzip` are assumed to be available and `docker` up and running.
|
|
||||||
# Limitations
|
# Limitations
|
||||||
## `process.env.PUBLIC_URL` not supported.
|
## `process.env.PUBLIC_URL` not supported.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
"version": "2.0.11",
|
"version": "2.0.13",
|
||||||
"description": "Keycloak theme generator for Reacts app",
|
"description": "Keycloak theme generator for Reacts app",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"!dist/tsconfig.tsbuildinfo"
|
"!dist/tsconfig.tsbuildinfo"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
"bluehats",
|
||||||
"keycloak",
|
"keycloak",
|
||||||
"react",
|
"react",
|
||||||
"theme",
|
"theme",
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
import { generateKeycloakThemeResources } from "./generateKeycloakThemeResources";
|
import { generateKeycloakThemeResources } from "./generateKeycloakThemeResources";
|
||||||
import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
||||||
import type { ParsedPackageJson } from "./generateJavaStackFiles";
|
|
||||||
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
|
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
|
|
||||||
|
type ParsedPackageJson = {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
homepage?: string;
|
||||||
|
};
|
||||||
|
|
||||||
const reactProjectDirPath = process.cwd();
|
const reactProjectDirPath = process.cwd();
|
||||||
|
|
||||||
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
||||||
@ -14,17 +19,21 @@ const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPat
|
|||||||
|
|
||||||
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
||||||
|
|
||||||
export function main() {
|
function sanitizeThemeName(name: string) {
|
||||||
|
return name.replace(/^@(.*)/, '$1').split('/').join('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function main() {
|
||||||
console.log("🔏 Building the keycloak theme...⌚");
|
console.log("🔏 Building the keycloak theme...⌚");
|
||||||
|
|
||||||
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
|
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
|
||||||
const extraThemeProperties: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraThemeProperties"] ?? [];
|
const extraThemeProperties: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraThemeProperties"] ?? [];
|
||||||
|
const themeName = sanitizeThemeName(parsedPackageJson.name);
|
||||||
|
|
||||||
generateKeycloakThemeResources({
|
generateKeycloakThemeResources({
|
||||||
keycloakThemeBuildingDirPath,
|
keycloakThemeBuildingDirPath,
|
||||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||||
"themeName": parsedPackageJson.name,
|
themeName,
|
||||||
...(() => {
|
...(() => {
|
||||||
|
|
||||||
const url = (() => {
|
const url = (() => {
|
||||||
@ -61,7 +70,9 @@ export function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { jarFilePath } = generateJavaStackFiles({
|
const { jarFilePath } = generateJavaStackFiles({
|
||||||
parsedPackageJson,
|
version: parsedPackageJson.version,
|
||||||
|
themeName,
|
||||||
|
homepage: parsedPackageJson.homepage,
|
||||||
keycloakThemeBuildingDirPath
|
keycloakThemeBuildingDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,7 +83,7 @@ export function main() {
|
|||||||
|
|
||||||
generateDebugFiles({
|
generateDebugFiles({
|
||||||
keycloakThemeBuildingDirPath,
|
keycloakThemeBuildingDirPath,
|
||||||
"packageJsonName": parsedPackageJson.name
|
themeName
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log([
|
console.log([
|
||||||
@ -106,7 +117,7 @@ export function main() {
|
|||||||
`👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
|
`👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
|
||||||
'',
|
'',
|
||||||
'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
|
'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
|
||||||
`go to your realm settings, click on the theme tab then select ${parsedPackageJson.name}.`,
|
`go to your realm settings, click on the theme tab then select ${themeName}.`,
|
||||||
`More details: https://www.keycloak.org/getting-started/getting-started-docker`,
|
`More details: https://www.keycloak.org/getting-started/getting-started-docker`,
|
||||||
'',
|
'',
|
||||||
'Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈',
|
'Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈',
|
||||||
|
@ -7,12 +7,12 @@ export const containerLaunchScriptBasename = "start_keycloak_testing_container.s
|
|||||||
/** Files for being able to run a hot reload keycloak container */
|
/** Files for being able to run a hot reload keycloak container */
|
||||||
export function generateDebugFiles(
|
export function generateDebugFiles(
|
||||||
params: {
|
params: {
|
||||||
packageJsonName: string;
|
themeName: string;
|
||||||
keycloakThemeBuildingDirPath: string;
|
keycloakThemeBuildingDirPath: string;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const { packageJsonName, keycloakThemeBuildingDirPath } = params;
|
const { themeName, keycloakThemeBuildingDirPath } = params;
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(keycloakThemeBuildingDirPath, "Dockerfile"),
|
pathJoin(keycloakThemeBuildingDirPath, "Dockerfile"),
|
||||||
@ -32,7 +32,7 @@ export function generateDebugFiles(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const dockerImage = `${packageJsonName}/keycloak-hot-reload`;
|
const dockerImage = `${themeName}/keycloak-hot-reload`;
|
||||||
const containerName = "keycloak-testing-container";
|
const containerName = "keycloak-testing-container";
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
@ -52,8 +52,8 @@ export function generateDebugFiles(
|
|||||||
` --name ${containerName} \\`,
|
` --name ${containerName} \\`,
|
||||||
" -e KEYCLOAK_USER=admin \\",
|
" -e KEYCLOAK_USER=admin \\",
|
||||||
" -e KEYCLOAK_PASSWORD=admin \\",
|
" -e KEYCLOAK_PASSWORD=admin \\",
|
||||||
` -v ${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", packageJsonName)
|
` -v ${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName)
|
||||||
}:/opt/jboss/keycloak/themes/${packageJsonName}:rw \\`,
|
}:/opt/jboss/keycloak/themes/${themeName}:rw \\`,
|
||||||
` -it ${dockerImage}:latest`,
|
` -it ${dockerImage}:latest`,
|
||||||
""
|
""
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
|
@ -3,21 +3,20 @@ import * as url from "url";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin, dirname as pathDirname } from "path";
|
import { join as pathJoin, dirname as pathDirname } from "path";
|
||||||
|
|
||||||
export type ParsedPackageJson = {
|
|
||||||
name: string;
|
|
||||||
version: string;
|
|
||||||
homepage?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function generateJavaStackFiles(
|
export function generateJavaStackFiles(
|
||||||
params: {
|
params: {
|
||||||
parsedPackageJson: ParsedPackageJson;
|
version: string;
|
||||||
|
themeName: string;
|
||||||
|
homepage?: string;
|
||||||
keycloakThemeBuildingDirPath: string;
|
keycloakThemeBuildingDirPath: string;
|
||||||
}
|
}
|
||||||
): { jarFilePath: string; } {
|
): { jarFilePath: string; } {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parsedPackageJson: { name, version, homepage },
|
themeName,
|
||||||
|
version,
|
||||||
|
homepage,
|
||||||
keycloakThemeBuildingDirPath
|
keycloakThemeBuildingDirPath
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
const groupId = (() => {
|
const groupId = (() => {
|
||||||
|
|
||||||
const fallbackGroupId = `there.was.no.homepage.field.in.the.package.json.${name}`;
|
const fallbackGroupId = `there.was.no.homepage.field.in.the.package.json.${themeName}`;
|
||||||
|
|
||||||
return (!homepage ?
|
return (!homepage ?
|
||||||
fallbackGroupId :
|
fallbackGroupId :
|
||||||
@ -37,7 +36,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const artefactId = `${name}-keycloak-theme`;
|
const artefactId = `${themeName}-keycloak-theme`;
|
||||||
|
|
||||||
const pomFileCode = [
|
const pomFileCode = [
|
||||||
`<?xml version="1.0"?>`,
|
`<?xml version="1.0"?>`,
|
||||||
@ -83,7 +82,7 @@ export function generateJavaStackFiles(
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
"themes": [
|
"themes": [
|
||||||
{
|
{
|
||||||
"name": name,
|
"name": themeName,
|
||||||
"types": ["login"]
|
"types": ["login"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -94,7 +93,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${name}-${version}.jar`) };
|
return { "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${themeName}-${version}.jar`) };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user