keycloakify 11.15.7 → 11.15.8-rc.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/254.index.js CHANGED
@@ -16,18 +16,20 @@ __webpack_require__.r(__webpack_exports__);
16
16
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
17
17
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
18
18
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
19
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(38469);
19
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(38469);
20
20
  /* harmony import */ var _shared_addSyncExtensionsToPostinstallScript__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(80339);
21
21
  /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(48433);
22
22
  /* harmony import */ var _tools_npmInstall__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(63046);
23
23
  /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(32081);
24
24
  /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_7__);
25
- /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(52300);
25
+ /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(52300);
26
26
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(78818);
27
27
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_8__);
28
28
  /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(99398);
29
29
  /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(cli_select__WEBPACK_IMPORTED_MODULE_9__);
30
30
  /* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(43765);
31
+ /* harmony import */ var _sync_extensions_extensionModuleMeta__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(77372);
32
+
31
33
 
32
34
 
33
35
 
@@ -58,13 +60,13 @@ async function command(params) {
58
60
  }
59
61
  const parsedPackageJson = await (async () => {
60
62
  const zParsedPackageJson = (() => {
61
- const zTargetType = zod__WEBPACK_IMPORTED_MODULE_11__.z.object({
62
- scripts: zod__WEBPACK_IMPORTED_MODULE_11__.z.record(zod__WEBPACK_IMPORTED_MODULE_11__.z.union([zod__WEBPACK_IMPORTED_MODULE_11__.z.string(), zod__WEBPACK_IMPORTED_MODULE_11__.z.undefined()])).optional(),
63
- dependencies: zod__WEBPACK_IMPORTED_MODULE_11__.z.record(zod__WEBPACK_IMPORTED_MODULE_11__.z.union([zod__WEBPACK_IMPORTED_MODULE_11__.z.string(), zod__WEBPACK_IMPORTED_MODULE_11__.z.undefined()])).optional(),
64
- devDependencies: zod__WEBPACK_IMPORTED_MODULE_11__.z.record(zod__WEBPACK_IMPORTED_MODULE_11__.z.union([zod__WEBPACK_IMPORTED_MODULE_11__.z.string(), zod__WEBPACK_IMPORTED_MODULE_11__.z.undefined()])).optional()
63
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_12__.z.object({
64
+ scripts: zod__WEBPACK_IMPORTED_MODULE_12__.z.record(zod__WEBPACK_IMPORTED_MODULE_12__.z.union([zod__WEBPACK_IMPORTED_MODULE_12__.z.string(), zod__WEBPACK_IMPORTED_MODULE_12__.z.undefined()])).optional(),
65
+ dependencies: zod__WEBPACK_IMPORTED_MODULE_12__.z.record(zod__WEBPACK_IMPORTED_MODULE_12__.z.union([zod__WEBPACK_IMPORTED_MODULE_12__.z.string(), zod__WEBPACK_IMPORTED_MODULE_12__.z.undefined()])).optional(),
66
+ devDependencies: zod__WEBPACK_IMPORTED_MODULE_12__.z.record(zod__WEBPACK_IMPORTED_MODULE_12__.z.union([zod__WEBPACK_IMPORTED_MODULE_12__.z.string(), zod__WEBPACK_IMPORTED_MODULE_12__.z.undefined()])).optional()
65
67
  });
66
68
  tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h;
67
- return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_12__.id)(zTargetType);
69
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_13__.id)(zTargetType);
68
70
  })();
69
71
  const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(buildContext.packageJsonFilePath)).toString("utf8"));
70
72
  zParsedPackageJson.parse(parsedPackageJson);
@@ -157,6 +159,11 @@ async function command(params) {
157
159
  break install_stories;
158
160
  }
159
161
  const moduleName = "@keycloakify/login-ui-storybook";
162
+ const extensionModuleMetas = await (0,_sync_extensions_extensionModuleMeta__WEBPACK_IMPORTED_MODULE_11__/* .getExtensionModuleMetas */ .f)({ buildContext });
163
+ const hasLoginStoriesProvidedFromOtherModule = extensionModuleMetas.find(meta => meta.files.find(file => file.fileRelativePath.startsWith(["login", "pages"].join(path__WEBPACK_IMPORTED_MODULE_1__.sep)) && file.copyableFilePath.endsWith("stories.tsx")) !== undefined) !== undefined;
164
+ if (hasLoginStoriesProvidedFromOtherModule) {
165
+ break install_stories;
166
+ }
160
167
  const latestVersion = getModuleLatestVersion({ moduleName });
161
168
  ((_d = parsedPackageJson.devDependencies) !== null && _d !== void 0 ? _d : (parsedPackageJson.devDependencies = {}))[moduleName] = `~${latestVersion}`;
162
169
  delete parsedPackageJson.dependencies[moduleName];
@@ -313,6 +320,578 @@ const storybookPreviewTsFileContent = [
313
320
  ].join("\n");
314
321
  //# sourceMappingURL=initialize-login-theme.js.map
315
322
 
323
+ /***/ }),
324
+
325
+ /***/ 77372:
326
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
327
+
328
+
329
+ // EXPORTS
330
+ __webpack_require__.d(__webpack_exports__, {
331
+ "x": () => (/* binding */ computeHash),
332
+ "f": () => (/* binding */ getExtensionModuleMetas)
333
+ });
334
+
335
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
336
+ var assert = __webpack_require__(29041);
337
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
338
+ var id = __webpack_require__(38469);
339
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
340
+ var lib = __webpack_require__(52300);
341
+ // EXTERNAL MODULE: external "path"
342
+ var external_path_ = __webpack_require__(71017);
343
+ // EXTERNAL MODULE: external "fs/promises"
344
+ var promises_ = __webpack_require__(73292);
345
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
346
+ var fs_existsAsync = __webpack_require__(43765);
347
+ // EXTERNAL MODULE: ./dist/bin/tools/listInstalledModules.js
348
+ var listInstalledModules = __webpack_require__(75564);
349
+ ;// CONCATENATED MODULE: ./dist/bin/tools/crawlAsync.js
350
+
351
+
352
+
353
+ /** List all files in a given directory return paths relative to the dir_path */
354
+ async function crawlAsync(params) {
355
+ const { dirPath, returnedPathsType, onFileFound } = params;
356
+ await crawlAsyncRec({
357
+ dirPath,
358
+ onFileFound: async ({ filePath }) => {
359
+ switch (returnedPathsType) {
360
+ case "absolute":
361
+ await onFileFound(filePath);
362
+ return;
363
+ case "relative to dirPath":
364
+ await onFileFound((0,external_path_.relative)(dirPath, filePath));
365
+ return;
366
+ }
367
+ (0,assert/* assert */.h)();
368
+ }
369
+ });
370
+ }
371
+ async function crawlAsyncRec(params) {
372
+ const { dirPath, onFileFound } = params;
373
+ await Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
374
+ const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
375
+ const isDirectory = await promises_.lstat(fileOrDirPath)
376
+ .then(stat => stat.isDirectory());
377
+ if (isDirectory) {
378
+ await crawlAsyncRec({ dirPath: fileOrDirPath, onFileFound });
379
+ return;
380
+ }
381
+ await onFileFound({ filePath: fileOrDirPath });
382
+ }));
383
+ }
384
+ //# sourceMappingURL=crawlAsync.js.map
385
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
386
+ var runPrettier = __webpack_require__(48433);
387
+ // EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
388
+ var readThisNpmPackageVersion = __webpack_require__(64795);
389
+ // EXTERNAL MODULE: ./dist/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.js
390
+ var getExtensionModuleFileSourceCodeReadyToBeCopied = __webpack_require__(2237);
391
+ // EXTERNAL MODULE: external "crypto"
392
+ var external_crypto_ = __webpack_require__(6113);
393
+ // EXTERNAL MODULE: ./dist/bin/shared/constants.js
394
+ var constants = __webpack_require__(173);
395
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
396
+ var exclude = __webpack_require__(83101);
397
+ ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/isAmong.mjs
398
+ /** https://docs.tsafe.dev/isamong */
399
+ function isAmong(names, value) {
400
+ for (const name of names) {
401
+ if (name === value) {
402
+ return true;
403
+ }
404
+ }
405
+ return false;
406
+ }
407
+
408
+
409
+ //# sourceMappingURL=isAmong.mjs.map
410
+
411
+ ;// CONCATENATED MODULE: ./dist/bin/sync-extensions/extensionModuleMeta.js
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+ const zExtensionModuleMeta = (() => {
428
+ const zTargetType = lib.z.object({
429
+ moduleName: lib.z.string(),
430
+ version: lib.z.string(),
431
+ files: lib.z.array(lib.z.object({
432
+ isPublic: lib.z.boolean(),
433
+ fileRelativePath: lib.z.string(),
434
+ hash: lib.z.string(),
435
+ copyableFilePath: lib.z.string()
436
+ })),
437
+ peerDependencies: lib.z.record(lib.z.string())
438
+ });
439
+ (0,assert/* assert */.h)();
440
+ return (0,id.id)(zTargetType);
441
+ })();
442
+ const zParsedCacheFile = (() => {
443
+ const zTargetType = lib.z.object({
444
+ keycloakifyVersion: lib.z.string(),
445
+ prettierConfigHash: lib.z.union([lib.z.string(), lib.z["null"]()]),
446
+ thisFilePath: lib.z.string(),
447
+ extensionModuleMetas: lib.z.array(zExtensionModuleMeta)
448
+ });
449
+ (0,assert/* assert */.h)();
450
+ return (0,id.id)(zTargetType);
451
+ })();
452
+ const CACHE_FILE_RELATIVE_PATH = (0,external_path_.join)("extension-modules", "cache.json");
453
+ (0,assert/* assert */.h)();
454
+ async function getExtensionModuleMetas(params) {
455
+ const { buildContext } = params;
456
+ const cacheFilePath = (0,external_path_.join)(buildContext.cacheDirPath, CACHE_FILE_RELATIVE_PATH);
457
+ const keycloakifyVersion = (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)();
458
+ const prettierConfigHash = await (async () => {
459
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
460
+ return null;
461
+ }
462
+ const { configHash } = await (0,runPrettier/* getPrettier */.LG)();
463
+ return configHash;
464
+ })();
465
+ const installedExtensionModules = await (async () => {
466
+ let installedExtensionModules = await (0,listInstalledModules/* listInstalledModules */.P)({
467
+ packageJsonFilePath: buildContext.packageJsonFilePath,
468
+ filter: ({ moduleName }) => moduleName.includes("keycloakify") && moduleName !== "keycloakify"
469
+ });
470
+ installedExtensionModules = (await Promise.all(installedExtensionModules.map(async (entry) => {
471
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC)))) {
472
+ return undefined;
473
+ }
474
+ return entry;
475
+ }))).filter((0,exclude/* exclude */.D)(undefined));
476
+ maybe_exclude_login_ui: {
477
+ const LOGIN_UI_MODULE_NAME = "@keycloakify/login-ui";
478
+ if (!installedExtensionModules
479
+ .map(({ moduleName }) => moduleName)
480
+ .includes(LOGIN_UI_MODULE_NAME)) {
481
+ break maybe_exclude_login_ui;
482
+ }
483
+ const shouldExcludeLoginUi = await (async () => {
484
+ for (const entry of installedExtensionModules) {
485
+ if (entry.moduleName === LOGIN_UI_MODULE_NAME ||
486
+ entry.moduleName === "@keycloakify/login-ui-storybook") {
487
+ continue;
488
+ }
489
+ if (await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC, "login", "pages", "login"))) {
490
+ return true;
491
+ }
492
+ }
493
+ return false;
494
+ })();
495
+ if (!shouldExcludeLoginUi) {
496
+ break maybe_exclude_login_ui;
497
+ }
498
+ installedExtensionModules = installedExtensionModules.filter(({ moduleName }) => moduleName !== LOGIN_UI_MODULE_NAME);
499
+ }
500
+ return installedExtensionModules;
501
+ })();
502
+ const cacheContent = await (async () => {
503
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
504
+ return undefined;
505
+ }
506
+ return await promises_.readFile(cacheFilePath);
507
+ })();
508
+ const extensionModuleMetas_cacheUpToDate = await (async () => {
509
+ const parsedCacheFile = await (async () => {
510
+ if (cacheContent === undefined) {
511
+ return undefined;
512
+ }
513
+ const cacheContentStr = cacheContent.toString("utf8");
514
+ let parsedCacheFile;
515
+ try {
516
+ parsedCacheFile = JSON.parse(cacheContentStr);
517
+ }
518
+ catch (_a) {
519
+ return undefined;
520
+ }
521
+ try {
522
+ zParsedCacheFile.parse(parsedCacheFile);
523
+ }
524
+ catch (_b) {
525
+ return undefined;
526
+ }
527
+ (0,assert/* assert */.h)((0,assert.is)(parsedCacheFile));
528
+ return parsedCacheFile;
529
+ })();
530
+ if (parsedCacheFile === undefined) {
531
+ return [];
532
+ }
533
+ if (parsedCacheFile.keycloakifyVersion !== keycloakifyVersion) {
534
+ return [];
535
+ }
536
+ if (parsedCacheFile.prettierConfigHash !== prettierConfigHash) {
537
+ return [];
538
+ }
539
+ if (parsedCacheFile.thisFilePath !== cacheFilePath) {
540
+ return [];
541
+ }
542
+ const extensionModuleMetas_cacheUpToDate = parsedCacheFile.extensionModuleMetas.filter(extensionModuleMeta => {
543
+ const correspondingInstalledExtensionModule = installedExtensionModules.find(installedExtensionModule => installedExtensionModule.moduleName ===
544
+ extensionModuleMeta.moduleName);
545
+ if (correspondingInstalledExtensionModule === undefined) {
546
+ return false;
547
+ }
548
+ return (correspondingInstalledExtensionModule.version ===
549
+ extensionModuleMeta.version);
550
+ });
551
+ return extensionModuleMetas_cacheUpToDate;
552
+ })();
553
+ const extensionModuleMetas = await Promise.all([...installedExtensionModules]
554
+ .sort((a, b) => a.moduleName.localeCompare(b.moduleName))
555
+ .map(async ({ moduleName, version, peerDependencies, dirPath }) => {
556
+ use_cache: {
557
+ const extensionModuleMeta_cache = extensionModuleMetas_cacheUpToDate.find(extensionModuleMeta => extensionModuleMeta.moduleName === moduleName);
558
+ if (extensionModuleMeta_cache === undefined) {
559
+ break use_cache;
560
+ }
561
+ return extensionModuleMeta_cache;
562
+ }
563
+ const files = [];
564
+ await crawlAsync({
565
+ dirPath: (0,external_path_.join)(dirPath, constants/* KEYCLOAK_THEME */.PC),
566
+ returnedPathsType: "relative to dirPath",
567
+ onFileFound: async (fileRelativePath_fromReservedDir) => {
568
+ const isPublic = fileRelativePath_fromReservedDir.startsWith(`public${external_path_.sep}`);
569
+ const fileRelativePath = isPublic
570
+ ? (0,external_path_.relative)("public", fileRelativePath_fromReservedDir)
571
+ : fileRelativePath_fromReservedDir;
572
+ const sourceCode = await (0,getExtensionModuleFileSourceCodeReadyToBeCopied/* getExtensionModuleFileSourceCodeReadyToBeCopied */.p)({
573
+ buildContext,
574
+ isPublic,
575
+ fileRelativePath,
576
+ isOwnershipAction: false,
577
+ extensionModuleDirPath: dirPath,
578
+ extensionModuleName: moduleName,
579
+ extensionModuleVersion: version
580
+ });
581
+ const hash = computeHash(sourceCode);
582
+ const copyableFilePath = (0,external_path_.join)((0,external_path_.dirname)(cacheFilePath), constants/* KEYCLOAK_THEME */.PC, fileRelativePath_fromReservedDir);
583
+ {
584
+ const dirPath = (0,external_path_.dirname)(copyableFilePath);
585
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
586
+ await promises_.mkdir(dirPath, { recursive: true });
587
+ }
588
+ }
589
+ await promises_.writeFile(copyableFilePath, sourceCode);
590
+ files.push({
591
+ isPublic,
592
+ fileRelativePath,
593
+ hash,
594
+ copyableFilePath
595
+ });
596
+ }
597
+ });
598
+ {
599
+ const getId = (file) => `${file.isPublic ? "public" : "src"} - ${file.fileRelativePath}`;
600
+ files.sort((a, b) => getId(a).localeCompare(getId(b)));
601
+ }
602
+ return (0,id.id)({
603
+ moduleName,
604
+ version,
605
+ files,
606
+ peerDependencies: Object.fromEntries(Object.entries(peerDependencies)
607
+ .filter(([moduleName]) => !isAmong(["react", "@types/react"], moduleName))
608
+ .sort(([moduleName_a], [moduleName_b]) => moduleName_a.localeCompare(moduleName_b)))
609
+ });
610
+ }));
611
+ update_cache: {
612
+ const parsedCacheFile = (0,id.id)({
613
+ keycloakifyVersion,
614
+ prettierConfigHash,
615
+ thisFilePath: cacheFilePath,
616
+ extensionModuleMetas
617
+ });
618
+ const cacheContent_new = Buffer.from(JSON.stringify(parsedCacheFile, null, 2), "utf8");
619
+ if (cacheContent !== undefined && cacheContent_new.equals(cacheContent)) {
620
+ break update_cache;
621
+ }
622
+ create_dir: {
623
+ const dirPath = (0,external_path_.dirname)(cacheFilePath);
624
+ if (await (0,fs_existsAsync/* existsAsync */.o)(dirPath)) {
625
+ break create_dir;
626
+ }
627
+ await promises_.mkdir(dirPath, { recursive: true });
628
+ }
629
+ await promises_.writeFile(cacheFilePath, cacheContent_new);
630
+ }
631
+ return extensionModuleMetas;
632
+ }
633
+ function computeHash(data) {
634
+ return external_crypto_.createHash("sha256").update(data).digest("hex");
635
+ }
636
+ //# sourceMappingURL=extensionModuleMeta.js.map
637
+
638
+ /***/ }),
639
+
640
+ /***/ 2237:
641
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
642
+
643
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
644
+ /* harmony export */ "p": () => (/* binding */ getExtensionModuleFileSourceCodeReadyToBeCopied)
645
+ /* harmony export */ });
646
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(48433);
647
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(73292);
648
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
649
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71017);
650
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
651
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
652
+ /* harmony import */ var _shared_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(173);
653
+
654
+
655
+
656
+
657
+
658
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)();
659
+ async function getExtensionModuleFileSourceCodeReadyToBeCopied(params) {
660
+ const { buildContext, extensionModuleDirPath, isPublic, fileRelativePath, isOwnershipAction, extensionModuleName, extensionModuleVersion } = params;
661
+ const { refSourceCode } = await (async () => {
662
+ let sourceCode = undefined;
663
+ const sourceCode_originalBuffer = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile((0,path__WEBPACK_IMPORTED_MODULE_2__.join)(extensionModuleDirPath, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .KEYCLOAK_THEME */ .PC, isPublic ? "public" : ".", fileRelativePath));
664
+ let hasBeenUpdated = false;
665
+ const refSourceCode = {
666
+ get current() {
667
+ if (sourceCode === undefined) {
668
+ sourceCode = sourceCode_originalBuffer.toString("utf8");
669
+ }
670
+ return sourceCode;
671
+ },
672
+ set current(value) {
673
+ hasBeenUpdated = true;
674
+ sourceCode = value;
675
+ },
676
+ getAsBuffer: () => {
677
+ if (!hasBeenUpdated) {
678
+ return sourceCode_originalBuffer;
679
+ }
680
+ return Buffer.from(refSourceCode.current, "utf8");
681
+ }
682
+ };
683
+ return { refSourceCode };
684
+ })();
685
+ add_eslint_disable: {
686
+ if (isOwnershipAction) {
687
+ break add_eslint_disable;
688
+ }
689
+ if (!fileRelativePath.endsWith(".ts") && !fileRelativePath.endsWith(".tsx")) {
690
+ break add_eslint_disable;
691
+ }
692
+ if (refSourceCode.current.includes("/* eslint-disable */")) {
693
+ break add_eslint_disable;
694
+ }
695
+ refSourceCode.current = ["/* eslint-disable */", "", refSourceCode.current].join("\n");
696
+ }
697
+ addCommentToSourceCode({
698
+ refSourceCode,
699
+ fileRelativePath,
700
+ commentLines: (() => {
701
+ const path = fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_2__.sep).join("/");
702
+ const isEarlyColorSchemeScript = isPublic &&
703
+ _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .THEME_TYPES.find */ .Jh.find(themeType => (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(themeType, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .EARLY_COLOR_SCHEME_SCRIPT_BASENAME */ .PH) ===
704
+ fileRelativePath) !== undefined;
705
+ const common = !isEarlyColorSchemeScript
706
+ ? []
707
+ : [
708
+ ``,
709
+ `${_shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .EARLY_COLOR_SCHEME_SCRIPT_BASENAME */ .PH} is a special file that will be imported in the head automatically by Keycloakify.`,
710
+ `Note that this file is not loaded in Storybook or when using the Vite DEV server.`,
711
+ "To test it you can use `NO_DEV_SERVER=true npx keycloakify start-keycloak` (NO_DEV_SERVER is only relevant for Account SPA and Admin themes)"
712
+ ];
713
+ return isOwnershipAction
714
+ ? [
715
+ `This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
716
+ `To relinquish ownership and restore this file to its original content, run the following command:`,
717
+ ``,
718
+ `$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`,
719
+ ...common
720
+ ]
721
+ : [
722
+ `WARNING: Before modifying this file, run the following command:`,
723
+ ``,
724
+ `$ npx keycloakify own --path "${path}"${isPublic ? " --public" : ""}`,
725
+ ``,
726
+ `This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
727
+ `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`,
728
+ ...common
729
+ ];
730
+ })()
731
+ });
732
+ format: {
733
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .getIsPrettierAvailable */ .MT)())) {
734
+ break format;
735
+ }
736
+ const sourceCode_buffer_before = refSourceCode.getAsBuffer();
737
+ const sourceCode_buffer_after = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .runPrettier */ .eY)({
738
+ filePath: (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(isPublic
739
+ ? (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.publicDirPath, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .KEYCLOAK_THEME */ .PC)
740
+ : buildContext.themeSrcDirPath, fileRelativePath),
741
+ sourceCode: sourceCode_buffer_before
742
+ });
743
+ if (sourceCode_buffer_before.compare(sourceCode_buffer_after) === 0) {
744
+ break format;
745
+ }
746
+ refSourceCode.current = sourceCode_buffer_after.toString("utf8");
747
+ }
748
+ return refSourceCode.getAsBuffer();
749
+ }
750
+ function addCommentToSourceCode(params) {
751
+ const { refSourceCode, fileRelativePath, commentLines } = params;
752
+ const updateRef = (comment) => {
753
+ refSourceCode.current = [comment, ``, refSourceCode.current].join("\n");
754
+ };
755
+ for (const ext of [".ts", ".tsx", ".css", ".less", ".sass", ".js", ".jsx"]) {
756
+ if (!fileRelativePath.endsWith(ext)) {
757
+ continue;
758
+ }
759
+ updateRef([`/**`, ...commentLines.map(line => ` * ${line}`), ` */`].join("\n"));
760
+ return;
761
+ }
762
+ if (fileRelativePath.endsWith(".properties")) {
763
+ updateRef(commentLines.map(line => `# ${line}`).join("\n"));
764
+ return;
765
+ }
766
+ if (fileRelativePath.endsWith(".ftl")) {
767
+ const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n");
768
+ if (refSourceCode.current.trim().startsWith("<#ftl")) {
769
+ const [first, ...rest] = refSourceCode.current.split(">");
770
+ const last = rest.join(">");
771
+ refSourceCode.current = [`${first}>`, comment, last].join("\n");
772
+ return;
773
+ }
774
+ updateRef(comment);
775
+ return;
776
+ }
777
+ if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
778
+ const comment = [
779
+ `<!--`,
780
+ ...commentLines.map(line => ` ${line
781
+ .replace("--path", "-t")
782
+ .replace("--revert", "-r")
783
+ .replace("Before modifying", "Before modifying or replacing")}`),
784
+ `-->`
785
+ ].join("\n");
786
+ if (fileRelativePath.endsWith(".html") &&
787
+ refSourceCode.current.trim().startsWith("<!")) {
788
+ const [first, ...rest] = refSourceCode.current.split(">");
789
+ const last = rest.join(">");
790
+ refSourceCode.current = [`${first}>`, comment, last].join("\n");
791
+ return;
792
+ }
793
+ if (fileRelativePath.endsWith(".svg") &&
794
+ refSourceCode.current.trim().startsWith("<?")) {
795
+ const [first, ...rest] = refSourceCode.current.split("?>");
796
+ const last = rest.join("?>");
797
+ refSourceCode.current = [`${first}?>`, comment, last].join("\n");
798
+ return;
799
+ }
800
+ updateRef(comment);
801
+ return;
802
+ }
803
+ }
804
+ //# sourceMappingURL=getExtensionModuleFileSourceCodeReadyToBeCopied.js.map
805
+
806
+ /***/ }),
807
+
808
+ /***/ 75564:
809
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
810
+
811
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
812
+ /* harmony export */ "J": () => (/* binding */ readPackageJsonDependencies),
813
+ /* harmony export */ "P": () => (/* binding */ listInstalledModules)
814
+ /* harmony export */ });
815
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29041);
816
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38469);
817
+ /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(52300);
818
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
819
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
820
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
821
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
822
+ /* harmony import */ var _tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(93721);
823
+ /* harmony import */ var tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(83101);
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+ async function listInstalledModules(params) {
832
+ const { packageJsonFilePath, filter } = params;
833
+ const parsedPackageJson = await readPackageJsonDependencies({
834
+ packageJsonFilePath
835
+ });
836
+ const extensionModuleNames = [parsedPackageJson.dependencies, parsedPackageJson.devDependencies]
837
+ .filter((0,tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__/* .exclude */ .D)(undefined))
838
+ .map(obj => Object.keys(obj))
839
+ .flat()
840
+ .filter(moduleName => filter({ moduleName }));
841
+ const result = await Promise.all(extensionModuleNames.map(async (moduleName) => {
842
+ const dirPath = await (0,_tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__/* .getInstalledModuleDirPath */ .p)({
843
+ moduleName,
844
+ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
845
+ });
846
+ const { version, peerDependencies } = await readPackageJsonVersionAndPeerDependencies({
847
+ packageJsonFilePath: (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, "package.json")
848
+ });
849
+ return { moduleName, version, peerDependencies, dirPath };
850
+ }));
851
+ return result;
852
+ }
853
+ const { readPackageJsonDependencies } = (() => {
854
+ const zParsedPackageJson = (() => {
855
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
856
+ dependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional(),
857
+ devDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
858
+ });
859
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
860
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
861
+ })();
862
+ async function readPackageJsonDependencies(params) {
863
+ const { packageJsonFilePath } = params;
864
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
865
+ zParsedPackageJson.parse(parsedPackageJson);
866
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
867
+ return parsedPackageJson;
868
+ }
869
+ return { readPackageJsonDependencies };
870
+ })();
871
+ const { readPackageJsonVersionAndPeerDependencies } = (() => {
872
+ const zParsedPackageJson = (() => {
873
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
874
+ version: zod__WEBPACK_IMPORTED_MODULE_5__.z.string(),
875
+ peerDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
876
+ });
877
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
878
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
879
+ })();
880
+ async function readPackageJsonVersionAndPeerDependencies(params) {
881
+ var _a;
882
+ const { packageJsonFilePath } = params;
883
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
884
+ zParsedPackageJson.parse(parsedPackageJson);
885
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
886
+ return {
887
+ version: parsedPackageJson.version,
888
+ peerDependencies: (_a = parsedPackageJson.peerDependencies) !== null && _a !== void 0 ? _a : {}
889
+ };
890
+ }
891
+ return { readPackageJsonVersionAndPeerDependencies };
892
+ })();
893
+ //# sourceMappingURL=listInstalledModules.js.map
894
+
316
895
  /***/ })
317
896
 
318
897
  };
package/bin/97.index.js CHANGED
@@ -267,7 +267,7 @@ async function getExtensionModuleMetas(params) {
267
267
  await promises_.mkdir(dirPath, { recursive: true });
268
268
  }
269
269
  }
270
- promises_.writeFile(copyableFilePath, sourceCode);
270
+ await promises_.writeFile(copyableFilePath, sourceCode);
271
271
  files.push({
272
272
  isPublic,
273
273
  fileRelativePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.15.7",
3
+ "version": "11.15.8-rc.2",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import { maybeDelegateCommandToCustomHandler } from "./shared/customHandler_delegate";
2
- import { dirname as pathDirname, join as pathJoin } from "path";
2
+ import { dirname as pathDirname, join as pathJoin, sep as pathSep } from "path";
3
3
  import type { BuildContext } from "./shared/buildContext";
4
4
  import * as fs from "fs/promises";
5
5
  import { assert, is, type Equals } from "tsafe/assert";
@@ -12,6 +12,7 @@ import { z } from "zod";
12
12
  import chalk from "chalk";
13
13
  import cliSelect from "cli-select";
14
14
  import { existsAsync } from "./tools/fs.existsAsync";
15
+ import { getExtensionModuleMetas } from "./sync-extensions/extensionModuleMeta";
15
16
 
16
17
  export async function command(params: { buildContext: BuildContext }) {
17
18
  const { buildContext } = params;
@@ -184,6 +185,23 @@ export async function command(params: { buildContext: BuildContext }) {
184
185
 
185
186
  const moduleName = "@keycloakify/login-ui-storybook";
186
187
 
188
+ const extensionModuleMetas = await getExtensionModuleMetas({ buildContext });
189
+
190
+ const hasLoginStoriesProvidedFromOtherModule =
191
+ extensionModuleMetas.find(
192
+ meta =>
193
+ meta.files.find(
194
+ file =>
195
+ file.fileRelativePath.startsWith(
196
+ ["login", "pages"].join(pathSep)
197
+ ) && file.copyableFilePath.endsWith("stories.tsx")
198
+ ) !== undefined
199
+ ) !== undefined;
200
+
201
+ if (hasLoginStoriesProvidedFromOtherModule) {
202
+ break install_stories;
203
+ }
204
+
187
205
  const latestVersion = getModuleLatestVersion({ moduleName });
188
206
 
189
207
  (parsedPackageJson.devDependencies ??= {})[moduleName] = `~${latestVersion}`;
@@ -319,7 +319,7 @@ export async function getExtensionModuleMetas(params: {
319
319
  }
320
320
  }
321
321
 
322
- fsPr.writeFile(copyableFilePath, sourceCode);
322
+ await fsPr.writeFile(copyableFilePath, sourceCode);
323
323
 
324
324
  files.push({
325
325
  isPublic,