keycloakify 11.4.0 → 11.4.1

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/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/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>`);
@@ -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.1",
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
  }