keycloakify 10.0.0-rc.73 → 10.0.0-rc.75
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/README.md +2 -3
- package/bin/266.index.js +806 -0
- package/bin/{772.index.js → 304.index.js} +262 -678
- package/bin/{363.index.js → 440.index.js} +24 -74
- package/bin/720.index.js +243 -0
- package/bin/877.index.js +275 -0
- package/bin/main.js +455 -330
- package/package.json +7 -9
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -20
- package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +11 -16
- package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +30 -62
- package/bin/246.index.js +0 -466
- package/bin/420.index.js +0 -508
- package/bin/509.index.js +0 -438
- package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +0 -28
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "keycloakify",
|
3
|
-
"version": "10.0.0-rc.
|
3
|
+
"version": "10.0.0-rc.75",
|
4
4
|
"description": "Create Keycloak themes using React",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -478,7 +478,6 @@
|
|
478
478
|
"src/bin/keycloakify/index.ts",
|
479
479
|
"src/bin/keycloakify/keycloakify.ts",
|
480
480
|
"src/bin/keycloakify/replacers/replaceImportsInCssCode.ts",
|
481
|
-
"src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts",
|
482
481
|
"src/bin/keycloakify/replacers/replaceImportsInJsCode/index.ts",
|
483
482
|
"src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts",
|
484
483
|
"src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts",
|
@@ -769,21 +768,21 @@
|
|
769
768
|
"bin/main.js",
|
770
769
|
"bin/180.index.js",
|
771
770
|
"bin/193.index.js",
|
772
|
-
"bin/
|
771
|
+
"bin/266.index.js",
|
772
|
+
"bin/304.index.js",
|
773
773
|
"bin/36.index.js",
|
774
|
-
"bin/363.index.js",
|
775
|
-
"bin/420.index.js",
|
776
774
|
"bin/430.index.js",
|
775
|
+
"bin/440.index.js",
|
777
776
|
"bin/453.index.js",
|
778
777
|
"bin/456.index.js",
|
779
778
|
"bin/490.index.js",
|
780
|
-
"bin/509.index.js",
|
781
779
|
"bin/525.index.js",
|
782
780
|
"bin/526.index.js",
|
783
781
|
"bin/538.index.js",
|
782
|
+
"bin/720.index.js",
|
784
783
|
"bin/751.index.js",
|
785
|
-
"bin/772.index.js",
|
786
784
|
"bin/837.index.js",
|
785
|
+
"bin/877.index.js",
|
787
786
|
"bin/932.index.js",
|
788
787
|
"bin/97.index.js",
|
789
788
|
"bin/shared/constants.js",
|
@@ -861,7 +860,6 @@
|
|
861
860
|
"lint-staged": "^11.0.0",
|
862
861
|
"magic-string": "^0.30.7",
|
863
862
|
"make-fetch-happen": "^11.0.3",
|
864
|
-
"patch-package": "^8.0.0",
|
865
863
|
"powerhooks": "^1.0.10",
|
866
864
|
"prettier": "^3.2.5",
|
867
865
|
"properties-parser": "^0.3.1",
|
@@ -870,7 +868,7 @@
|
|
870
868
|
"recast": "^0.23.3",
|
871
869
|
"run-exclusive": "^2.2.19",
|
872
870
|
"storybook-dark-mode": "^1.1.2",
|
873
|
-
"termost": "^
|
871
|
+
"termost": "^v0.12.1",
|
874
872
|
"tsc-alias": "^1.8.10",
|
875
873
|
"tss-react": "^4.9.10",
|
876
874
|
"typescript": "^4.9.1-beta",
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import cheerio from "cheerio";
|
2
2
|
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
3
|
-
import {
|
4
|
-
import { replaceImportsInInlineCssCode } from "../replacers/replaceImportsInInlineCssCode";
|
3
|
+
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
5
4
|
import * as fs from "fs";
|
6
5
|
import { join as pathJoin } from "path";
|
7
6
|
import type { BuildContext } from "../../shared/buildContext";
|
@@ -28,7 +27,6 @@ assert<BuildContext extends BuildContextLike ? true : false>();
|
|
28
27
|
export function generateFtlFilesCodeFactory(params: {
|
29
28
|
themeName: string;
|
30
29
|
indexHtmlCode: string;
|
31
|
-
cssGlobalsToDefine: Record<string, string>;
|
32
30
|
buildContext: BuildContextLike;
|
33
31
|
keycloakifyVersion: string;
|
34
32
|
themeType: ThemeType;
|
@@ -36,7 +34,6 @@ export function generateFtlFilesCodeFactory(params: {
|
|
36
34
|
}) {
|
37
35
|
const {
|
38
36
|
themeName,
|
39
|
-
cssGlobalsToDefine,
|
40
37
|
indexHtmlCode,
|
41
38
|
buildContext,
|
42
39
|
keycloakifyVersion,
|
@@ -65,8 +62,9 @@ export function generateFtlFilesCodeFactory(params: {
|
|
65
62
|
|
66
63
|
assert(cssCode !== null);
|
67
64
|
|
68
|
-
const { fixedCssCode } =
|
65
|
+
const { fixedCssCode } = replaceImportsInCssCode({
|
69
66
|
cssCode,
|
67
|
+
fileRelativeDirPath: ".",
|
70
68
|
buildContext
|
71
69
|
});
|
72
70
|
|
@@ -97,21 +95,6 @@ export function generateFtlFilesCodeFactory(params: {
|
|
97
95
|
);
|
98
96
|
})
|
99
97
|
);
|
100
|
-
|
101
|
-
if (Object.keys(cssGlobalsToDefine).length !== 0) {
|
102
|
-
$("head").prepend(
|
103
|
-
[
|
104
|
-
"",
|
105
|
-
"<style>",
|
106
|
-
generateCssCodeToDefineGlobals({
|
107
|
-
cssGlobalsToDefine,
|
108
|
-
buildContext
|
109
|
-
}).cssCodeToPrependInHead,
|
110
|
-
"</style>",
|
111
|
-
""
|
112
|
-
].join("\n")
|
113
|
-
);
|
114
|
-
}
|
115
98
|
}
|
116
99
|
|
117
100
|
//FTL is no valid html, we can't insert with cheerio, we put placeholder for injecting later.
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import { transformCodebase } from "../../tools/transformCodebase";
|
2
2
|
import * as fs from "fs";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
join as pathJoin,
|
5
|
+
resolve as pathResolve,
|
6
|
+
relative as pathRelative,
|
7
|
+
dirname as pathDirname
|
8
|
+
} from "path";
|
4
9
|
import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
5
10
|
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
6
11
|
import {
|
@@ -64,8 +69,6 @@ export async function generateResourcesForMainTheme(params: {
|
|
64
69
|
return pathJoin(resourcesDirPath, "theme", themeName, themeType);
|
65
70
|
};
|
66
71
|
|
67
|
-
const cssGlobalsToDefine: Record<string, string> = {};
|
68
|
-
|
69
72
|
for (const themeType of ["login", "account"] as const) {
|
70
73
|
if (!buildContext.recordIsImplementedByThemeType[themeType]) {
|
71
74
|
continue;
|
@@ -127,21 +130,14 @@ export async function generateResourcesForMainTheme(params: {
|
|
127
130
|
transformCodebase({
|
128
131
|
srcDirPath: buildContext.projectBuildDirPath,
|
129
132
|
destDirPath,
|
130
|
-
transformSourceCode: ({ filePath, sourceCode }) => {
|
133
|
+
transformSourceCode: ({ filePath, fileRelativePath, sourceCode }) => {
|
131
134
|
if (filePath.endsWith(".css")) {
|
132
|
-
const {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
cssCode: sourceCode.toString("utf8")
|
135
|
+
const { fixedCssCode } = replaceImportsInCssCode({
|
136
|
+
cssCode: sourceCode.toString("utf8"),
|
137
|
+
fileRelativeDirPath: pathDirname(fileRelativePath),
|
138
|
+
buildContext
|
137
139
|
});
|
138
140
|
|
139
|
-
Object.entries(cssGlobalsToDefineForThisFile).forEach(
|
140
|
-
([key, value]) => {
|
141
|
-
cssGlobalsToDefine[key] = value;
|
142
|
-
}
|
143
|
-
);
|
144
|
-
|
145
141
|
return {
|
146
142
|
modifiedSourceCode: Buffer.from(fixedCssCode, "utf8")
|
147
143
|
};
|
@@ -168,7 +164,6 @@ export async function generateResourcesForMainTheme(params: {
|
|
168
164
|
indexHtmlCode: fs
|
169
165
|
.readFileSync(pathJoin(buildContext.projectBuildDirPath, "index.html"))
|
170
166
|
.toString("utf8"),
|
171
|
-
cssGlobalsToDefine,
|
172
167
|
buildContext,
|
173
168
|
keycloakifyVersion: readThisNpmPackageVersion(),
|
174
169
|
themeType,
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import * as crypto from "crypto";
|
2
1
|
import type { BuildContext } from "../../shared/buildContext";
|
3
2
|
import { assert } from "tsafe/assert";
|
4
|
-
import {
|
3
|
+
import { posix } from "path";
|
5
4
|
|
6
5
|
export type BuildContextLike = {
|
7
6
|
urlPathname: string | undefined;
|
@@ -9,68 +8,37 @@ export type BuildContextLike = {
|
|
9
8
|
|
10
9
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
11
10
|
|
12
|
-
export function replaceImportsInCssCode(params: {
|
13
|
-
|
14
|
-
|
15
|
-
} {
|
16
|
-
const { cssCode } = params;
|
17
|
-
|
18
|
-
const cssGlobalsToDefine: Record<string, string> = {};
|
19
|
-
|
20
|
-
new Set(cssCode.match(/url\(["']?\/[^/][^)"']+["']?\)[^;}]*?/g) ?? []).forEach(
|
21
|
-
match =>
|
22
|
-
(cssGlobalsToDefine[
|
23
|
-
"url" +
|
24
|
-
crypto
|
25
|
-
.createHash("sha256")
|
26
|
-
.update(match)
|
27
|
-
.digest("hex")
|
28
|
-
.substring(0, 15)
|
29
|
-
] = match)
|
30
|
-
);
|
31
|
-
|
32
|
-
let fixedCssCode = cssCode;
|
33
|
-
|
34
|
-
Object.keys(cssGlobalsToDefine).forEach(
|
35
|
-
cssVariableName =>
|
36
|
-
//NOTE: split/join pattern ~ replace all
|
37
|
-
(fixedCssCode = fixedCssCode
|
38
|
-
.split(cssGlobalsToDefine[cssVariableName])
|
39
|
-
.join(`var(--${cssVariableName})`))
|
40
|
-
);
|
41
|
-
|
42
|
-
return { fixedCssCode, cssGlobalsToDefine };
|
43
|
-
}
|
44
|
-
|
45
|
-
export function generateCssCodeToDefineGlobals(params: {
|
46
|
-
cssGlobalsToDefine: Record<string, string>;
|
11
|
+
export function replaceImportsInCssCode(params: {
|
12
|
+
cssCode: string;
|
13
|
+
fileRelativeDirPath: string;
|
47
14
|
buildContext: BuildContextLike;
|
48
15
|
}): {
|
49
|
-
|
16
|
+
fixedCssCode: string;
|
50
17
|
} {
|
51
|
-
const {
|
18
|
+
const { cssCode, fileRelativeDirPath, buildContext } = params;
|
19
|
+
|
20
|
+
const fixedCssCode = cssCode.replace(
|
21
|
+
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
22
|
+
(match, assetFileAbsoluteUrlPathname) => {
|
23
|
+
if (buildContext.urlPathname !== undefined) {
|
24
|
+
if (!assetFileAbsoluteUrlPathname.startsWith(buildContext.urlPathname)) {
|
25
|
+
// NOTE: Should never happen
|
26
|
+
return match;
|
27
|
+
}
|
28
|
+
assetFileAbsoluteUrlPathname = assetFileAbsoluteUrlPathname.replace(
|
29
|
+
buildContext.urlPathname,
|
30
|
+
"/"
|
31
|
+
);
|
32
|
+
}
|
33
|
+
|
34
|
+
const assetFileRelativeUrlPathname = posix.relative(
|
35
|
+
fileRelativeDirPath.replace(/\\/g, "/"),
|
36
|
+
assetFileAbsoluteUrlPathname.replace(/^\//, "")
|
37
|
+
);
|
38
|
+
|
39
|
+
return `url(${assetFileRelativeUrlPathname})`;
|
40
|
+
}
|
41
|
+
);
|
52
42
|
|
53
|
-
return {
|
54
|
-
cssCodeToPrependInHead: [
|
55
|
-
":root {",
|
56
|
-
...Object.keys(cssGlobalsToDefine)
|
57
|
-
.map(cssVariableName =>
|
58
|
-
[
|
59
|
-
`--${cssVariableName}:`,
|
60
|
-
cssGlobalsToDefine[cssVariableName].replace(
|
61
|
-
new RegExp(
|
62
|
-
`url\\(${(buildContext.urlPathname ?? "/").replace(
|
63
|
-
/\//g,
|
64
|
-
"\\/"
|
65
|
-
)}`,
|
66
|
-
"g"
|
67
|
-
),
|
68
|
-
`url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
69
|
-
)
|
70
|
-
].join(" ")
|
71
|
-
)
|
72
|
-
.map(line => ` ${line};`),
|
73
|
-
"}"
|
74
|
-
].join("\n")
|
75
|
-
};
|
43
|
+
return { fixedCssCode };
|
76
44
|
}
|