keycloakify 11.7.3 → 11.8.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 (30) hide show
  1. package/bin/{911.index.js → 297.index.js} +18918 -11359
  2. package/bin/355.index.js +41 -703
  3. package/bin/363.index.js +3 -0
  4. package/bin/369.index.js +968 -0
  5. package/bin/656.index.js +111 -0
  6. package/bin/{288.index.js → 664.index.js} +13 -119
  7. package/bin/780.index.js +9 -7
  8. package/bin/880.index.js +215 -160
  9. package/bin/932.index.js +965 -0
  10. package/bin/97.index.js +2092 -770
  11. package/bin/main.js +52 -24
  12. package/bin/shared/buildContext.d.ts +11 -3
  13. package/package.json +10 -13
  14. package/src/bin/initialize-account-theme/initialize-account-theme.ts +29 -27
  15. package/src/bin/initialize-account-theme/multi-page-boilerplate/i18n.ts +2 -2
  16. package/src/bin/initialize-email-theme.ts +103 -53
  17. package/src/bin/keycloakify/generateResources/generateResources.ts +285 -205
  18. package/src/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.ts → addSyncExtensionsToPostinstallScript.ts} +1 -1
  19. package/src/bin/shared/buildContext.ts +69 -24
  20. package/src/bin/shared/{initializeSpa/initializeSpa.ts → initializeSpa.ts} +3 -3
  21. package/src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts +6 -0
  22. package/vite-plugin/index.js +48 -20
  23. package/bin/313.index.js +0 -377
  24. package/bin/678.index.js +0 -7565
  25. package/bin/9.index.js +0 -850
  26. package/bin/947.index.js +0 -1565
  27. package/bin/shared/initializeSpa/index.d.ts +0 -1
  28. package/src/bin/shared/initializeSpa/index.ts +0 -1
  29. /package/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.d.ts → addSyncExtensionsToPostinstallScript.d.ts} +0 -0
  30. /package/bin/shared/{initializeSpa/initializeSpa.d.ts → initializeSpa.d.ts} +0 -0
package/bin/947.index.js DELETED
@@ -1,1565 +0,0 @@
1
- "use strict";
2
- exports.id = 947;
3
- exports.ids = [947];
4
- exports.modules = {
5
-
6
- /***/ 32947:
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: ./dist/bin/start-keycloak/realmConfig/defaultConfig/index.js + 1 modules
273
- var defaultConfig = __webpack_require__(88984);
274
- // EXTERNAL MODULE: ./dist/bin/start-keycloak/getSupportedDockerImageTags.js
275
- var getSupportedDockerImageTags = __webpack_require__(28434);
276
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
277
- var objectKeys = __webpack_require__(23483);
278
- // EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
279
- var same = __webpack_require__(33805);
280
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/prepareRealmConfig.js
281
-
282
-
283
-
284
-
285
-
286
- assert/* assert */.h;
287
- function prepareRealmConfig(params) {
288
- const { parsedRealmJson, keycloakMajorVersionNumber, buildContext } = params;
289
- const { username } = addOrEditTestUser({
290
- parsedRealmJson,
291
- keycloakMajorVersionNumber
292
- });
293
- const { clientId } = addOrEditClient({
294
- parsedRealmJson,
295
- keycloakMajorVersionNumber
296
- });
297
- editAccountConsoleAndSecurityAdminConsole({ parsedRealmJson });
298
- enableCustomThemes({
299
- parsedRealmJson,
300
- themeName: buildContext.themeNames[0],
301
- implementedThemeTypes: buildContext.implementedThemeTypes
302
- });
303
- enable_custom_events_listeners: {
304
- const name = "keycloakify-logging";
305
- if (parsedRealmJson.eventsListeners.includes(name)) {
306
- break enable_custom_events_listeners;
307
- }
308
- parsedRealmJson.eventsListeners.push(name);
309
- parsedRealmJson.eventsListeners.sort();
310
- }
311
- return {
312
- realmName: parsedRealmJson.realm,
313
- clientName: clientId,
314
- username
315
- };
316
- }
317
- function enableCustomThemes(params) {
318
- const { parsedRealmJson, themeName, implementedThemeTypes } = params;
319
- for (const themeType of (0,objectKeys/* objectKeys */.Y)(implementedThemeTypes)) {
320
- if (!implementedThemeTypes[themeType].isImplemented) {
321
- continue;
322
- }
323
- parsedRealmJson[`${themeType}Theme`] = themeName;
324
- }
325
- }
326
- function addOrEditTestUser(params) {
327
- var _a, _b, _c, _d;
328
- const { parsedRealmJson, keycloakMajorVersionNumber } = params;
329
- const parsedRealmJson_default = (0,defaultConfig/* getDefaultConfig */._)({ keycloakMajorVersionNumber });
330
- const [defaultUser_default] = parsedRealmJson_default.users;
331
- (0,assert/* assert */.h)(defaultUser_default !== undefined);
332
- const defaultUser_preexisting = parsedRealmJson.users.find(user => user.username === defaultUser_default.username);
333
- const newUser = structuredClone((_a = defaultUser_preexisting !== null && defaultUser_preexisting !== void 0 ? defaultUser_preexisting : (() => {
334
- const firstUser = parsedRealmJson.users[0];
335
- if (firstUser === undefined) {
336
- return undefined;
337
- }
338
- const firstUserCopy = structuredClone(firstUser);
339
- firstUserCopy.id = defaultUser_default.id;
340
- return firstUserCopy;
341
- })()) !== null && _a !== void 0 ? _a : defaultUser_default);
342
- newUser.username = defaultUser_default.username;
343
- newUser.email = defaultUser_default.email;
344
- delete_existing_password_credential_if_any: {
345
- const i = newUser.credentials.findIndex(credential => credential.type === "password");
346
- if (i === -1) {
347
- break delete_existing_password_credential_if_any;
348
- }
349
- newUser.credentials.splice(i, 1);
350
- }
351
- {
352
- const credential = defaultUser_default.credentials.find(credential => credential.type === "password");
353
- (0,assert/* assert */.h)(credential !== undefined);
354
- newUser.credentials.push(credential);
355
- }
356
- {
357
- const nameByClientId = Object.fromEntries(parsedRealmJson.clients.map(client => [client.id, client.clientId]));
358
- const newClientRoles = {};
359
- for (const clientRole of Object.values(parsedRealmJson.roles.client).flat()) {
360
- const clientName = nameByClientId[clientRole.containerId];
361
- (0,assert/* assert */.h)(clientName !== undefined);
362
- ((_b = newClientRoles[clientName]) !== null && _b !== void 0 ? _b : (newClientRoles[clientName] = [])).push(clientRole.name);
363
- }
364
- const { same: sameSet } = (0,same.sameFactory)({
365
- takeIntoAccountArraysOrdering: false
366
- });
367
- for (const [clientName, roles] of Object.entries(newClientRoles)) {
368
- keep_previous_ordering_if_possible: {
369
- const roles_previous = (_c = newUser.clientRoles) === null || _c === void 0 ? void 0 : _c[clientName];
370
- if (roles_previous === undefined) {
371
- break keep_previous_ordering_if_possible;
372
- }
373
- if (!sameSet(roles_previous, roles)) {
374
- break keep_previous_ordering_if_possible;
375
- }
376
- continue;
377
- }
378
- ((_d = newUser.clientRoles) !== null && _d !== void 0 ? _d : (newUser.clientRoles = {}))[clientName] = roles;
379
- }
380
- }
381
- if (defaultUser_preexisting === undefined) {
382
- parsedRealmJson.users.push(newUser);
383
- }
384
- else {
385
- const i = parsedRealmJson.users.indexOf(defaultUser_preexisting);
386
- (0,assert/* assert */.h)(i !== -1);
387
- parsedRealmJson.users[i] = newUser;
388
- }
389
- return { username: newUser.username };
390
- }
391
- function addOrEditClient(params) {
392
- var _a;
393
- const { parsedRealmJson, keycloakMajorVersionNumber } = params;
394
- const parsedRealmJson_default = (0,defaultConfig/* getDefaultConfig */._)({ keycloakMajorVersionNumber });
395
- const testClient_default = (() => {
396
- const clients = parsedRealmJson_default.clients.filter(client => {
397
- return JSON.stringify(client).includes(constants/* TEST_APP_URL */.jp);
398
- });
399
- (0,assert/* assert */.h)(clients.length === 1);
400
- return clients[0];
401
- })();
402
- const clientIds_builtIn = parsedRealmJson_default.clients
403
- .map(client => client.clientId)
404
- .filter(clientId => clientId !== testClient_default.clientId);
405
- const testClient_preexisting = (() => {
406
- const clients = parsedRealmJson.clients
407
- .filter(client => !clientIds_builtIn.includes(client.clientId))
408
- .filter(client => client.protocol === "openid-connect");
409
- {
410
- const client = clients.find(client => client.clientId === testClient_default.clientId);
411
- if (client !== undefined) {
412
- return client;
413
- }
414
- }
415
- {
416
- const client = clients.find(client => {
417
- var _a;
418
- return ((_a = client.redirectUris) === null || _a === void 0 ? void 0 : _a.find(redirectUri => redirectUri.startsWith(constants/* TEST_APP_URL */.jp))) !== undefined;
419
- });
420
- if (client !== undefined) {
421
- return client;
422
- }
423
- }
424
- const [client] = clients;
425
- if (client === undefined) {
426
- return undefined;
427
- }
428
- return client;
429
- })();
430
- let testClient;
431
- if (testClient_preexisting !== undefined) {
432
- testClient = testClient_preexisting;
433
- }
434
- else {
435
- testClient = structuredClone(testClient_default);
436
- delete testClient.protocolMappers;
437
- parsedRealmJson.clients.push(testClient);
438
- }
439
- testClient.redirectUris = [
440
- `${constants/* TEST_APP_URL */.jp}/*`,
441
- "http://localhost*",
442
- "http://127.0.0.1*"
443
- ]
444
- .sort()
445
- .reverse();
446
- ((_a = testClient.attributes) !== null && _a !== void 0 ? _a : (testClient.attributes = {}))["post.logout.redirect.uris"] = "+";
447
- testClient.webOrigins = ["*"];
448
- return { clientId: testClient.clientId };
449
- }
450
- function editAccountConsoleAndSecurityAdminConsole(params) {
451
- var _a, _b, _c, _d, _e;
452
- const { parsedRealmJson } = params;
453
- for (const clientId of ["account-console", "security-admin-console"]) {
454
- const client = parsedRealmJson.clients.find(client => client.clientId === clientId);
455
- (0,assert/* assert */.h)(client !== undefined);
456
- {
457
- const arr = ((_a = client.redirectUris) !== null && _a !== void 0 ? _a : (client.redirectUris = []));
458
- for (const value of ["http://localhost*", "http://127.0.0.1*"]) {
459
- if (!arr.includes(value)) {
460
- arr.push(value);
461
- }
462
- }
463
- (_b = client.redirectUris) === null || _b === void 0 ? void 0 : _b.sort().reverse();
464
- }
465
- ((_c = client.attributes) !== null && _c !== void 0 ? _c : (client.attributes = {}))["post.logout.redirect.uris"] = "+";
466
- client.webOrigins = ["*"];
467
- admin_specific: {
468
- if (clientId !== "security-admin-console") {
469
- break admin_specific;
470
- }
471
- const protocolMapper_preexisting = (_d = client.protocolMappers) === null || _d === void 0 ? void 0 : _d.find(protocolMapper => {
472
- if (protocolMapper.protocolMapper !== "oidc-hardcoded-claim-mapper") {
473
- return false;
474
- }
475
- if (protocolMapper.protocol !== "openid-connect") {
476
- return false;
477
- }
478
- if (protocolMapper.config === undefined) {
479
- return false;
480
- }
481
- if (protocolMapper.config["claim.name"] !== "allowed-origins") {
482
- return false;
483
- }
484
- return true;
485
- });
486
- let protocolMapper;
487
- const config = {
488
- "introspection.token.claim": "true",
489
- "claim.value": '["*"]',
490
- "userinfo.token.claim": "true",
491
- "id.token.claim": "false",
492
- "lightweight.claim": "true",
493
- "access.token.claim": "true",
494
- "claim.name": "allowed-origins",
495
- "jsonType.label": "JSON",
496
- "access.tokenResponse.claim": "false"
497
- };
498
- if (protocolMapper_preexisting !== undefined) {
499
- protocolMapper = protocolMapper_preexisting;
500
- }
501
- else {
502
- protocolMapper = {
503
- id: "8fd0d584-7052-4d04-a615-d18a71050873",
504
- name: "allowed-origins",
505
- protocol: "openid-connect",
506
- protocolMapper: "oidc-hardcoded-claim-mapper",
507
- consentRequired: false,
508
- config
509
- };
510
- ((_e = client.protocolMappers) !== null && _e !== void 0 ? _e : (client.protocolMappers = [])).push(protocolMapper);
511
- }
512
- (0,assert/* assert */.h)(protocolMapper.config !== undefined);
513
- if (config !== protocolMapper.config) {
514
- Object.assign(protocolMapper.config, config);
515
- }
516
- }
517
- }
518
- }
519
- //# sourceMappingURL=prepareRealmConfig.js.map
520
- // EXTERNAL MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.js + 1 modules
521
- var readRealmJsonFile = __webpack_require__(96709);
522
- // EXTERNAL MODULE: external "fs/promises"
523
- var promises_ = __webpack_require__(73292);
524
- // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
525
- var runPrettier = __webpack_require__(48433);
526
- ;// CONCATENATED MODULE: ./dist/bin/tools/Stringifyable.js
527
-
528
-
529
-
530
-
531
- const zStringifyableAtomic = (() => {
532
- const zTargetType = lib.z.union([lib.z.string(), lib.z.number(), lib.z.boolean(), lib.z["null"]()]);
533
- (0,assert/* assert */.h)();
534
- return (0,id.id)(zTargetType);
535
- })();
536
- const zStringifyable = lib.z.any()
537
- .superRefine((val, ctx) => {
538
- const isStringifyable = (0,same.same)(JSON.parse(JSON.stringify(val)), val);
539
- if (!isStringifyable) {
540
- ctx.addIssue({
541
- code: lib.z.ZodIssueCode.custom,
542
- message: "Not stringifyable"
543
- });
544
- }
545
- });
546
- function getIsAtomic(stringifyable) {
547
- return (["string", "number", "boolean"].includes(typeof stringifyable) ||
548
- stringifyable === null);
549
- }
550
- const { getValueAtPath } = (() => {
551
- function getValueAtPath_rec(stringifyable, path) {
552
- if (path.length === 0) {
553
- return stringifyable;
554
- }
555
- if (getIsAtomic(stringifyable)) {
556
- return undefined;
557
- }
558
- const [first, ...rest] = path;
559
- let dereferenced;
560
- if (stringifyable instanceof Array) {
561
- if (typeof first !== "number") {
562
- return undefined;
563
- }
564
- dereferenced = stringifyable[first];
565
- }
566
- else {
567
- if (typeof first !== "string") {
568
- return undefined;
569
- }
570
- dereferenced = stringifyable[first];
571
- }
572
- if (dereferenced === undefined) {
573
- return undefined;
574
- }
575
- return getValueAtPath_rec(dereferenced, rest);
576
- }
577
- function getValueAtPath(stringifyableObjectOrArray, path) {
578
- return getValueAtPath_rec(stringifyableObjectOrArray, path);
579
- }
580
- return { getValueAtPath };
581
- })();
582
- //# sourceMappingURL=Stringifyable.js.map
583
- ;// CONCATENATED MODULE: ./dist/bin/tools/canonicalStringify.js
584
-
585
- function canonicalStringify(params) {
586
- const { data, referenceData } = params;
587
- return JSON.stringify(makeDeterministicCopy({
588
- path: [],
589
- data,
590
- getCanonicalKeys: path => {
591
- const referenceValue = (() => {
592
- const path_patched = [];
593
- for (let i = 0; i < path.length; i++) {
594
- let value_i = getValueAtPath(referenceData, [
595
- ...path_patched,
596
- path[i]
597
- ]);
598
- if (value_i !== undefined) {
599
- path_patched.push(path[i]);
600
- continue;
601
- }
602
- if (typeof path[i] !== "number") {
603
- return undefined;
604
- }
605
- value_i = getValueAtPath(referenceData, [...path_patched, 0]);
606
- if (value_i !== undefined) {
607
- path_patched.push(0);
608
- continue;
609
- }
610
- return undefined;
611
- }
612
- return getValueAtPath(referenceData, path_patched);
613
- })();
614
- if (referenceValue === undefined) {
615
- return undefined;
616
- }
617
- if (getIsAtomic(referenceValue)) {
618
- return undefined;
619
- }
620
- if (referenceValue instanceof Array) {
621
- return undefined;
622
- }
623
- return Object.keys(referenceValue);
624
- }
625
- }), null, 2);
626
- }
627
- function makeDeterministicCopy(params) {
628
- const { path, data, getCanonicalKeys } = params;
629
- if (getIsAtomic(data)) {
630
- return data;
631
- }
632
- if (data instanceof Array) {
633
- return makeDeterministicCopy_array({
634
- path,
635
- data,
636
- getCanonicalKeys
637
- });
638
- }
639
- return makeDeterministicCopy_record({
640
- path,
641
- data,
642
- getCanonicalKeys
643
- });
644
- }
645
- function makeDeterministicCopy_record(params) {
646
- const { path, data, getCanonicalKeys } = params;
647
- const keysOfAtomicValues = [];
648
- const keysOfNonAtomicValues = [];
649
- for (const [key, value] of Object.entries(data)) {
650
- if (getIsAtomic(value)) {
651
- keysOfAtomicValues.push(key);
652
- }
653
- else {
654
- keysOfNonAtomicValues.push(key);
655
- }
656
- }
657
- keysOfAtomicValues.sort();
658
- keysOfNonAtomicValues.sort();
659
- const keys = [...keysOfAtomicValues, ...keysOfNonAtomicValues];
660
- reorder_according_to_canonical: {
661
- const canonicalKeys = getCanonicalKeys(path);
662
- if (canonicalKeys === undefined) {
663
- break reorder_according_to_canonical;
664
- }
665
- const keys_toPrepend = [];
666
- for (const key of canonicalKeys) {
667
- const indexOfKey = keys.indexOf(key);
668
- if (indexOfKey === -1) {
669
- continue;
670
- }
671
- keys.splice(indexOfKey, 1);
672
- keys_toPrepend.push(key);
673
- }
674
- keys.unshift(...keys_toPrepend);
675
- }
676
- const result = {};
677
- for (const key of keys) {
678
- result[key] = makeDeterministicCopy({
679
- path: [...path, key],
680
- data: data[key],
681
- getCanonicalKeys
682
- });
683
- }
684
- return result;
685
- }
686
- function makeDeterministicCopy_array(params) {
687
- const { path, data, getCanonicalKeys } = params;
688
- return [...data].map((entry, i) => makeDeterministicCopy({
689
- path: [...path, i],
690
- data: entry,
691
- getCanonicalKeys
692
- }));
693
- }
694
- //# sourceMappingURL=canonicalStringify.js.map
695
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.js
696
-
697
-
698
-
699
-
700
- async function writeRealmJsonFile(params) {
701
- const { realmJsonFilePath, parsedRealmJson, keycloakMajorVersionNumber } = params;
702
- let sourceCode = canonicalStringify({
703
- data: parsedRealmJson,
704
- referenceData: (0,defaultConfig/* getDefaultConfig */._)({
705
- keycloakMajorVersionNumber
706
- })
707
- });
708
- if (await (0,runPrettier/* getIsPrettierAvailable */.MT)()) {
709
- sourceCode = await (0,runPrettier/* runPrettier */.eY)({
710
- sourceCode: sourceCode,
711
- filePath: realmJsonFilePath
712
- });
713
- }
714
- await promises_.writeFile(realmJsonFilePath, Buffer.from(sourceCode, "utf8"));
715
- }
716
- //# sourceMappingURL=writeRealmJsonFile.js.map
717
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/index.js
718
-
719
-
720
- //# sourceMappingURL=index.js.map
721
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/dumpContainerConfig.js
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
- (0,assert/* assert */.h)();
730
- async function dumpContainerConfig(params) {
731
- const { realmName, keycloakMajorVersionNumber, buildContext } = params;
732
- // https://github.com/keycloak/keycloak/issues/33800
733
- const doesUseLockedH2Database = keycloakMajorVersionNumber >= 25;
734
- if (doesUseLockedH2Database) {
735
- const dCompleted = new Deferred.Deferred();
736
- const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "cp -rp /opt/keycloak/data/h2 /tmp"`;
737
- external_child_process_default().exec(cmd, error => {
738
- if (error !== null) {
739
- dCompleted.reject(error);
740
- return;
741
- }
742
- dCompleted.resolve();
743
- });
744
- try {
745
- await dCompleted.pr;
746
- }
747
- catch (error) {
748
- (0,assert/* assert */.h)((0,assert.is)(error));
749
- console.log(source_default().red(`Docker command failed: ${cmd}`));
750
- console.log(source_default().red(error.message));
751
- throw error;
752
- }
753
- }
754
- {
755
- const dCompleted = new Deferred.Deferred();
756
- const child = external_child_process_default().spawn("docker", [
757
- ...["exec", constants/* CONTAINER_NAME */.sv],
758
- ...["/opt/keycloak/bin/kc.sh", "export"],
759
- ...["--dir", "/tmp"],
760
- ...["--realm", realmName],
761
- ...["--users", "realm_file"],
762
- ...(!doesUseLockedH2Database
763
- ? []
764
- : [
765
- ...["--db", "dev-file"],
766
- ...[
767
- "--db-url",
768
- '"jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE"'
769
- ]
770
- ])
771
- ], { shell: true });
772
- let output = "";
773
- const onExit = (code) => {
774
- dCompleted.reject(new Error(`docker exec kc.sh export command failed with code ${code}`));
775
- };
776
- child.once("exit", onExit);
777
- child.stdout.on("data", data => {
778
- const outputStr = data.toString("utf8");
779
- if (outputStr.includes("Export finished successfully")) {
780
- child.removeListener("exit", onExit);
781
- // NOTE: On older Keycloak versions the process keeps running after the export is done.
782
- const timer = setTimeout(() => {
783
- child.removeListener("exit", onExit2);
784
- child.kill();
785
- dCompleted.resolve();
786
- }, 1500);
787
- const onExit2 = () => {
788
- clearTimeout(timer);
789
- dCompleted.resolve();
790
- };
791
- child.once("exit", onExit2);
792
- }
793
- output += outputStr;
794
- });
795
- child.stderr.on("data", data => (output += source_default().red(data.toString("utf8"))));
796
- try {
797
- await dCompleted.pr;
798
- }
799
- catch (error) {
800
- (0,assert/* assert */.h)((0,assert.is)(error));
801
- console.log(source_default().red(error.message));
802
- console.log(output);
803
- throw error;
804
- }
805
- }
806
- if (doesUseLockedH2Database) {
807
- const dCompleted = new Deferred.Deferred();
808
- const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "rm -rf /tmp/h2"`;
809
- external_child_process_default().exec(cmd, error => {
810
- if (error !== null) {
811
- dCompleted.reject(error);
812
- return;
813
- }
814
- dCompleted.resolve();
815
- });
816
- try {
817
- await dCompleted.pr;
818
- }
819
- catch (error) {
820
- (0,assert/* assert */.h)((0,assert.is)(error));
821
- console.log(source_default().red(`Docker command failed: ${cmd}`));
822
- console.log(source_default().red(error.message));
823
- throw error;
824
- }
825
- }
826
- const targetRealmConfigJsonFilePath_tmp = (0,external_path_.join)(buildContext.cacheDirPath, "realm.json");
827
- {
828
- const dCompleted = new Deferred.Deferred();
829
- const cmd = `docker cp ${constants/* CONTAINER_NAME */.sv}:/tmp/${realmName}-realm.json ${(0,external_path_.basename)(targetRealmConfigJsonFilePath_tmp)}`;
830
- external_child_process_default().exec(cmd, {
831
- cwd: (0,external_path_.dirname)(targetRealmConfigJsonFilePath_tmp)
832
- }, error => {
833
- if (error !== null) {
834
- dCompleted.reject(error);
835
- return;
836
- }
837
- dCompleted.resolve();
838
- });
839
- try {
840
- await dCompleted.pr;
841
- }
842
- catch (error) {
843
- (0,assert/* assert */.h)((0,assert.is)(error));
844
- console.log(source_default().red(`Docker command failed: ${cmd}`));
845
- console.log(source_default().red(error.message));
846
- throw error;
847
- }
848
- }
849
- return (0,readRealmJsonFile/* readRealmJsonFile */.X)({
850
- realmJsonFilePath: targetRealmConfigJsonFilePath_tmp
851
- });
852
- }
853
- //# sourceMappingURL=dumpContainerConfig.js.map
854
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/realmConfig.js
855
-
856
-
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
- assert/* assert */.h;
867
- async function getRealmConfig(params) {
868
- const { keycloakMajorVersionNumber, realmJsonFilePath_userProvided, buildContext } = params;
869
- const realmJsonFilePath = (0,external_path_.join)(buildContext.projectDirPath, ".keycloakify", `realm-kc-${keycloakMajorVersionNumber}.json`);
870
- const parsedRealmJson = await (async () => {
871
- if (realmJsonFilePath_userProvided !== undefined) {
872
- return (0,readRealmJsonFile/* readRealmJsonFile */.X)({
873
- realmJsonFilePath: realmJsonFilePath_userProvided
874
- });
875
- }
876
- if (await (0,fs_existsAsync/* existsAsync */.o)(realmJsonFilePath)) {
877
- return (0,readRealmJsonFile/* readRealmJsonFile */.X)({
878
- realmJsonFilePath
879
- });
880
- }
881
- return (0,defaultConfig/* getDefaultConfig */._)({ keycloakMajorVersionNumber });
882
- })();
883
- const { clientName, realmName, username } = prepareRealmConfig({
884
- parsedRealmJson,
885
- buildContext,
886
- keycloakMajorVersionNumber
887
- });
888
- {
889
- const dirPath = (0,external_path_.dirname)(realmJsonFilePath);
890
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
891
- external_fs_.mkdirSync(dirPath, { recursive: true });
892
- }
893
- }
894
- await writeRealmJsonFile({
895
- realmJsonFilePath,
896
- parsedRealmJson,
897
- keycloakMajorVersionNumber
898
- });
899
- const { onRealmConfigChange } = (() => {
900
- const run = runExclusive.build(async () => {
901
- const start = Date.now();
902
- console.log(source_default().grey(`Changes detected to the '${realmName}' config, backing up...`));
903
- let parsedRealmJson;
904
- try {
905
- parsedRealmJson = await dumpContainerConfig({
906
- buildContext,
907
- realmName,
908
- keycloakMajorVersionNumber
909
- });
910
- }
911
- catch (error) {
912
- console.log(source_default().red(`Failed to backup '${realmName}' config:`));
913
- return;
914
- }
915
- await writeRealmJsonFile({
916
- realmJsonFilePath,
917
- parsedRealmJson,
918
- keycloakMajorVersionNumber
919
- });
920
- console.log([
921
- source_default().grey(`Save changed to \`.${external_path_.sep}${(0,external_path_.relative)(buildContext.projectDirPath, realmJsonFilePath)}\``),
922
- source_default().grey(`Next time you'll be running \`keycloakify start-keycloak\`, the realm '${realmName}' will be restored to this state.`),
923
- source_default().green(`✓ '${realmName}' config backed up completed in ${Date.now() - start}ms`)
924
- ].join("\n"));
925
- });
926
- const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({
927
- delay: 1000
928
- });
929
- async function onRealmConfigChange() {
930
- await waitForDebounce();
931
- run();
932
- }
933
- return { onRealmConfigChange };
934
- })();
935
- return {
936
- realmJsonFilePath,
937
- clientName,
938
- realmName,
939
- username,
940
- onRealmConfigChange
941
- };
942
- }
943
- //# sourceMappingURL=realmConfig.js.map
944
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/index.js
945
-
946
- //# sourceMappingURL=index.js.map
947
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/start-keycloak.js
948
-
949
-
950
-
951
-
952
-
953
-
954
-
955
-
956
-
957
-
958
-
959
-
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
-
971
-
972
-
973
- async function command(params) {
974
- var _a, _b, _c, _d, _e;
975
- exit_if_docker_not_installed: {
976
- let commandOutput = undefined;
977
- try {
978
- commandOutput = (_a = external_child_process_.execSync("docker --version", {
979
- stdio: ["ignore", "pipe", "ignore"]
980
- })) === null || _a === void 0 ? void 0 : _a.toString("utf8");
981
- }
982
- catch (_f) { }
983
- if ((commandOutput === null || commandOutput === void 0 ? void 0 : commandOutput.includes("Docker")) || (commandOutput === null || commandOutput === void 0 ? void 0 : commandOutput.includes("podman"))) {
984
- break exit_if_docker_not_installed;
985
- }
986
- console.log([
987
- `${source_default().red("Docker required.")}`,
988
- `Install it with Docker Desktop: ${source_default().bold.underline("https://www.docker.com/products/docker-desktop/")}`,
989
- `(or any other way)`
990
- ].join(" "));
991
- process.exit(1);
992
- }
993
- exit_if_docker_not_running: {
994
- let isDockerRunning;
995
- try {
996
- external_child_process_.execSync("docker info", { stdio: "ignore" });
997
- isDockerRunning = true;
998
- }
999
- catch (_g) {
1000
- isDockerRunning = false;
1001
- }
1002
- if (isDockerRunning) {
1003
- break exit_if_docker_not_running;
1004
- }
1005
- console.log([
1006
- `${source_default().red("Docker daemon is not running.")}`,
1007
- `Please start Docker Desktop and try again.`
1008
- ].join(" "));
1009
- process.exit(1);
1010
- }
1011
- const { cliCommandOptions, buildContext } = params;
1012
- const { allSupportedTags, latestMajorTags } = await (0,getSupportedDockerImageTags/* getSupportedDockerImageTags */.z)({
1013
- buildContext
1014
- });
1015
- const { dockerImageTag } = await (async () => {
1016
- if (cliCommandOptions.keycloakVersion !== undefined) {
1017
- const cliCommandOptions_keycloakVersion = cliCommandOptions.keycloakVersion;
1018
- const tag = allSupportedTags.find(tag => tag.startsWith(cliCommandOptions_keycloakVersion));
1019
- if (tag === undefined) {
1020
- console.log(source_default().red([
1021
- `We could not find a Keycloak Docker image for ${cliCommandOptions_keycloakVersion}`,
1022
- `Example of valid values: --keycloak-version 26, --keycloak-version 26.0.7`
1023
- ].join("\n")));
1024
- process.exit(1);
1025
- }
1026
- return { dockerImageTag: tag };
1027
- }
1028
- if (buildContext.startKeycloakOptions.dockerImage !== undefined) {
1029
- return {
1030
- dockerImageTag: buildContext.startKeycloakOptions.dockerImage.tag
1031
- };
1032
- }
1033
- console.log([
1034
- source_default().cyan("On which version of Keycloak do you want to test your theme?"),
1035
- source_default().gray("You can also explicitly provide the version with `npx keycloakify start-keycloak --keycloak-version 26` (or any other version)")
1036
- ].join("\n"));
1037
- const tag_userSelected = await (async () => {
1038
- let tag;
1039
- let latestMajorTags_copy = [...latestMajorTags];
1040
- while (true) {
1041
- const { value } = await dist_default()({
1042
- values: latestMajorTags_copy
1043
- }).catch(() => {
1044
- process.exit(-1);
1045
- });
1046
- tag = value;
1047
- {
1048
- const doImplementAccountMpa = buildContext.implementedThemeTypes.account.isImplemented &&
1049
- buildContext.implementedThemeTypes.account.type === "Multi-Page";
1050
- if (doImplementAccountMpa && tag.startsWith("22.")) {
1051
- console.log(source_default().yellow(`You are implementing a Multi-Page Account theme. Keycloak 22 is not supported, select another version`));
1052
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => !tag.startsWith("22."));
1053
- continue;
1054
- }
1055
- }
1056
- const readMajor = (tag) => {
1057
- const major = parseInt(tag.split(".")[0]);
1058
- (0,assert/* assert */.h)(!isNaN(major));
1059
- return major;
1060
- };
1061
- {
1062
- const major = readMajor(tag);
1063
- const doImplementAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
1064
- const getIsSupported = (major) => major >= 23;
1065
- if (doImplementAdminTheme && !getIsSupported(major)) {
1066
- console.log(source_default().yellow(`You are implementing an Admin theme. Only Keycloak 23 and later are supported, select another version`));
1067
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
1068
- continue;
1069
- }
1070
- }
1071
- {
1072
- const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
1073
- buildContext.implementedThemeTypes.account.type === "Single-Page";
1074
- const major = readMajor(tag);
1075
- const getIsSupported = (major) => major >= 19;
1076
- if (doImplementAccountSpa && !getIsSupported(major)) {
1077
- console.log(source_default().yellow(`You are implementing a Single-Page Account theme. Only Keycloak 19 and later are supported, select another version`));
1078
- latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
1079
- continue;
1080
- }
1081
- }
1082
- break;
1083
- }
1084
- return tag;
1085
- })();
1086
- console.log(`→ ${tag_userSelected}`);
1087
- return { dockerImageTag: tag_userSelected };
1088
- })();
1089
- const keycloakMajorVersionNumber = (() => {
1090
- const [wrap] = (0,defaultConfig/* getSupportedKeycloakMajorVersions */.Z)()
1091
- .map(majorVersionNumber => ({
1092
- majorVersionNumber,
1093
- index: dockerImageTag.indexOf(`${majorVersionNumber}`)
1094
- }))
1095
- .filter(({ index }) => index !== -1)
1096
- .sort((a, b) => a.index - b.index);
1097
- if (wrap === undefined) {
1098
- try {
1099
- const version = SemVer/* SemVer.parse */.h.parse(dockerImageTag);
1100
- console.error(source_default().yellow(`Keycloak version ${version.major} is not supported, supported versions are ${(0,defaultConfig/* getSupportedKeycloakMajorVersions */.Z)().join(", ")}`));
1101
- process.exit(1);
1102
- }
1103
- catch (_a) {
1104
- // NOTE: Latest version
1105
- const [n] = (0,defaultConfig/* getSupportedKeycloakMajorVersions */.Z)();
1106
- console.warn(source_default().yellow(`Could not determine the major Keycloak version number from the docker image tag ${dockerImageTag}. Assuming ${n}`));
1107
- return n;
1108
- }
1109
- }
1110
- return wrap.majorVersionNumber;
1111
- })();
1112
- const { clientName, onRealmConfigChange, realmJsonFilePath, realmName, username } = await getRealmConfig({
1113
- keycloakMajorVersionNumber,
1114
- realmJsonFilePath_userProvided: await (async () => {
1115
- if (cliCommandOptions.realmJsonFilePath !== undefined) {
1116
- return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
1117
- pathIsh: cliCommandOptions.realmJsonFilePath,
1118
- cwd: process.cwd()
1119
- });
1120
- }
1121
- if (buildContext.startKeycloakOptions.realmJsonFilePath !== undefined) {
1122
- (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`);
1123
- return buildContext.startKeycloakOptions.realmJsonFilePath;
1124
- }
1125
- return undefined;
1126
- })(),
1127
- buildContext
1128
- });
1129
- {
1130
- const { isAppBuildSuccess } = await appBuild({
1131
- buildContext
1132
- });
1133
- if (!isAppBuildSuccess) {
1134
- console.log(source_default().red(`App build failed, exiting. Try building your app (e.g 'npm run build') and see what's wrong.`));
1135
- process.exit(1);
1136
- }
1137
- const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
1138
- buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
1139
- buildContext
1140
- });
1141
- if (!isKeycloakifyBuildSuccess) {
1142
- console.log(source_default().red(`Keycloakify build failed, exiting. Try running 'npx keycloakify build' and see what's wrong.`));
1143
- process.exit(1);
1144
- }
1145
- }
1146
- const jarFilePath = external_fs_.readdirSync(buildContext.keycloakifyBuildDirPath)
1147
- .filter(fileBasename => fileBasename.endsWith(".jar"))
1148
- .map(fileBasename => (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, fileBasename))
1149
- .sort((a, b) => external_fs_.statSync(b).mtimeMs - external_fs_.statSync(a).mtimeMs)[0];
1150
- (0,assert/* assert */.h)(jarFilePath !== undefined);
1151
- const extensionJarFilePaths = [
1152
- ...(keycloakMajorVersionNumber <= 20
1153
- ? (console.log(source_default().yellow("WARNING: With older version of keycloak your changes to the realm configuration are not persisted")),
1154
- [])
1155
- : [
1156
- (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", constants/* KEYCLOAKIFY_LOGIN_JAR_BASENAME */.Tr)
1157
- ]),
1158
- ...(await Promise.all(buildContext.startKeycloakOptions.extensionJars.map(async (extensionJar) => {
1159
- switch (extensionJar.type) {
1160
- case "path": {
1161
- (0,assert/* assert */.h)(await (0,fs_existsAsync/* existsAsync */.o)(extensionJar.path), `${extensionJar.path} does not exist`);
1162
- return extensionJar.path;
1163
- }
1164
- case "url": {
1165
- const { archiveFilePath } = await (0,downloadAndExtractArchive/* downloadAndExtractArchive */.I)({
1166
- cacheDirPath: buildContext.cacheDirPath,
1167
- fetchOptions: buildContext.fetchOptions,
1168
- url: extensionJar.url,
1169
- uniqueIdOfOnArchiveFile: "no extraction",
1170
- onArchiveFile: async () => { }
1171
- });
1172
- return archiveFilePath;
1173
- }
1174
- }
1175
- (0,assert/* assert */.h)(false);
1176
- })))
1177
- ];
1178
- async function extractThemeResourcesFromJar() {
1179
- await (0,extractArchive/* extractArchive */.N)({
1180
- archiveFilePath: jarFilePath,
1181
- onArchiveFile: async ({ relativeFilePathInArchive, writeFile }) => {
1182
- if ((0,isInside/* isInside */.V)({ dirPath: "theme", filePath: relativeFilePathInArchive })) {
1183
- await writeFile({
1184
- filePath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, relativeFilePathInArchive)
1185
- });
1186
- }
1187
- }
1188
- });
1189
- }
1190
- {
1191
- const destDirPath = (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme");
1192
- if (await (0,fs_existsAsync/* existsAsync */.o)(destDirPath)) {
1193
- await (0,fs_rm.rm)(destDirPath, { recursive: true });
1194
- }
1195
- }
1196
- await extractThemeResourcesFromJar();
1197
- const jarFilePath_cacheDir = (0,external_path_.join)(buildContext.cacheDirPath, (0,external_path_.basename)(jarFilePath));
1198
- external_fs_.copyFileSync(jarFilePath, jarFilePath_cacheDir);
1199
- try {
1200
- external_child_process_.execSync(`docker rm --force ${constants/* CONTAINER_NAME */.sv}`, {
1201
- stdio: "ignore"
1202
- });
1203
- }
1204
- catch (_h) { }
1205
- const port = (_c = (_b = cliCommandOptions.port) !== null && _b !== void 0 ? _b : buildContext.startKeycloakOptions.port) !== null && _c !== void 0 ? _c : 8080;
1206
- const doStartDevServer = (() => {
1207
- const hasSpaUi = buildContext.implementedThemeTypes.admin.isImplemented ||
1208
- (buildContext.implementedThemeTypes.account.isImplemented &&
1209
- buildContext.implementedThemeTypes.account.type === "Single-Page");
1210
- if (!hasSpaUi) {
1211
- return false;
1212
- }
1213
- if (buildContext.bundler !== "vite") {
1214
- console.log(source_default().yellow([
1215
- `WARNING: Since you are using ${buildContext.bundler} instead of Vite,`,
1216
- `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`,
1217
- `For a better development experience, consider migrating to Vite.`
1218
- ].join(" ")));
1219
- return false;
1220
- }
1221
- if (keycloakMajorVersionNumber < 25) {
1222
- console.log(source_default().yellow([
1223
- `WARNING: Your account or admin theme can't be tested with hot module replacement on Keycloak ${keycloakMajorVersionNumber}.`,
1224
- `This mean that you'll have to wait serval seconds for the changes to be reflected in the browser.`,
1225
- `For a better development experience, select a more recent version of Keycloak.`
1226
- ].join("\n")));
1227
- return false;
1228
- }
1229
- return true;
1230
- })();
1231
- let devServerPort = undefined;
1232
- if (doStartDevServer) {
1233
- const { port } = await startViteDevServer({ buildContext });
1234
- devServerPort = port;
1235
- }
1236
- const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
1237
- const dockerRunArgs = [
1238
- `-p${SPACE_PLACEHOLDER}${port}:8080`,
1239
- `--name${SPACE_PLACEHOLDER}${constants/* CONTAINER_NAME */.sv}`,
1240
- ...(keycloakMajorVersionNumber >= 26
1241
- ? [
1242
- `-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_USERNAME=admin`,
1243
- `-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_PASSWORD=admin`
1244
- ]
1245
- : [
1246
- `-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN=admin`,
1247
- `-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN_PASSWORD=admin`
1248
- ]),
1249
- ...(devServerPort === undefined
1250
- ? []
1251
- : [
1252
- `-e${SPACE_PLACEHOLDER}${constants/* KEYCLOAKIFY_SPA_DEV_SERVER_PORT */.Sz}=${devServerPort}`
1253
- ]),
1254
- ...(buildContext.startKeycloakOptions.dockerExtraArgs.length === 0
1255
- ? []
1256
- : [
1257
- buildContext.startKeycloakOptions.dockerExtraArgs.join(SPACE_PLACEHOLDER)
1258
- ]),
1259
- ...(realmJsonFilePath === undefined
1260
- ? []
1261
- : [
1262
- `-v${SPACE_PLACEHOLDER}"${realmJsonFilePath}":/opt/keycloak/data/import/${realmName}-realm.json`
1263
- ]),
1264
- `-v${SPACE_PLACEHOLDER}"${jarFilePath_cacheDir}":/opt/keycloak/providers/keycloak-theme.jar`,
1265
- ...extensionJarFilePaths.map(jarFilePath => `-v${SPACE_PLACEHOLDER}"${jarFilePath}":/opt/keycloak/providers/${(0,external_path_.basename)(jarFilePath)}`),
1266
- ...(keycloakMajorVersionNumber <= 20
1267
- ? [`-e${SPACE_PLACEHOLDER}JAVA_OPTS=-Dkeycloak.profile=preview`]
1268
- : []),
1269
- ...[
1270
- ...buildContext.themeNames,
1271
- ...(external_fs_.existsSync((0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", "account-v1"))
1272
- ? ["account-v1"]
1273
- : [])
1274
- ]
1275
- .map(themeName => ({
1276
- localDirPath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", themeName),
1277
- containerDirPath: `/opt/keycloak/themes/${themeName}`
1278
- }))
1279
- .map(({ localDirPath, containerDirPath }) => `-v${SPACE_PLACEHOLDER}"${localDirPath}":${containerDirPath}:rw`),
1280
- ...buildContext.environmentVariables
1281
- .map(({ name }) => ({ name, envValue: process.env[name] }))
1282
- .map(({ name, envValue }) => envValue === undefined ? undefined : { name, envValue })
1283
- .filter((0,exclude/* exclude */.D)(undefined))
1284
- .map(({ name, envValue }) => `--env${SPACE_PLACEHOLDER}${name}='${envValue.replace(/'/g, "'\\''")}'`),
1285
- `${(_e = (_d = buildContext.startKeycloakOptions.dockerImage) === null || _d === void 0 ? void 0 : _d.reference) !== null && _e !== void 0 ? _e : "quay.io/keycloak/keycloak"}:${dockerImageTag}`,
1286
- "start-dev",
1287
- ...(21 <= keycloakMajorVersionNumber && keycloakMajorVersionNumber < 24
1288
- ? ["--features=declarative-user-profile"]
1289
- : []),
1290
- ...(realmJsonFilePath === undefined ? [] : ["--import-realm"]),
1291
- ...(buildContext.startKeycloakOptions.keycloakExtraArgs.length === 0
1292
- ? []
1293
- : [
1294
- buildContext.startKeycloakOptions.keycloakExtraArgs.join(SPACE_PLACEHOLDER)
1295
- ])
1296
- ];
1297
- console.log(source_default().blue([
1298
- `$ docker run \\`,
1299
- ...dockerRunArgs
1300
- .map(arg => arg.replace(new RegExp(SPACE_PLACEHOLDER, "g"), " "))
1301
- .map((line, i, arr) => ` ${line}${arr.length - 1 === i ? "" : " \\"}`)
1302
- ].join("\n")));
1303
- const child = external_child_process_.spawn("docker", ["run", ...dockerRunArgs.map(line => line.split(SPACE_PLACEHOLDER)).flat()], { shell: true });
1304
- child.stdout.on("data", async (data) => {
1305
- if (data.toString("utf8").includes("keycloakify-logging: REALM_CONFIG_CHANGED")) {
1306
- await onRealmConfigChange();
1307
- return;
1308
- }
1309
- process.stdout.write(data);
1310
- });
1311
- child.stderr.on("data", data => process.stderr.write(data));
1312
- child.on("exit", process.exit);
1313
- const srcDirPath = (0,external_path_.join)(buildContext.projectDirPath, "src");
1314
- {
1315
- const kcHttpRelativePath = (() => {
1316
- const match = buildContext.startKeycloakOptions.dockerExtraArgs
1317
- .join(" ")
1318
- .match(/KC_HTTP_RELATIVE_PATH=([^ ]+)/);
1319
- if (match === null) {
1320
- return undefined;
1321
- }
1322
- return match[1];
1323
- })();
1324
- const handler = async (data) => {
1325
- if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) {
1326
- return;
1327
- }
1328
- child.stdout.off("data", handler);
1329
- await new Promise(resolve => setTimeout(resolve, 1000));
1330
- console.log([
1331
- "",
1332
- `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.`,
1333
- "",
1334
- `Keycloak Admin console: ${source_default().cyan.bold(`http://localhost:${port}${kcHttpRelativePath !== null && kcHttpRelativePath !== void 0 ? kcHttpRelativePath : ""}`)}`,
1335
- `- user: ${source_default().cyan.bold("admin")}`,
1336
- `- password: ${source_default().cyan.bold("admin")}`,
1337
- "",
1338
- "",
1339
- `${source_default().green("Your theme is accessible at:")}`,
1340
- `${source_default().green("➜")} ${source_default().cyan.bold((() => {
1341
- const url = new URL(constants/* TEST_APP_URL */.jp);
1342
- if (port !== 8080) {
1343
- url.searchParams.set("port", `${port}`);
1344
- }
1345
- if (kcHttpRelativePath !== undefined) {
1346
- url.searchParams.set("kcHttpRelativePath", kcHttpRelativePath);
1347
- }
1348
- if (realmName !== "myrealm") {
1349
- url.searchParams.set("realm", realmName);
1350
- }
1351
- if (clientName !== "myclient") {
1352
- url.searchParams.set("client", clientName);
1353
- }
1354
- return url.href;
1355
- })())}`,
1356
- "",
1357
- "You can login with the following credentials:",
1358
- `- username: ${source_default().cyan.bold(username)}`,
1359
- `- password: ${source_default().cyan.bold("password123")}`,
1360
- "",
1361
- `Watching for changes in ${source_default().bold(`.${external_path_.sep}${(0,external_path_.relative)(process.cwd(), buildContext.projectDirPath)}`)}`
1362
- ].join("\n"));
1363
- };
1364
- child.stdout.on("data", handler);
1365
- }
1366
- {
1367
- const runFullBuild = runExclusive.build(async () => {
1368
- console.log(source_default().cyan("Detected changes in the theme. Rebuilding ..."));
1369
- const { isAppBuildSuccess } = await appBuild({
1370
- buildContext
1371
- });
1372
- if (!isAppBuildSuccess) {
1373
- return;
1374
- }
1375
- const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
1376
- buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
1377
- buildContext
1378
- });
1379
- if (!isKeycloakifyBuildSuccess) {
1380
- return;
1381
- }
1382
- await extractThemeResourcesFromJar();
1383
- console.log(source_default().green("Theme rebuilt and updated in Keycloak."));
1384
- });
1385
- const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({ delay: 400 });
1386
- chokidar.watch([
1387
- srcDirPath,
1388
- buildContext.publicDirPath,
1389
- (0,external_path_.join)(buildContext.projectDirPath, "package.json"),
1390
- (0,external_path_.join)(buildContext.projectDirPath, "vite.config.ts"),
1391
- (0,external_path_.join)(buildContext.projectDirPath, "vite.config.js"),
1392
- (0,external_path_.join)(buildContext.projectDirPath, "index.html"),
1393
- (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src")
1394
- ], {
1395
- ignoreInitial: true
1396
- })
1397
- .on("all", async (...[, filePath]) => {
1398
- ignore_path_covered_by_hmr: {
1399
- if (filePath.endsWith(".properties")) {
1400
- break ignore_path_covered_by_hmr;
1401
- }
1402
- if (!doStartDevServer) {
1403
- break ignore_path_covered_by_hmr;
1404
- }
1405
- ignore_account_spa: {
1406
- const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
1407
- buildContext.implementedThemeTypes.account.type ===
1408
- "Single-Page";
1409
- if (!doImplementAccountSpa) {
1410
- break ignore_account_spa;
1411
- }
1412
- if (!(0,isInside/* isInside */.V)({
1413
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "account"),
1414
- filePath
1415
- })) {
1416
- break ignore_account_spa;
1417
- }
1418
- return;
1419
- }
1420
- ignore_admin: {
1421
- if (!buildContext.implementedThemeTypes.admin.isImplemented) {
1422
- break ignore_admin;
1423
- }
1424
- if (!(0,isInside/* isInside */.V)({
1425
- dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "admin"),
1426
- filePath
1427
- })) {
1428
- break ignore_admin;
1429
- }
1430
- return;
1431
- }
1432
- }
1433
- console.log(`Detected changes in ${filePath}`);
1434
- await waitForDebounce();
1435
- runFullBuild();
1436
- });
1437
- }
1438
- }
1439
- //# sourceMappingURL=start-keycloak.js.map
1440
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/index.js
1441
-
1442
- //# sourceMappingURL=index.js.map
1443
-
1444
- /***/ }),
1445
-
1446
- /***/ 90665:
1447
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1448
-
1449
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1450
- /* harmony export */ "V": () => (/* binding */ isInside)
1451
- /* harmony export */ });
1452
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
1453
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
1454
-
1455
- function isInside(params) {
1456
- const { dirPath, filePath } = params;
1457
- return !(0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(dirPath, filePath).startsWith("..");
1458
- }
1459
- //# sourceMappingURL=isInside.js.map
1460
-
1461
- /***/ }),
1462
-
1463
- /***/ 48433:
1464
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1465
-
1466
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1467
- /* harmony export */ "LG": () => (/* binding */ getPrettier),
1468
- /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
1469
- /* harmony export */ "eY": () => (/* binding */ runPrettier)
1470
- /* harmony export */ });
1471
- /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
1472
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
1473
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1474
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
1475
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
1476
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
1477
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
1478
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
1479
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
1480
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
1481
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
1482
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
1483
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
1484
-
1485
-
1486
-
1487
-
1488
-
1489
-
1490
-
1491
-
1492
-
1493
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1494
- async function getIsPrettierAvailable() {
1495
- var _a;
1496
- if (getIsPrettierAvailable.cache !== undefined) {
1497
- return getIsPrettierAvailable.cache;
1498
- }
1499
- const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)();
1500
- const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
1501
- const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
1502
- const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
1503
- getIsPrettierAvailable.cache = isPrettierAvailable;
1504
- return isPrettierAvailable;
1505
- }
1506
- getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1507
- async function getPrettier() {
1508
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
1509
- if (getPrettier.cache !== undefined) {
1510
- return getPrettier.cache;
1511
- }
1512
- let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1513
- import_prettier: {
1514
- // NOTE: When module is linked we want to make sure we import the correct version
1515
- // of prettier, that is the one of the project, not the one of this repo.
1516
- // So we do a sketchy eval to bypass ncc.
1517
- // We make sure to only do that when linking, otherwise we import properly.
1518
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
1519
- 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"))}")`);
1520
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
1521
- break import_prettier;
1522
- }
1523
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
1524
- }
1525
- const configHash = await (async () => {
1526
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
1527
- if (configFilePath === null) {
1528
- return "";
1529
- }
1530
- const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
1531
- return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
1532
- })();
1533
- const prettierAndConfig = {
1534
- prettier,
1535
- configHash
1536
- };
1537
- getPrettier.cache = prettierAndConfig;
1538
- return prettierAndConfig;
1539
- }
1540
- async function runPrettier(params) {
1541
- const { sourceCode, filePath } = params;
1542
- let formattedSourceCode;
1543
- try {
1544
- const { prettier } = await getPrettier();
1545
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
1546
- resolveConfig: true
1547
- });
1548
- if (ignored || inferredParser === null) {
1549
- return sourceCode;
1550
- }
1551
- const config = await prettier.resolveConfig(filePath);
1552
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
1553
- }
1554
- catch (error) {
1555
- console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
1556
- throw error;
1557
- }
1558
- return formattedSourceCode;
1559
- }
1560
- //# sourceMappingURL=runPrettier.js.map
1561
-
1562
- /***/ })
1563
-
1564
- };
1565
- ;