Compare commits
11 Commits
v9.0.0-rc.
...
v8.1.2
Author | SHA1 | Date | |
---|---|---|---|
96d5cfea14 | |||
79007ebd55 | |||
fcb519dac3 | |||
2b487aa959 | |||
733feadcb2 | |||
5ae568f19c | |||
0e51807856 | |||
b6eb165207 | |||
d26dbf4b3d | |||
a722582709 | |||
de64deb5c5 |
@ -158,6 +158,16 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "zavoloklom",
|
||||||
|
"name": "Sergey Kupletsky",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/4151869?v=4",
|
||||||
|
"profile": "https://github.com/zavoloklom",
|
||||||
|
"contributions": [
|
||||||
|
"test",
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
@ -165,5 +175,6 @@
|
|||||||
"repoType": "github",
|
"repoType": "github",
|
||||||
"repoHost": "https://github.com",
|
"repoHost": "https://github.com",
|
||||||
"projectName": "keycloakify",
|
"projectName": "keycloakify",
|
||||||
"projectOwner": "keycloakify"
|
"projectOwner": "keycloakify",
|
||||||
|
"commitType": "docs"
|
||||||
}
|
}
|
||||||
|
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- v*
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
@ -116,6 +116,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center" valign="top" width="14.28%"><a href="https://www.gravitysoftware.be"><img src="https://avatars.githubusercontent.com/u/1140574?v=4?s=100" width="100px;" alt="Thomas Silvestre"/><br /><sub><b>Thomas Silvestre</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=thosil" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://www.gravitysoftware.be"><img src="https://avatars.githubusercontent.com/u/1140574?v=4?s=100" width="100px;" alt="Thomas Silvestre"/><br /><sub><b>Thomas Silvestre</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=thosil" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/satanshiro"><img src="https://avatars.githubusercontent.com/u/38865738?v=4?s=100" width="100px;" alt="satanshiro"/><br /><sub><b>satanshiro</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=satanshiro" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/satanshiro"><img src="https://avatars.githubusercontent.com/u/38865738?v=4?s=100" width="100px;" alt="satanshiro"/><br /><sub><b>satanshiro</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=satanshiro" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://poelhekke.dev"><img src="https://avatars.githubusercontent.com/u/1632377?v=4?s=100" width="100px;" alt="Koen Poelhekke"/><br /><sub><b>Koen Poelhekke</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=kpoelhekke" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://poelhekke.dev"><img src="https://avatars.githubusercontent.com/u/1632377?v=4?s=100" width="100px;" alt="Koen Poelhekke"/><br /><sub><b>Koen Poelhekke</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=kpoelhekke" title="Code">💻</a></td>
|
||||||
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zavoloklom"><img src="https://avatars.githubusercontent.com/u/4151869?v=4?s=100" width="100px;" alt="Sergey Kupletsky"/><br /><sub><b>Sergey Kupletsky</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=zavoloklom" title="Tests">⚠️</a> <a href="https://github.com/keycloakify/keycloakify/commits?author=zavoloklom" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
"version": "8.0.0",
|
"version": "8.1.2",
|
||||||
"description": "Create Keycloak themes using React",
|
"description": "Create Keycloak themes using React",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -22,7 +22,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
|||||||
`${url.resourcesCommonPath}/node_modules/patternfly/dist/css/patternfly-additions.min.css`,
|
`${url.resourcesCommonPath}/node_modules/patternfly/dist/css/patternfly-additions.min.css`,
|
||||||
`${url.resourcesPath}/css/account.css`
|
`${url.resourcesPath}/css/account.css`
|
||||||
],
|
],
|
||||||
"htmlClassName": undefined,
|
"htmlClassName": getClassName("kcHtmlClass"),
|
||||||
"bodyClassName": clsx("admin-console", "user", getClassName("kcBodyClass"))
|
"bodyClassName": clsx("admin-console", "user", getClassName("kcBodyClass"))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,4 +11,4 @@ export type TemplateProps<KcContext extends KcContext.Common, I18nExtended exten
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClassKey = "kcBodyClass" | "kcButtonClass" | "kcButtonPrimaryClass" | "kcButtonLargeClass" | "kcButtonDefaultClass";
|
export type ClassKey = "kcHtmlClass" | "kcBodyClass" | "kcButtonClass" | "kcButtonPrimaryClass" | "kcButtonLargeClass" | "kcButtonDefaultClass";
|
||||||
|
@ -3,6 +3,7 @@ import type { ClassKey } from "keycloakify/account/TemplateProps";
|
|||||||
|
|
||||||
export const { useGetClassName } = createUseClassName<ClassKey>({
|
export const { useGetClassName } = createUseClassName<ClassKey>({
|
||||||
"defaultClasses": {
|
"defaultClasses": {
|
||||||
|
"kcHtmlClass": undefined,
|
||||||
"kcBodyClass": undefined,
|
"kcBodyClass": undefined,
|
||||||
"kcButtonClass": "btn",
|
"kcButtonClass": "btn",
|
||||||
"kcButtonPrimaryClass": "btn-primary",
|
"kcButtonPrimaryClass": "btn-primary",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
|
||||||
import type { ThemeType } from "../generateFtl";
|
import type { ThemeType } from "../generateFtl";
|
||||||
import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
|
import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,7 @@ import {
|
|||||||
basenameOfKeycloakDirInPublicDir
|
basenameOfKeycloakDirInPublicDir
|
||||||
} from "../../mockTestingResourcesPath";
|
} from "../../mockTestingResourcesPath";
|
||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
|
import { assert } from "tsafe/assert";
|
||||||
|
|
||||||
export async function downloadKeycloakStaticResources(
|
export async function downloadKeycloakStaticResources(
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@ -23,7 +24,32 @@ export async function downloadKeycloakStaticResources(
|
|||||||
} | undefined
|
} | undefined
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const { projectDirPath, themeType, themeDirPath, keycloakVersion, usedResources } = params;
|
const { projectDirPath, themeType, themeDirPath, keycloakVersion } = params;
|
||||||
|
|
||||||
|
// NOTE: Hack for 427
|
||||||
|
const usedResources = (() => {
|
||||||
|
const { usedResources } = params;
|
||||||
|
|
||||||
|
if (usedResources === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(usedResources !== undefined);
|
||||||
|
|
||||||
|
return {
|
||||||
|
"resourcesCommonDirPaths": usedResources.resourcesCommonFilePaths.map(filePath => {
|
||||||
|
{
|
||||||
|
const splitArg = "/dist/";
|
||||||
|
|
||||||
|
if (filePath.includes(splitArg)) {
|
||||||
|
return filePath.split(splitArg)[0] + splitArg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathDirname(filePath);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
const tmpDirPath = pathJoin(
|
const tmpDirPath = pathJoin(
|
||||||
themeDirPath,
|
themeDirPath,
|
||||||
@ -39,17 +65,7 @@ export async function downloadKeycloakStaticResources(
|
|||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
"srcDirPath": pathJoin(tmpDirPath, "keycloak", themeType, "resources"),
|
"srcDirPath": pathJoin(tmpDirPath, "keycloak", themeType, "resources"),
|
||||||
"destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesDirPathRelativeToPublicDir)),
|
"destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesDirPathRelativeToPublicDir))
|
||||||
"transformSourceCode":
|
|
||||||
usedResources === undefined
|
|
||||||
? undefined
|
|
||||||
: ({ fileRelativePath, sourceCode }) => {
|
|
||||||
if (!usedResources.resourcesFilePaths.includes(fileRelativePath)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { "modifiedSourceCode": sourceCode };
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
@ -59,7 +75,7 @@ export async function downloadKeycloakStaticResources(
|
|||||||
usedResources === undefined
|
usedResources === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: ({ fileRelativePath, sourceCode }) => {
|
: ({ fileRelativePath, sourceCode }) => {
|
||||||
if (!usedResources.resourcesCommonFilePaths.includes(fileRelativePath)) {
|
if (usedResources.resourcesCommonDirPaths.find(dirPath => fileRelativePath.startsWith(dirPath)) === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,18 +16,25 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string }): {
|
|||||||
const { jsCode } = params;
|
const { jsCode } = params;
|
||||||
|
|
||||||
const getReplaceArgs = (language: "js" | "css"): Parameters<typeof String.prototype.replace> => [
|
const getReplaceArgs = (language: "js" | "css"): Parameters<typeof String.prototype.replace> => [
|
||||||
new RegExp(`([a-zA-Z_]+)\\.([a-zA-Z]+)=function\\(([a-zA-Z]+)\\){return"static\\/${language}\\/"`, "g"),
|
new RegExp(`([a-zA-Z_]+)\\.([a-zA-Z]+)=(function\\(([a-z]+)\\){return|([a-z]+)=>)"static\\/${language}\\/"`, "g"),
|
||||||
(...[, n, u, e]) => `
|
(...[, n, u, matchedFunction, eForFunction]) => {
|
||||||
${n}[(function(){
|
const isArrowFunction = matchedFunction.includes("=>");
|
||||||
var pd= Object.getOwnPropertyDescriptor(${n}, "p");
|
const e = isArrowFunction ? matchedFunction.replace("=>", "").trim() : eForFunction;
|
||||||
|
|
||||||
|
return `
|
||||||
|
${n}[(function(){
|
||||||
|
var pd = Object.getOwnPropertyDescriptor(${n}, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(${n}, "p", {
|
Object.defineProperty(${n}, "p", {
|
||||||
get: function() { return window.${ftlValuesGlobalName}.url.resourcesPath; },
|
get: function() { return window.${ftlValuesGlobalName}.url.resourcesPath; },
|
||||||
set: function (){}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return "${u}";
|
return "${u}";
|
||||||
})()] = function(${e}) { return "${true ? "/build/" : ""}static/${language}/"`
|
})()] = ${isArrowFunction ? `${e} =>` : `function(${e}) { return `} "/build/static/${language}/"`
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const fixedJsCode = jsCode
|
const fixedJsCode = jsCode
|
||||||
|
@ -38,7 +38,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
|||||||
`${url.resourcesPath}/css/login.css`
|
`${url.resourcesPath}/css/login.css`
|
||||||
],
|
],
|
||||||
"htmlClassName": getClassName("kcHtmlClass"),
|
"htmlClassName": getClassName("kcHtmlClass"),
|
||||||
"bodyClassName": undefined
|
"bodyClassName": getClassName("kcBodyClass")
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
|
@ -21,6 +21,7 @@ export type TemplateProps<KcContext extends KcContext.Common, I18nExtended exten
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ClassKey =
|
export type ClassKey =
|
||||||
|
| "kcBodyClass"
|
||||||
| "kcHtmlClass"
|
| "kcHtmlClass"
|
||||||
| "kcLoginClass"
|
| "kcLoginClass"
|
||||||
| "kcHeaderClass"
|
| "kcHeaderClass"
|
||||||
|
@ -3,6 +3,7 @@ import type { ClassKey } from "keycloakify/login/TemplateProps";
|
|||||||
|
|
||||||
export const { useGetClassName } = createUseClassName<ClassKey>({
|
export const { useGetClassName } = createUseClassName<ClassKey>({
|
||||||
"defaultClasses": {
|
"defaultClasses": {
|
||||||
|
"kcBodyClass": undefined,
|
||||||
"kcHtmlClass": "login-pf",
|
"kcHtmlClass": "login-pf",
|
||||||
"kcLoginClass": "login-pf-page",
|
"kcLoginClass": "login-pf-page",
|
||||||
"kcContentWrapperClass": "row",
|
"kcContentWrapperClass": "row",
|
||||||
|
@ -32,6 +32,10 @@ describe("bin/js-transforms", () => {
|
|||||||
908:"67c9ed2c"
|
908:"67c9ed2c"
|
||||||
}[e]+".chunk.css"
|
}[e]+".chunk.css"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n.u=e=>"static/js/"+e+"."+{69:"4f205f87",128:"49264537",453:"b2fed72e",482:"f0106901"}[e]+".chunk.js"
|
||||||
|
|
||||||
|
t.miniCssF=e=>"static/css/"+e+"."+{164:"dcfd7749",908:"67c9ed2c"}[e]+".chunk.css"
|
||||||
`;
|
`;
|
||||||
it("transforms standalone code properly", () => {
|
it("transforms standalone code properly", () => {
|
||||||
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
|
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
|
||||||
@ -52,11 +56,11 @@ describe("bin/js-transforms", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__webpack_require__[(function (){
|
__webpack_require__[(function (){
|
||||||
var pd= Object.getOwnPropertyDescriptor(__webpack_require__, "p");
|
var pd = Object.getOwnPropertyDescriptor(__webpack_require__, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(__webpack_require__, "p", {
|
Object.defineProperty(__webpack_require__, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext.url.resourcesPath; },
|
||||||
set: function (){}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return "u";
|
return "u";
|
||||||
@ -69,11 +73,11 @@ describe("bin/js-transforms", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t[(function (){
|
t[(function (){
|
||||||
var pd= Object.getOwnPropertyDescriptor(t, "p");
|
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(t, "p", {
|
Object.defineProperty(t, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext.url.resourcesPath; },
|
||||||
set: function (){}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return "miniCssF";
|
return "miniCssF";
|
||||||
@ -83,7 +87,28 @@ describe("bin/js-transforms", () => {
|
|||||||
908:"67c9ed2c"
|
908:"67c9ed2c"
|
||||||
} [e] + ".chunk.css"
|
} [e] + ".chunk.css"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n[(function(){
|
||||||
|
var pd = Object.getOwnPropertyDescriptor(n, "p");
|
||||||
|
if( pd === undefined || pd.configurable ){
|
||||||
|
Object.defineProperty(n, "p", {
|
||||||
|
get: function() { return window.kcContext.url.resourcesPath; },
|
||||||
|
set: function() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return "u";
|
||||||
|
})()] = e => "/build/static/js/"+e+"."+{69:"4f205f87",128:"49264537",453:"b2fed72e",482:"f0106901"}[e]+".chunk.js"
|
||||||
|
|
||||||
|
t[(function(){
|
||||||
|
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
||||||
|
if( pd === undefined || pd.configurable ){
|
||||||
|
Object.defineProperty(t, "p", {
|
||||||
|
get: function() { return window.kcContext.url.resourcesPath; },
|
||||||
|
set: function() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return "miniCssF";
|
||||||
|
})()] = e => "/build/static/css/"+e+"."+{164:"dcfd7749",908:"67c9ed2c"}[e]+".chunk.css"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
||||||
|
Reference in New Issue
Block a user