keycloakify 11.4.5 → 11.5.0

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