keycloakify 11.8.30 → 11.8.32

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/bin/97.index.js CHANGED
@@ -3,1294 +3,101 @@ exports.id = 97;
3
3
  exports.ids = [97];
4
4
  exports.modules = {
5
5
 
6
- /***/ 64097:
6
+ /***/ 77372:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
- // ESM COMPAT FLAG
10
- __webpack_require__.r(__webpack_exports__);
11
9
 
12
10
  // EXPORTS
13
11
  __webpack_require__.d(__webpack_exports__, {
14
- "command": () => (/* reexport */ command)
12
+ "x": () => (/* binding */ computeHash),
13
+ "f": () => (/* binding */ getExtensionModuleMetas)
15
14
  });
16
15
 
17
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
18
- var exclude = __webpack_require__(83101);
19
- // EXTERNAL MODULE: ./dist/bin/shared/constants.js
20
- var constants = __webpack_require__(173);
21
- // EXTERNAL MODULE: ./dist/bin/tools/SemVer.js
22
- var SemVer = __webpack_require__(12171);
23
16
  // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
24
17
  var assert = __webpack_require__(29041);
25
- // EXTERNAL MODULE: external "fs"
26
- var external_fs_ = __webpack_require__(57147);
27
- var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
18
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
19
+ var id = __webpack_require__(38469);
20
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
21
+ var lib = __webpack_require__(52300);
28
22
  // EXTERNAL MODULE: external "path"
29
23
  var external_path_ = __webpack_require__(71017);
30
- // EXTERNAL MODULE: external "child_process"
31
- var external_child_process_ = __webpack_require__(32081);
32
- var external_child_process_default = /*#__PURE__*/__webpack_require__.n(external_child_process_);
33
- // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
34
- var source = __webpack_require__(78818);
35
- var source_default = /*#__PURE__*/__webpack_require__.n(source);
36
- // EXTERNAL MODULE: ./node_modules/chokidar/index.js
37
- var chokidar = __webpack_require__(42677);
38
- // EXTERNAL MODULE: ./node_modules/powerhooks/tools/waitForDebounce.js
39
- var tools_waitForDebounce = __webpack_require__(18721);
40
- // EXTERNAL MODULE: ./dist/bin/tools/getThisCodebaseRootDirPath.js
41
- var getThisCodebaseRootDirPath = __webpack_require__(58822);
42
- // EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
43
- var getAbsoluteAndInOsFormatPath = __webpack_require__(84794);
44
- // EXTERNAL MODULE: ./node_modules/cli-select/dist/index.js
45
- var dist = __webpack_require__(99398);
46
- var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
47
- // EXTERNAL MODULE: ./node_modules/run-exclusive/lib/runExclusive.js
48
- var runExclusive = __webpack_require__(81708);
49
24
  // EXTERNAL MODULE: external "fs/promises"
50
25
  var promises_ = __webpack_require__(73292);
51
- var promises_default = /*#__PURE__*/__webpack_require__.n(promises_);
52
- // EXTERNAL MODULE: ./node_modules/yauzl/index.js
53
- var yauzl = __webpack_require__(78781);
54
- // EXTERNAL MODULE: external "stream"
55
- var external_stream_ = __webpack_require__(12781);
56
- var external_stream_default = /*#__PURE__*/__webpack_require__.n(external_stream_);
57
- // EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
58
- var Deferred = __webpack_require__(50689);
59
26
  // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
60
27
  var fs_existsAsync = __webpack_require__(43765);
61
- ;// CONCATENATED MODULE: ./dist/bin/tools/extractArchive.js
62
-
63
-
64
-
28
+ // EXTERNAL MODULE: ./dist/bin/tools/listInstalledModules.js
29
+ var listInstalledModules = __webpack_require__(75564);
30
+ ;// CONCATENATED MODULE: ./dist/bin/tools/crawlAsync.js
65
31
 
66
32
 
67
33
 
68
-
69
- async function extractArchive(params) {
70
- const { archiveFilePath, onArchiveFile } = params;
71
- const zipFile = await new Promise((resolve, reject) => {
72
- yauzl.open(archiveFilePath, { lazyEntries: true }, async (error, zipFile) => {
73
- if (error) {
74
- reject(error);
75
- return;
76
- }
77
- resolve(zipFile);
78
- });
79
- });
80
- const dDone = new Deferred.Deferred();
81
- zipFile.once("end", () => {
82
- zipFile.close();
83
- dDone.resolve();
84
- });
85
- const writeFile = async (entry, params) => {
86
- const { filePath, modifiedData } = params;
87
- {
88
- const dirPath = (0,external_path_.dirname)(filePath);
89
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
90
- await promises_default().mkdir(dirPath, { recursive: true });
91
- }
92
- }
93
- if (modifiedData !== undefined) {
94
- await promises_default().writeFile(filePath, modifiedData);
95
- return;
96
- }
97
- const readStream = await new Promise(resolve => zipFile.openReadStream(entry, async (error, readStream) => {
98
- if (error) {
99
- dDone.reject(error);
100
- return;
101
- }
102
- resolve(readStream);
103
- }));
104
- const dDoneWithFile = new Deferred.Deferred();
105
- external_stream_default().pipeline(readStream, external_fs_default().createWriteStream(filePath), error => {
106
- if (error) {
107
- dDone.reject(error);
108
- return;
109
- }
110
- dDoneWithFile.resolve();
111
- });
112
- await dDoneWithFile.pr;
113
- };
114
- const readFile = (entry) => new Promise(resolve => zipFile.openReadStream(entry, async (error, readStream) => {
115
- if (error) {
116
- dDone.reject(error);
117
- return;
118
- }
119
- const chunks = [];
120
- readStream.on("data", chunk => {
121
- chunks.push(chunk);
122
- });
123
- readStream.on("end", () => {
124
- resolve(Buffer.concat(chunks));
125
- });
126
- readStream.on("error", error => {
127
- dDone.reject(error);
128
- });
129
- }));
130
- zipFile.on("entry", async (entry) => {
131
- handle_file: {
132
- // NOTE: Skip directories
133
- if (entry.fileName.endsWith("/")) {
134
- break handle_file;
135
- }
136
- let hasEarlyExitBeenCalled = false;
137
- await onArchiveFile({
138
- relativeFilePathInArchive: entry.fileName.split("/").join(external_path_.sep),
139
- readFile: () => readFile(entry),
140
- writeFile: params => writeFile(entry, params),
141
- earlyExit: () => {
142
- hasEarlyExitBeenCalled = true;
143
- }
144
- });
145
- if (hasEarlyExitBeenCalled) {
146
- zipFile.close();
147
- dDone.resolve();
148
- return;
34
+ /** List all files in a given directory return paths relative to the dir_path */
35
+ async function crawlAsync(params) {
36
+ const { dirPath, returnedPathsType, onFileFound } = params;
37
+ await crawlAsyncRec({
38
+ dirPath,
39
+ onFileFound: async ({ filePath }) => {
40
+ switch (returnedPathsType) {
41
+ case "absolute":
42
+ await onFileFound(filePath);
43
+ return;
44
+ case "relative to dirPath":
45
+ await onFileFound((0,external_path_.relative)(dirPath, filePath));
46
+ return;
149
47
  }
150
- }
151
- zipFile.readEntry();
152
- });
153
- zipFile.readEntry();
154
- await dDone.pr;
155
- }
156
- //# sourceMappingURL=extractArchive.js.map
157
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
158
- var id = __webpack_require__(38469);
159
- // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
160
- var lib = __webpack_require__(52300);
161
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/appBuild.js
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
- (0,assert/* assert */.h)();
173
- async function appBuild(params) {
174
- var _a;
175
- const { buildContext } = params;
176
- const { parsedPackageJson } = (() => {
177
- const zParsedPackageJson = (() => {
178
- const zTargetType = lib.z.object({
179
- scripts: lib.z.record(lib.z.string()).optional()
180
- });
181
48
  (0,assert/* assert */.h)();
182
- return (0,id.id)(zTargetType);
183
- })();
184
- const parsedPackageJson = JSON.parse(external_fs_.readFileSync(buildContext.packageJsonFilePath).toString("utf8"));
185
- zParsedPackageJson.parse(parsedPackageJson);
186
- (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
187
- return { parsedPackageJson };
188
- })();
189
- const entries = Object.entries((_a = parsedPackageJson.scripts) !== null && _a !== void 0 ? _a : {}).filter(([, scriptCommand]) => scriptCommand.includes("keycloakify build"));
190
- if (entries.length === 0) {
191
- console.log(source_default().red([
192
- `You should have a script in your package.json at ${(0,external_path_.relative)(process.cwd(), (0,external_path_.dirname)(buildContext.packageJsonFilePath))}`,
193
- `that includes the 'keycloakify build' command`
194
- ].join(" ")));
195
- process.exit(-1);
196
- }
197
- const entry = entries.length === 1
198
- ? entries[0]
199
- : entries.find(([scriptName]) => scriptName === "build-keycloak-theme");
200
- if (entry === undefined) {
201
- console.log(source_default().red("There's multiple candidate script for building your app, name one 'build-keycloak-theme'"));
202
- process.exit(-1);
203
- }
204
- const [scriptName, scriptCommand] = entry;
205
- const { appBuildSubCommands } = (() => {
206
- const appBuildSubCommands = [];
207
- for (const subCmd of scriptCommand.split("&&").map(s => s.trim())) {
208
- if (subCmd.includes("keycloakify build")) {
209
- break;
210
- }
211
- appBuildSubCommands.push(subCmd);
212
- }
213
- return { appBuildSubCommands };
214
- })();
215
- if (appBuildSubCommands.length === 0) {
216
- console.log(source_default().red(`Your ${scriptName} script should look like "... && keycloakify build ..."`));
217
- process.exit(-1);
218
- }
219
- common_case: {
220
- if (appBuildSubCommands.length !== 1) {
221
- break common_case;
222
- }
223
- const [appBuildSubCommand] = appBuildSubCommands;
224
- const isNpmRunBuild = (() => {
225
- for (const packageManager of ["npm", "yarn", "pnpm", "bun", "deno"]) {
226
- for (const doUseRun of [true, false]) {
227
- if (`${packageManager}${doUseRun ? " run " : " "}build` ===
228
- appBuildSubCommand) {
229
- return true;
230
- }
231
- }
232
- }
233
- return false;
234
- })();
235
- if (!isNpmRunBuild) {
236
- break common_case;
237
- }
238
- const { scripts } = parsedPackageJson;
239
- (0,assert/* assert */.h)(scripts !== undefined);
240
- const buildCmd = scripts.build;
241
- if (buildCmd !== "tsc && vite build") {
242
- break common_case;
243
- }
244
- if (scripts.prebuild !== undefined) {
245
- break common_case;
246
- }
247
- if (scripts.postbuild !== undefined) {
248
- break common_case;
249
- }
250
- const dIsSuccess = new Deferred.Deferred();
251
- console.log(source_default().blue("$ npx vite build"));
252
- const child = external_child_process_.spawn("npx", ["vite", "build"], {
253
- cwd: buildContext.projectDirPath,
254
- shell: true
255
- });
256
- child.stdout.on("data", data => {
257
- if (data.toString("utf8").includes("gzip:")) {
258
- return;
259
- }
260
- process.stdout.write(data);
261
- });
262
- child.stderr.on("data", data => process.stderr.write(data));
263
- child.on("exit", code => dIsSuccess.resolve(code === 0));
264
- const isSuccess = await dIsSuccess.pr;
265
- return { isAppBuildSuccess: isSuccess };
266
- }
267
- let commandCwd = (0,external_path_.dirname)(buildContext.packageJsonFilePath);
268
- for (const subCommand of appBuildSubCommands) {
269
- const dIsSuccess = new Deferred.Deferred();
270
- const [command, ...args] = subCommand.split(" ");
271
- if (command === "cd") {
272
- const [pathIsh] = args;
273
- commandCwd = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
274
- pathIsh,
275
- cwd: commandCwd
276
- });
277
- continue;
278
- }
279
- console.log(source_default().blue(`$ ${subCommand}`));
280
- const child = external_child_process_.spawn(command, args, {
281
- cwd: commandCwd,
282
- env: Object.assign(Object.assign({}, process.env), { PATH: (() => {
283
- var _a;
284
- const separator = external_path_.sep === "/" ? ":" : ";";
285
- return [
286
- (0,external_path_.join)((0,external_path_.dirname)(buildContext.packageJsonFilePath), "node_modules", ".bin"),
287
- ...((_a = process.env.PATH) !== null && _a !== void 0 ? _a : "").split(separator)
288
- ].join(separator);
289
- })() }),
290
- shell: true
291
- });
292
- child.stdout.on("data", data => process.stdout.write(data));
293
- child.stderr.on("data", data => process.stderr.write(data));
294
- child.on("exit", code => dIsSuccess.resolve(code === 0));
295
- const isSuccess = await dIsSuccess.pr;
296
- if (!isSuccess) {
297
- return { isAppBuildSuccess: false };
298
49
  }
299
- }
300
- return { isAppBuildSuccess: true };
301
- }
302
- //# sourceMappingURL=appBuild.js.map
303
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/keycloakifyBuild.js
304
-
305
-
306
-
307
-
308
-
309
- (0,assert/* assert */.h)();
310
- async function keycloakifyBuild(params) {
311
- const { buildForKeycloakMajorVersionNumber, buildContext } = params;
312
- const dResult = new Deferred.Deferred();
313
- console.log(source_default().blue("$ npx keycloakify build"));
314
- const child = external_child_process_.spawn("npx", ["keycloakify", "build"], {
315
- cwd: buildContext.projectDirPath,
316
- env: Object.assign(Object.assign({}, process.env), { [constants/* BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME */.ac]: `${buildForKeycloakMajorVersionNumber}` }),
317
- shell: true
318
50
  });
319
- child.stdout.on("data", data => process.stdout.write(data));
320
- child.stderr.on("data", data => process.stderr.write(data));
321
- child.on("exit", code => dResult.resolve({ isSuccess: code === 0 }));
322
- const { isSuccess } = await dResult.pr;
323
- return { isKeycloakifyBuildSuccess: isSuccess };
324
- }
325
- //# sourceMappingURL=keycloakifyBuild.js.map
326
- // EXTERNAL MODULE: ./dist/bin/tools/isInside.js
327
- var isInside = __webpack_require__(90665);
328
- ;// CONCATENATED MODULE: ./dist/bin/tools/fs.rm.js
329
-
330
-
331
-
332
- /**
333
- * Polyfill of fs.rm(dirPath, { "recursive": true })
334
- * For older version of Node
335
- */
336
- async function rm(dirPath, options) {
337
- if (SemVer/* SemVer.compare */.h.compare(SemVer/* SemVer.parse */.h.parse(process.version), SemVer/* SemVer.parse */.h.parse("14.14.0")) > 0) {
338
- return promises_.rm(dirPath, options);
339
- }
340
- const { force = true } = options;
341
- if (force && !(await checkDirExists(dirPath))) {
342
- return;
343
- }
344
- const removeDir_rec = async (dirPath) => Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
345
- const fileOrDirpath = (0,external_path_.join)(dirPath, basename);
346
- if ((await promises_.lstat(fileOrDirpath)).isDirectory()) {
347
- await removeDir_rec(fileOrDirpath);
348
- }
349
- else {
350
- await promises_.unlink(fileOrDirpath);
351
- }
352
- }));
353
- await removeDir_rec(dirPath);
354
- }
355
- async function checkDirExists(dirPath) {
356
- try {
357
- await promises_.access(dirPath, promises_.constants.F_OK);
358
- return true;
359
- }
360
- catch (_a) {
361
- return false;
362
- }
363
- }
364
- //# sourceMappingURL=fs.rm.js.map
365
- // EXTERNAL MODULE: ./node_modules/make-fetch-happen/lib/index.js
366
- var make_fetch_happen_lib = __webpack_require__(9525);
367
- var lib_default = /*#__PURE__*/__webpack_require__.n(make_fetch_happen_lib);
368
- // EXTERNAL MODULE: external "crypto"
369
- var external_crypto_ = __webpack_require__(6113);
370
- ;// CONCATENATED MODULE: ./dist/bin/tools/downloadAndExtractArchive.js
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
- async function downloadAndExtractArchive(params) {
380
- var _a;
381
- const { url, uniqueIdOfOnArchiveFile, onArchiveFile, cacheDirPath, fetchOptions } = params;
382
- const archiveFileBasename = url.split("?")[0].split("/").reverse()[0];
383
- const archiveFilePath = (0,external_path_.join)(cacheDirPath, archiveFileBasename);
384
- download: {
385
- await (0,promises_.mkdir)((0,external_path_.dirname)(archiveFilePath), { recursive: true });
386
- if (await (0,fs_existsAsync/* existsAsync */.o)(archiveFilePath)) {
387
- const isDownloaded = await SuccessTracker.getIsDownloaded({
388
- cacheDirPath,
389
- archiveFileBasename
390
- });
391
- if (isDownloaded) {
392
- break download;
393
- }
394
- await (0,promises_.unlink)(archiveFilePath);
395
- await SuccessTracker.removeFromDownloaded({
396
- cacheDirPath,
397
- archiveFileBasename
398
- });
399
- }
400
- const response = await lib_default()(url, fetchOptions);
401
- (_a = response.body) === null || _a === void 0 ? void 0 : _a.setMaxListeners(Number.MAX_VALUE);
402
- (0,assert/* assert */.h)(typeof response.body !== "undefined" && response.body != null);
403
- await (0,promises_.writeFile)(archiveFilePath, response.body);
404
- await SuccessTracker.markAsDownloaded({
405
- cacheDirPath,
406
- archiveFileBasename
407
- });
408
- }
409
- const extractDirBasename = `${archiveFileBasename.replace(/\.([^.]+)$/, (...[, ext]) => `_${ext}`)}_${uniqueIdOfOnArchiveFile}_${external_crypto_.createHash("sha256")
410
- .update(onArchiveFile.toString())
411
- .digest("hex")
412
- .substring(0, 5)}`;
413
- await Promise.all((await (0,promises_.readdir)(cacheDirPath))
414
- .filter((() => {
415
- const prefix = extractDirBasename
416
- .split("_")
417
- .reverse()
418
- .slice(1)
419
- .reverse()
420
- .join("_");
421
- return basename => basename !== extractDirBasename && basename.startsWith(prefix);
422
- })())
423
- .map(async (extractDirBasename) => {
424
- await rm((0,external_path_.join)(cacheDirPath, extractDirBasename), {
425
- recursive: true
426
- });
427
- await SuccessTracker.removeFromExtracted({
428
- cacheDirPath,
429
- extractDirBasename
430
- });
431
- }));
432
- const extractedDirPath = (0,external_path_.join)(cacheDirPath, extractDirBasename);
433
- extract_and_transform: {
434
- if (await (0,fs_existsAsync/* existsAsync */.o)(extractedDirPath)) {
435
- const isExtracted = await SuccessTracker.getIsExtracted({
436
- cacheDirPath,
437
- extractDirBasename
438
- });
439
- if (isExtracted) {
440
- break extract_and_transform;
441
- }
442
- await rm(extractedDirPath, { recursive: true });
443
- await SuccessTracker.removeFromExtracted({
444
- cacheDirPath,
445
- extractDirBasename
446
- });
447
- }
448
- await extractArchive({
449
- archiveFilePath,
450
- onArchiveFile: async ({ relativeFilePathInArchive, readFile, writeFile }) => onArchiveFile({
451
- fileRelativePath: relativeFilePathInArchive,
452
- readFile,
453
- writeFile: ({ fileRelativePath, modifiedData }) => writeFile({
454
- filePath: (0,external_path_.join)(extractedDirPath, fileRelativePath),
455
- modifiedData
456
- })
457
- })
458
- });
459
- await SuccessTracker.markAsExtracted({
460
- cacheDirPath,
461
- extractDirBasename
462
- });
463
- }
464
- return { extractedDirPath, archiveFilePath };
465
51
  }
466
- var SuccessTracker;
467
- (function (SuccessTracker) {
468
- async function read(params) {
469
- const { cacheDirPath } = params;
470
- const filePath = (0,external_path_.join)(cacheDirPath, "downloadAndExtractArchive.json");
471
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(filePath))) {
472
- return { archiveFileBasenames: [], extractDirBasenames: [] };
473
- }
474
- return JSON.parse((await (0,promises_.readFile)(filePath)).toString("utf8"));
475
- }
476
- async function write(params) {
477
- const { cacheDirPath, successTracker } = params;
478
- const filePath = (0,external_path_.join)(cacheDirPath, "downloadAndExtractArchive.json");
479
- {
480
- const dirPath = (0,external_path_.dirname)(filePath);
481
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
482
- await (0,promises_.mkdir)(dirPath, { recursive: true });
483
- }
484
- }
485
- await (0,promises_.writeFile)(filePath, JSON.stringify(successTracker));
486
- }
487
- async function markAsDownloaded(params) {
488
- const { cacheDirPath, archiveFileBasename } = params;
489
- const successTracker = await read({ cacheDirPath });
490
- successTracker.archiveFileBasenames.push(archiveFileBasename);
491
- await write({ cacheDirPath, successTracker });
492
- }
493
- SuccessTracker.markAsDownloaded = markAsDownloaded;
494
- async function getIsDownloaded(params) {
495
- const { cacheDirPath, archiveFileBasename } = params;
496
- const successTracker = await read({ cacheDirPath });
497
- return successTracker.archiveFileBasenames.includes(archiveFileBasename);
498
- }
499
- SuccessTracker.getIsDownloaded = getIsDownloaded;
500
- async function removeFromDownloaded(params) {
501
- const { cacheDirPath, archiveFileBasename } = params;
502
- const successTracker = await read({ cacheDirPath });
503
- successTracker.archiveFileBasenames = successTracker.archiveFileBasenames.filter(basename => basename !== archiveFileBasename);
504
- await write({ cacheDirPath, successTracker });
505
- }
506
- SuccessTracker.removeFromDownloaded = removeFromDownloaded;
507
- async function markAsExtracted(params) {
508
- const { cacheDirPath, extractDirBasename } = params;
509
- const successTracker = await read({ cacheDirPath });
510
- successTracker.extractDirBasenames.push(extractDirBasename);
511
- await write({ cacheDirPath, successTracker });
512
- }
513
- SuccessTracker.markAsExtracted = markAsExtracted;
514
- async function getIsExtracted(params) {
515
- const { cacheDirPath, extractDirBasename } = params;
516
- const successTracker = await read({ cacheDirPath });
517
- return successTracker.extractDirBasenames.includes(extractDirBasename);
518
- }
519
- SuccessTracker.getIsExtracted = getIsExtracted;
520
- async function removeFromExtracted(params) {
521
- const { cacheDirPath, extractDirBasename } = params;
522
- const successTracker = await read({ cacheDirPath });
523
- successTracker.extractDirBasenames = successTracker.extractDirBasenames.filter(basename => basename !== extractDirBasename);
524
- await write({ cacheDirPath, successTracker });
525
- }
526
- SuccessTracker.removeFromExtracted = removeFromExtracted;
527
- })(SuccessTracker || (SuccessTracker = {}));
528
- //# sourceMappingURL=downloadAndExtractArchive.js.map
529
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/startViteDevServer.js
530
-
531
-
532
-
533
-
534
-
535
- (0,assert/* assert */.h)();
536
- function startViteDevServer(params) {
537
- const { buildContext } = params;
538
- console.log(source_default().blue(`$ npx vite dev`));
539
- const child = external_child_process_.spawn("npx", ["vite", "dev"], {
540
- cwd: buildContext.projectDirPath,
541
- env: Object.assign(Object.assign({}, process.env), { [constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.READ_KC_CONTEXT_FROM_URL */.TE.READ_KC_CONTEXT_FROM_URL]: "true" }),
542
- shell: true
543
- });
544
- child.stdout.on("data", data => {
545
- if (!data.toString("utf8").includes("[vite] hmr")) {
52
+ async function crawlAsyncRec(params) {
53
+ const { dirPath, onFileFound } = params;
54
+ await Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
55
+ const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
56
+ const isDirectory = await promises_.lstat(fileOrDirPath)
57
+ .then(stat => stat.isDirectory());
58
+ if (isDirectory) {
59
+ await crawlAsyncRec({ dirPath: fileOrDirPath, onFileFound });
546
60
  return;
547
61
  }
548
- process.stdout.write(data);
549
- });
550
- child.stderr.on("data", data => process.stderr.write(data));
551
- const dPort = new Deferred.Deferred();
552
- {
553
- const onData = (data) => {
554
- //Local: http://localhost:8083/
555
- const match = data
556
- .toString("utf8")
557
- .replace(/\x1b[[0-9;]*m/g, "")
558
- .match(/Local:\s*http:\/\/(?:localhost|127\.0\.0\.1):(\d+)\//);
559
- if (match === null) {
560
- return;
561
- }
562
- child.stdout.off("data", onData);
563
- const port = parseInt(match[1]);
564
- (0,assert/* assert */.h)(!isNaN(port));
565
- dPort.resolve(port);
566
- };
567
- child.stdout.on("data", onData);
568
- }
569
- return dPort.pr.then(port => ({ port }));
570
- }
571
- //# sourceMappingURL=startViteDevServer.js.map
572
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/is.mjs
573
- var is = __webpack_require__(16453);
574
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/ParsedRealmJson.js
575
-
576
-
577
-
578
- const zParsedRealmJson = (() => {
579
- const zTargetType = lib.z.object({
580
- realm: lib.z.string(),
581
- loginTheme: lib.z.string().optional(),
582
- accountTheme: lib.z.string().optional(),
583
- adminTheme: lib.z.string().optional(),
584
- emailTheme: lib.z.string().optional(),
585
- eventsListeners: lib.z.array(lib.z.string()),
586
- users: lib.z.array(lib.z.object({
587
- id: lib.z.string(),
588
- email: lib.z.string(),
589
- username: lib.z.string(),
590
- credentials: lib.z.array(lib.z.object({
591
- type: lib.z.string()
592
- })),
593
- clientRoles: lib.z.record(lib.z.array(lib.z.string())).optional()
594
- })),
595
- roles: lib.z.object({
596
- client: lib.z.record(lib.z.array(lib.z.object({
597
- name: lib.z.string(),
598
- containerId: lib.z.string()
599
- })))
600
- }),
601
- clients: lib.z.array(lib.z.object({
602
- id: lib.z.string(),
603
- clientId: lib.z.string(),
604
- baseUrl: lib.z.string().optional(),
605
- redirectUris: lib.z.array(lib.z.string()).optional(),
606
- webOrigins: lib.z.array(lib.z.string()).optional(),
607
- attributes: lib.z.object({
608
- "post.logout.redirect.uris": lib.z.string().optional()
609
- })
610
- .optional(),
611
- protocol: lib.z.string().optional(),
612
- protocolMappers: lib.z.array(lib.z.object({
613
- id: lib.z.string(),
614
- name: lib.z.string(),
615
- protocol: lib.z.string(),
616
- protocolMapper: lib.z.string(),
617
- consentRequired: lib.z.boolean(),
618
- config: lib.z.record(lib.z.string()).optional()
619
- }))
620
- .optional()
621
- }))
622
- });
623
- assert/* assert */.h;
624
- return (0,id.id)(zTargetType);
625
- })();
626
- //# sourceMappingURL=ParsedRealmJson.js.map
627
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.js
628
-
629
-
630
-
631
-
632
- function readRealmJsonFile(params) {
633
- const { realmJsonFilePath } = params;
634
- const parsedRealmJson = JSON.parse(external_fs_.readFileSync(realmJsonFilePath).toString("utf8"));
635
- zParsedRealmJson.parse(parsedRealmJson);
636
- (0,assert/* assert */.h)((0,is.is)(parsedRealmJson));
637
- return parsedRealmJson;
638
- }
639
- //# sourceMappingURL=readRealmJsonFile.js.map
640
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.js
641
-
642
-
643
-
644
-
645
-
646
-
647
- function getDefaultRealmJsonFilePath(params) {
648
- const { keycloakMajorVersionNumber } = params;
649
- return (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", "realmConfig", "defaultConfig", `realm-kc-${keycloakMajorVersionNumber}.json`);
650
- }
651
- const { getSupportedKeycloakMajorVersions } = (() => {
652
- let cache = undefined;
653
- function getSupportedKeycloakMajorVersions() {
654
- if (cache !== undefined) {
655
- return cache;
656
- }
657
- cache = external_fs_.readdirSync((0,external_path_.dirname)(getDefaultRealmJsonFilePath({ keycloakMajorVersionNumber: 0 })))
658
- .map(fileBasename => {
659
- const match = fileBasename.match(/^realm-kc-(\d+)\.json$/);
660
- if (match === null) {
661
- return undefined;
662
- }
663
- const n = parseInt(match[1]);
664
- (0,assert/* assert */.h)(!isNaN(n));
665
- return n;
666
- })
667
- .filter((0,exclude/* exclude */.D)(undefined))
668
- .sort((a, b) => b - a);
669
- return cache;
670
- }
671
- return { getSupportedKeycloakMajorVersions };
672
- })();
673
- function getDefaultConfig(params) {
674
- const { keycloakMajorVersionNumber } = params;
675
- (0,assert/* assert */.h)(getSupportedKeycloakMajorVersions().includes(keycloakMajorVersionNumber), `We do not have a default config for Keycloak ${keycloakMajorVersionNumber}`);
676
- return readRealmJsonFile({
677
- realmJsonFilePath: getDefaultRealmJsonFilePath({
678
- keycloakMajorVersionNumber
679
- })
680
- });
62
+ await onFileFound({ filePath: fileOrDirPath });
63
+ }));
681
64
  }
682
- //# sourceMappingURL=defaultConfig.js.map
683
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/index.js
684
-
685
- //# sourceMappingURL=index.js.map
65
+ //# sourceMappingURL=crawlAsync.js.map
66
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
67
+ var runPrettier = __webpack_require__(48433);
686
68
  // EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
687
69
  var readThisNpmPackageVersion = __webpack_require__(64795);
688
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/getSupportedDockerImageTags.js
689
-
690
-
691
-
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
- assert/* assert */.h;
701
- async function getSupportedDockerImageTags(params) {
702
- const { buildContext } = params;
703
- {
704
- const result = await getCachedValue({ cacheDirPath: buildContext.cacheDirPath });
705
- if (result !== undefined) {
706
- return result;
707
- }
708
- }
709
- const tags_queryResponse = [];
710
- await (async function callee(url) {
711
- const r = await lib_default()(url, buildContext.fetchOptions);
712
- await Promise.all([
713
- (async () => {
714
- tags_queryResponse.push(...lib.z.object({
715
- tags: lib.z.array(lib.z.string())
716
- })
717
- .parse(await r.json()).tags);
718
- })(),
719
- (async () => {
720
- const link = r.headers.get("link");
721
- if (link === null) {
722
- return;
723
- }
724
- const split = link.split(";").map(s => s.trim());
725
- (0,assert/* assert */.h)(split.length === 2);
726
- (0,assert/* assert */.h)(split[1] === 'rel="next"');
727
- const match = split[0].match(/^<(.+)>$/);
728
- (0,assert/* assert */.h)(match !== null);
729
- const nextUrl = new URL(url).origin + match[1];
730
- await callee(nextUrl);
731
- })()
732
- ]);
733
- })("https://quay.io/v2/keycloak/keycloak/tags/list");
734
- const supportedKeycloakMajorVersions = getSupportedKeycloakMajorVersions();
735
- const allSupportedTags_withVersion = tags_queryResponse
736
- .map(tag => ({
737
- tag,
738
- version: (() => {
739
- if (tag.includes("-")) {
740
- return undefined;
741
- }
742
- let version;
743
- try {
744
- version = SemVer/* SemVer.parse */.h.parse(tag);
745
- }
746
- catch (_a) {
747
- return undefined;
748
- }
749
- if (tag.split(".").length !== 3) {
750
- return undefined;
751
- }
752
- if (!supportedKeycloakMajorVersions.includes(version.major)) {
753
- return undefined;
754
- }
755
- return version;
756
- })()
757
- }))
758
- .map(({ tag, version }) => (version === undefined ? undefined : { tag, version }))
759
- .filter((0,exclude/* exclude */.D)(undefined))
760
- .sort(({ version: a }, { version: b }) => SemVer/* SemVer.compare */.h.compare(b, a));
761
- const latestTagByMajor = {};
762
- for (const { version } of allSupportedTags_withVersion) {
763
- const version_current = latestTagByMajor[version.major];
764
- if (version_current === undefined ||
765
- SemVer/* SemVer.compare */.h.compare(version_current, version) === -1) {
766
- latestTagByMajor[version.major] = version;
767
- }
768
- }
769
- const latestMajorTags = Object.entries(latestTagByMajor)
770
- .sort(([a], [b]) => parseInt(b) - parseInt(a))
771
- .map(([, version]) => version)
772
- .map(version => {
773
- (0,assert/* assert */.h)(version !== undefined);
774
- if (!supportedKeycloakMajorVersions.includes(version.major)) {
775
- return undefined;
776
- }
777
- return SemVer/* SemVer.stringify */.h.stringify(version);
778
- })
779
- .filter((0,exclude/* exclude */.D)(undefined));
780
- const allSupportedTags = allSupportedTags_withVersion.map(({ tag }) => tag);
781
- const result = {
782
- latestMajorTags,
783
- allSupportedTags
784
- };
785
- await setCachedValue({ cacheDirPath: buildContext.cacheDirPath, result });
786
- return result;
787
- }
788
- const { getCachedValue, setCachedValue } = (() => {
789
- const zResult = (() => {
790
- const zTargetType = lib.z.object({
791
- allSupportedTags: lib.z.array(lib.z.string()),
792
- latestMajorTags: lib.z.array(lib.z.string())
793
- });
794
- assert/* assert */.h;
795
- return (0,id.id)(zTargetType);
796
- })();
797
- const zCache = (() => {
798
- const zTargetType = lib.z.object({
799
- keycloakifyVersion: lib.z.string(),
800
- time: lib.z.number(),
801
- result: zResult
802
- });
803
- assert/* assert */.h;
804
- return (0,id.id)(zTargetType);
805
- })();
806
- let inMemoryCachedResult = undefined;
807
- function getCacheFilePath(params) {
808
- const { cacheDirPath } = params;
809
- return (0,external_path_.join)(cacheDirPath, "supportedDockerImageTags.json");
810
- }
811
- async function getCachedValue(params) {
812
- const { cacheDirPath } = params;
813
- if (inMemoryCachedResult !== undefined) {
814
- return inMemoryCachedResult;
815
- }
816
- const cacheFilePath = getCacheFilePath({ cacheDirPath });
817
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
818
- return undefined;
819
- }
820
- let cache;
821
- try {
822
- cache = zCache.parse(JSON.parse(await promises_.readFile(cacheFilePath, "utf8")));
823
- }
824
- catch (_a) {
825
- return undefined;
826
- }
827
- if (cache.keycloakifyVersion !== (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)()) {
828
- return undefined;
829
- }
830
- if (Date.now() - cache.time > 3600 * 24) {
831
- return undefined;
832
- }
833
- inMemoryCachedResult = cache.result;
834
- return cache.result;
835
- }
836
- async function setCachedValue(params) {
837
- const { cacheDirPath, result } = params;
838
- inMemoryCachedResult = result;
839
- const cacheFilePath = getCacheFilePath({ cacheDirPath });
840
- {
841
- const dirPath = (0,external_path_.dirname)(cacheFilePath);
842
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
843
- await promises_.mkdir(dirPath, { recursive: true });
844
- }
845
- }
846
- await promises_.writeFile(cacheFilePath, JSON.stringify(zCache.parse({
847
- keycloakifyVersion: (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)(),
848
- time: Date.now(),
849
- result
850
- }), null, 2));
851
- }
852
- return {
853
- getCachedValue,
854
- setCachedValue
855
- };
856
- })();
857
- //# sourceMappingURL=getSupportedDockerImageTags.js.map
858
- // EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
859
- var same = __webpack_require__(33805);
860
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/prepareRealmConfig.js
861
-
862
-
863
-
864
-
865
- function prepareRealmConfig(params) {
866
- const { parsedRealmJson, keycloakMajorVersionNumber, parsedKeycloakThemesJsonEntry } = params;
867
- const { username } = addOrEditTestUser({
868
- parsedRealmJson,
869
- keycloakMajorVersionNumber
870
- });
871
- const { clientId } = addOrEditClient({
872
- parsedRealmJson,
873
- keycloakMajorVersionNumber
874
- });
875
- editAccountConsoleAndSecurityAdminConsole({ parsedRealmJson });
876
- enableCustomThemes({
877
- parsedRealmJson,
878
- parsedKeycloakThemesJsonEntry
879
- });
880
- enable_custom_events_listeners: {
881
- const name = "keycloakify-logging";
882
- if (parsedRealmJson.eventsListeners.includes(name)) {
883
- break enable_custom_events_listeners;
884
- }
885
- parsedRealmJson.eventsListeners.push(name);
886
- parsedRealmJson.eventsListeners.sort();
887
- }
888
- return {
889
- realmName: parsedRealmJson.realm,
890
- clientName: clientId,
891
- username
892
- };
893
- }
894
- function enableCustomThemes(params) {
895
- const { parsedRealmJson, parsedKeycloakThemesJsonEntry } = params;
896
- for (const themeType of [...constants/* THEME_TYPES */.Jh, "email"]) {
897
- parsedRealmJson[`${themeType}Theme`] =
898
- !parsedKeycloakThemesJsonEntry.types.includes(themeType)
899
- ? ""
900
- : parsedKeycloakThemesJsonEntry.name;
901
- }
902
- }
903
- function addOrEditTestUser(params) {
904
- var _a, _b, _c, _d;
905
- const { parsedRealmJson, keycloakMajorVersionNumber } = params;
906
- const parsedRealmJson_default = getDefaultConfig({ keycloakMajorVersionNumber });
907
- const [defaultUser_default] = parsedRealmJson_default.users;
908
- (0,assert/* assert */.h)(defaultUser_default !== undefined);
909
- const defaultUser_preexisting = parsedRealmJson.users.find(user => user.username === defaultUser_default.username);
910
- const newUser = structuredClone((_a = defaultUser_preexisting !== null && defaultUser_preexisting !== void 0 ? defaultUser_preexisting : (() => {
911
- const firstUser = parsedRealmJson.users[0];
912
- if (firstUser === undefined) {
913
- return undefined;
914
- }
915
- const firstUserCopy = structuredClone(firstUser);
916
- firstUserCopy.id = defaultUser_default.id;
917
- return firstUserCopy;
918
- })()) !== null && _a !== void 0 ? _a : defaultUser_default);
919
- newUser.username = defaultUser_default.username;
920
- delete_existing_password_credential_if_any: {
921
- const i = newUser.credentials.findIndex(credential => credential.type === "password");
922
- if (i === -1) {
923
- break delete_existing_password_credential_if_any;
924
- }
925
- newUser.credentials.splice(i, 1);
926
- }
927
- {
928
- const credential = defaultUser_default.credentials.find(credential => credential.type === "password");
929
- (0,assert/* assert */.h)(credential !== undefined);
930
- newUser.credentials.push(credential);
931
- }
932
- {
933
- const nameByClientId = Object.fromEntries(parsedRealmJson.clients.map(client => [client.id, client.clientId]));
934
- const newClientRoles = {};
935
- for (const clientRole of Object.values(parsedRealmJson.roles.client).flat()) {
936
- const clientName = nameByClientId[clientRole.containerId];
937
- (0,assert/* assert */.h)(clientName !== undefined);
938
- ((_b = newClientRoles[clientName]) !== null && _b !== void 0 ? _b : (newClientRoles[clientName] = [])).push(clientRole.name);
939
- }
940
- const { same: sameSet } = (0,same.sameFactory)({
941
- takeIntoAccountArraysOrdering: false
942
- });
943
- for (const [clientName, roles] of Object.entries(newClientRoles)) {
944
- keep_previous_ordering_if_possible: {
945
- const roles_previous = (_c = newUser.clientRoles) === null || _c === void 0 ? void 0 : _c[clientName];
946
- if (roles_previous === undefined) {
947
- break keep_previous_ordering_if_possible;
948
- }
949
- if (!sameSet(roles_previous, roles)) {
950
- break keep_previous_ordering_if_possible;
951
- }
952
- continue;
953
- }
954
- ((_d = newUser.clientRoles) !== null && _d !== void 0 ? _d : (newUser.clientRoles = {}))[clientName] = roles;
955
- }
956
- }
957
- if (defaultUser_preexisting === undefined) {
958
- parsedRealmJson.users.push(newUser);
959
- }
960
- else {
961
- const i = parsedRealmJson.users.indexOf(defaultUser_preexisting);
962
- (0,assert/* assert */.h)(i !== -1);
963
- parsedRealmJson.users[i] = newUser;
964
- }
965
- return { username: newUser.username };
966
- }
967
- function addOrEditClient(params) {
968
- var _a;
969
- const { parsedRealmJson, keycloakMajorVersionNumber } = params;
970
- const parsedRealmJson_default = getDefaultConfig({ keycloakMajorVersionNumber });
971
- const testClient_default = (() => {
972
- const clients = parsedRealmJson_default.clients.filter(client => {
973
- return JSON.stringify(client).includes(constants/* TEST_APP_URL */.jp);
974
- });
975
- (0,assert/* assert */.h)(clients.length === 1);
976
- return clients[0];
977
- })();
978
- const clientIds_builtIn = parsedRealmJson_default.clients
979
- .map(client => client.clientId)
980
- .filter(clientId => clientId !== testClient_default.clientId);
981
- const testClient_preexisting = (() => {
982
- const clients = parsedRealmJson.clients
983
- .filter(client => !clientIds_builtIn.includes(client.clientId))
984
- .filter(client => client.protocol === "openid-connect");
985
- {
986
- const client = clients.find(client => client.clientId === testClient_default.clientId);
987
- if (client !== undefined) {
988
- return client;
989
- }
990
- }
991
- {
992
- const client = clients.find(client => {
993
- var _a;
994
- return ((_a = client.redirectUris) === null || _a === void 0 ? void 0 : _a.find(redirectUri => redirectUri.startsWith(constants/* TEST_APP_URL */.jp))) !== undefined;
995
- });
996
- if (client !== undefined) {
997
- return client;
998
- }
999
- }
1000
- const [client] = clients;
1001
- if (client === undefined) {
1002
- return undefined;
1003
- }
1004
- return client;
1005
- })();
1006
- let testClient;
1007
- if (testClient_preexisting !== undefined) {
1008
- testClient = testClient_preexisting;
1009
- }
1010
- else {
1011
- testClient = structuredClone(testClient_default);
1012
- delete testClient.protocolMappers;
1013
- parsedRealmJson.clients.push(testClient);
1014
- }
1015
- testClient.redirectUris = [
1016
- `${constants/* TEST_APP_URL */.jp}/*`,
1017
- "http://localhost*",
1018
- "http://127.0.0.1*"
1019
- ]
1020
- .sort()
1021
- .reverse();
1022
- ((_a = testClient.attributes) !== null && _a !== void 0 ? _a : (testClient.attributes = {}))["post.logout.redirect.uris"] = "+";
1023
- testClient.webOrigins = ["*"];
1024
- return { clientId: testClient.clientId };
1025
- }
1026
- function editAccountConsoleAndSecurityAdminConsole(params) {
1027
- var _a, _b, _c, _d, _e;
1028
- const { parsedRealmJson } = params;
1029
- for (const clientId of ["account-console", "security-admin-console"]) {
1030
- const client = parsedRealmJson.clients.find(client => client.clientId === clientId);
1031
- (0,assert/* assert */.h)(client !== undefined);
1032
- {
1033
- const arr = ((_a = client.redirectUris) !== null && _a !== void 0 ? _a : (client.redirectUris = []));
1034
- for (const value of ["http://localhost*", "http://127.0.0.1*"]) {
1035
- if (!arr.includes(value)) {
1036
- arr.push(value);
1037
- }
1038
- }
1039
- (_b = client.redirectUris) === null || _b === void 0 ? void 0 : _b.sort().reverse();
1040
- }
1041
- ((_c = client.attributes) !== null && _c !== void 0 ? _c : (client.attributes = {}))["post.logout.redirect.uris"] = "+";
1042
- client.webOrigins = ["*"];
1043
- admin_specific: {
1044
- if (clientId !== "security-admin-console") {
1045
- break admin_specific;
1046
- }
1047
- const protocolMapper_preexisting = (_d = client.protocolMappers) === null || _d === void 0 ? void 0 : _d.find(protocolMapper => {
1048
- if (protocolMapper.protocolMapper !== "oidc-hardcoded-claim-mapper") {
1049
- return false;
1050
- }
1051
- if (protocolMapper.protocol !== "openid-connect") {
1052
- return false;
1053
- }
1054
- if (protocolMapper.config === undefined) {
1055
- return false;
1056
- }
1057
- if (protocolMapper.config["claim.name"] !== "allowed-origins") {
1058
- return false;
1059
- }
1060
- return true;
1061
- });
1062
- let protocolMapper;
1063
- const config = {
1064
- "introspection.token.claim": "true",
1065
- "claim.value": '["*"]',
1066
- "userinfo.token.claim": "true",
1067
- "id.token.claim": "false",
1068
- "lightweight.claim": "true",
1069
- "access.token.claim": "true",
1070
- "claim.name": "allowed-origins",
1071
- "jsonType.label": "JSON",
1072
- "access.tokenResponse.claim": "false"
1073
- };
1074
- if (protocolMapper_preexisting !== undefined) {
1075
- protocolMapper = protocolMapper_preexisting;
1076
- }
1077
- else {
1078
- protocolMapper = {
1079
- id: "8fd0d584-7052-4d04-a615-d18a71050873",
1080
- name: "allowed-origins",
1081
- protocol: "openid-connect",
1082
- protocolMapper: "oidc-hardcoded-claim-mapper",
1083
- consentRequired: false,
1084
- config
1085
- };
1086
- ((_e = client.protocolMappers) !== null && _e !== void 0 ? _e : (client.protocolMappers = [])).push(protocolMapper);
1087
- }
1088
- (0,assert/* assert */.h)(protocolMapper.config !== undefined);
1089
- if (config !== protocolMapper.config) {
1090
- Object.assign(protocolMapper.config, config);
1091
- }
70
+ // EXTERNAL MODULE: ./dist/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.js
71
+ var getExtensionModuleFileSourceCodeReadyToBeCopied = __webpack_require__(2237);
72
+ // EXTERNAL MODULE: external "crypto"
73
+ var external_crypto_ = __webpack_require__(6113);
74
+ // EXTERNAL MODULE: ./dist/bin/shared/constants.js
75
+ var constants = __webpack_require__(173);
76
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
77
+ var exclude = __webpack_require__(83101);
78
+ ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/isAmong.mjs
79
+ /** https://docs.tsafe.dev/isamong */
80
+ function isAmong(names, value) {
81
+ for (const name of names) {
82
+ if (name === value) {
83
+ return true;
1092
84
  }
1093
85
  }
86
+ return false;
1094
87
  }
1095
- //# sourceMappingURL=prepareRealmConfig.js.map
1096
- // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
1097
- var runPrettier = __webpack_require__(48433);
1098
- ;// CONCATENATED MODULE: ./dist/bin/tools/Stringifyable.js
88
+
89
+
90
+ //# sourceMappingURL=isAmong.mjs.map
91
+
92
+ ;// CONCATENATED MODULE: ./dist/bin/sync-extensions/extensionModuleMeta.js
1099
93
 
1100
94
 
1101
95
 
1102
-
1103
- const zStringifyableAtomic = (() => {
1104
- const zTargetType = lib.z.union([lib.z.string(), lib.z.number(), lib.z.boolean(), lib.z["null"]()]);
1105
- (0,assert/* assert */.h)();
1106
- return (0,id.id)(zTargetType);
1107
- })();
1108
- const zStringifyable = lib.z.any()
1109
- .superRefine((val, ctx) => {
1110
- const isStringifyable = (0,same.same)(JSON.parse(JSON.stringify(val)), val);
1111
- if (!isStringifyable) {
1112
- ctx.addIssue({
1113
- code: lib.z.ZodIssueCode.custom,
1114
- message: "Not stringifyable"
1115
- });
1116
- }
1117
- });
1118
- function getIsAtomic(stringifyable) {
1119
- return (["string", "number", "boolean"].includes(typeof stringifyable) ||
1120
- stringifyable === null);
1121
- }
1122
- const { getValueAtPath } = (() => {
1123
- function getValueAtPath_rec(stringifyable, path) {
1124
- if (path.length === 0) {
1125
- return stringifyable;
1126
- }
1127
- if (getIsAtomic(stringifyable)) {
1128
- return undefined;
1129
- }
1130
- const [first, ...rest] = path;
1131
- let dereferenced;
1132
- if (stringifyable instanceof Array) {
1133
- if (typeof first !== "number") {
1134
- return undefined;
1135
- }
1136
- dereferenced = stringifyable[first];
1137
- }
1138
- else {
1139
- if (typeof first !== "string") {
1140
- return undefined;
1141
- }
1142
- dereferenced = stringifyable[first];
1143
- }
1144
- if (dereferenced === undefined) {
1145
- return undefined;
1146
- }
1147
- return getValueAtPath_rec(dereferenced, rest);
1148
- }
1149
- function getValueAtPath(stringifyableObjectOrArray, path) {
1150
- return getValueAtPath_rec(stringifyableObjectOrArray, path);
1151
- }
1152
- return { getValueAtPath };
1153
- })();
1154
- //# sourceMappingURL=Stringifyable.js.map
1155
- ;// CONCATENATED MODULE: ./dist/bin/tools/canonicalStringify.js
1156
-
1157
- function canonicalStringify(params) {
1158
- const { data, referenceData } = params;
1159
- return JSON.stringify(makeDeterministicCopy({
1160
- path: [],
1161
- data,
1162
- getCanonicalKeys: path => {
1163
- const referenceValue = (() => {
1164
- const path_patched = [];
1165
- for (let i = 0; i < path.length; i++) {
1166
- let value_i = getValueAtPath(referenceData, [
1167
- ...path_patched,
1168
- path[i]
1169
- ]);
1170
- if (value_i !== undefined) {
1171
- path_patched.push(path[i]);
1172
- continue;
1173
- }
1174
- if (typeof path[i] !== "number") {
1175
- return undefined;
1176
- }
1177
- value_i = getValueAtPath(referenceData, [...path_patched, 0]);
1178
- if (value_i !== undefined) {
1179
- path_patched.push(0);
1180
- continue;
1181
- }
1182
- return undefined;
1183
- }
1184
- return getValueAtPath(referenceData, path_patched);
1185
- })();
1186
- if (referenceValue === undefined) {
1187
- return undefined;
1188
- }
1189
- if (getIsAtomic(referenceValue)) {
1190
- return undefined;
1191
- }
1192
- if (referenceValue instanceof Array) {
1193
- return undefined;
1194
- }
1195
- return Object.keys(referenceValue);
1196
- }
1197
- }), null, 2);
1198
- }
1199
- function makeDeterministicCopy(params) {
1200
- const { path, data, getCanonicalKeys } = params;
1201
- if (getIsAtomic(data)) {
1202
- return data;
1203
- }
1204
- if (data instanceof Array) {
1205
- return makeDeterministicCopy_array({
1206
- path,
1207
- data,
1208
- getCanonicalKeys
1209
- });
1210
- }
1211
- return makeDeterministicCopy_record({
1212
- path,
1213
- data,
1214
- getCanonicalKeys
1215
- });
1216
- }
1217
- function makeDeterministicCopy_record(params) {
1218
- const { path, data, getCanonicalKeys } = params;
1219
- const keysOfAtomicValues = [];
1220
- const keysOfNonAtomicValues = [];
1221
- for (const [key, value] of Object.entries(data)) {
1222
- if (getIsAtomic(value)) {
1223
- keysOfAtomicValues.push(key);
1224
- }
1225
- else {
1226
- keysOfNonAtomicValues.push(key);
1227
- }
1228
- }
1229
- keysOfAtomicValues.sort();
1230
- keysOfNonAtomicValues.sort();
1231
- const keys = [...keysOfAtomicValues, ...keysOfNonAtomicValues];
1232
- reorder_according_to_canonical: {
1233
- const canonicalKeys = getCanonicalKeys(path);
1234
- if (canonicalKeys === undefined) {
1235
- break reorder_according_to_canonical;
1236
- }
1237
- const keys_toPrepend = [];
1238
- for (const key of canonicalKeys) {
1239
- const indexOfKey = keys.indexOf(key);
1240
- if (indexOfKey === -1) {
1241
- continue;
1242
- }
1243
- keys.splice(indexOfKey, 1);
1244
- keys_toPrepend.push(key);
1245
- }
1246
- keys.unshift(...keys_toPrepend);
1247
- }
1248
- const result = {};
1249
- for (const key of keys) {
1250
- result[key] = makeDeterministicCopy({
1251
- path: [...path, key],
1252
- data: data[key],
1253
- getCanonicalKeys
1254
- });
1255
- }
1256
- return result;
1257
- }
1258
- function makeDeterministicCopy_array(params) {
1259
- const { path, data, getCanonicalKeys } = params;
1260
- return [...data].map((entry, i) => makeDeterministicCopy({
1261
- path: [...path, i],
1262
- data: entry,
1263
- getCanonicalKeys
1264
- }));
1265
- }
1266
- //# sourceMappingURL=canonicalStringify.js.map
1267
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.js
1268
-
1269
96
 
1270
97
 
1271
98
 
1272
- async function writeRealmJsonFile(params) {
1273
- const { realmJsonFilePath, parsedRealmJson, keycloakMajorVersionNumber } = params;
1274
- let sourceCode = canonicalStringify({
1275
- data: parsedRealmJson,
1276
- referenceData: getDefaultConfig({
1277
- keycloakMajorVersionNumber
1278
- })
1279
- });
1280
- if (await (0,runPrettier/* getIsPrettierAvailable */.MT)()) {
1281
- sourceCode = await (0,runPrettier/* runPrettier */.eY)({
1282
- sourceCode: sourceCode,
1283
- filePath: realmJsonFilePath
1284
- });
1285
- }
1286
- await promises_.writeFile(realmJsonFilePath, Buffer.from(sourceCode, "utf8"));
1287
- }
1288
- //# sourceMappingURL=writeRealmJsonFile.js.map
1289
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/index.js
1290
99
 
1291
100
 
1292
- //# sourceMappingURL=index.js.map
1293
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/dumpContainerConfig.js
1294
101
 
1295
102
 
1296
103
 
@@ -1298,242 +105,418 @@ async function writeRealmJsonFile(params) {
1298
105
 
1299
106
 
1300
107
 
108
+ const zExtensionModuleMeta = (() => {
109
+ const zTargetType = lib.z.object({
110
+ moduleName: lib.z.string(),
111
+ version: lib.z.string(),
112
+ files: lib.z.array(lib.z.object({
113
+ fileRelativePath: lib.z.string(),
114
+ hash: lib.z.string(),
115
+ copyableFilePath: lib.z.string()
116
+ })),
117
+ peerDependencies: lib.z.record(lib.z.string())
118
+ });
119
+ (0,assert/* assert */.h)();
120
+ return (0,id.id)(zTargetType);
121
+ })();
122
+ const zParsedCacheFile = (() => {
123
+ const zTargetType = lib.z.object({
124
+ keycloakifyVersion: lib.z.string(),
125
+ prettierConfigHash: lib.z.union([lib.z.string(), lib.z["null"]()]),
126
+ thisFilePath: lib.z.string(),
127
+ extensionModuleMetas: lib.z.array(zExtensionModuleMeta)
128
+ });
129
+ (0,assert/* assert */.h)();
130
+ return (0,id.id)(zTargetType);
131
+ })();
132
+ const CACHE_FILE_RELATIVE_PATH = (0,external_path_.join)("extension-modules", "cache.json");
1301
133
  (0,assert/* assert */.h)();
1302
- async function dumpContainerConfig(params) {
1303
- const { realmName, keycloakMajorVersionNumber, buildContext } = params;
1304
- // https://github.com/keycloak/keycloak/issues/33800
1305
- const doesUseLockedH2Database = keycloakMajorVersionNumber >= 25;
1306
- if (doesUseLockedH2Database) {
1307
- const dCompleted = new Deferred.Deferred();
1308
- const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "cp -rp /opt/keycloak/data/h2 /tmp"`;
1309
- external_child_process_default().exec(cmd, error => {
1310
- if (error !== null) {
1311
- dCompleted.reject(error);
1312
- return;
1313
- }
1314
- dCompleted.resolve();
134
+ async function getExtensionModuleMetas(params) {
135
+ const { buildContext } = params;
136
+ const cacheFilePath = (0,external_path_.join)(buildContext.cacheDirPath, CACHE_FILE_RELATIVE_PATH);
137
+ const keycloakifyVersion = (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)();
138
+ const prettierConfigHash = await (async () => {
139
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
140
+ return null;
141
+ }
142
+ const { configHash } = await (0,runPrettier/* getPrettier */.LG)();
143
+ return configHash;
144
+ })();
145
+ const installedExtensionModules = await (async () => {
146
+ const installedModulesWithKeycloakifyInTheName = await (0,listInstalledModules/* listInstalledModules */.P)({
147
+ packageJsonFilePath: buildContext.packageJsonFilePath,
148
+ filter: ({ moduleName }) => moduleName.includes("keycloakify") && moduleName !== "keycloakify"
1315
149
  });
1316
- try {
1317
- await dCompleted.pr;
1318
- }
1319
- catch (error) {
1320
- (0,assert/* assert */.h)((0,assert.is)(error));
1321
- console.log(source_default().red(`Docker command failed: ${cmd}`));
1322
- console.log(source_default().red(error.message));
1323
- throw error;
150
+ return (await Promise.all(installedModulesWithKeycloakifyInTheName.map(async (entry) => {
151
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC)))) {
152
+ return undefined;
153
+ }
154
+ return entry;
155
+ }))).filter((0,exclude/* exclude */.D)(undefined));
156
+ })();
157
+ const cacheContent = await (async () => {
158
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
159
+ return undefined;
1324
160
  }
1325
- }
1326
- {
1327
- const dCompleted = new Deferred.Deferred();
1328
- const child = external_child_process_default().spawn("docker", [
1329
- ...["exec", constants/* CONTAINER_NAME */.sv],
1330
- ...["/opt/keycloak/bin/kc.sh", "export"],
1331
- ...["--dir", "/tmp"],
1332
- ...["--realm", realmName],
1333
- ...["--users", "realm_file"],
1334
- ...(!doesUseLockedH2Database
1335
- ? []
1336
- : [
1337
- ...["--db", "dev-file"],
1338
- ...[
1339
- "--db-url",
1340
- '"jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE"'
1341
- ]
1342
- ])
1343
- ], { shell: true });
1344
- let output = "";
1345
- const onExit = (code) => {
1346
- dCompleted.reject(new Error(`docker exec kc.sh export command failed with code ${code}`));
1347
- };
1348
- child.once("exit", onExit);
1349
- child.stdout.on("data", data => {
1350
- const outputStr = data.toString("utf8");
1351
- if (outputStr.includes("Export finished successfully")) {
1352
- child.removeListener("exit", onExit);
1353
- // NOTE: On older Keycloak versions the process keeps running after the export is done.
1354
- const timer = setTimeout(() => {
1355
- child.removeListener("exit", onExit2);
1356
- child.kill();
1357
- dCompleted.resolve();
1358
- }, 1500);
1359
- const onExit2 = () => {
1360
- clearTimeout(timer);
1361
- dCompleted.resolve();
1362
- };
1363
- child.once("exit", onExit2);
161
+ return await promises_.readFile(cacheFilePath);
162
+ })();
163
+ const extensionModuleMetas_cacheUpToDate = await (async () => {
164
+ const parsedCacheFile = await (async () => {
165
+ if (cacheContent === undefined) {
166
+ return undefined;
1364
167
  }
1365
- output += outputStr;
1366
- });
1367
- child.stderr.on("data", data => (output += source_default().red(data.toString("utf8"))));
1368
- try {
1369
- await dCompleted.pr;
168
+ const cacheContentStr = cacheContent.toString("utf8");
169
+ let parsedCacheFile;
170
+ try {
171
+ parsedCacheFile = JSON.parse(cacheContentStr);
172
+ }
173
+ catch (_a) {
174
+ return undefined;
175
+ }
176
+ try {
177
+ zParsedCacheFile.parse(parsedCacheFile);
178
+ }
179
+ catch (_b) {
180
+ return undefined;
181
+ }
182
+ (0,assert/* assert */.h)((0,assert.is)(parsedCacheFile));
183
+ return parsedCacheFile;
184
+ })();
185
+ if (parsedCacheFile === undefined) {
186
+ return [];
1370
187
  }
1371
- catch (error) {
1372
- (0,assert/* assert */.h)((0,assert.is)(error));
1373
- console.log(source_default().red(error.message));
1374
- console.log(output);
1375
- throw error;
188
+ if (parsedCacheFile.keycloakifyVersion !== keycloakifyVersion) {
189
+ return [];
1376
190
  }
1377
- }
1378
- if (doesUseLockedH2Database) {
1379
- const dCompleted = new Deferred.Deferred();
1380
- const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "rm -rf /tmp/h2"`;
1381
- external_child_process_default().exec(cmd, error => {
1382
- if (error !== null) {
1383
- dCompleted.reject(error);
1384
- return;
191
+ if (parsedCacheFile.prettierConfigHash !== prettierConfigHash) {
192
+ return [];
193
+ }
194
+ if (parsedCacheFile.thisFilePath !== cacheFilePath) {
195
+ return [];
196
+ }
197
+ const extensionModuleMetas_cacheUpToDate = parsedCacheFile.extensionModuleMetas.filter(extensionModuleMeta => {
198
+ const correspondingInstalledExtensionModule = installedExtensionModules.find(installedExtensionModule => installedExtensionModule.moduleName ===
199
+ extensionModuleMeta.moduleName);
200
+ if (correspondingInstalledExtensionModule === undefined) {
201
+ return false;
1385
202
  }
1386
- dCompleted.resolve();
203
+ return (correspondingInstalledExtensionModule.version ===
204
+ extensionModuleMeta.version);
1387
205
  });
1388
- try {
1389
- await dCompleted.pr;
206
+ return extensionModuleMetas_cacheUpToDate;
207
+ })();
208
+ const extensionModuleMetas = await Promise.all(installedExtensionModules.map(async ({ moduleName, version, peerDependencies, dirPath }) => {
209
+ use_cache: {
210
+ const extensionModuleMeta_cache = extensionModuleMetas_cacheUpToDate.find(extensionModuleMeta => extensionModuleMeta.moduleName === moduleName);
211
+ if (extensionModuleMeta_cache === undefined) {
212
+ break use_cache;
213
+ }
214
+ return extensionModuleMeta_cache;
1390
215
  }
1391
- catch (error) {
1392
- (0,assert/* assert */.h)((0,assert.is)(error));
1393
- console.log(source_default().red(`Docker command failed: ${cmd}`));
1394
- console.log(source_default().red(error.message));
1395
- throw error;
216
+ const files = [];
217
+ {
218
+ const srcDirPath = (0,external_path_.join)(dirPath, constants/* KEYCLOAK_THEME */.PC);
219
+ await crawlAsync({
220
+ dirPath: srcDirPath,
221
+ returnedPathsType: "relative to dirPath",
222
+ onFileFound: async (fileRelativePath) => {
223
+ const sourceCode = await (0,getExtensionModuleFileSourceCodeReadyToBeCopied/* getExtensionModuleFileSourceCodeReadyToBeCopied */.p)({
224
+ buildContext,
225
+ fileRelativePath,
226
+ isOwnershipAction: false,
227
+ extensionModuleDirPath: dirPath,
228
+ extensionModuleName: moduleName,
229
+ extensionModuleVersion: version
230
+ });
231
+ const hash = computeHash(sourceCode);
232
+ const copyableFilePath = (0,external_path_.join)((0,external_path_.dirname)(cacheFilePath), constants/* KEYCLOAK_THEME */.PC, fileRelativePath);
233
+ {
234
+ const dirPath = (0,external_path_.dirname)(copyableFilePath);
235
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
236
+ await promises_.mkdir(dirPath, { recursive: true });
237
+ }
238
+ }
239
+ promises_.writeFile(copyableFilePath, sourceCode);
240
+ files.push({
241
+ fileRelativePath,
242
+ hash,
243
+ copyableFilePath
244
+ });
245
+ }
246
+ });
1396
247
  }
1397
- }
1398
- const targetRealmConfigJsonFilePath_tmp = (0,external_path_.join)(buildContext.cacheDirPath, "realm.json");
1399
- {
1400
- const dCompleted = new Deferred.Deferred();
1401
- const cmd = `docker cp ${constants/* CONTAINER_NAME */.sv}:/tmp/${realmName}-realm.json ${(0,external_path_.basename)(targetRealmConfigJsonFilePath_tmp)}`;
1402
- external_child_process_default().exec(cmd, {
1403
- cwd: (0,external_path_.dirname)(targetRealmConfigJsonFilePath_tmp)
1404
- }, error => {
1405
- if (error !== null) {
1406
- dCompleted.reject(error);
1407
- return;
1408
- }
1409
- dCompleted.resolve();
248
+ return (0,id.id)({
249
+ moduleName,
250
+ version,
251
+ files,
252
+ peerDependencies: Object.fromEntries(Object.entries(peerDependencies).filter(([moduleName]) => !isAmong(["react", "@types/react"], moduleName)))
1410
253
  });
1411
- try {
1412
- await dCompleted.pr;
254
+ }));
255
+ update_cache: {
256
+ const parsedCacheFile = (0,id.id)({
257
+ keycloakifyVersion,
258
+ prettierConfigHash,
259
+ thisFilePath: cacheFilePath,
260
+ extensionModuleMetas
261
+ });
262
+ const cacheContent_new = Buffer.from(JSON.stringify(parsedCacheFile, null, 2), "utf8");
263
+ if (cacheContent !== undefined && cacheContent_new.equals(cacheContent)) {
264
+ break update_cache;
1413
265
  }
1414
- catch (error) {
1415
- (0,assert/* assert */.h)((0,assert.is)(error));
1416
- console.log(source_default().red(`Docker command failed: ${cmd}`));
1417
- console.log(source_default().red(error.message));
1418
- throw error;
266
+ create_dir: {
267
+ const dirPath = (0,external_path_.dirname)(cacheFilePath);
268
+ if (await (0,fs_existsAsync/* existsAsync */.o)(dirPath)) {
269
+ break create_dir;
270
+ }
271
+ await promises_.mkdir(dirPath, { recursive: true });
1419
272
  }
273
+ await promises_.writeFile(cacheFilePath, cacheContent_new);
1420
274
  }
1421
- return readRealmJsonFile({
1422
- realmJsonFilePath: targetRealmConfigJsonFilePath_tmp
1423
- });
275
+ return extensionModuleMetas;
1424
276
  }
1425
- //# sourceMappingURL=dumpContainerConfig.js.map
1426
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/realmConfig.js
1427
-
1428
-
1429
-
277
+ function computeHash(data) {
278
+ return external_crypto_.createHash("sha256").update(data).digest("hex");
279
+ }
280
+ //# sourceMappingURL=extensionModuleMeta.js.map
1430
281
 
282
+ /***/ }),
1431
283
 
284
+ /***/ 2237:
285
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1432
286
 
287
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
288
+ /* harmony export */ "p": () => (/* binding */ getExtensionModuleFileSourceCodeReadyToBeCopied)
289
+ /* harmony export */ });
290
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(48433);
291
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(73292);
292
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
293
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71017);
294
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
295
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
296
+ /* harmony import */ var _shared_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(173);
1433
297
 
1434
298
 
1435
299
 
1436
300
 
1437
301
 
1438
- assert/* assert */.h;
1439
- async function getRealmConfig(params) {
1440
- const { keycloakMajorVersionNumber, realmJsonFilePath_userProvided, parsedKeycloakThemesJsonEntry, buildContext } = params;
1441
- const realmJsonFilePath = (0,external_path_.join)(buildContext.projectDirPath, ".keycloakify", `realm-kc-${keycloakMajorVersionNumber}.json`);
1442
- const parsedRealmJson = await (async () => {
1443
- if (realmJsonFilePath_userProvided !== undefined) {
1444
- return readRealmJsonFile({
1445
- realmJsonFilePath: realmJsonFilePath_userProvided
1446
- });
1447
- }
1448
- if (await (0,fs_existsAsync/* existsAsync */.o)(realmJsonFilePath)) {
1449
- return readRealmJsonFile({
1450
- realmJsonFilePath
1451
- });
1452
- }
1453
- return getDefaultConfig({ keycloakMajorVersionNumber });
1454
- })();
1455
- const { clientName, realmName, username } = prepareRealmConfig({
1456
- parsedRealmJson,
1457
- keycloakMajorVersionNumber,
1458
- parsedKeycloakThemesJsonEntry
1459
- });
1460
- {
1461
- const dirPath = (0,external_path_.dirname)(realmJsonFilePath);
1462
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
1463
- external_fs_.mkdirSync(dirPath, { recursive: true });
1464
- }
1465
- }
1466
- await writeRealmJsonFile({
1467
- realmJsonFilePath,
1468
- parsedRealmJson,
1469
- keycloakMajorVersionNumber
302
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)();
303
+ async function getExtensionModuleFileSourceCodeReadyToBeCopied(params) {
304
+ const { buildContext, extensionModuleDirPath, fileRelativePath, isOwnershipAction, extensionModuleName, extensionModuleVersion } = params;
305
+ let sourceCode = (await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile((0,path__WEBPACK_IMPORTED_MODULE_2__.join)(extensionModuleDirPath, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .KEYCLOAK_THEME */ .PC, fileRelativePath))).toString("utf8");
306
+ sourceCode = addCommentToSourceCode({
307
+ sourceCode,
308
+ fileRelativePath,
309
+ commentLines: (() => {
310
+ const path = fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_2__.sep).join("/");
311
+ return isOwnershipAction
312
+ ? [
313
+ `This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
314
+ `To relinquish ownership and restore this file to its original content, run the following command:`,
315
+ ``,
316
+ `$ npx keycloakify own --path "${path}" --revert`
317
+ ]
318
+ : [
319
+ `WARNING: Before modifying this file, run the following command:`,
320
+ ``,
321
+ `$ npx keycloakify own --path "${path}"`,
322
+ ``,
323
+ `This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
324
+ `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`
325
+ ];
326
+ })()
1470
327
  });
1471
- const { onRealmConfigChange } = (() => {
1472
- const run = runExclusive.build(async () => {
1473
- const start = Date.now();
1474
- console.log(source_default().grey(`Changes detected to the '${realmName}' config, backing up...`));
1475
- let parsedRealmJson;
1476
- try {
1477
- parsedRealmJson = await dumpContainerConfig({
1478
- buildContext,
1479
- realmName,
1480
- keycloakMajorVersionNumber
1481
- });
1482
- }
1483
- catch (error) {
1484
- console.log(source_default().red(`Failed to backup '${realmName}' config:`));
1485
- return;
1486
- }
1487
- await writeRealmJsonFile({
1488
- realmJsonFilePath,
1489
- parsedRealmJson,
1490
- keycloakMajorVersionNumber
1491
- });
1492
- console.log([
1493
- source_default().grey(`Save changed to \`.${external_path_.sep}${(0,external_path_.relative)(buildContext.projectDirPath, realmJsonFilePath)}\``),
1494
- source_default().grey(`Next time you'll be running \`keycloakify start-keycloak\`, the realm '${realmName}' will be restored to this state.`),
1495
- source_default().green(`✓ '${realmName}' config backed up completed in ${Date.now() - start}ms`)
1496
- ].join("\n"));
1497
- });
1498
- const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({
1499
- delay: 1000
328
+ const destFilePath = (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.themeSrcDirPath, fileRelativePath);
329
+ format: {
330
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .getIsPrettierAvailable */ .MT)())) {
331
+ break format;
332
+ }
333
+ sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .runPrettier */ .eY)({
334
+ filePath: destFilePath,
335
+ sourceCode
1500
336
  });
1501
- async function onRealmConfigChange() {
1502
- await waitForDebounce();
1503
- run();
1504
- }
1505
- return { onRealmConfigChange };
1506
- })();
1507
- return {
1508
- realmJsonFilePath,
1509
- clientName,
1510
- realmName,
1511
- username,
1512
- onRealmConfigChange
337
+ }
338
+ return Buffer.from(sourceCode, "utf8");
339
+ }
340
+ function addCommentToSourceCode(params) {
341
+ const { sourceCode, fileRelativePath, commentLines } = params;
342
+ const toResult = (comment) => {
343
+ return [comment, ``, sourceCode].join("\n");
1513
344
  };
345
+ for (const ext of [".ts", ".tsx", ".css", ".less", ".sass", ".js", ".jsx"]) {
346
+ if (!fileRelativePath.endsWith(ext)) {
347
+ continue;
348
+ }
349
+ return toResult([`/**`, ...commentLines.map(line => ` * ${line}`), ` */`].join("\n"));
350
+ }
351
+ if (fileRelativePath.endsWith(".properties")) {
352
+ return toResult(commentLines.map(line => `# ${line}`).join("\n"));
353
+ }
354
+ if (fileRelativePath.endsWith(".ftl")) {
355
+ const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n");
356
+ if (sourceCode.trim().startsWith("<#ftl")) {
357
+ const [first, ...rest] = sourceCode.split(">");
358
+ const last = rest.join(">");
359
+ return [`${first}>`, comment, last].join("\n");
360
+ }
361
+ return toResult(comment);
362
+ }
363
+ if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
364
+ const comment = [
365
+ `<!--`,
366
+ ...commentLines.map(line => ` ${line
367
+ .replace("--path", "-t")
368
+ .replace("--revert", "-r")
369
+ .replace("Before modifying", "Before modifying or replacing")}`),
370
+ `-->`
371
+ ].join("\n");
372
+ if (fileRelativePath.endsWith(".html") && sourceCode.trim().startsWith("<!")) {
373
+ const [first, ...rest] = sourceCode.split(">");
374
+ const last = rest.join(">");
375
+ return [`${first}>`, comment, last].join("\n");
376
+ }
377
+ if (fileRelativePath.endsWith(".svg") && sourceCode.trim().startsWith("<?")) {
378
+ const [first, ...rest] = sourceCode.split("?>");
379
+ const last = rest.join("?>");
380
+ return [`${first}?>`, comment, last].join("\n");
381
+ }
382
+ return toResult(comment);
383
+ }
384
+ return sourceCode;
1514
385
  }
1515
- //# sourceMappingURL=realmConfig.js.map
1516
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/index.js
1517
-
1518
- //# sourceMappingURL=index.js.map
1519
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/start-keycloak.js
1520
-
1521
-
1522
-
1523
-
386
+ //# sourceMappingURL=getExtensionModuleFileSourceCodeReadyToBeCopied.js.map
1524
387
 
388
+ /***/ }),
1525
389
 
390
+ /***/ 69674:
391
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1526
392
 
393
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
394
+ /* harmony export */ "Y": () => (/* binding */ writeManagedGitignoreFile),
395
+ /* harmony export */ "w": () => (/* binding */ readManagedGitignoreFile)
396
+ /* harmony export */ });
397
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
398
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
399
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
400
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
401
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29041);
402
+ /* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
403
+ /* harmony import */ var _tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(84794);
1527
404
 
1528
405
 
1529
406
 
1530
407
 
1531
408
 
409
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .h)();
410
+ const DELIMITER_START = `# === Owned files start ===`;
411
+ const DELIMITER_END = `# === Owned files end =====`;
412
+ async function writeManagedGitignoreFile(params) {
413
+ const { buildContext, extensionModuleMetas, ownedFilesRelativePaths } = params;
414
+ if (extensionModuleMetas.length === 0) {
415
+ return;
416
+ }
417
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
418
+ const content_new = Buffer.from([
419
+ `# This file is managed by Keycloakify, do not edit it manually.`,
420
+ ``,
421
+ DELIMITER_START,
422
+ ...ownedFilesRelativePaths
423
+ .map(fileRelativePath => fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/"))
424
+ .map(line => `# ${line}`),
425
+ DELIMITER_END,
426
+ ``,
427
+ ...extensionModuleMetas
428
+ .map(extensionModuleMeta => [
429
+ `# === ${extensionModuleMeta.moduleName} v${extensionModuleMeta.version} ===`,
430
+ ...extensionModuleMeta.files
431
+ .map(({ fileRelativePath }) => fileRelativePath)
432
+ .filter(fileRelativePath => !ownedFilesRelativePaths.includes(fileRelativePath))
433
+ .map(fileRelativePath => `/${fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/").replace(/^\.\//, "")}`),
434
+ ``
435
+ ])
436
+ .flat()
437
+ ].join("\n"), "utf8");
438
+ const content_current = await (async () => {
439
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
440
+ return undefined;
441
+ }
442
+ return await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath);
443
+ })();
444
+ if (content_current !== undefined && content_current.equals(content_new)) {
445
+ return;
446
+ }
447
+ create_dir: {
448
+ const dirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(filePath);
449
+ if (await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(dirPath)) {
450
+ break create_dir;
451
+ }
452
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(dirPath, { recursive: true });
453
+ }
454
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(filePath, content_new);
455
+ }
456
+ async function readManagedGitignoreFile(params) {
457
+ const { buildContext } = params;
458
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
459
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
460
+ return { ownedFilesRelativePaths: [] };
461
+ }
462
+ const contentStr = (await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath)).toString("utf8");
463
+ const payload = (() => {
464
+ const index_start = contentStr.indexOf(DELIMITER_START);
465
+ const index_end = contentStr.indexOf(DELIMITER_END);
466
+ if (index_start === -1 || index_end === -1) {
467
+ return undefined;
468
+ }
469
+ return contentStr.slice(index_start + DELIMITER_START.length, index_end).trim();
470
+ })();
471
+ if (payload === undefined) {
472
+ return { ownedFilesRelativePaths: [] };
473
+ }
474
+ const ownedFilesRelativePaths = payload
475
+ .split("\n")
476
+ .map(line => line.trim())
477
+ .map(line => line.replace(/^# /, ""))
478
+ .filter(line => line !== "")
479
+ .map(line => (0,_tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__/* .getAbsoluteAndInOsFormatPath */ .c)({
480
+ cwd: buildContext.themeSrcDirPath,
481
+ pathIsh: line
482
+ }))
483
+ .map(filePath => (0,path__WEBPACK_IMPORTED_MODULE_1__.relative)(buildContext.themeSrcDirPath, filePath));
484
+ return { ownedFilesRelativePaths };
485
+ }
486
+ //# sourceMappingURL=managedGitignoreFile.js.map
1532
487
 
488
+ /***/ }),
1533
489
 
490
+ /***/ 91097:
491
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1534
492
 
1535
493
 
494
+ // EXPORTS
495
+ __webpack_require__.d(__webpack_exports__, {
496
+ "W": () => (/* binding */ command)
497
+ });
1536
498
 
499
+ // EXTERNAL MODULE: ./dist/bin/sync-extensions/extensionModuleMeta.js + 2 modules
500
+ var sync_extensions_extensionModuleMeta = __webpack_require__(77372);
501
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
502
+ var assert = __webpack_require__(29041);
503
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
504
+ var lib = __webpack_require__(52300);
505
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
506
+ var id = __webpack_require__(38469);
507
+ // EXTERNAL MODULE: external "fs/promises"
508
+ var promises_ = __webpack_require__(73292);
509
+ // EXTERNAL MODULE: ./dist/bin/tools/SemVer.js
510
+ var SemVer = __webpack_require__(12171);
511
+ // EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
512
+ var same = __webpack_require__(33805);
513
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
514
+ var runPrettier = __webpack_require__(48433);
515
+ // EXTERNAL MODULE: ./dist/bin/tools/npmInstall.js + 1 modules
516
+ var npmInstall = __webpack_require__(63046);
517
+ // EXTERNAL MODULE: external "path"
518
+ var external_path_ = __webpack_require__(71017);
519
+ ;// CONCATENATED MODULE: ./dist/bin/sync-extensions/installExtensionModulesPeerDependencies.js
1537
520
 
1538
521
 
1539
522
 
@@ -1543,512 +526,211 @@ async function getRealmConfig(params) {
1543
526
 
1544
527
 
1545
528
 
1546
- async function command(params) {
1547
- var _a, _b, _c, _d;
1548
- exit_if_docker_not_installed: {
1549
- let commandOutput = undefined;
1550
- try {
1551
- commandOutput = external_child_process_.execSync("docker --version", {
1552
- stdio: ["ignore", "pipe", "ignore"]
1553
- })
1554
- .toString("utf8");
1555
- }
1556
- catch (_e) {
1557
- commandOutput = "";
1558
- }
1559
- commandOutput = commandOutput.trim().toLowerCase();
1560
- for (const term of ["docker", "podman"]) {
1561
- if (commandOutput.includes(term)) {
1562
- break exit_if_docker_not_installed;
1563
- }
1564
- }
1565
- console.log([
1566
- `${source_default().red("Docker required.")}`,
1567
- `Install it with Docker Desktop: ${source_default().bold.underline("https://www.docker.com/products/docker-desktop/")}`,
1568
- `(or any other way)`
1569
- ].join(" "));
1570
- process.exit(1);
1571
- }
1572
- exit_if_docker_not_running: {
1573
- let isDockerRunning;
1574
- try {
1575
- external_child_process_.execSync("docker info", { stdio: "ignore" });
1576
- isDockerRunning = true;
1577
- }
1578
- catch (_f) {
1579
- isDockerRunning = false;
1580
- }
1581
- if (isDockerRunning) {
1582
- break exit_if_docker_not_running;
1583
- }
1584
- console.log([
1585
- `${source_default().red("Docker daemon is not running.")}`,
1586
- `Please start Docker Desktop and try again.`
1587
- ].join(" "));
1588
- process.exit(1);
1589
- }
1590
- const { cliCommandOptions, buildContext } = params;
1591
- const { allSupportedTags, latestMajorTags } = await getSupportedDockerImageTags({
1592
- buildContext
1593
- });
1594
- const { dockerImageTag } = await (async () => {
1595
- if (cliCommandOptions.keycloakVersion !== undefined) {
1596
- const cliCommandOptions_keycloakVersion = cliCommandOptions.keycloakVersion;
1597
- const tag = allSupportedTags.find(tag => tag.startsWith(cliCommandOptions_keycloakVersion));
1598
- if (tag === undefined) {
1599
- console.log(source_default().red([
1600
- `We could not find a Keycloak Docker image for ${cliCommandOptions_keycloakVersion}`,
1601
- `Example of valid values: --keycloak-version 26, --keycloak-version 26.0.7`
1602
- ].join("\n")));
1603
- process.exit(1);
1604
- }
1605
- return { dockerImageTag: tag };
1606
- }
1607
- if (buildContext.startKeycloakOptions.dockerImage !== undefined) {
1608
- return {
1609
- dockerImageTag: buildContext.startKeycloakOptions.dockerImage.tag
1610
- };
1611
- }
1612
- console.log([
1613
- source_default().cyan("On which version of Keycloak do you want to test your theme?"),
1614
- source_default().gray("You can also explicitly provide the version with `npx keycloakify start-keycloak --keycloak-version 26` (or any other version)")
1615
- ].join("\n"));
1616
- const tag_userSelected = await (async () => {
1617
- let tag;
1618
- let latestMajorTags_copy = [...latestMajorTags];
1619
- while (true) {
1620
- const { value } = await dist_default()({
1621
- values: latestMajorTags_copy
1622
- }).catch(() => {
1623
- process.exit(-1);
1624
- });
1625
- tag = value;
1626
- {
1627
- const doImplementAccountMpa = buildContext.implementedThemeTypes.account.isImplemented &&
1628
- buildContext.implementedThemeTypes.account.type === "Multi-Page";
1629
- if (doImplementAccountMpa && tag.startsWith("22.")) {
1630
- console.log(source_default().yellow(`You are implementing a Multi-Page Account theme. Keycloak 22 is not supported, select another version`));
1631
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => !tag.startsWith("22."));
1632
- continue;
529
+ (0,assert/* assert */.h)();
530
+ (0,assert/* assert */.h)();
531
+ async function installExtensionModulesPeerDependencies(params) {
532
+ var _a, _b;
533
+ const { buildContext, extensionModuleMetas } = params;
534
+ const { extensionModulesPerDependencies } = (() => {
535
+ const extensionModulesPerDependencies = {};
536
+ for (const { peerDependencies } of extensionModuleMetas) {
537
+ for (const [peerDependencyName, versionRange_candidate] of Object.entries(peerDependencies)) {
538
+ const versionRange = (() => {
539
+ const versionRange_current = extensionModulesPerDependencies[peerDependencyName];
540
+ if (versionRange_current === undefined) {
541
+ return versionRange_candidate;
1633
542
  }
1634
- }
1635
- const readMajor = (tag) => {
1636
- const major = parseInt(tag.split(".")[0]);
1637
- (0,assert/* assert */.h)(!isNaN(major));
1638
- return major;
1639
- };
1640
- {
1641
- const major = readMajor(tag);
1642
- const doImplementAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
1643
- const getIsSupported = (major) => major >= 23;
1644
- if (doImplementAdminTheme && !getIsSupported(major)) {
1645
- console.log(source_default().yellow(`You are implementing an Admin theme. Only Keycloak 23 and later are supported, select another version`));
1646
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
1647
- continue;
543
+ if (versionRange_current === "*") {
544
+ return versionRange_candidate;
1648
545
  }
1649
- }
1650
- {
1651
- const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
1652
- buildContext.implementedThemeTypes.account.type === "Single-Page";
1653
- const major = readMajor(tag);
1654
- const getIsSupported = (major) => major >= 19;
1655
- if (doImplementAccountSpa && !getIsSupported(major)) {
1656
- console.log(source_default().yellow(`You are implementing a Single-Page Account theme. Only Keycloak 19 and later are supported, select another version`));
1657
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
1658
- continue;
546
+ if (versionRange_candidate === "*") {
547
+ return versionRange_current;
1659
548
  }
1660
- }
1661
- break;
1662
- }
1663
- return tag;
1664
- })();
1665
- console.log(`→ ${tag_userSelected}`);
1666
- return { dockerImageTag: tag_userSelected };
549
+ const { versionRange } = [
550
+ versionRange_current,
551
+ versionRange_candidate
552
+ ]
553
+ .map(versionRange => ({
554
+ versionRange,
555
+ semVer: SemVer/* SemVer.parse */.h.parse((() => {
556
+ if (versionRange.startsWith("^") ||
557
+ versionRange.startsWith("~")) {
558
+ return versionRange.slice(1);
559
+ }
560
+ return versionRange;
561
+ })())
562
+ }))
563
+ .sort((a, b) => SemVer/* SemVer.compare */.h.compare(b.semVer, a.semVer))[0];
564
+ return versionRange;
565
+ })();
566
+ extensionModulesPerDependencies[peerDependencyName] = versionRange;
567
+ }
568
+ }
569
+ return { extensionModulesPerDependencies };
1667
570
  })();
1668
- const keycloakMajorVersionNumber = (() => {
1669
- const [wrap] = getSupportedKeycloakMajorVersions()
1670
- .map(majorVersionNumber => ({
1671
- majorVersionNumber,
1672
- index: dockerImageTag.indexOf(`${majorVersionNumber}`)
1673
- }))
1674
- .filter(({ index }) => index !== -1)
1675
- .sort((a, b) => a.index - b.index);
1676
- if (wrap === undefined) {
1677
- try {
1678
- const version = SemVer/* SemVer.parse */.h.parse(dockerImageTag);
1679
- console.error(source_default().yellow(`Keycloak version ${version.major} is not supported, supported versions are ${getSupportedKeycloakMajorVersions().join(", ")}`));
1680
- process.exit(1);
1681
- }
1682
- catch (_a) {
1683
- // NOTE: Latest version
1684
- const [n] = getSupportedKeycloakMajorVersions();
1685
- console.warn(source_default().yellow(`Could not determine the major Keycloak version number from the docker image tag ${dockerImageTag}. Assuming ${n}`));
1686
- return n;
1687
- }
1688
- }
1689
- return wrap.majorVersionNumber;
571
+ const parsedPackageJson = await (async () => {
572
+ const zParsedPackageJson = (() => {
573
+ const zParsedPackageJson = lib.z.object({
574
+ dependencies: lib.z.record(lib.z.string()).optional(),
575
+ devDependencies: lib.z.record(lib.z.string()).optional()
576
+ });
577
+ (0,assert/* assert */.h)();
578
+ return (0,id.id)(zParsedPackageJson);
579
+ })();
580
+ const parsedPackageJson = JSON.parse((await promises_.readFile(buildContext.packageJsonFilePath)).toString("utf8"));
581
+ zParsedPackageJson.parse(parsedPackageJson);
582
+ (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
583
+ return parsedPackageJson;
1690
584
  })();
1691
- {
1692
- const { isAppBuildSuccess } = await appBuild({
1693
- buildContext
1694
- });
1695
- if (!isAppBuildSuccess) {
1696
- console.log(source_default().red(`App build failed, exiting. Try building your app (e.g 'npm run build') and see what's wrong.`));
1697
- process.exit(1);
585
+ const parsedPackageJson_before = JSON.parse(JSON.stringify(parsedPackageJson));
586
+ for (const [moduleName, versionRange] of Object.entries(extensionModulesPerDependencies)) {
587
+ if (moduleName.startsWith("@types/")) {
588
+ ((_a = parsedPackageJson.devDependencies) !== null && _a !== void 0 ? _a : (parsedPackageJson.devDependencies = {}))[moduleName] = versionRange;
589
+ continue;
1698
590
  }
1699
- const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
1700
- buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
1701
- buildContext
1702
- });
1703
- if (!isKeycloakifyBuildSuccess) {
1704
- console.log(source_default().red(`Keycloakify build failed, exiting. Try running 'npx keycloakify build' and see what's wrong.`));
1705
- process.exit(1);
591
+ if (parsedPackageJson.devDependencies !== undefined) {
592
+ delete parsedPackageJson.devDependencies[moduleName];
1706
593
  }
594
+ ((_b = parsedPackageJson.dependencies) !== null && _b !== void 0 ? _b : (parsedPackageJson.dependencies = {}))[moduleName] = versionRange;
1707
595
  }
1708
- const jarFilePath = external_fs_.readdirSync(buildContext.keycloakifyBuildDirPath)
1709
- .filter(fileBasename => fileBasename.endsWith(".jar"))
1710
- .map(fileBasename => (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, fileBasename))
1711
- .sort((a, b) => external_fs_.statSync(b).mtimeMs - external_fs_.statSync(a).mtimeMs)[0];
1712
- (0,assert/* assert */.h)(jarFilePath !== undefined);
1713
- const extensionJarFilePaths = [
1714
- ...(keycloakMajorVersionNumber <= 20
1715
- ? (console.log(source_default().yellow("WARNING: With older version of keycloak your changes to the realm configuration are not persisted")),
1716
- [])
1717
- : [
1718
- (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", constants/* KEYCLOAKIFY_LOGIN_JAR_BASENAME */.Tr)
1719
- ]),
1720
- ...(await Promise.all(buildContext.startKeycloakOptions.extensionJars.map(async (extensionJar) => {
1721
- switch (extensionJar.type) {
1722
- case "path": {
1723
- (0,assert/* assert */.h)(await (0,fs_existsAsync/* existsAsync */.o)(extensionJar.path), `${extensionJar.path} does not exist`);
1724
- return extensionJar.path;
1725
- }
1726
- case "url": {
1727
- const { archiveFilePath } = await downloadAndExtractArchive({
1728
- cacheDirPath: buildContext.cacheDirPath,
1729
- fetchOptions: buildContext.fetchOptions,
1730
- url: extensionJar.url,
1731
- uniqueIdOfOnArchiveFile: "no extraction",
1732
- onArchiveFile: async () => { }
1733
- });
1734
- return archiveFilePath;
1735
- }
1736
- }
1737
- (0,assert/* assert */.h)(false);
1738
- })))
1739
- ];
1740
- let parsedKeycloakThemesJson = (0,id.id)(undefined);
1741
- async function extractThemeResourcesFromJar() {
1742
- await extractArchive({
1743
- archiveFilePath: jarFilePath,
1744
- onArchiveFile: async ({ relativeFilePathInArchive, writeFile, readFile }) => {
1745
- if (relativeFilePathInArchive ===
1746
- (0,external_path_.join)("META-INF", "keycloak-themes.json") &&
1747
- parsedKeycloakThemesJson === undefined) {
1748
- parsedKeycloakThemesJson = JSON.parse((await readFile()).toString("utf8"));
1749
- }
1750
- if ((0,isInside/* isInside */.V)({ dirPath: "theme", filePath: relativeFilePathInArchive })) {
1751
- await writeFile({
1752
- filePath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, relativeFilePathInArchive)
1753
- });
1754
- }
1755
- }
1756
- });
596
+ if ((0,same.same)(parsedPackageJson, parsedPackageJson_before)) {
597
+ return;
1757
598
  }
1758
- {
1759
- const destDirPath = (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme");
1760
- if (await (0,fs_existsAsync/* existsAsync */.o)(destDirPath)) {
1761
- await rm(destDirPath, { recursive: true });
599
+ let packageJsonContentStr = JSON.stringify(parsedPackageJson, null, 2);
600
+ format: {
601
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
602
+ break format;
1762
603
  }
604
+ packageJsonContentStr = await (0,runPrettier/* runPrettier */.eY)({
605
+ sourceCode: packageJsonContentStr,
606
+ filePath: buildContext.packageJsonFilePath
607
+ });
1763
608
  }
1764
- await extractThemeResourcesFromJar();
1765
- (0,assert/* assert */.h)(parsedKeycloakThemesJson !== undefined);
1766
- const { clientName, onRealmConfigChange, realmJsonFilePath, realmName, username } = await getRealmConfig({
1767
- keycloakMajorVersionNumber,
1768
- parsedKeycloakThemesJsonEntry: (() => {
1769
- const entry = parsedKeycloakThemesJson.themes.find(({ name }) => name === buildContext.themeNames[0]);
1770
- (0,assert/* assert */.h)(entry !== undefined);
1771
- return entry;
1772
- })(),
1773
- realmJsonFilePath_userProvided: await (async () => {
1774
- if (cliCommandOptions.realmJsonFilePath !== undefined) {
1775
- return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
1776
- pathIsh: cliCommandOptions.realmJsonFilePath,
1777
- cwd: process.cwd()
1778
- });
1779
- }
1780
- if (buildContext.startKeycloakOptions.realmJsonFilePath !== undefined) {
1781
- (0,assert/* assert */.h)(await (0,fs_existsAsync/* existsAsync */.o)(buildContext.startKeycloakOptions.realmJsonFilePath), `${(0,external_path_.relative)(process.cwd(), buildContext.startKeycloakOptions.realmJsonFilePath)} does not exist`);
1782
- return buildContext.startKeycloakOptions.realmJsonFilePath;
1783
- }
1784
- return undefined;
1785
- })(),
1786
- buildContext
609
+ await promises_.writeFile(buildContext.packageJsonFilePath, packageJsonContentStr);
610
+ await (0,npmInstall/* npmInstall */.c)({
611
+ packageJsonDirPath: (0,external_path_.dirname)(buildContext.packageJsonFilePath)
1787
612
  });
1788
- const jarFilePath_cacheDir = (0,external_path_.join)(buildContext.cacheDirPath, (0,external_path_.basename)(jarFilePath));
1789
- external_fs_.copyFileSync(jarFilePath, jarFilePath_cacheDir);
1790
- try {
1791
- external_child_process_.execSync(`docker rm --force ${constants/* CONTAINER_NAME */.sv}`, {
1792
- stdio: "ignore"
1793
- });
613
+ process.exit(0);
614
+ }
615
+ //# sourceMappingURL=installExtensionModulesPeerDependencies.js.map
616
+ // EXTERNAL MODULE: ./dist/bin/sync-extensions/managedGitignoreFile.js
617
+ var managedGitignoreFile = __webpack_require__(69674);
618
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
619
+ var fs_existsAsync = __webpack_require__(43765);
620
+ // EXTERNAL MODULE: external "child_process"
621
+ var external_child_process_ = __webpack_require__(32081);
622
+ // EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
623
+ var Deferred = __webpack_require__(50689);
624
+ // EXTERNAL MODULE: external "fs"
625
+ var external_fs_ = __webpack_require__(57147);
626
+ // EXTERNAL MODULE: ./node_modules/run-exclusive/lib/runExclusive.js
627
+ var runExclusive = __webpack_require__(81708);
628
+ ;// CONCATENATED MODULE: ./dist/bin/tools/gitUtils.js
629
+
630
+
631
+
632
+
633
+
634
+
635
+ const groupRef = runExclusive.createGroupRef();
636
+ const getIsKnownByGit = runExclusive.build(groupRef, (params) => {
637
+ const { filePath } = params;
638
+ const dIsKnownByGit = new Deferred.Deferred();
639
+ let relativePath = (0,external_path_.basename)(filePath);
640
+ let dirPath = (0,external_path_.dirname)(filePath);
641
+ while (!external_fs_.existsSync(dirPath)) {
642
+ relativePath = (0,external_path_.join)((0,external_path_.basename)(dirPath), relativePath);
643
+ dirPath = (0,external_path_.dirname)(dirPath);
1794
644
  }
1795
- catch (_g) { }
1796
- const port = (_b = (_a = cliCommandOptions.port) !== null && _a !== void 0 ? _a : buildContext.startKeycloakOptions.port) !== null && _b !== void 0 ? _b : 8080;
1797
- const doStartDevServer = (() => {
1798
- const hasSpaUi = buildContext.implementedThemeTypes.admin.isImplemented ||
1799
- (buildContext.implementedThemeTypes.account.isImplemented &&
1800
- buildContext.implementedThemeTypes.account.type === "Single-Page");
1801
- if (!hasSpaUi) {
1802
- return false;
645
+ external_child_process_.exec(`git ls-files --error-unmatch '${relativePath.split(external_path_.sep).join("/")}'`, { cwd: dirPath }, error => {
646
+ if (error === null) {
647
+ dIsKnownByGit.resolve(true);
648
+ return;
1803
649
  }
1804
- if (buildContext.bundler !== "vite") {
1805
- console.log(source_default().yellow([
1806
- `WARNING: Since you are using ${buildContext.bundler} instead of Vite,`,
1807
- `you'll have to wait serval seconds for the changes you made on your account or admin theme to be reflected in the browser.\n`,
1808
- `For a better development experience, consider migrating to Vite.`
1809
- ].join(" ")));
1810
- return false;
650
+ if (error.code === 1) {
651
+ dIsKnownByGit.resolve(false);
652
+ return;
1811
653
  }
1812
- if (keycloakMajorVersionNumber < 25) {
1813
- console.log(source_default().yellow([
1814
- `WARNING: Your account or admin theme can't be tested with hot module replacement on Keycloak ${keycloakMajorVersionNumber}.`,
1815
- `This mean that you'll have to wait serval seconds for the changes to be reflected in the browser.`,
1816
- `For a better development experience, select a more recent version of Keycloak.`
1817
- ].join("\n")));
1818
- return false;
654
+ dIsKnownByGit.reject(error);
655
+ });
656
+ return dIsKnownByGit.pr;
657
+ });
658
+ const untrackFromGit = runExclusive.build(groupRef, async (params) => {
659
+ const { filePath } = params;
660
+ const dDone = new Deferred.Deferred();
661
+ let relativePath = (0,external_path_.basename)(filePath);
662
+ let dirPath = (0,external_path_.dirname)(filePath);
663
+ while (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
664
+ relativePath = (0,external_path_.join)((0,external_path_.basename)(dirPath), relativePath);
665
+ dirPath = (0,external_path_.dirname)(dirPath);
666
+ }
667
+ external_child_process_.exec(`git rm --cached '${relativePath.split(external_path_.sep).join("/")}'`, { cwd: dirPath }, error => {
668
+ if (error !== null) {
669
+ dDone.reject(error);
670
+ return;
1819
671
  }
1820
- return true;
1821
- })();
1822
- let devServerPort = undefined;
1823
- if (doStartDevServer) {
1824
- const { port } = await startViteDevServer({ buildContext });
1825
- devServerPort = port;
1826
- }
1827
- const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
1828
- const dockerRunArgs = [
1829
- `-p${SPACE_PLACEHOLDER}${port}:8080`,
1830
- `--name${SPACE_PLACEHOLDER}${constants/* CONTAINER_NAME */.sv}`,
1831
- ...(keycloakMajorVersionNumber >= 26
1832
- ? [
1833
- `-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_USERNAME=admin`,
1834
- `-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_PASSWORD=admin`
1835
- ]
1836
- : [
1837
- `-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN=admin`,
1838
- `-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN_PASSWORD=admin`
1839
- ]),
1840
- ...(devServerPort === undefined
1841
- ? []
1842
- : [
1843
- `-e${SPACE_PLACEHOLDER}${constants/* KEYCLOAKIFY_SPA_DEV_SERVER_PORT */.Sz}=${devServerPort}`
1844
- ]),
1845
- ...(buildContext.startKeycloakOptions.dockerExtraArgs.length === 0
1846
- ? []
1847
- : [
1848
- buildContext.startKeycloakOptions.dockerExtraArgs.join(SPACE_PLACEHOLDER)
1849
- ]),
1850
- ...(realmJsonFilePath === undefined
1851
- ? []
1852
- : [
1853
- `-v${SPACE_PLACEHOLDER}"${realmJsonFilePath}":/opt/keycloak/data/import/${realmName}-realm.json`
1854
- ]),
1855
- `-v${SPACE_PLACEHOLDER}"${jarFilePath_cacheDir}":/opt/keycloak/providers/keycloak-theme.jar`,
1856
- ...extensionJarFilePaths.map(jarFilePath => `-v${SPACE_PLACEHOLDER}"${jarFilePath}":/opt/keycloak/providers/${(0,external_path_.basename)(jarFilePath)}`),
1857
- ...(keycloakMajorVersionNumber <= 20
1858
- ? [`-e${SPACE_PLACEHOLDER}JAVA_OPTS=-Dkeycloak.profile=preview`]
1859
- : []),
1860
- ...[
1861
- ...buildContext.themeNames,
1862
- ...(external_fs_.existsSync((0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", "account-v1"))
1863
- ? ["account-v1"]
1864
- : [])
1865
- ]
1866
- .map(themeName => ({
1867
- localDirPath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", themeName),
1868
- containerDirPath: `/opt/keycloak/themes/${themeName}`
1869
- }))
1870
- .map(({ localDirPath, containerDirPath }) => `-v${SPACE_PLACEHOLDER}"${localDirPath}":${containerDirPath}:rw`),
1871
- ...buildContext.environmentVariables
1872
- .map(({ name }) => ({ name, envValue: process.env[name] }))
1873
- .map(({ name, envValue }) => envValue === undefined ? undefined : { name, envValue })
1874
- .filter((0,exclude/* exclude */.D)(undefined))
1875
- .map(({ name, envValue }) => `--env${SPACE_PLACEHOLDER}${name}='${envValue.replace(/'/g, "'\\''")}'`),
1876
- `${(_d = (_c = buildContext.startKeycloakOptions.dockerImage) === null || _c === void 0 ? void 0 : _c.reference) !== null && _d !== void 0 ? _d : "quay.io/keycloak/keycloak"}:${dockerImageTag}`,
1877
- "start-dev",
1878
- ...(21 <= keycloakMajorVersionNumber && keycloakMajorVersionNumber < 24
1879
- ? ["--features=declarative-user-profile"]
1880
- : []),
1881
- ...(realmJsonFilePath === undefined ? [] : ["--import-realm"]),
1882
- ...(buildContext.startKeycloakOptions.keycloakExtraArgs.length === 0
1883
- ? []
1884
- : [
1885
- buildContext.startKeycloakOptions.keycloakExtraArgs.join(SPACE_PLACEHOLDER)
1886
- ])
1887
- ];
1888
- console.log(source_default().blue([
1889
- `$ docker run \\`,
1890
- ...dockerRunArgs
1891
- .map(arg => arg.replace(new RegExp(SPACE_PLACEHOLDER, "g"), " "))
1892
- .map((line, i, arr) => ` ${line}${arr.length - 1 === i ? "" : " \\"}`)
1893
- ].join("\n")));
1894
- const child = external_child_process_.spawn("docker", ["run", ...dockerRunArgs.map(line => line.split(SPACE_PLACEHOLDER)).flat()], { shell: true });
1895
- child.stdout.on("data", async (data) => {
1896
- if (data.toString("utf8").includes("keycloakify-logging: REALM_CONFIG_CHANGED")) {
1897
- await onRealmConfigChange();
672
+ dDone.resolve();
673
+ });
674
+ await dDone.pr;
675
+ });
676
+ //# sourceMappingURL=gitUtils.js.map
677
+ ;// CONCATENATED MODULE: ./dist/bin/sync-extensions/sync-extension.js
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+ async function command(params) {
687
+ const { buildContext } = params;
688
+ const extensionModuleMetas = await (0,sync_extensions_extensionModuleMeta/* getExtensionModuleMetas */.f)({ buildContext });
689
+ await installExtensionModulesPeerDependencies({
690
+ buildContext,
691
+ extensionModuleMetas
692
+ });
693
+ const { ownedFilesRelativePaths } = await (0,managedGitignoreFile/* readManagedGitignoreFile */.w)({
694
+ buildContext
695
+ });
696
+ await (0,managedGitignoreFile/* writeManagedGitignoreFile */.Y)({
697
+ buildContext,
698
+ ownedFilesRelativePaths,
699
+ extensionModuleMetas
700
+ });
701
+ await Promise.all(extensionModuleMetas
702
+ .map(extensionModuleMeta => Promise.all(extensionModuleMeta.files.map(async ({ fileRelativePath, copyableFilePath, hash }) => {
703
+ if (ownedFilesRelativePaths.includes(fileRelativePath)) {
1898
704
  return;
1899
705
  }
1900
- process.stdout.write(data);
1901
- });
1902
- child.stderr.on("data", data => process.stderr.write(data));
1903
- child.on("exit", process.exit);
1904
- const srcDirPath = (0,external_path_.join)(buildContext.projectDirPath, "src");
1905
- {
1906
- const kcHttpRelativePath = (() => {
1907
- const match = buildContext.startKeycloakOptions.dockerExtraArgs
1908
- .join(" ")
1909
- .match(/KC_HTTP_RELATIVE_PATH=([^ ]+)/);
1910
- if (match === null) {
1911
- return undefined;
1912
- }
1913
- return match[1];
1914
- })();
1915
- const handler = async (data) => {
1916
- if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) {
1917
- return;
706
+ const destFilePath = (0,external_path_.join)(buildContext.themeSrcDirPath, fileRelativePath);
707
+ const doesFileExist = await (0,fs_existsAsync/* existsAsync */.o)(destFilePath);
708
+ skip_condition: {
709
+ if (!doesFileExist) {
710
+ break skip_condition;
1918
711
  }
1919
- child.stdout.off("data", handler);
1920
- await new Promise(resolve => setTimeout(resolve, 1000));
1921
- console.log([
1922
- "",
1923
- `The ftl files from ${source_default().bold(`.${external_path_.sep}${(0,external_path_.relative)(process.cwd(), (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme"))}`)} are mounted in the Keycloak container.`,
1924
- "",
1925
- `Keycloak Admin console: ${source_default().cyan.bold(`http://localhost:${port}${kcHttpRelativePath !== null && kcHttpRelativePath !== void 0 ? kcHttpRelativePath : ""}`)}`,
1926
- `- user: ${source_default().cyan.bold("admin")}`,
1927
- `- password: ${source_default().cyan.bold("admin")}`,
1928
- "",
1929
- "",
1930
- `${source_default().green("Your theme is accessible at:")}`,
1931
- `${source_default().green("➜")} ${source_default().cyan.bold((() => {
1932
- const url = new URL(constants/* TEST_APP_URL */.jp);
1933
- if (port !== 8080) {
1934
- url.searchParams.set("port", `${port}`);
1935
- }
1936
- if (kcHttpRelativePath !== undefined) {
1937
- url.searchParams.set("kcHttpRelativePath", kcHttpRelativePath);
1938
- }
1939
- if (realmName !== "myrealm") {
1940
- url.searchParams.set("realm", realmName);
1941
- }
1942
- if (clientName !== "myclient") {
1943
- url.searchParams.set("client", clientName);
1944
- }
1945
- return url.href;
1946
- })())}`,
1947
- "",
1948
- "You can login with the following credentials:",
1949
- `- username: ${source_default().cyan.bold(username)}`,
1950
- `- password: ${source_default().cyan.bold("password123")}`,
1951
- "",
1952
- `Watching for changes in ${source_default().bold(`.${external_path_.sep}${(0,external_path_.relative)(process.cwd(), buildContext.projectDirPath)}`)}`
1953
- ].join("\n"));
1954
- };
1955
- child.stdout.on("data", handler);
1956
- }
1957
- {
1958
- const runFullBuild = runExclusive.build(async () => {
1959
- console.log(source_default().cyan("Detected changes in the theme. Rebuilding ..."));
1960
- const { isAppBuildSuccess } = await appBuild({
1961
- buildContext
1962
- });
1963
- if (!isAppBuildSuccess) {
1964
- return;
712
+ const destFileHash = (0,sync_extensions_extensionModuleMeta/* computeHash */.x)(await promises_.readFile(destFilePath));
713
+ if (destFileHash !== hash) {
714
+ break skip_condition;
1965
715
  }
1966
- const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
1967
- buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
1968
- buildContext
716
+ return;
717
+ }
718
+ if (await getIsKnownByGit({ filePath: destFilePath })) {
719
+ await untrackFromGit({
720
+ filePath: destFilePath
1969
721
  });
1970
- if (!isKeycloakifyBuildSuccess) {
1971
- return;
1972
- }
1973
- await extractThemeResourcesFromJar();
1974
- console.log(source_default().green("Theme rebuilt and updated in Keycloak."));
1975
- });
1976
- const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({ delay: 400 });
1977
- chokidar.watch([
1978
- srcDirPath,
1979
- buildContext.publicDirPath,
1980
- (0,external_path_.join)(buildContext.projectDirPath, "package.json"),
1981
- (0,external_path_.join)(buildContext.projectDirPath, "vite.config.ts"),
1982
- (0,external_path_.join)(buildContext.projectDirPath, "vite.config.js"),
1983
- (0,external_path_.join)(buildContext.projectDirPath, "index.html"),
1984
- (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src")
1985
- ], {
1986
- ignoreInitial: true
1987
- })
1988
- .on("all", async (...[, filePath]) => {
1989
- ignore_path_covered_by_hmr: {
1990
- if (filePath.endsWith(".properties")) {
1991
- break ignore_path_covered_by_hmr;
1992
- }
1993
- if (!doStartDevServer) {
1994
- break ignore_path_covered_by_hmr;
1995
- }
1996
- ignore_account_spa: {
1997
- const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
1998
- buildContext.implementedThemeTypes.account.type ===
1999
- "Single-Page";
2000
- if (!doImplementAccountSpa) {
2001
- break ignore_account_spa;
2002
- }
2003
- if (!(0,isInside/* isInside */.V)({
2004
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "account"),
2005
- filePath
2006
- })) {
2007
- break ignore_account_spa;
2008
- }
2009
- return;
2010
- }
2011
- ignore_admin: {
2012
- if (!buildContext.implementedThemeTypes.admin.isImplemented) {
2013
- break ignore_admin;
2014
- }
2015
- if (!(0,isInside/* isInside */.V)({
2016
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "admin"),
2017
- filePath
2018
- })) {
2019
- break ignore_admin;
2020
- }
2021
- return;
2022
- }
2023
- ignore_patternfly: {
2024
- if (!(0,isInside/* isInside */.V)({
2025
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "shared", "@patternfly"),
2026
- filePath
2027
- })) {
2028
- break ignore_patternfly;
2029
- }
2030
- return;
2031
- }
2032
- ignore_keycloak_ui_shared: {
2033
- if (!(0,isInside/* isInside */.V)({
2034
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "shared", "keycloak-ui-shared"),
2035
- filePath
2036
- })) {
2037
- break ignore_keycloak_ui_shared;
2038
- }
2039
- return;
2040
- }
722
+ }
723
+ {
724
+ const dirName = (0,external_path_.dirname)(destFilePath);
725
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirName))) {
726
+ await promises_.mkdir(dirName, { recursive: true });
2041
727
  }
2042
- console.log(`Detected changes in ${filePath}`);
2043
- await waitForDebounce();
2044
- runFullBuild();
2045
- });
2046
- }
728
+ }
729
+ await promises_.copyFile(copyableFilePath, destFilePath);
730
+ })))
731
+ .flat());
2047
732
  }
2048
- //# sourceMappingURL=start-keycloak.js.map
2049
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/index.js
2050
-
2051
- //# sourceMappingURL=index.js.map
733
+ //# sourceMappingURL=sync-extension.js.map
2052
734
 
2053
735
  /***/ }),
2054
736
 
@@ -2161,6 +843,49 @@ async function existsAsync(path) {
2161
843
 
2162
844
  /***/ }),
2163
845
 
846
+ /***/ 89693:
847
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
848
+
849
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
850
+ /* harmony export */ "a": () => (/* binding */ rmSync)
851
+ /* harmony export */ });
852
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
853
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
854
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
855
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
856
+ /* harmony import */ var _SemVer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12171);
857
+
858
+
859
+
860
+ /**
861
+ * Polyfill of fs.rmSync(dirPath, { "recursive": true })
862
+ * For older version of Node
863
+ */
864
+ function rmSync(dirPath, options) {
865
+ if (_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.compare */ .h.compare(_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse(process.version), _SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse("14.14.0")) > 0) {
866
+ fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(dirPath, options);
867
+ return;
868
+ }
869
+ const { force = true } = options;
870
+ if (force && !fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dirPath)) {
871
+ return;
872
+ }
873
+ const removeDir_rec = (dirPath) => fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath).forEach(basename => {
874
+ const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
875
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
876
+ removeDir_rec(fileOrDirPath);
877
+ return;
878
+ }
879
+ else {
880
+ fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(fileOrDirPath);
881
+ }
882
+ });
883
+ removeDir_rec(dirPath);
884
+ }
885
+ //# sourceMappingURL=fs.rmSync.js.map
886
+
887
+ /***/ }),
888
+
2164
889
  /***/ 93721:
2165
890
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2166
891
 
@@ -2237,20 +962,91 @@ async function getInstalledModuleDirPath(params) {
2237
962
 
2238
963
  /***/ }),
2239
964
 
2240
- /***/ 90665:
965
+ /***/ 75564:
2241
966
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2242
967
 
2243
968
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2244
- /* harmony export */ "V": () => (/* binding */ isInside)
969
+ /* harmony export */ "P": () => (/* binding */ listInstalledModules)
2245
970
  /* harmony export */ });
2246
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
2247
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
971
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29041);
972
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38469);
973
+ /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(52300);
974
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
975
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
976
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
977
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
978
+ /* harmony import */ var _tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(93721);
979
+ /* harmony import */ var tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(83101);
2248
980
 
2249
- function isInside(params) {
2250
- const { dirPath, filePath } = params;
2251
- return !(0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(dirPath, filePath).startsWith("..");
981
+
982
+
983
+
984
+
985
+
986
+
987
+ async function listInstalledModules(params) {
988
+ const { packageJsonFilePath, filter } = params;
989
+ const parsedPackageJson = await readPackageJsonDependencies({
990
+ packageJsonFilePath
991
+ });
992
+ const extensionModuleNames = [parsedPackageJson.dependencies, parsedPackageJson.devDependencies]
993
+ .filter((0,tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__/* .exclude */ .D)(undefined))
994
+ .map(obj => Object.keys(obj))
995
+ .flat()
996
+ .filter(moduleName => filter({ moduleName }));
997
+ const result = await Promise.all(extensionModuleNames.map(async (moduleName) => {
998
+ const dirPath = await (0,_tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__/* .getInstalledModuleDirPath */ .p)({
999
+ moduleName,
1000
+ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
1001
+ });
1002
+ const { version, peerDependencies } = await readPackageJsonVersionAndPeerDependencies({
1003
+ packageJsonFilePath: (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, "package.json")
1004
+ });
1005
+ return { moduleName, version, peerDependencies, dirPath };
1006
+ }));
1007
+ return result;
2252
1008
  }
2253
- //# sourceMappingURL=isInside.js.map
1009
+ const { readPackageJsonDependencies } = (() => {
1010
+ const zParsedPackageJson = (() => {
1011
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
1012
+ dependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional(),
1013
+ devDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
1014
+ });
1015
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
1016
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
1017
+ })();
1018
+ async function readPackageJsonDependencies(params) {
1019
+ const { packageJsonFilePath } = params;
1020
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
1021
+ zParsedPackageJson.parse(parsedPackageJson);
1022
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
1023
+ return parsedPackageJson;
1024
+ }
1025
+ return { readPackageJsonDependencies };
1026
+ })();
1027
+ const { readPackageJsonVersionAndPeerDependencies } = (() => {
1028
+ const zParsedPackageJson = (() => {
1029
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
1030
+ version: zod__WEBPACK_IMPORTED_MODULE_5__.z.string(),
1031
+ peerDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
1032
+ });
1033
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
1034
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
1035
+ })();
1036
+ async function readPackageJsonVersionAndPeerDependencies(params) {
1037
+ var _a;
1038
+ const { packageJsonFilePath } = params;
1039
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
1040
+ zParsedPackageJson.parse(parsedPackageJson);
1041
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
1042
+ return {
1043
+ version: parsedPackageJson.version,
1044
+ peerDependencies: (_a = parsedPackageJson.peerDependencies) !== null && _a !== void 0 ? _a : {}
1045
+ };
1046
+ }
1047
+ return { readPackageJsonVersionAndPeerDependencies };
1048
+ })();
1049
+ //# sourceMappingURL=listInstalledModules.js.map
2254
1050
 
2255
1051
  /***/ }),
2256
1052
 
@@ -2388,6 +1184,379 @@ function getNodeModulesBinDirPath(params) {
2388
1184
 
2389
1185
  /***/ }),
2390
1186
 
1187
+ /***/ 63046:
1188
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1189
+
1190
+
1191
+ // EXPORTS
1192
+ __webpack_require__.d(__webpack_exports__, {
1193
+ "c": () => (/* binding */ npmInstall)
1194
+ });
1195
+
1196
+ // EXTERNAL MODULE: external "fs"
1197
+ var external_fs_ = __webpack_require__(57147);
1198
+ // EXTERNAL MODULE: external "path"
1199
+ var external_path_ = __webpack_require__(71017);
1200
+ // EXTERNAL MODULE: external "child_process"
1201
+ var external_child_process_ = __webpack_require__(32081);
1202
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
1203
+ var source = __webpack_require__(78818);
1204
+ var source_default = /*#__PURE__*/__webpack_require__.n(source);
1205
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
1206
+ var lib = __webpack_require__(52300);
1207
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
1208
+ var assert = __webpack_require__(29041);
1209
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
1210
+ var id = __webpack_require__(38469);
1211
+ ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
1212
+ /** https://docs.tsafe.dev/objectKeys */
1213
+ function objectKeys(o) {
1214
+ return Object.keys(o);
1215
+ }
1216
+
1217
+
1218
+ //# sourceMappingURL=objectKeys.mjs.map
1219
+
1220
+ // EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
1221
+ var getAbsoluteAndInOsFormatPath = __webpack_require__(84794);
1222
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
1223
+ var exclude = __webpack_require__(83101);
1224
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.rmSync.js
1225
+ var fs_rmSync = __webpack_require__(89693);
1226
+ // EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
1227
+ var Deferred = __webpack_require__(50689);
1228
+ ;// CONCATENATED MODULE: ./dist/bin/tools/npmInstall.js
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+ async function npmInstall(params) {
1242
+ const { packageJsonDirPath } = params;
1243
+ const packageManagerBinName = (() => {
1244
+ const packageMangers = [
1245
+ {
1246
+ binName: "yarn",
1247
+ lockFileBasename: "yarn.lock"
1248
+ },
1249
+ {
1250
+ binName: "npm",
1251
+ lockFileBasename: "package-lock.json"
1252
+ },
1253
+ {
1254
+ binName: "pnpm",
1255
+ lockFileBasename: "pnpm-lock.yaml"
1256
+ },
1257
+ {
1258
+ binName: "bun",
1259
+ lockFileBasename: "bun.lockdb"
1260
+ },
1261
+ {
1262
+ binName: "deno",
1263
+ lockFileBasename: "deno.lock"
1264
+ }
1265
+ ];
1266
+ for (const packageManager of packageMangers) {
1267
+ if (external_fs_.existsSync((0,external_path_.join)(packageJsonDirPath, packageManager.lockFileBasename)) ||
1268
+ external_fs_.existsSync((0,external_path_.join)(process.cwd(), packageManager.lockFileBasename))) {
1269
+ return packageManager.binName;
1270
+ }
1271
+ }
1272
+ throw new Error("No lock file found, cannot tell which package manager to use for installing dependencies.");
1273
+ })();
1274
+ console.log(`Installing the new dependencies...`);
1275
+ install_without_breaking_links: {
1276
+ if (packageManagerBinName !== "yarn") {
1277
+ break install_without_breaking_links;
1278
+ }
1279
+ const garronejLinkInfos = getGarronejLinkInfos({ packageJsonDirPath });
1280
+ if (garronejLinkInfos === undefined) {
1281
+ break install_without_breaking_links;
1282
+ }
1283
+ console.log(source_default().green("Installing in a way that won't break the links..."));
1284
+ await installWithoutBreakingLinks({
1285
+ packageJsonDirPath,
1286
+ garronejLinkInfos
1287
+ });
1288
+ return;
1289
+ }
1290
+ try {
1291
+ await runPackageManagerInstall({
1292
+ packageManagerBinName,
1293
+ cwd: packageJsonDirPath
1294
+ });
1295
+ }
1296
+ catch (_a) {
1297
+ console.log(source_default().yellow(`\`${packageManagerBinName} install\` failed, continuing anyway...`));
1298
+ }
1299
+ }
1300
+ async function runPackageManagerInstall(params) {
1301
+ const { packageManagerBinName, cwd } = params;
1302
+ const dCompleted = new Deferred.Deferred();
1303
+ const child = external_child_process_.spawn(packageManagerBinName, ["install"], {
1304
+ cwd,
1305
+ env: process.env,
1306
+ shell: true
1307
+ });
1308
+ child.stdout.on("data", data => process.stdout.write(data));
1309
+ child.stderr.on("data", data => {
1310
+ if (data.toString("utf8").includes("peer dependency")) {
1311
+ return;
1312
+ }
1313
+ process.stderr.write(data);
1314
+ });
1315
+ child.on("exit", code => {
1316
+ if (code !== 0) {
1317
+ dCompleted.reject(new Error(`Failed with code ${code}`));
1318
+ return;
1319
+ }
1320
+ dCompleted.resolve();
1321
+ });
1322
+ await dCompleted.pr;
1323
+ }
1324
+ function getGarronejLinkInfos(params) {
1325
+ const { packageJsonDirPath } = params;
1326
+ const nodeModuleDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
1327
+ if (!external_fs_.existsSync(nodeModuleDirPath)) {
1328
+ return undefined;
1329
+ }
1330
+ const linkedModuleNames = [];
1331
+ let yarnHomeDirPath = undefined;
1332
+ const getIsLinkedByGarronejScript = (path) => {
1333
+ let realPath;
1334
+ try {
1335
+ realPath = external_fs_.readlinkSync(path);
1336
+ }
1337
+ catch (_a) {
1338
+ return false;
1339
+ }
1340
+ const doesIncludeYarnHome = realPath.includes(".yarn_home");
1341
+ if (!doesIncludeYarnHome) {
1342
+ return false;
1343
+ }
1344
+ set_yarnHomeDirPath: {
1345
+ if (yarnHomeDirPath !== undefined) {
1346
+ break set_yarnHomeDirPath;
1347
+ }
1348
+ const [firstElement] = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
1349
+ pathIsh: realPath,
1350
+ cwd: (0,external_path_.dirname)(path)
1351
+ }).split(".yarn_home");
1352
+ yarnHomeDirPath = (0,external_path_.join)(firstElement, ".yarn_home");
1353
+ }
1354
+ return true;
1355
+ };
1356
+ for (const basename of external_fs_.readdirSync(nodeModuleDirPath)) {
1357
+ const path = (0,external_path_.join)(nodeModuleDirPath, basename);
1358
+ if (external_fs_.lstatSync(path).isSymbolicLink()) {
1359
+ if (basename.startsWith("@")) {
1360
+ return undefined;
1361
+ }
1362
+ if (!getIsLinkedByGarronejScript(path)) {
1363
+ return undefined;
1364
+ }
1365
+ linkedModuleNames.push(basename);
1366
+ continue;
1367
+ }
1368
+ if (!external_fs_.lstatSync(path).isDirectory()) {
1369
+ continue;
1370
+ }
1371
+ if (basename.startsWith("@")) {
1372
+ for (const subBasename of external_fs_.readdirSync(path)) {
1373
+ const subPath = (0,external_path_.join)(path, subBasename);
1374
+ if (!external_fs_.lstatSync(subPath).isSymbolicLink()) {
1375
+ continue;
1376
+ }
1377
+ if (!getIsLinkedByGarronejScript(subPath)) {
1378
+ return undefined;
1379
+ }
1380
+ linkedModuleNames.push(`${basename}/${subBasename}`);
1381
+ }
1382
+ }
1383
+ }
1384
+ if (yarnHomeDirPath === undefined) {
1385
+ return undefined;
1386
+ }
1387
+ return { linkedModuleNames, yarnHomeDirPath };
1388
+ }
1389
+ async function installWithoutBreakingLinks(params) {
1390
+ const { packageJsonDirPath, garronejLinkInfos: { linkedModuleNames, yarnHomeDirPath } } = params;
1391
+ const parsedPackageJson = (() => {
1392
+ const packageJsonFilePath = (0,external_path_.join)(packageJsonDirPath, "package.json");
1393
+ const zParsedPackageJson = (() => {
1394
+ const zTargetType = lib.z.object({
1395
+ scripts: lib.z.record(lib.z.string()).optional()
1396
+ });
1397
+ assert/* assert */.h;
1398
+ return (0,id.id)(zTargetType);
1399
+ })();
1400
+ const parsedPackageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
1401
+ zParsedPackageJson.parse(parsedPackageJson);
1402
+ (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
1403
+ return parsedPackageJson;
1404
+ })();
1405
+ const isImplementedScriptByName = {
1406
+ postinstall: false,
1407
+ prepare: false
1408
+ };
1409
+ delete_postinstall_script: {
1410
+ if (parsedPackageJson.scripts === undefined) {
1411
+ break delete_postinstall_script;
1412
+ }
1413
+ for (const scriptName of objectKeys(isImplementedScriptByName)) {
1414
+ if (parsedPackageJson.scripts[scriptName] === undefined) {
1415
+ continue;
1416
+ }
1417
+ isImplementedScriptByName[scriptName] = true;
1418
+ delete parsedPackageJson.scripts[scriptName];
1419
+ }
1420
+ }
1421
+ const tmpProjectDirPath = (0,external_path_.join)(yarnHomeDirPath, "tmpProject");
1422
+ if (external_fs_.existsSync(tmpProjectDirPath)) {
1423
+ (0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
1424
+ }
1425
+ external_fs_.mkdirSync(tmpProjectDirPath, { recursive: true });
1426
+ external_fs_.writeFileSync((0,external_path_.join)(tmpProjectDirPath, "package.json"), JSON.stringify(parsedPackageJson, undefined, 4));
1427
+ const YARN_LOCK = "yarn.lock";
1428
+ external_fs_.copyFileSync((0,external_path_.join)(packageJsonDirPath, YARN_LOCK), (0,external_path_.join)(tmpProjectDirPath, YARN_LOCK));
1429
+ await runPackageManagerInstall({
1430
+ packageManagerBinName: "yarn",
1431
+ cwd: tmpProjectDirPath
1432
+ });
1433
+ // NOTE: Moving the modules from the tmp project to the actual project
1434
+ // without messing up the links.
1435
+ {
1436
+ const { getAreSameVersions } = (() => {
1437
+ const zParsedPackageJson = (() => {
1438
+ const zTargetType = lib.z.object({
1439
+ version: lib.z.string()
1440
+ });
1441
+ assert/* assert */.h;
1442
+ return (0,id.id)(zTargetType);
1443
+ })();
1444
+ function readVersion(params) {
1445
+ const { moduleDirPath } = params;
1446
+ const packageJsonFilePath = (0,external_path_.join)(moduleDirPath, "package.json");
1447
+ const packageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
1448
+ zParsedPackageJson.parse(packageJson);
1449
+ (0,assert/* assert */.h)((0,assert.is)(packageJson));
1450
+ return packageJson.version;
1451
+ }
1452
+ function getAreSameVersions(params) {
1453
+ const { moduleDirPath_a, moduleDirPath_b } = params;
1454
+ return (readVersion({ moduleDirPath: moduleDirPath_a }) ===
1455
+ readVersion({ moduleDirPath: moduleDirPath_b }));
1456
+ }
1457
+ return { getAreSameVersions };
1458
+ })();
1459
+ const nodeModulesDirPath_tmpProject = (0,external_path_.join)(tmpProjectDirPath, "node_modules");
1460
+ const nodeModulesDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
1461
+ const modulePaths = external_fs_.readdirSync(nodeModulesDirPath_tmpProject)
1462
+ .map(basename => {
1463
+ if (basename.startsWith(".")) {
1464
+ return undefined;
1465
+ }
1466
+ const path = (0,external_path_.join)(nodeModulesDirPath_tmpProject, basename);
1467
+ if (basename.startsWith("@")) {
1468
+ return external_fs_.readdirSync(path)
1469
+ .map(subBasename => {
1470
+ if (subBasename.startsWith(".")) {
1471
+ return undefined;
1472
+ }
1473
+ const subPath = (0,external_path_.join)(path, subBasename);
1474
+ if (!external_fs_.lstatSync(subPath).isDirectory()) {
1475
+ return undefined;
1476
+ }
1477
+ return {
1478
+ moduleName: `${basename}/${subBasename}`,
1479
+ moduleDirPath_tmpProject: subPath,
1480
+ moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename, subBasename)
1481
+ };
1482
+ })
1483
+ .filter((0,exclude/* exclude */.D)(undefined));
1484
+ }
1485
+ if (!external_fs_.lstatSync(path).isDirectory()) {
1486
+ return undefined;
1487
+ }
1488
+ return [
1489
+ {
1490
+ moduleName: basename,
1491
+ moduleDirPath_tmpProject: path,
1492
+ moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename)
1493
+ }
1494
+ ];
1495
+ })
1496
+ .filter((0,exclude/* exclude */.D)(undefined))
1497
+ .flat();
1498
+ for (const { moduleName, moduleDirPath, moduleDirPath_tmpProject } of modulePaths) {
1499
+ if (linkedModuleNames.includes(moduleName)) {
1500
+ continue;
1501
+ }
1502
+ let doesTargetModuleExist = false;
1503
+ skip_condition: {
1504
+ if (!external_fs_.existsSync(moduleDirPath)) {
1505
+ break skip_condition;
1506
+ }
1507
+ doesTargetModuleExist = true;
1508
+ const areSameVersions = getAreSameVersions({
1509
+ moduleDirPath_a: moduleDirPath,
1510
+ moduleDirPath_b: moduleDirPath_tmpProject
1511
+ });
1512
+ if (!areSameVersions) {
1513
+ break skip_condition;
1514
+ }
1515
+ continue;
1516
+ }
1517
+ if (doesTargetModuleExist) {
1518
+ (0,fs_rmSync/* rmSync */.a)(moduleDirPath, { recursive: true });
1519
+ }
1520
+ {
1521
+ const dirPath = (0,external_path_.dirname)(moduleDirPath);
1522
+ if (!external_fs_.existsSync(dirPath)) {
1523
+ external_fs_.mkdirSync(dirPath, { recursive: true });
1524
+ }
1525
+ }
1526
+ external_fs_.renameSync(moduleDirPath_tmpProject, moduleDirPath);
1527
+ }
1528
+ move_bin: {
1529
+ const binDirPath_tmpProject = (0,external_path_.join)(nodeModulesDirPath_tmpProject, ".bin");
1530
+ const binDirPath = (0,external_path_.join)(nodeModulesDirPath, ".bin");
1531
+ if (!external_fs_.existsSync(binDirPath_tmpProject)) {
1532
+ break move_bin;
1533
+ }
1534
+ for (const basename of external_fs_.readdirSync(binDirPath_tmpProject)) {
1535
+ const path_tmpProject = (0,external_path_.join)(binDirPath_tmpProject, basename);
1536
+ const path = (0,external_path_.join)(binDirPath, basename);
1537
+ if (external_fs_.existsSync(path)) {
1538
+ continue;
1539
+ }
1540
+ external_fs_.renameSync(path_tmpProject, path);
1541
+ }
1542
+ }
1543
+ }
1544
+ external_fs_.cpSync((0,external_path_.join)(tmpProjectDirPath, YARN_LOCK), (0,external_path_.join)(packageJsonDirPath, YARN_LOCK));
1545
+ (0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
1546
+ for (const scriptName of objectKeys(isImplementedScriptByName)) {
1547
+ if (!isImplementedScriptByName[scriptName]) {
1548
+ continue;
1549
+ }
1550
+ external_child_process_.execSync(`yarn run ${scriptName}`, {
1551
+ cwd: packageJsonDirPath,
1552
+ stdio: "inherit"
1553
+ });
1554
+ }
1555
+ }
1556
+ //# sourceMappingURL=npmInstall.js.map
1557
+
1558
+ /***/ }),
1559
+
2391
1560
  /***/ 48433:
2392
1561
  /***/ ((module, __webpack_exports__, __webpack_require__) => {
2393
1562