keycloakify 11.3.19 → 11.3.21

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.
Files changed (67) hide show
  1. package/bin/124.index.js +676 -0
  2. package/bin/356.index.js +700 -0
  3. package/bin/40.index.js +41 -21
  4. package/bin/{903.index.js → 450.index.js} +2 -680
  5. package/bin/453.index.js +143 -85
  6. package/bin/573.index.js +51 -24
  7. package/bin/{599.index.js → 735.index.js} +438 -121
  8. package/bin/786.index.js +129 -78
  9. package/bin/805.index.js +674 -0
  10. package/bin/854.index.js +68 -0
  11. package/bin/{780.index.js → 921.index.js} +168 -109
  12. package/bin/932.index.js +41 -21
  13. package/bin/97.index.js +125 -75
  14. package/bin/eject-file.d.ts +7 -0
  15. package/bin/keycloakify/generateResources/generateMessageProperties.d.ts +1 -1
  16. package/bin/keycloakify/generateResources/readFieldNameUsage.d.ts +1 -1
  17. package/bin/main.js +70 -7
  18. package/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.d.ts +12 -0
  19. package/bin/postinstall/index.d.ts +1 -0
  20. package/bin/postinstall/installUiModulesPeerDependencies.d.ts +11 -0
  21. package/bin/postinstall/managedGitignoreFile.d.ts +14 -0
  22. package/bin/postinstall/postinstall.d.ts +4 -0
  23. package/bin/postinstall/uiModuleMeta.d.ts +21 -0
  24. package/bin/shared/buildContext.d.ts +3 -0
  25. package/bin/shared/constants.d.ts +2 -1
  26. package/bin/shared/constants.js +2 -1
  27. package/bin/shared/constants.js.map +1 -1
  28. package/bin/shared/customHandler.d.ts +1 -1
  29. package/bin/shared/customHandler.js.map +1 -1
  30. package/bin/shared/exitIfUncommittedChanges.d.ts +3 -0
  31. package/bin/tools/crawlAsync.d.ts +6 -0
  32. package/bin/tools/getInstalledModuleDirPath.d.ts +5 -0
  33. package/bin/tools/listInstalledModules.d.ts +12 -0
  34. package/bin/tools/nodeModulesBinDirPath.d.ts +1 -0
  35. package/bin/tools/runPrettier.d.ts +17 -0
  36. package/package.json +34 -6
  37. package/src/bin/add-story.ts +28 -10
  38. package/src/bin/eject-file.ts +68 -0
  39. package/src/bin/eject-page.ts +51 -31
  40. package/src/bin/initialize-account-theme/initialize-account-theme.ts +4 -32
  41. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +2 -16
  42. package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +1 -1
  43. package/src/bin/keycloakify/generateResources/generateResources.ts +58 -26
  44. package/src/bin/keycloakify/generateResources/readFieldNameUsage.ts +1 -1
  45. package/src/bin/main.ts +50 -0
  46. package/src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts +73 -0
  47. package/src/bin/postinstall/index.ts +1 -0
  48. package/src/bin/postinstall/installUiModulesPeerDependencies.ts +158 -0
  49. package/src/bin/postinstall/managedGitignoreFile.ts +136 -0
  50. package/src/bin/postinstall/postinstall.ts +79 -0
  51. package/src/bin/postinstall/uiModuleMeta.ts +309 -0
  52. package/src/bin/shared/buildContext.ts +11 -5
  53. package/src/bin/shared/constants.ts +3 -1
  54. package/src/bin/shared/customHandler.ts +1 -0
  55. package/src/bin/shared/customHandler_delegate.ts +2 -27
  56. package/src/bin/shared/exitIfUncommittedChanges.ts +36 -0
  57. package/src/bin/tools/crawlAsync.ts +51 -0
  58. package/src/bin/tools/getInstalledModuleDirPath.ts +51 -0
  59. package/src/bin/tools/listInstalledModules.ts +131 -0
  60. package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
  61. package/src/bin/tools/npmInstall.ts +411 -15
  62. package/src/bin/tools/readThisNpmPackageVersion.ts +8 -0
  63. package/src/bin/tools/runPrettier.ts +106 -0
  64. package/src/bin/update-kc-gen.ts +28 -17
  65. package/vite-plugin/index.js +9237 -9163
  66. package/bin/tools/runFormat.d.ts +0 -3
  67. package/src/bin/tools/runFormat.ts +0 -76
package/bin/453.index.js CHANGED
@@ -24,7 +24,7 @@ __webpack_require__.r(__webpack_exports__);
24
24
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(78818);
25
25
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_6__);
26
26
  /* harmony import */ var _shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(72138);
27
- /* harmony import */ var _tools_runFormat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(22577);
27
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(48433);
28
28
 
29
29
 
30
30
 
@@ -53,6 +53,8 @@ async function command(params) {
53
53
  return buildContext.implementedThemeTypes.account.isImplemented;
54
54
  case "login":
55
55
  return buildContext.implementedThemeTypes.login.isImplemented;
56
+ case "admin":
57
+ return buildContext.implementedThemeTypes.admin.isImplemented;
56
58
  }
57
59
  (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)(false);
58
60
  });
@@ -67,41 +69,55 @@ async function command(params) {
67
69
  });
68
70
  return value;
69
71
  })();
72
+ if (themeType === "admin") {
73
+ console.log("Use `npx keycloakify eject-file` command instead, see documentation");
74
+ process.exit(-1);
75
+ }
70
76
  if (themeType === "account" &&
71
77
  ((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)(buildContext.implementedThemeTypes.account.isImplemented),
72
78
  buildContext.implementedThemeTypes.account.type === "Single-Page")) {
73
- const srcDirPath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,path__WEBPACK_IMPORTED_MODULE_4__.dirname)(buildContext.packageJsonFilePath), "node_modules", "@keycloakify", "keycloak-account-ui", "src");
79
+ const srcDirPath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,path__WEBPACK_IMPORTED_MODULE_4__.dirname)(buildContext.packageJsonFilePath), "node_modules", "@keycloakify", `keycloak-account-ui`, "src");
74
80
  console.log([
75
- `There isn't an interactive CLI to eject components of the Single-Page Account theme.`,
81
+ `There isn't an interactive CLI to eject components of the Account SPA UI.`,
76
82
  `You can however copy paste into your codebase the any file or directory from the following source directory:`,
77
83
  ``,
78
84
  `${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold((0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), srcDirPath)))}`,
79
85
  ``
80
86
  ].join("\n"));
81
87
  eject_entrypoint: {
82
- const kcAccountUiTsxFileRelativePath = "KcAccountUi.tsx";
83
- const accountThemeSrcDirPath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(buildContext.themeSrcDirPath, "account");
84
- const targetFilePath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(accountThemeSrcDirPath, kcAccountUiTsxFileRelativePath);
88
+ const kcUiTsxFileRelativePath = `KcAccountUi.tsx`;
89
+ const themeSrcDirPath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(buildContext.themeSrcDirPath, "account");
90
+ const targetFilePath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(themeSrcDirPath, kcUiTsxFileRelativePath);
85
91
  if (fs__WEBPACK_IMPORTED_MODULE_3__.existsSync(targetFilePath)) {
86
92
  break eject_entrypoint;
87
93
  }
88
- fs__WEBPACK_IMPORTED_MODULE_3__.cpSync((0,path__WEBPACK_IMPORTED_MODULE_4__.join)(srcDirPath, kcAccountUiTsxFileRelativePath), targetFilePath);
94
+ fs__WEBPACK_IMPORTED_MODULE_3__.cpSync((0,path__WEBPACK_IMPORTED_MODULE_4__.join)(srcDirPath, kcUiTsxFileRelativePath), targetFilePath);
89
95
  {
90
- const kcPageTsxFilePath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(accountThemeSrcDirPath, "KcPage.tsx");
96
+ const kcPageTsxFilePath = (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(themeSrcDirPath, "KcPage.tsx");
91
97
  const kcPageTsxCode = fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync(kcPageTsxFilePath).toString("utf8");
92
- const componentName = (0,path__WEBPACK_IMPORTED_MODULE_4__.basename)(kcAccountUiTsxFileRelativePath).replace(/.tsx$/, "");
93
- const modifiedKcPageTsxCode = kcPageTsxCode.replace(`@keycloakify/keycloak-account-ui/${componentName}`, `./${componentName}`);
98
+ const componentName = (0,path__WEBPACK_IMPORTED_MODULE_4__.basename)(kcUiTsxFileRelativePath).replace(/.tsx$/, "");
99
+ let modifiedKcPageTsxCode = kcPageTsxCode.replace(`@keycloakify/keycloak-account-ui/${componentName}`, `./${componentName}`);
100
+ run_prettier: {
101
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_8__/* .getIsPrettierAvailable */ .MT)())) {
102
+ break run_prettier;
103
+ }
104
+ modifiedKcPageTsxCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_8__/* .runPrettier */ .eY)({
105
+ filePath: kcPageTsxFilePath,
106
+ sourceCode: modifiedKcPageTsxCode
107
+ });
108
+ }
94
109
  fs__WEBPACK_IMPORTED_MODULE_3__.writeFileSync(kcPageTsxFilePath, Buffer.from(modifiedKcPageTsxCode, "utf8"));
95
110
  }
96
111
  const routesTsxFilePath = (0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), (0,path__WEBPACK_IMPORTED_MODULE_4__.join)(srcDirPath, "routes.tsx"));
97
112
  console.log([
98
113
  `To help you get started ${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold((0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), targetFilePath))} has been copied into your project.`,
99
114
  `The next step is usually to eject ${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold(routesTsxFilePath)}`,
100
- `with \`cp ${routesTsxFilePath} ${(0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), accountThemeSrcDirPath)}\``,
101
- `then update the import of routes in ${kcAccountUiTsxFileRelativePath}.`
115
+ `with \`cp ${routesTsxFilePath} ${(0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), themeSrcDirPath)}\``,
116
+ `then update the import of routes in ${kcUiTsxFileRelativePath}.`
102
117
  ].join("\n"));
103
118
  }
104
119
  process.exit(0);
120
+ return;
105
121
  }
106
122
  console.log(`→ ${themeType}`);
107
123
  console.log(chalk__WEBPACK_IMPORTED_MODULE_6___default().cyan("Select the page you want to customize:"));
@@ -146,8 +162,17 @@ async function command(params) {
146
162
  console.log(`${pageIdOrComponent} is already ejected, ${(0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), targetFilePath)} already exists`);
147
163
  process.exit(-1);
148
164
  }
149
- const componentCode = fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,_tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getThisCodebaseRootDirPath */ .e)(), "src", themeType, pagesOrDot, componentBasename))
165
+ let componentCode = fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,_tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getThisCodebaseRootDirPath */ .e)(), "src", themeType, pagesOrDot, componentBasename))
150
166
  .toString("utf8");
167
+ run_prettier: {
168
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_8__/* .getIsPrettierAvailable */ .MT)())) {
169
+ break run_prettier;
170
+ }
171
+ componentCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_8__/* .runPrettier */ .eY)({
172
+ filePath: targetFilePath,
173
+ sourceCode: componentCode
174
+ });
175
+ }
151
176
  {
152
177
  const targetDirPath = (0,path__WEBPACK_IMPORTED_MODULE_4__.dirname)(targetFilePath);
153
178
  if (!fs__WEBPACK_IMPORTED_MODULE_3__.existsSync(targetDirPath)) {
@@ -155,9 +180,6 @@ async function command(params) {
155
180
  }
156
181
  }
157
182
  fs__WEBPACK_IMPORTED_MODULE_3__.writeFileSync(targetFilePath, Buffer.from(componentCode, "utf8"));
158
- (0,_tools_runFormat__WEBPACK_IMPORTED_MODULE_8__/* .runFormat */ .S)({
159
- packageJsonFilePath: buildContext.packageJsonFilePath
160
- });
161
183
  console.log(`${chalk__WEBPACK_IMPORTED_MODULE_6___default().green("✓")} ${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold((0,path__WEBPACK_IMPORTED_MODULE_4__.join)(".", (0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), targetFilePath)))} copy pasted from the Keycloakify source code into your project`);
162
184
  edit_KcPage: {
163
185
  if (pageIdOrComponent !== templateValue &&
@@ -276,8 +298,8 @@ function readParams(params) {
276
298
  //# sourceMappingURL=customHandler.js.map
277
299
  // EXTERNAL MODULE: external "child_process"
278
300
  var external_child_process_ = __webpack_require__(32081);
279
- // EXTERNAL MODULE: external "path"
280
- var external_path_ = __webpack_require__(71017);
301
+ // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
302
+ var tools_nodeModulesBinDirPath = __webpack_require__(73776);
281
303
  // EXTERNAL MODULE: external "fs"
282
304
  var external_fs_ = __webpack_require__(57147);
283
305
  ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
@@ -290,25 +312,7 @@ var external_fs_ = __webpack_require__(57147);
290
312
  (0,esm_assert/* assert */.h)();
291
313
  function maybeDelegateCommandToCustomHandler(params) {
292
314
  const { commandName, buildContext } = params;
293
- const nodeModulesBinDirPath = (() => {
294
- const binPath = process.argv[1];
295
- const segments = [".bin"];
296
- let foundNodeModules = false;
297
- for (const segment of binPath.split(external_path_.sep).reverse()) {
298
- skip_segment: {
299
- if (foundNodeModules) {
300
- break skip_segment;
301
- }
302
- if (segment === "node_modules") {
303
- foundNodeModules = true;
304
- break skip_segment;
305
- }
306
- continue;
307
- }
308
- segments.unshift(segment);
309
- }
310
- return segments.join(external_path_.sep);
311
- })();
315
+ const nodeModulesBinDirPath = (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)();
312
316
  if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
313
317
  return { hasBeenHandled: false };
314
318
  }
@@ -347,24 +351,63 @@ function kebabCaseToCamelCase(kebabCaseString) {
347
351
 
348
352
  /***/ }),
349
353
 
350
- /***/ 22577:
354
+ /***/ 73776:
351
355
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
352
356
 
353
357
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
354
- /* harmony export */ "S": () => (/* binding */ runFormat)
358
+ /* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
355
359
  /* harmony export */ });
356
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
357
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
360
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
361
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
362
+
363
+ let cache = undefined;
364
+ function getNodeModulesBinDirPath() {
365
+ if (cache !== undefined) {
366
+ return cache;
367
+ }
368
+ const binPath = process.argv[1];
369
+ const segments = [".bin"];
370
+ let foundNodeModules = false;
371
+ for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
372
+ skip_segment: {
373
+ if (foundNodeModules) {
374
+ break skip_segment;
375
+ }
376
+ if (segment === "node_modules") {
377
+ foundNodeModules = true;
378
+ break skip_segment;
379
+ }
380
+ continue;
381
+ }
382
+ segments.unshift(segment);
383
+ }
384
+ const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
385
+ cache = nodeModulesBinDirPath;
386
+ return nodeModulesBinDirPath;
387
+ }
388
+ //# sourceMappingURL=nodeModulesBinDirPath.js.map
389
+
390
+ /***/ }),
391
+
392
+ /***/ 48433:
393
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
394
+
395
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
396
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
397
+ /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
398
+ /* harmony export */ "eY": () => (/* binding */ runPrettier)
399
+ /* harmony export */ });
400
+ /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
358
401
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
359
402
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
360
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29041);
361
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(78818);
362
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_3__);
363
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
364
- /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(52300);
365
- /* harmony import */ var tsafe_is__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(16453);
366
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(32081);
367
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_5__);
403
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
404
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
405
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38469);
406
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
407
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
408
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
409
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
410
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
368
411
 
369
412
 
370
413
 
@@ -372,47 +415,62 @@ function kebabCaseToCamelCase(kebabCaseString) {
372
415
 
373
416
 
374
417
 
375
-
376
- function runFormat(params) {
377
- const { packageJsonFilePath } = params;
378
- const parsedPackageJson = (() => {
379
- const zParsedPackageJson = (() => {
380
- const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
381
- scripts: zod__WEBPACK_IMPORTED_MODULE_6__.z.record(zod__WEBPACK_IMPORTED_MODULE_6__.z.string()).optional()
382
- });
383
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .h)();
384
- return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
385
- })();
386
- const parsedPackageJson = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(packageJsonFilePath).toString("utf8"));
387
- zParsedPackageJson.parse(parsedPackageJson);
388
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .h)((0,tsafe_is__WEBPACK_IMPORTED_MODULE_4__.is)(parsedPackageJson));
389
- return parsedPackageJson;
390
- })();
391
- const { scripts } = parsedPackageJson;
392
- if (scripts === undefined) {
393
- return;
418
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(undefined);
419
+ async function getIsPrettierAvailable() {
420
+ var _a;
421
+ if (getIsPrettierAvailable.cache !== undefined) {
422
+ return getIsPrettierAvailable.cache;
394
423
  }
395
- const scriptKeys = Object.keys(scripts);
396
- const scriptNames = scriptKeys.filter(scriptKey => scriptKey.trim().match(/^(lint|format)/));
397
- for (const scriptName of scriptNames) {
398
- if (!(scriptName in scripts)) {
399
- continue;
400
- }
401
- const command = `npm run ${scriptName}`;
402
- console.log(chalk__WEBPACK_IMPORTED_MODULE_3___default().grey(`$ ${command}`));
403
- try {
404
- child_process__WEBPACK_IMPORTED_MODULE_5__.execSync(`npm run ${scriptName}`, {
405
- stdio: "inherit",
406
- cwd: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
407
- });
424
+ const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)();
425
+ const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
426
+ const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
427
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
428
+ getIsPrettierAvailable.cache = isPrettierAvailable;
429
+ return isPrettierAvailable;
430
+ }
431
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(undefined);
432
+ async function getPrettier() {
433
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
434
+ if (getPrettier.cache !== undefined) {
435
+ return getPrettier.cache;
436
+ }
437
+ const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
438
+ const configHash = await (async () => {
439
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
440
+ if (configFilePath === null) {
441
+ return "";
408
442
  }
409
- catch (_a) {
410
- console.log(chalk__WEBPACK_IMPORTED_MODULE_3___default().yellow(`\`${command}\` failed, it does not matter, please format your code manually, continuing...`));
443
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
444
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
445
+ })();
446
+ const prettierAndConfig = {
447
+ prettier,
448
+ configHash
449
+ };
450
+ getPrettier.cache = prettierAndConfig;
451
+ return prettierAndConfig;
452
+ }
453
+ async function runPrettier(params) {
454
+ const { sourceCode, filePath } = params;
455
+ let formattedSourceCode;
456
+ try {
457
+ const { prettier } = await getPrettier();
458
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
459
+ resolveConfig: true
460
+ });
461
+ if (ignored) {
462
+ return sourceCode;
411
463
  }
412
- return;
464
+ const config = await prettier.resolveConfig(filePath);
465
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
466
+ }
467
+ catch (error) {
468
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
469
+ throw error;
413
470
  }
471
+ return formattedSourceCode;
414
472
  }
415
- //# sourceMappingURL=runFormat.js.map
473
+ //# sourceMappingURL=runPrettier.js.map
416
474
 
417
475
  /***/ }),
418
476
 
package/bin/573.index.js CHANGED
@@ -820,19 +820,31 @@ async function generateResources(params) {
820
820
  return (0,external_path_.join)(resourcesDirPath, "theme", themeName, themeType);
821
821
  };
822
822
  const writeMessagePropertiesFilesByThemeType = {};
823
- for (const themeType of ["login", "account"]) {
823
+ for (const themeType of constants/* THEME_TYPES */.Jh) {
824
824
  if (!buildContext.implementedThemeTypes[themeType].isImplemented) {
825
825
  continue;
826
826
  }
827
- const isForAccountSpa = themeType === "account" &&
828
- ((0,assert/* assert */.h)(buildContext.implementedThemeTypes.account.isImplemented),
829
- buildContext.implementedThemeTypes.account.type === "Single-Page");
827
+ const getAccountThemeType = () => {
828
+ (0,assert/* assert */.h)(themeType === "account");
829
+ (0,assert/* assert */.h)(buildContext.implementedThemeTypes.account.isImplemented);
830
+ return buildContext.implementedThemeTypes.account.type;
831
+ };
832
+ const isSpa = (() => {
833
+ switch (themeType) {
834
+ case "login":
835
+ return false;
836
+ case "account":
837
+ return getAccountThemeType() === "Single-Page";
838
+ case "admin":
839
+ return true;
840
+ }
841
+ })();
830
842
  const themeTypeDirPath = getThemeTypeDirPath({ themeName, themeType });
831
843
  apply_replacers_and_move_to_theme_resources: {
832
844
  const destDirPath = (0,external_path_.join)(themeTypeDirPath, "resources", constants/* WELL_KNOWN_DIRECTORY_BASE_NAME.DIST */.Ju.DIST);
833
845
  // NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
834
846
  (0,fs_rmSync/* rmSync */.a)(destDirPath, { recursive: true, force: true });
835
- if (themeType === "account" &&
847
+ if (themeType !== "login" &&
836
848
  buildContext.implementedThemeTypes.login.isImplemented) {
837
849
  // NOTE: We prevent doing it twice, it has been done for the login theme.
838
850
  (0,transformCodebase/* transformCodebase */.N)({
@@ -891,10 +903,13 @@ async function generateResources(params) {
891
903
  buildContext,
892
904
  keycloakifyVersion: (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)(),
893
905
  themeType,
894
- fieldNames: readFieldNameUsage({
895
- themeSrcDirPath: buildContext.themeSrcDirPath,
896
- themeType
897
- })
906
+ fieldNames: isSpa
907
+ ? []
908
+ : ((0,assert/* assert */.h)(themeType !== "admin"),
909
+ readFieldNameUsage({
910
+ themeSrcDirPath: buildContext.themeSrcDirPath,
911
+ themeType
912
+ }))
898
913
  });
899
914
  [
900
915
  ...(() => {
@@ -902,10 +917,14 @@ async function generateResources(params) {
902
917
  case "login":
903
918
  return constants/* LOGIN_THEME_PAGE_IDS */.XV;
904
919
  case "account":
905
- return isForAccountSpa ? ["index.ftl"] : constants/* ACCOUNT_THEME_PAGE_IDS */.yV;
920
+ return getAccountThemeType() === "Single-Page"
921
+ ? ["index.ftl"]
922
+ : constants/* ACCOUNT_THEME_PAGE_IDS */.yV;
923
+ case "admin":
924
+ return ["index.ftl"];
906
925
  }
907
926
  })(),
908
- ...(isForAccountSpa
927
+ ...(isSpa
909
928
  ? []
910
929
  : readExtraPagesNames({
911
930
  themeType,
@@ -917,9 +936,10 @@ async function generateResources(params) {
917
936
  });
918
937
  let languageTags = undefined;
919
938
  i18n_messages_generation: {
920
- if (isForAccountSpa) {
939
+ if (isSpa) {
921
940
  break i18n_messages_generation;
922
941
  }
942
+ (0,assert/* assert */.h)(themeType !== "admin");
923
943
  const wrap = (0,generateMessageProperties/* generateMessageProperties */.k)({
924
944
  buildContext,
925
945
  themeType
@@ -929,14 +949,12 @@ async function generateResources(params) {
929
949
  writeMessagePropertiesFilesByThemeType[themeType] =
930
950
  writeMessagePropertiesFiles;
931
951
  }
932
- bring_in_account_v3_i18n_messages: {
933
- if (!buildContext.implementedThemeTypes.account.isImplemented) {
934
- break bring_in_account_v3_i18n_messages;
935
- }
936
- if (buildContext.implementedThemeTypes.account.type !== "Single-Page") {
937
- break bring_in_account_v3_i18n_messages;
952
+ bring_in_spas_messages: {
953
+ if (!isSpa) {
954
+ break bring_in_spas_messages;
938
955
  }
939
- const accountUiDirPath = external_child_process_.execSync("npm list @keycloakify/keycloak-account-ui --parseable", {
956
+ (0,assert/* assert */.h)(themeType !== "login");
957
+ const accountUiDirPath = external_child_process_.execSync(`npm list @keycloakify/keycloak-${themeType}-ui --parseable`, {
940
958
  cwd: (0,external_path_.dirname)(buildContext.packageJsonFilePath)
941
959
  })
942
960
  .toString("utf8")
@@ -945,13 +963,13 @@ async function generateResources(params) {
945
963
  if (!external_fs_default().existsSync(messageDirPath_defaults)) {
946
964
  throw new Error(`Please update @keycloakify/keycloak-account-ui to 25.0.4-rc.5 or later.`);
947
965
  }
948
- const messagesDirPath_dest = (0,external_path_.join)(getThemeTypeDirPath({ themeName, themeType: "account" }), "messages");
966
+ const messagesDirPath_dest = (0,external_path_.join)(getThemeTypeDirPath({ themeName, themeType }), "messages");
949
967
  (0,transformCodebase/* transformCodebase */.N)({
950
968
  srcDirPath: messageDirPath_defaults,
951
969
  destDirPath: messagesDirPath_dest
952
970
  });
953
971
  apply_theme_changes: {
954
- const messagesDirPath_theme = (0,external_path_.join)(buildContext.themeSrcDirPath, "account", "messages");
972
+ const messagesDirPath_theme = (0,external_path_.join)(buildContext.themeSrcDirPath, themeType, "messages");
955
973
  if (!external_fs_default().existsSync(messagesDirPath_theme)) {
956
974
  break apply_theme_changes;
957
975
  }
@@ -975,7 +993,7 @@ async function generateResources(params) {
975
993
  .map(basename => basename.replace(/^messages_/, "").replace(/\.properties$/, ""));
976
994
  }
977
995
  keycloak_static_resources: {
978
- if (isForAccountSpa) {
996
+ if (isSpa) {
979
997
  break keycloak_static_resources;
980
998
  }
981
999
  (0,transformCodebase/* transformCodebase */.N)({
@@ -987,13 +1005,22 @@ async function generateResources(params) {
987
1005
  `parent=${(() => {
988
1006
  switch (themeType) {
989
1007
  case "account":
990
- return isForAccountSpa ? "base" : "account-v1";
1008
+ switch (getAccountThemeType()) {
1009
+ case "Multi-Page":
1010
+ return "account-v1";
1011
+ case "Single-Page":
1012
+ return "base";
1013
+ }
991
1014
  case "login":
992
1015
  return "keycloak";
1016
+ case "admin":
1017
+ return "base";
993
1018
  }
994
1019
  (0,assert/* assert */.h)(false);
995
1020
  })()}`,
996
- ...(isForAccountSpa ? ["deprecatedMode=false"] : []),
1021
+ ...(themeType === "account" && getAccountThemeType() === "Single-Page"
1022
+ ? ["deprecatedMode=false"]
1023
+ : []),
997
1024
  ...((_a = buildContext.extraThemeProperties) !== null && _a !== void 0 ? _a : []),
998
1025
  ...buildContext.environmentVariables.map(({ name, default: defaultValue }) => `${name}=\${env.${name}:${(0,escapeStringForPropertiesFile/* escapeStringForPropertiesFile */.y)(defaultValue)}}`),
999
1026
  ...(languageTags === undefined