keycloakify 10.0.0-rc.109 → 10.0.0-rc.111
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 +2 -2
- package/PUBLIC_URL.js.map +1 -1
- package/account/KcContext/kcContextMocks.js +3 -3
- package/account/i18n/i18n.js +4 -4
- package/account/i18n/i18n.js.map +1 -1
- package/account/i18n/useI18n.d.ts +1 -1
- package/account/i18n/useI18n.js +2 -2
- package/account/i18n/useI18n.js.map +1 -1
- package/bin/193.index.js +4 -4
- package/bin/31.index.js +31 -31
- package/bin/440.index.js +59 -59
- package/bin/453.index.js +3 -3
- package/bin/526.index.js +5 -5
- package/bin/622.index.js +1 -1
- package/bin/97.index.js +3 -3
- package/bin/shared/buildContext.js.map +1 -1
- package/bin/shared/constants.d.ts +17 -17
- package/bin/shared/constants.js +14 -14
- package/bin/shared/constants.js.map +1 -1
- package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -1
- package/bin/shared/downloadKeycloakDefaultTheme.js.map +1 -1
- package/login/KcContext/kcContextMocks.js +3 -3
- package/login/i18n/i18n.js +4 -4
- package/login/i18n/i18n.js.map +1 -1
- package/login/i18n/useI18n.d.ts +1 -1
- package/login/i18n/useI18n.js +2 -11
- package/login/i18n/useI18n.js.map +1 -1
- package/package.json +1 -1
- package/src/PUBLIC_URL.ts +2 -2
- package/src/account/KcContext/kcContextMocks.ts +3 -3
- package/src/account/i18n/i18n.tsx +4 -4
- package/src/account/i18n/useI18n.tsx +2 -2
- package/src/bin/add-story.ts +6 -6
- package/src/bin/eject-page.ts +6 -6
- package/src/bin/keycloakify/buildJars/buildJar.ts +23 -22
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +15 -19
- package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +386 -375
- package/src/bin/keycloakify/generateResources/bringInAccountV1.ts +7 -7
- package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +2 -2
- package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +17 -19
- package/src/bin/keycloakify/generateResources/generateResourcesForThemeVariant.ts +2 -2
- package/src/bin/keycloakify/generateResources/readExtraPageNames.ts +4 -4
- package/src/bin/keycloakify/keycloakify.ts +7 -5
- package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +3 -4
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +6 -6
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +4 -4
- package/src/bin/shared/buildContext.ts +9 -8
- package/src/bin/shared/constants.ts +17 -17
- package/src/bin/shared/copyKeycloakResourcesToPublic.ts +6 -6
- package/src/bin/shared/downloadKeycloakDefaultTheme.ts +2 -2
- package/src/bin/shared/downloadKeycloakStaticResources.ts +2 -2
- package/src/bin/start-keycloak/keycloakifyBuild.ts +2 -2
- package/src/bin/start-keycloak/start-keycloak.ts +5 -5
- package/src/login/KcContext/kcContextMocks.ts +4 -4
- package/src/login/i18n/i18n.tsx +4 -4
- package/src/login/i18n/useI18n.tsx +2 -11
- package/src/vite-plugin/vite-plugin.ts +8 -8
- package/vite-plugin/index.js +42 -42
@@ -3,9 +3,9 @@ import { join as pathJoin } from "path";
|
|
3
3
|
import { assert } from "tsafe/assert";
|
4
4
|
import type { BuildContext } from "../../shared/buildContext";
|
5
5
|
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
RESOURCES_COMMON,
|
7
|
+
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
8
|
+
ACCOUNT_V1_THEME_NAME
|
9
9
|
} from "../../shared/constants";
|
10
10
|
import {
|
11
11
|
downloadKeycloakDefaultTheme,
|
@@ -24,14 +24,14 @@ export async function bringInAccountV1(params: {
|
|
24
24
|
const { resourcesDirPath, buildContext } = params;
|
25
25
|
|
26
26
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
27
|
-
keycloakVersion:
|
27
|
+
keycloakVersion: LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
28
28
|
buildContext
|
29
29
|
});
|
30
30
|
|
31
31
|
const accountV1DirPath = pathJoin(
|
32
32
|
resourcesDirPath,
|
33
33
|
"theme",
|
34
|
-
|
34
|
+
ACCOUNT_V1_THEME_NAME,
|
35
35
|
"account"
|
36
36
|
);
|
37
37
|
|
@@ -47,7 +47,7 @@ export async function bringInAccountV1(params: {
|
|
47
47
|
|
48
48
|
transformCodebase({
|
49
49
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
50
|
-
destDirPath: pathJoin(accountV1DirPath, "resources",
|
50
|
+
destDirPath: pathJoin(accountV1DirPath, "resources", RESOURCES_COMMON)
|
51
51
|
});
|
52
52
|
|
53
53
|
fs.writeFileSync(
|
@@ -69,7 +69,7 @@ export async function bringInAccountV1(params: {
|
|
69
69
|
"patternfly-additions.min.css"
|
70
70
|
].map(
|
71
71
|
fileBasename =>
|
72
|
-
`${
|
72
|
+
`${RESOURCES_COMMON}/node_modules/patternfly/dist/css/${fileBasename}`
|
73
73
|
)
|
74
74
|
].join(" "),
|
75
75
|
"",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type ThemeType,
|
1
|
+
import { type ThemeType, FALLBACK_LANGUAGE_TAG } from "../../shared/constants";
|
2
2
|
import { crawl } from "../../tools/crawl";
|
3
3
|
import { join as pathJoin } from "path";
|
4
4
|
import { symToStr } from "tsafe/symToStr";
|
@@ -168,7 +168,7 @@ export function generateMessageProperties(params: {
|
|
168
168
|
...(messageBundle === undefined
|
169
169
|
? {}
|
170
170
|
: messageBundle[languageTag] ??
|
171
|
-
messageBundle[
|
171
|
+
messageBundle[FALLBACK_LANGUAGE_TAG] ??
|
172
172
|
messageBundle[Object.keys(messageBundle)[0]] ??
|
173
173
|
{})
|
174
174
|
}
|
@@ -15,12 +15,12 @@ import {
|
|
15
15
|
} from "../generateFtl";
|
16
16
|
import {
|
17
17
|
type ThemeType,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
19
|
+
KEYCLOAK_RESOURCES,
|
20
|
+
ACCOUNT_V1_THEME_NAME,
|
21
|
+
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR,
|
22
|
+
LOGIN_THEME_PAGE_IDS,
|
23
|
+
ACCOUNT_THEME_PAGE_IDS
|
24
24
|
} from "../../shared/constants";
|
25
25
|
import type { BuildContext } from "../../shared/buildContext";
|
26
26
|
import { assert, type Equals } from "tsafe/assert";
|
@@ -85,7 +85,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
85
85
|
const destDirPath = pathJoin(
|
86
86
|
themeTypeDirPath,
|
87
87
|
"resources",
|
88
|
-
|
88
|
+
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
|
89
89
|
);
|
90
90
|
|
91
91
|
// NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
|
@@ -103,7 +103,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
103
103
|
themeType: "login"
|
104
104
|
}),
|
105
105
|
"resources",
|
106
|
-
|
106
|
+
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
|
107
107
|
),
|
108
108
|
destDirPath
|
109
109
|
});
|
@@ -114,7 +114,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
114
114
|
{
|
115
115
|
const dirPath = pathJoin(
|
116
116
|
buildContext.projectBuildDirPath,
|
117
|
-
|
117
|
+
KEYCLOAK_RESOURCES
|
118
118
|
);
|
119
119
|
|
120
120
|
if (fs.existsSync(dirPath)) {
|
@@ -122,7 +122,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
122
122
|
|
123
123
|
throw new Error(
|
124
124
|
[
|
125
|
-
`Keycloakify build error: The ${
|
125
|
+
`Keycloakify build error: The ${KEYCLOAK_RESOURCES} directory shouldn't exist in your build directory.`,
|
126
126
|
`(${pathRelative(process.cwd(), dirPath)}).\n`,
|
127
127
|
`Theses assets are only required for local development with Storybook.",
|
128
128
|
"Please remove this directory as an additional step of your command.\n`,
|
@@ -140,8 +140,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
140
140
|
const { fixedCssCode } = replaceImportsInCssCode({
|
141
141
|
cssCode: sourceCode.toString("utf8"),
|
142
142
|
cssFileRelativeDirPath: pathDirname(fileRelativePath),
|
143
|
-
buildContext
|
144
|
-
isAccountV3
|
143
|
+
buildContext
|
145
144
|
});
|
146
145
|
|
147
146
|
return {
|
@@ -176,17 +175,16 @@ export async function generateResourcesForMainTheme(params: {
|
|
176
175
|
fieldNames: readFieldNameUsage({
|
177
176
|
themeSrcDirPath: buildContext.themeSrcDirPath,
|
178
177
|
themeType
|
179
|
-
})
|
180
|
-
isAccountV3
|
178
|
+
})
|
181
179
|
});
|
182
180
|
|
183
181
|
[
|
184
182
|
...(() => {
|
185
183
|
switch (themeType) {
|
186
184
|
case "login":
|
187
|
-
return
|
185
|
+
return LOGIN_THEME_PAGE_IDS;
|
188
186
|
case "account":
|
189
|
-
return isAccountV3 ? ["index.ftl"] :
|
187
|
+
return isAccountV3 ? ["index.ftl"] : ACCOUNT_THEME_PAGE_IDS;
|
190
188
|
}
|
191
189
|
})(),
|
192
190
|
...(isAccountV3
|
@@ -240,7 +238,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
240
238
|
keycloakVersion: (() => {
|
241
239
|
switch (themeType) {
|
242
240
|
case "account":
|
243
|
-
return
|
241
|
+
return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
|
244
242
|
case "login":
|
245
243
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
246
244
|
}
|
@@ -258,7 +256,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
258
256
|
`parent=${(() => {
|
259
257
|
switch (themeType) {
|
260
258
|
case "account":
|
261
|
-
return isAccountV3 ? "base" :
|
259
|
+
return isAccountV3 ? "base" : ACCOUNT_V1_THEME_NAME;
|
262
260
|
case "login":
|
263
261
|
return "keycloak";
|
264
262
|
}
|
@@ -349,7 +347,7 @@ export async function generateResourcesForMainTheme(params: {
|
|
349
347
|
|
350
348
|
if (buildContext.recordIsImplementedByThemeType.account) {
|
351
349
|
metaInfKeycloakThemes.themes.push({
|
352
|
-
name:
|
350
|
+
name: ACCOUNT_V1_THEME_NAME,
|
353
351
|
types: ["account"]
|
354
352
|
});
|
355
353
|
}
|
@@ -31,8 +31,8 @@ export function generateResourcesForThemeVariant(params: {
|
|
31
31
|
Buffer.from(sourceCode)
|
32
32
|
.toString("utf-8")
|
33
33
|
.replace(
|
34
|
-
`
|
35
|
-
`
|
34
|
+
`"themeName": "${themeName}"`,
|
35
|
+
`"themeName": "${themeVariantName}"`
|
36
36
|
),
|
37
37
|
"utf8"
|
38
38
|
);
|
@@ -5,8 +5,8 @@ import * as fs from "fs";
|
|
5
5
|
import { join as pathJoin } from "path";
|
6
6
|
import {
|
7
7
|
type ThemeType,
|
8
|
-
|
9
|
-
|
8
|
+
ACCOUNT_THEME_PAGE_IDS,
|
9
|
+
LOGIN_THEME_PAGE_IDS
|
10
10
|
} from "../../shared/constants";
|
11
11
|
|
12
12
|
export function readExtraPagesNames(params: {
|
@@ -41,9 +41,9 @@ export function readExtraPagesNames(params: {
|
|
41
41
|
return extraPages.reduce(...removeDuplicates<string>()).filter(pageId => {
|
42
42
|
switch (themeType) {
|
43
43
|
case "account":
|
44
|
-
return !id<readonly string[]>(
|
44
|
+
return !id<readonly string[]>(ACCOUNT_THEME_PAGE_IDS).includes(pageId);
|
45
45
|
case "login":
|
46
|
-
return !id<readonly string[]>(
|
46
|
+
return !id<readonly string[]>(LOGIN_THEME_PAGE_IDS).includes(pageId);
|
47
47
|
}
|
48
48
|
});
|
49
49
|
}
|
@@ -3,7 +3,7 @@ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path
|
|
3
3
|
import * as child_process from "child_process";
|
4
4
|
import * as fs from "fs";
|
5
5
|
import { getBuildContext } from "../shared/buildContext";
|
6
|
-
import {
|
6
|
+
import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
|
7
7
|
import { buildJars } from "./buildJars";
|
8
8
|
import type { CliCommandOptions } from "../main";
|
9
9
|
import chalk from "chalk";
|
@@ -93,10 +93,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
93
93
|
cwd: buildContext.projectDirPath,
|
94
94
|
env: {
|
95
95
|
...process.env,
|
96
|
-
[
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RUN_POST_BUILD_SCRIPT]: JSON.stringify(
|
97
|
+
{
|
98
|
+
resourcesDirPath,
|
99
|
+
buildContext
|
100
|
+
}
|
101
|
+
)
|
100
102
|
}
|
101
103
|
});
|
102
104
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { BuildContext } from "../../shared/buildContext";
|
2
|
-
import {
|
2
|
+
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../shared/constants";
|
3
3
|
import { assert } from "tsafe/assert";
|
4
4
|
import { posix } from "path";
|
5
5
|
|
@@ -12,12 +12,11 @@ assert<BuildContext extends BuildContextLike ? true : false>();
|
|
12
12
|
export function replaceImportsInCssCode(params: {
|
13
13
|
cssCode: string;
|
14
14
|
cssFileRelativeDirPath: string | undefined;
|
15
|
-
isAccountV3: boolean;
|
16
15
|
buildContext: BuildContextLike;
|
17
16
|
}): {
|
18
17
|
fixedCssCode: string;
|
19
18
|
} {
|
20
|
-
const { cssCode, cssFileRelativeDirPath, buildContext
|
19
|
+
const { cssCode, cssFileRelativeDirPath, buildContext } = params;
|
21
20
|
|
22
21
|
const fixedCssCode = cssCode.replace(
|
23
22
|
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
@@ -38,7 +37,7 @@ export function replaceImportsInCssCode(params: {
|
|
38
37
|
break inline_style_in_html;
|
39
38
|
}
|
40
39
|
|
41
|
-
return `url(\${
|
40
|
+
return `url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}${assetFileAbsoluteUrlPathname})`;
|
42
41
|
}
|
43
42
|
|
44
43
|
const assetFileRelativeUrlPathname = posix.relative(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
|
2
2
|
import { assert } from "tsafe/assert";
|
3
3
|
import type { BuildContext } from "../../../shared/buildContext";
|
4
4
|
import * as nodePath from "path";
|
@@ -31,13 +31,13 @@ export function replaceImportsInJsCode_vite(params: {
|
|
31
31
|
|
32
32
|
let fixedJsCode = jsCode;
|
33
33
|
|
34
|
-
|
34
|
+
replace_base_js_import: {
|
35
35
|
if (buildContext.urlPathname === undefined) {
|
36
|
-
break
|
36
|
+
break replace_base_js_import;
|
37
37
|
}
|
38
38
|
// Optimization
|
39
39
|
if (!jsCode.includes(buildContext.urlPathname)) {
|
40
|
-
break
|
40
|
+
break replace_base_js_import;
|
41
41
|
}
|
42
42
|
|
43
43
|
// Replace `Hv=function(e){return"/abcde12345/"+e}` by `Hv=function(e){return"/"+e}`
|
@@ -85,13 +85,13 @@ export function replaceImportsInJsCode_vite(params: {
|
|
85
85
|
fixedJsCode = replaceAll(
|
86
86
|
fixedJsCode,
|
87
87
|
`"${relativePathOfAssetFile}"`,
|
88
|
-
`(window.kcContext.
|
88
|
+
`(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
|
89
89
|
);
|
90
90
|
|
91
91
|
fixedJsCode = replaceAll(
|
92
92
|
fixedJsCode,
|
93
93
|
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
94
|
-
`(window.kcContext.
|
94
|
+
`(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
|
95
95
|
);
|
96
96
|
});
|
97
97
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
|
2
2
|
import { assert } from "tsafe/assert";
|
3
3
|
import type { BuildContext } from "../../../shared/buildContext";
|
4
4
|
import * as nodePath from "path";
|
@@ -83,14 +83,14 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
83
83
|
var pd = Object.getOwnPropertyDescriptor(${n}, "p");
|
84
84
|
if( pd === undefined || pd.configurable ){
|
85
85
|
Object.defineProperty(${n}, "p", {
|
86
|
-
get: function() { return window.kcContext.
|
86
|
+
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
87
87
|
set: function() {}
|
88
88
|
});
|
89
89
|
}
|
90
90
|
return "${u}";
|
91
91
|
})()] = ${
|
92
92
|
isArrowFunction ? `${e} =>` : `function(${e}) { return `
|
93
|
-
} "/${
|
93
|
+
} "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}${language}/"`
|
94
94
|
.replace(/\s+/g, " ")
|
95
95
|
.trim();
|
96
96
|
}
|
@@ -104,7 +104,7 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
104
104
|
`[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
|
105
105
|
"g"
|
106
106
|
),
|
107
|
-
`window.kcContext.
|
107
|
+
`window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}`
|
108
108
|
);
|
109
109
|
|
110
110
|
return { fixedJsCode };
|
@@ -13,13 +13,13 @@ import * as fs from "fs";
|
|
13
13
|
import { assert, type Equals } from "tsafe/assert";
|
14
14
|
import * as child_process from "child_process";
|
15
15
|
import {
|
16
|
-
|
17
|
-
|
16
|
+
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES,
|
17
|
+
BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME
|
18
18
|
} from "./constants";
|
19
19
|
import type { KeycloakVersionRange } from "./KeycloakVersionRange";
|
20
20
|
import { exclude } from "tsafe";
|
21
21
|
import { crawl } from "../tools/crawl";
|
22
|
-
import {
|
22
|
+
import { THEME_TYPES } from "./constants";
|
23
23
|
import { objectFromEntries } from "tsafe/objectFromEntries";
|
24
24
|
import { objectEntries } from "tsafe/objectEntries";
|
25
25
|
import { type ThemeType } from "./constants";
|
@@ -136,7 +136,7 @@ export function getBuildContext(params: {
|
|
136
136
|
return { themeSrcDirPath };
|
137
137
|
}
|
138
138
|
|
139
|
-
for (const themeType of [...
|
139
|
+
for (const themeType of [...THEME_TYPES, "email"]) {
|
140
140
|
if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
|
141
141
|
continue;
|
142
142
|
}
|
@@ -171,18 +171,18 @@ export function getBuildContext(params: {
|
|
171
171
|
cwd: projectDirPath,
|
172
172
|
env: {
|
173
173
|
...process.env,
|
174
|
-
[
|
174
|
+
[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG]: "true"
|
175
175
|
}
|
176
176
|
})
|
177
177
|
.toString("utf8");
|
178
178
|
|
179
179
|
assert(
|
180
|
-
output.includes(
|
180
|
+
output.includes(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG),
|
181
181
|
"Seems like the Keycloakify's Vite plugin is not installed."
|
182
182
|
);
|
183
183
|
|
184
184
|
const resolvedViteConfigStr = output
|
185
|
-
.split(
|
185
|
+
.split(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG)
|
186
186
|
.reverse()[0];
|
187
187
|
|
188
188
|
const resolvedViteConfig: ResolvedViteConfig = JSON.parse(resolvedViteConfigStr);
|
@@ -594,7 +594,8 @@ export function getBuildContext(params: {
|
|
594
594
|
|
595
595
|
build_for_specific_keycloak_major_version: {
|
596
596
|
const buildForKeycloakMajorVersionNumber = (() => {
|
597
|
-
const envValue =
|
597
|
+
const envValue =
|
598
|
+
process.env[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME];
|
598
599
|
|
599
600
|
if (envValue === undefined) {
|
600
601
|
return undefined;
|
@@ -1,22 +1,22 @@
|
|
1
|
-
export const
|
2
|
-
export const
|
3
|
-
export const
|
4
|
-
export const
|
1
|
+
export const KEYCLOAK_RESOURCES = "keycloak-resources";
|
2
|
+
export const RESOURCES_COMMON = "resources-common";
|
3
|
+
export const LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 = "21.1.2";
|
4
|
+
export const BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR = "dist";
|
5
5
|
|
6
|
-
export const
|
7
|
-
export const
|
6
|
+
export const THEME_TYPES = ["login", "account"] as const;
|
7
|
+
export const ACCOUNT_V1_THEME_NAME = "account-v1";
|
8
8
|
|
9
|
-
export type ThemeType = (typeof
|
9
|
+
export type ThemeType = (typeof THEME_TYPES)[number];
|
10
10
|
|
11
|
-
export const
|
12
|
-
|
13
|
-
|
11
|
+
export const VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES = {
|
12
|
+
RUN_POST_BUILD_SCRIPT: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
|
13
|
+
RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
|
14
14
|
} as const;
|
15
15
|
|
16
|
-
export const
|
16
|
+
export const BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME =
|
17
17
|
"KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
|
18
18
|
|
19
|
-
export const
|
19
|
+
export const LOGIN_THEME_PAGE_IDS = [
|
20
20
|
"login.ftl",
|
21
21
|
"login-username.ftl",
|
22
22
|
"login-password.ftl",
|
@@ -53,7 +53,7 @@ export const loginThemePageIds = [
|
|
53
53
|
"webauthn-error.ftl"
|
54
54
|
] as const;
|
55
55
|
|
56
|
-
export const
|
56
|
+
export const ACCOUNT_THEME_PAGE_IDS = [
|
57
57
|
"password.ftl",
|
58
58
|
"account.ftl",
|
59
59
|
"sessions.ftl",
|
@@ -63,9 +63,9 @@ export const accountThemePageIds = [
|
|
63
63
|
"federatedIdentity.ftl"
|
64
64
|
] as const;
|
65
65
|
|
66
|
-
export type LoginThemePageId = (typeof
|
67
|
-
export type AccountThemePageId = (typeof
|
66
|
+
export type LoginThemePageId = (typeof LOGIN_THEME_PAGE_IDS)[number];
|
67
|
+
export type AccountThemePageId = (typeof ACCOUNT_THEME_PAGE_IDS)[number];
|
68
68
|
|
69
|
-
export const
|
69
|
+
export const CONTAINER_NAME = "keycloak-keycloakify";
|
70
70
|
|
71
|
-
export const
|
71
|
+
export const FALLBACK_LANGUAGE_TAG = "en";
|
@@ -4,9 +4,9 @@ import {
|
|
4
4
|
} from "./downloadKeycloakStaticResources";
|
5
5
|
import { join as pathJoin, relative as pathRelative } from "path";
|
6
6
|
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
THEME_TYPES,
|
8
|
+
KEYCLOAK_RESOURCES,
|
9
|
+
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1
|
10
10
|
} from "../shared/constants";
|
11
11
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
12
12
|
import { assert } from "tsafe/assert";
|
@@ -26,7 +26,7 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
26
26
|
}) {
|
27
27
|
const { buildContext } = params;
|
28
28
|
|
29
|
-
const destDirPath = pathJoin(buildContext.publicDirPath,
|
29
|
+
const destDirPath = pathJoin(buildContext.publicDirPath, KEYCLOAK_RESOURCES);
|
30
30
|
|
31
31
|
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
32
32
|
|
@@ -66,14 +66,14 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
66
66
|
|
67
67
|
fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
68
68
|
|
69
|
-
for (const themeType of
|
69
|
+
for (const themeType of THEME_TYPES) {
|
70
70
|
await downloadKeycloakStaticResources({
|
71
71
|
keycloakVersion: (() => {
|
72
72
|
switch (themeType) {
|
73
73
|
case "login":
|
74
74
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
75
75
|
case "account":
|
76
|
-
return
|
76
|
+
return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
|
77
77
|
}
|
78
78
|
})(),
|
79
79
|
themeType,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { join as pathJoin, relative as pathRelative } from "path";
|
2
2
|
import { type BuildContext } from "./buildContext";
|
3
3
|
import { assert } from "tsafe/assert";
|
4
|
-
import {
|
4
|
+
import { LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 } from "./constants";
|
5
5
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
6
6
|
|
7
7
|
export type BuildContextLike = {
|
@@ -43,7 +43,7 @@ export async function downloadKeycloakDefaultTheme(params: {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
last_account_v1_transformations: {
|
46
|
-
if (
|
46
|
+
if (LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 !== keycloakVersion) {
|
47
47
|
break last_account_v1_transformations;
|
48
48
|
}
|
49
49
|
|
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
downloadKeycloakDefaultTheme,
|
5
5
|
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
6
6
|
} from "./downloadKeycloakDefaultTheme";
|
7
|
-
import {
|
7
|
+
import { RESOURCES_COMMON, type ThemeType } from "./constants";
|
8
8
|
import type { BuildContext } from "./buildContext";
|
9
9
|
import { assert } from "tsafe/assert";
|
10
10
|
import { existsAsync } from "../tools/fs.existsAsync";
|
@@ -48,6 +48,6 @@ export async function downloadKeycloakStaticResources(params: {
|
|
48
48
|
|
49
49
|
transformCodebase({
|
50
50
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
51
|
-
destDirPath: pathJoin(resourcesDirPath,
|
51
|
+
destDirPath: pathJoin(resourcesDirPath, RESOURCES_COMMON)
|
52
52
|
});
|
53
53
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME } from "../shared/constants";
|
2
2
|
import * as child_process from "child_process";
|
3
3
|
import { Deferred } from "evt/tools/Deferred";
|
4
4
|
import { assert } from "tsafe/assert";
|
@@ -26,7 +26,7 @@ export async function keycloakifyBuild(params: {
|
|
26
26
|
cwd: buildContext.projectDirPath,
|
27
27
|
env: {
|
28
28
|
...process.env,
|
29
|
-
[
|
29
|
+
[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME]: `${buildForKeycloakMajorVersionNumber}`
|
30
30
|
},
|
31
31
|
shell: true
|
32
32
|
});
|
@@ -2,7 +2,7 @@ import { getBuildContext } from "../shared/buildContext";
|
|
2
2
|
import { exclude } from "tsafe/exclude";
|
3
3
|
import type { CliCommandOptions as CliCommandOptions_common } from "../main";
|
4
4
|
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
5
|
-
import {
|
5
|
+
import { ACCOUNT_V1_THEME_NAME, CONTAINER_NAME } from "../shared/constants";
|
6
6
|
import { SemVer } from "../tools/SemVer";
|
7
7
|
import { assert } from "tsafe/assert";
|
8
8
|
import * as fs from "fs";
|
@@ -269,7 +269,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
269
269
|
fs.copyFileSync(jarFilePath, jarFilePath_cacheDir);
|
270
270
|
|
271
271
|
try {
|
272
|
-
child_process.execSync(`docker rm --force ${
|
272
|
+
child_process.execSync(`docker rm --force ${CONTAINER_NAME}`, {
|
273
273
|
stdio: "ignore"
|
274
274
|
});
|
275
275
|
} catch {}
|
@@ -279,7 +279,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
279
279
|
[
|
280
280
|
"run",
|
281
281
|
...["-p", `${cliCommandOptions.port}:8080`],
|
282
|
-
...["--name",
|
282
|
+
...["--name", CONTAINER_NAME],
|
283
283
|
...["-e", "KEYCLOAK_ADMIN=admin"],
|
284
284
|
...["-e", "KEYCLOAK_ADMIN_PASSWORD=admin"],
|
285
285
|
...(realmJsonFilePath === undefined
|
@@ -301,10 +301,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
301
301
|
pathJoin(
|
302
302
|
buildContext.keycloakifyBuildDirPath,
|
303
303
|
"theme",
|
304
|
-
|
304
|
+
ACCOUNT_V1_THEME_NAME
|
305
305
|
)
|
306
306
|
)
|
307
|
-
? [
|
307
|
+
? [ACCOUNT_V1_THEME_NAME]
|
308
308
|
: [])
|
309
309
|
]
|
310
310
|
.map(themeName => ({
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import "keycloakify/tools/Object.fromEntries";
|
2
2
|
import type { KcContext, Attribute } from "./KcContext";
|
3
3
|
import {
|
4
|
-
|
5
|
-
|
4
|
+
RESOURCES_COMMON,
|
5
|
+
KEYCLOAK_RESOURCES,
|
6
6
|
type LoginThemePageId
|
7
7
|
} from "keycloakify/bin/shared/constants";
|
8
8
|
import { id } from "tsafe/id";
|
@@ -76,7 +76,7 @@ const attributesByName = Object.fromEntries(
|
|
76
76
|
]).map(attribute => [attribute.name, attribute])
|
77
77
|
);
|
78
78
|
|
79
|
-
const resourcesPath = `${BASE_URL}${
|
79
|
+
const resourcesPath = `${BASE_URL}${KEYCLOAK_RESOURCES}/login/resources`;
|
80
80
|
|
81
81
|
export const kcContextCommonMock: KcContext.Common = {
|
82
82
|
themeVersion: "0.0.0",
|
@@ -86,7 +86,7 @@ export const kcContextCommonMock: KcContext.Common = {
|
|
86
86
|
url: {
|
87
87
|
loginAction: "#",
|
88
88
|
resourcesPath,
|
89
|
-
resourcesCommonPath: `${resourcesPath}/${
|
89
|
+
resourcesCommonPath: `${resourcesPath}/${RESOURCES_COMMON}`,
|
90
90
|
loginRestartFlowUrl: "#",
|
91
91
|
loginUrl: "#",
|
92
92
|
ssoLoginInOtherTabsUrl: "#"
|
package/src/login/i18n/i18n.tsx
CHANGED
@@ -3,7 +3,7 @@ import { assert } from "tsafe/assert";
|
|
3
3
|
import messages_defaultSet_fallbackLanguage from "./messages_defaultSet/en";
|
4
4
|
import { fetchMessages_defaultSet } from "./messages_defaultSet";
|
5
5
|
import type { KcContext } from "../KcContext";
|
6
|
-
import {
|
6
|
+
import { FALLBACK_LANGUAGE_TAG } from "keycloakify/bin/shared/constants";
|
7
7
|
import { id } from "tsafe/id";
|
8
8
|
|
9
9
|
export type KcContextLike = {
|
@@ -104,7 +104,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|
104
104
|
}
|
105
105
|
|
106
106
|
const partialI18n: Pick<I18n, "currentLanguageTag" | "getChangeLocaleUrl" | "labelBySupportedLanguageTag"> = {
|
107
|
-
currentLanguageTag: kcContext.locale?.currentLanguageTag ??
|
107
|
+
currentLanguageTag: kcContext.locale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG,
|
108
108
|
getChangeLocaleUrl: newLanguageTag => {
|
109
109
|
const { locale } = kcContext;
|
110
110
|
|
@@ -122,7 +122,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|
122
122
|
const { createI18nTranslationFunctions } = createI18nTranslationFunctionsFactory<MessageKey_themeDefined>({
|
123
123
|
messages_themeDefined:
|
124
124
|
messagesByLanguageTag_themeDefined[partialI18n.currentLanguageTag] ??
|
125
|
-
messagesByLanguageTag_themeDefined[
|
125
|
+
messagesByLanguageTag_themeDefined[FALLBACK_LANGUAGE_TAG] ??
|
126
126
|
(() => {
|
127
127
|
const firstLanguageTag = Object.keys(messagesByLanguageTag_themeDefined)[0];
|
128
128
|
if (firstLanguageTag === undefined) {
|
@@ -133,7 +133,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|
133
133
|
messages_fromKcServer: kcContext["x-keycloakify"].messages
|
134
134
|
});
|
135
135
|
|
136
|
-
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag ===
|
136
|
+
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag === FALLBACK_LANGUAGE_TAG;
|
137
137
|
|
138
138
|
const result: Result = {
|
139
139
|
i18n: {
|