Compare commits

..

14 Commits

10 changed files with 37 additions and 31 deletions

4
.github/FUNDING.yaml vendored Normal file
View File

@ -0,0 +1,4 @@
# These are supported funding model platforms
github: [garronej]
custom: ['https://www.ringerhq.com/experts/garronej']

View File

@ -3,11 +3,9 @@ on:
push: push:
branches: branches:
- main - main
- v6
pull_request: pull_request:
branches: branches:
- main - main
- v6
jobs: jobs:

View File

@ -2,7 +2,7 @@
<img src="https://user-images.githubusercontent.com/6702424/109387840-eba11f80-7903-11eb-9050-db1dad883f78.png"> <img src="https://user-images.githubusercontent.com/6702424/109387840-eba11f80-7903-11eb-9050-db1dad883f78.png">
</p> </p>
<p align="center"> <p align="center">
<i>🔏 Create Keycloak themes using React 🔏</i> <i>🔏 Create Keycloak themes using React 🔏</i>
<br> <br>
<br> <br>
<a href="https://github.com/garronej/keycloakify/actions"> <a href="https://github.com/garronej/keycloakify/actions">
@ -36,6 +36,10 @@
<img src="https://user-images.githubusercontent.com/6702424/110260457-a1c3d380-7fac-11eb-853a-80459b65626b.png"> <img src="https://user-images.githubusercontent.com/6702424/110260457-a1c3d380-7fac-11eb-853a-80459b65626b.png">
</p> </p>
> 🗣 V6 have been released 🎉
> [It features major improvements](https://github.com/InseeFrLab/keycloakify#600).
> Checkout [the migration guide](https://docs.keycloakify.dev/v5-to-v6).
# Changelog highlights # Changelog highlights
## 6.0.0 ## 6.0.0
@ -45,7 +49,7 @@
- Real i18n API. - Real i18n API.
- Actual documentation for build options. - Actual documentation for build options.
Checkout the migration guide. Checkout [the migration guide](https://docs.keycloakify.dev/v5-to-v6)
## 5.8.0 ## 5.8.0

View File

@ -1,6 +1,6 @@
{ {
"name": "keycloakify", "name": "keycloakify",
"version": "6.0.0-beta.14", "version": "6.0.2",
"description": "Keycloak theme generator for Reacts app", "description": "Keycloak theme generator for Reacts app",
"repository": { "repository": {
"type": "git", "type": "git",
@ -83,7 +83,7 @@
"react-markdown": "^5.0.3", "react-markdown": "^5.0.3",
"scripting-tools": "^0.19.13", "scripting-tools": "^0.19.13",
"tsafe": "^1.0.1", "tsafe": "^1.0.1",
"tss-react": "^4.0.0", "tss-react": "^4.1.1",
"zod": "^3.17.10" "zod": "^3.17.10"
} }
} }

View File

@ -11,7 +11,7 @@ type ParsedPackageJson = {
keycloakify?: { keycloakify?: {
extraPages?: string[]; extraPages?: string[];
extraThemeProperties?: string[]; extraThemeProperties?: string[];
isAppAndKeycloakServerSharingSameDomain?: boolean; areAppAndKeycloakServerSharingSameDomain?: boolean;
}; };
}; };
@ -23,7 +23,7 @@ const zParsedPackageJson = z.object({
.object({ .object({
"extraPages": z.array(z.string()).optional(), "extraPages": z.array(z.string()).optional(),
"extraThemeProperties": z.array(z.string()).optional(), "extraThemeProperties": z.array(z.string()).optional(),
"isAppAndKeycloakServerSharingSameDomain": z.boolean().optional() "areAppAndKeycloakServerSharingSameDomain": z.boolean().optional()
}) })
.optional() .optional()
}); });
@ -56,11 +56,11 @@ export namespace BuildOptions {
}; };
export type SameDomain = CommonExternalAssets & { export type SameDomain = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: true; areAppAndKeycloakServerSharingSameDomain: true;
}; };
export type DifferentDomains = CommonExternalAssets & { export type DifferentDomains = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: false; areAppAndKeycloakServerSharingSameDomain: false;
urlOrigin: string; urlOrigin: string;
urlPathname: string | undefined; urlPathname: string | undefined;
}; };
@ -140,10 +140,10 @@ export function readBuildOptions(params: {
"isStandalone": false "isStandalone": false
}); });
if (parsedPackageJson.keycloakify?.isAppAndKeycloakServerSharingSameDomain) { if (parsedPackageJson.keycloakify?.areAppAndKeycloakServerSharingSameDomain) {
return id<BuildOptions.ExternalAssets.SameDomain>({ return id<BuildOptions.ExternalAssets.SameDomain>({
...commonExternalAssets, ...commonExternalAssets,
"isAppAndKeycloakServerSharingSameDomain": true "areAppAndKeycloakServerSharingSameDomain": true
}); });
} else { } else {
assert( assert(
@ -155,14 +155,14 @@ export function readBuildOptions(params: {
"public/CNAME file.", "public/CNAME file.",
"Alternatively, if your app and the Keycloak server are on the same domain, ", "Alternatively, if your app and the Keycloak server are on the same domain, ",
"eg https://example.com is your app and https://example.com/auth is the keycloak", "eg https://example.com is your app and https://example.com/auth is the keycloak",
'admin UI, you can set "keycloakify": { "isAppAndKeycloakServerSharingSameDomain": true }', 'admin UI, you can set "keycloakify": { "areAppAndKeycloakServerSharingSameDomain": true }',
"in your package.json" "in your package.json"
].join(" ") ].join(" ")
); );
return id<BuildOptions.ExternalAssets.DifferentDomains>({ return id<BuildOptions.ExternalAssets.DifferentDomains>({
...commonExternalAssets, ...commonExternalAssets,
"isAppAndKeycloakServerSharingSameDomain": false, "areAppAndKeycloakServerSharingSameDomain": false,
"urlOrigin": url.origin, "urlOrigin": url.origin,
"urlPathname": url.pathname "urlPathname": url.pathname
}); });

View File

@ -46,11 +46,11 @@ export namespace BuildOptionsLike {
}; };
export type SameDomain = CommonExternalAssets & { export type SameDomain = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: true; areAppAndKeycloakServerSharingSameDomain: true;
}; };
export type DifferentDomains = CommonExternalAssets & { export type DifferentDomains = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: false; areAppAndKeycloakServerSharingSameDomain: false;
urlOrigin: string; urlOrigin: string;
urlPathname: string | undefined; urlPathname: string | undefined;
}; };
@ -76,7 +76,7 @@ export function generateFtlFilesCodeFactory(params: {
const $ = cheerio.load(indexHtmlCode); const $ = cheerio.load(indexHtmlCode);
fix_imports_statements: { fix_imports_statements: {
if (!buildOptions.isStandalone && buildOptions.isAppAndKeycloakServerSharingSameDomain) { if (!buildOptions.isStandalone && buildOptions.areAppAndKeycloakServerSharingSameDomain) {
break fix_imports_statements; break fix_imports_statements;
} }

View File

@ -34,11 +34,11 @@ export namespace BuildOptionsLike {
}; };
export type SameDomain = CommonExternalAssets & { export type SameDomain = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: true; areAppAndKeycloakServerSharingSameDomain: true;
}; };
export type DifferentDomains = CommonExternalAssets & { export type DifferentDomains = CommonExternalAssets & {
isAppAndKeycloakServerSharingSameDomain: false; areAppAndKeycloakServerSharingSameDomain: false;
urlOrigin: string; urlOrigin: string;
urlPathname: string | undefined; urlPathname: string | undefined;
}; };
@ -97,7 +97,7 @@ export function generateKeycloakThemeResources(params: {
} }
if (/\.js?$/i.test(filePath)) { if (/\.js?$/i.test(filePath)) {
if (!buildOptions.isStandalone && buildOptions.isAppAndKeycloakServerSharingSameDomain) { if (!buildOptions.isStandalone && buildOptions.areAppAndKeycloakServerSharingSameDomain) {
return undefined; return undefined;
} }

View File

@ -57,7 +57,7 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string; build
: ` : `
var p= ""; var p= "";
Object.defineProperty(${n}, "p", { Object.defineProperty(${n}, "p", {
get: function() { return "${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : p; }, get: function() { return "${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : p; },
set: function (value){ p = value;} set: function (value){ p = value;}
}); });
` `
@ -73,13 +73,13 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string; build
.replace(/([a-zA-Z]+\.[a-zA-Z]+)\+"static\//g, (...[, group]) => .replace(/([a-zA-Z]+\.[a-zA-Z]+)\+"static\//g, (...[, group]) =>
buildOptions.isStandalone buildOptions.isStandalone
? `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/` ? `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`
: `("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : ${group}) + "static/` : `("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : ${group}) + "static/`
) )
//TODO: Write a test case for this //TODO: Write a test case for this
.replace(/".chunk.css",([a-zA-Z])+=([a-zA-Z]+\.[a-zA-Z]+)\+([a-zA-Z]+),/, (...[, group1, group2, group3]) => .replace(/".chunk.css",([a-zA-Z])+=([a-zA-Z]+\.[a-zA-Z]+)\+([a-zA-Z]+),/, (...[, group1, group2, group3]) =>
buildOptions.isStandalone buildOptions.isStandalone
? `".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group3},` ? `".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group3},`
: `".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : ${group2}) + ${group3},` : `".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : ${group2}) + ${group3},`
); );
return { fixedJsCode }; return { fixedJsCode };

View File

@ -103,13 +103,13 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
const fixedJsCodeExpected = ` const fixedJsCodeExpected = `
function f() { function f() {
return ("kcContext" in window ? "https://demo-app.keycloakify.dev" : a.p) + "static/js/" + ({}[e] || e) + "." + { return ("kcContext" in window ? "https://demo-app.keycloakify.dev/" : a.p) + "static/js/" + ({}[e] || e) + "." + {
3: "0664cdc0" 3: "0664cdc0"
}[e] + ".chunk.js" }[e] + ".chunk.js"
} }
function sameAsF() { function sameAsF() {
return ("kcContext" in window ? "https://demo-app.keycloakify.dev" : a.p) + "static/js/" + ({}[e] || e) + "." + { return ("kcContext" in window ? "https://demo-app.keycloakify.dev/" : a.p) + "static/js/" + ({}[e] || e) + "." + {
3: "0664cdc0" 3: "0664cdc0"
}[e] + ".chunk.js" }[e] + ".chunk.js"
} }
@ -119,7 +119,7 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
if( pd === undefined || pd.configurable ){ if( pd === undefined || pd.configurable ){
var p= ""; var p= "";
Object.defineProperty(__webpack_require__, "p", { Object.defineProperty(__webpack_require__, "p", {
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev" : p; }, get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev/" : p; },
set: function (value){ p = value; } set: function (value){ p = value; }
}); });
} }
@ -137,7 +137,7 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
if( pd === undefined || pd.configurable ){ if( pd === undefined || pd.configurable ){
var p= ""; var p= "";
Object.defineProperty(t, "p", { Object.defineProperty(t, "p", {
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev" : p; }, get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev/" : p; },
set: function (value){ p = value; } set: function (value){ p = value; }
}); });
} }

View File

@ -1733,10 +1733,10 @@ tslib@^2.1.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==
tss-react@^4.0.0: tss-react@^4.1.1:
version "4.0.0" version "4.1.1"
resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-4.0.0.tgz#cdd9d4c4ae24de04c13b9deff59b50fdf6ce10ae" resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-4.1.1.tgz#207220417e4b2f8eb26d8280ab9cdeb385063069"
integrity sha512-pPkOKWiWWPbKdQFnGGeHEgRceUwkjrv0eldVCAdBll3j6Y3Ys/xwqsnlWYwWOU3SMJygVRE/S4CsIYx6KPpOkA== integrity sha512-K1U2s/GGw+XycUjJGztJsLUhwm8KJWz5afL5WZU3SwMeQsA+gbETM6bSxVk2/DXBdw9uYLL9jkSYPAXh0tfYBw==
dependencies: dependencies:
"@emotion/cache" "*" "@emotion/cache" "*"
"@emotion/serialize" "*" "@emotion/serialize" "*"