keycloakify 11.4.0 → 11.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/356.index.js CHANGED
@@ -694,11 +694,11 @@ async function runPrettier(params) {
694
694
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
695
695
  resolveConfig: true
696
696
  });
697
- if (ignored) {
697
+ if (ignored || inferredParser === null) {
698
698
  return sourceCode;
699
699
  }
700
700
  const config = await prettier.resolveConfig(filePath);
701
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
701
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
702
702
  }
703
703
  catch (error) {
704
704
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
package/bin/392.index.js CHANGED
@@ -196,11 +196,12 @@ var downloadAndExtractArchive = __webpack_require__(38367);
196
196
 
197
197
 
198
198
 
199
+
199
200
  (0,assert/* assert */.h)();
200
201
  function startViteDevServer(params) {
201
- const { buildContext, port } = params;
202
- console.log(source_default().blue(`$ npx vite dev --port ${port}`));
203
- const child = external_child_process_.spawn("npx", ["vite", "dev", "--port", `${port}`], {
202
+ const { buildContext } = params;
203
+ console.log(source_default().blue(`$ npx vite dev`));
204
+ const child = external_child_process_.spawn("npx", ["vite", "dev"], {
204
205
  cwd: buildContext.projectDirPath,
205
206
  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" }),
206
207
  shell: true
@@ -212,6 +213,24 @@ function startViteDevServer(params) {
212
213
  process.stdout.write(data);
213
214
  });
214
215
  child.stderr.on("data", data => process.stderr.write(data));
216
+ const dPort = new Deferred.Deferred();
217
+ {
218
+ const onData = (data) => {
219
+ //Local: http://localhost:8083/
220
+ const match = data
221
+ .toString("utf8")
222
+ .match(/Local:\s*http:\/\/(?:localhost|127\.0\.0\.1):(\d+)\//);
223
+ if (match === null) {
224
+ return;
225
+ }
226
+ child.stdout.off("data", onData);
227
+ const port = parseInt(match[1]);
228
+ (0,assert/* assert */.h)(!isNaN(port));
229
+ dPort.resolve(port);
230
+ };
231
+ child.stdout.on("data", onData);
232
+ }
233
+ return dPort.pr.then(port => ({ port }));
215
234
  }
216
235
  //# sourceMappingURL=startViteDevServer.js.map
217
236
  ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/start-keycloak.js
@@ -452,12 +471,12 @@ async function command(params) {
452
471
  catch (_h) { }
453
472
  const DEFAULT_PORT = 8080;
454
473
  const port = (_c = (_b = cliCommandOptions.port) !== null && _b !== void 0 ? _b : buildContext.startKeycloakOptions.port) !== null && _c !== void 0 ? _c : DEFAULT_PORT;
455
- const devServerPort = (() => {
474
+ const doStartDevServer = (() => {
456
475
  const hasSpaUi = buildContext.implementedThemeTypes.admin.isImplemented ||
457
476
  (buildContext.implementedThemeTypes.account.isImplemented &&
458
477
  buildContext.implementedThemeTypes.account.type === "Single-Page");
459
478
  if (!hasSpaUi) {
460
- return undefined;
479
+ return false;
461
480
  }
462
481
  if (buildContext.bundler !== "vite") {
463
482
  console.log(source_default().yellow([
@@ -465,7 +484,7 @@ async function command(params) {
465
484
  `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`,
466
485
  `For a better development experience, consider migrating to Vite.`
467
486
  ].join(" ")));
468
- return undefined;
487
+ return false;
469
488
  }
470
489
  if (keycloakMajorVersionNumber < 25) {
471
490
  console.log(source_default().yellow([
@@ -473,15 +492,14 @@ async function command(params) {
473
492
  `This mean that you'll have to wait serval seconds for the changes to be reflected in the browser.`,
474
493
  `For a better development experience, select a more recent version of Keycloak.`
475
494
  ].join("\n")));
476
- return undefined;
495
+ return false;
477
496
  }
478
- return port + 1;
497
+ return true;
479
498
  })();
480
- if (devServerPort !== undefined) {
481
- startViteDevServer({
482
- buildContext,
483
- port: devServerPort
484
- });
499
+ let devServerPort = undefined;
500
+ if (doStartDevServer) {
501
+ const { port } = await startViteDevServer({ buildContext });
502
+ devServerPort = port;
485
503
  }
486
504
  const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
487
505
  const dockerRunArgs = [
package/bin/453.index.js CHANGED
@@ -474,11 +474,11 @@ async function runPrettier(params) {
474
474
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
475
475
  resolveConfig: true
476
476
  });
477
- if (ignored) {
477
+ if (ignored || inferredParser === null) {
478
478
  return sourceCode;
479
479
  }
480
480
  const config = await prettier.resolveConfig(filePath);
481
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
481
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
482
482
  }
483
483
  catch (error) {
484
484
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
package/bin/573.index.js CHANGED
@@ -602,6 +602,7 @@ function generateFtlFilesCodeFactory(params) {
602
602
  .replace("{{themeVersion}}", buildContext.themeVersion)
603
603
  .replace("{{fieldNames}}", fieldNames.map(name => `"${name}"`).join(", "))
604
604
  .replace("{{RESOURCES_COMMON}}", constants/* WELL_KNOWN_DIRECTORY_BASE_NAME.RESOURCES_COMMON */.Ju.RESOURCES_COMMON)
605
+ .replace("{{KEYCLOAKIFY_SPA_DEV_SERVER_PORT}}", constants/* KEYCLOAKIFY_SPA_DEV_SERVER_PORT */.Sz)
605
606
  .replace("{{userDefinedExclusions}}", (_a = buildContext.kcContextExclusionsFtlCode) !== null && _a !== void 0 ? _a : "");
606
607
  const ftlObjectToJsCodeDeclaringAnObjectPlaceholder = '{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
607
608
  $("head").prepend(`<script>\n${ftlObjectToJsCodeDeclaringAnObjectPlaceholder}\n</script>`);
package/bin/786.index.js CHANGED
@@ -223,11 +223,11 @@ async function runPrettier(params) {
223
223
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
224
224
  resolveConfig: true
225
225
  });
226
- if (ignored) {
226
+ if (ignored || inferredParser === null) {
227
227
  return sourceCode;
228
228
  }
229
229
  const config = await prettier.resolveConfig(filePath);
230
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
230
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
231
231
  }
232
232
  catch (error) {
233
233
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
package/bin/921.index.js CHANGED
@@ -403,11 +403,11 @@ async function runPrettier(params) {
403
403
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
404
404
  resolveConfig: true
405
405
  });
406
- if (ignored) {
406
+ if (ignored || inferredParser === null) {
407
407
  return sourceCode;
408
408
  }
409
409
  const config = await prettier.resolveConfig(filePath);
410
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
410
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
411
411
  }
412
412
  catch (error) {
413
413
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
package/bin/97.index.js CHANGED
@@ -344,11 +344,11 @@ async function runPrettier(params) {
344
344
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
345
345
  resolveConfig: true
346
346
  });
347
- if (ignored) {
347
+ if (ignored || inferredParser === null) {
348
348
  return sourceCode;
349
349
  }
350
350
  const config = await prettier.resolveConfig(filePath);
351
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
351
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
352
352
  }
353
353
  catch (error) {
354
354
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
@@ -3,5 +3,6 @@ export type BuildContextLike = {
3
3
  };
4
4
  export declare function startViteDevServer(params: {
5
5
  buildContext: BuildContextLike;
6
+ }): Promise<{
6
7
  port: number;
7
- }): void;
8
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.4.0",
3
+ "version": "11.4.2",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,11 @@ import * as fs from "fs";
11
11
  import { join as pathJoin } from "path";
12
12
  import type { BuildContext } from "../../shared/buildContext";
13
13
  import { assert } from "tsafe/assert";
14
- import { type ThemeType, WELL_KNOWN_DIRECTORY_BASE_NAME } from "../../shared/constants";
14
+ import {
15
+ type ThemeType,
16
+ WELL_KNOWN_DIRECTORY_BASE_NAME,
17
+ KEYCLOAKIFY_SPA_DEV_SERVER_PORT
18
+ } from "../../shared/constants";
15
19
  import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
16
20
 
17
21
  export type BuildContextLike = BuildContextLike_replaceImportsInJsCode &
@@ -116,6 +120,7 @@ export function generateFtlFilesCodeFactory(params: {
116
120
  .replace("{{themeVersion}}", buildContext.themeVersion)
117
121
  .replace("{{fieldNames}}", fieldNames.map(name => `"${name}"`).join(", "))
118
122
  .replace("{{RESOURCES_COMMON}}", WELL_KNOWN_DIRECTORY_BASE_NAME.RESOURCES_COMMON)
123
+ .replace("{{KEYCLOAKIFY_SPA_DEV_SERVER_PORT}}", KEYCLOAKIFY_SPA_DEV_SERVER_PORT)
119
124
  .replace(
120
125
  "{{userDefinedExclusions}}",
121
126
  buildContext.kcContextExclusionsFtlCode ?? ""
@@ -101,7 +101,7 @@ redirect_to_dev_server: {
101
101
  break redirect_to_dev_server;
102
102
  }
103
103
 
104
- const devSeverPort = kcContext.properties.KEYCLOAKIFY_SPA_DEV_SERVER_PORT;
104
+ const devSeverPort = kcContext.properties.{{KEYCLOAKIFY_SPA_DEV_SERVER_PORT}};
105
105
 
106
106
  if( !devSeverPort ){
107
107
  break redirect_to_dev_server;
@@ -115,7 +115,7 @@ redirect_to_dev_server: {
115
115
 
116
116
  console.log(kcContext);
117
117
 
118
- redirectUrl.searchParams.set("kcContext", encodeURIComponent(JSON.stringify(kcContext)) );
118
+ redirectUrl.searchParams.set("kcContext", encodeURIComponent(JSON.stringify(kcContext)));
119
119
 
120
120
  window.location.href = redirectUrl.toString();
121
121
 
@@ -380,14 +380,14 @@ export async function command(params: {
380
380
  const port =
381
381
  cliCommandOptions.port ?? buildContext.startKeycloakOptions.port ?? DEFAULT_PORT;
382
382
 
383
- const devServerPort = (() => {
383
+ const doStartDevServer = (() => {
384
384
  const hasSpaUi =
385
385
  buildContext.implementedThemeTypes.admin.isImplemented ||
386
386
  (buildContext.implementedThemeTypes.account.isImplemented &&
387
387
  buildContext.implementedThemeTypes.account.type === "Single-Page");
388
388
 
389
389
  if (!hasSpaUi) {
390
- return undefined;
390
+ return false;
391
391
  }
392
392
 
393
393
  if (buildContext.bundler !== "vite") {
@@ -401,7 +401,7 @@ export async function command(params: {
401
401
  )
402
402
  );
403
403
 
404
- return undefined;
404
+ return false;
405
405
  }
406
406
 
407
407
  if (keycloakMajorVersionNumber < 25) {
@@ -415,17 +415,18 @@ export async function command(params: {
415
415
  )
416
416
  );
417
417
 
418
- return undefined;
418
+ return false;
419
419
  }
420
420
 
421
- return port + 1;
421
+ return true;
422
422
  })();
423
423
 
424
- if (devServerPort !== undefined) {
425
- startViteDevServer({
426
- buildContext,
427
- port: devServerPort
428
- });
424
+ let devServerPort: number | undefined = undefined;
425
+
426
+ if (doStartDevServer) {
427
+ const { port } = await startViteDevServer({ buildContext });
428
+
429
+ devServerPort = port;
429
430
  }
430
431
 
431
432
  const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
@@ -3,6 +3,7 @@ import { assert } from "tsafe/assert";
3
3
  import type { BuildContext } from "../shared/buildContext";
4
4
  import chalk from "chalk";
5
5
  import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
6
+ import { Deferred } from "evt/tools/Deferred";
6
7
 
7
8
  export type BuildContextLike = {
8
9
  projectDirPath: string;
@@ -12,13 +13,12 @@ assert<BuildContext extends BuildContextLike ? true : false>();
12
13
 
13
14
  export function startViteDevServer(params: {
14
15
  buildContext: BuildContextLike;
15
- port: number;
16
- }): void {
17
- const { buildContext, port } = params;
16
+ }): Promise<{ port: number }> {
17
+ const { buildContext } = params;
18
18
 
19
- console.log(chalk.blue(`$ npx vite dev --port ${port}`));
19
+ console.log(chalk.blue(`$ npx vite dev`));
20
20
 
21
- const child = child_process.spawn("npx", ["vite", "dev", "--port", `${port}`], {
21
+ const child = child_process.spawn("npx", ["vite", "dev"], {
22
22
  cwd: buildContext.projectDirPath,
23
23
  env: {
24
24
  ...process.env,
@@ -36,4 +36,31 @@ export function startViteDevServer(params: {
36
36
  });
37
37
 
38
38
  child.stderr.on("data", data => process.stderr.write(data));
39
+
40
+ const dPort = new Deferred<number>();
41
+
42
+ {
43
+ const onData = (data: Buffer) => {
44
+ //Local: http://localhost:8083/
45
+ const match = data
46
+ .toString("utf8")
47
+ .match(/Local:\s*http:\/\/(?:localhost|127\.0\.0\.1):(\d+)\//);
48
+
49
+ if (match === null) {
50
+ return;
51
+ }
52
+
53
+ child.stdout.off("data", onData);
54
+
55
+ const port = parseInt(match[1]);
56
+
57
+ assert(!isNaN(port));
58
+
59
+ dPort.resolve(port);
60
+ };
61
+
62
+ child.stdout.on("data", onData);
63
+ }
64
+
65
+ return dPort.pr.then(port => ({ port }));
39
66
  }
@@ -101,7 +101,7 @@ export async function runPrettier(params: {
101
101
  resolveConfig: true
102
102
  });
103
103
 
104
- if (ignored) {
104
+ if (ignored || inferredParser === null) {
105
105
  return sourceCode;
106
106
  }
107
107
 
@@ -110,7 +110,7 @@ export async function runPrettier(params: {
110
110
  formattedSourceCode = await prettier.format(sourceCode, {
111
111
  ...config,
112
112
  filePath,
113
- parser: inferredParser ?? undefined
113
+ parser: inferredParser
114
114
  });
115
115
  } catch (error) {
116
116
  console.log(
@@ -5496,11 +5496,11 @@ async function runPrettier(params) {
5496
5496
  const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
5497
5497
  resolveConfig: true
5498
5498
  });
5499
- if (ignored) {
5499
+ if (ignored || inferredParser === null) {
5500
5500
  return sourceCode;
5501
5501
  }
5502
5502
  const config = await prettier.resolveConfig(filePath);
5503
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
5503
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
5504
5504
  }
5505
5505
  catch (error) {
5506
5506
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));