keycloakify 11.3.19 → 11.3.21

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.
Files changed (67) hide show
  1. package/bin/124.index.js +676 -0
  2. package/bin/356.index.js +700 -0
  3. package/bin/40.index.js +41 -21
  4. package/bin/{903.index.js → 450.index.js} +2 -680
  5. package/bin/453.index.js +143 -85
  6. package/bin/573.index.js +51 -24
  7. package/bin/{599.index.js → 735.index.js} +438 -121
  8. package/bin/786.index.js +129 -78
  9. package/bin/805.index.js +674 -0
  10. package/bin/854.index.js +68 -0
  11. package/bin/{780.index.js → 921.index.js} +168 -109
  12. package/bin/932.index.js +41 -21
  13. package/bin/97.index.js +125 -75
  14. package/bin/eject-file.d.ts +7 -0
  15. package/bin/keycloakify/generateResources/generateMessageProperties.d.ts +1 -1
  16. package/bin/keycloakify/generateResources/readFieldNameUsage.d.ts +1 -1
  17. package/bin/main.js +70 -7
  18. package/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.d.ts +12 -0
  19. package/bin/postinstall/index.d.ts +1 -0
  20. package/bin/postinstall/installUiModulesPeerDependencies.d.ts +11 -0
  21. package/bin/postinstall/managedGitignoreFile.d.ts +14 -0
  22. package/bin/postinstall/postinstall.d.ts +4 -0
  23. package/bin/postinstall/uiModuleMeta.d.ts +21 -0
  24. package/bin/shared/buildContext.d.ts +3 -0
  25. package/bin/shared/constants.d.ts +2 -1
  26. package/bin/shared/constants.js +2 -1
  27. package/bin/shared/constants.js.map +1 -1
  28. package/bin/shared/customHandler.d.ts +1 -1
  29. package/bin/shared/customHandler.js.map +1 -1
  30. package/bin/shared/exitIfUncommittedChanges.d.ts +3 -0
  31. package/bin/tools/crawlAsync.d.ts +6 -0
  32. package/bin/tools/getInstalledModuleDirPath.d.ts +5 -0
  33. package/bin/tools/listInstalledModules.d.ts +12 -0
  34. package/bin/tools/nodeModulesBinDirPath.d.ts +1 -0
  35. package/bin/tools/runPrettier.d.ts +17 -0
  36. package/package.json +34 -6
  37. package/src/bin/add-story.ts +28 -10
  38. package/src/bin/eject-file.ts +68 -0
  39. package/src/bin/eject-page.ts +51 -31
  40. package/src/bin/initialize-account-theme/initialize-account-theme.ts +4 -32
  41. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +2 -16
  42. package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +1 -1
  43. package/src/bin/keycloakify/generateResources/generateResources.ts +58 -26
  44. package/src/bin/keycloakify/generateResources/readFieldNameUsage.ts +1 -1
  45. package/src/bin/main.ts +50 -0
  46. package/src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts +73 -0
  47. package/src/bin/postinstall/index.ts +1 -0
  48. package/src/bin/postinstall/installUiModulesPeerDependencies.ts +158 -0
  49. package/src/bin/postinstall/managedGitignoreFile.ts +136 -0
  50. package/src/bin/postinstall/postinstall.ts +79 -0
  51. package/src/bin/postinstall/uiModuleMeta.ts +309 -0
  52. package/src/bin/shared/buildContext.ts +11 -5
  53. package/src/bin/shared/constants.ts +3 -1
  54. package/src/bin/shared/customHandler.ts +1 -0
  55. package/src/bin/shared/customHandler_delegate.ts +2 -27
  56. package/src/bin/shared/exitIfUncommittedChanges.ts +36 -0
  57. package/src/bin/tools/crawlAsync.ts +51 -0
  58. package/src/bin/tools/getInstalledModuleDirPath.ts +51 -0
  59. package/src/bin/tools/listInstalledModules.ts +131 -0
  60. package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
  61. package/src/bin/tools/npmInstall.ts +411 -15
  62. package/src/bin/tools/readThisNpmPackageVersion.ts +8 -0
  63. package/src/bin/tools/runPrettier.ts +106 -0
  64. package/src/bin/update-kc-gen.ts +28 -17
  65. package/vite-plugin/index.js +9237 -9163
  66. package/bin/tools/runFormat.d.ts +0 -3
  67. package/src/bin/tools/runFormat.ts +0 -76
@@ -0,0 +1,700 @@
1
+ "use strict";
2
+ exports.id = 356;
3
+ exports.ids = [356];
4
+ exports.modules = {
5
+
6
+ /***/ 6385:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
+ /* harmony export */ "X": () => (/* binding */ getUiModuleFileSourceCodeReadyToBeCopied)
11
+ /* harmony export */ });
12
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(48433);
13
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(73292);
14
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
15
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71017);
16
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
17
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
18
+ /* harmony import */ var _shared_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(173);
19
+
20
+
21
+
22
+
23
+
24
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)();
25
+ async function getUiModuleFileSourceCodeReadyToBeCopied(params) {
26
+ const { buildContext, uiModuleDirPath, fileRelativePath, isForEjection, uiModuleName, uiModuleVersion } = params;
27
+ let sourceCode = (await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile((0,path__WEBPACK_IMPORTED_MODULE_2__.join)(uiModuleDirPath, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .KEYCLOAK_THEME */ .PC, fileRelativePath))).toString("utf8");
28
+ const comment = (() => {
29
+ if (isForEjection) {
30
+ return [
31
+ `/*`,
32
+ ` * This file was ejected from ${uiModuleName} version ${uiModuleVersion}.`,
33
+ ` */`
34
+ ].join("\n");
35
+ }
36
+ else {
37
+ return [
38
+ `/*`,
39
+ ` *`,
40
+ ` * WARNING: Before modifying this file run the following command:`,
41
+ ` * `,
42
+ ` * $ npx keycloakify eject-file --file ${fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_2__.sep).join("/")}`,
43
+ ` * `,
44
+ ` * This file comes from ${uiModuleName} version ${uiModuleVersion}.`,
45
+ ` *`,
46
+ ` */`
47
+ ].join("\n");
48
+ }
49
+ })();
50
+ sourceCode = [comment, ``, sourceCode].join("\n");
51
+ const destFilePath = (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.themeSrcDirPath, fileRelativePath);
52
+ format: {
53
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .getIsPrettierAvailable */ .MT)())) {
54
+ break format;
55
+ }
56
+ sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .runPrettier */ .eY)({
57
+ filePath: destFilePath,
58
+ sourceCode
59
+ });
60
+ }
61
+ return Buffer.from(sourceCode, "utf8");
62
+ }
63
+ //# sourceMappingURL=getUiModuleFileSourceCodeReadyToBeCopied.js.map
64
+
65
+ /***/ }),
66
+
67
+ /***/ 36843:
68
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
69
+
70
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
71
+ /* harmony export */ "Y": () => (/* binding */ writeManagedGitignoreFile),
72
+ /* harmony export */ "w": () => (/* binding */ readManagedGitignoreFile)
73
+ /* harmony export */ });
74
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
75
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
76
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
77
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
78
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29041);
79
+ /* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
80
+ /* harmony import */ var _tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(84794);
81
+
82
+
83
+
84
+
85
+
86
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .h)();
87
+ const DELIMITER_START = `# === Ejected files start ===`;
88
+ const DELIMITER_END = `# === Ejected files end =====`;
89
+ async function writeManagedGitignoreFile(params) {
90
+ const { buildContext, uiModuleMetas, ejectedFilesRelativePaths } = params;
91
+ if (uiModuleMetas.length === 0) {
92
+ return;
93
+ }
94
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
95
+ const content_new = Buffer.from([
96
+ `# This file is managed by Keycloakify, do not edit it manually.`,
97
+ ``,
98
+ DELIMITER_START,
99
+ ...ejectedFilesRelativePaths
100
+ .map(fileRelativePath => fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/"))
101
+ .map(line => `# ${line}`),
102
+ DELIMITER_END,
103
+ ``,
104
+ ...uiModuleMetas
105
+ .map(uiModuleMeta => [
106
+ `# === ${uiModuleMeta.moduleName} v${uiModuleMeta.version} ===`,
107
+ ...uiModuleMeta.files
108
+ .map(({ fileRelativePath }) => fileRelativePath)
109
+ .filter(fileRelativePath => !ejectedFilesRelativePaths.includes(fileRelativePath))
110
+ .map(fileRelativePath => `/${fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/").replace(/^\.\//, "")}`),
111
+ ``
112
+ ])
113
+ .flat()
114
+ ].join("\n"), "utf8");
115
+ const content_current = await (async () => {
116
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
117
+ return undefined;
118
+ }
119
+ return await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath);
120
+ })();
121
+ if (content_current !== undefined && content_current.equals(content_new)) {
122
+ return;
123
+ }
124
+ create_dir: {
125
+ const dirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(filePath);
126
+ if (await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(dirPath)) {
127
+ break create_dir;
128
+ }
129
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(dirPath, { recursive: true });
130
+ }
131
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(filePath, content_new);
132
+ }
133
+ async function readManagedGitignoreFile(params) {
134
+ const { buildContext } = params;
135
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
136
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
137
+ return { ejectedFilesRelativePaths: [] };
138
+ }
139
+ const contentStr = (await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath)).toString("utf8");
140
+ const payload = (() => {
141
+ const index_start = contentStr.indexOf(DELIMITER_START);
142
+ const index_end = contentStr.indexOf(DELIMITER_END);
143
+ if (index_start === -1 || index_end === -1) {
144
+ return undefined;
145
+ }
146
+ return contentStr.slice(index_start + DELIMITER_START.length, index_end).trim();
147
+ })();
148
+ if (payload === undefined) {
149
+ return { ejectedFilesRelativePaths: [] };
150
+ }
151
+ const ejectedFilesRelativePaths = payload
152
+ .split("\n")
153
+ .map(line => line.trim())
154
+ .map(line => line.replace(/^# /, ""))
155
+ .filter(line => line !== "")
156
+ .map(line => (0,_tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__/* .getAbsoluteAndInOsFormatPath */ .c)({
157
+ cwd: buildContext.themeSrcDirPath,
158
+ pathIsh: line
159
+ }))
160
+ .map(filePath => (0,path__WEBPACK_IMPORTED_MODULE_1__.relative)(buildContext.themeSrcDirPath, filePath));
161
+ return { ejectedFilesRelativePaths };
162
+ }
163
+ //# sourceMappingURL=managedGitignoreFile.js.map
164
+
165
+ /***/ }),
166
+
167
+ /***/ 5038:
168
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
169
+
170
+
171
+ // EXPORTS
172
+ __webpack_require__.d(__webpack_exports__, {
173
+ "x": () => (/* binding */ computeHash),
174
+ "j": () => (/* binding */ getUiModuleMetas)
175
+ });
176
+
177
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
178
+ var assert = __webpack_require__(29041);
179
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
180
+ var id = __webpack_require__(38469);
181
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
182
+ var lib = __webpack_require__(52300);
183
+ // EXTERNAL MODULE: external "path"
184
+ var external_path_ = __webpack_require__(71017);
185
+ // EXTERNAL MODULE: external "fs/promises"
186
+ var promises_ = __webpack_require__(73292);
187
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/is.mjs
188
+ var is = __webpack_require__(16453);
189
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
190
+ var fs_existsAsync = __webpack_require__(43765);
191
+ // EXTERNAL MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js
192
+ var getInstalledModuleDirPath = __webpack_require__(21022);
193
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
194
+ var exclude = __webpack_require__(83101);
195
+ ;// CONCATENATED MODULE: ./dist/bin/tools/listInstalledModules.js
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ async function listInstalledModules(params) {
205
+ const { packageJsonFilePath, projectDirPath, filter } = params;
206
+ const parsedPackageJson = await readPackageJsonDependencies({
207
+ packageJsonFilePath
208
+ });
209
+ const uiModuleNames = [parsedPackageJson.dependencies, parsedPackageJson.devDependencies]
210
+ .filter((0,exclude/* exclude */.D)(undefined))
211
+ .map(obj => Object.keys(obj))
212
+ .flat()
213
+ .filter(moduleName => filter({ moduleName }));
214
+ const result = await Promise.all(uiModuleNames.map(async (moduleName) => {
215
+ const dirPath = await (0,getInstalledModuleDirPath/* getInstalledModuleDirPath */.p)({
216
+ moduleName,
217
+ packageJsonDirPath: (0,external_path_.dirname)(packageJsonFilePath),
218
+ projectDirPath
219
+ });
220
+ const { version, peerDependencies } = await readPackageJsonVersionAndPeerDependencies({
221
+ packageJsonFilePath: (0,external_path_.join)(dirPath, "package.json")
222
+ });
223
+ return { moduleName, version, peerDependencies, dirPath };
224
+ }));
225
+ return result;
226
+ }
227
+ const { readPackageJsonDependencies } = (() => {
228
+ const zParsedPackageJson = (() => {
229
+ const zTargetType = lib.z.object({
230
+ dependencies: lib.z.record(lib.z.string()).optional(),
231
+ devDependencies: lib.z.record(lib.z.string()).optional()
232
+ });
233
+ (0,assert/* assert */.h)();
234
+ return (0,id.id)(zTargetType);
235
+ })();
236
+ async function readPackageJsonDependencies(params) {
237
+ const { packageJsonFilePath } = params;
238
+ const parsedPackageJson = JSON.parse((await promises_.readFile(packageJsonFilePath)).toString("utf8"));
239
+ zParsedPackageJson.parse(parsedPackageJson);
240
+ (0,assert/* assert */.h)((0,is.is)(parsedPackageJson));
241
+ return parsedPackageJson;
242
+ }
243
+ return { readPackageJsonDependencies };
244
+ })();
245
+ const { readPackageJsonVersionAndPeerDependencies } = (() => {
246
+ const zParsedPackageJson = (() => {
247
+ const zTargetType = lib.z.object({
248
+ version: lib.z.string(),
249
+ peerDependencies: lib.z.record(lib.z.string()).optional()
250
+ });
251
+ (0,assert/* assert */.h)();
252
+ return (0,id.id)(zTargetType);
253
+ })();
254
+ async function readPackageJsonVersionAndPeerDependencies(params) {
255
+ var _a;
256
+ const { packageJsonFilePath } = params;
257
+ const parsedPackageJson = JSON.parse((await promises_.readFile(packageJsonFilePath)).toString("utf8"));
258
+ zParsedPackageJson.parse(parsedPackageJson);
259
+ (0,assert/* assert */.h)((0,is.is)(parsedPackageJson));
260
+ return {
261
+ version: parsedPackageJson.version,
262
+ peerDependencies: (_a = parsedPackageJson.peerDependencies) !== null && _a !== void 0 ? _a : {}
263
+ };
264
+ }
265
+ return { readPackageJsonVersionAndPeerDependencies };
266
+ })();
267
+ //# sourceMappingURL=listInstalledModules.js.map
268
+ ;// CONCATENATED MODULE: ./dist/bin/tools/crawlAsync.js
269
+
270
+
271
+
272
+ /** List all files in a given directory return paths relative to the dir_path */
273
+ async function crawlAsync(params) {
274
+ const { dirPath, returnedPathsType, onFileFound } = params;
275
+ await crawlAsyncRec({
276
+ dirPath,
277
+ onFileFound: async ({ filePath }) => {
278
+ switch (returnedPathsType) {
279
+ case "absolute":
280
+ await onFileFound(filePath);
281
+ return;
282
+ case "relative to dirPath":
283
+ await onFileFound((0,external_path_.relative)(dirPath, filePath));
284
+ return;
285
+ }
286
+ (0,assert/* assert */.h)();
287
+ }
288
+ });
289
+ }
290
+ async function crawlAsyncRec(params) {
291
+ const { dirPath, onFileFound } = params;
292
+ await Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
293
+ const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
294
+ const isDirectory = await promises_.lstat(fileOrDirPath)
295
+ .then(stat => stat.isDirectory());
296
+ if (isDirectory) {
297
+ await crawlAsyncRec({ dirPath: fileOrDirPath, onFileFound });
298
+ return;
299
+ }
300
+ await onFileFound({ filePath: fileOrDirPath });
301
+ }));
302
+ }
303
+ //# sourceMappingURL=crawlAsync.js.map
304
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
305
+ var runPrettier = __webpack_require__(48433);
306
+ // EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
307
+ var readThisNpmPackageVersion = __webpack_require__(64795);
308
+ // EXTERNAL MODULE: ./dist/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.js
309
+ var getUiModuleFileSourceCodeReadyToBeCopied = __webpack_require__(6385);
310
+ // EXTERNAL MODULE: external "crypto"
311
+ var external_crypto_ = __webpack_require__(6113);
312
+ // EXTERNAL MODULE: ./dist/bin/shared/constants.js
313
+ var constants = __webpack_require__(173);
314
+ ;// CONCATENATED MODULE: ./dist/bin/postinstall/uiModuleMeta.js
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+ const zUiModuleMeta = (() => {
331
+ const zTargetType = lib.z.object({
332
+ moduleName: lib.z.string(),
333
+ version: lib.z.string(),
334
+ files: lib.z.array(lib.z.object({
335
+ fileRelativePath: lib.z.string(),
336
+ hash: lib.z.string(),
337
+ copyableFilePath: lib.z.string()
338
+ })),
339
+ peerDependencies: lib.z.record(lib.z.string())
340
+ });
341
+ (0,assert/* assert */.h)();
342
+ return (0,id.id)(zTargetType);
343
+ })();
344
+ const zParsedCacheFile = (() => {
345
+ const zTargetType = lib.z.object({
346
+ keycloakifyVersion: lib.z.string(),
347
+ prettierConfigHash: lib.z.union([lib.z.string(), lib.z["null"]()]),
348
+ thisFilePath: lib.z.string(),
349
+ uiModuleMetas: lib.z.array(zUiModuleMeta)
350
+ });
351
+ (0,assert/* assert */.h)();
352
+ return (0,id.id)(zTargetType);
353
+ })();
354
+ const CACHE_FILE_RELATIVE_PATH = (0,external_path_.join)("ui-modules", "cache.json");
355
+ (0,assert/* assert */.h)();
356
+ async function getUiModuleMetas(params) {
357
+ const { buildContext } = params;
358
+ const cacheFilePath = (0,external_path_.join)(buildContext.cacheDirPath, CACHE_FILE_RELATIVE_PATH);
359
+ const keycloakifyVersion = (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)();
360
+ const prettierConfigHash = await (async () => {
361
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
362
+ return null;
363
+ }
364
+ const { configHash } = await (0,runPrettier/* getPrettier */.LG)();
365
+ return configHash;
366
+ })();
367
+ const installedUiModules = await (async () => {
368
+ const installedModulesWithKeycloakifyInTheName = await listInstalledModules({
369
+ packageJsonFilePath: buildContext.packageJsonFilePath,
370
+ projectDirPath: buildContext.packageJsonFilePath,
371
+ filter: ({ moduleName }) => moduleName.includes("keycloakify") && moduleName !== "keycloakify"
372
+ });
373
+ return (await Promise.all(installedModulesWithKeycloakifyInTheName.map(async (entry) => {
374
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC)))) {
375
+ return undefined;
376
+ }
377
+ return entry;
378
+ }))).filter((0,exclude/* exclude */.D)(undefined));
379
+ })();
380
+ const cacheContent = await (async () => {
381
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
382
+ return undefined;
383
+ }
384
+ return await promises_.readFile(cacheFilePath);
385
+ })();
386
+ const uiModuleMetas_cacheUpToDate = await (async () => {
387
+ const parsedCacheFile = await (async () => {
388
+ if (cacheContent === undefined) {
389
+ return undefined;
390
+ }
391
+ const cacheContentStr = cacheContent.toString("utf8");
392
+ let parsedCacheFile;
393
+ try {
394
+ parsedCacheFile = JSON.parse(cacheContentStr);
395
+ }
396
+ catch (_a) {
397
+ return undefined;
398
+ }
399
+ try {
400
+ zParsedCacheFile.parse(parsedCacheFile);
401
+ }
402
+ catch (_b) {
403
+ return undefined;
404
+ }
405
+ (0,assert/* assert */.h)((0,is.is)(parsedCacheFile));
406
+ return parsedCacheFile;
407
+ })();
408
+ if (parsedCacheFile === undefined) {
409
+ return [];
410
+ }
411
+ if (parsedCacheFile.keycloakifyVersion !== keycloakifyVersion) {
412
+ return [];
413
+ }
414
+ if (parsedCacheFile.prettierConfigHash !== prettierConfigHash) {
415
+ return [];
416
+ }
417
+ if (parsedCacheFile.thisFilePath !== cacheFilePath) {
418
+ return [];
419
+ }
420
+ const uiModuleMetas_cacheUpToDate = parsedCacheFile.uiModuleMetas.filter(uiModuleMeta => {
421
+ const correspondingInstalledUiModule = installedUiModules.find(installedUiModule => installedUiModule.moduleName === uiModuleMeta.moduleName);
422
+ if (correspondingInstalledUiModule === undefined) {
423
+ return false;
424
+ }
425
+ return correspondingInstalledUiModule.version === uiModuleMeta.version;
426
+ });
427
+ return uiModuleMetas_cacheUpToDate;
428
+ })();
429
+ const uiModuleMetas = await Promise.all(installedUiModules.map(async ({ moduleName, version, peerDependencies, dirPath }) => {
430
+ use_cache: {
431
+ const uiModuleMeta_cache = uiModuleMetas_cacheUpToDate.find(uiModuleMeta => uiModuleMeta.moduleName === moduleName);
432
+ if (uiModuleMeta_cache === undefined) {
433
+ break use_cache;
434
+ }
435
+ return uiModuleMeta_cache;
436
+ }
437
+ const files = [];
438
+ {
439
+ const srcDirPath = (0,external_path_.join)(dirPath, constants/* KEYCLOAK_THEME */.PC);
440
+ await crawlAsync({
441
+ dirPath: srcDirPath,
442
+ returnedPathsType: "relative to dirPath",
443
+ onFileFound: async (fileRelativePath) => {
444
+ const sourceCode = await (0,getUiModuleFileSourceCodeReadyToBeCopied/* getUiModuleFileSourceCodeReadyToBeCopied */.X)({
445
+ buildContext,
446
+ fileRelativePath,
447
+ isForEjection: false,
448
+ uiModuleDirPath: dirPath,
449
+ uiModuleName: moduleName,
450
+ uiModuleVersion: version
451
+ });
452
+ const hash = computeHash(sourceCode);
453
+ const copyableFilePath = (0,external_path_.join)((0,external_path_.dirname)(cacheFilePath), constants/* KEYCLOAK_THEME */.PC, fileRelativePath);
454
+ {
455
+ const dirPath = (0,external_path_.dirname)(copyableFilePath);
456
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
457
+ await promises_.mkdir(dirPath, { recursive: true });
458
+ }
459
+ }
460
+ promises_.writeFile(copyableFilePath, sourceCode);
461
+ files.push({
462
+ fileRelativePath,
463
+ hash,
464
+ copyableFilePath
465
+ });
466
+ }
467
+ });
468
+ }
469
+ return (0,id.id)({
470
+ moduleName,
471
+ version,
472
+ files,
473
+ peerDependencies
474
+ });
475
+ }));
476
+ update_cache: {
477
+ const parsedCacheFile = (0,id.id)({
478
+ keycloakifyVersion,
479
+ prettierConfigHash,
480
+ thisFilePath: cacheFilePath,
481
+ uiModuleMetas
482
+ });
483
+ const cacheContent_new = Buffer.from(JSON.stringify(parsedCacheFile, null, 2), "utf8");
484
+ if (cacheContent !== undefined && cacheContent_new.equals(cacheContent)) {
485
+ break update_cache;
486
+ }
487
+ create_dir: {
488
+ const dirPath = (0,external_path_.dirname)(cacheFilePath);
489
+ if (await (0,fs_existsAsync/* existsAsync */.o)(dirPath)) {
490
+ break create_dir;
491
+ }
492
+ await promises_.mkdir(dirPath, { recursive: true });
493
+ }
494
+ await promises_.writeFile(cacheFilePath, cacheContent_new);
495
+ }
496
+ return uiModuleMetas;
497
+ }
498
+ function computeHash(data) {
499
+ return external_crypto_.createHash("sha256").update(data).digest("hex");
500
+ }
501
+ //# sourceMappingURL=uiModuleMeta.js.map
502
+
503
+ /***/ }),
504
+
505
+ /***/ 43765:
506
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
507
+
508
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
509
+ /* harmony export */ "o": () => (/* binding */ existsAsync)
510
+ /* harmony export */ });
511
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
512
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
513
+
514
+ async function existsAsync(path) {
515
+ try {
516
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
517
+ return true;
518
+ }
519
+ catch (error) {
520
+ if (error.code === "ENOENT")
521
+ return false;
522
+ throw error;
523
+ }
524
+ }
525
+ //# sourceMappingURL=fs.existsAsync.js.map
526
+
527
+ /***/ }),
528
+
529
+ /***/ 21022:
530
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
531
+
532
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
533
+ /* harmony export */ "p": () => (/* binding */ getInstalledModuleDirPath)
534
+ /* harmony export */ });
535
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
536
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
537
+ /* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(43765);
538
+ /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(32081);
539
+ /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_2__);
540
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
541
+
542
+
543
+
544
+
545
+ async function getInstalledModuleDirPath(params) {
546
+ const { moduleName, packageJsonDirPath, projectDirPath } = params;
547
+ common_case: {
548
+ const dirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(...[packageJsonDirPath, "node_modules", ...moduleName.split("/")]);
549
+ if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_1__/* .existsAsync */ .o)(dirPath))) {
550
+ break common_case;
551
+ }
552
+ return dirPath;
553
+ }
554
+ node_modules_at_root_case: {
555
+ if (projectDirPath === packageJsonDirPath) {
556
+ break node_modules_at_root_case;
557
+ }
558
+ const dirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(...[projectDirPath, "node_modules", ...moduleName.split("/")]);
559
+ if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_1__/* .existsAsync */ .o)(dirPath))) {
560
+ break node_modules_at_root_case;
561
+ }
562
+ return dirPath;
563
+ }
564
+ const dirPath = child_process__WEBPACK_IMPORTED_MODULE_2__.execSync(`npm list ${moduleName}`, {
565
+ cwd: packageJsonDirPath
566
+ })
567
+ .toString("utf8")
568
+ .trim();
569
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(dirPath !== "");
570
+ return dirPath;
571
+ }
572
+ //# sourceMappingURL=getInstalledModuleDirPath.js.map
573
+
574
+ /***/ }),
575
+
576
+ /***/ 73776:
577
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
578
+
579
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
580
+ /* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
581
+ /* harmony export */ });
582
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
583
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
584
+
585
+ let cache = undefined;
586
+ function getNodeModulesBinDirPath() {
587
+ if (cache !== undefined) {
588
+ return cache;
589
+ }
590
+ const binPath = process.argv[1];
591
+ const segments = [".bin"];
592
+ let foundNodeModules = false;
593
+ for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
594
+ skip_segment: {
595
+ if (foundNodeModules) {
596
+ break skip_segment;
597
+ }
598
+ if (segment === "node_modules") {
599
+ foundNodeModules = true;
600
+ break skip_segment;
601
+ }
602
+ continue;
603
+ }
604
+ segments.unshift(segment);
605
+ }
606
+ const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
607
+ cache = nodeModulesBinDirPath;
608
+ return nodeModulesBinDirPath;
609
+ }
610
+ //# sourceMappingURL=nodeModulesBinDirPath.js.map
611
+
612
+ /***/ }),
613
+
614
+ /***/ 48433:
615
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
616
+
617
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
618
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
619
+ /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
620
+ /* harmony export */ "eY": () => (/* binding */ runPrettier)
621
+ /* harmony export */ });
622
+ /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
623
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
624
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
625
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
626
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
627
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38469);
628
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
629
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
630
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
631
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
632
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(undefined);
641
+ async function getIsPrettierAvailable() {
642
+ var _a;
643
+ if (getIsPrettierAvailable.cache !== undefined) {
644
+ return getIsPrettierAvailable.cache;
645
+ }
646
+ const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)();
647
+ const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
648
+ const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
649
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
650
+ getIsPrettierAvailable.cache = isPrettierAvailable;
651
+ return isPrettierAvailable;
652
+ }
653
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(undefined);
654
+ async function getPrettier() {
655
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
656
+ if (getPrettier.cache !== undefined) {
657
+ return getPrettier.cache;
658
+ }
659
+ const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
660
+ const configHash = await (async () => {
661
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
662
+ if (configFilePath === null) {
663
+ return "";
664
+ }
665
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
666
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
667
+ })();
668
+ const prettierAndConfig = {
669
+ prettier,
670
+ configHash
671
+ };
672
+ getPrettier.cache = prettierAndConfig;
673
+ return prettierAndConfig;
674
+ }
675
+ async function runPrettier(params) {
676
+ const { sourceCode, filePath } = params;
677
+ let formattedSourceCode;
678
+ try {
679
+ const { prettier } = await getPrettier();
680
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
681
+ resolveConfig: true
682
+ });
683
+ if (ignored) {
684
+ return sourceCode;
685
+ }
686
+ const config = await prettier.resolveConfig(filePath);
687
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
688
+ }
689
+ catch (error) {
690
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
691
+ throw error;
692
+ }
693
+ return formattedSourceCode;
694
+ }
695
+ //# sourceMappingURL=runPrettier.js.map
696
+
697
+ /***/ })
698
+
699
+ };
700
+ ;