keycloakify 2.2.0 → 2.5.1
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/CHANGELOG.md +21 -0
- package/README.md +156 -127
- package/bin/KeycloakVersion.js.map +1 -1
- package/bin/build-keycloak-theme/build-keycloak-theme.js +57 -54
- package/bin/build-keycloak-theme/build-keycloak-theme.js.map +1 -1
- package/bin/build-keycloak-theme/ftlValuesGlobalName.js.map +1 -1
- package/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.js +4 -11
- package/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.js.map +1 -1
- package/bin/build-keycloak-theme/generateFtl/common.ftl +72 -56
- package/bin/build-keycloak-theme/generateFtl/generateFtl.d.ts +1 -1
- package/bin/build-keycloak-theme/generateFtl/generateFtl.js +47 -44
- package/bin/build-keycloak-theme/generateFtl/generateFtl.js.map +1 -1
- package/bin/build-keycloak-theme/generateJavaStackFiles.js +12 -8
- package/bin/build-keycloak-theme/generateJavaStackFiles.js.map +1 -1
- package/bin/build-keycloak-theme/generateKeycloakThemeResources.js +20 -21
- package/bin/build-keycloak-theme/generateKeycloakThemeResources.js.map +1 -1
- package/bin/build-keycloak-theme/index.js.map +1 -1
- package/bin/build-keycloak-theme/replaceImportFromStatic.js +18 -30
- package/bin/build-keycloak-theme/replaceImportFromStatic.js.map +1 -1
- package/bin/download-builtin-keycloak-theme.js +2 -2
- package/bin/download-builtin-keycloak-theme.js.map +1 -1
- package/bin/generate-i18n-messages.js +9 -11
- package/bin/generate-i18n-messages.js.map +1 -1
- package/bin/link_in_test_app.js +6 -22
- package/bin/link_in_test_app.js.map +1 -1
- package/bin/tools/crawl.js.map +1 -1
- package/bin/tools/downloadAndUnzip.js +4 -5
- package/bin/tools/downloadAndUnzip.js.map +1 -1
- package/bin/tools/grant-exec-perms.js +4 -3
- package/bin/tools/grant-exec-perms.js.map +1 -1
- package/bin/tools/isInside.js.map +1 -1
- package/bin/tools/rm.js +1 -1
- package/bin/tools/rm.js.map +1 -1
- package/bin/tools/transformCodebase.js +7 -3
- package/bin/tools/transformCodebase.js.map +1 -1
- package/lib/components/Error.js +1 -2
- package/lib/components/Error.js.map +1 -1
- package/lib/components/Info.js +1 -15
- package/lib/components/Info.js.map +1 -1
- package/lib/components/KcApp.js +23 -10
- package/lib/components/KcApp.js.map +1 -1
- package/lib/components/KcProps.d.ts +4 -2
- package/lib/components/KcProps.js +10 -8
- package/lib/components/KcProps.js.map +1 -1
- package/lib/components/Login.js +20 -18
- package/lib/components/Login.js.map +1 -1
- package/lib/components/LoginIdpLinkConfirm.js.map +1 -1
- package/lib/components/LoginOtp.js +14 -15
- package/lib/components/LoginOtp.js.map +1 -1
- package/lib/components/LoginResetPassword.js +5 -7
- package/lib/components/LoginResetPassword.js.map +1 -1
- package/lib/components/LoginUpdateProfile.js +1 -5
- package/lib/components/LoginUpdateProfile.js.map +1 -1
- package/lib/components/LoginVerifyEmail.js.map +1 -1
- package/lib/components/Register.js +1 -4
- package/lib/components/Register.js.map +1 -1
- package/lib/components/RegisterUserProfile.d.ts +6 -0
- package/lib/components/RegisterUserProfile.js +78 -0
- package/lib/components/RegisterUserProfile.js.map +1 -0
- package/lib/components/Template.js +28 -43
- package/lib/components/Template.js.map +1 -1
- package/lib/components/Terms.js.map +1 -1
- package/lib/getKcContext/KcContextBase.d.ts +78 -18
- package/lib/getKcContext/KcContextBase.js +2 -3
- package/lib/getKcContext/KcContextBase.js.map +1 -1
- package/lib/getKcContext/getKcContext.d.ts +1 -3
- package/lib/getKcContext/getKcContext.js +5 -9
- package/lib/getKcContext/getKcContext.js.map +1 -1
- package/lib/getKcContext/kcContextMocks/kcContextMocks.d.ts +1 -0
- package/lib/getKcContext/kcContextMocks/kcContextMocks.js +187 -55
- package/lib/getKcContext/kcContextMocks/kcContextMocks.js.map +1 -1
- package/lib/getKcContext/kcContextMocks/urlResourcesPath.js.map +1 -1
- package/lib/i18n/KcLanguageTag.d.ts +25 -2
- package/lib/i18n/KcLanguageTag.js +27 -27
- package/lib/i18n/KcLanguageTag.js.map +1 -1
- package/lib/i18n/generated_kcMessages/11.0.3/account.js +27 -27
- package/lib/i18n/generated_kcMessages/11.0.3/account.js.map +1 -1
- package/lib/i18n/generated_kcMessages/11.0.3/admin.js +23 -23
- package/lib/i18n/generated_kcMessages/11.0.3/admin.js.map +1 -1
- package/lib/i18n/generated_kcMessages/11.0.3/email.js +97 -97
- package/lib/i18n/generated_kcMessages/11.0.3/email.js.map +1 -1
- package/lib/i18n/generated_kcMessages/11.0.3/login.js +30 -30
- package/lib/i18n/generated_kcMessages/11.0.3/login.js.map +1 -1
- package/lib/i18n/generated_kcMessages/15.0.2/account.js +29 -29
- package/lib/i18n/generated_kcMessages/15.0.2/account.js.map +1 -1
- package/lib/i18n/generated_kcMessages/15.0.2/admin.js +23 -23
- package/lib/i18n/generated_kcMessages/15.0.2/admin.js.map +1 -1
- package/lib/i18n/generated_kcMessages/15.0.2/email.js +111 -111
- package/lib/i18n/generated_kcMessages/15.0.2/email.js.map +1 -1
- package/lib/i18n/generated_kcMessages/15.0.2/login.js +32 -32
- package/lib/i18n/generated_kcMessages/15.0.2/login.js.map +1 -1
- package/lib/i18n/kcMessages/login.js +1 -1
- package/lib/i18n/kcMessages/login.js.map +1 -1
- package/lib/i18n/useKcLanguageTag.js +1 -3
- package/lib/i18n/useKcLanguageTag.js.map +1 -1
- package/lib/i18n/useKcMessage.d.ts +4 -2
- package/lib/i18n/useKcMessage.js +12 -3
- package/lib/i18n/useKcMessage.js.map +1 -1
- package/lib/keycloakJsAdapter.d.ts +6 -6
- package/lib/keycloakJsAdapter.js +10 -12
- package/lib/keycloakJsAdapter.js.map +1 -1
- package/lib/tools/ReactComponent.d.ts +2 -0
- package/lib/tools/ReactComponent.js +3 -0
- package/lib/tools/ReactComponent.js.map +1 -0
- package/lib/tools/allPropertiesValuesToUndefined.js +1 -2
- package/lib/tools/allPropertiesValuesToUndefined.js.map +1 -1
- package/lib/tools/appendHead.js +16 -12
- package/lib/tools/appendHead.js.map +1 -1
- package/lib/tools/assert.js.map +1 -1
- package/lib/tools/deepAssign.js +3 -4
- package/lib/tools/deepAssign.js.map +1 -1
- package/lib/tools/deepClone.js.map +1 -1
- package/package.json +25 -5
- package/src/bin/KeycloakVersion.ts +0 -2
- package/src/bin/build-keycloak-theme/build-keycloak-theme.ts +70 -77
- package/src/bin/build-keycloak-theme/ftlValuesGlobalName.ts +1 -2
- package/src/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.ts +26 -37
- package/src/bin/build-keycloak-theme/generateDebugFiles/index.ts +1 -1
- package/src/bin/build-keycloak-theme/generateFtl/common.ftl +72 -56
- package/src/bin/build-keycloak-theme/generateFtl/generateFtl.ts +75 -95
- package/src/bin/build-keycloak-theme/generateFtl/index.ts +1 -1
- package/src/bin/build-keycloak-theme/generateJavaStackFiles.ts +38 -56
- package/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts +47 -85
- package/src/bin/build-keycloak-theme/index.ts +2 -4
- package/src/bin/build-keycloak-theme/replaceImportFromStatic.ts +34 -78
- package/src/bin/download-builtin-keycloak-theme.ts +5 -19
- package/src/bin/generate-i18n-messages.ts +13 -25
- package/src/bin/link_in_test_app.ts +9 -38
- package/src/bin/tools/crawl.ts +2 -12
- package/src/bin/tools/downloadAndUnzip.ts +6 -22
- package/src/bin/tools/getProjectRoot.ts +1 -1
- package/src/bin/tools/grant-exec-perms.ts +8 -7
- package/src/bin/tools/isInside.ts +2 -9
- package/src/bin/tools/rm.ts +21 -32
- package/src/bin/tools/transformCodebase.ts +20 -43
- package/src/lib/components/Error.tsx +3 -7
- package/src/lib/components/Info.tsx +23 -47
- package/src/lib/components/KcApp.tsx +25 -13
- package/src/lib/components/KcProps.ts +94 -92
- package/src/lib/components/Login.tsx +126 -116
- package/src/lib/components/LoginIdpLinkConfirm.tsx +38 -53
- package/src/lib/components/LoginOtp.tsx +39 -76
- package/src/lib/components/LoginResetPassword.tsx +9 -26
- package/src/lib/components/LoginUpdateProfile.tsx +104 -117
- package/src/lib/components/LoginVerifyEmail.tsx +3 -12
- package/src/lib/components/Register.tsx +76 -46
- package/src/lib/components/RegisterUserProfile.tsx +201 -0
- package/src/lib/components/Template.tsx +109 -161
- package/src/lib/components/Terms.tsx +4 -13
- package/src/lib/getKcContext/KcContextBase.ts +104 -53
- package/src/lib/getKcContext/getKcContext.ts +47 -78
- package/src/lib/getKcContext/index.ts +2 -2
- package/src/lib/getKcContext/kcContextMocks/index.ts +1 -1
- package/src/lib/getKcContext/kcContextMocks/kcContextMocks.ts +362 -241
- package/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts +1 -2
- package/src/lib/i18n/KcLanguageTag.ts +34 -45
- package/src/lib/i18n/generated_kcMessages/11.0.3/account.ts +3086 -3059
- package/src/lib/i18n/generated_kcMessages/11.0.3/admin.ts +248 -239
- package/src/lib/i18n/generated_kcMessages/11.0.3/email.ts +848 -633
- package/src/lib/i18n/generated_kcMessages/11.0.3/login.ts +4466 -4359
- package/src/lib/i18n/generated_kcMessages/15.0.2/account.ts +4247 -4202
- package/src/lib/i18n/generated_kcMessages/15.0.2/admin.ts +273 -264
- package/src/lib/i18n/generated_kcMessages/15.0.2/email.ts +997 -749
- package/src/lib/i18n/generated_kcMessages/15.0.2/login.ts +5352 -5212
- package/src/lib/i18n/kcMessages/login.ts +4 -9
- package/src/lib/i18n/useKcLanguageTag.ts +2 -16
- package/src/lib/i18n/useKcMessage.tsx +26 -15
- package/src/lib/index.ts +0 -1
- package/src/lib/keycloakJsAdapter.ts +23 -53
- package/src/lib/tools/AndByDiscriminatingKey.ts +16 -30
- package/src/lib/tools/DeepPartial.ts +1 -2
- package/src/lib/tools/ReactComponent.ts +4 -0
- package/src/lib/tools/allPropertiesValuesToUndefined.ts +1 -6
- package/src/lib/tools/appendHead.ts +28 -25
- package/src/lib/tools/assert.ts +1 -2
- package/src/lib/tools/deepAssign.ts +28 -46
- package/src/lib/tools/deepClone.ts +2 -3
@@ -1,14 +1,7 @@
|
|
1
|
-
|
2
1
|
import * as crypto from "crypto";
|
3
2
|
import { ftlValuesGlobalName } from "./ftlValuesGlobalName";
|
4
3
|
|
5
|
-
export function replaceImportsFromStaticInJsCode(
|
6
|
-
params: {
|
7
|
-
jsCode: string;
|
8
|
-
urlOrigin: undefined | string;
|
9
|
-
}
|
10
|
-
): { fixedJsCode: string; } {
|
11
|
-
|
4
|
+
export function replaceImportsFromStaticInJsCode(params: { jsCode: string; urlOrigin: undefined | string }): { fixedJsCode: string } {
|
12
5
|
/*
|
13
6
|
NOTE:
|
14
7
|
|
@@ -23,114 +16,77 @@ export function replaceImportsFromStaticInJsCode(
|
|
23
16
|
|
24
17
|
const { jsCode, urlOrigin } = params;
|
25
18
|
|
26
|
-
const fixedJsCode =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
(...[, group1, group2, group3]) =>
|
38
|
-
urlOrigin === undefined ?
|
39
|
-
`".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group3},` :
|
40
|
-
`".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${urlOrigin}" : "") + ${group2} + ${group3},`
|
41
|
-
);
|
19
|
+
const fixedJsCode = jsCode
|
20
|
+
.replace(/([a-z]+\.[a-z]+)\+"static\//g, (...[, group]) =>
|
21
|
+
urlOrigin === undefined
|
22
|
+
? `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`
|
23
|
+
: `("${ftlValuesGlobalName}" in window ? "${urlOrigin}" : "") + ${group} + "static/`,
|
24
|
+
)
|
25
|
+
.replace(/".chunk.css",([a-z])+=([a-z]+\.[a-z]+)\+([a-z]+),/, (...[, group1, group2, group3]) =>
|
26
|
+
urlOrigin === undefined
|
27
|
+
? `".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group3},`
|
28
|
+
: `".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${urlOrigin}" : "") + ${group2} + ${group3},`,
|
29
|
+
);
|
42
30
|
|
43
31
|
return { fixedJsCode };
|
44
|
-
|
45
32
|
}
|
46
33
|
|
47
|
-
export function replaceImportsInInlineCssCode(
|
48
|
-
|
49
|
-
|
50
|
-
urlPathname: string;
|
51
|
-
urlOrigin: undefined | string;
|
52
|
-
}
|
53
|
-
): { fixedCssCode: string; } {
|
54
|
-
|
34
|
+
export function replaceImportsInInlineCssCode(params: { cssCode: string; urlPathname: string; urlOrigin: undefined | string }): {
|
35
|
+
fixedCssCode: string;
|
36
|
+
} {
|
55
37
|
const { cssCode, urlPathname, urlOrigin } = params;
|
56
38
|
|
57
39
|
const fixedCssCode = cssCode.replace(
|
58
|
-
urlPathname === "/" ?
|
59
|
-
|
60
|
-
new RegExp(`url\\(${urlPathname}([^)]+)\\)`, "g"),
|
61
|
-
(...[, group]) => `url(${urlOrigin === undefined ?
|
62
|
-
"${url.resourcesPath}/build/" + group :
|
63
|
-
params.urlOrigin + urlPathname + group})`
|
40
|
+
urlPathname === "/" ? /url\(\/([^/][^)]+)\)/g : new RegExp(`url\\(${urlPathname}([^)]+)\\)`, "g"),
|
41
|
+
(...[, group]) => `url(${urlOrigin === undefined ? "${url.resourcesPath}/build/" + group : params.urlOrigin + urlPathname + group})`,
|
64
42
|
);
|
65
43
|
|
66
44
|
return { fixedCssCode };
|
67
|
-
|
68
45
|
}
|
69
46
|
|
70
|
-
export function replaceImportsInCssCode(
|
71
|
-
params: {
|
72
|
-
cssCode: string;
|
73
|
-
}
|
74
|
-
): {
|
47
|
+
export function replaceImportsInCssCode(params: { cssCode: string }): {
|
75
48
|
fixedCssCode: string;
|
76
49
|
cssGlobalsToDefine: Record<string, string>;
|
77
50
|
} {
|
78
|
-
|
79
51
|
const { cssCode } = params;
|
80
52
|
|
81
53
|
const cssGlobalsToDefine: Record<string, string> = {};
|
82
54
|
|
83
|
-
new Set(cssCode.match(/url\(\/[^/][^)]+\)[^;}]*/g) ?? [])
|
84
|
-
.
|
85
|
-
|
86
|
-
"url" + crypto
|
87
|
-
.createHash("sha256")
|
88
|
-
.update(match)
|
89
|
-
.digest("hex")
|
90
|
-
.substring(0, 15)
|
91
|
-
] = match
|
92
|
-
);
|
55
|
+
new Set(cssCode.match(/url\(\/[^/][^)]+\)[^;}]*/g) ?? []).forEach(
|
56
|
+
match => (cssGlobalsToDefine["url" + crypto.createHash("sha256").update(match).digest("hex").substring(0, 15)] = match),
|
57
|
+
);
|
93
58
|
|
94
59
|
let fixedCssCode = cssCode;
|
95
60
|
|
96
61
|
Object.keys(cssGlobalsToDefine).forEach(
|
97
62
|
cssVariableName =>
|
98
63
|
//NOTE: split/join pattern ~ replace all
|
99
|
-
fixedCssCode =
|
100
|
-
fixedCssCode.split(cssGlobalsToDefine[cssVariableName])
|
101
|
-
.join(`var(--${cssVariableName})`)
|
64
|
+
(fixedCssCode = fixedCssCode.split(cssGlobalsToDefine[cssVariableName]).join(`var(--${cssVariableName})`)),
|
102
65
|
);
|
103
66
|
|
104
67
|
return { fixedCssCode, cssGlobalsToDefine };
|
105
|
-
|
106
68
|
}
|
107
69
|
|
108
|
-
export function generateCssCodeToDefineGlobals(
|
109
|
-
params: {
|
110
|
-
cssGlobalsToDefine: Record<string, string>;
|
111
|
-
urlPathname: string;
|
112
|
-
}
|
113
|
-
): {
|
70
|
+
export function generateCssCodeToDefineGlobals(params: { cssGlobalsToDefine: Record<string, string>; urlPathname: string }): {
|
114
71
|
cssCodeToPrependInHead: string;
|
115
72
|
} {
|
116
|
-
|
117
73
|
const { cssGlobalsToDefine, urlPathname } = params;
|
118
74
|
|
119
75
|
return {
|
120
76
|
"cssCodeToPrependInHead": [
|
121
77
|
":root {",
|
122
78
|
...Object.keys(cssGlobalsToDefine)
|
123
|
-
.map(cssVariableName =>
|
124
|
-
|
125
|
-
|
126
|
-
.replace(
|
127
|
-
|
79
|
+
.map(cssVariableName =>
|
80
|
+
[
|
81
|
+
`--${cssVariableName}:`,
|
82
|
+
cssGlobalsToDefine[cssVariableName].replace(
|
83
|
+
new RegExp(`url\\(${urlPathname.replace(/\//g, "\\/")}`, "g"),
|
84
|
+
"url(${url.resourcesPath}/build/",
|
85
|
+
),
|
86
|
+
].join(" "),
|
87
|
+
)
|
128
88
|
.map(line => ` ${line};`),
|
129
|
-
"}"
|
130
|
-
].join("\n")
|
89
|
+
"}",
|
90
|
+
].join("\n"),
|
131
91
|
};
|
132
|
-
|
133
92
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
@@ -2,42 +2,30 @@
|
|
2
2
|
|
3
3
|
import { keycloakThemeBuildingDirPath } from "./build-keycloak-theme";
|
4
4
|
import { join as pathJoin } from "path";
|
5
|
-
import { downloadAndUnzip } from "./tools/downloadAndUnzip"
|
5
|
+
import { downloadAndUnzip } from "./tools/downloadAndUnzip";
|
6
6
|
import type { KeycloakVersion } from "./KeycloakVersion";
|
7
7
|
|
8
|
-
export function downloadBuiltinKeycloakTheme(
|
9
|
-
params: {
|
10
|
-
keycloakVersion: KeycloakVersion;
|
11
|
-
destDirPath: string;
|
12
|
-
}
|
13
|
-
) {
|
14
|
-
|
8
|
+
export function downloadBuiltinKeycloakTheme(params: { keycloakVersion: KeycloakVersion; destDirPath: string }) {
|
15
9
|
const { keycloakVersion, destDirPath } = params;
|
16
10
|
|
17
11
|
for (const ext of ["", "-community"]) {
|
18
|
-
|
19
12
|
downloadAndUnzip({
|
20
13
|
"destDirPath": destDirPath,
|
21
14
|
"url": `https://github.com/keycloak/keycloak/archive/refs/tags/${keycloakVersion}.zip`,
|
22
|
-
"pathOfDirToExtractInArchive": `keycloak-${keycloakVersion}/themes/src/main/resources${ext}/theme
|
15
|
+
"pathOfDirToExtractInArchive": `keycloak-${keycloakVersion}/themes/src/main/resources${ext}/theme`,
|
23
16
|
});
|
24
|
-
|
25
17
|
}
|
26
|
-
|
27
18
|
}
|
28
19
|
|
29
20
|
if (require.main === module) {
|
30
|
-
|
31
21
|
const keycloakVersion = (() => {
|
32
|
-
|
33
|
-
const keycloakVersion = process.argv[2] as (KeycloakVersion | undefined);
|
22
|
+
const keycloakVersion = process.argv[2] as KeycloakVersion | undefined;
|
34
23
|
|
35
24
|
if (keycloakVersion === undefined) {
|
36
25
|
return "15.0.2";
|
37
26
|
}
|
38
27
|
|
39
28
|
return keycloakVersion;
|
40
|
-
|
41
29
|
})();
|
42
30
|
|
43
31
|
const destDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme");
|
@@ -46,8 +34,6 @@ if (require.main === module) {
|
|
46
34
|
|
47
35
|
downloadBuiltinKeycloakTheme({
|
48
36
|
keycloakVersion,
|
49
|
-
destDirPath
|
37
|
+
destDirPath,
|
50
38
|
});
|
51
|
-
|
52
39
|
}
|
53
|
-
|
@@ -11,7 +11,6 @@ import { keycloakVersions } from "./KeycloakVersion";
|
|
11
11
|
const propertiesParser = require("properties-parser");
|
12
12
|
|
13
13
|
for (const keycloakVersion of keycloakVersions) {
|
14
|
-
|
15
14
|
console.log({ keycloakVersion });
|
16
15
|
|
17
16
|
const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44");
|
@@ -20,7 +19,7 @@ for (const keycloakVersion of keycloakVersions) {
|
|
20
19
|
|
21
20
|
downloadBuiltinKeycloakTheme({
|
22
21
|
keycloakVersion,
|
23
|
-
"destDirPath": tmpDirPath
|
22
|
+
"destDirPath": tmpDirPath,
|
24
23
|
});
|
25
24
|
|
26
25
|
type Dictionary = { [idiomId: string]: string };
|
@@ -28,11 +27,9 @@ for (const keycloakVersion of keycloakVersions) {
|
|
28
27
|
const record: { [typeOfPage: string]: { [language: string]: Dictionary } } = {};
|
29
28
|
|
30
29
|
{
|
31
|
-
|
32
30
|
const baseThemeDirPath = pathJoin(tmpDirPath, "base");
|
33
31
|
|
34
32
|
crawl(baseThemeDirPath).forEach(filePath => {
|
35
|
-
|
36
33
|
const match = filePath.match(/^([^/]+)\/messages\/messages_([^.]+)\.properties$/);
|
37
34
|
|
38
35
|
if (match === null) {
|
@@ -41,20 +38,12 @@ for (const keycloakVersion of keycloakVersions) {
|
|
41
38
|
|
42
39
|
const [, typeOfPage, language] = match;
|
43
40
|
|
44
|
-
(record[typeOfPage] ??= {})[language.replace(/_/g, "-")] =
|
45
|
-
Object.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
pathJoin(baseThemeDirPath, filePath)
|
50
|
-
)
|
51
|
-
.toString("utf8")
|
52
|
-
)
|
53
|
-
).map(([key, value]: any) => [key, value.replace(/''/g, "'")])
|
54
|
-
);
|
55
|
-
|
41
|
+
(record[typeOfPage] ??= {})[language.replace(/_/g, "-")] = Object.fromEntries(
|
42
|
+
Object.entries(propertiesParser.parse(fs.readFileSync(pathJoin(baseThemeDirPath, filePath)).toString("utf8"))).map(
|
43
|
+
([key, value]: any) => [key, value.replace(/''/g, "'")],
|
44
|
+
),
|
45
|
+
);
|
56
46
|
});
|
57
|
-
|
58
47
|
}
|
59
48
|
|
60
49
|
rm_r(tmpDirPath);
|
@@ -64,7 +53,6 @@ for (const keycloakVersion of keycloakVersions) {
|
|
64
53
|
fs.mkdirSync(targetDirPath, { "recursive": true });
|
65
54
|
|
66
55
|
Object.keys(record).forEach(pageType => {
|
67
|
-
|
68
56
|
const filePath = pathJoin(targetDirPath, `${pageType}.ts`);
|
69
57
|
|
70
58
|
fs.writeFileSync(
|
@@ -72,16 +60,16 @@ for (const keycloakVersion of keycloakVersions) {
|
|
72
60
|
Buffer.from(
|
73
61
|
[
|
74
62
|
`//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`,
|
75
|
-
|
76
|
-
|
77
|
-
|
63
|
+
"//PLEASE DO NOT EDIT MANUALLY",
|
64
|
+
"",
|
65
|
+
"/* spell-checker: disable */",
|
78
66
|
`export const kcMessages= ${JSON.stringify(record[pageType], null, 2)};`,
|
79
|
-
|
80
|
-
].join("\n"),
|
67
|
+
"/* spell-checker: enable */",
|
68
|
+
].join("\n"),
|
69
|
+
"utf8",
|
70
|
+
),
|
81
71
|
);
|
82
72
|
|
83
73
|
console.log(`${filePath} wrote`);
|
84
|
-
|
85
74
|
});
|
86
|
-
|
87
75
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
import { execSync } from "child_process";
|
3
2
|
import { join as pathJoin, relative as pathRelative } from "path";
|
4
3
|
import * as fs from "fs";
|
@@ -10,11 +9,7 @@ fs.writeFileSync(
|
|
10
9
|
Buffer.from(
|
11
10
|
JSON.stringify(
|
12
11
|
(() => {
|
13
|
-
const packageJsonParsed = JSON.parse(
|
14
|
-
fs
|
15
|
-
.readFileSync(pathJoin(keycloakifyDirPath, "package.json"))
|
16
|
-
.toString("utf8"),
|
17
|
-
);
|
12
|
+
const packageJsonParsed = JSON.parse(fs.readFileSync(pathJoin(keycloakifyDirPath, "package.json")).toString("utf8"));
|
18
13
|
|
19
14
|
return {
|
20
15
|
...packageJsonParsed,
|
@@ -37,17 +32,8 @@ const commonThirdPartyDeps = (() => {
|
|
37
32
|
...namespaceModuleNames
|
38
33
|
.map(namespaceModuleName =>
|
39
34
|
fs
|
40
|
-
.readdirSync(
|
41
|
-
|
42
|
-
keycloakifyDirPath,
|
43
|
-
"node_modules",
|
44
|
-
namespaceModuleName,
|
45
|
-
),
|
46
|
-
)
|
47
|
-
.map(
|
48
|
-
submoduleName =>
|
49
|
-
`${namespaceModuleName}/${submoduleName}`,
|
50
|
-
),
|
35
|
+
.readdirSync(pathJoin(keycloakifyDirPath, "node_modules", namespaceModuleName))
|
36
|
+
.map(submoduleName => `${namespaceModuleName}/${submoduleName}`),
|
51
37
|
)
|
52
38
|
.reduce((prev, curr) => [...prev, ...curr], []),
|
53
39
|
...standaloneModuleNames,
|
@@ -56,18 +42,12 @@ const commonThirdPartyDeps = (() => {
|
|
56
42
|
|
57
43
|
const yarnHomeDirPath = pathJoin(keycloakifyDirPath, ".yarn_home");
|
58
44
|
|
59
|
-
execSync(
|
60
|
-
["rm -rf", "mkdir"].map(cmd => `${cmd} ${yarnHomeDirPath}`).join(" && "),
|
61
|
-
);
|
45
|
+
execSync(["rm -rf", "mkdir"].map(cmd => `${cmd} ${yarnHomeDirPath}`).join(" && "));
|
62
46
|
|
63
47
|
const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
64
48
|
const { targetModuleName, cwd } = params;
|
65
49
|
|
66
|
-
const cmd = [
|
67
|
-
"yarn",
|
68
|
-
"link",
|
69
|
-
...(targetModuleName !== undefined ? [targetModuleName] : []),
|
70
|
-
].join(" ");
|
50
|
+
const cmd = ["yarn", "link", ...(targetModuleName !== undefined ? [targetModuleName] : [])].join(" ");
|
71
51
|
|
72
52
|
console.log(`$ cd ${pathRelative(keycloakifyDirPath, cwd) || "."} && ${cmd}`);
|
73
53
|
|
@@ -82,12 +62,9 @@ const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
|
82
62
|
|
83
63
|
const testAppNames = ["keycloakify-demo-app"] as const;
|
84
64
|
|
85
|
-
const getTestAppPath = (testAppName: typeof testAppNames[number]) =>
|
86
|
-
pathJoin(keycloakifyDirPath, "..", testAppName);
|
65
|
+
const getTestAppPath = (testAppName: typeof testAppNames[number]) => pathJoin(keycloakifyDirPath, "..", testAppName);
|
87
66
|
|
88
|
-
testAppNames.forEach(testAppName =>
|
89
|
-
execSync("yarn install", { "cwd": getTestAppPath(testAppName) }),
|
90
|
-
);
|
67
|
+
testAppNames.forEach(testAppName => execSync("yarn install", { "cwd": getTestAppPath(testAppName) }));
|
91
68
|
|
92
69
|
console.log("=== Linking common dependencies ===");
|
93
70
|
|
@@ -100,13 +77,7 @@ commonThirdPartyDeps.forEach(commonThirdPartyDep => {
|
|
100
77
|
console.log(`${current}/${total} ${commonThirdPartyDep}`);
|
101
78
|
|
102
79
|
const localInstallPath = pathJoin(
|
103
|
-
...[
|
104
|
-
keycloakifyDirPath,
|
105
|
-
"node_modules",
|
106
|
-
...(commonThirdPartyDep.startsWith("@")
|
107
|
-
? commonThirdPartyDep.split("/")
|
108
|
-
: [commonThirdPartyDep]),
|
109
|
-
],
|
80
|
+
...[keycloakifyDirPath, "node_modules", ...(commonThirdPartyDep.startsWith("@") ? commonThirdPartyDep.split("/") : [commonThirdPartyDep])],
|
110
81
|
);
|
111
82
|
|
112
83
|
execYarnLink({ "cwd": localInstallPath });
|
@@ -128,4 +99,4 @@ testAppNames.forEach(testAppName =>
|
|
128
99
|
"cwd": getTestAppPath(testAppName),
|
129
100
|
"targetModuleName": "keycloakify",
|
130
101
|
}),
|
131
|
-
);
|
102
|
+
);
|
package/src/bin/tools/crawl.ts
CHANGED
@@ -3,35 +3,25 @@ import * as path from "path";
|
|
3
3
|
|
4
4
|
/** List all files in a given directory return paths relative to the dir_path */
|
5
5
|
export const crawl = (() => {
|
6
|
-
|
7
6
|
const crawlRec = (dir_path: string, paths: string[]) => {
|
8
|
-
|
9
7
|
for (const file_name of fs.readdirSync(dir_path)) {
|
10
|
-
|
11
8
|
const file_path = path.join(dir_path, file_name);
|
12
9
|
|
13
10
|
if (fs.lstatSync(file_path).isDirectory()) {
|
14
|
-
|
15
11
|
crawlRec(file_path, paths);
|
16
12
|
|
17
13
|
continue;
|
18
|
-
|
19
14
|
}
|
20
15
|
|
21
16
|
paths.push(file_path);
|
22
|
-
|
23
17
|
}
|
24
|
-
|
25
18
|
};
|
26
19
|
|
27
20
|
return function crawl(dir_path: string): string[] {
|
28
|
-
|
29
21
|
const paths: string[] = [];
|
30
22
|
|
31
23
|
crawlRec(dir_path, paths);
|
32
24
|
|
33
25
|
return paths.map(file_path => path.relative(dir_path, file_path));
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
})();
|
26
|
+
};
|
27
|
+
})();
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
import { basename as pathBasename, join as pathJoin } from "path";
|
3
2
|
import { execSync } from "child_process";
|
4
3
|
import fs from "fs";
|
@@ -6,14 +5,7 @@ import { transformCodebase } from "../tools/transformCodebase";
|
|
6
5
|
import { rm_rf, rm, rm_r } from "./rm";
|
7
6
|
|
8
7
|
/** assert url ends with .zip */
|
9
|
-
export function downloadAndUnzip(
|
10
|
-
params: {
|
11
|
-
url: string;
|
12
|
-
destDirPath: string;
|
13
|
-
pathOfDirToExtractInArchive?: string;
|
14
|
-
}
|
15
|
-
) {
|
16
|
-
|
8
|
+
export function downloadAndUnzip(params: { url: string; destDirPath: string; pathOfDirToExtractInArchive?: string }) {
|
17
9
|
const { url, destDirPath, pathOfDirToExtractInArchive } = params;
|
18
10
|
|
19
11
|
const tmpDirPath = pathJoin(destDirPath, "..", "tmp_xxKdOxnEdx");
|
@@ -24,24 +16,16 @@ export function downloadAndUnzip(
|
|
24
16
|
|
25
17
|
execSync(`wget ${url}`, { "cwd": tmpDirPath });
|
26
18
|
|
27
|
-
execSync(
|
28
|
-
|
29
|
-
|
30
|
-
"" : ` "${pathOfDirToExtractInArchive}/*"`
|
31
|
-
}`,
|
32
|
-
{ "cwd": tmpDirPath }
|
33
|
-
);
|
19
|
+
execSync(`unzip ${pathBasename(url)}${pathOfDirToExtractInArchive === undefined ? "" : ` "${pathOfDirToExtractInArchive}/*"`}`, {
|
20
|
+
"cwd": tmpDirPath,
|
21
|
+
});
|
34
22
|
|
35
23
|
rm(pathBasename(url), { "cwd": tmpDirPath });
|
36
24
|
|
37
25
|
transformCodebase({
|
38
|
-
"srcDirPath": pathOfDirToExtractInArchive === undefined ?
|
39
|
-
tmpDirPath :
|
40
|
-
pathJoin(tmpDirPath, pathOfDirToExtractInArchive)
|
41
|
-
,
|
26
|
+
"srcDirPath": pathOfDirToExtractInArchive === undefined ? tmpDirPath : pathJoin(tmpDirPath, pathOfDirToExtractInArchive),
|
42
27
|
destDirPath,
|
43
28
|
});
|
44
29
|
|
45
30
|
rm_r(tmpDirPath);
|
46
|
-
|
47
|
-
}
|
31
|
+
}
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import { getProjectRoot } from "./getProjectRoot";
|
2
|
+
import { join as pathJoin } from "path";
|
3
|
+
import child_process from "child_process";
|
1
4
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
.forEach(([, scriptPath]) => child_process.execSync(`chmod +x ${scriptPath}`, { "cwd": getProjectRoot() }));
|
8
|
-
|
5
|
+
Object.entries<string>(require(pathJoin(getProjectRoot(), "package.json"))["bin"]).forEach(([, scriptPath]) =>
|
6
|
+
child_process.execSync(`chmod +x ${scriptPath}`, {
|
7
|
+
"cwd": getProjectRoot(),
|
8
|
+
}),
|
9
|
+
);
|
@@ -1,14 +1,7 @@
|
|
1
1
|
import { relative as pathRelative } from "path";
|
2
2
|
|
3
|
-
export function isInside(
|
4
|
-
params: {
|
5
|
-
dirPath: string;
|
6
|
-
filePath: string;
|
7
|
-
}
|
8
|
-
) {
|
9
|
-
|
3
|
+
export function isInside(params: { dirPath: string; filePath: string }) {
|
10
4
|
const { dirPath, filePath } = params;
|
11
5
|
|
12
6
|
return !pathRelative(dirPath, filePath).startsWith("..");
|
13
|
-
|
14
|
-
}
|
7
|
+
}
|
package/src/bin/tools/rm.ts
CHANGED
@@ -1,42 +1,31 @@
|
|
1
|
-
|
2
1
|
import { execSync } from "child_process";
|
3
2
|
|
4
|
-
function rmInternal(
|
5
|
-
|
6
|
-
pathToRemove: string;
|
7
|
-
args: string | undefined;
|
8
|
-
cwd: string | undefined;
|
9
|
-
}
|
10
|
-
) {
|
11
|
-
|
12
|
-
const { pathToRemove, args, cwd } = params;
|
3
|
+
function rmInternal(params: { pathToRemove: string; args: string | undefined; cwd: string | undefined }) {
|
4
|
+
const { pathToRemove, args, cwd } = params;
|
13
5
|
|
14
|
-
|
15
|
-
`rm ${args ? `-${args} ` : ""}${pathToRemove.replace(/\ /g, "\\ ")}`,
|
16
|
-
cwd !== undefined ? { cwd } : undefined
|
17
|
-
);
|
6
|
+
execSync(`rm ${args ? `-${args} ` : ""}${pathToRemove.replace(/ /g, "\\ ")}`, cwd !== undefined ? { cwd } : undefined);
|
18
7
|
}
|
19
8
|
|
20
|
-
export function rm(pathToRemove: string, options?: { cwd: string
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
export function rm(pathToRemove: string, options?: { cwd: string }) {
|
10
|
+
rmInternal({
|
11
|
+
pathToRemove,
|
12
|
+
"args": undefined,
|
13
|
+
"cwd": options?.cwd,
|
14
|
+
});
|
26
15
|
}
|
27
16
|
|
28
|
-
export function rm_r(pathToRemove: string, options?: { cwd: string
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
export function rm_r(pathToRemove: string, options?: { cwd: string }) {
|
18
|
+
rmInternal({
|
19
|
+
pathToRemove,
|
20
|
+
"args": "r",
|
21
|
+
"cwd": options?.cwd,
|
22
|
+
});
|
34
23
|
}
|
35
24
|
|
36
|
-
export function rm_rf(pathToRemove: string, options?: { cwd: string
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
export function rm_rf(pathToRemove: string, options?: { cwd: string }) {
|
26
|
+
rmInternal({
|
27
|
+
pathToRemove,
|
28
|
+
"args": "rf",
|
29
|
+
"cwd": options?.cwd,
|
30
|
+
});
|
42
31
|
}
|