keycloakify 8.1.0 → 8.1.2
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 +1 -0
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js +22 -12
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js.map +1 -1
- package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js +7 -3
- package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js.map +1 -1
- package/package.json +1 -1
- package/src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts +30 -14
- package/src/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.ts +14 -7
package/README.md
CHANGED
@@ -116,6 +116,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
116
116
|
<td align="center" valign="top" width="14.28%"><a href="https://www.gravitysoftware.be"><img src="https://avatars.githubusercontent.com/u/1140574?v=4?s=100" width="100px;" alt="Thomas Silvestre"/><br /><sub><b>Thomas Silvestre</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=thosil" title="Code">💻</a></td>
|
117
117
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/satanshiro"><img src="https://avatars.githubusercontent.com/u/38865738?v=4?s=100" width="100px;" alt="satanshiro"/><br /><sub><b>satanshiro</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=satanshiro" title="Code">💻</a></td>
|
118
118
|
<td align="center" valign="top" width="14.28%"><a href="https://poelhekke.dev"><img src="https://avatars.githubusercontent.com/u/1632377?v=4?s=100" width="100px;" alt="Koen Poelhekke"/><br /><sub><b>Koen Poelhekke</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=kpoelhekke" title="Code">💻</a></td>
|
119
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zavoloklom"><img src="https://avatars.githubusercontent.com/u/4151869?v=4?s=100" width="100px;" alt="Sergey Kupletsky"/><br /><sub><b>Sergey Kupletsky</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=zavoloklom" title="Tests">⚠️</a> <a href="https://github.com/keycloakify/keycloakify/commits?author=zavoloklom" title="Code">💻</a></td>
|
119
120
|
</tr>
|
120
121
|
</tbody>
|
121
122
|
</table>
|
@@ -66,6 +66,7 @@ var path_1 = require("path");
|
|
66
66
|
var download_builtin_keycloak_theme_1 = require("../../download-builtin-keycloak-theme");
|
67
67
|
var mockTestingResourcesPath_1 = require("../../mockTestingResourcesPath");
|
68
68
|
var crypto = __importStar(require("crypto"));
|
69
|
+
var assert_1 = require("tsafe/assert");
|
69
70
|
function downloadKeycloakStaticResources(
|
70
71
|
// prettier-ignore
|
71
72
|
params) {
|
@@ -74,7 +75,25 @@ params) {
|
|
74
75
|
return __generator(this, function (_a) {
|
75
76
|
switch (_a.label) {
|
76
77
|
case 0:
|
77
|
-
projectDirPath = params.projectDirPath, themeType = params.themeType, themeDirPath = params.themeDirPath, keycloakVersion = params.keycloakVersion
|
78
|
+
projectDirPath = params.projectDirPath, themeType = params.themeType, themeDirPath = params.themeDirPath, keycloakVersion = params.keycloakVersion;
|
79
|
+
usedResources = (function () {
|
80
|
+
var usedResources = params.usedResources;
|
81
|
+
if (usedResources === undefined) {
|
82
|
+
return undefined;
|
83
|
+
}
|
84
|
+
(0, assert_1.assert)(usedResources !== undefined);
|
85
|
+
return {
|
86
|
+
"resourcesCommonDirPaths": usedResources.resourcesCommonFilePaths.map(function (filePath) {
|
87
|
+
{
|
88
|
+
var splitArg = "/dist/";
|
89
|
+
if (filePath.includes(splitArg)) {
|
90
|
+
return filePath.split(splitArg)[0] + splitArg;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return (0, path_1.dirname)(filePath);
|
94
|
+
})
|
95
|
+
};
|
96
|
+
})();
|
78
97
|
tmpDirPath = (0, path_1.join)(themeDirPath, "..", "tmp_suLeKsxId_".concat(crypto.createHash("sha256").update("".concat(themeType, "-").concat(keycloakVersion)).digest("hex").slice(0, 8)));
|
79
98
|
return [4 /*yield*/, (0, download_builtin_keycloak_theme_1.downloadBuiltinKeycloakTheme)({
|
80
99
|
projectDirPath: projectDirPath,
|
@@ -85,16 +104,7 @@ params) {
|
|
85
104
|
_a.sent();
|
86
105
|
(0, transformCodebase_1.transformCodebase)({
|
87
106
|
"srcDirPath": (0, path_1.join)(tmpDirPath, "keycloak", themeType, "resources"),
|
88
|
-
"destDirPath": (0, path_1.join)(themeDirPath, (0, path_1.relative)(mockTestingResourcesPath_1.basenameOfKeycloakDirInPublicDir, mockTestingResourcesPath_1.resourcesDirPathRelativeToPublicDir))
|
89
|
-
"transformSourceCode": usedResources === undefined
|
90
|
-
? undefined
|
91
|
-
: function (_a) {
|
92
|
-
var fileRelativePath = _a.fileRelativePath, sourceCode = _a.sourceCode;
|
93
|
-
if (!usedResources.resourcesFilePaths.includes(fileRelativePath)) {
|
94
|
-
return undefined;
|
95
|
-
}
|
96
|
-
return { "modifiedSourceCode": sourceCode };
|
97
|
-
}
|
107
|
+
"destDirPath": (0, path_1.join)(themeDirPath, (0, path_1.relative)(mockTestingResourcesPath_1.basenameOfKeycloakDirInPublicDir, mockTestingResourcesPath_1.resourcesDirPathRelativeToPublicDir))
|
98
108
|
});
|
99
109
|
(0, transformCodebase_1.transformCodebase)({
|
100
110
|
"srcDirPath": (0, path_1.join)(tmpDirPath, "keycloak", "common", "resources"),
|
@@ -103,7 +113,7 @@ params) {
|
|
103
113
|
? undefined
|
104
114
|
: function (_a) {
|
105
115
|
var fileRelativePath = _a.fileRelativePath, sourceCode = _a.sourceCode;
|
106
|
-
if (
|
116
|
+
if (usedResources.resourcesCommonDirPaths.find(function (dirPath) { return fileRelativePath.startsWith(dirPath); }) === undefined) {
|
107
117
|
return undefined;
|
108
118
|
}
|
109
119
|
return { "modifiedSourceCode": sourceCode };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"downloadKeycloakStaticResources.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAkE;AAClE,qCAAyB;AACzB,
|
1
|
+
{"version":3,"file":"downloadKeycloakStaticResources.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAkE;AAClE,qCAAyB;AACzB,6BAA0F;AAE1F,yFAAqF;AACrF,2EAIwC;AACxC,6CAAiC;AACjC,uCAAsC;AAEtC,SAAsB,+BAA+B;AACjD,kBAAkB;AAClB,MASC;;;;;;oBAEO,cAAc,GAA+C,MAAM,eAArD,EAAE,SAAS,GAAoC,MAAM,UAA1C,EAAE,YAAY,GAAsB,MAAM,aAA5B,EAAE,eAAe,GAAK,MAAM,gBAAX,CAAY;oBAGtE,aAAa,GAAG,CAAC;wBACX,IAAA,aAAa,GAAK,MAAM,cAAX,CAAY;wBAEjC,IAAI,aAAa,KAAK,SAAS,EAAE;4BAC7B,OAAO,SAAS,CAAC;yBACpB;wBAED,IAAA,eAAM,EAAC,aAAa,KAAK,SAAS,CAAC,CAAC;wBAEpC,OAAO;4BACH,yBAAyB,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,CAAC,UAAA,QAAQ;gCAC1E;oCACI,IAAM,QAAQ,GAAG,QAAQ,CAAC;oCAE1B,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;wCAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;qCACjD;iCACJ;gCAED,OAAO,IAAA,cAAW,EAAC,QAAQ,CAAC,CAAC;4BACjC,CAAC,CAAC;yBACL,CAAC;oBACN,CAAC,CAAC,EAAE,C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AChD,CAAC;qBACd,CAAC,CAAC;oBAEH,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;;;;;CAC/D;AAzED,0EAyEC"}
|
@@ -42,14 +42,18 @@ function replaceImportsFromStaticInJsCode(params) {
|
|
42
42
|
var _a;
|
43
43
|
var jsCode = params.jsCode;
|
44
44
|
var getReplaceArgs = function (language) { return [
|
45
|
-
new RegExp("([a-zA-Z_]+)\\.([a-zA-Z]+)=function\\(([a-
|
45
|
+
new RegExp("([a-zA-Z_]+)\\.([a-zA-Z]+)=(function\\(([a-z]+)\\){return|([a-z]+)=>)\"static\\/".concat(language, "\\/\""), "g"),
|
46
46
|
function () {
|
47
47
|
var _a = [];
|
48
48
|
for (var _i = 0; _i < arguments.length; _i++) {
|
49
49
|
_a[_i] = arguments[_i];
|
50
50
|
}
|
51
|
-
var _b = __read(_a,
|
52
|
-
|
51
|
+
var _b = __read(_a, 5), n = _b[1], u = _b[2], matchedFunction = _b[3], eForFunction = _b[4];
|
52
|
+
var isArrowFunction = matchedFunction.includes("=>");
|
53
|
+
var e = isArrowFunction ? matchedFunction.replace("=>", "").trim() : eForFunction;
|
54
|
+
return "\n ".concat(n, "[(function(){\n var pd = Object.getOwnPropertyDescriptor(").concat(n, ", \"p\");\n if( pd === undefined || pd.configurable ){\n Object.defineProperty(").concat(n, ", \"p\", {\n get: function() { return window.").concat(ftlValuesGlobalName_1.ftlValuesGlobalName, ".url.resourcesPath; },\n set: function() {}\n });\n }\n return \"").concat(u, "\";\n })()] = ").concat(isArrowFunction ? "".concat(e, " =>") : "function(".concat(e, ") { return "), " \"/build/static/").concat(language, "/\"")
|
55
|
+
.replace(/\s+/g, " ")
|
56
|
+
.trim();
|
53
57
|
}
|
54
58
|
]; };
|
55
59
|
var fixedJsCode = (_a = jsCode
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"replaceImportsFromStaticInJsCode.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAA6D;AAE7D,SAAgB,gCAAgC,CAAC,MAA0B;IACvE;;;;;;;;;;MAUD;;IAES,IAAA,MAAM,GAAK,MAAM,OAAX,CAAY;IAE1B,IAAM,cAAc,GAAG,UAAC,QAAsB,IAAkD,OAAA;QAC5F,IAAI,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"replaceImportsFromStaticInJsCode.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAA6D;AAE7D,SAAgB,gCAAgC,CAAC,MAA0B;IACvE;;;;;;;;;;MAUD;;IAES,IAAA,MAAM,GAAK,MAAM,OAAX,CAAY;IAE1B,IAAM,cAAc,GAAG,UAAC,QAAsB,IAAkD,OAAA;QAC5F,IAAI,MAAM,CAAC,0FAAkF,QAAQ,UAAM,EAAE,GAAG,CAAC;QACjH;YAAC,YAA0C;iBAA1C,UAA0C,EAA1C,qBAA0C,EAA1C,IAA0C;gBAA1C,uBAA0C;;YAA1C,IAAA,KAAA,aAA0C,EAApC,CAAC,QAAA,EAAE,CAAC,QAAA,EAAE,eAAe,QAAA,EAAE,YAAY,QAAA,CAAC;YACvC,IAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvD,IAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;YAEpF,OAAO,wBACL,CAAC,qFAC4C,CAAC,8HAEhB,CAAC,iFACa,yCAAmB,sJAInD,CAAC,sCACL,eAAe,CAAC,CAAC,CAAC,UAAG,CAAC,QAAK,CAAC,CAAC,CAAC,mBAAY,CAAC,gBAAa,8BAAmB,QAAQ,QAAI;iBAC5F,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;iBACpB,IAAI,EAAE,CAAC;QAChB,CAAC;KACJ,EApB+F,CAoB/F,CAAC;IAEF,IAAM,WAAW,GAAG,CAAA,KAAA,MAAM;SACrB,OAAO,OADQ,MAAM,2BACV,cAAc,CAAC,IAAI,CAAC,UAAC,CAAA;SAChC,OAAO,oCAAI,cAAc,CAAC,KAAK,CAAC,WAChC,OAAO,CAAC,kCAAkC,EAAE,iBAAU,yCAAmB,0CAAsC,CAAC;QACjH,kCAAkC;SACjC,OAAO,CACJ,6DAA6D,EAC7D;QAAC,YAAqB;aAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;YAArB,uBAAqB;;QAArB,IAAA,KAAA,aAAqB,EAAf,MAAM,QAAA,EAAE,MAAM,QAAA,CAAC;QAAK,OAAA,yBAAgB,MAAM,uBAAa,yCAAmB,gDAAoC,MAAM,MAAG;IAAnG,CAAmG,CACjI,CAAC;IAEN,OAAO,EAAE,WAAW,aAAA,EAAE,CAAC;AAC3B,CAAC;AAhDD,4EAgDC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { transformCodebase } from "../../tools/transformCodebase";
|
2
2
|
import * as fs from "fs";
|
3
|
-
import { join as pathJoin, relative as pathRelative } from "path";
|
3
|
+
import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
|
4
4
|
import type { ThemeType } from "../generateFtl";
|
5
5
|
import { downloadBuiltinKeycloakTheme } from "../../download-builtin-keycloak-theme";
|
6
6
|
import {
|
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
basenameOfKeycloakDirInPublicDir
|
10
10
|
} from "../../mockTestingResourcesPath";
|
11
11
|
import * as crypto from "crypto";
|
12
|
+
import { assert } from "tsafe/assert";
|
12
13
|
|
13
14
|
export async function downloadKeycloakStaticResources(
|
14
15
|
// prettier-ignore
|
@@ -23,7 +24,32 @@ export async function downloadKeycloakStaticResources(
|
|
23
24
|
} | undefined
|
24
25
|
}
|
25
26
|
) {
|
26
|
-
const { projectDirPath, themeType, themeDirPath, keycloakVersion
|
27
|
+
const { projectDirPath, themeType, themeDirPath, keycloakVersion } = params;
|
28
|
+
|
29
|
+
// NOTE: Hack for 427
|
30
|
+
const usedResources = (() => {
|
31
|
+
const { usedResources } = params;
|
32
|
+
|
33
|
+
if (usedResources === undefined) {
|
34
|
+
return undefined;
|
35
|
+
}
|
36
|
+
|
37
|
+
assert(usedResources !== undefined);
|
38
|
+
|
39
|
+
return {
|
40
|
+
"resourcesCommonDirPaths": usedResources.resourcesCommonFilePaths.map(filePath => {
|
41
|
+
{
|
42
|
+
const splitArg = "/dist/";
|
43
|
+
|
44
|
+
if (filePath.includes(splitArg)) {
|
45
|
+
return filePath.split(splitArg)[0] + splitArg;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
return pathDirname(filePath);
|
50
|
+
})
|
51
|
+
};
|
52
|
+
})();
|
27
53
|
|
28
54
|
const tmpDirPath = pathJoin(
|
29
55
|
themeDirPath,
|
@@ -39,17 +65,7 @@ export async function downloadKeycloakStaticResources(
|
|
39
65
|
|
40
66
|
transformCodebase({
|
41
67
|
"srcDirPath": pathJoin(tmpDirPath, "keycloak", themeType, "resources"),
|
42
|
-
"destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesDirPathRelativeToPublicDir))
|
43
|
-
"transformSourceCode":
|
44
|
-
usedResources === undefined
|
45
|
-
? undefined
|
46
|
-
: ({ fileRelativePath, sourceCode }) => {
|
47
|
-
if (!usedResources.resourcesFilePaths.includes(fileRelativePath)) {
|
48
|
-
return undefined;
|
49
|
-
}
|
50
|
-
|
51
|
-
return { "modifiedSourceCode": sourceCode };
|
52
|
-
}
|
68
|
+
"destDirPath": pathJoin(themeDirPath, pathRelative(basenameOfKeycloakDirInPublicDir, resourcesDirPathRelativeToPublicDir))
|
53
69
|
});
|
54
70
|
|
55
71
|
transformCodebase({
|
@@ -59,7 +75,7 @@ export async function downloadKeycloakStaticResources(
|
|
59
75
|
usedResources === undefined
|
60
76
|
? undefined
|
61
77
|
: ({ fileRelativePath, sourceCode }) => {
|
62
|
-
if (
|
78
|
+
if (usedResources.resourcesCommonDirPaths.find(dirPath => fileRelativePath.startsWith(dirPath)) === undefined) {
|
63
79
|
return undefined;
|
64
80
|
}
|
65
81
|
|
@@ -16,18 +16,25 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string }): {
|
|
16
16
|
const { jsCode } = params;
|
17
17
|
|
18
18
|
const getReplaceArgs = (language: "js" | "css"): Parameters<typeof String.prototype.replace> => [
|
19
|
-
new RegExp(`([a-zA-Z_]+)\\.([a-zA-Z]+)=function\\(([a-
|
20
|
-
(...[, n, u,
|
21
|
-
|
22
|
-
|
19
|
+
new RegExp(`([a-zA-Z_]+)\\.([a-zA-Z]+)=(function\\(([a-z]+)\\){return|([a-z]+)=>)"static\\/${language}\\/"`, "g"),
|
20
|
+
(...[, n, u, matchedFunction, eForFunction]) => {
|
21
|
+
const isArrowFunction = matchedFunction.includes("=>");
|
22
|
+
const e = isArrowFunction ? matchedFunction.replace("=>", "").trim() : eForFunction;
|
23
|
+
|
24
|
+
return `
|
25
|
+
${n}[(function(){
|
26
|
+
var pd = Object.getOwnPropertyDescriptor(${n}, "p");
|
23
27
|
if( pd === undefined || pd.configurable ){
|
24
28
|
Object.defineProperty(${n}, "p", {
|
25
29
|
get: function() { return window.${ftlValuesGlobalName}.url.resourcesPath; },
|
26
|
-
set: function
|
30
|
+
set: function() {}
|
27
31
|
});
|
28
32
|
}
|
29
|
-
|
30
|
-
|
33
|
+
return "${u}";
|
34
|
+
})()] = ${isArrowFunction ? `${e} =>` : `function(${e}) { return `} "/build/static/${language}/"`
|
35
|
+
.replace(/\s+/g, " ")
|
36
|
+
.trim();
|
37
|
+
}
|
31
38
|
];
|
32
39
|
|
33
40
|
const fixedJsCode = jsCode
|