keycloakify 11.8.42 → 11.8.43

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.
@@ -5,6 +5,9 @@ import { existsAsync } from "./tools/fs.existsAsync";
5
5
  import { maybeDelegateCommandToCustomHandler } from "./shared/customHandler_delegate";
6
6
  import * as crypto from "crypto";
7
7
  import { getIsPrettierAvailable, runPrettier } from "./tools/runPrettier";
8
+ import { assert, type Equals } from "tsafe/assert";
9
+ import { WELL_KNOWN_DIRECTORY_BASE_NAME } from "./shared/constants";
10
+ import { readPackageJsonDependencies } from "./tools/listInstalledModules";
8
11
 
9
12
  export async function command(params: { buildContext: BuildContext }) {
10
13
  const { buildContext } = params;
@@ -135,9 +138,71 @@ export async function command(params: { buildContext: BuildContext }) {
135
138
  ` </Suspense>`,
136
139
  ` );`,
137
140
  `}`,
138
- ``
141
+ ``,
142
+ ...(() => {
143
+ const { bundler } = buildContext;
144
+ switch (bundler) {
145
+ case "vite":
146
+ return [
147
+ "NOTE: This is exported here only because in Webpack environnement it works differently",
148
+ `export const BASE_URL = import.meta.env.BASE_URL`
149
+ ];
150
+ case "webpack":
151
+ return [
152
+ "// NOTE: This is a polyfill for `import.meta.env.BASE_URL` as it's not available in Webpack environment.",
153
+ "export const BASE_URL =",
154
+ ` window.kcContext === undefined || process.env.NODE_ENV === "development"`,
155
+ ` ? process.env.PUBLIC_URL === ""`,
156
+ ` ? "/"`,
157
+ ` : \`${process.env.PUBLIC_URL}/\``,
158
+ ` : \`\${kcContext["x-keycloakify"].resourcesPath}/${WELL_KNOWN_DIRECTORY_BASE_NAME.DIST}/\`;`,
159
+ ""
160
+ ];
161
+ default:
162
+ assert<Equals<typeof bundler, never>>(false);
163
+ }
164
+ })(),
165
+ await (async () => {
166
+ const { dependencies, devDependencies } =
167
+ await readPackageJsonDependencies({
168
+ packageJsonFilePath: buildContext.packageJsonFilePath
169
+ });
170
+
171
+ const moduleNames = Object.keys({
172
+ ...dependencies,
173
+ ...devDependencies
174
+ });
175
+
176
+ const moduleName = (() => {
177
+ for (const moduleName_candidate of [
178
+ "@storybook/react-vite",
179
+ "@storybook/react-webpack5",
180
+ "@storybook/react"
181
+ ]) {
182
+ if (moduleNames.includes(moduleName_candidate)) {
183
+ return moduleName_candidate;
184
+ }
185
+ }
186
+
187
+ return undefined;
188
+ })();
189
+
190
+ if (moduleName === undefined) {
191
+ return false as const;
192
+ }
193
+
194
+ return [
195
+ `// NOTE: This is only exported here because you're supposed to import type from different packages`,
196
+ `// Depending of if you are using Vite, Webpack, ect...`,
197
+ `export type { Meta, StoryObj } from "${moduleName}";`,
198
+ ``
199
+ ].join("\n");
200
+ })()
139
201
  ]
140
- .filter(item => typeof item === "string")
202
+ .filter(item => {
203
+ assert<Equals<typeof item, string | false>>;
204
+ return typeof item === "string";
205
+ })
141
206
  .join("\n");
142
207
  }
143
208
 
@@ -1153,8 +1153,8 @@ function readParams(params) {
1153
1153
  //# sourceMappingURL=customHandler.js.map
1154
1154
  // EXTERNAL MODULE: external "child_process"
1155
1155
  var external_child_process_ = __nccwpck_require__(81);
1156
- // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js + 2 modules
1157
- var tools_nodeModulesBinDirPath = __nccwpck_require__(636);
1156
+ // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
1157
+ var tools_nodeModulesBinDirPath = __nccwpck_require__(776);
1158
1158
  // EXTERNAL MODULE: external "fs"
1159
1159
  var external_fs_ = __nccwpck_require__(147);
1160
1160
  ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
@@ -1430,51 +1430,18 @@ async function checkDirExists(dirPath) {
1430
1430
 
1431
1431
  /***/ }),
1432
1432
 
1433
- /***/ 822:
1434
- /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1435
-
1436
- "use strict";
1437
- /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
1438
- /* harmony export */ "B": () => (/* binding */ getNearestPackageJsonDirPath),
1439
- /* harmony export */ "e": () => (/* binding */ getThisCodebaseRootDirPath)
1440
- /* harmony export */ });
1441
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(147);
1442
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
1443
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(17);
1444
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1445
-
1446
-
1447
- let result = undefined;
1448
- function getThisCodebaseRootDirPath() {
1449
- if (result !== undefined) {
1450
- return result;
1451
- }
1452
- return (result = getNearestPackageJsonDirPath(__dirname));
1453
- }
1454
- function getNearestPackageJsonDirPath(dirPath) {
1455
- if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, "package.json"))) {
1456
- return dirPath;
1457
- }
1458
- return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, ".."));
1459
- }
1460
- //# sourceMappingURL=getThisCodebaseRootDirPath.js.map
1461
-
1462
- /***/ }),
1463
-
1464
- /***/ 636:
1433
+ /***/ 721:
1465
1434
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1466
1435
 
1467
1436
  "use strict";
1468
1437
 
1469
1438
  // EXPORTS
1470
1439
  __nccwpck_require__.d(__webpack_exports__, {
1471
- "K": () => (/* binding */ getNodeModulesBinDirPath)
1440
+ "p": () => (/* binding */ getInstalledModuleDirPath)
1472
1441
  });
1473
1442
 
1474
1443
  // EXTERNAL MODULE: external "path"
1475
1444
  var external_path_ = __nccwpck_require__(17);
1476
- // EXTERNAL MODULE: ./dist/bin/tools/getThisCodebaseRootDirPath.js
1477
- var getThisCodebaseRootDirPath = __nccwpck_require__(822);
1478
1445
  // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
1479
1446
  var fs_existsAsync = __nccwpck_require__(765);
1480
1447
  // EXTERNAL MODULE: external "child_process"
@@ -1537,13 +1504,57 @@ async function getInstalledModuleDirPath(params) {
1537
1504
  return dirPath;
1538
1505
  }
1539
1506
  //# sourceMappingURL=getInstalledModuleDirPath.js.map
1540
- // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
1541
- var lib = __nccwpck_require__(300);
1542
- // EXTERNAL MODULE: external "fs/promises"
1543
- var promises_ = __nccwpck_require__(292);
1544
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
1545
- var id = __nccwpck_require__(469);
1546
- ;// CONCATENATED MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
1507
+
1508
+ /***/ }),
1509
+
1510
+ /***/ 822:
1511
+ /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1512
+
1513
+ "use strict";
1514
+ /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
1515
+ /* harmony export */ "B": () => (/* binding */ getNearestPackageJsonDirPath),
1516
+ /* harmony export */ "e": () => (/* binding */ getThisCodebaseRootDirPath)
1517
+ /* harmony export */ });
1518
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(147);
1519
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
1520
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(17);
1521
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1522
+
1523
+
1524
+ let result = undefined;
1525
+ function getThisCodebaseRootDirPath() {
1526
+ if (result !== undefined) {
1527
+ return result;
1528
+ }
1529
+ return (result = getNearestPackageJsonDirPath(__dirname));
1530
+ }
1531
+ function getNearestPackageJsonDirPath(dirPath) {
1532
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, "package.json"))) {
1533
+ return dirPath;
1534
+ }
1535
+ return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, ".."));
1536
+ }
1537
+ //# sourceMappingURL=getThisCodebaseRootDirPath.js.map
1538
+
1539
+ /***/ }),
1540
+
1541
+ /***/ 776:
1542
+ /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1543
+
1544
+ "use strict";
1545
+ /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
1546
+ /* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
1547
+ /* harmony export */ });
1548
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(17);
1549
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
1550
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(822);
1551
+ /* harmony import */ var _getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(721);
1552
+ /* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(765);
1553
+ /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(300);
1554
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(292);
1555
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_4__);
1556
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(41);
1557
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(469);
1547
1558
 
1548
1559
 
1549
1560
 
@@ -1574,13 +1585,13 @@ function getNodeModulesBinDirPath_bestEffort() {
1574
1585
  if (!binPath.endsWith(".ts")) {
1575
1586
  break special_case_running_not_from_distribution;
1576
1587
  }
1577
- const packageJsonDirPath = (0,getThisCodebaseRootDirPath/* getNearestPackageJsonDirPath */.B)((0,external_path_.dirname)(binPath));
1578
- const nodeModulesBinDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules", ".bin");
1588
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .B)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
1589
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, "node_modules", ".bin");
1579
1590
  return nodeModulesBinDirPath;
1580
1591
  }
1581
1592
  const segments = [".bin"];
1582
1593
  let foundNodeModules = false;
1583
- for (const segment of binPath.split(external_path_.sep).reverse()) {
1594
+ for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
1584
1595
  skip_segment: {
1585
1596
  if (foundNodeModules) {
1586
1597
  break skip_segment;
@@ -1596,7 +1607,7 @@ function getNodeModulesBinDirPath_bestEffort() {
1596
1607
  if (!foundNodeModules) {
1597
1608
  throw new Error(`Could not find node_modules in path ${binPath}`);
1598
1609
  }
1599
- const nodeModulesBinDirPath = segments.join(external_path_.sep);
1610
+ const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
1600
1611
  cache_bestEffort = nodeModulesBinDirPath;
1601
1612
  return nodeModulesBinDirPath;
1602
1613
  }
@@ -1614,24 +1625,24 @@ async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
1614
1625
  return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
1615
1626
  }
1616
1627
  // [...]node_modules/keycloakify
1617
- const installedModuleDirPath = await getInstalledModuleDirPath({
1628
+ const installedModuleDirPath = await (0,_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getInstalledModuleDirPath */ .p)({
1618
1629
  // Here it will always be "keycloakify" but since we are in tools/ we make something generic
1619
1630
  moduleName: await (async () => {
1620
1631
  const zParsedPackageJson = (() => {
1621
- const zTargetType = lib.z.object({
1622
- name: lib.z.string()
1632
+ const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
1633
+ name: zod__WEBPACK_IMPORTED_MODULE_6__.z.string()
1623
1634
  });
1624
- assert/* assert */.h;
1625
- return (0,id.id)(zTargetType);
1635
+ tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h;
1636
+ return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
1626
1637
  })();
1627
- const parsedPackageJson = JSON.parse((await promises_.readFile((0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "package.json"))).toString("utf8"));
1638
+ const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_4__.readFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))).toString("utf8"));
1628
1639
  zParsedPackageJson.parse(parsedPackageJson);
1629
- (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
1640
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__.is)(parsedPackageJson));
1630
1641
  return parsedPackageJson.name;
1631
1642
  })(),
1632
- packageJsonDirPath: (0,external_path_.dirname)(packageJsonFilePath)
1643
+ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(packageJsonFilePath)
1633
1644
  });
1634
- const segments = installedModuleDirPath.split(external_path_.sep);
1645
+ const segments = installedModuleDirPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep);
1635
1646
  while (true) {
1636
1647
  const segment = segments.pop();
1637
1648
  if (segment === undefined) {
@@ -1640,8 +1651,8 @@ async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
1640
1651
  if (segment !== "node_modules") {
1641
1652
  continue;
1642
1653
  }
1643
- const candidate = (0,external_path_.join)(segments.join(external_path_.sep), segment, ".bin");
1644
- if (!(await (0,fs_existsAsync/* existsAsync */.o)(candidate))) {
1654
+ const candidate = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep), segment, ".bin");
1655
+ if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(candidate))) {
1645
1656
  continue;
1646
1657
  }
1647
1658
  cache_withPackageJsonFileDirPath = {
@@ -1703,7 +1714,7 @@ function readThisNpmPackageVersion() {
1703
1714
  /* harmony export */ "eY": () => (/* binding */ runPrettier)
1704
1715
  /* harmony export */ });
1705
1716
  /* unused harmony export getPrettier */
1706
- /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(636);
1717
+ /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(776);
1707
1718
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(17);
1708
1719
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1709
1720
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(292);
@@ -1810,23 +1821,115 @@ async function runPrettier(params) {
1810
1821
 
1811
1822
  /***/ }),
1812
1823
 
1813
- /***/ 786:
1824
+ /***/ 371:
1814
1825
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1815
1826
 
1816
1827
  "use strict";
1828
+ // ESM COMPAT FLAG
1817
1829
  __nccwpck_require__.r(__webpack_exports__);
1818
- /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
1819
- /* harmony export */ "command": () => (/* binding */ command)
1820
- /* harmony export */ });
1821
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(292);
1822
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
1823
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(17);
1824
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1825
- /* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(765);
1826
- /* harmony import */ var _shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(138);
1827
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(113);
1828
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__nccwpck_require__.n(crypto__WEBPACK_IMPORTED_MODULE_4__);
1829
- /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(433);
1830
+
1831
+ // EXPORTS
1832
+ __nccwpck_require__.d(__webpack_exports__, {
1833
+ "command": () => (/* binding */ command)
1834
+ });
1835
+
1836
+ // EXTERNAL MODULE: external "fs/promises"
1837
+ var promises_ = __nccwpck_require__(292);
1838
+ // EXTERNAL MODULE: external "path"
1839
+ var external_path_ = __nccwpck_require__(17);
1840
+ // EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
1841
+ var fs_existsAsync = __nccwpck_require__(765);
1842
+ // EXTERNAL MODULE: ./dist/bin/shared/customHandler_delegate.js + 1 modules
1843
+ var customHandler_delegate = __nccwpck_require__(138);
1844
+ // EXTERNAL MODULE: external "crypto"
1845
+ var external_crypto_ = __nccwpck_require__(113);
1846
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
1847
+ var runPrettier = __nccwpck_require__(433);
1848
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
1849
+ var assert = __nccwpck_require__(41);
1850
+ // EXTERNAL MODULE: ./dist/bin/shared/constants.js
1851
+ var constants = __nccwpck_require__(173);
1852
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
1853
+ var id = __nccwpck_require__(469);
1854
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
1855
+ var lib = __nccwpck_require__(300);
1856
+ // EXTERNAL MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js + 1 modules
1857
+ var tools_getInstalledModuleDirPath = __nccwpck_require__(721);
1858
+ ;// CONCATENATED MODULE: ./dist/bin/tools/listInstalledModules.js
1859
+
1860
+
1861
+
1862
+
1863
+
1864
+
1865
+
1866
+ async function listInstalledModules(params) {
1867
+ const { packageJsonFilePath, filter } = params;
1868
+ const parsedPackageJson = await readPackageJsonDependencies({
1869
+ packageJsonFilePath
1870
+ });
1871
+ const extensionModuleNames = [parsedPackageJson.dependencies, parsedPackageJson.devDependencies]
1872
+ .filter(exclude(undefined))
1873
+ .map(obj => Object.keys(obj))
1874
+ .flat()
1875
+ .filter(moduleName => filter({ moduleName }));
1876
+ const result = await Promise.all(extensionModuleNames.map(async (moduleName) => {
1877
+ const dirPath = await getInstalledModuleDirPath({
1878
+ moduleName,
1879
+ packageJsonDirPath: pathDirname(packageJsonFilePath)
1880
+ });
1881
+ const { version, peerDependencies } = await readPackageJsonVersionAndPeerDependencies({
1882
+ packageJsonFilePath: pathJoin(dirPath, "package.json")
1883
+ });
1884
+ return { moduleName, version, peerDependencies, dirPath };
1885
+ }));
1886
+ return result;
1887
+ }
1888
+ const { readPackageJsonDependencies } = (() => {
1889
+ const zParsedPackageJson = (() => {
1890
+ const zTargetType = lib.z.object({
1891
+ dependencies: lib.z.record(lib.z.string()).optional(),
1892
+ devDependencies: lib.z.record(lib.z.string()).optional()
1893
+ });
1894
+ (0,assert/* assert */.h)();
1895
+ return (0,id.id)(zTargetType);
1896
+ })();
1897
+ async function readPackageJsonDependencies(params) {
1898
+ const { packageJsonFilePath } = params;
1899
+ const parsedPackageJson = JSON.parse((await promises_.readFile(packageJsonFilePath)).toString("utf8"));
1900
+ zParsedPackageJson.parse(parsedPackageJson);
1901
+ (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
1902
+ return parsedPackageJson;
1903
+ }
1904
+ return { readPackageJsonDependencies };
1905
+ })();
1906
+ const { readPackageJsonVersionAndPeerDependencies } = (() => {
1907
+ const zParsedPackageJson = (() => {
1908
+ const zTargetType = lib.z.object({
1909
+ version: lib.z.string(),
1910
+ peerDependencies: lib.z.record(lib.z.string()).optional()
1911
+ });
1912
+ (0,assert/* assert */.h)();
1913
+ return (0,id.id)(zTargetType);
1914
+ })();
1915
+ async function readPackageJsonVersionAndPeerDependencies(params) {
1916
+ var _a;
1917
+ const { packageJsonFilePath } = params;
1918
+ const parsedPackageJson = JSON.parse((await promises_.readFile(packageJsonFilePath)).toString("utf8"));
1919
+ zParsedPackageJson.parse(parsedPackageJson);
1920
+ (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
1921
+ return {
1922
+ version: parsedPackageJson.version,
1923
+ peerDependencies: (_a = parsedPackageJson.peerDependencies) !== null && _a !== void 0 ? _a : {}
1924
+ };
1925
+ }
1926
+ return { readPackageJsonVersionAndPeerDependencies };
1927
+ })();
1928
+ //# sourceMappingURL=listInstalledModules.js.map
1929
+ ;// CONCATENATED MODULE: ./dist/bin/update-kc-gen.js
1930
+
1931
+
1932
+
1830
1933
 
1831
1934
 
1832
1935
 
@@ -1842,14 +1945,14 @@ async function command(params) {
1842
1945
  const { command } = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 713));
1843
1946
  await command({ buildContext });
1844
1947
  }
1845
- const { hasBeenHandled } = await (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__/* .maybeDelegateCommandToCustomHandler */ .q)({
1948
+ const { hasBeenHandled } = await (0,customHandler_delegate/* maybeDelegateCommandToCustomHandler */.q)({
1846
1949
  commandName: "update-kc-gen",
1847
1950
  buildContext
1848
1951
  });
1849
1952
  if (hasBeenHandled) {
1850
1953
  return;
1851
1954
  }
1852
- const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc.gen.tsx");
1955
+ const filePath = (0,external_path_.join)(buildContext.themeSrcDirPath, "kc.gen.tsx");
1853
1956
  const hasLoginTheme = buildContext.implementedThemeTypes.login.isImplemented;
1854
1957
  const hasAccountTheme = buildContext.implementedThemeTypes.account.isImplemented;
1855
1958
  const hasAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
@@ -1943,17 +2046,70 @@ async function command(params) {
1943
2046
  ` </Suspense>`,
1944
2047
  ` );`,
1945
2048
  `}`,
1946
- ``
2049
+ ``,
2050
+ ...(() => {
2051
+ const { bundler } = buildContext;
2052
+ switch (bundler) {
2053
+ case "vite":
2054
+ return [
2055
+ "NOTE: This is exported here only because in Webpack environnement it works differently",
2056
+ `export const BASE_URL = import.meta.env.BASE_URL`
2057
+ ];
2058
+ case "webpack":
2059
+ return [
2060
+ "// NOTE: This is a polyfill for `import.meta.env.BASE_URL` as it's not available in Webpack environment.",
2061
+ "export const BASE_URL =",
2062
+ ` window.kcContext === undefined || process.env.NODE_ENV === "development"`,
2063
+ ` ? process.env.PUBLIC_URL === ""`,
2064
+ ` ? "/"`,
2065
+ ` : \`${process.env.PUBLIC_URL}/\``,
2066
+ ` : \`\${kcContext["x-keycloakify"].resourcesPath}/${constants.WELL_KNOWN_DIRECTORY_BASE_NAME.DIST}/\`;`,
2067
+ ""
2068
+ ];
2069
+ default:
2070
+ (0,assert/* assert */.h)(false);
2071
+ }
2072
+ })(),
2073
+ await (async () => {
2074
+ const { dependencies, devDependencies } = await readPackageJsonDependencies({
2075
+ packageJsonFilePath: buildContext.packageJsonFilePath
2076
+ });
2077
+ const moduleNames = Object.keys(Object.assign(Object.assign({}, dependencies), devDependencies));
2078
+ const moduleName = (() => {
2079
+ for (const moduleName_candidate of [
2080
+ "@storybook/react-vite",
2081
+ "@storybook/react-webpack5",
2082
+ "@storybook/react"
2083
+ ]) {
2084
+ if (moduleNames.includes(moduleName_candidate)) {
2085
+ return moduleName_candidate;
2086
+ }
2087
+ }
2088
+ return undefined;
2089
+ })();
2090
+ if (moduleName === undefined) {
2091
+ return false;
2092
+ }
2093
+ return [
2094
+ `// NOTE: This is only exported here because you're supposed to import type from different packages`,
2095
+ `// Depending of if you are using Vite, Webpack, ect...`,
2096
+ `export type { Meta, StoryObj } from "${moduleName}";`,
2097
+ ``
2098
+ ].join("\n");
2099
+ })()
1947
2100
  ]
1948
- .filter(item => typeof item === "string")
2101
+ .filter(item => {
2102
+ assert/* assert */.h;
2103
+ return typeof item === "string";
2104
+ })
1949
2105
  .join("\n");
1950
2106
  }
1951
- const hash = crypto__WEBPACK_IMPORTED_MODULE_4__.createHash("sha256").update(newContent).digest("hex");
2107
+ const hash = external_crypto_.createHash("sha256").update(newContent).digest("hex");
1952
2108
  skip_if_no_changes: {
1953
- if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__/* .existsAsync */ .o)(filePath))) {
2109
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(filePath))) {
1954
2110
  break skip_if_no_changes;
1955
2111
  }
1956
- const currentContent = (await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath)).toString("utf8");
2112
+ const currentContent = (await promises_.readFile(filePath)).toString("utf8");
1957
2113
  if (!currentContent.includes(hash)) {
1958
2114
  break skip_if_no_changes;
1959
2115
  }
@@ -1966,21 +2122,21 @@ async function command(params) {
1966
2122
  newContent
1967
2123
  ].join("\n");
1968
2124
  format: {
1969
- if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .getIsPrettierAvailable */ .MT)())) {
2125
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
1970
2126
  break format;
1971
2127
  }
1972
- newContent = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .runPrettier */ .eY)({
2128
+ newContent = await (0,runPrettier/* runPrettier */.eY)({
1973
2129
  filePath,
1974
2130
  sourceCode: newContent
1975
2131
  });
1976
2132
  }
1977
- await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(filePath, Buffer.from(newContent, "utf8"));
2133
+ await promises_.writeFile(filePath, Buffer.from(newContent, "utf8"));
1978
2134
  delete_legacy_file: {
1979
2135
  const legacyFilePath = filePath.replace(/tsx$/, "ts");
1980
- if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__/* .existsAsync */ .o)(legacyFilePath))) {
2136
+ if (!(await (0,fs_existsAsync/* existsAsync */.o)(legacyFilePath))) {
1981
2137
  break delete_legacy_file;
1982
2138
  }
1983
- await fs_promises__WEBPACK_IMPORTED_MODULE_0__.unlink(legacyFilePath);
2139
+ await promises_.unlink(legacyFilePath);
1984
2140
  }
1985
2141
  }
1986
2142
  //# sourceMappingURL=update-kc-gen.js.map
@@ -2030,7 +2186,7 @@ const copy_keycloak_resources_to_public_1 = __nccwpck_require__(713);
2030
2186
  const assert_1 = __nccwpck_require__(78);
2031
2187
  const buildContext_1 = __nccwpck_require__(250);
2032
2188
  const magic_string_1 = __importDefault(__nccwpck_require__(734));
2033
- const update_kc_gen_1 = __nccwpck_require__(786);
2189
+ const update_kc_gen_1 = __nccwpck_require__(371);
2034
2190
  const String_prototype_replaceAll_1 = __nccwpck_require__(62);
2035
2191
  function keycloakify(params) {
2036
2192
  const { postBuild, ...buildOptions } = params;