keycloakify 9.4.0-rc.0 → 9.4.0-rc.10
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.d.ts +5 -0
- package/PUBLIC_URL.js +15 -0
- package/PUBLIC_URL.js.map +1 -0
- package/account/kcContext/createGetKcContext.js +7 -4
- package/account/kcContext/createGetKcContext.js.map +1 -1
- package/account/kcContext/kcContextMocks.js +3 -5
- package/account/kcContext/kcContextMocks.js.map +1 -1
- package/bin/copy-keycloak-resources-to-public.js +1 -4
- package/bin/copy-keycloak-resources-to-public.js.map +1 -1
- package/bin/download-builtin-keycloak-theme.js +109 -55
- package/bin/download-builtin-keycloak-theme.js.map +1 -1
- package/bin/initialize-email-theme.js +2 -4
- package/bin/initialize-email-theme.js.map +1 -1
- package/bin/keycloakify/buildOptions/buildOptions.d.ts +0 -1
- package/bin/keycloakify/buildOptions/buildOptions.js +14 -5
- package/bin/keycloakify/buildOptions/buildOptions.js.map +1 -1
- package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +8 -0
- package/bin/keycloakify/generateFtl/generateFtl.js +2 -1
- package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
- package/bin/keycloakify/generateStartKeycloakTestingContainer.js +0 -1
- package/bin/keycloakify/generateStartKeycloakTestingContainer.js.map +1 -1
- package/bin/keycloakify/keycloakify.js +6 -6
- package/bin/keycloakify/keycloakify.js.map +1 -1
- package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js +0 -5
- package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js.map +1 -1
- package/bin/tools/downloadAndUnzip.js +108 -24
- package/bin/tools/downloadAndUnzip.js.map +1 -1
- package/bin/tools/transformCodebase.js +5 -5
- package/bin/tools/transformCodebase.js.map +1 -1
- package/lib/BASE_URL.d.ts +10 -0
- package/lib/BASE_URL.js +38 -0
- package/lib/BASE_URL.js.map +1 -0
- package/lib/isStorybook.d.ts +1 -0
- package/lib/isStorybook.js +3 -0
- package/lib/isStorybook.js.map +1 -0
- package/lib/keycloakJsAdapter.d.ts +4 -0
- package/lib/keycloakJsAdapter.js +4 -0
- package/lib/keycloakJsAdapter.js.map +1 -1
- package/login/kcContext/createGetKcContext.js +7 -4
- package/login/kcContext/createGetKcContext.js.map +1 -1
- package/login/kcContext/kcContextMocks.js +3 -5
- package/login/kcContext/kcContextMocks.js.map +1 -1
- package/package.json +16 -6
- package/src/PUBLIC_URL.ts +21 -0
- package/src/account/kcContext/createGetKcContext.ts +8 -5
- package/src/account/kcContext/kcContextMocks.ts +3 -5
- package/src/bin/copy-keycloak-resources-to-public.ts +1 -6
- package/src/bin/download-builtin-keycloak-theme.ts +110 -57
- package/src/bin/initialize-email-theme.ts +1 -4
- package/src/bin/keycloakify/buildOptions/buildOptions.ts +18 -7
- package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +8 -0
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -2
- package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +0 -1
- package/src/bin/keycloakify/keycloakify.ts +8 -6
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +0 -14
- package/src/bin/tools/downloadAndUnzip.ts +77 -15
- package/src/bin/tools/transformCodebase.ts +6 -5
- package/src/lib/BASE_URL.ts +44 -0
- package/src/lib/isStorybook.ts +3 -0
- package/src/lib/keycloakJsAdapter.ts +4 -0
- package/src/login/kcContext/createGetKcContext.ts +8 -5
- package/src/login/kcContext/kcContextMocks.ts +3 -5
- package/bin/tools/pathJoin.d.ts +0 -1
- package/bin/tools/pathJoin.js +0 -15
- package/bin/tools/pathJoin.js.map +0 -1
- package/src/bin/tools/pathJoin.ts +0 -6
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "keycloakify",
|
3
|
-
"version": "9.4.0-rc.
|
3
|
+
"version": "9.4.0-rc.10",
|
4
4
|
"description": "Create Keycloak themes using React",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -28,6 +28,7 @@
|
|
28
28
|
"author": "u/garronej",
|
29
29
|
"license": "MIT",
|
30
30
|
"files": [
|
31
|
+
"src/PUBLIC_URL.ts",
|
31
32
|
"src/account/Fallback.tsx",
|
32
33
|
"src/account/Template.tsx",
|
33
34
|
"src/account/TemplateProps.ts",
|
@@ -122,13 +123,14 @@
|
|
122
123
|
"src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts",
|
123
124
|
"src/bin/tools/octokit-addons/listTags.ts",
|
124
125
|
"src/bin/tools/partitionPromiseSettledResults.ts",
|
125
|
-
"src/bin/tools/pathJoin.ts",
|
126
126
|
"src/bin/tools/tee.ts",
|
127
127
|
"src/bin/tools/transformCodebase.ts",
|
128
128
|
"src/bin/tools/trimIndent.ts",
|
129
129
|
"src/bin/tools/unzip.ts",
|
130
130
|
"src/bin/tsconfig.json",
|
131
131
|
"src/index.ts",
|
132
|
+
"src/lib/BASE_URL.ts",
|
133
|
+
"src/lib/isStorybook.ts",
|
132
134
|
"src/lib/keycloakJsAdapter.ts",
|
133
135
|
"src/lib/useGetClassName.ts",
|
134
136
|
"src/lib/usePrepareTemplate.ts",
|
@@ -223,6 +225,9 @@
|
|
223
225
|
"src/vite-plugin/index.ts",
|
224
226
|
"src/vite-plugin/tsconfig.json",
|
225
227
|
"src/vite-plugin/vite-plugin.ts",
|
228
|
+
"PUBLIC_URL.d.ts",
|
229
|
+
"PUBLIC_URL.js",
|
230
|
+
"PUBLIC_URL.js.map",
|
226
231
|
"account/Fallback.d.ts",
|
227
232
|
"account/Fallback.js",
|
228
233
|
"account/Fallback.js.map",
|
@@ -503,9 +508,6 @@
|
|
503
508
|
"bin/tools/partitionPromiseSettledResults.d.ts",
|
504
509
|
"bin/tools/partitionPromiseSettledResults.js",
|
505
510
|
"bin/tools/partitionPromiseSettledResults.js.map",
|
506
|
-
"bin/tools/pathJoin.d.ts",
|
507
|
-
"bin/tools/pathJoin.js",
|
508
|
-
"bin/tools/pathJoin.js.map",
|
509
511
|
"bin/tools/tee.d.ts",
|
510
512
|
"bin/tools/tee.js",
|
511
513
|
"bin/tools/tee.js.map",
|
@@ -521,6 +523,12 @@
|
|
521
523
|
"index.d.ts",
|
522
524
|
"index.js",
|
523
525
|
"index.js.map",
|
526
|
+
"lib/BASE_URL.d.ts",
|
527
|
+
"lib/BASE_URL.js",
|
528
|
+
"lib/BASE_URL.js.map",
|
529
|
+
"lib/isStorybook.d.ts",
|
530
|
+
"lib/isStorybook.js",
|
531
|
+
"lib/isStorybook.js.map",
|
524
532
|
"lib/keycloakJsAdapter.d.ts",
|
525
533
|
"lib/keycloakJsAdapter.js",
|
526
534
|
"lib/keycloakJsAdapter.js.map",
|
@@ -740,6 +748,7 @@
|
|
740
748
|
"login/pages/shared/UserProfileFormFields.d.ts",
|
741
749
|
"login/pages/shared/UserProfileFormFields.js",
|
742
750
|
"login/pages/shared/UserProfileFormFields.js.map",
|
751
|
+
"src/PUBLIC_URL.ts",
|
743
752
|
"src/account/Fallback.tsx",
|
744
753
|
"src/account/Template.tsx",
|
745
754
|
"src/account/TemplateProps.ts",
|
@@ -834,13 +843,14 @@
|
|
834
843
|
"src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts",
|
835
844
|
"src/bin/tools/octokit-addons/listTags.ts",
|
836
845
|
"src/bin/tools/partitionPromiseSettledResults.ts",
|
837
|
-
"src/bin/tools/pathJoin.ts",
|
838
846
|
"src/bin/tools/tee.ts",
|
839
847
|
"src/bin/tools/transformCodebase.ts",
|
840
848
|
"src/bin/tools/trimIndent.ts",
|
841
849
|
"src/bin/tools/unzip.ts",
|
842
850
|
"src/bin/tsconfig.json",
|
843
851
|
"src/index.ts",
|
852
|
+
"src/lib/BASE_URL.ts",
|
853
|
+
"src/lib/isStorybook.ts",
|
844
854
|
"src/lib/keycloakJsAdapter.ts",
|
845
855
|
"src/lib/useGetClassName.ts",
|
846
856
|
"src/lib/usePrepareTemplate.ts",
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir } from "keycloakify/bin/constants";
|
2
|
+
import { assert } from "tsafe/assert";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* This is an equivalent of process.env.PUBLIC_URL thay you can use in Webpack projects.
|
6
|
+
* This works both in your main app and in your Keycloak theme.
|
7
|
+
*/
|
8
|
+
export const PUBLIC_URL = (() => {
|
9
|
+
const kcContext = (window as any)[nameOfTheGlobal];
|
10
|
+
|
11
|
+
if (kcContext === undefined || process.env.NODE_ENV === "development") {
|
12
|
+
assert(
|
13
|
+
process.env.PUBLIC_URL !== undefined,
|
14
|
+
`If you use keycloakify/PUBLIC_URL you should be in Webpack and thus process.env.PUBLIC_URL should be defined`
|
15
|
+
);
|
16
|
+
|
17
|
+
return process.env.PUBLIC_URL;
|
18
|
+
}
|
19
|
+
|
20
|
+
return `${kcContext.url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}`;
|
21
|
+
})();
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
2
2
|
import { deepAssign } from "keycloakify/tools/deepAssign";
|
3
|
+
import { isStorybook } from "keycloakify/lib/isStorybook";
|
3
4
|
import type { ExtendKcContext } from "./getKcContextFromWindow";
|
4
5
|
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
5
|
-
import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
6
6
|
import { symToStr } from "tsafe/symToStr";
|
7
|
-
import { resources_common } from "keycloakify/bin/constants";
|
8
7
|
import { kcContextMocks, kcContextCommonMock } from "keycloakify/account/kcContext/kcContextMocks";
|
9
8
|
|
10
9
|
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
@@ -27,7 +26,13 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|
27
26
|
if (mockPageId !== undefined && realKcContext === undefined) {
|
28
27
|
//TODO maybe trow if no mock fo custom page
|
29
28
|
|
30
|
-
|
29
|
+
warn_that_mock_is_enbaled: {
|
30
|
+
if (isStorybook) {
|
31
|
+
break warn_that_mock_is_enbaled;
|
32
|
+
}
|
33
|
+
|
34
|
+
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
35
|
+
}
|
31
36
|
|
32
37
|
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
33
38
|
|
@@ -88,8 +93,6 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|
88
93
|
return { "kcContext": undefined as any };
|
89
94
|
}
|
90
95
|
|
91
|
-
realKcContext.url.resourcesCommonPath = pathJoin(realKcContext.url.resourcesPath, resources_common);
|
92
|
-
|
93
96
|
return { "kcContext": realKcContext as any };
|
94
97
|
}
|
95
98
|
|
@@ -1,12 +1,10 @@
|
|
1
1
|
import "minimal-polyfills/Object.fromEntries";
|
2
2
|
import { resources_common, keycloak_resources } from "keycloakify/bin/constants";
|
3
|
-
import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
4
3
|
import { id } from "tsafe/id";
|
5
4
|
import type { KcContext } from "./KcContext";
|
5
|
+
import { BASE_URL } from "keycloakify/lib/BASE_URL";
|
6
6
|
|
7
|
-
const
|
8
|
-
|
9
|
-
const resourcesPath = pathJoin(PUBLIC_URL, keycloak_resources, "account", "resources");
|
7
|
+
const resourcesPath = `${BASE_URL}${keycloak_resources}/account/resources`;
|
10
8
|
|
11
9
|
export const kcContextCommonMock: KcContext.Common = {
|
12
10
|
"themeVersion": "0.0.0",
|
@@ -15,7 +13,7 @@ export const kcContextCommonMock: KcContext.Common = {
|
|
15
13
|
"themeName": "my-theme-name",
|
16
14
|
"url": {
|
17
15
|
resourcesPath,
|
18
|
-
"resourcesCommonPath":
|
16
|
+
"resourcesCommonPath": `${resourcesPath}/${resources_common}`,
|
19
17
|
"resourceUrl": "#",
|
20
18
|
"accountUrl": "#",
|
21
19
|
"applicationsUrl": "#",
|
@@ -1,16 +1,13 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
3
|
import { downloadKeycloakStaticResources } from "./keycloakify/generateTheme/downloadKeycloakStaticResources";
|
4
|
-
import { join as pathJoin
|
4
|
+
import { join as pathJoin } from "path";
|
5
5
|
import { readBuildOptions } from "./keycloakify/buildOptions";
|
6
6
|
import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants";
|
7
7
|
import * as fs from "fs";
|
8
8
|
|
9
9
|
(async () => {
|
10
|
-
const reactAppRootDirPath = process.cwd();
|
11
|
-
|
12
10
|
const buildOptions = readBuildOptions({
|
13
|
-
reactAppRootDirPath,
|
14
11
|
"processArgv": process.argv.slice(2)
|
15
12
|
});
|
16
13
|
|
@@ -44,6 +41,4 @@ import * as fs from "fs";
|
|
44
41
|
);
|
45
42
|
|
46
43
|
fs.writeFileSync(pathJoin(buildOptions.publicDirPath, keycloak_resources, ".gitignore"), Buffer.from("*", "utf8"));
|
47
|
-
|
48
|
-
console.log(`${pathRelative(reactAppRootDirPath, reservedDirPath)} directory created.`);
|
49
44
|
})();
|
@@ -50,43 +50,121 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|
50
50
|
});
|
51
51
|
}
|
52
52
|
|
53
|
-
|
54
|
-
const
|
53
|
+
remove_keycloak_v2: {
|
54
|
+
const keycloakV2DirPath = pathJoin(destDirPath, "keycloak.v2");
|
55
55
|
|
56
|
-
if (!fs.existsSync(
|
57
|
-
break
|
56
|
+
if (!fs.existsSync(keycloakV2DirPath)) {
|
57
|
+
break remove_keycloak_v2;
|
58
58
|
}
|
59
59
|
|
60
|
-
|
60
|
+
rmSync(keycloakV2DirPath, { "recursive": true });
|
61
|
+
}
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
63
|
+
// Note, this is an optimization for reducing the size of the jar
|
64
|
+
remove_unused_node_modules: {
|
65
|
+
const nodeModuleDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
66
|
+
|
67
|
+
if (!fs.existsSync(nodeModuleDirPath)) {
|
68
|
+
break remove_unused_node_modules;
|
69
69
|
}
|
70
70
|
|
71
|
-
|
71
|
+
const toDeletePerfixes = [
|
72
|
+
"angular",
|
73
|
+
"bootstrap",
|
74
|
+
"rcue",
|
75
|
+
"font-awesome",
|
76
|
+
"ng-file-upload",
|
77
|
+
pathJoin("patternfly", "dist", "sass"),
|
78
|
+
pathJoin("patternfly", "dist", "less"),
|
79
|
+
pathJoin("patternfly", "dist", "js"),
|
80
|
+
"d3",
|
81
|
+
pathJoin("jquery", "src"),
|
82
|
+
"c3",
|
83
|
+
"core-js",
|
84
|
+
"eonasdan-bootstrap-datetimepicker",
|
85
|
+
"moment",
|
86
|
+
"react",
|
87
|
+
"patternfly-bootstrap-treeview",
|
88
|
+
"popper.js",
|
89
|
+
"tippy.js",
|
90
|
+
"jquery-match-height",
|
91
|
+
"google-code-prettify",
|
92
|
+
"patternfly-bootstrap-combobox",
|
93
|
+
"focus-trap",
|
94
|
+
"tabbable",
|
95
|
+
"scheduler",
|
96
|
+
"@types",
|
97
|
+
"datatables.net",
|
98
|
+
"datatables.net-colreorder",
|
99
|
+
"tslib",
|
100
|
+
"prop-types",
|
101
|
+
"file-selector",
|
102
|
+
"datatables.net-colreorder-bs",
|
103
|
+
"object-assign",
|
104
|
+
"warning",
|
105
|
+
"js-tokens",
|
106
|
+
"loose-envify",
|
107
|
+
"prop-types-extra",
|
108
|
+
"attr-accept",
|
109
|
+
"datatables.net-select",
|
110
|
+
"drmonty-datatables-colvis",
|
111
|
+
"datatables.net-bs",
|
112
|
+
pathJoin("@patternfly", "react"),
|
113
|
+
pathJoin("@patternfly", "patternfly", "docs")
|
114
|
+
];
|
115
|
+
|
116
|
+
transformCodebase({
|
117
|
+
"srcDirPath": nodeModuleDirPath,
|
118
|
+
"destDirPath": nodeModuleDirPath,
|
119
|
+
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
120
|
+
if (fileRelativePath.endsWith(".map")) {
|
121
|
+
return undefined;
|
122
|
+
}
|
72
123
|
|
73
|
-
|
124
|
+
if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
|
125
|
+
return undefined;
|
126
|
+
}
|
74
127
|
|
75
|
-
|
128
|
+
if (fileRelativePath.startsWith(pathJoin("patternfly", "dist", "fonts"))) {
|
129
|
+
if (
|
130
|
+
!fileRelativePath.endsWith(".woff2") &&
|
131
|
+
!fileRelativePath.endsWith(".woff") &&
|
132
|
+
!fileRelativePath.endsWith(".ttf")
|
133
|
+
) {
|
134
|
+
return undefined;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
return { "modifiedSourceCode": sourceCode };
|
139
|
+
}
|
140
|
+
});
|
141
|
+
}
|
76
142
|
|
77
|
-
|
143
|
+
// Just like node_modules
|
144
|
+
remove_unused_lib: {
|
145
|
+
const libDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "lib");
|
78
146
|
|
79
|
-
|
80
|
-
|
81
|
-
|
147
|
+
if (!fs.existsSync(libDirPath)) {
|
148
|
+
break remove_unused_lib;
|
149
|
+
}
|
82
150
|
|
83
|
-
|
151
|
+
const toDeletePerfixes = ["ui-ace", "filesaver", "fileupload", "angular", "ui-ace", "pficon"];
|
84
152
|
|
85
|
-
|
153
|
+
transformCodebase({
|
154
|
+
"srcDirPath": libDirPath,
|
155
|
+
"destDirPath": libDirPath,
|
156
|
+
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
157
|
+
if (fileRelativePath.endsWith(".map")) {
|
158
|
+
return undefined;
|
159
|
+
}
|
86
160
|
|
87
|
-
|
161
|
+
if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
|
162
|
+
return undefined;
|
163
|
+
}
|
88
164
|
|
89
|
-
|
165
|
+
return { "modifiedSourceCode": sourceCode };
|
166
|
+
}
|
167
|
+
});
|
90
168
|
}
|
91
169
|
|
92
170
|
last_account_v1_transformations: {
|
@@ -131,53 +209,29 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|
131
209
|
);
|
132
210
|
}
|
133
211
|
|
134
|
-
// Note, this is an optimization for reducing the size of the jar
|
212
|
+
// Note, this is an optimization for reducing the size of the jar,
|
213
|
+
// For this version we know exactly which resources are used.
|
135
214
|
{
|
136
|
-
const
|
215
|
+
const nodeModulesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
137
216
|
|
138
|
-
const
|
217
|
+
const toKeepPrefixes = [
|
139
218
|
...["patternfly.min.css", "patternfly-additions.min.css", "patternfly-additions.min.css"].map(fileBasename =>
|
140
|
-
pathJoin("
|
219
|
+
pathJoin("patternfly", "dist", "css", fileBasename)
|
141
220
|
),
|
142
|
-
|
143
|
-
"OpenSans-Light-webfont.woff2",
|
144
|
-
"OpenSans-Regular-webfont.woff2",
|
145
|
-
"OpenSans-Bold-webfont.woff2",
|
146
|
-
"OpenSans-Semibold-webfont.woff2",
|
147
|
-
"OpenSans-Bold-webfont.woff",
|
148
|
-
"OpenSans-Light-webfont.woff",
|
149
|
-
"OpenSans-Regular-webfont.woff",
|
150
|
-
"OpenSans-Semibold-webfont.woff",
|
151
|
-
"OpenSans-Regular-webfont.ttf",
|
152
|
-
"OpenSans-Light-webfont.ttf",
|
153
|
-
"OpenSans-Semibold-webfont.ttf",
|
154
|
-
"OpenSans-Bold-webfont.ttf"
|
155
|
-
].map(fileBasename => pathJoin("node_modules", "patternfly", "dist", "fonts", fileBasename))
|
221
|
+
pathJoin("patternfly", "dist", "fonts")
|
156
222
|
];
|
157
223
|
|
158
224
|
transformCodebase({
|
159
|
-
"srcDirPath":
|
160
|
-
"destDirPath":
|
225
|
+
"srcDirPath": nodeModulesDirPath,
|
226
|
+
"destDirPath": nodeModulesDirPath,
|
161
227
|
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
162
|
-
if (
|
228
|
+
if (toKeepPrefixes.find(prefix => fileRelativePath.startsWith(prefix)) === undefined) {
|
163
229
|
return undefined;
|
164
230
|
}
|
165
|
-
|
166
231
|
return { "modifiedSourceCode": sourceCode };
|
167
232
|
}
|
168
233
|
});
|
169
234
|
}
|
170
|
-
|
171
|
-
// Other optimization: Remove AngularJS
|
172
|
-
{
|
173
|
-
const nodeModuleDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
174
|
-
|
175
|
-
fs.readdirSync(nodeModuleDirPath)
|
176
|
-
.filter(basename => basename.startsWith("angular"))
|
177
|
-
.map(basename => pathJoin(nodeModuleDirPath, basename))
|
178
|
-
.filter(dirPath => fs.statSync(dirPath).isDirectory())
|
179
|
-
.forEach(dirPath => rmSync(dirPath, { "recursive": true }));
|
180
|
-
}
|
181
235
|
}
|
182
236
|
}
|
183
237
|
}
|
@@ -186,7 +240,6 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|
186
240
|
|
187
241
|
async function main() {
|
188
242
|
const buildOptions = readBuildOptions({
|
189
|
-
"reactAppRootDirPath": process.cwd(),
|
190
243
|
"processArgv": process.argv.slice(2)
|
191
244
|
});
|
192
245
|
|
@@ -11,17 +11,14 @@ import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
|
11
11
|
import { rmSync } from "./tools/fs.rmSync";
|
12
12
|
|
13
13
|
export async function main() {
|
14
|
-
const reactAppRootDirPath = process.cwd();
|
15
|
-
|
16
14
|
const buildOptions = readBuildOptions({
|
17
|
-
reactAppRootDirPath,
|
18
15
|
"processArgv": process.argv.slice(2)
|
19
16
|
});
|
20
17
|
|
21
18
|
const logger = getLogger({ "isSilent": buildOptions.isSilent });
|
22
19
|
|
23
20
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
24
|
-
reactAppRootDirPath
|
21
|
+
"reactAppRootDirPath": buildOptions.reactAppRootDirPath
|
25
22
|
});
|
26
23
|
|
27
24
|
const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
|
@@ -30,8 +30,23 @@ export type BuildOptions = {
|
|
30
30
|
doBuildRetrocompatAccountTheme: boolean;
|
31
31
|
};
|
32
32
|
|
33
|
-
export function readBuildOptions(params: {
|
34
|
-
const {
|
33
|
+
export function readBuildOptions(params: { processArgv: string[] }): BuildOptions {
|
34
|
+
const { processArgv } = params;
|
35
|
+
|
36
|
+
const argv = parseArgv(processArgv);
|
37
|
+
|
38
|
+
const reactAppRootDirPath = (() => {
|
39
|
+
const arg = argv["project"] ?? argv["p"];
|
40
|
+
|
41
|
+
if (typeof arg !== "string") {
|
42
|
+
return process.cwd();
|
43
|
+
}
|
44
|
+
|
45
|
+
return getAbsoluteAndInOsFormatPath({
|
46
|
+
"pathIsh": arg,
|
47
|
+
"cwd": process.cwd()
|
48
|
+
});
|
49
|
+
})();
|
35
50
|
|
36
51
|
const parsedPackageJson = readParsedPackageJson({ reactAppRootDirPath });
|
37
52
|
|
@@ -85,11 +100,7 @@ export function readBuildOptions(params: { reactAppRootDirPath: string; processA
|
|
85
100
|
|
86
101
|
return {
|
87
102
|
"bundler": resolvedViteConfig !== undefined ? "vite" : "webpack",
|
88
|
-
"isSilent":
|
89
|
-
const argv = parseArgv(processArgv);
|
90
|
-
|
91
|
-
return typeof argv["silent"] === "boolean" ? argv["silent"] : false;
|
92
|
-
})(),
|
103
|
+
"isSilent": typeof argv["silent"] === "boolean" ? argv["silent"] : false,
|
93
104
|
"themeVersion": process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
94
105
|
themeNames,
|
95
106
|
"extraThemeProperties": parsedPackageJson.keycloakify?.extraThemeProperties,
|
@@ -408,6 +408,14 @@
|
|
408
408
|
out["themeName"] = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer";
|
409
409
|
out["pageId"] = "${pageId}";
|
410
410
|
|
411
|
+
try {
|
412
|
+
|
413
|
+
out["url"]["resourcesCommonPath"] = out["url"]["resourcesPath"] + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv";
|
414
|
+
|
415
|
+
} catch(error) {
|
416
|
+
|
417
|
+
}
|
418
|
+
|
411
419
|
return out;
|
412
420
|
|
413
421
|
})()
|
@@ -7,7 +7,7 @@ import { join as pathJoin } from "path";
|
|
7
7
|
import { objectKeys } from "tsafe/objectKeys";
|
8
8
|
import type { BuildOptions } from "../buildOptions";
|
9
9
|
import { assert } from "tsafe/assert";
|
10
|
-
import { type ThemeType, nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir } from "../../constants";
|
10
|
+
import { type ThemeType, nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir, resources_common } from "../../constants";
|
11
11
|
|
12
12
|
export type BuildOptionsLike = {
|
13
13
|
bundler: "vite" | "webpack";
|
@@ -105,7 +105,8 @@ export function generateFtlFilesCodeFactory(params: {
|
|
105
105
|
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
106
106
|
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildOptions.themeVersion)
|
107
107
|
.replace("KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr", themeType)
|
108
|
-
.replace("KEYCLOAKIFY_THEME_NAME_cXxKd3xEer", themeName)
|
108
|
+
.replace("KEYCLOAKIFY_THEME_NAME_cXxKd3xEer", themeName)
|
109
|
+
.replace("RESOURCES_COMMON_cLsLsMrtDkpVv", resources_common),
|
109
110
|
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
|
110
111
|
"<#if scripts??>",
|
111
112
|
" <#list scripts as script>",
|
@@ -30,7 +30,6 @@ export function generateStartKeycloakTestingContainer(params: { jarFilePath: str
|
|
30
30
|
Buffer.from(
|
31
31
|
[
|
32
32
|
"#!/usr/bin/env bash",
|
33
|
-
`# If you want to test with Keycloak version prior to 23 use the retrocompat-${pathBasename(jarFilePath)}`,
|
34
33
|
"",
|
35
34
|
`docker rm ${containerName} || true`,
|
36
35
|
"",
|
@@ -11,10 +11,7 @@ import { getThemeSrcDirPath } from "../getThemeSrcDirPath";
|
|
11
11
|
import { getProjectRoot } from "../tools/getProjectRoot";
|
12
12
|
|
13
13
|
export async function main() {
|
14
|
-
const reactAppRootDirPath = process.cwd();
|
15
|
-
|
16
14
|
const buildOptions = readBuildOptions({
|
17
|
-
reactAppRootDirPath,
|
18
15
|
"processArgv": process.argv.slice(2)
|
19
16
|
});
|
20
17
|
|
@@ -23,7 +20,7 @@ export async function main() {
|
|
23
20
|
|
24
21
|
const keycloakifyDirPath = getProjectRoot();
|
25
22
|
|
26
|
-
const { themeSrcDirPath } = getThemeSrcDirPath({ reactAppRootDirPath });
|
23
|
+
const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
|
27
24
|
|
28
25
|
for (const themeName of buildOptions.themeNames) {
|
29
26
|
await generateTheme({
|
@@ -83,12 +80,17 @@ export async function main() {
|
|
83
80
|
"",
|
84
81
|
...(!buildOptions.doCreateJar
|
85
82
|
? []
|
86
|
-
: [
|
83
|
+
: [
|
84
|
+
`✅ Your keycloak theme has been generated and bundled into .${pathSep}${pathRelative(
|
85
|
+
buildOptions.reactAppRootDirPath,
|
86
|
+
jarFilePath
|
87
|
+
)} 🚀`
|
88
|
+
]),
|
87
89
|
"",
|
88
90
|
`To test your theme locally you can spin up a Keycloak ${containerKeycloakVersion} container image with the theme pre loaded by running:`,
|
89
91
|
"",
|
90
92
|
`👉 $ .${pathSep}${pathRelative(
|
91
|
-
reactAppRootDirPath,
|
93
|
+
buildOptions.reactAppRootDirPath,
|
92
94
|
pathJoin(buildOptions.keycloakifyBuildDirPath, generateStartKeycloakTestingContainer.basename)
|
93
95
|
)} 👈`,
|
94
96
|
``,
|
@@ -29,20 +29,6 @@ export function replaceImportsInJsCode_webpack(params: { jsCode: string; buildOp
|
|
29
29
|
);
|
30
30
|
}
|
31
31
|
|
32
|
-
// d={NODE_ENV:"production",PUBLIC_URL:"/foo-bar",WDS_SOCKET_HOST
|
33
|
-
// d={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST
|
34
|
-
// ->
|
35
|
-
// ... PUBLIC_URL:window.kcContext.url.resourcesPath+"/build" ...
|
36
|
-
fixedJsCode = fixedJsCode.replace(
|
37
|
-
new RegExp(
|
38
|
-
`NODE_ENV:"production",PUBLIC_URL:"${
|
39
|
-
buildOptions.urlPathname !== undefined ? replaceAll(buildOptions.urlPathname.slice(0, -1), "/", "\\/") : ""
|
40
|
-
}"`,
|
41
|
-
"g"
|
42
|
-
),
|
43
|
-
`NODE_ENV:"production",PUBLIC_URL:window.${nameOfTheGlobal}.url.resourcesPath+"/${basenameOfTheKeycloakifyResourcesDir}"`
|
44
|
-
);
|
45
|
-
|
46
32
|
// Example: "static/ or "foo/bar/"
|
47
33
|
const staticDir = (() => {
|
48
34
|
let out = pathRelative(buildOptions.reactAppBuildDirPath, buildOptions.assetsDirPath);
|