keycloakify 11.8.34 → 11.8.35

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/97.index.js CHANGED
@@ -3,6 +3,81 @@ exports.id = 97;
3
3
  exports.ids = [97];
4
4
  exports.modules = {
5
5
 
6
+ /***/ 72138:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+
10
+ // EXPORTS
11
+ __webpack_require__.d(__webpack_exports__, {
12
+ "q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
13
+ });
14
+
15
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
16
+ var esm_assert = __webpack_require__(29041);
17
+ // EXTERNAL MODULE: ./dist/bin/shared/constants.js
18
+ var constants = __webpack_require__(173);
19
+ ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
20
+
21
+
22
+ const BIN_NAME = "_keycloakify-custom-handler";
23
+ const NOT_IMPLEMENTED_EXIT_CODE = 78;
24
+ function readParams(params) {
25
+ const { apiVersion } = params;
26
+ assert(apiVersion === "v1");
27
+ const commandName = (() => {
28
+ const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
29
+ assert(envValue !== undefined);
30
+ return envValue;
31
+ })();
32
+ const buildContext = (() => {
33
+ const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
34
+ assert(envValue !== undefined);
35
+ return JSON.parse(envValue);
36
+ })();
37
+ return { commandName, buildContext };
38
+ }
39
+ //# sourceMappingURL=customHandler.js.map
40
+ // EXTERNAL MODULE: external "child_process"
41
+ var external_child_process_ = __webpack_require__(32081);
42
+ // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
43
+ var tools_nodeModulesBinDirPath = __webpack_require__(73776);
44
+ // EXTERNAL MODULE: external "fs"
45
+ var external_fs_ = __webpack_require__(57147);
46
+ ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
47
+
48
+
49
+
50
+
51
+
52
+
53
+ (0,esm_assert/* assert */.h)();
54
+ async function maybeDelegateCommandToCustomHandler(params) {
55
+ const { commandName, buildContext } = params;
56
+ const nodeModulesBinDirPath = await (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)({
57
+ packageJsonFilePath: buildContext.packageJsonFilePath
58
+ });
59
+ if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
60
+ return { hasBeenHandled: false };
61
+ }
62
+ try {
63
+ external_child_process_.execSync(`npx ${BIN_NAME}`, {
64
+ stdio: "inherit",
65
+ env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
66
+ });
67
+ }
68
+ catch (error) {
69
+ const status = error.status;
70
+ if (status === NOT_IMPLEMENTED_EXIT_CODE) {
71
+ return { hasBeenHandled: false };
72
+ }
73
+ process.exit(status);
74
+ }
75
+ return { hasBeenHandled: true };
76
+ }
77
+ //# sourceMappingURL=customHandler_delegate.js.map
78
+
79
+ /***/ }),
80
+
6
81
  /***/ 77372:
7
82
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
83
 
@@ -686,6 +761,10 @@ const untrackFromGit = runExclusive.build(groupRef, async (params) => {
686
761
  await dDone.pr;
687
762
  });
688
763
  //# sourceMappingURL=gitUtils.js.map
764
+ // EXTERNAL MODULE: ./dist/bin/update-kc-gen.js
765
+ var update_kc_gen = __webpack_require__(10786);
766
+ // EXTERNAL MODULE: ./dist/bin/shared/buildContext.js + 3 modules
767
+ var shared_buildContext = __webpack_require__(85400);
689
768
  ;// CONCATENATED MODULE: ./dist/bin/sync-extensions/sync-extension.js
690
769
 
691
770
 
@@ -695,6 +774,8 @@ const untrackFromGit = runExclusive.build(groupRef, async (params) => {
695
774
 
696
775
 
697
776
 
777
+
778
+
698
779
  async function command(params) {
699
780
  const { buildContext } = params;
700
781
  const extensionModuleMetas = await (0,sync_extensions_extensionModuleMeta/* getExtensionModuleMetas */.f)({ buildContext });
@@ -741,96 +822,16 @@ async function command(params) {
741
822
  await promises_.copyFile(copyableFilePath, destFilePath);
742
823
  })))
743
824
  .flat());
825
+ await (0,update_kc_gen.command)({
826
+ buildContext: (0,shared_buildContext/* getBuildContext */.s)({
827
+ projectDirPath: buildContext.projectDirPath
828
+ })
829
+ });
744
830
  }
745
831
  //# sourceMappingURL=sync-extension.js.map
746
832
 
747
833
  /***/ }),
748
834
 
749
- /***/ 12171:
750
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
751
-
752
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
753
- /* harmony export */ "h": () => (/* binding */ SemVer)
754
- /* harmony export */ });
755
- var SemVer;
756
- (function (SemVer) {
757
- const bumpTypes = ["major", "minor", "patch", "rc", "no bump"];
758
- function parse(versionStr) {
759
- const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
760
- if (!match) {
761
- throw new Error(`${versionStr} is not a valid semantic version`);
762
- }
763
- const semVer = Object.assign({ major: parseInt(match[1]), minor: parseInt(match[2]), patch: (() => {
764
- const str = match[3];
765
- return str === undefined ? 0 : parseInt(str);
766
- })() }, (() => {
767
- const str = match[4];
768
- return str === undefined ? {} : { rc: parseInt(str) };
769
- })());
770
- const initialStr = stringify(semVer);
771
- Object.defineProperty(semVer, "parsedFrom", {
772
- enumerable: true,
773
- get: function () {
774
- const currentStr = stringify(this);
775
- if (currentStr !== initialStr) {
776
- throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
777
- }
778
- return versionStr;
779
- }
780
- });
781
- return semVer;
782
- }
783
- SemVer.parse = parse;
784
- function stringify(v) {
785
- return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? "" : `-rc.${v.rc}`}`;
786
- }
787
- SemVer.stringify = stringify;
788
- /**
789
- *
790
- * v1 < v2 => -1
791
- * v1 === v2 => 0
792
- * v1 > v2 => 1
793
- *
794
- */
795
- function compare(v1, v2) {
796
- const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
797
- const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
798
- for (const level of ["major", "minor", "patch", "rc"]) {
799
- if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
800
- return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
801
- }
802
- }
803
- return 0;
804
- }
805
- SemVer.compare = compare;
806
- /*
807
- console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
808
- console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
809
- console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
810
- */
811
- function bumpType(params) {
812
- const versionAhead = typeof params.versionAhead === "string"
813
- ? parse(params.versionAhead)
814
- : params.versionAhead;
815
- const versionBehind = typeof params.versionBehind === "string"
816
- ? parse(params.versionBehind)
817
- : params.versionBehind;
818
- if (compare(versionBehind, versionAhead) === 1) {
819
- throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
820
- }
821
- for (const level of ["major", "minor", "patch", "rc"]) {
822
- if (versionBehind[level] !== versionAhead[level]) {
823
- return level;
824
- }
825
- }
826
- return "no bump";
827
- }
828
- SemVer.bumpType = bumpType;
829
- })(SemVer || (SemVer = {}));
830
- //# sourceMappingURL=SemVer.js.map
831
-
832
- /***/ }),
833
-
834
835
  /***/ 43765:
835
836
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
836
837
 
@@ -855,49 +856,6 @@ async function existsAsync(path) {
855
856
 
856
857
  /***/ }),
857
858
 
858
- /***/ 89693:
859
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
860
-
861
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
862
- /* harmony export */ "a": () => (/* binding */ rmSync)
863
- /* harmony export */ });
864
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
865
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
866
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
867
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
868
- /* harmony import */ var _SemVer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12171);
869
-
870
-
871
-
872
- /**
873
- * Polyfill of fs.rmSync(dirPath, { "recursive": true })
874
- * For older version of Node
875
- */
876
- function rmSync(dirPath, options) {
877
- if (_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.compare */ .h.compare(_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse(process.version), _SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse("14.14.0")) > 0) {
878
- fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(dirPath, options);
879
- return;
880
- }
881
- const { force = true } = options;
882
- if (force && !fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dirPath)) {
883
- return;
884
- }
885
- const removeDir_rec = (dirPath) => fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath).forEach(basename => {
886
- const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
887
- if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
888
- removeDir_rec(fileOrDirPath);
889
- return;
890
- }
891
- else {
892
- fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(fileOrDirPath);
893
- }
894
- });
895
- removeDir_rec(dirPath);
896
- }
897
- //# sourceMappingURL=fs.rmSync.js.map
898
-
899
- /***/ }),
900
-
901
859
  /***/ 93721:
902
860
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
903
861
 
@@ -1196,489 +1154,154 @@ function getNodeModulesBinDirPath(params) {
1196
1154
 
1197
1155
  /***/ }),
1198
1156
 
1199
- /***/ 63046:
1157
+ /***/ 10786:
1200
1158
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1201
1159
 
1202
-
1203
- // EXPORTS
1204
- __webpack_require__.d(__webpack_exports__, {
1205
- "c": () => (/* binding */ npmInstall)
1206
- });
1207
-
1208
- // EXTERNAL MODULE: external "fs"
1209
- var external_fs_ = __webpack_require__(57147);
1210
- // EXTERNAL MODULE: external "path"
1211
- var external_path_ = __webpack_require__(71017);
1212
- // EXTERNAL MODULE: external "child_process"
1213
- var external_child_process_ = __webpack_require__(32081);
1214
- // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
1215
- var source = __webpack_require__(78818);
1216
- var source_default = /*#__PURE__*/__webpack_require__.n(source);
1217
- // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
1218
- var lib = __webpack_require__(52300);
1219
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
1220
- var assert = __webpack_require__(29041);
1221
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
1222
- var id = __webpack_require__(38469);
1223
- ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
1224
- /** https://docs.tsafe.dev/objectKeys */
1225
- function objectKeys(o) {
1226
- return Object.keys(o);
1227
- }
1228
-
1229
-
1230
- //# sourceMappingURL=objectKeys.mjs.map
1231
-
1232
- // EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
1233
- var getAbsoluteAndInOsFormatPath = __webpack_require__(84794);
1234
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
1235
- var exclude = __webpack_require__(83101);
1236
- // EXTERNAL MODULE: ./dist/bin/tools/fs.rmSync.js
1237
- var fs_rmSync = __webpack_require__(89693);
1238
- // EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
1239
- var Deferred = __webpack_require__(50689);
1240
- ;// CONCATENATED MODULE: ./dist/bin/tools/npmInstall.js
1241
-
1242
-
1243
-
1244
-
1245
-
1246
-
1247
-
1248
-
1249
-
1250
-
1251
-
1252
-
1253
- async function npmInstall(params) {
1254
- const { packageJsonDirPath } = params;
1255
- const packageManagerBinName = (() => {
1256
- const packageMangers = [
1257
- {
1258
- binName: "yarn",
1259
- lockFileBasename: "yarn.lock"
1260
- },
1261
- {
1262
- binName: "npm",
1263
- lockFileBasename: "package-lock.json"
1264
- },
1265
- {
1266
- binName: "pnpm",
1267
- lockFileBasename: "pnpm-lock.yaml"
1268
- },
1269
- {
1270
- binName: "bun",
1271
- lockFileBasename: "bun.lockdb"
1272
- },
1273
- {
1274
- binName: "deno",
1275
- lockFileBasename: "deno.lock"
1276
- }
1277
- ];
1278
- for (const packageManager of packageMangers) {
1279
- if (external_fs_.existsSync((0,external_path_.join)(packageJsonDirPath, packageManager.lockFileBasename)) ||
1280
- external_fs_.existsSync((0,external_path_.join)(process.cwd(), packageManager.lockFileBasename))) {
1281
- return packageManager.binName;
1282
- }
1283
- }
1284
- throw new Error("No lock file found, cannot tell which package manager to use for installing dependencies.");
1285
- })();
1286
- console.log(`Installing the new dependencies...`);
1287
- install_without_breaking_links: {
1288
- if (packageManagerBinName !== "yarn") {
1289
- break install_without_breaking_links;
1290
- }
1291
- const garronejLinkInfos = getGarronejLinkInfos({ packageJsonDirPath });
1292
- if (garronejLinkInfos === undefined) {
1293
- break install_without_breaking_links;
1294
- }
1295
- console.log(source_default().green("Installing in a way that won't break the links..."));
1296
- await installWithoutBreakingLinks({
1297
- packageJsonDirPath,
1298
- garronejLinkInfos
1299
- });
1300
- return;
1301
- }
1302
- try {
1303
- await runPackageManagerInstall({
1304
- packageManagerBinName,
1305
- cwd: packageJsonDirPath
1306
- });
1307
- }
1308
- catch (_a) {
1309
- console.log(source_default().yellow(`\`${packageManagerBinName} install\` failed, continuing anyway...`));
1310
- }
1311
- }
1312
- async function runPackageManagerInstall(params) {
1313
- const { packageManagerBinName, cwd } = params;
1314
- const dCompleted = new Deferred.Deferred();
1315
- const child = external_child_process_.spawn(packageManagerBinName, ["install"], {
1316
- cwd,
1317
- env: process.env,
1318
- shell: true
1319
- });
1320
- child.stdout.on("data", data => process.stdout.write(data));
1321
- child.stderr.on("data", data => {
1322
- if (data.toString("utf8").includes("peer dependency")) {
1323
- return;
1324
- }
1325
- process.stderr.write(data);
1326
- });
1327
- child.on("exit", code => {
1328
- if (code !== 0) {
1329
- dCompleted.reject(new Error(`Failed with code ${code}`));
1330
- return;
1331
- }
1332
- dCompleted.resolve();
1333
- });
1334
- await dCompleted.pr;
1335
- }
1336
- function getGarronejLinkInfos(params) {
1337
- const { packageJsonDirPath } = params;
1338
- const nodeModuleDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
1339
- if (!external_fs_.existsSync(nodeModuleDirPath)) {
1340
- return undefined;
1341
- }
1342
- const linkedModuleNames = [];
1343
- let yarnHomeDirPath = undefined;
1344
- const getIsLinkedByGarronejScript = (path) => {
1345
- let realPath;
1346
- try {
1347
- realPath = external_fs_.readlinkSync(path);
1348
- }
1349
- catch (_a) {
1350
- return false;
1351
- }
1352
- const doesIncludeYarnHome = realPath.includes(".yarn_home");
1353
- if (!doesIncludeYarnHome) {
1354
- return false;
1355
- }
1356
- set_yarnHomeDirPath: {
1357
- if (yarnHomeDirPath !== undefined) {
1358
- break set_yarnHomeDirPath;
1359
- }
1360
- const [firstElement] = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
1361
- pathIsh: realPath,
1362
- cwd: (0,external_path_.dirname)(path)
1363
- }).split(".yarn_home");
1364
- yarnHomeDirPath = (0,external_path_.join)(firstElement, ".yarn_home");
1365
- }
1366
- return true;
1367
- };
1368
- for (const basename of external_fs_.readdirSync(nodeModuleDirPath)) {
1369
- const path = (0,external_path_.join)(nodeModuleDirPath, basename);
1370
- if (external_fs_.lstatSync(path).isSymbolicLink()) {
1371
- if (basename.startsWith("@")) {
1372
- return undefined;
1373
- }
1374
- if (!getIsLinkedByGarronejScript(path)) {
1375
- return undefined;
1376
- }
1377
- linkedModuleNames.push(basename);
1378
- continue;
1379
- }
1380
- if (!external_fs_.lstatSync(path).isDirectory()) {
1381
- continue;
1382
- }
1383
- if (basename.startsWith("@")) {
1384
- for (const subBasename of external_fs_.readdirSync(path)) {
1385
- const subPath = (0,external_path_.join)(path, subBasename);
1386
- if (!external_fs_.lstatSync(subPath).isSymbolicLink()) {
1387
- continue;
1388
- }
1389
- if (!getIsLinkedByGarronejScript(subPath)) {
1390
- return undefined;
1391
- }
1392
- linkedModuleNames.push(`${basename}/${subBasename}`);
1393
- }
1394
- }
1395
- }
1396
- if (yarnHomeDirPath === undefined) {
1397
- return undefined;
1398
- }
1399
- return { linkedModuleNames, yarnHomeDirPath };
1400
- }
1401
- async function installWithoutBreakingLinks(params) {
1402
- const { packageJsonDirPath, garronejLinkInfos: { linkedModuleNames, yarnHomeDirPath } } = params;
1403
- const parsedPackageJson = (() => {
1404
- const packageJsonFilePath = (0,external_path_.join)(packageJsonDirPath, "package.json");
1405
- const zParsedPackageJson = (() => {
1406
- const zTargetType = lib.z.object({
1407
- scripts: lib.z.record(lib.z.string()).optional()
1408
- });
1409
- assert/* assert */.h;
1410
- return (0,id.id)(zTargetType);
1411
- })();
1412
- const parsedPackageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
1413
- zParsedPackageJson.parse(parsedPackageJson);
1414
- (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
1415
- return parsedPackageJson;
1416
- })();
1417
- const isImplementedScriptByName = {
1418
- postinstall: false,
1419
- prepare: false
1420
- };
1421
- delete_postinstall_script: {
1422
- if (parsedPackageJson.scripts === undefined) {
1423
- break delete_postinstall_script;
1424
- }
1425
- for (const scriptName of objectKeys(isImplementedScriptByName)) {
1426
- if (parsedPackageJson.scripts[scriptName] === undefined) {
1427
- continue;
1428
- }
1429
- isImplementedScriptByName[scriptName] = true;
1430
- delete parsedPackageJson.scripts[scriptName];
1431
- }
1432
- }
1433
- const tmpProjectDirPath = (0,external_path_.join)(yarnHomeDirPath, "tmpProject");
1434
- if (external_fs_.existsSync(tmpProjectDirPath)) {
1435
- (0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
1436
- }
1437
- external_fs_.mkdirSync(tmpProjectDirPath, { recursive: true });
1438
- external_fs_.writeFileSync((0,external_path_.join)(tmpProjectDirPath, "package.json"), JSON.stringify(parsedPackageJson, undefined, 4));
1439
- const YARN_LOCK = "yarn.lock";
1440
- external_fs_.copyFileSync((0,external_path_.join)(packageJsonDirPath, YARN_LOCK), (0,external_path_.join)(tmpProjectDirPath, YARN_LOCK));
1441
- await runPackageManagerInstall({
1442
- packageManagerBinName: "yarn",
1443
- cwd: tmpProjectDirPath
1444
- });
1445
- // NOTE: Moving the modules from the tmp project to the actual project
1446
- // without messing up the links.
1447
- {
1448
- const { getAreSameVersions } = (() => {
1449
- const zParsedPackageJson = (() => {
1450
- const zTargetType = lib.z.object({
1451
- version: lib.z.string()
1452
- });
1453
- assert/* assert */.h;
1454
- return (0,id.id)(zTargetType);
1455
- })();
1456
- function readVersion(params) {
1457
- const { moduleDirPath } = params;
1458
- const packageJsonFilePath = (0,external_path_.join)(moduleDirPath, "package.json");
1459
- const packageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
1460
- zParsedPackageJson.parse(packageJson);
1461
- (0,assert/* assert */.h)((0,assert.is)(packageJson));
1462
- return packageJson.version;
1463
- }
1464
- function getAreSameVersions(params) {
1465
- const { moduleDirPath_a, moduleDirPath_b } = params;
1466
- return (readVersion({ moduleDirPath: moduleDirPath_a }) ===
1467
- readVersion({ moduleDirPath: moduleDirPath_b }));
1468
- }
1469
- return { getAreSameVersions };
1470
- })();
1471
- const nodeModulesDirPath_tmpProject = (0,external_path_.join)(tmpProjectDirPath, "node_modules");
1472
- const nodeModulesDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
1473
- const modulePaths = external_fs_.readdirSync(nodeModulesDirPath_tmpProject)
1474
- .map(basename => {
1475
- if (basename.startsWith(".")) {
1476
- return undefined;
1477
- }
1478
- const path = (0,external_path_.join)(nodeModulesDirPath_tmpProject, basename);
1479
- if (basename.startsWith("@")) {
1480
- return external_fs_.readdirSync(path)
1481
- .map(subBasename => {
1482
- if (subBasename.startsWith(".")) {
1483
- return undefined;
1484
- }
1485
- const subPath = (0,external_path_.join)(path, subBasename);
1486
- if (!external_fs_.lstatSync(subPath).isDirectory()) {
1487
- return undefined;
1488
- }
1489
- return {
1490
- moduleName: `${basename}/${subBasename}`,
1491
- moduleDirPath_tmpProject: subPath,
1492
- moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename, subBasename)
1493
- };
1494
- })
1495
- .filter((0,exclude/* exclude */.D)(undefined));
1496
- }
1497
- if (!external_fs_.lstatSync(path).isDirectory()) {
1498
- return undefined;
1499
- }
1500
- return [
1501
- {
1502
- moduleName: basename,
1503
- moduleDirPath_tmpProject: path,
1504
- moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename)
1505
- }
1506
- ];
1507
- })
1508
- .filter((0,exclude/* exclude */.D)(undefined))
1509
- .flat();
1510
- for (const { moduleName, moduleDirPath, moduleDirPath_tmpProject } of modulePaths) {
1511
- if (linkedModuleNames.includes(moduleName)) {
1512
- continue;
1513
- }
1514
- let doesTargetModuleExist = false;
1515
- skip_condition: {
1516
- if (!external_fs_.existsSync(moduleDirPath)) {
1517
- break skip_condition;
1518
- }
1519
- doesTargetModuleExist = true;
1520
- const areSameVersions = getAreSameVersions({
1521
- moduleDirPath_a: moduleDirPath,
1522
- moduleDirPath_b: moduleDirPath_tmpProject
1523
- });
1524
- if (!areSameVersions) {
1525
- break skip_condition;
1526
- }
1527
- continue;
1528
- }
1529
- if (doesTargetModuleExist) {
1530
- (0,fs_rmSync/* rmSync */.a)(moduleDirPath, { recursive: true });
1531
- }
1532
- {
1533
- const dirPath = (0,external_path_.dirname)(moduleDirPath);
1534
- if (!external_fs_.existsSync(dirPath)) {
1535
- external_fs_.mkdirSync(dirPath, { recursive: true });
1536
- }
1537
- }
1538
- external_fs_.renameSync(moduleDirPath_tmpProject, moduleDirPath);
1539
- }
1540
- move_bin: {
1541
- const binDirPath_tmpProject = (0,external_path_.join)(nodeModulesDirPath_tmpProject, ".bin");
1542
- const binDirPath = (0,external_path_.join)(nodeModulesDirPath, ".bin");
1543
- if (!external_fs_.existsSync(binDirPath_tmpProject)) {
1544
- break move_bin;
1545
- }
1546
- for (const basename of external_fs_.readdirSync(binDirPath_tmpProject)) {
1547
- const path_tmpProject = (0,external_path_.join)(binDirPath_tmpProject, basename);
1548
- const path = (0,external_path_.join)(binDirPath, basename);
1549
- if (external_fs_.existsSync(path)) {
1550
- continue;
1551
- }
1552
- external_fs_.renameSync(path_tmpProject, path);
1553
- }
1554
- }
1555
- }
1556
- external_fs_.cpSync((0,external_path_.join)(tmpProjectDirPath, YARN_LOCK), (0,external_path_.join)(packageJsonDirPath, YARN_LOCK));
1557
- (0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
1558
- for (const scriptName of objectKeys(isImplementedScriptByName)) {
1559
- if (!isImplementedScriptByName[scriptName]) {
1560
- continue;
1561
- }
1562
- external_child_process_.execSync(`yarn run ${scriptName}`, {
1563
- cwd: packageJsonDirPath,
1564
- stdio: "inherit"
1565
- });
1566
- }
1567
- }
1568
- //# sourceMappingURL=npmInstall.js.map
1569
-
1570
- /***/ }),
1571
-
1572
- /***/ 48433:
1573
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
1574
-
1160
+ __webpack_require__.r(__webpack_exports__);
1575
1161
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1576
- /* harmony export */ "LG": () => (/* binding */ getPrettier),
1577
- /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
1578
- /* harmony export */ "eY": () => (/* binding */ runPrettier)
1162
+ /* harmony export */ "command": () => (/* binding */ command)
1579
1163
  /* harmony export */ });
1580
- /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
1164
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
1165
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
1581
1166
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
1582
1167
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1583
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
1584
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
1585
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
1586
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
1587
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
1588
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
1589
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
1590
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
1591
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
1592
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
1593
- /* module decorator */ module = __webpack_require__.hmd(module);
1594
-
1168
+ /* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(43765);
1169
+ /* harmony import */ var _shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(72138);
1170
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6113);
1171
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_4__);
1172
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(48433);
1595
1173
 
1596
1174
 
1597
1175
 
1598
1176
 
1599
1177
 
1600
1178
 
1601
-
1602
-
1603
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1604
- async function getIsPrettierAvailable() {
1605
- var _a;
1606
- if (getIsPrettierAvailable.cache !== undefined) {
1607
- return getIsPrettierAvailable.cache;
1179
+ async function command(params) {
1180
+ const { buildContext } = params;
1181
+ run_copy_assets_to_public: {
1182
+ if (buildContext.bundler !== "webpack") {
1183
+ break run_copy_assets_to_public;
1184
+ }
1185
+ const { command } = await __webpack_require__.e(/* import() */ 658).then(__webpack_require__.bind(__webpack_require__, 18040));
1186
+ await command({ buildContext });
1608
1187
  }
1609
- const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({
1610
- packageJsonFilePath: undefined
1188
+ const { hasBeenHandled } = await (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__/* .maybeDelegateCommandToCustomHandler */ .q)({
1189
+ commandName: "update-kc-gen",
1190
+ buildContext
1611
1191
  });
1612
- const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
1613
- const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
1614
- const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
1615
- getIsPrettierAvailable.cache = isPrettierAvailable;
1616
- return isPrettierAvailable;
1617
- }
1618
- getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1619
- async function getPrettier() {
1620
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
1621
- if (getPrettier.cache !== undefined) {
1622
- return getPrettier.cache;
1192
+ if (hasBeenHandled) {
1193
+ return;
1623
1194
  }
1624
- let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
1625
- import_prettier: {
1626
- // NOTE: When module is linked we want to make sure we import the correct version
1627
- // of prettier, that is the one of the project, not the one of this repo.
1628
- // So we do a sketchy eval to bypass ncc.
1629
- // We make sure to only do that when linking, otherwise we import properly.
1630
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
1631
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", "prettier"));
1632
- const isCJS = true && module.exports;
1633
- if (isCJS) {
1634
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${prettierDirPath}")`);
1635
- }
1636
- else {
1637
- prettier = await new Promise(_resolve => {
1638
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_1__.join)(prettierDirPath, "index.mjs").replace(/\\/g, "/")}").then(prettier => _resolve(prettier))`);
1639
- });
1640
- }
1641
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
1642
- break import_prettier;
1195
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc.gen.tsx");
1196
+ const hasLoginTheme = buildContext.implementedThemeTypes.login.isImplemented;
1197
+ const hasAccountTheme = buildContext.implementedThemeTypes.account.isImplemented;
1198
+ const hasAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
1199
+ let newContent = [
1200
+ ``,
1201
+ `/* eslint-disable */`,
1202
+ ``,
1203
+ `// @ts-nocheck`,
1204
+ ``,
1205
+ `// noinspection JSUnusedGlobalSymbols`,
1206
+ ``,
1207
+ `import { lazy, Suspense, type ReactNode } from "react";`,
1208
+ ``,
1209
+ `export type ThemeName = ${buildContext.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
1210
+ ``,
1211
+ `export const themeNames: ThemeName[] = [${buildContext.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
1212
+ ``,
1213
+ `export type KcEnvName = ${buildContext.environmentVariables.length === 0 ? "never" : buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
1214
+ ``,
1215
+ `export const kcEnvNames: KcEnvName[] = [${buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
1216
+ ``,
1217
+ `export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(Object.fromEntries(buildContext.environmentVariables.map(({ name, default: defaultValue }) => [name, defaultValue])), null, 2)};`,
1218
+ ``,
1219
+ `/**`,
1220
+ ` * NOTE: Do not import this type except maybe in your entrypoint. `,
1221
+ ` * If you need to import the KcContext import it either from src/login/KcContext.ts or src/account/KcContext.ts.`,
1222
+ ` * Depending on the theme type you are working on.`,
1223
+ ` */`,
1224
+ `export type KcContext =`,
1225
+ hasLoginTheme && ` | import("./login/KcContext").KcContext`,
1226
+ hasAccountTheme && ` | import("./account/KcContext").KcContext`,
1227
+ hasAdminTheme && ` | import("./admin/KcContext").KcContext`,
1228
+ ` ;`,
1229
+ ``,
1230
+ `declare global {`,
1231
+ ` interface Window {`,
1232
+ ` kcContext?: KcContext;`,
1233
+ ` }`,
1234
+ `}`,
1235
+ ``,
1236
+ hasLoginTheme &&
1237
+ `export const KcLoginPage = lazy(() => import("./login/KcPage"));`,
1238
+ hasAccountTheme &&
1239
+ `export const KcAccountPage = lazy(() => import("./account/KcPage"));`,
1240
+ hasAdminTheme &&
1241
+ `export const KcAdminPage = lazy(() => import("./admin/KcPage"));`,
1242
+ ``,
1243
+ `export function KcPage(`,
1244
+ ` props: {`,
1245
+ ` kcContext: KcContext;`,
1246
+ ` fallback?: ReactNode;`,
1247
+ ` }`,
1248
+ `) {`,
1249
+ ` const { kcContext, fallback } = props;`,
1250
+ ` return (`,
1251
+ ` <Suspense fallback={fallback}>`,
1252
+ ` {(() => {`,
1253
+ ` switch (kcContext.themeType) {`,
1254
+ hasLoginTheme &&
1255
+ ` case "login": return <KcLoginPage kcContext={kcContext} />;`,
1256
+ hasAccountTheme &&
1257
+ ` case "account": return <KcAccountPage kcContext={kcContext} />;`,
1258
+ hasAdminTheme &&
1259
+ ` case "admin": return <KcAdminPage kcContext={kcContext} />;`,
1260
+ ` }`,
1261
+ ` })()}`,
1262
+ ` </Suspense>`,
1263
+ ` );`,
1264
+ `}`,
1265
+ ``
1266
+ ]
1267
+ .filter(item => typeof item === "string")
1268
+ .join("\n");
1269
+ const hash = crypto__WEBPACK_IMPORTED_MODULE_4__.createHash("sha256").update(newContent).digest("hex");
1270
+ skip_if_no_changes: {
1271
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__/* .existsAsync */ .o)(filePath))) {
1272
+ break skip_if_no_changes;
1273
+ }
1274
+ const currentContent = (await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath)).toString("utf8");
1275
+ if (!currentContent.includes(hash)) {
1276
+ break skip_if_no_changes;
1643
1277
  }
1644
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
1278
+ return;
1645
1279
  }
1646
- const configHash = await (async () => {
1647
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", ".."));
1648
- if (configFilePath === null) {
1649
- return "";
1280
+ newContent = [
1281
+ `// This file is auto-generated by the \`update-kc-gen\` command. Do not edit it manually.`,
1282
+ `// Hash: ${hash}`,
1283
+ ``,
1284
+ newContent
1285
+ ].join("\n");
1286
+ format: {
1287
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .getIsPrettierAvailable */ .MT)())) {
1288
+ break format;
1650
1289
  }
1651
- const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
1652
- return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
1653
- })();
1654
- const prettierAndConfig = {
1655
- prettier,
1656
- configHash
1657
- };
1658
- getPrettier.cache = prettierAndConfig;
1659
- return prettierAndConfig;
1660
- }
1661
- async function runPrettier(params) {
1662
- const { sourceCode, filePath } = params;
1663
- let formattedSourceCode;
1664
- try {
1665
- const { prettier } = await getPrettier();
1666
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
1667
- resolveConfig: true
1290
+ newContent = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .runPrettier */ .eY)({
1291
+ filePath,
1292
+ sourceCode: newContent
1668
1293
  });
1669
- if (ignored || inferredParser === null) {
1670
- return sourceCode;
1671
- }
1672
- const config = await prettier.resolveConfig(filePath);
1673
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
1674
1294
  }
1675
- catch (error) {
1676
- console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
1677
- throw error;
1295
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(filePath, Buffer.from(newContent, "utf8"));
1296
+ delete_legacy_file: {
1297
+ const legacyFilePath = filePath.replace(/tsx$/, "ts");
1298
+ if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_2__/* .existsAsync */ .o)(legacyFilePath))) {
1299
+ break delete_legacy_file;
1300
+ }
1301
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.unlink(legacyFilePath);
1678
1302
  }
1679
- return formattedSourceCode;
1680
1303
  }
1681
- //# sourceMappingURL=runPrettier.js.map
1304
+ //# sourceMappingURL=update-kc-gen.js.map
1682
1305
 
1683
1306
  /***/ })
1684
1307