keycloakify 10.0.0-rc.17 → 10.0.0-rc.18
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 +2066 -2165
- 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 +230 -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/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/index.ts +1 -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 +467 -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 +120 -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 +975 -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
package/src/bin/eject-page.ts
CHANGED
@@ -30,7 +30,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
30
30
|
console.log(chalk.cyan("Theme type:"));
|
31
31
|
|
32
32
|
const { value: themeType } = await cliSelect<ThemeType>({
|
33
|
-
|
33
|
+
values: [...themeTypes]
|
34
34
|
}).catch(() => {
|
35
35
|
process.exit(-1);
|
36
36
|
});
|
@@ -40,7 +40,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
40
40
|
console.log(chalk.cyan("Select the page you want to customize:"));
|
41
41
|
|
42
42
|
const { value: pageId } = await cliSelect<LoginThemePageId | AccountThemePageId>({
|
43
|
-
|
43
|
+
values: (() => {
|
44
44
|
switch (themeType) {
|
45
45
|
case "login":
|
46
46
|
return [...loginThemePageIds];
|
@@ -55,14 +55,29 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
55
55
|
|
56
56
|
console.log(`→ ${pageId}`);
|
57
57
|
|
58
|
-
const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
|
58
|
+
const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
|
59
|
+
/ftl$/,
|
60
|
+
"tsx"
|
61
|
+
);
|
59
62
|
|
60
|
-
const { themeSrcDirPath } = getThemeSrcDirPath({
|
63
|
+
const { themeSrcDirPath } = getThemeSrcDirPath({
|
64
|
+
reactAppRootDirPath: buildOptions.reactAppRootDirPath
|
65
|
+
});
|
61
66
|
|
62
|
-
const targetFilePath = pathJoin(
|
67
|
+
const targetFilePath = pathJoin(
|
68
|
+
themeSrcDirPath,
|
69
|
+
themeType,
|
70
|
+
"pages",
|
71
|
+
componentPageBasename
|
72
|
+
);
|
63
73
|
|
64
74
|
if (fs.existsSync(targetFilePath)) {
|
65
|
-
console.log(
|
75
|
+
console.log(
|
76
|
+
`${pageId} is already ejected, ${pathRelative(
|
77
|
+
process.cwd(),
|
78
|
+
targetFilePath
|
79
|
+
)} already exists`
|
80
|
+
);
|
66
81
|
|
67
82
|
process.exit(-1);
|
68
83
|
}
|
@@ -71,12 +86,20 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
71
86
|
const targetDirPath = pathDirname(targetFilePath);
|
72
87
|
|
73
88
|
if (!fs.existsSync(targetDirPath)) {
|
74
|
-
fs.mkdirSync(targetDirPath, {
|
89
|
+
fs.mkdirSync(targetDirPath, { recursive: true });
|
75
90
|
}
|
76
91
|
}
|
77
92
|
|
78
93
|
const componentPageContent = fs
|
79
|
-
.readFileSync(
|
94
|
+
.readFileSync(
|
95
|
+
pathJoin(
|
96
|
+
getThisCodebaseRootDirPath(),
|
97
|
+
"src",
|
98
|
+
themeType,
|
99
|
+
"pages",
|
100
|
+
componentPageBasename
|
101
|
+
)
|
102
|
+
)
|
80
103
|
.toString("utf8");
|
81
104
|
|
82
105
|
fs.writeFileSync(targetFilePath, Buffer.from(componentPageContent, "utf8"));
|
@@ -92,11 +115,23 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
92
115
|
``,
|
93
116
|
`You now need to update your page router:`,
|
94
117
|
``,
|
95
|
-
`${chalk.bold(
|
118
|
+
`${chalk.bold(
|
119
|
+
pathJoin(
|
120
|
+
".",
|
121
|
+
pathRelative(process.cwd(), themeSrcDirPath),
|
122
|
+
themeType,
|
123
|
+
"KcApp.tsx"
|
124
|
+
)
|
125
|
+
)}:`,
|
96
126
|
chalk.grey("```"),
|
97
127
|
`// ...`,
|
98
128
|
``,
|
99
|
-
chalk.green(
|
129
|
+
chalk.green(
|
130
|
+
`+const ${componentPageBasename.replace(
|
131
|
+
/.tsx$/,
|
132
|
+
""
|
133
|
+
)} = lazy(() => import("./pages/${componentPageBasename}"));`
|
134
|
+
),
|
100
135
|
...[
|
101
136
|
``,
|
102
137
|
` export default function KcApp(props: { kcContext: KcContext; }) {`,
|
@@ -114,7 +149,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
114
149
|
`+ Template={Template}`,
|
115
150
|
...(!componentPageContent.includes(userProfileFormFieldComponentName)
|
116
151
|
? []
|
117
|
-
: [
|
152
|
+
: [
|
153
|
+
`+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`
|
154
|
+
]),
|
118
155
|
`+ doUseDefaultCss={true}`,
|
119
156
|
`+ />`,
|
120
157
|
`+ );`,
|
@@ -5,7 +5,6 @@ import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
|
5
5
|
import { readBuildOptions } from "./shared/buildOptions";
|
6
6
|
import * as fs from "fs";
|
7
7
|
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
8
|
-
import { rmSync } from "./tools/fs.rmSync";
|
9
8
|
import type { CliCommandOptions } from "./main";
|
10
9
|
|
11
10
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
@@ -14,13 +13,18 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
14
13
|
const buildOptions = readBuildOptions({ cliCommandOptions });
|
15
14
|
|
16
15
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
17
|
-
|
16
|
+
reactAppRootDirPath: buildOptions.reactAppRootDirPath
|
18
17
|
});
|
19
18
|
|
20
19
|
const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
|
21
20
|
|
22
21
|
if (fs.existsSync(emailThemeSrcDirPath)) {
|
23
|
-
console.warn(
|
22
|
+
console.warn(
|
23
|
+
`There is already a ${pathRelative(
|
24
|
+
process.cwd(),
|
25
|
+
emailThemeSrcDirPath
|
26
|
+
)} directory in your project. Aborting.`
|
27
|
+
);
|
24
28
|
|
25
29
|
process.exit(-1);
|
26
30
|
}
|
@@ -29,33 +33,37 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
29
33
|
|
30
34
|
const { keycloakVersion } = await promptKeycloakVersion({
|
31
35
|
// NOTE: This is arbitrary
|
32
|
-
|
33
|
-
|
36
|
+
startingFromMajor: 17,
|
37
|
+
cacheDirPath: buildOptions.cacheDirPath
|
34
38
|
});
|
35
39
|
|
36
|
-
const
|
37
|
-
|
38
|
-
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
|
39
|
-
|
40
|
-
await downloadKeycloakDefaultTheme({
|
40
|
+
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
41
41
|
keycloakVersion,
|
42
|
-
"destDirPath": builtinKeycloakThemeTmpDirPath,
|
43
42
|
buildOptions
|
44
43
|
});
|
45
44
|
|
46
45
|
transformCodebase({
|
47
|
-
|
48
|
-
|
46
|
+
srcDirPath: pathJoin(defaultThemeDirPath, "base", "email"),
|
47
|
+
destDirPath: emailThemeSrcDirPath
|
49
48
|
});
|
50
49
|
|
51
50
|
{
|
52
51
|
const themePropertyFilePath = pathJoin(emailThemeSrcDirPath, "theme.properties");
|
53
52
|
|
54
|
-
fs.writeFileSync(
|
53
|
+
fs.writeFileSync(
|
54
|
+
themePropertyFilePath,
|
55
|
+
Buffer.from(
|
56
|
+
`parent=base\n${fs.readFileSync(themePropertyFilePath).toString("utf8")}`,
|
57
|
+
"utf8"
|
58
|
+
)
|
59
|
+
);
|
55
60
|
}
|
56
61
|
|
57
|
-
console.log(
|
62
|
+
console.log(
|
63
|
+
`The \`${pathJoin(
|
64
|
+
".",
|
65
|
+
pathRelative(process.cwd(), emailThemeSrcDirPath)
|
66
|
+
)}\` directory have been created.`
|
67
|
+
);
|
58
68
|
console.log("You can delete any file you don't modify.");
|
59
|
-
|
60
|
-
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true });
|
61
69
|
}
|
@@ -1,17 +1,22 @@
|
|
1
1
|
import { assert, type Equals } from "tsafe/assert";
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
KeycloakAccountV1Version,
|
4
|
+
KeycloakThemeAdditionalInfoExtensionVersion
|
5
|
+
} from "./extensionVersions";
|
3
6
|
import { join as pathJoin, dirname as pathDirname } from "path";
|
4
7
|
import { transformCodebase } from "../../tools/transformCodebase";
|
5
8
|
import type { BuildOptions } from "../../shared/buildOptions";
|
6
9
|
import * as fs from "fs/promises";
|
7
10
|
import { accountV1ThemeName } from "../../shared/constants";
|
8
|
-
import {
|
11
|
+
import {
|
12
|
+
generatePom,
|
13
|
+
BuildOptionsLike as BuildOptionsLike_generatePom
|
14
|
+
} from "./generatePom";
|
9
15
|
import { readFileSync } from "fs";
|
10
16
|
import { isInside } from "../../tools/isInside";
|
11
17
|
import child_process from "child_process";
|
12
18
|
import { rmSync } from "../../tools/fs.rmSync";
|
13
19
|
import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
|
14
|
-
import type { Param0 } from "tsafe";
|
15
20
|
|
16
21
|
export type BuildOptionsLike = BuildOptionsLike_generatePom & {
|
17
22
|
keycloakifyBuildDirPath: string;
|
@@ -29,103 +34,150 @@ export async function buildJar(params: {
|
|
29
34
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
30
35
|
buildOptions: BuildOptionsLike;
|
31
36
|
}): Promise<void> {
|
32
|
-
const {
|
33
|
-
|
34
|
-
|
37
|
+
const {
|
38
|
+
jarFileBasename,
|
39
|
+
keycloakAccountV1Version,
|
40
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
41
|
+
buildOptions
|
42
|
+
} = params;
|
43
|
+
|
44
|
+
const keycloakifyBuildTmpDirPath = pathJoin(
|
45
|
+
buildOptions.cacheDirPath,
|
46
|
+
jarFileBasename.replace(".jar", "")
|
47
|
+
);
|
35
48
|
|
36
|
-
rmSync(keycloakifyBuildTmpDirPath, {
|
49
|
+
rmSync(keycloakifyBuildTmpDirPath, { recursive: true, force: true });
|
37
50
|
|
38
51
|
{
|
39
|
-
const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
if (isInside({ "dirPath": pathJoin("src", "main", "resources", "theme", themeName), "filePath": fileRelativePath })) {
|
51
|
-
return { "modifiedSourceCode": sourceCode };
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
return undefined;
|
56
|
-
};
|
57
|
-
|
58
|
-
return { transformCodebase_common };
|
59
|
-
})();
|
60
|
-
|
61
|
-
const { transformCodebase_patchForUsingBuiltinAccountV1 } = (() => {
|
62
|
-
if (keycloakAccountV1Version !== null) {
|
63
|
-
return { "transformCodebase_patchForUsingBuiltinAccountV1": undefined };
|
52
|
+
const transformCodebase_common = (params: {
|
53
|
+
fileRelativePath: string;
|
54
|
+
sourceCode: Buffer;
|
55
|
+
}): { modifiedSourceCode: Buffer } | undefined => {
|
56
|
+
const { fileRelativePath, sourceCode } = params;
|
57
|
+
|
58
|
+
if (
|
59
|
+
fileRelativePath ===
|
60
|
+
getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath: "." })
|
61
|
+
) {
|
62
|
+
return { modifiedSourceCode: sourceCode };
|
64
63
|
}
|
65
64
|
|
66
|
-
const
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
sourceCode
|
75
|
-
}) => {
|
76
|
-
if (isInside({ "dirPath": accountV1RelativeDirPath, "filePath": fileRelativePath })) {
|
77
|
-
return undefined;
|
78
|
-
}
|
79
|
-
|
80
|
-
if (fileRelativePath === metaInfKeycloakThemesJsonRelativePath) {
|
81
|
-
const keycloakThemesJsonParsed = JSON.parse(sourceCode.toString("utf8")) as {
|
82
|
-
themes: { name: string; types: string[] }[];
|
83
|
-
};
|
84
|
-
|
85
|
-
keycloakThemesJsonParsed.themes = keycloakThemesJsonParsed.themes.filter(({ name }) => name !== accountV1ThemeName);
|
86
|
-
|
87
|
-
return { "modifiedSourceCode": Buffer.from(JSON.stringify(keycloakThemesJsonParsed, null, 2), "utf8") };
|
88
|
-
}
|
89
|
-
|
90
|
-
if (themePropertiesFileRelativePathSet.has(fileRelativePath)) {
|
91
|
-
const modifiedSourceCode = Buffer.from(
|
92
|
-
sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
|
93
|
-
"utf8"
|
94
|
-
);
|
95
|
-
|
96
|
-
// assert modifiedSourceCode !== sourceCode
|
97
|
-
assert(Buffer.compare(modifiedSourceCode, sourceCode) !== 0);
|
98
|
-
|
99
|
-
return { modifiedSourceCode };
|
65
|
+
for (const themeName of [...buildOptions.themeNames, accountV1ThemeName]) {
|
66
|
+
if (
|
67
|
+
isInside({
|
68
|
+
dirPath: pathJoin("src", "main", "resources", "theme", themeName),
|
69
|
+
filePath: fileRelativePath
|
70
|
+
})
|
71
|
+
) {
|
72
|
+
return { modifiedSourceCode: sourceCode };
|
100
73
|
}
|
74
|
+
}
|
101
75
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
76
|
+
return undefined;
|
77
|
+
};
|
78
|
+
|
79
|
+
const transformCodebase_patchForUsingBuiltinAccountV1 =
|
80
|
+
keycloakAccountV1Version !== null
|
81
|
+
? undefined
|
82
|
+
: (params: {
|
83
|
+
fileRelativePath: string;
|
84
|
+
sourceCode: Buffer;
|
85
|
+
}): { modifiedSourceCode: Buffer } | undefined => {
|
86
|
+
const { fileRelativePath, sourceCode } = params;
|
87
|
+
|
88
|
+
if (
|
89
|
+
isInside({
|
90
|
+
dirPath: pathJoin(
|
91
|
+
"src",
|
92
|
+
"main",
|
93
|
+
"resources",
|
94
|
+
"theme",
|
95
|
+
accountV1ThemeName
|
96
|
+
),
|
97
|
+
filePath: fileRelativePath
|
98
|
+
})
|
99
|
+
) {
|
100
|
+
return undefined;
|
101
|
+
}
|
102
|
+
|
103
|
+
if (
|
104
|
+
fileRelativePath ===
|
105
|
+
getMetaInfKeycloakThemesJsonFilePath({
|
106
|
+
keycloakifyBuildDirPath: "."
|
107
|
+
})
|
108
|
+
) {
|
109
|
+
const keycloakThemesJsonParsed = JSON.parse(
|
110
|
+
sourceCode.toString("utf8")
|
111
|
+
) as {
|
112
|
+
themes: { name: string; types: string[] }[];
|
113
|
+
};
|
114
|
+
|
115
|
+
keycloakThemesJsonParsed.themes =
|
116
|
+
keycloakThemesJsonParsed.themes.filter(
|
117
|
+
({ name }) => name !== accountV1ThemeName
|
118
|
+
);
|
119
|
+
|
120
|
+
return {
|
121
|
+
modifiedSourceCode: Buffer.from(
|
122
|
+
JSON.stringify(keycloakThemesJsonParsed, null, 2),
|
123
|
+
"utf8"
|
124
|
+
)
|
125
|
+
};
|
126
|
+
}
|
127
|
+
|
128
|
+
for (const themeName of buildOptions.themeNames) {
|
129
|
+
if (
|
130
|
+
fileRelativePath ===
|
131
|
+
pathJoin(
|
132
|
+
"src",
|
133
|
+
"main",
|
134
|
+
"resources",
|
135
|
+
"theme",
|
136
|
+
themeName,
|
137
|
+
"account",
|
138
|
+
"theme.properties"
|
139
|
+
)
|
140
|
+
) {
|
141
|
+
const modifiedSourceCode = Buffer.from(
|
142
|
+
sourceCode
|
143
|
+
.toString("utf8")
|
144
|
+
.replace(
|
145
|
+
`parent=${accountV1ThemeName}`,
|
146
|
+
"parent=keycloak"
|
147
|
+
),
|
148
|
+
"utf8"
|
149
|
+
);
|
150
|
+
|
151
|
+
assert(
|
152
|
+
Buffer.compare(modifiedSourceCode, sourceCode) !== 0
|
153
|
+
);
|
154
|
+
|
155
|
+
return { modifiedSourceCode };
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
return { modifiedSourceCode: sourceCode };
|
160
|
+
};
|
107
161
|
|
108
162
|
transformCodebase({
|
109
|
-
|
110
|
-
|
111
|
-
|
163
|
+
srcDirPath: buildOptions.keycloakifyBuildDirPath,
|
164
|
+
destDirPath: keycloakifyBuildTmpDirPath,
|
165
|
+
transformSourceCode: params => {
|
112
166
|
const resultCommon = transformCodebase_common(params);
|
113
167
|
|
114
|
-
if (resultCommon === undefined) {
|
115
|
-
return undefined;
|
116
|
-
}
|
117
|
-
|
118
168
|
if (transformCodebase_patchForUsingBuiltinAccountV1 === undefined) {
|
119
169
|
return resultCommon;
|
120
170
|
}
|
121
171
|
|
122
|
-
|
172
|
+
if (resultCommon === undefined) {
|
173
|
+
return undefined;
|
174
|
+
}
|
123
175
|
|
124
|
-
|
176
|
+
const { modifiedSourceCode } = resultCommon;
|
125
177
|
|
126
|
-
return transformCodebase_patchForUsingBuiltinAccountV1
|
178
|
+
return transformCodebase_patchForUsingBuiltinAccountV1({
|
127
179
|
...params,
|
128
|
-
|
180
|
+
sourceCode: modifiedSourceCode
|
129
181
|
});
|
130
182
|
}
|
131
183
|
});
|
@@ -152,7 +204,16 @@ export async function buildJar(params: {
|
|
152
204
|
|
153
205
|
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
154
206
|
buildOptions.themeNames.map(themeName => {
|
155
|
-
const ftlFilePath = pathJoin(
|
207
|
+
const ftlFilePath = pathJoin(
|
208
|
+
keycloakifyBuildTmpDirPath,
|
209
|
+
"src",
|
210
|
+
"main",
|
211
|
+
"resources",
|
212
|
+
"theme",
|
213
|
+
themeName,
|
214
|
+
"login",
|
215
|
+
pageId
|
216
|
+
);
|
156
217
|
|
157
218
|
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
158
219
|
|
@@ -173,7 +234,10 @@ export async function buildJar(params: {
|
|
173
234
|
|
174
235
|
assert(modifiedFtlFileContent !== ftlFileContent);
|
175
236
|
|
176
|
-
fs.writeFile(
|
237
|
+
fs.writeFile(
|
238
|
+
pathJoin(pathDirname(ftlFilePath), realPageId),
|
239
|
+
Buffer.from(modifiedFtlFileContent, "utf8")
|
240
|
+
);
|
177
241
|
})
|
178
242
|
);
|
179
243
|
}
|
@@ -185,35 +249,46 @@ export async function buildJar(params: {
|
|
185
249
|
keycloakThemeAdditionalInfoExtensionVersion
|
186
250
|
});
|
187
251
|
|
188
|
-
await fs.writeFile(
|
252
|
+
await fs.writeFile(
|
253
|
+
pathJoin(keycloakifyBuildTmpDirPath, "pom.xml"),
|
254
|
+
Buffer.from(pomFileCode, "utf8")
|
255
|
+
);
|
189
256
|
}
|
190
257
|
|
191
258
|
await new Promise<void>((resolve, reject) =>
|
192
|
-
child_process.exec(
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
259
|
+
child_process.exec(
|
260
|
+
`mvn clean install -Dmaven.repo.local=${pathJoin(keycloakifyBuildTmpDirPath, ".m2")}`,
|
261
|
+
{ cwd: keycloakifyBuildTmpDirPath },
|
262
|
+
error => {
|
263
|
+
if (error !== null) {
|
264
|
+
console.error(
|
265
|
+
`Build jar failed: ${JSON.stringify(
|
266
|
+
{
|
267
|
+
jarFileBasename,
|
268
|
+
keycloakAccountV1Version,
|
269
|
+
keycloakThemeAdditionalInfoExtensionVersion
|
270
|
+
},
|
271
|
+
null,
|
272
|
+
2
|
273
|
+
)}`
|
274
|
+
);
|
205
275
|
|
206
|
-
|
207
|
-
|
276
|
+
reject(error);
|
277
|
+
return;
|
278
|
+
}
|
279
|
+
resolve();
|
208
280
|
}
|
209
|
-
|
210
|
-
})
|
281
|
+
)
|
211
282
|
);
|
212
283
|
|
213
284
|
await fs.rename(
|
214
|
-
pathJoin(
|
285
|
+
pathJoin(
|
286
|
+
keycloakifyBuildTmpDirPath,
|
287
|
+
"target",
|
288
|
+
`${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`
|
289
|
+
),
|
215
290
|
pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename)
|
216
291
|
);
|
217
292
|
|
218
|
-
rmSync(keycloakifyBuildTmpDirPath, {
|
293
|
+
rmSync(keycloakifyBuildTmpDirPath, { recursive: true });
|
219
294
|
}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { assert } from "tsafe/assert";
|
2
2
|
import { exclude } from "tsafe/exclude";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
keycloakAccountV1Versions,
|
5
|
+
keycloakThemeAdditionalInfoExtensionVersions
|
6
|
+
} from "./extensionVersions";
|
4
7
|
import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
|
5
8
|
import { buildJar, BuildOptionsLike as BuildOptionsLike_buildJar } from "./buildJar";
|
6
9
|
import type { BuildOptions } from "../../shared/buildOptions";
|
@@ -14,11 +17,13 @@ export type BuildOptionsLike = BuildOptionsLike_buildJar & {
|
|
14
17
|
|
15
18
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
16
19
|
|
17
|
-
export async function buildJars(params: {
|
20
|
+
export async function buildJars(params: {
|
21
|
+
buildOptions: BuildOptionsLike;
|
22
|
+
}): Promise<void> {
|
18
23
|
const { buildOptions } = params;
|
19
24
|
|
20
25
|
const doesImplementAccountTheme = readMetaInfKeycloakThemes({
|
21
|
-
|
26
|
+
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
|
22
27
|
}).themes.some(({ name }) => name === accountV1ThemeName);
|
23
28
|
|
24
29
|
await Promise.all(
|
@@ -36,24 +41,38 @@ export async function buildJars(params: { buildOptions: BuildOptionsLike }): Pro
|
|
36
41
|
return undefined;
|
37
42
|
}
|
38
43
|
|
39
|
-
return { keycloakThemeAdditionalInfoExtensionVersion, keycloakVersionRange };
|
40
|
-
})
|
41
|
-
.filter(exclude(undefined))
|
42
|
-
.map(({ keycloakThemeAdditionalInfoExtensionVersion, keycloakVersionRange }) => {
|
43
|
-
const { jarFileBasename } = getJarFileBasename({ keycloakVersionRange });
|
44
|
-
|
45
44
|
return {
|
46
45
|
keycloakThemeAdditionalInfoExtensionVersion,
|
47
|
-
|
46
|
+
keycloakVersionRange
|
48
47
|
};
|
49
48
|
})
|
50
|
-
.
|
51
|
-
|
52
|
-
|
53
|
-
keycloakAccountV1Version,
|
49
|
+
.filter(exclude(undefined))
|
50
|
+
.map(
|
51
|
+
({
|
54
52
|
keycloakThemeAdditionalInfoExtensionVersion,
|
55
|
-
|
56
|
-
})
|
53
|
+
keycloakVersionRange
|
54
|
+
}) => {
|
55
|
+
const { jarFileBasename } = getJarFileBasename({
|
56
|
+
keycloakVersionRange
|
57
|
+
});
|
58
|
+
|
59
|
+
return {
|
60
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
61
|
+
jarFileBasename
|
62
|
+
};
|
63
|
+
}
|
64
|
+
)
|
65
|
+
.map(
|
66
|
+
({
|
67
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
68
|
+
jarFileBasename
|
69
|
+
}) =>
|
70
|
+
buildJar({
|
71
|
+
jarFileBasename,
|
72
|
+
keycloakAccountV1Version,
|
73
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
74
|
+
buildOptions
|
75
|
+
})
|
57
76
|
)
|
58
77
|
)
|
59
78
|
.flat()
|
@@ -13,4 +13,5 @@ export const keycloakThemeAdditionalInfoExtensionVersions = [null, "1.1.5"] as c
|
|
13
13
|
* https://central.sonatype.com/artifact/dev.jcputney/keycloak-theme-additional-info-extension
|
14
14
|
* https://github.com/jcputney/keycloak-theme-additional-info-extension
|
15
15
|
* */
|
16
|
-
export type KeycloakThemeAdditionalInfoExtensionVersion =
|
16
|
+
export type KeycloakThemeAdditionalInfoExtensionVersion =
|
17
|
+
(typeof keycloakThemeAdditionalInfoExtensionVersions)[number];
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { assert } from "tsafe/assert";
|
2
2
|
import type { BuildOptions } from "../../shared/buildOptions";
|
3
|
-
import type {
|
3
|
+
import type {
|
4
|
+
KeycloakAccountV1Version,
|
5
|
+
KeycloakThemeAdditionalInfoExtensionVersion
|
6
|
+
} from "./extensionVersions";
|
4
7
|
|
5
8
|
export type BuildOptionsLike = {
|
6
9
|
groupId: string;
|
@@ -15,7 +18,11 @@ export function generatePom(params: {
|
|
15
18
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
16
19
|
buildOptions: BuildOptionsLike;
|
17
20
|
}) {
|
18
|
-
const {
|
21
|
+
const {
|
22
|
+
keycloakAccountV1Version,
|
23
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
24
|
+
buildOptions
|
25
|
+
} = params;
|
19
26
|
|
20
27
|
const { pomFileCode } = (function generatePomFileCode(): {
|
21
28
|
pomFileCode: string;
|
@@ -35,7 +42,8 @@ export function generatePom(params: {
|
|
35
42
|
` <properties>`,
|
36
43
|
` <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>`,
|
37
44
|
` </properties>`,
|
38
|
-
...(keycloakAccountV1Version !== null &&
|
45
|
+
...(keycloakAccountV1Version !== null &&
|
46
|
+
keycloakThemeAdditionalInfoExtensionVersion !== null
|
39
47
|
? [
|
40
48
|
` <build>`,
|
41
49
|
` <plugins>`,
|