keycloakify 10.0.0-rc.17 → 10.0.0-rc.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PUBLIC_URL.js.map +1 -1
- package/account/Template.js +5 -5
- package/account/Template.js.map +1 -1
- package/account/i18n/i18n.js +37 -29
- package/account/i18n/i18n.js.map +1 -1
- package/account/kcContext/KcContext.js.map +1 -1
- package/account/kcContext/createGetKcContext.js +20 -15
- package/account/kcContext/createGetKcContext.js.map +1 -1
- package/account/kcContext/getKcContext.js.map +1 -1
- package/account/kcContext/getKcContextFromWindow.d.ts +3 -1
- package/account/kcContext/getKcContextFromWindow.js.map +1 -1
- package/account/kcContext/kcContextMocks.js +148 -144
- package/account/kcContext/kcContextMocks.js.map +1 -1
- package/account/lib/useGetClassName.js +14 -14
- package/account/lib/useGetClassName.js.map +1 -1
- package/account/pages/Account.js +1 -1
- package/account/pages/Account.js.map +1 -1
- package/account/pages/Password.js +7 -7
- package/account/pages/Password.js.map +1 -1
- package/account/pages/Totp.js +4 -4
- package/account/pages/Totp.js.map +1 -1
- package/bin/main.js +2265 -2028
- package/bin/shared/constants.d.ts +1 -0
- package/bin/shared/constants.js +4 -3
- package/bin/shared/constants.js.map +1 -1
- package/lib/isStorybook.js +2 -1
- package/lib/isStorybook.js.map +1 -1
- package/lib/useGetClassName.js.map +1 -1
- package/login/Template.js +13 -13
- package/login/Template.js.map +1 -1
- package/login/UserProfileFormFields.js +43 -41
- package/login/UserProfileFormFields.js.map +1 -1
- package/login/i18n/baseMessages/ca.d.ts +1 -1
- package/login/i18n/baseMessages/ca.js +1 -1
- package/login/i18n/baseMessages/el.d.ts +0 -1
- package/login/i18n/baseMessages/el.js +0 -1
- package/login/i18n/baseMessages/el.js.map +1 -1
- package/login/i18n/baseMessages/en.d.ts +1 -1
- package/login/i18n/baseMessages/en.js +1 -1
- package/login/i18n/baseMessages/es.d.ts +1 -1
- package/login/i18n/baseMessages/es.js +1 -1
- package/login/i18n/baseMessages/fa.d.ts +0 -1
- package/login/i18n/baseMessages/fa.js +0 -1
- package/login/i18n/baseMessages/fa.js.map +1 -1
- package/login/i18n/baseMessages/hu.d.ts +1 -1
- package/login/i18n/baseMessages/hu.js +1 -1
- package/login/i18n/baseMessages/index.d.ts +1 -2
- package/login/i18n/baseMessages/zh-CN.d.ts +1 -1
- package/login/i18n/baseMessages/zh-CN.js +1 -1
- package/login/i18n/i18n.js +39 -31
- package/login/i18n/i18n.js.map +1 -1
- package/login/kcContext/KcContext.js.map +1 -1
- package/login/kcContext/createGetKcContext.js +30 -22
- package/login/kcContext/createGetKcContext.js.map +1 -1
- package/login/kcContext/getKcContext.js.map +1 -1
- package/login/kcContext/getKcContextFromWindow.d.ts +3 -1
- package/login/kcContext/getKcContextFromWindow.js.map +1 -1
- package/login/kcContext/kcContextMocks.js +233 -231
- package/login/kcContext/kcContextMocks.js.map +1 -1
- package/login/lib/useDownloadTerms.js.map +1 -1
- package/login/lib/useGetClassName.js +112 -112
- package/login/lib/useGetClassName.js.map +1 -1
- package/login/lib/useUserProfileForm.js +181 -181
- package/login/lib/useUserProfileForm.js.map +1 -1
- package/login/pages/DeleteAccountConfirm.js +5 -1
- package/login/pages/DeleteAccountConfirm.js.map +1 -1
- package/login/pages/FrontchannelLogout.js +1 -1
- package/login/pages/FrontchannelLogout.js.map +1 -1
- package/login/pages/Login.js.map +1 -1
- package/login/pages/LoginRecoveryAuthnCodeConfig.js +3 -3
- package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
- package/login/pages/LoginResetPassword.js.map +1 -1
- package/login/pages/LoginUsername.js.map +1 -1
- package/login/pages/WebauthnAuthenticate.js +11 -8
- package/login/pages/WebauthnAuthenticate.js.map +1 -1
- package/login/pages/WebauthnRegister.js +7 -7
- package/login/pages/WebauthnRegister.js.map +1 -1
- package/package.json +232 -226
- package/src/PUBLIC_URL.ts +4 -1
- package/src/account/Template.tsx +5 -5
- package/src/account/TemplateProps.ts +4 -1
- package/src/account/i18n/i18n.tsx +40 -30
- package/src/account/kcContext/KcContext.ts +4 -1
- package/src/account/kcContext/createGetKcContext.ts +48 -22
- package/src/account/kcContext/getKcContext.ts +3 -1
- package/src/account/kcContext/getKcContextFromWindow.ts +6 -2
- package/src/account/kcContext/kcContextMocks.ts +164 -160
- package/src/account/lib/useGetClassName.ts +15 -14
- package/src/account/pages/Account.tsx +2 -2
- package/src/account/pages/Password.tsx +8 -8
- package/src/account/pages/Totp.tsx +4 -6
- package/src/bin/copy-keycloak-resources-to-public.ts +2 -2
- package/src/bin/download-keycloak-default-theme.ts +30 -8
- package/src/bin/eject-page.ts +48 -11
- package/src/bin/initialize-email-theme.ts +25 -17
- package/src/bin/keycloakify/buildJars/buildJar.ts +179 -104
- package/src/bin/keycloakify/buildJars/buildJars.ts +35 -16
- package/src/bin/keycloakify/buildJars/extensionVersions.ts +2 -1
- package/src/bin/keycloakify/buildJars/generatePom.ts +11 -3
- package/src/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.ts +33 -8
- package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +20 -2
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +49 -12
- package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +29 -18
- package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +35 -12
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +3 -1
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +86 -41
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +39 -15
- package/src/bin/keycloakify/generateSrcMainResources/readExtraPageNames.ts +21 -7
- package/src/bin/keycloakify/generateSrcMainResources/readFieldNameUsage.ts +34 -7
- package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +19 -5
- package/src/bin/keycloakify/keycloakify.ts +28 -9
- package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +24 -5
- package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +6 -2
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +6 -3
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +24 -6
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +49 -11
- package/src/bin/main.ts +78 -41
- package/src/bin/shared/KeycloakVersionRange.ts +3 -1
- package/src/bin/shared/buildOptions.ts +70 -43
- package/src/bin/shared/constants.ts +4 -2
- package/src/bin/shared/copyKeycloakResourcesToPublic.ts +27 -13
- package/src/bin/shared/downloadKeycloakDefaultTheme.ts +161 -218
- package/src/bin/shared/downloadKeycloakStaticResources.ts +25 -21
- package/src/bin/shared/getJarFileBasename.ts +3 -1
- package/src/bin/shared/getThemeSrcDirPath.ts +5 -2
- package/src/bin/shared/metaInfKeycloakThemes.ts +35 -8
- package/src/bin/shared/promptKeycloakVersion.ts +33 -14
- package/src/bin/start-keycloak/appBuild.ts +128 -0
- package/src/bin/start-keycloak/index.ts +1 -0
- package/src/bin/start-keycloak/keycloakifyBuild.ts +41 -0
- package/src/bin/start-keycloak/myrealm-realm-23.json +2142 -0
- package/src/bin/start-keycloak/myrealm-realm-24.json +2318 -0
- package/src/bin/start-keycloak/start-keycloak.ts +469 -0
- package/src/bin/tools/SemVer.ts +32 -13
- package/src/bin/tools/String.prototype.replaceAll.ts +9 -2
- package/src/bin/tools/crawl.ts +4 -1
- package/src/bin/tools/crc32.ts +42 -24
- package/src/bin/tools/downloadAndExtractArchive/downloadAndExtractArchive.ts +262 -0
- package/src/bin/tools/downloadAndExtractArchive/fetchProxyOptions.ts +96 -0
- package/src/bin/tools/downloadAndExtractArchive/index.ts +1 -0
- package/src/bin/tools/extractArchive.ts +132 -0
- package/src/bin/tools/fetchProxyOptions.ts +31 -8
- package/src/bin/tools/getAbsoluteAndInOsFormatPath.ts +10 -2
- package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +18 -5
- package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +8 -2
- package/src/bin/tools/octokit-addons/listTags.ts +15 -4
- package/src/bin/tools/partitionPromiseSettledResults.ts +12 -3
- package/src/bin/tools/readThisNpmPackageVersion.ts +5 -1
- package/src/bin/tools/transformCodebase.ts +29 -10
- package/src/bin/tools/trimIndent.ts +4 -1
- package/src/lib/isStorybook.ts +3 -1
- package/src/lib/useGetClassName.ts +12 -3
- package/src/login/Template.tsx +14 -14
- package/src/login/TemplateProps.ts +4 -1
- package/src/login/UserProfileFormFields.tsx +44 -42
- package/src/login/i18n/baseMessages/ca.ts +1 -1
- package/src/login/i18n/baseMessages/el.ts +0 -1
- package/src/login/i18n/baseMessages/en.ts +1 -1
- package/src/login/i18n/baseMessages/es.ts +1 -1
- package/src/login/i18n/baseMessages/fa.ts +0 -1
- package/src/login/i18n/baseMessages/hu.ts +1 -1
- package/src/login/i18n/baseMessages/zh-CN.ts +1 -1
- package/src/login/i18n/i18n.tsx +42 -32
- package/src/login/kcContext/KcContext.ts +8 -2
- package/src/login/kcContext/createGetKcContext.ts +84 -37
- package/src/login/kcContext/getKcContext.ts +3 -1
- package/src/login/kcContext/getKcContextFromWindow.ts +6 -2
- package/src/login/kcContext/kcContextMocks.ts +339 -325
- package/src/login/lib/useDownloadTerms.ts +6 -4
- package/src/login/lib/useGetClassName.ts +119 -112
- package/src/login/lib/useUserProfileForm.tsx +219 -205
- package/src/login/pages/DeleteAccountConfirm.tsx +9 -3
- package/src/login/pages/FrontchannelLogout.tsx +1 -1
- package/src/login/pages/Login.tsx +2 -2
- package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +3 -3
- package/src/login/pages/LoginResetPassword.tsx +2 -2
- package/src/login/pages/LoginUsername.tsx +2 -2
- package/src/login/pages/WebauthnAuthenticate.tsx +11 -8
- package/src/login/pages/WebauthnRegister.tsx +7 -7
- package/src/tools/AndByDiscriminatingKey.ts +12 -6
- package/src/tools/Array.prototype.every.ts +4 -1
- package/src/tools/LazyOrNot.ts +3 -1
- package/src/tools/clsx.ts +7 -1
- package/src/tools/deepAssign.ts +15 -8
- package/src/tools/deepClone.ts +3 -1
- package/src/tools/formatNumber.ts +4 -1
- package/src/tools/useConstCallback.ts +3 -1
- package/src/tools/useInsertLinkTags.ts +20 -7
- package/src/tools/useInsertScriptTags.ts +7 -2
- package/src/tools/useSetClassName.ts +4 -1
- package/src/vite-plugin/vite-plugin.ts +45 -21
- package/tools/Array.prototype.every.js +2 -1
- package/tools/Array.prototype.every.js.map +1 -1
- package/tools/clsx.js.map +1 -1
- package/tools/deepAssign.js +9 -7
- package/tools/deepAssign.js.map +1 -1
- package/tools/deepClone.js.map +1 -1
- package/tools/formatNumber.js.map +1 -1
- package/tools/useConstCallback.js.map +1 -1
- package/tools/useInsertLinkTags.js +5 -4
- package/tools/useInsertLinkTags.js.map +1 -1
- package/tools/useInsertScriptTags.js +5 -2
- package/tools/useInsertScriptTags.js.map +1 -1
- package/tools/useSetClassName.js.map +1 -1
- package/vite-plugin/index.js +985 -1651
- package/src/bin/shared/downloadAndUnzip.ts +0 -203
- package/src/bin/start-keycloak.ts +0 -309
- package/src/bin/tools/unzip.ts +0 -141
@@ -1,12 +1,9 @@
|
|
1
|
-
import { join as pathJoin } from "path";
|
2
|
-
import { downloadAndUnzip } from "./downloadAndUnzip";
|
1
|
+
import { join as pathJoin, relative as pathRelative } from "path";
|
3
2
|
import { type BuildOptions } from "./buildOptions";
|
4
3
|
import { assert } from "tsafe/assert";
|
5
|
-
import * as child_process from "child_process";
|
6
|
-
import * as fs from "fs";
|
7
|
-
import { rmSync } from "../tools/fs.rmSync";
|
8
4
|
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
9
|
-
import {
|
5
|
+
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
6
|
+
import { isInside } from "../tools/isInside";
|
10
7
|
|
11
8
|
export type BuildOptionsLike = {
|
12
9
|
cacheDirPath: string;
|
@@ -15,250 +12,196 @@ export type BuildOptionsLike = {
|
|
15
12
|
|
16
13
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
17
14
|
|
18
|
-
export async function downloadKeycloakDefaultTheme(params: {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
15
|
+
export async function downloadKeycloakDefaultTheme(params: {
|
16
|
+
keycloakVersion: string;
|
17
|
+
buildOptions: BuildOptionsLike;
|
18
|
+
}): Promise<{ defaultThemeDirPath: string }> {
|
19
|
+
const { keycloakVersion, buildOptions } = params;
|
20
|
+
|
21
|
+
const { extractedDirPath } = await downloadAndExtractArchive({
|
22
|
+
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
23
|
+
cacheDirPath: buildOptions.cacheDirPath,
|
24
|
+
npmWorkspaceRootDirPath: buildOptions.npmWorkspaceRootDirPath,
|
25
|
+
uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
|
26
|
+
onArchiveFile: async params => {
|
27
|
+
if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
|
28
|
+
return;
|
29
|
+
}
|
31
30
|
|
32
|
-
|
33
|
-
break install_common_node_modules;
|
34
|
-
}
|
31
|
+
const { readFile, writeFile } = params;
|
35
32
|
|
36
|
-
|
37
|
-
break install_common_node_modules;
|
38
|
-
}
|
33
|
+
const fileRelativePath = pathRelative("theme", params.fileRelativePath);
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
35
|
+
skip_keycloak_v2: {
|
36
|
+
if (
|
37
|
+
!isInside({
|
38
|
+
dirPath: pathJoin("keycloak.v2"),
|
39
|
+
filePath: fileRelativePath
|
40
|
+
})
|
41
|
+
) {
|
42
|
+
break skip_keycloak_v2;
|
48
43
|
}
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if (!fs.existsSync(baseLoginThemeResourceDir)) {
|
54
|
-
break repatriate_common_resources_from_base_login_theme;
|
55
|
-
}
|
45
|
+
return;
|
46
|
+
}
|
56
47
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
});
|
48
|
+
last_account_v1_transformations: {
|
49
|
+
if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
|
50
|
+
break last_account_v1_transformations;
|
61
51
|
}
|
62
52
|
|
63
|
-
|
64
|
-
if (
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
if (!fs.existsSync(accountV2DirSrcDirPath)) {
|
71
|
-
break install_and_move_to_common_resources_generated_in_keycloak_v2;
|
72
|
-
}
|
73
|
-
|
74
|
-
const packageManager = fs.existsSync(pathJoin(accountV2DirSrcDirPath, "pnpm-lock.yaml")) ? "pnpm" : "npm";
|
75
|
-
|
76
|
-
if (packageManager === "pnpm") {
|
77
|
-
try {
|
78
|
-
child_process.execSync(`which pnpm`);
|
79
|
-
} catch {
|
80
|
-
console.log(`Installing pnpm globally`);
|
81
|
-
child_process.execSync(`npm install -g pnpm`);
|
82
|
-
}
|
53
|
+
patch_account_css: {
|
54
|
+
if (
|
55
|
+
fileRelativePath !==
|
56
|
+
pathJoin("keycloak", "account", "resources", "css", "account.css")
|
57
|
+
) {
|
58
|
+
break patch_account_css;
|
83
59
|
}
|
84
60
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
.replace(`${packageManager} run check-types`, "true")
|
95
|
-
.replace(`${packageManager} run babel`, "true");
|
96
|
-
|
97
|
-
fs.writeFileSync(packageJsonFilePath, Buffer.from(JSON.stringify(parsedPackageJson, null, 2), "utf8"));
|
98
|
-
|
99
|
-
child_process.execSync(`${packageManager} run build`, { "cwd": accountV2DirSrcDirPath, "stdio": "ignore" });
|
100
|
-
|
101
|
-
fs.writeFileSync(packageJsonFilePath, packageJsonRaw);
|
61
|
+
await writeFile({
|
62
|
+
fileRelativePath,
|
63
|
+
modifiedData: Buffer.from(
|
64
|
+
(await readFile())
|
65
|
+
.toString("utf8")
|
66
|
+
.replace("top: -34px;", "top: -34px !important;"),
|
67
|
+
"utf8"
|
68
|
+
)
|
69
|
+
});
|
102
70
|
|
103
|
-
|
71
|
+
return;
|
104
72
|
}
|
105
73
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
74
|
+
skip_web_modules: {
|
75
|
+
if (
|
76
|
+
!isInside({
|
77
|
+
dirPath: pathJoin(
|
78
|
+
"keycloak",
|
79
|
+
"common",
|
80
|
+
"resources",
|
81
|
+
"web_modules"
|
82
|
+
),
|
83
|
+
filePath: fileRelativePath
|
84
|
+
})
|
85
|
+
) {
|
86
|
+
break skip_web_modules;
|
111
87
|
}
|
112
88
|
|
113
|
-
|
89
|
+
return;
|
114
90
|
}
|
115
91
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
92
|
+
skip_unused_node_modules: {
|
93
|
+
const nodeModulesDirPath = pathJoin(
|
94
|
+
"keycloak",
|
95
|
+
"common",
|
96
|
+
"resources",
|
97
|
+
"node_modules"
|
98
|
+
);
|
99
|
+
|
100
|
+
if (
|
101
|
+
!isInside({
|
102
|
+
dirPath: nodeModulesDirPath,
|
103
|
+
filePath: fileRelativePath
|
104
|
+
})
|
105
|
+
) {
|
106
|
+
break skip_unused_node_modules;
|
122
107
|
}
|
123
108
|
|
124
|
-
const
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
"
|
139
|
-
"react",
|
140
|
-
"patternfly-bootstrap-treeview",
|
141
|
-
"popper.js",
|
142
|
-
"tippy.js",
|
143
|
-
"jquery-match-height",
|
144
|
-
"google-code-prettify",
|
145
|
-
"patternfly-bootstrap-combobox",
|
146
|
-
"focus-trap",
|
147
|
-
"tabbable",
|
148
|
-
"scheduler",
|
149
|
-
"@types",
|
150
|
-
"datatables.net",
|
151
|
-
"datatables.net-colreorder",
|
152
|
-
"tslib",
|
153
|
-
"prop-types",
|
154
|
-
"file-selector",
|
155
|
-
"datatables.net-colreorder-bs",
|
156
|
-
"object-assign",
|
157
|
-
"warning",
|
158
|
-
"js-tokens",
|
159
|
-
"loose-envify",
|
160
|
-
"prop-types-extra",
|
161
|
-
"attr-accept",
|
162
|
-
"datatables.net-select",
|
163
|
-
"drmonty-datatables-colvis",
|
164
|
-
"datatables.net-bs",
|
165
|
-
pathJoin("@patternfly", "react"),
|
166
|
-
pathJoin("@patternfly", "patternfly", "docs")
|
109
|
+
const toKeepPrefixes = [
|
110
|
+
...[
|
111
|
+
"patternfly.min.css",
|
112
|
+
"patternfly-additions.min.css",
|
113
|
+
"patternfly-additions.min.css"
|
114
|
+
].map(fileBasename =>
|
115
|
+
pathJoin(
|
116
|
+
nodeModulesDirPath,
|
117
|
+
"patternfly",
|
118
|
+
"dist",
|
119
|
+
"css",
|
120
|
+
fileBasename
|
121
|
+
)
|
122
|
+
),
|
123
|
+
pathJoin(nodeModulesDirPath, "patternfly", "dist", "fonts")
|
167
124
|
];
|
168
125
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
}
|
176
|
-
|
177
|
-
if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
|
178
|
-
return undefined;
|
179
|
-
}
|
180
|
-
|
181
|
-
if (fileRelativePath.startsWith(pathJoin("patternfly", "dist", "fonts"))) {
|
182
|
-
if (
|
183
|
-
!fileRelativePath.endsWith(".woff2") &&
|
184
|
-
!fileRelativePath.endsWith(".woff") &&
|
185
|
-
!fileRelativePath.endsWith(".ttf")
|
186
|
-
) {
|
187
|
-
return undefined;
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
return { "modifiedSourceCode": sourceCode };
|
192
|
-
}
|
193
|
-
});
|
194
|
-
}
|
195
|
-
|
196
|
-
// Just like node_modules
|
197
|
-
remove_unused_lib: {
|
198
|
-
const libDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "lib");
|
199
|
-
|
200
|
-
if (!fs.existsSync(libDirPath)) {
|
201
|
-
break remove_unused_lib;
|
126
|
+
if (
|
127
|
+
toKeepPrefixes.find(prefix =>
|
128
|
+
fileRelativePath.startsWith(prefix)
|
129
|
+
) !== undefined
|
130
|
+
) {
|
131
|
+
break skip_unused_node_modules;
|
202
132
|
}
|
203
133
|
|
204
|
-
|
205
|
-
|
206
|
-
transformCodebase({
|
207
|
-
"srcDirPath": libDirPath,
|
208
|
-
"destDirPath": libDirPath,
|
209
|
-
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
210
|
-
if (fileRelativePath.endsWith(".map")) {
|
211
|
-
return undefined;
|
212
|
-
}
|
213
|
-
|
214
|
-
if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
|
215
|
-
return undefined;
|
216
|
-
}
|
217
|
-
|
218
|
-
return { "modifiedSourceCode": sourceCode };
|
219
|
-
}
|
220
|
-
});
|
134
|
+
return;
|
221
135
|
}
|
136
|
+
}
|
222
137
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
{
|
229
|
-
const accountCssFilePath = pathJoin(destDirPath, "keycloak", "account", "resources", "css", "account.css");
|
138
|
+
skip_unused_resources: {
|
139
|
+
if (keycloakVersion !== "24.0.4") {
|
140
|
+
break skip_unused_resources;
|
141
|
+
}
|
230
142
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
143
|
+
for (const dirBasename of [
|
144
|
+
"@patternfly-v5",
|
145
|
+
"@rollup",
|
146
|
+
"rollup",
|
147
|
+
"react",
|
148
|
+
"react-dom",
|
149
|
+
"shx",
|
150
|
+
".pnpm"
|
151
|
+
]) {
|
152
|
+
if (
|
153
|
+
isInside({
|
154
|
+
dirPath: pathJoin(
|
155
|
+
"keycloak",
|
156
|
+
"common",
|
157
|
+
"resources",
|
158
|
+
"node_modules",
|
159
|
+
dirBasename
|
160
|
+
),
|
161
|
+
filePath: fileRelativePath
|
162
|
+
})
|
163
|
+
) {
|
164
|
+
return;
|
235
165
|
}
|
166
|
+
}
|
236
167
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
168
|
+
for (const dirBasename of ["react", "react-dom"]) {
|
169
|
+
if (
|
170
|
+
isInside({
|
171
|
+
dirPath: pathJoin(
|
172
|
+
"keycloak",
|
173
|
+
"common",
|
174
|
+
"resources",
|
175
|
+
"vendor",
|
176
|
+
dirBasename
|
245
177
|
),
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
"srcDirPath": nodeModulesDirPath,
|
251
|
-
"destDirPath": nodeModulesDirPath,
|
252
|
-
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
253
|
-
if (toKeepPrefixes.find(prefix => fileRelativePath.startsWith(prefix)) === undefined) {
|
254
|
-
return undefined;
|
255
|
-
}
|
256
|
-
return { "modifiedSourceCode": sourceCode };
|
257
|
-
}
|
258
|
-
});
|
178
|
+
filePath: fileRelativePath
|
179
|
+
})
|
180
|
+
) {
|
181
|
+
return;
|
259
182
|
}
|
260
183
|
}
|
184
|
+
|
185
|
+
if (
|
186
|
+
isInside({
|
187
|
+
dirPath: pathJoin(
|
188
|
+
"keycloak",
|
189
|
+
"common",
|
190
|
+
"resources",
|
191
|
+
"node_modules",
|
192
|
+
"@patternfly",
|
193
|
+
"react-core"
|
194
|
+
),
|
195
|
+
filePath: fileRelativePath
|
196
|
+
})
|
197
|
+
) {
|
198
|
+
return;
|
199
|
+
}
|
261
200
|
}
|
201
|
+
|
202
|
+
await writeFile({ fileRelativePath });
|
262
203
|
}
|
263
204
|
});
|
205
|
+
|
206
|
+
return { defaultThemeDirPath: extractedDirPath };
|
264
207
|
}
|
@@ -1,16 +1,15 @@
|
|
1
1
|
import { transformCodebase } from "../tools/transformCodebase";
|
2
2
|
import { join as pathJoin } from "path";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
downloadKeycloakDefaultTheme,
|
5
|
+
type BuildOptionsLike as BuildOptionsLike_downloadKeycloakDefaultTheme
|
6
|
+
} from "./downloadKeycloakDefaultTheme";
|
4
7
|
import { resources_common, type ThemeType } from "./constants";
|
5
8
|
import type { BuildOptions } from "./buildOptions";
|
6
9
|
import { assert } from "tsafe/assert";
|
7
|
-
import
|
8
|
-
import { rmSync } from "../tools/fs.rmSync";
|
10
|
+
import { existsAsync } from "../tools/fs.existsAsync";
|
9
11
|
|
10
|
-
export type BuildOptionsLike = {
|
11
|
-
cacheDirPath: string;
|
12
|
-
npmWorkspaceRootDirPath: string;
|
13
|
-
};
|
12
|
+
export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakDefaultTheme & {};
|
14
13
|
|
15
14
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
16
15
|
|
@@ -22,28 +21,33 @@ export async function downloadKeycloakStaticResources(params: {
|
|
22
21
|
}) {
|
23
22
|
const { themeType, themeDirPath, keycloakVersion, buildOptions } = params;
|
24
23
|
|
25
|
-
const
|
26
|
-
buildOptions.cacheDirPath,
|
27
|
-
`downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
|
28
|
-
);
|
29
|
-
|
30
|
-
await downloadKeycloakDefaultTheme({
|
24
|
+
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
31
25
|
keycloakVersion,
|
32
|
-
"destDirPath": tmpDirPath,
|
33
26
|
buildOptions
|
34
27
|
});
|
35
28
|
|
36
|
-
const
|
29
|
+
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
30
|
+
|
31
|
+
repatriate_base_resources: {
|
32
|
+
const srcDirPath = pathJoin(defaultThemeDirPath, "base", themeType, "resources");
|
33
|
+
|
34
|
+
if (!(await existsAsync(srcDirPath))) {
|
35
|
+
break repatriate_base_resources;
|
36
|
+
}
|
37
|
+
|
38
|
+
transformCodebase({
|
39
|
+
srcDirPath,
|
40
|
+
destDirPath: resourcesDirPath
|
41
|
+
});
|
42
|
+
}
|
37
43
|
|
38
44
|
transformCodebase({
|
39
|
-
|
40
|
-
|
45
|
+
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", themeType, "resources"),
|
46
|
+
destDirPath: resourcesDirPath
|
41
47
|
});
|
42
48
|
|
43
49
|
transformCodebase({
|
44
|
-
|
45
|
-
|
50
|
+
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
51
|
+
destDirPath: pathJoin(resourcesDirPath, resources_common)
|
46
52
|
});
|
47
|
-
|
48
|
-
rmSync(tmpDirPath, { "recursive": true });
|
49
53
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import type { KeycloakVersionRange } from "./KeycloakVersionRange";
|
2
2
|
|
3
|
-
export function getJarFileBasename(params: {
|
3
|
+
export function getJarFileBasename(params: {
|
4
|
+
keycloakVersionRange: KeycloakVersionRange;
|
5
|
+
}) {
|
4
6
|
const { keycloakVersionRange } = params;
|
5
7
|
|
6
8
|
const jarFileBasename = `keycloak-theme-for-kc-${keycloakVersionRange}.jar`;
|
@@ -12,7 +12,10 @@ export function getThemeSrcDirPath(params: { reactAppRootDirPath: string }) {
|
|
12
12
|
|
13
13
|
const srcDirPath = pathJoin(reactAppRootDirPath, "src");
|
14
14
|
|
15
|
-
const themeSrcDirPath: string | undefined = crawl({
|
15
|
+
const themeSrcDirPath: string | undefined = crawl({
|
16
|
+
dirPath: srcDirPath,
|
17
|
+
returnedPathsType: "relative to dirPath"
|
18
|
+
})
|
16
19
|
.map(fileRelativePath => {
|
17
20
|
for (const themeSrcDirBasename of themeSrcDirBasenames) {
|
18
21
|
const split = fileRelativePath.split(themeSrcDirBasename);
|
@@ -32,7 +35,7 @@ export function getThemeSrcDirPath(params: { reactAppRootDirPath: string }) {
|
|
32
35
|
if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
|
33
36
|
continue;
|
34
37
|
}
|
35
|
-
return {
|
38
|
+
return { themeSrcDirPath: srcDirPath };
|
36
39
|
}
|
37
40
|
|
38
41
|
console.error(
|
@@ -6,29 +6,56 @@ export type MetaInfKeycloakTheme = {
|
|
6
6
|
themes: { name: string; types: (ThemeType | "email")[] }[];
|
7
7
|
};
|
8
8
|
|
9
|
-
export function getMetaInfKeycloakThemesJsonFilePath(params: {
|
9
|
+
export function getMetaInfKeycloakThemesJsonFilePath(params: {
|
10
|
+
keycloakifyBuildDirPath: string;
|
11
|
+
}) {
|
10
12
|
const { keycloakifyBuildDirPath } = params;
|
11
13
|
|
12
|
-
return pathJoin(
|
14
|
+
return pathJoin(
|
15
|
+
keycloakifyBuildDirPath === "." ? "" : keycloakifyBuildDirPath,
|
16
|
+
"src",
|
17
|
+
"main",
|
18
|
+
"resources",
|
19
|
+
"META-INF",
|
20
|
+
"keycloak-themes.json"
|
21
|
+
);
|
13
22
|
}
|
14
23
|
|
15
|
-
export function readMetaInfKeycloakThemes(params: {
|
24
|
+
export function readMetaInfKeycloakThemes(params: {
|
25
|
+
keycloakifyBuildDirPath: string;
|
26
|
+
}): MetaInfKeycloakTheme {
|
16
27
|
const { keycloakifyBuildDirPath } = params;
|
17
28
|
|
18
|
-
return JSON.parse(
|
29
|
+
return JSON.parse(
|
30
|
+
fs
|
31
|
+
.readFileSync(
|
32
|
+
getMetaInfKeycloakThemesJsonFilePath({
|
33
|
+
keycloakifyBuildDirPath
|
34
|
+
})
|
35
|
+
)
|
36
|
+
.toString("utf8")
|
37
|
+
) as MetaInfKeycloakTheme;
|
19
38
|
}
|
20
39
|
|
21
|
-
export function writeMetaInfKeycloakThemes(params: {
|
40
|
+
export function writeMetaInfKeycloakThemes(params: {
|
41
|
+
keycloakifyBuildDirPath: string;
|
42
|
+
metaInfKeycloakThemes: MetaInfKeycloakTheme;
|
43
|
+
}) {
|
22
44
|
const { keycloakifyBuildDirPath, metaInfKeycloakThemes } = params;
|
23
45
|
|
24
|
-
const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonFilePath({
|
46
|
+
const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonFilePath({
|
47
|
+
keycloakifyBuildDirPath
|
48
|
+
});
|
25
49
|
|
26
50
|
{
|
27
51
|
const dirPath = pathDirname(metaInfKeycloakThemesJsonPath);
|
28
52
|
if (!fs.existsSync(dirPath)) {
|
29
|
-
fs.mkdirSync(dirPath, {
|
53
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
30
54
|
}
|
31
55
|
}
|
32
56
|
|
33
|
-
fs.writeFileSync(
|
57
|
+
fs.writeFileSync(
|
58
|
+
metaInfKeycloakThemesJsonPath,
|
59
|
+
Buffer.from(JSON.stringify(metaInfKeycloakThemes, null, 2), "utf8")
|
60
|
+
);
|
34
61
|
}
|