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/main.ts
CHANGED
@@ -10,12 +10,12 @@ export type CliCommandOptions = {
|
|
10
10
|
|
11
11
|
const program = termost<CliCommandOptions>(
|
12
12
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
name: "keycloakify",
|
14
|
+
description: "Keycloakify CLI",
|
15
|
+
version: readThisNpmPackageVersion()
|
16
16
|
},
|
17
17
|
{
|
18
|
-
|
18
|
+
onException: error => {
|
19
19
|
console.error(error);
|
20
20
|
process.exit(1);
|
21
21
|
}
|
@@ -25,8 +25,8 @@ const program = termost<CliCommandOptions>(
|
|
25
25
|
const optionsKeys: string[] = [];
|
26
26
|
|
27
27
|
program.option({
|
28
|
-
|
29
|
-
|
28
|
+
key: "reactAppRootDirPath",
|
29
|
+
name: (() => {
|
30
30
|
const long = "project";
|
31
31
|
const short = "p";
|
32
32
|
|
@@ -34,19 +34,25 @@ program.option({
|
|
34
34
|
|
35
35
|
return { long, short };
|
36
36
|
})(),
|
37
|
-
|
37
|
+
description: [
|
38
38
|
`For monorepos, path to the keycloakify project.`,
|
39
39
|
"Example: `npx keycloakify build --project packages/keycloak-theme`",
|
40
40
|
"https://docs.keycloakify.dev/build-options#project-or-p-cli-option"
|
41
41
|
].join(" "),
|
42
|
-
|
42
|
+
defaultValue: undefined
|
43
43
|
});
|
44
44
|
|
45
45
|
function skip(_context: any, argv: { options: Record<string, unknown> }) {
|
46
|
-
const unrecognizedOptionKey = Object.keys(argv.options).find(
|
46
|
+
const unrecognizedOptionKey = Object.keys(argv.options).find(
|
47
|
+
key => !optionsKeys.includes(key)
|
48
|
+
);
|
47
49
|
|
48
50
|
if (unrecognizedOptionKey !== undefined) {
|
49
|
-
console.error(
|
51
|
+
console.error(
|
52
|
+
`keycloakify: Unrecognized option: ${
|
53
|
+
unrecognizedOptionKey.length === 1 ? "-" : "--"
|
54
|
+
}${unrecognizedOptionKey}`
|
55
|
+
);
|
50
56
|
process.exit(1);
|
51
57
|
}
|
52
58
|
|
@@ -55,12 +61,12 @@ function skip(_context: any, argv: { options: Record<string, unknown> }) {
|
|
55
61
|
|
56
62
|
program
|
57
63
|
.command({
|
58
|
-
|
59
|
-
|
64
|
+
name: "build",
|
65
|
+
description: "Build the theme (default subcommand)."
|
60
66
|
})
|
61
67
|
.task({
|
62
68
|
skip,
|
63
|
-
|
69
|
+
handler: async cliCommandOptions => {
|
64
70
|
const { command } = await import("./keycloakify");
|
65
71
|
|
66
72
|
await command({ cliCommandOptions });
|
@@ -68,37 +74,60 @@ program
|
|
68
74
|
});
|
69
75
|
|
70
76
|
program
|
71
|
-
.command<{
|
72
|
-
|
73
|
-
|
77
|
+
.command<{
|
78
|
+
port: number;
|
79
|
+
keycloakVersion: string | undefined;
|
80
|
+
realmJsonFilePath: string | undefined;
|
81
|
+
}>({
|
82
|
+
name: "start-keycloak",
|
83
|
+
description:
|
84
|
+
"Spin up a pre configured Docker image of Keycloak to test your theme."
|
74
85
|
})
|
75
86
|
.option({
|
76
|
-
|
77
|
-
|
87
|
+
key: "port",
|
88
|
+
name: (() => {
|
78
89
|
const name = "port";
|
79
90
|
|
80
91
|
optionsKeys.push(name);
|
81
92
|
|
82
93
|
return name;
|
83
94
|
})(),
|
84
|
-
|
85
|
-
|
95
|
+
description: ["Keycloak server port.", "Example `--port 8085`"].join(" "),
|
96
|
+
defaultValue: 8080
|
86
97
|
})
|
87
98
|
.option({
|
88
|
-
|
89
|
-
|
99
|
+
key: "keycloakVersion",
|
100
|
+
name: (() => {
|
90
101
|
const name = "keycloak-version";
|
91
102
|
|
92
103
|
optionsKeys.push(name);
|
93
104
|
|
94
105
|
return name;
|
95
106
|
})(),
|
96
|
-
|
97
|
-
|
107
|
+
description: [
|
108
|
+
"Use a specific version of Keycloak.",
|
109
|
+
"Example `--keycloak-version 21.1.1`"
|
110
|
+
].join(" "),
|
111
|
+
defaultValue: undefined
|
112
|
+
})
|
113
|
+
.option({
|
114
|
+
key: "realmJsonFilePath",
|
115
|
+
name: (() => {
|
116
|
+
const name = "import";
|
117
|
+
|
118
|
+
optionsKeys.push(name);
|
119
|
+
|
120
|
+
return name;
|
121
|
+
})(),
|
122
|
+
defaultValue: undefined,
|
123
|
+
description: [
|
124
|
+
"Import your own realm configuration file",
|
125
|
+
"Example `--import path/to/myrealm-realm.json`"
|
126
|
+
].join(" ")
|
98
127
|
})
|
99
128
|
.task({
|
100
129
|
skip,
|
101
|
-
|
130
|
+
handler: async cliCommandOptions => {
|
102
131
|
const { command } = await import("./start-keycloak");
|
103
132
|
|
104
133
|
await command({ cliCommandOptions });
|
@@ -107,12 +136,12 @@ program
|
|
107
136
|
|
108
137
|
program
|
109
138
|
.command({
|
110
|
-
|
111
|
-
|
139
|
+
name: "download-keycloak-default-theme",
|
140
|
+
description: "Download the built-in Keycloak theme."
|
112
141
|
})
|
113
142
|
.task({
|
114
143
|
skip,
|
115
|
-
|
144
|
+
handler: async cliCommandOptions => {
|
116
145
|
const { command } = await import("./download-keycloak-default-theme");
|
117
146
|
|
118
147
|
await command({ cliCommandOptions });
|
@@ -121,12 +150,12 @@ program
|
|
121
150
|
|
122
151
|
program
|
123
152
|
.command({
|
124
|
-
|
125
|
-
|
153
|
+
name: "eject-page",
|
154
|
+
description: "Eject a Keycloak page."
|
126
155
|
})
|
127
156
|
.task({
|
128
157
|
skip,
|
129
|
-
|
158
|
+
handler: async cliCommandOptions => {
|
130
159
|
const { command } = await import("./eject-page");
|
131
160
|
|
132
161
|
await command({ cliCommandOptions });
|
@@ -135,12 +164,12 @@ program
|
|
135
164
|
|
136
165
|
program
|
137
166
|
.command({
|
138
|
-
|
139
|
-
|
167
|
+
name: "initialize-email-theme",
|
168
|
+
description: "Initialize an email theme."
|
140
169
|
})
|
141
170
|
.task({
|
142
171
|
skip,
|
143
|
-
|
172
|
+
handler: async cliCommandOptions => {
|
144
173
|
const { command } = await import("./initialize-email-theme");
|
145
174
|
|
146
175
|
await command({ cliCommandOptions });
|
@@ -149,12 +178,13 @@ program
|
|
149
178
|
|
150
179
|
program
|
151
180
|
.command({
|
152
|
-
|
153
|
-
|
181
|
+
name: "copy-keycloak-resources-to-public",
|
182
|
+
description:
|
183
|
+
"(Webpack/Create-React-App only) Copy Keycloak default theme resources to the public directory."
|
154
184
|
})
|
155
185
|
.task({
|
156
186
|
skip,
|
157
|
-
|
187
|
+
handler: async cliCommandOptions => {
|
158
188
|
const { command } = await import("./copy-keycloak-resources-to-public");
|
159
189
|
|
160
190
|
await command({ cliCommandOptions });
|
@@ -165,10 +195,17 @@ program
|
|
165
195
|
{
|
166
196
|
const [, , ...rest] = process.argv;
|
167
197
|
|
168
|
-
if (
|
169
|
-
|
170
|
-
|
171
|
-
|
198
|
+
if (
|
199
|
+
rest.length === 0 ||
|
200
|
+
(rest[0].startsWith("-") && rest[0] !== "--help" && rest[0] !== "-h")
|
201
|
+
) {
|
202
|
+
const { status } = child_process.spawnSync(
|
203
|
+
"npx",
|
204
|
+
["keycloakify", "build", ...rest],
|
205
|
+
{
|
206
|
+
stdio: "inherit"
|
207
|
+
}
|
208
|
+
);
|
172
209
|
|
173
210
|
process.exit(status ?? 1);
|
174
211
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
export type KeycloakVersionRange =
|
1
|
+
export type KeycloakVersionRange =
|
2
|
+
| KeycloakVersionRange.WithAccountTheme
|
3
|
+
| KeycloakVersionRange.WithoutAccountTheme;
|
2
4
|
|
3
5
|
export namespace KeycloakVersionRange {
|
4
6
|
export type WithoutAccountTheme = "21-and-below" | "22-and-above";
|
@@ -49,7 +49,9 @@ export type ResolvedViteConfig = {
|
|
49
49
|
userProvidedBuildOptions: UserProvidedBuildOptions;
|
50
50
|
};
|
51
51
|
|
52
|
-
export function readBuildOptions(params: {
|
52
|
+
export function readBuildOptions(params: {
|
53
|
+
cliCommandOptions: CliCommandOptions;
|
54
|
+
}): BuildOptions {
|
53
55
|
const { cliCommandOptions } = params;
|
54
56
|
|
55
57
|
const reactAppRootDirPath = (() => {
|
@@ -58,29 +60,39 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
58
60
|
}
|
59
61
|
|
60
62
|
return getAbsoluteAndInOsFormatPath({
|
61
|
-
|
62
|
-
|
63
|
+
pathIsh: cliCommandOptions.reactAppRootDirPath,
|
64
|
+
cwd: process.cwd()
|
63
65
|
});
|
64
66
|
})();
|
65
67
|
|
66
68
|
const { resolvedViteConfig } = (() => {
|
67
|
-
if (
|
68
|
-
|
69
|
+
if (
|
70
|
+
fs
|
71
|
+
.readdirSync(reactAppRootDirPath)
|
72
|
+
.find(fileBasename => fileBasename.startsWith("vite.config")) ===
|
73
|
+
undefined
|
74
|
+
) {
|
75
|
+
return { resolvedViteConfig: undefined };
|
69
76
|
}
|
70
77
|
|
71
78
|
const output = child_process
|
72
79
|
.execSync("npx vite", {
|
73
|
-
|
74
|
-
|
80
|
+
cwd: reactAppRootDirPath,
|
81
|
+
env: {
|
75
82
|
...process.env,
|
76
83
|
[vitePluginSubScriptEnvNames.resolveViteConfig]: "true"
|
77
84
|
}
|
78
85
|
})
|
79
86
|
.toString("utf8");
|
80
87
|
|
81
|
-
assert(
|
88
|
+
assert(
|
89
|
+
output.includes(vitePluginSubScriptEnvNames.resolveViteConfig),
|
90
|
+
"Seems like the Keycloakify's Vite plugin is not installed."
|
91
|
+
);
|
82
92
|
|
83
|
-
const resolvedViteConfigStr = output
|
93
|
+
const resolvedViteConfigStr = output
|
94
|
+
.split(vitePluginSubScriptEnvNames.resolveViteConfig)
|
95
|
+
.reverse()[0];
|
84
96
|
|
85
97
|
const resolvedViteConfig: ResolvedViteConfig = JSON.parse(resolvedViteConfigStr);
|
86
98
|
|
@@ -92,22 +104,24 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
92
104
|
name: string;
|
93
105
|
version?: string;
|
94
106
|
homepage?: string;
|
95
|
-
keycloakify?: UserProvidedBuildOptions & {
|
107
|
+
keycloakify?: UserProvidedBuildOptions & {
|
108
|
+
reactAppBuildDirPath?: string;
|
109
|
+
};
|
96
110
|
};
|
97
111
|
|
98
112
|
const zParsedPackageJson = z.object({
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
113
|
+
name: z.string(),
|
114
|
+
version: z.string().optional(),
|
115
|
+
homepage: z.string().optional(),
|
116
|
+
keycloakify: z
|
103
117
|
.object({
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
118
|
+
extraThemeProperties: z.array(z.string()).optional(),
|
119
|
+
artifactId: z.string().optional(),
|
120
|
+
groupId: z.string().optional(),
|
121
|
+
loginThemeResourcesFromKeycloakVersion: z.string().optional(),
|
122
|
+
reactAppBuildDirPath: z.string().optional(),
|
123
|
+
keycloakifyBuildDirPath: z.string().optional(),
|
124
|
+
themeName: z.union([z.string(), z.array(z.string())]).optional()
|
111
125
|
})
|
112
126
|
.optional()
|
113
127
|
});
|
@@ -119,7 +133,13 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
119
133
|
assert<Expected extends Got ? true : false>();
|
120
134
|
}
|
121
135
|
|
122
|
-
return zParsedPackageJson.parse(
|
136
|
+
return zParsedPackageJson.parse(
|
137
|
+
JSON.parse(
|
138
|
+
fs
|
139
|
+
.readFileSync(pathJoin(reactAppRootDirPath, "package.json"))
|
140
|
+
.toString("utf8")
|
141
|
+
)
|
142
|
+
);
|
123
143
|
})();
|
124
144
|
|
125
145
|
const userProvidedBuildOptions: UserProvidedBuildOptions = {
|
@@ -152,8 +172,8 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
152
172
|
|
153
173
|
if (parsedPackageJson.keycloakify?.reactAppBuildDirPath !== undefined) {
|
154
174
|
return getAbsoluteAndInOsFormatPath({
|
155
|
-
|
156
|
-
|
175
|
+
pathIsh: parsedPackageJson.keycloakify.reactAppBuildDirPath,
|
176
|
+
cwd: reactAppRootDirPath
|
157
177
|
});
|
158
178
|
}
|
159
179
|
|
@@ -165,15 +185,16 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
165
185
|
|
166
186
|
const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({
|
167
187
|
reactAppRootDirPath,
|
168
|
-
|
188
|
+
dependencyExpected: "keycloakify"
|
169
189
|
});
|
170
190
|
|
171
191
|
return {
|
172
|
-
|
173
|
-
|
192
|
+
bundler: resolvedViteConfig !== undefined ? "vite" : "webpack",
|
193
|
+
themeVersion:
|
194
|
+
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
174
195
|
themeNames,
|
175
|
-
|
176
|
-
|
196
|
+
extraThemeProperties: userProvidedBuildOptions.extraThemeProperties,
|
197
|
+
groupId: (() => {
|
177
198
|
const fallbackGroupId = `${themeNames[0]}.keycloak`;
|
178
199
|
|
179
200
|
return (
|
@@ -188,24 +209,30 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
188
209
|
.join(".") ?? fallbackGroupId) + ".keycloak"
|
189
210
|
);
|
190
211
|
})(),
|
191
|
-
|
192
|
-
|
212
|
+
artifactId:
|
213
|
+
process.env.KEYCLOAKIFY_ARTIFACT_ID ??
|
214
|
+
userProvidedBuildOptions.artifactId ??
|
215
|
+
`${themeNames[0]}-keycloak-theme`,
|
216
|
+
loginThemeResourcesFromKeycloakVersion:
|
217
|
+
userProvidedBuildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
|
193
218
|
reactAppRootDirPath,
|
194
219
|
reactAppBuildDirPath,
|
195
|
-
|
220
|
+
keycloakifyBuildDirPath: (() => {
|
196
221
|
if (userProvidedBuildOptions.keycloakifyBuildDirPath !== undefined) {
|
197
222
|
return getAbsoluteAndInOsFormatPath({
|
198
|
-
|
199
|
-
|
223
|
+
pathIsh: userProvidedBuildOptions.keycloakifyBuildDirPath,
|
224
|
+
cwd: reactAppRootDirPath
|
200
225
|
});
|
201
226
|
}
|
202
227
|
|
203
228
|
return pathJoin(
|
204
229
|
reactAppRootDirPath,
|
205
|
-
resolvedViteConfig?.buildDir === undefined
|
230
|
+
resolvedViteConfig?.buildDir === undefined
|
231
|
+
? "build_keycloak"
|
232
|
+
: `${resolvedViteConfig.buildDir}_keycloak`
|
206
233
|
);
|
207
234
|
})(),
|
208
|
-
|
235
|
+
publicDirPath: (() => {
|
209
236
|
webpack: {
|
210
237
|
if (resolvedViteConfig !== undefined) {
|
211
238
|
break webpack;
|
@@ -213,8 +240,8 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
213
240
|
|
214
241
|
if (process.env.PUBLIC_DIR_PATH !== undefined) {
|
215
242
|
return getAbsoluteAndInOsFormatPath({
|
216
|
-
|
217
|
-
|
243
|
+
pathIsh: process.env.PUBLIC_DIR_PATH,
|
244
|
+
cwd: reactAppRootDirPath
|
218
245
|
});
|
219
246
|
}
|
220
247
|
|
@@ -223,13 +250,13 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
223
250
|
|
224
251
|
return pathJoin(reactAppRootDirPath, resolvedViteConfig.publicDir);
|
225
252
|
})(),
|
226
|
-
|
253
|
+
cacheDirPath: (() => {
|
227
254
|
const cacheDirPath = pathJoin(
|
228
255
|
(() => {
|
229
256
|
if (process.env.XDG_CACHE_HOME !== undefined) {
|
230
257
|
return getAbsoluteAndInOsFormatPath({
|
231
|
-
|
232
|
-
|
258
|
+
pathIsh: process.env.XDG_CACHE_HOME,
|
259
|
+
cwd: process.cwd()
|
233
260
|
});
|
234
261
|
}
|
235
262
|
|
@@ -240,7 +267,7 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
240
267
|
|
241
268
|
return cacheDirPath;
|
242
269
|
})(),
|
243
|
-
|
270
|
+
urlPathname: (() => {
|
244
271
|
webpack: {
|
245
272
|
if (resolvedViteConfig !== undefined) {
|
246
273
|
break webpack;
|
@@ -264,7 +291,7 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
|
|
264
291
|
|
265
292
|
return resolvedViteConfig.urlPathname;
|
266
293
|
})(),
|
267
|
-
|
294
|
+
assetsDirPath: (() => {
|
268
295
|
webpack: {
|
269
296
|
if (resolvedViteConfig !== undefined) {
|
270
297
|
break webpack;
|
@@ -10,8 +10,8 @@ export const accountV1ThemeName = "account-v1";
|
|
10
10
|
export type ThemeType = (typeof themeTypes)[number];
|
11
11
|
|
12
12
|
export const vitePluginSubScriptEnvNames = {
|
13
|
-
|
14
|
-
|
13
|
+
runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
|
14
|
+
resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
|
15
15
|
} as const;
|
16
16
|
|
17
17
|
export const skipBuildJarsEnvName = "KEYCLOAKIFY_SKIP_BUILD_JAR";
|
@@ -65,3 +65,5 @@ export const accountThemePageIds = [
|
|
65
65
|
|
66
66
|
export type LoginThemePageId = (typeof loginThemePageIds)[number];
|
67
67
|
export type AccountThemePageId = (typeof accountThemePageIds)[number];
|
68
|
+
|
69
|
+
export const containerName = "keycloak-keycloakify";
|
@@ -3,7 +3,11 @@ import {
|
|
3
3
|
type BuildOptionsLike as BuildOptionsLike_downloadKeycloakStaticResources
|
4
4
|
} from "./downloadKeycloakStaticResources";
|
5
5
|
import { join as pathJoin, relative as pathRelative } from "path";
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
themeTypes,
|
8
|
+
keycloak_resources,
|
9
|
+
lastKeycloakVersionWithAccountV1
|
10
|
+
} from "../shared/constants";
|
7
11
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
8
12
|
import { assert } from "tsafe/assert";
|
9
13
|
import * as fs from "fs";
|
@@ -17,7 +21,9 @@ export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakStaticResources
|
|
17
21
|
|
18
22
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
19
23
|
|
20
|
-
export async function copyKeycloakResourcesToPublic(params: {
|
24
|
+
export async function copyKeycloakResourcesToPublic(params: {
|
25
|
+
buildOptions: BuildOptionsLike;
|
26
|
+
}) {
|
21
27
|
const { buildOptions } = params;
|
22
28
|
|
23
29
|
const destDirPath = pathJoin(buildOptions.publicDirPath, keycloak_resources);
|
@@ -27,11 +33,14 @@ export async function copyKeycloakResourcesToPublic(params: { buildOptions: Buil
|
|
27
33
|
const keycloakifyBuildinfoRaw = JSON.stringify(
|
28
34
|
{
|
29
35
|
destDirPath,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
keycloakifyVersion: readThisNpmPackageVersion(),
|
37
|
+
buildOptions: {
|
38
|
+
loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
|
39
|
+
cacheDirPath: pathRelative(destDirPath, buildOptions.cacheDirPath),
|
40
|
+
npmWorkspaceRootDirPath: pathRelative(
|
41
|
+
destDirPath,
|
42
|
+
buildOptions.npmWorkspaceRootDirPath
|
43
|
+
)
|
35
44
|
}
|
36
45
|
},
|
37
46
|
null,
|
@@ -43,7 +52,9 @@ export async function copyKeycloakResourcesToPublic(params: { buildOptions: Buil
|
|
43
52
|
break skip_if_already_done;
|
44
53
|
}
|
45
54
|
|
46
|
-
const keycloakifyBuildinfoRaw_previousRun = fs
|
55
|
+
const keycloakifyBuildinfoRaw_previousRun = fs
|
56
|
+
.readFileSync(keycloakifyBuildinfoFilePath)
|
57
|
+
.toString("utf8");
|
47
58
|
|
48
59
|
if (keycloakifyBuildinfoRaw_previousRun !== keycloakifyBuildinfoRaw) {
|
49
60
|
break skip_if_already_done;
|
@@ -52,15 +63,15 @@ export async function copyKeycloakResourcesToPublic(params: { buildOptions: Buil
|
|
52
63
|
return;
|
53
64
|
}
|
54
65
|
|
55
|
-
rmSync(destDirPath, {
|
66
|
+
rmSync(destDirPath, { force: true, recursive: true });
|
56
67
|
|
57
|
-
fs.mkdirSync(destDirPath, {
|
68
|
+
fs.mkdirSync(destDirPath, { recursive: true });
|
58
69
|
|
59
70
|
fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
60
71
|
|
61
72
|
for (const themeType of themeTypes) {
|
62
73
|
await downloadKeycloakStaticResources({
|
63
|
-
|
74
|
+
keycloakVersion: (() => {
|
64
75
|
switch (themeType) {
|
65
76
|
case "login":
|
66
77
|
return buildOptions.loginThemeResourcesFromKeycloakVersion;
|
@@ -69,7 +80,7 @@ export async function copyKeycloakResourcesToPublic(params: { buildOptions: Buil
|
|
69
80
|
}
|
70
81
|
})(),
|
71
82
|
themeType,
|
72
|
-
|
83
|
+
themeDirPath: destDirPath,
|
73
84
|
buildOptions
|
74
85
|
});
|
75
86
|
}
|
@@ -86,5 +97,8 @@ export async function copyKeycloakResourcesToPublic(params: { buildOptions: Buil
|
|
86
97
|
)
|
87
98
|
);
|
88
99
|
|
89
|
-
fs.writeFileSync(
|
100
|
+
fs.writeFileSync(
|
101
|
+
keycloakifyBuildinfoFilePath,
|
102
|
+
Buffer.from(keycloakifyBuildinfoRaw, "utf8")
|
103
|
+
);
|
90
104
|
}
|