keycloakify 11.8.31 → 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.
@@ -0,0 +1,2505 @@
1
+ "use strict";
2
+ exports.id = 375;
3
+ exports.ids = [375];
4
+ exports.modules = {
5
+
6
+ /***/ 64097:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+ // ESM COMPAT FLAG
10
+ __webpack_require__.r(__webpack_exports__);
11
+
12
+ // EXPORTS
13
+ __webpack_require__.d(__webpack_exports__, {
14
+ "command": () => (/* reexport */ command)
15
+ });
16
+
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
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
24
+ 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_);
28
+ // EXTERNAL MODULE: external "path"
29
+ 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
+ // EXTERNAL MODULE: external "fs/promises"
50
+ 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
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
60
+ var fs_existsAsync = __webpack_require__(43765);
61
+ ;// CONCATENATED MODULE: ./dist/bin/tools/extractArchive.js
62
+
63
+
64
+
65
+
66
+
67
+
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;
149
+ }
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
+ (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
+ }
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
+ });
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
+ }
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")) {
546
+ return;
547
+ }
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
+ });
681
+ }
682
+ //# sourceMappingURL=defaultConfig.js.map
683
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/index.js
684
+
685
+ //# sourceMappingURL=index.js.map
686
+ // EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
687
+ 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
+ }
1092
+ }
1093
+ }
1094
+ }
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
1099
+
1100
+
1101
+
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
+
1270
+
1271
+
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
+
1291
+
1292
+ //# sourceMappingURL=index.js.map
1293
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/dumpContainerConfig.js
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+ (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();
1315
+ });
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;
1324
+ }
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);
1364
+ }
1365
+ output += outputStr;
1366
+ });
1367
+ child.stderr.on("data", data => (output += source_default().red(data.toString("utf8"))));
1368
+ try {
1369
+ await dCompleted.pr;
1370
+ }
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;
1376
+ }
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;
1385
+ }
1386
+ dCompleted.resolve();
1387
+ });
1388
+ try {
1389
+ await dCompleted.pr;
1390
+ }
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;
1396
+ }
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();
1410
+ });
1411
+ try {
1412
+ await dCompleted.pr;
1413
+ }
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;
1419
+ }
1420
+ }
1421
+ return readRealmJsonFile({
1422
+ realmJsonFilePath: targetRealmConfigJsonFilePath_tmp
1423
+ });
1424
+ }
1425
+ //# sourceMappingURL=dumpContainerConfig.js.map
1426
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/realmConfig.js
1427
+
1428
+
1429
+
1430
+
1431
+
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
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
1470
+ });
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
1500
+ });
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
1513
+ };
1514
+ }
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
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+
1533
+
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+
1540
+
1541
+
1542
+
1543
+
1544
+
1545
+
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;
1633
+ }
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;
1648
+ }
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;
1659
+ }
1660
+ }
1661
+ break;
1662
+ }
1663
+ return tag;
1664
+ })();
1665
+ console.log(`→ ${tag_userSelected}`);
1666
+ return { dockerImageTag: tag_userSelected };
1667
+ })();
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;
1690
+ })();
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);
1698
+ }
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);
1706
+ }
1707
+ }
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
+ });
1757
+ }
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 });
1762
+ }
1763
+ }
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
1787
+ });
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
+ });
1794
+ }
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;
1803
+ }
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;
1811
+ }
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;
1819
+ }
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();
1898
+ return;
1899
+ }
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;
1918
+ }
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;
1965
+ }
1966
+ const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
1967
+ buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
1968
+ buildContext
1969
+ });
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
+ }
2041
+ }
2042
+ console.log(`Detected changes in ${filePath}`);
2043
+ await waitForDebounce();
2044
+ runFullBuild();
2045
+ });
2046
+ }
2047
+ }
2048
+ //# sourceMappingURL=start-keycloak.js.map
2049
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/index.js
2050
+
2051
+ //# sourceMappingURL=index.js.map
2052
+
2053
+ /***/ }),
2054
+
2055
+ /***/ 12171:
2056
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2057
+
2058
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2059
+ /* harmony export */ "h": () => (/* binding */ SemVer)
2060
+ /* harmony export */ });
2061
+ var SemVer;
2062
+ (function (SemVer) {
2063
+ const bumpTypes = ["major", "minor", "patch", "rc", "no bump"];
2064
+ function parse(versionStr) {
2065
+ const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
2066
+ if (!match) {
2067
+ throw new Error(`${versionStr} is not a valid semantic version`);
2068
+ }
2069
+ const semVer = Object.assign({ major: parseInt(match[1]), minor: parseInt(match[2]), patch: (() => {
2070
+ const str = match[3];
2071
+ return str === undefined ? 0 : parseInt(str);
2072
+ })() }, (() => {
2073
+ const str = match[4];
2074
+ return str === undefined ? {} : { rc: parseInt(str) };
2075
+ })());
2076
+ const initialStr = stringify(semVer);
2077
+ Object.defineProperty(semVer, "parsedFrom", {
2078
+ enumerable: true,
2079
+ get: function () {
2080
+ const currentStr = stringify(this);
2081
+ if (currentStr !== initialStr) {
2082
+ throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
2083
+ }
2084
+ return versionStr;
2085
+ }
2086
+ });
2087
+ return semVer;
2088
+ }
2089
+ SemVer.parse = parse;
2090
+ function stringify(v) {
2091
+ return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? "" : `-rc.${v.rc}`}`;
2092
+ }
2093
+ SemVer.stringify = stringify;
2094
+ /**
2095
+ *
2096
+ * v1 < v2 => -1
2097
+ * v1 === v2 => 0
2098
+ * v1 > v2 => 1
2099
+ *
2100
+ */
2101
+ function compare(v1, v2) {
2102
+ const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
2103
+ const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
2104
+ for (const level of ["major", "minor", "patch", "rc"]) {
2105
+ if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
2106
+ return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
2107
+ }
2108
+ }
2109
+ return 0;
2110
+ }
2111
+ SemVer.compare = compare;
2112
+ /*
2113
+ console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
2114
+ console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
2115
+ console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
2116
+ */
2117
+ function bumpType(params) {
2118
+ const versionAhead = typeof params.versionAhead === "string"
2119
+ ? parse(params.versionAhead)
2120
+ : params.versionAhead;
2121
+ const versionBehind = typeof params.versionBehind === "string"
2122
+ ? parse(params.versionBehind)
2123
+ : params.versionBehind;
2124
+ if (compare(versionBehind, versionAhead) === 1) {
2125
+ throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
2126
+ }
2127
+ for (const level of ["major", "minor", "patch", "rc"]) {
2128
+ if (versionBehind[level] !== versionAhead[level]) {
2129
+ return level;
2130
+ }
2131
+ }
2132
+ return "no bump";
2133
+ }
2134
+ SemVer.bumpType = bumpType;
2135
+ })(SemVer || (SemVer = {}));
2136
+ //# sourceMappingURL=SemVer.js.map
2137
+
2138
+ /***/ }),
2139
+
2140
+ /***/ 43765:
2141
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2142
+
2143
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2144
+ /* harmony export */ "o": () => (/* binding */ existsAsync)
2145
+ /* harmony export */ });
2146
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
2147
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
2148
+
2149
+ async function existsAsync(path) {
2150
+ try {
2151
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
2152
+ return true;
2153
+ }
2154
+ catch (error) {
2155
+ if (error.code === "ENOENT")
2156
+ return false;
2157
+ throw error;
2158
+ }
2159
+ }
2160
+ //# sourceMappingURL=fs.existsAsync.js.map
2161
+
2162
+ /***/ }),
2163
+
2164
+ /***/ 93721:
2165
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2166
+
2167
+
2168
+ // EXPORTS
2169
+ __webpack_require__.d(__webpack_exports__, {
2170
+ "p": () => (/* binding */ getInstalledModuleDirPath)
2171
+ });
2172
+
2173
+ // EXTERNAL MODULE: external "path"
2174
+ var external_path_ = __webpack_require__(71017);
2175
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
2176
+ var fs_existsAsync = __webpack_require__(43765);
2177
+ // EXTERNAL MODULE: external "child_process"
2178
+ var external_child_process_ = __webpack_require__(32081);
2179
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
2180
+ var assert = __webpack_require__(29041);
2181
+ ;// CONCATENATED MODULE: ./dist/bin/tools/isRootPath.js
2182
+
2183
+ function getIsRootPath(filePath) {
2184
+ const path_normalized = (0,external_path_.normalize)(filePath);
2185
+ // Unix-like root ("/")
2186
+ if (path_normalized === "/") {
2187
+ return true;
2188
+ }
2189
+ // Check for Windows drive root (e.g., "C:\\")
2190
+ if (/^[a-zA-Z]:\\$/.test(path_normalized)) {
2191
+ return true;
2192
+ }
2193
+ // Check for UNC root (e.g., "\\server\share")
2194
+ if (/^\\\\[^\\]+\\[^\\]+\\?$/.test(path_normalized)) {
2195
+ return true;
2196
+ }
2197
+ return false;
2198
+ }
2199
+ //# sourceMappingURL=isRootPath.js.map
2200
+ ;// CONCATENATED MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js
2201
+
2202
+
2203
+
2204
+
2205
+
2206
+ async function getInstalledModuleDirPath(params) {
2207
+ const { moduleName, packageJsonDirPath } = params;
2208
+ {
2209
+ let dirPath = packageJsonDirPath;
2210
+ while (true) {
2211
+ const dirPath_candidate = (0,external_path_.join)(dirPath, "node_modules", ...moduleName.split("/"));
2212
+ let doesExist;
2213
+ try {
2214
+ doesExist = await (0,fs_existsAsync/* existsAsync */.o)(dirPath_candidate);
2215
+ }
2216
+ catch (_a) {
2217
+ doesExist = false;
2218
+ }
2219
+ if (doesExist) {
2220
+ return dirPath_candidate;
2221
+ }
2222
+ if (getIsRootPath(dirPath)) {
2223
+ break;
2224
+ }
2225
+ dirPath = (0,external_path_.join)(dirPath, "..");
2226
+ }
2227
+ }
2228
+ const dirPath = external_child_process_.execSync(`npm list ${moduleName}`, {
2229
+ cwd: packageJsonDirPath
2230
+ })
2231
+ .toString("utf8")
2232
+ .trim();
2233
+ (0,assert/* assert */.h)(dirPath !== "");
2234
+ return dirPath;
2235
+ }
2236
+ //# sourceMappingURL=getInstalledModuleDirPath.js.map
2237
+
2238
+ /***/ }),
2239
+
2240
+ /***/ 90665:
2241
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2242
+
2243
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2244
+ /* harmony export */ "V": () => (/* binding */ isInside)
2245
+ /* 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__);
2248
+
2249
+ function isInside(params) {
2250
+ const { dirPath, filePath } = params;
2251
+ return !(0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(dirPath, filePath).startsWith("..");
2252
+ }
2253
+ //# sourceMappingURL=isInside.js.map
2254
+
2255
+ /***/ }),
2256
+
2257
+ /***/ 73776:
2258
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2259
+
2260
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2261
+ /* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
2262
+ /* harmony export */ });
2263
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
2264
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
2265
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58822);
2266
+ /* harmony import */ var _getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(93721);
2267
+ /* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
2268
+ /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(52300);
2269
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(73292);
2270
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_4__);
2271
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
2272
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
2273
+
2274
+
2275
+
2276
+
2277
+
2278
+
2279
+
2280
+
2281
+ let cache_bestEffort = undefined;
2282
+ /** NOTE: Careful, this function can fail when the binary
2283
+ * Used is not in the node_modules directory of the project
2284
+ * (for example when running tests with vscode extension we'll get
2285
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
2286
+ *
2287
+ * instead of
2288
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
2289
+ * or
2290
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
2291
+ *
2292
+ * as the value of process.argv[1]
2293
+ */
2294
+ function getNodeModulesBinDirPath_bestEffort() {
2295
+ if (cache_bestEffort !== undefined) {
2296
+ return cache_bestEffort;
2297
+ }
2298
+ const binPath = process.argv[1];
2299
+ special_case_running_not_from_distribution: {
2300
+ if (!binPath.endsWith(".ts")) {
2301
+ break special_case_running_not_from_distribution;
2302
+ }
2303
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .B)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
2304
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, "node_modules", ".bin");
2305
+ return nodeModulesBinDirPath;
2306
+ }
2307
+ const segments = [".bin"];
2308
+ let foundNodeModules = false;
2309
+ for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
2310
+ skip_segment: {
2311
+ if (foundNodeModules) {
2312
+ break skip_segment;
2313
+ }
2314
+ if (segment === "node_modules") {
2315
+ foundNodeModules = true;
2316
+ break skip_segment;
2317
+ }
2318
+ continue;
2319
+ }
2320
+ segments.unshift(segment);
2321
+ }
2322
+ if (!foundNodeModules) {
2323
+ throw new Error(`Could not find node_modules in path ${binPath}`);
2324
+ }
2325
+ const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
2326
+ cache_bestEffort = nodeModulesBinDirPath;
2327
+ return nodeModulesBinDirPath;
2328
+ }
2329
+ let cache_withPackageJsonFileDirPath = undefined;
2330
+ async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
2331
+ const { packageJsonFilePath } = params;
2332
+ use_cache: {
2333
+ if (cache_withPackageJsonFileDirPath === undefined) {
2334
+ break use_cache;
2335
+ }
2336
+ if (cache_withPackageJsonFileDirPath.packageJsonFilePath !== packageJsonFilePath) {
2337
+ cache_withPackageJsonFileDirPath = undefined;
2338
+ break use_cache;
2339
+ }
2340
+ return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
2341
+ }
2342
+ // [...]node_modules/keycloakify
2343
+ const installedModuleDirPath = await (0,_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getInstalledModuleDirPath */ .p)({
2344
+ // Here it will always be "keycloakify" but since we are in tools/ we make something generic
2345
+ moduleName: await (async () => {
2346
+ const zParsedPackageJson = (() => {
2347
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
2348
+ name: zod__WEBPACK_IMPORTED_MODULE_6__.z.string()
2349
+ });
2350
+ tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h;
2351
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
2352
+ })();
2353
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_4__.readFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))).toString("utf8"));
2354
+ zParsedPackageJson.parse(parsedPackageJson);
2355
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__.is)(parsedPackageJson));
2356
+ return parsedPackageJson.name;
2357
+ })(),
2358
+ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(packageJsonFilePath)
2359
+ });
2360
+ const segments = installedModuleDirPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep);
2361
+ while (true) {
2362
+ const segment = segments.pop();
2363
+ if (segment === undefined) {
2364
+ throw new Error(`Could not find .bin directory relative to ${packageJsonFilePath}`);
2365
+ }
2366
+ if (segment !== "node_modules") {
2367
+ continue;
2368
+ }
2369
+ const candidate = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep), segment, ".bin");
2370
+ if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(candidate))) {
2371
+ continue;
2372
+ }
2373
+ cache_withPackageJsonFileDirPath = {
2374
+ packageJsonFilePath,
2375
+ nodeModulesBinDirPath: candidate
2376
+ };
2377
+ break;
2378
+ }
2379
+ return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
2380
+ }
2381
+ function getNodeModulesBinDirPath(params) {
2382
+ const { packageJsonFilePath } = params !== null && params !== void 0 ? params : {};
2383
+ return packageJsonFilePath === undefined
2384
+ ? getNodeModulesBinDirPath_bestEffort()
2385
+ : getNodeModulesBinDirPath_withPackageJsonFileDirPath({ packageJsonFilePath });
2386
+ }
2387
+ //# sourceMappingURL=nodeModulesBinDirPath.js.map
2388
+
2389
+ /***/ }),
2390
+
2391
+ /***/ 48433:
2392
+ /***/ ((module, __webpack_exports__, __webpack_require__) => {
2393
+
2394
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2395
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
2396
+ /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
2397
+ /* harmony export */ "eY": () => (/* binding */ runPrettier)
2398
+ /* harmony export */ });
2399
+ /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
2400
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
2401
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
2402
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
2403
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
2404
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
2405
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
2406
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
2407
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
2408
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
2409
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
2410
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
2411
+ /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
2412
+ /* module decorator */ module = __webpack_require__.hmd(module);
2413
+
2414
+
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
2423
+ async function getIsPrettierAvailable() {
2424
+ var _a;
2425
+ if (getIsPrettierAvailable.cache !== undefined) {
2426
+ return getIsPrettierAvailable.cache;
2427
+ }
2428
+ const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({
2429
+ packageJsonFilePath: undefined
2430
+ });
2431
+ const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
2432
+ const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
2433
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
2434
+ getIsPrettierAvailable.cache = isPrettierAvailable;
2435
+ return isPrettierAvailable;
2436
+ }
2437
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
2438
+ async function getPrettier() {
2439
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
2440
+ if (getPrettier.cache !== undefined) {
2441
+ return getPrettier.cache;
2442
+ }
2443
+ let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
2444
+ import_prettier: {
2445
+ // NOTE: When module is linked we want to make sure we import the correct version
2446
+ // of prettier, that is the one of the project, not the one of this repo.
2447
+ // So we do a sketchy eval to bypass ncc.
2448
+ // We make sure to only do that when linking, otherwise we import properly.
2449
+ if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
2450
+ const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", "prettier"));
2451
+ const isCJS = true && module.exports;
2452
+ if (isCJS) {
2453
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${prettierDirPath}")`);
2454
+ }
2455
+ else {
2456
+ prettier = await new Promise(_resolve => {
2457
+ eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_1__.join)(prettierDirPath, "index.mjs").replace(/\\/g, "/")}").then(prettier => _resolve(prettier))`);
2458
+ });
2459
+ }
2460
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
2461
+ break import_prettier;
2462
+ }
2463
+ prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
2464
+ }
2465
+ const configHash = await (async () => {
2466
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", ".."));
2467
+ if (configFilePath === null) {
2468
+ return "";
2469
+ }
2470
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
2471
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
2472
+ })();
2473
+ const prettierAndConfig = {
2474
+ prettier,
2475
+ configHash
2476
+ };
2477
+ getPrettier.cache = prettierAndConfig;
2478
+ return prettierAndConfig;
2479
+ }
2480
+ async function runPrettier(params) {
2481
+ const { sourceCode, filePath } = params;
2482
+ let formattedSourceCode;
2483
+ try {
2484
+ const { prettier } = await getPrettier();
2485
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
2486
+ resolveConfig: true
2487
+ });
2488
+ if (ignored || inferredParser === null) {
2489
+ return sourceCode;
2490
+ }
2491
+ const config = await prettier.resolveConfig(filePath);
2492
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
2493
+ }
2494
+ catch (error) {
2495
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
2496
+ throw error;
2497
+ }
2498
+ return formattedSourceCode;
2499
+ }
2500
+ //# sourceMappingURL=runPrettier.js.map
2501
+
2502
+ /***/ })
2503
+
2504
+ };
2505
+ ;