keycloakify 8.1.3 → 8.2.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/README.md +1 -0
- package/bin/getSrcDirPath.js +30 -17
- package/bin/getSrcDirPath.js.map +1 -1
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.d.ts +0 -1
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js.map +1 -1
- package/bin/keycloakify/generateTheme/readStaticResourcesUsage.d.ts +0 -2
- package/bin/keycloakify/generateTheme/readStaticResourcesUsage.js +37 -51
- package/bin/keycloakify/generateTheme/readStaticResourcesUsage.js.map +1 -1
- package/package.json +1 -1
- package/src/bin/getSrcDirPath.ts +8 -8
- package/src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts +0 -1
- package/src/bin/keycloakify/generateTheme/readStaticResourcesUsage.ts +21 -28
package/README.md
CHANGED
@@ -117,6 +117,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
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
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>
|
120
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rome-user"><img src="https://avatars.githubusercontent.com/u/114131048?v=4?s=100" width="100px;" alt="rome-user"/><br /><sub><b>rome-user</b></sub></a><br /><a href="https://github.com/keycloakify/keycloakify/commits?author=rome-user" title="Code">💻</a></td>
|
120
121
|
</tr>
|
121
122
|
</tbody>
|
122
123
|
</table>
|
package/bin/getSrcDirPath.js
CHANGED
@@ -22,6 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
22
|
__setModuleDefault(result, mod);
|
23
23
|
return result;
|
24
24
|
};
|
25
|
+
var __values = (this && this.__values) || function(o) {
|
26
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
27
|
+
if (m) return m.call(o);
|
28
|
+
if (o && typeof o.length === "number") return {
|
29
|
+
next: function () {
|
30
|
+
if (o && i >= o.length) o = void 0;
|
31
|
+
return { value: o && o[i++], done: !o };
|
32
|
+
}
|
33
|
+
};
|
34
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
35
|
+
};
|
25
36
|
var __read = (this && this.__read) || function (o, n) {
|
26
37
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
27
38
|
if (!m) return o;
|
@@ -47,17 +58,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
47
58
|
}
|
48
59
|
return to.concat(ar || Array.prototype.slice.call(from));
|
49
60
|
};
|
50
|
-
var __values = (this && this.__values) || function(o) {
|
51
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
52
|
-
if (m) return m.call(o);
|
53
|
-
if (o && typeof o.length === "number") return {
|
54
|
-
next: function () {
|
55
|
-
if (o && i >= o.length) o = void 0;
|
56
|
-
return { value: o && o[i++], done: !o };
|
57
|
-
}
|
58
|
-
};
|
59
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
60
|
-
};
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
62
62
|
exports.getThemeSrcDirPath = void 0;
|
63
63
|
var fs = __importStar(require("fs"));
|
@@ -65,7 +65,7 @@ var tsafe_1 = require("tsafe");
|
|
65
65
|
var crawl_1 = require("./tools/crawl");
|
66
66
|
var path_1 = require("path");
|
67
67
|
var generateFtl_1 = require("./keycloakify/generateFtl");
|
68
|
-
var
|
68
|
+
var themeSrcDirBasenames = ["keycloak-theme", "keycloak_theme"];
|
69
69
|
/** Can't catch error, if the directory isn't found, this function will just exit the process with an error message. */
|
70
70
|
function getThemeSrcDirPath(params) {
|
71
71
|
var e_1, _a;
|
@@ -73,11 +73,24 @@ function getThemeSrcDirPath(params) {
|
|
73
73
|
var srcDirPath = (0, path_1.join)(projectDirPath, "src");
|
74
74
|
var themeSrcDirPath = (0, crawl_1.crawl)({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" })
|
75
75
|
.map(function (fileRelativePath) {
|
76
|
-
var
|
77
|
-
|
78
|
-
|
76
|
+
var e_2, _a;
|
77
|
+
try {
|
78
|
+
for (var themeSrcDirBasenames_1 = __values(themeSrcDirBasenames), themeSrcDirBasenames_1_1 = themeSrcDirBasenames_1.next(); !themeSrcDirBasenames_1_1.done; themeSrcDirBasenames_1_1 = themeSrcDirBasenames_1.next()) {
|
79
|
+
var themeSrcDirBasename = themeSrcDirBasenames_1_1.value;
|
80
|
+
var split = fileRelativePath.split(themeSrcDirBasename);
|
81
|
+
if (split.length === 2) {
|
82
|
+
return (0, path_1.join)(srcDirPath, split[0] + themeSrcDirBasename);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
87
|
+
finally {
|
88
|
+
try {
|
89
|
+
if (themeSrcDirBasenames_1_1 && !themeSrcDirBasenames_1_1.done && (_a = themeSrcDirBasenames_1.return)) _a.call(themeSrcDirBasenames_1);
|
90
|
+
}
|
91
|
+
finally { if (e_2) throw e_2.error; }
|
79
92
|
}
|
80
|
-
return
|
93
|
+
return undefined;
|
81
94
|
})
|
82
95
|
.filter((0, tsafe_1.exclude)(undefined))[0];
|
83
96
|
if (themeSrcDirPath !== undefined) {
|
@@ -101,7 +114,7 @@ function getThemeSrcDirPath(params) {
|
|
101
114
|
}
|
102
115
|
console.error([
|
103
116
|
"Can't locate your theme source directory. It should be either: ",
|
104
|
-
"src/ or src/keycloak-theme.",
|
117
|
+
"src/ or src/keycloak-theme or src/keycloak_theme.",
|
105
118
|
"Example in the starter: https://github.com/keycloakify/keycloakify-starter/tree/main/src/keycloak-theme"
|
106
119
|
].join("\n"));
|
107
120
|
process.exit(-1);
|
package/bin/getSrcDirPath.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getSrcDirPath.js","sourceRoot":"","sources":["../src/bin/getSrcDirPath.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,+BAAgC;AAChC,uCAAsC;AACtC,6BAAwC;AACxC,yDAAuD;AAEvD,IAAM,
|
1
|
+
{"version":3,"file":"getSrcDirPath.js","sourceRoot":"","sources":["../src/bin/getSrcDirPath.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,+BAAgC;AAChC,uCAAsC;AACtC,6BAAwC;AACxC,yDAAuD;AAEvD,IAAM,oBAAoB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAElE,uHAAuH;AACvH,SAAgB,kBAAkB,CAAC,MAAkC;;IACzD,IAAA,cAAc,GAAK,MAAM,eAAX,CAAY;IAElC,IAAM,UAAU,GAAG,IAAA,WAAQ,EAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAEnD,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ources":["../../../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,
|
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,MAQC;;;;;;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,QA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,CAAC,EAApC,CAAoC,CAAC,KAAK,SAAS,EAAE;oCAC3G,OAAO,SAAS,CAAC;iCACpB;gCAED,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,CAAC;4BAChD,CAAC;qBACd,CAAC,CAAC;oBAEH,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;;;;;CAC/D;AAxED,0EAwEC"}
|
@@ -6,12 +6,10 @@ export declare function readStaticResourcesUsage(params: {
|
|
6
6
|
themeType: ThemeType;
|
7
7
|
}): {
|
8
8
|
resourcesCommonFilePaths: string[];
|
9
|
-
resourcesFilePaths: string[];
|
10
9
|
};
|
11
10
|
/** Exported for testing purpose */
|
12
11
|
export declare function readPaths(params: {
|
13
12
|
rawSourceFile: string;
|
14
13
|
}): {
|
15
14
|
resourcesCommonFilePaths: string[];
|
16
|
-
resourcesFilePaths: string[];
|
17
15
|
};
|
@@ -68,7 +68,6 @@ function readStaticResourcesUsage(params) {
|
|
68
68
|
var e_1, _a, e_2, _b;
|
69
69
|
var keycloakifySrcDirPath = params.keycloakifySrcDirPath, themeSrcDirPath = params.themeSrcDirPath, themeType = params.themeType;
|
70
70
|
var resourcesCommonFilePaths = new Set();
|
71
|
-
var resourcesFilePaths = new Set();
|
72
71
|
try {
|
73
72
|
for (var _c = __values([(0, path_1.join)(keycloakifySrcDirPath, themeType), (0, path_1.join)(themeSrcDirPath, themeType)]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
74
73
|
var srcDirPath = _d.value;
|
@@ -82,7 +81,6 @@ function readStaticResourcesUsage(params) {
|
|
82
81
|
}
|
83
82
|
var wrap = readPaths({ rawSourceFile: rawSourceFile });
|
84
83
|
wrap.resourcesCommonFilePaths.forEach(function (filePath) { return resourcesCommonFilePaths.add(filePath); });
|
85
|
-
wrap.resourcesFilePaths.forEach(function (filePath) { return resourcesFilePaths.add(filePath); });
|
86
84
|
}
|
87
85
|
}
|
88
86
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
@@ -102,70 +100,58 @@ function readStaticResourcesUsage(params) {
|
|
102
100
|
finally { if (e_1) throw e_1.error; }
|
103
101
|
}
|
104
102
|
return {
|
105
|
-
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
|
106
|
-
"resourcesFilePaths": Array.from(resourcesFilePaths)
|
103
|
+
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
|
107
104
|
};
|
108
105
|
}
|
109
106
|
exports.readStaticResourcesUsage = readStaticResourcesUsage;
|
110
107
|
/** Exported for testing purpose */
|
111
108
|
function readPaths(params) {
|
112
|
-
var e_3, _a, e_4, _b
|
109
|
+
var e_3, _a, e_4, _b;
|
113
110
|
var rawSourceFile = params.rawSourceFile;
|
114
111
|
var resourcesCommonFilePaths = new Set();
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
var
|
120
|
-
|
121
|
-
var
|
122
|
-
|
123
|
-
try {
|
124
|
-
for (var matches_1 = (e_4 = void 0, __values(matches)), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
125
|
-
var match = matches_1_1.value;
|
126
|
-
var filePath = match[1];
|
127
|
-
set.add(filePath);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
131
|
-
finally {
|
132
|
-
try {
|
133
|
-
if (matches_1_1 && !matches_1_1.done && (_b = matches_1.return)) _b.call(matches_1);
|
134
|
-
}
|
135
|
-
finally { if (e_4) throw e_4.error; }
|
136
|
-
}
|
112
|
+
{
|
113
|
+
var regexp = new RegExp("resourcesCommonPath\\s*}([^`]+)`", "g");
|
114
|
+
var matches = __spreadArray([], __read(rawSourceFile.matchAll(regexp)), false);
|
115
|
+
try {
|
116
|
+
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
117
|
+
var match = matches_1_1.value;
|
118
|
+
var filePath = match[1];
|
119
|
+
resourcesCommonFilePaths.add(filePath);
|
137
120
|
}
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
var match = matches_2_1.value;
|
144
|
-
var filePath = match[1];
|
145
|
-
set.add(filePath);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
149
|
-
finally {
|
150
|
-
try {
|
151
|
-
if (matches_2_1 && !matches_2_1.done && (_c = matches_2.return)) _c.call(matches_2);
|
152
|
-
}
|
153
|
-
finally { if (e_5) throw e_5.error; }
|
154
|
-
}
|
121
|
+
}
|
122
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
123
|
+
finally {
|
124
|
+
try {
|
125
|
+
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
155
126
|
}
|
127
|
+
finally { if (e_3) throw e_3.error; }
|
156
128
|
}
|
157
129
|
}
|
158
|
-
|
159
|
-
|
130
|
+
{
|
131
|
+
var regexp = new RegExp("resourcesCommonPath\\s*[+,]\\s*[\"']([^\"'`]+)[\"'`]", "g");
|
132
|
+
var matches = __spreadArray([], __read(rawSourceFile.matchAll(regexp)), false);
|
160
133
|
try {
|
161
|
-
|
134
|
+
for (var matches_2 = __values(matches), matches_2_1 = matches_2.next(); !matches_2_1.done; matches_2_1 = matches_2.next()) {
|
135
|
+
var match = matches_2_1.value;
|
136
|
+
var filePath = match[1];
|
137
|
+
resourcesCommonFilePaths.add(filePath);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
141
|
+
finally {
|
142
|
+
try {
|
143
|
+
if (matches_2_1 && !matches_2_1.done && (_b = matches_2.return)) _b.call(matches_2);
|
144
|
+
}
|
145
|
+
finally { if (e_4) throw e_4.error; }
|
162
146
|
}
|
163
|
-
finally { if (e_3) throw e_3.error; }
|
164
147
|
}
|
165
|
-
var
|
148
|
+
var normalizePath = function (filePath) {
|
149
|
+
filePath = filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
150
|
+
filePath = filePath.replace(/\//g, path_1.sep);
|
151
|
+
return filePath;
|
152
|
+
};
|
166
153
|
return {
|
167
|
-
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(
|
168
|
-
"resourcesFilePaths": Array.from(resourcesFilePaths).map(removePrefixSlash)
|
154
|
+
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(normalizePath)
|
169
155
|
};
|
170
156
|
}
|
171
157
|
exports.readPaths = readPaths;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"readStaticResourcesUsage.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/generateTheme/readStaticResourcesUsage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,
|
1
|
+
{"version":3,"file":"readStaticResourcesUsage.js","sourceRoot":"","sources":["../../../src/bin/keycloakify/generateTheme/readStaticResourcesUsage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6BAAwD;AACxD,qCAAyB;AAGzB,oCAAoC;AACpC,SAAgB,wBAAwB,CAAC,MAAwF;;IAGrH,IAAA,qBAAqB,GAAiC,MAAM,sBAAvC,EAAE,eAAe,GAAgB,MAAM,gBAAtB,EAAE,SAAS,GAAK,MAAM,UAAX,CAAY;IAErE,IAAM,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;;QAEnD,KAAyB,IAAA,KAAA,SAAA,CAAC,IAAA,WAAQ,EAAC,qBAAqB,EAAE,SAAS,CAAC,EAAE,IAAA,WAAQ,EAAC,eAAe,EAAE,SAAS,CAAC,CAAC,CAAA,gBAAA,4BAAE;YAAxG,IAAM,UAAU,WAAA;YACjB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AAA,gCAAA,qDAAE;gBAAxB,IAAM,KAAK,oBAAA;gBACZ,IAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aAC1C;;;;;;;;;KACJ;IAED;QACI,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,sDAAqD,EAAE,GAAG,CAAC,CAAC;QAEtF,IAAM,OAAO,4BAAO,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAC,CAAC;;YAEpD,KAAoB,IAAA,YAAA,SAAA,OAAO,CAAA,gCAAA,qDAAE;gBAAxB,IAAM,KAAK,oBAAA;gBACZ,IAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aAC1C;;;;;;;;;KACJ;IAED,IAAM,aAAa,GAAG,UAAC,QAAgB;QACnC,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnE,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,UAAO,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAC;IAEF,OAAO;QACH,0BAA0B,EAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;KACtF,CAAC;AACN,CAAC;AAxCD,8BAwCC"}
|
package/package.json
CHANGED
package/src/bin/getSrcDirPath.ts
CHANGED
@@ -4,7 +4,7 @@ import { crawl } from "./tools/crawl";
|
|
4
4
|
import { join as pathJoin } from "path";
|
5
5
|
import { themeTypes } from "./keycloakify/generateFtl";
|
6
6
|
|
7
|
-
const
|
7
|
+
const themeSrcDirBasenames = ["keycloak-theme", "keycloak_theme"];
|
8
8
|
|
9
9
|
/** Can't catch error, if the directory isn't found, this function will just exit the process with an error message. */
|
10
10
|
export function getThemeSrcDirPath(params: { projectDirPath: string }) {
|
@@ -14,13 +14,13 @@ export function getThemeSrcDirPath(params: { projectDirPath: string }) {
|
|
14
14
|
|
15
15
|
const themeSrcDirPath: string | undefined = crawl({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" })
|
16
16
|
.map(fileRelativePath => {
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
for (const themeSrcDirBasename of themeSrcDirBasenames) {
|
18
|
+
const split = fileRelativePath.split(themeSrcDirBasename);
|
19
|
+
if (split.length === 2) {
|
20
|
+
return pathJoin(srcDirPath, split[0] + themeSrcDirBasename);
|
21
|
+
}
|
21
22
|
}
|
22
|
-
|
23
|
-
return pathJoin(srcDirPath, split[0] + themeSrcDirBasename);
|
23
|
+
return undefined;
|
24
24
|
})
|
25
25
|
.filter(exclude(undefined))[0];
|
26
26
|
|
@@ -38,7 +38,7 @@ export function getThemeSrcDirPath(params: { projectDirPath: string }) {
|
|
38
38
|
console.error(
|
39
39
|
[
|
40
40
|
"Can't locate your theme source directory. It should be either: ",
|
41
|
-
"src/ or src/keycloak-theme.",
|
41
|
+
"src/ or src/keycloak-theme or src/keycloak_theme.",
|
42
42
|
"Example in the starter: https://github.com/keycloakify/keycloakify-starter/tree/main/src/keycloak-theme"
|
43
43
|
].join("\n")
|
44
44
|
);
|
@@ -1,17 +1,15 @@
|
|
1
1
|
import { crawl } from "../../tools/crawl";
|
2
|
-
import { join as pathJoin } from "path";
|
2
|
+
import { join as pathJoin, sep as pathSep } from "path";
|
3
3
|
import * as fs from "fs";
|
4
4
|
import type { ThemeType } from "../generateFtl";
|
5
5
|
|
6
6
|
/** Assumes the theme type exists */
|
7
7
|
export function readStaticResourcesUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): {
|
8
8
|
resourcesCommonFilePaths: string[];
|
9
|
-
resourcesFilePaths: string[];
|
10
9
|
} {
|
11
10
|
const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params;
|
12
11
|
|
13
12
|
const resourcesCommonFilePaths = new Set<string>();
|
14
|
-
const resourcesFilePaths = new Set<string>();
|
15
13
|
|
16
14
|
for (const srcDirPath of [pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)]) {
|
17
15
|
const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
|
@@ -26,58 +24,53 @@ export function readStaticResourcesUsage(params: { keycloakifySrcDirPath: string
|
|
26
24
|
const wrap = readPaths({ rawSourceFile });
|
27
25
|
|
28
26
|
wrap.resourcesCommonFilePaths.forEach(filePath => resourcesCommonFilePaths.add(filePath));
|
29
|
-
wrap.resourcesFilePaths.forEach(filePath => resourcesFilePaths.add(filePath));
|
30
27
|
}
|
31
28
|
}
|
32
29
|
|
33
30
|
return {
|
34
|
-
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
|
35
|
-
"resourcesFilePaths": Array.from(resourcesFilePaths)
|
31
|
+
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
|
36
32
|
};
|
37
33
|
}
|
38
34
|
|
39
35
|
/** Exported for testing purpose */
|
40
36
|
export function readPaths(params: { rawSourceFile: string }): {
|
41
37
|
resourcesCommonFilePaths: string[];
|
42
|
-
resourcesFilePaths: string[];
|
43
38
|
} {
|
44
39
|
const { rawSourceFile } = params;
|
45
40
|
|
46
41
|
const resourcesCommonFilePaths = new Set<string>();
|
47
|
-
const resourcesFilePaths = new Set<string>();
|
48
42
|
|
49
|
-
|
50
|
-
const
|
43
|
+
{
|
44
|
+
const regexp = new RegExp(`resourcesCommonPath\\s*}([^\`]+)\``, "g");
|
51
45
|
|
52
|
-
|
53
|
-
const regexp = new RegExp(`resources${isCommon ? "Common" : ""}Path\\s*}([^\`]+)\``, "g");
|
46
|
+
const matches = [...rawSourceFile.matchAll(regexp)];
|
54
47
|
|
55
|
-
|
48
|
+
for (const match of matches) {
|
49
|
+
const filePath = match[1];
|
56
50
|
|
57
|
-
|
58
|
-
const filePath = match[1];
|
59
|
-
|
60
|
-
set.add(filePath);
|
61
|
-
}
|
51
|
+
resourcesCommonFilePaths.add(filePath);
|
62
52
|
}
|
53
|
+
}
|
63
54
|
|
64
|
-
|
65
|
-
|
55
|
+
{
|
56
|
+
const regexp = new RegExp(`resourcesCommonPath\\s*[+,]\\s*["']([^"'\`]+)["'\`]`, "g");
|
66
57
|
|
67
|
-
|
58
|
+
const matches = [...rawSourceFile.matchAll(regexp)];
|
68
59
|
|
69
|
-
|
70
|
-
|
60
|
+
for (const match of matches) {
|
61
|
+
const filePath = match[1];
|
71
62
|
|
72
|
-
|
73
|
-
}
|
63
|
+
resourcesCommonFilePaths.add(filePath);
|
74
64
|
}
|
75
65
|
}
|
76
66
|
|
77
|
-
const
|
67
|
+
const normalizePath = (filePath: string) => {
|
68
|
+
filePath = filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
69
|
+
filePath = filePath.replace(/\//g, pathSep);
|
70
|
+
return filePath;
|
71
|
+
};
|
78
72
|
|
79
73
|
return {
|
80
|
-
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(
|
81
|
-
"resourcesFilePaths": Array.from(resourcesFilePaths).map(removePrefixSlash)
|
74
|
+
"resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(normalizePath)
|
82
75
|
};
|
83
76
|
}
|