keycloakify 10.0.0-rc.16 → 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 +12232 -2467
- package/bin/shared/constants.d.ts +2 -0
- package/bin/shared/constants.js +5 -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 +33 -7
- package/src/bin/eject-page.ts +48 -11
- package/src/bin/initialize-email-theme.ts +25 -17
- package/src/bin/keycloakify/buildJars/buildJar.ts +188 -64
- 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 +36 -11
- 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 +73 -43
- package/src/bin/shared/constants.ts +6 -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 +50 -4
- 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 +1033 -1661
- package/src/bin/shared/downloadAndUnzip.ts +0 -203
- package/src/bin/start-keycloak.ts +0 -236
- 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,16 +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
|
-
import {
|
19
|
+
import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
|
14
20
|
|
15
21
|
export type BuildOptionsLike = BuildOptionsLike_generatePom & {
|
16
22
|
keycloakifyBuildDirPath: string;
|
@@ -28,57 +34,152 @@ export async function buildJar(params: {
|
|
28
34
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
29
35
|
buildOptions: BuildOptionsLike;
|
30
36
|
}): Promise<void> {
|
31
|
-
const {
|
37
|
+
const {
|
38
|
+
jarFileBasename,
|
39
|
+
keycloakAccountV1Version,
|
40
|
+
keycloakThemeAdditionalInfoExtensionVersion,
|
41
|
+
buildOptions
|
42
|
+
} = params;
|
32
43
|
|
33
|
-
const keycloakifyBuildTmpDirPath = pathJoin(
|
44
|
+
const keycloakifyBuildTmpDirPath = pathJoin(
|
45
|
+
buildOptions.cacheDirPath,
|
46
|
+
jarFileBasename.replace(".jar", "")
|
47
|
+
);
|
34
48
|
|
35
|
-
rmSync(keycloakifyBuildTmpDirPath, {
|
49
|
+
rmSync(keycloakifyBuildTmpDirPath, { recursive: true, force: true });
|
36
50
|
|
37
51
|
{
|
38
|
-
const
|
52
|
+
const transformCodebase_common = (params: {
|
53
|
+
fileRelativePath: string;
|
54
|
+
sourceCode: Buffer;
|
55
|
+
}): { modifiedSourceCode: Buffer } | undefined => {
|
56
|
+
const { fileRelativePath, sourceCode } = params;
|
39
57
|
|
40
|
-
|
41
|
-
|
42
|
-
|
58
|
+
if (
|
59
|
+
fileRelativePath ===
|
60
|
+
getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath: "." })
|
61
|
+
) {
|
62
|
+
return { modifiedSourceCode: sourceCode };
|
63
|
+
}
|
43
64
|
|
44
|
-
|
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 };
|
73
|
+
}
|
74
|
+
}
|
45
75
|
|
46
|
-
|
47
|
-
|
48
|
-
"destDirPath": keycloakifyBuildTmpDirPath,
|
49
|
-
"transformSourceCode":
|
50
|
-
keycloakAccountV1Version !== null
|
51
|
-
? undefined
|
52
|
-
: ({ fileRelativePath, sourceCode }) => {
|
53
|
-
if (fileRelativePath === keycloakThemesJsonFilePath) {
|
54
|
-
const keycloakThemesJsonParsed = JSON.parse(sourceCode.toString("utf8")) as {
|
55
|
-
themes: { name: string; types: string[] }[];
|
56
|
-
};
|
57
|
-
|
58
|
-
keycloakThemesJsonParsed.themes = keycloakThemesJsonParsed.themes.filter(({ name }) => name !== accountV1ThemeName);
|
59
|
-
|
60
|
-
return { "modifiedSourceCode": Buffer.from(JSON.stringify(keycloakThemesJsonParsed, null, 2), "utf8") };
|
61
|
-
}
|
76
|
+
return undefined;
|
77
|
+
};
|
62
78
|
|
63
|
-
|
64
|
-
|
65
|
-
|
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;
|
66
87
|
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
+
}
|
70
102
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
+
);
|
79
150
|
|
80
|
-
|
151
|
+
assert(
|
152
|
+
Buffer.compare(modifiedSourceCode, sourceCode) !== 0
|
153
|
+
);
|
154
|
+
|
155
|
+
return { modifiedSourceCode };
|
156
|
+
}
|
81
157
|
}
|
158
|
+
|
159
|
+
return { modifiedSourceCode: sourceCode };
|
160
|
+
};
|
161
|
+
|
162
|
+
transformCodebase({
|
163
|
+
srcDirPath: buildOptions.keycloakifyBuildDirPath,
|
164
|
+
destDirPath: keycloakifyBuildTmpDirPath,
|
165
|
+
transformSourceCode: params => {
|
166
|
+
const resultCommon = transformCodebase_common(params);
|
167
|
+
|
168
|
+
if (transformCodebase_patchForUsingBuiltinAccountV1 === undefined) {
|
169
|
+
return resultCommon;
|
170
|
+
}
|
171
|
+
|
172
|
+
if (resultCommon === undefined) {
|
173
|
+
return undefined;
|
174
|
+
}
|
175
|
+
|
176
|
+
const { modifiedSourceCode } = resultCommon;
|
177
|
+
|
178
|
+
return transformCodebase_patchForUsingBuiltinAccountV1({
|
179
|
+
...params,
|
180
|
+
sourceCode: modifiedSourceCode
|
181
|
+
});
|
182
|
+
}
|
82
183
|
});
|
83
184
|
}
|
84
185
|
|
@@ -103,7 +204,16 @@ export async function buildJar(params: {
|
|
103
204
|
|
104
205
|
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
105
206
|
buildOptions.themeNames.map(themeName => {
|
106
|
-
const ftlFilePath = pathJoin(
|
207
|
+
const ftlFilePath = pathJoin(
|
208
|
+
keycloakifyBuildTmpDirPath,
|
209
|
+
"src",
|
210
|
+
"main",
|
211
|
+
"resources",
|
212
|
+
"theme",
|
213
|
+
themeName,
|
214
|
+
"login",
|
215
|
+
pageId
|
216
|
+
);
|
107
217
|
|
108
218
|
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
109
219
|
|
@@ -124,7 +234,10 @@ export async function buildJar(params: {
|
|
124
234
|
|
125
235
|
assert(modifiedFtlFileContent !== ftlFileContent);
|
126
236
|
|
127
|
-
fs.writeFile(
|
237
|
+
fs.writeFile(
|
238
|
+
pathJoin(pathDirname(ftlFilePath), realPageId),
|
239
|
+
Buffer.from(modifiedFtlFileContent, "utf8")
|
240
|
+
);
|
128
241
|
})
|
129
242
|
);
|
130
243
|
}
|
@@ -136,35 +249,46 @@ export async function buildJar(params: {
|
|
136
249
|
keycloakThemeAdditionalInfoExtensionVersion
|
137
250
|
});
|
138
251
|
|
139
|
-
await fs.writeFile(
|
252
|
+
await fs.writeFile(
|
253
|
+
pathJoin(keycloakifyBuildTmpDirPath, "pom.xml"),
|
254
|
+
Buffer.from(pomFileCode, "utf8")
|
255
|
+
);
|
140
256
|
}
|
141
257
|
|
142
258
|
await new Promise<void>((resolve, reject) =>
|
143
|
-
child_process.exec(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
+
);
|
156
275
|
|
157
|
-
|
158
|
-
|
276
|
+
reject(error);
|
277
|
+
return;
|
278
|
+
}
|
279
|
+
resolve();
|
159
280
|
}
|
160
|
-
|
161
|
-
})
|
281
|
+
)
|
162
282
|
);
|
163
283
|
|
164
284
|
await fs.rename(
|
165
|
-
pathJoin(
|
285
|
+
pathJoin(
|
286
|
+
keycloakifyBuildTmpDirPath,
|
287
|
+
"target",
|
288
|
+
`${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`
|
289
|
+
),
|
166
290
|
pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename)
|
167
291
|
);
|
168
292
|
|
169
|
-
rmSync(keycloakifyBuildTmpDirPath, {
|
293
|
+
rmSync(keycloakifyBuildTmpDirPath, { recursive: true });
|
170
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>`,
|