@keycloakify/angular 0.0.11 → 0.1.0

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 (60) hide show
  1. package/bin/108.index.js +242 -0
  2. package/bin/338.index.js +104 -54
  3. package/bin/402.index.js +1250 -0
  4. package/bin/758.index.js +777 -53
  5. package/bin/{925.index.js → 84.index.js} +124 -624
  6. package/bin/main.js +59 -4
  7. package/package.json +1 -1
  8. package/src/bin/add-story.ts +126 -0
  9. package/src/bin/eject-page.ts +49 -11
  10. package/src/bin/main.ts +2 -4
  11. package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
  12. package/src/bin/tools/runPrettier.ts +89 -0
  13. package/src/bin/tools/transformCodebase_async.ts +89 -0
  14. package/src/bin/update-kc-gen.ts +20 -15
  15. package/stories/account/pages/account.stories.ts +133 -0
  16. package/stories/account/pages/applications.stories.ts +196 -0
  17. package/stories/account/pages/federated-identity.stories.ts +78 -0
  18. package/stories/account/pages/log.stories.ts +147 -0
  19. package/stories/account/pages/password.stories.ts +104 -0
  20. package/stories/account/pages/sessions.stories.ts +143 -0
  21. package/stories/account/pages/totp.stories.ts +100 -0
  22. package/stories/login/pages/code.stories.ts +51 -0
  23. package/stories/login/pages/delete-account-confirm.stories.ts +43 -0
  24. package/stories/login/pages/delete-credential.stories.ts +56 -0
  25. package/stories/login/pages/error.stories.ts +56 -0
  26. package/stories/login/pages/frontchannel-logout.stories.ts +26 -0
  27. package/stories/login/pages/idp-review-user-profile.stories.ts +60 -0
  28. package/stories/login/pages/info.stories.ts +94 -0
  29. package/stories/login/pages/login-config-totp.stories.ts +57 -0
  30. package/stories/login/pages/login-device-verify-user-code.stories.ts +14 -0
  31. package/stories/login/pages/login-idp-link-confirm-override.stories.ts +17 -0
  32. package/stories/login/pages/login-idp-link-confirm.stories.ts +103 -0
  33. package/stories/login/pages/login-idp-link-email.stories.ts +102 -0
  34. package/stories/login/pages/login-oauth-grant.stories.ts +68 -0
  35. package/stories/login/pages/login-oauth2-device-verify-user-code.stories.ts +15 -0
  36. package/stories/login/pages/login-otp.stories.ts +94 -0
  37. package/stories/login/pages/login-page-expired.stories.ts +31 -0
  38. package/stories/login/pages/login-passkeys-conditional-authenticate.stories.ts +16 -0
  39. package/stories/login/pages/login-password.stories.ts +52 -0
  40. package/stories/login/pages/login-recovery-authn-code-config.stories.ts +31 -0
  41. package/stories/login/pages/login-recovery-authn-code-input.stories.ts +16 -0
  42. package/stories/login/pages/login-reset-otp.stories.ts +71 -0
  43. package/stories/login/pages/login-reset-password.stories.ts +50 -0
  44. package/stories/login/pages/login-update-password.stories.ts +46 -0
  45. package/stories/login/pages/login-update-profile.stories.ts +31 -0
  46. package/stories/login/pages/login-username.stories.ts +28 -0
  47. package/stories/login/pages/login-verify-email.stories.ts +98 -0
  48. package/stories/login/pages/login-x509-info.stories.ts +40 -0
  49. package/stories/login/pages/login.stories.ts +260 -0
  50. package/stories/login/pages/logout-confirm.stories.ts +44 -0
  51. package/stories/login/pages/register.stories.ts +230 -0
  52. package/stories/login/pages/saml-post-form.stories.ts +17 -0
  53. package/stories/login/pages/select-authenticator.stories.ts +95 -0
  54. package/stories/login/pages/terms.stories.ts +79 -0
  55. package/stories/login/pages/update-email.stories.ts +31 -0
  56. package/stories/login/pages/webauthn-authenticate.stories.ts +126 -0
  57. package/stories/login/pages/webauthn-error.stories.ts +62 -0
  58. package/stories/login/pages/webauthn-register.stories.ts +46 -0
  59. package/src/bin/tools/runFormat.ts +0 -71
  60. package/src/stories/login/pages/login/login.stories.ts +0 -146
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ exports.id = 108;
3
+ exports.ids = [108];
4
+ exports.modules = {
5
+
6
+ /***/ 108:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
+ /* harmony export */ command: () => (/* binding */ command)
11
+ /* harmony export */ });
12
+ /* harmony import */ var _tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(427);
13
+ /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(546);
14
+ /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cli_select__WEBPACK_IMPORTED_MODULE_0__);
15
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(896);
16
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
17
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(928);
18
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
19
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
20
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(797);
21
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(199);
22
+ /* harmony import */ var _core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(316);
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ async function command(params) {
32
+ const { buildContext } = params;
33
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.cyan('Theme type:'));
34
+ const themeType = await (async () => {
35
+ const values = _core__WEBPACK_IMPORTED_MODULE_5__/* .THEME_TYPES */ .qA.filter(themeType => {
36
+ switch (themeType) {
37
+ case 'account':
38
+ return buildContext.implementedThemeTypes.account.isImplemented;
39
+ case 'login':
40
+ return buildContext.implementedThemeTypes.login.isImplemented;
41
+ }
42
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(false);
43
+ });
44
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(values.length > 0, 'No theme is implemented in this project');
45
+ if (values.length === 1) {
46
+ return values[0];
47
+ }
48
+ const { value } = await cli_select__WEBPACK_IMPORTED_MODULE_0___default()({
49
+ values
50
+ }).catch(() => {
51
+ process.exit(-1);
52
+ });
53
+ return value;
54
+ })();
55
+ console.log(`→ ${themeType}`);
56
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.cyan('Select the page you want to create a Storybook for:'));
57
+ const { value: pageId } = await cli_select__WEBPACK_IMPORTED_MODULE_0___default()({
58
+ values: (() => {
59
+ switch (themeType) {
60
+ case 'login':
61
+ return [..._core__WEBPACK_IMPORTED_MODULE_5__/* .LOGIN_THEME_PAGE_IDS */ .hz];
62
+ case 'account':
63
+ return [..._core__WEBPACK_IMPORTED_MODULE_5__/* .ACCOUNT_THEME_PAGE_IDS */ .Hp];
64
+ }
65
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(false);
66
+ })()
67
+ }).catch(() => {
68
+ process.exit(-1);
69
+ });
70
+ console.log(`→ ${pageId}`);
71
+ const componentBasename = pageId.replace(/ftl$/, 'stories.ts');
72
+ const targetFilePath = (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.themeSrcDirPath, themeType, 'pages', pageId.replace(/\.ftl$/, ''), componentBasename);
73
+ if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(targetFilePath)) {
74
+ console.log(`${(0,path__WEBPACK_IMPORTED_MODULE_2__.relative)(process.cwd(), targetFilePath)} already exists`);
75
+ process.exit(-1);
76
+ }
77
+ let sourceCode = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_2__.join)((0,_tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getThisCodebaseRootDirPath */ .J)(), 'stories', themeType, 'pages', componentBasename))
78
+ .toString('utf8')
79
+ .replace(/["']\.\.\/KcPageStory["']/, "'../../KcPageStory'");
80
+ run_prettier: {
81
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__/* .getIsPrettierAvailable */ .L)())) {
82
+ break run_prettier;
83
+ }
84
+ sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__/* .runPrettier */ .JS)({
85
+ filePath: targetFilePath,
86
+ sourceCode: sourceCode
87
+ });
88
+ }
89
+ {
90
+ const targetDirPath = (0,path__WEBPACK_IMPORTED_MODULE_2__.dirname)(targetFilePath);
91
+ if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(targetDirPath)) {
92
+ fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(targetDirPath, { recursive: true });
93
+ }
94
+ }
95
+ fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(targetFilePath, Buffer.from(sourceCode, 'utf8'));
96
+ console.log([
97
+ `${chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.green('✓')} ${chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.bold((0,path__WEBPACK_IMPORTED_MODULE_2__.join)('.', (0,path__WEBPACK_IMPORTED_MODULE_2__.relative)(process.cwd(), targetFilePath)))} copy pasted from the Keycloakify source code into your project`,
98
+ `You can start storybook with ${chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.bold('npm run storybook')}`
99
+ ].join('\n'));
100
+ }
101
+
102
+
103
+ /***/ }),
104
+
105
+ /***/ 427:
106
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
107
+
108
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
109
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
110
+ /* harmony export */ });
111
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
112
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
113
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
114
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
115
+
116
+
117
+ function getThisCodebaseRootDirPath_rec(dirPath) {
118
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
119
+ return dirPath;
120
+ }
121
+ return getThisCodebaseRootDirPath_rec(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
122
+ }
123
+ let result = undefined;
124
+ function getThisCodebaseRootDirPath() {
125
+ if (result !== undefined) {
126
+ return result;
127
+ }
128
+ return (result = getThisCodebaseRootDirPath_rec(__dirname));
129
+ }
130
+
131
+
132
+ /***/ }),
133
+
134
+ /***/ 199:
135
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
136
+
137
+
138
+ // EXPORTS
139
+ __webpack_require__.d(__webpack_exports__, {
140
+ L: () => (/* binding */ getIsPrettierAvailable),
141
+ JS: () => (/* binding */ runPrettier)
142
+ });
143
+
144
+ // UNUSED EXPORTS: getPrettierAndConfig
145
+
146
+ // EXTERNAL MODULE: external "path"
147
+ var external_path_ = __webpack_require__(928);
148
+ ;// CONCATENATED MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
149
+
150
+ let cache = undefined;
151
+ function getNodeModulesBinDirPath() {
152
+ if (cache !== undefined) {
153
+ return cache;
154
+ }
155
+ const binPath = process.argv[1];
156
+ const segments = ['.bin'];
157
+ let foundNodeModules = false;
158
+ for (const segment of binPath.split(external_path_.sep).reverse()) {
159
+ skip_segment: {
160
+ if (foundNodeModules) {
161
+ break skip_segment;
162
+ }
163
+ if (segment === 'node_modules') {
164
+ foundNodeModules = true;
165
+ break skip_segment;
166
+ }
167
+ continue;
168
+ }
169
+ segments.unshift(segment);
170
+ }
171
+ const nodeModulesBinDirPath = segments.join(external_path_.sep);
172
+ cache = nodeModulesBinDirPath;
173
+ return nodeModulesBinDirPath;
174
+ }
175
+
176
+ // EXTERNAL MODULE: external "fs/promises"
177
+ var promises_ = __webpack_require__(943);
178
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
179
+ var id = __webpack_require__(94);
180
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
181
+ var assert = __webpack_require__(966);
182
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js + 3 modules
183
+ var source = __webpack_require__(797);
184
+ ;// CONCATENATED MODULE: ./dist/bin/tools/runPrettier.js
185
+
186
+
187
+
188
+
189
+
190
+
191
+ getIsPrettierAvailable.cache = (0,id.id)(undefined);
192
+ async function getIsPrettierAvailable() {
193
+ var _a;
194
+ if (getIsPrettierAvailable.cache !== undefined) {
195
+ return getIsPrettierAvailable.cache;
196
+ }
197
+ const nodeModulesBinDirPath = getNodeModulesBinDirPath();
198
+ const prettierBinPath = (0,external_path_.join)(nodeModulesBinDirPath, 'prettier');
199
+ const stats = await promises_.stat(prettierBinPath).catch(() => undefined);
200
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
201
+ getIsPrettierAvailable.cache = isPrettierAvailable;
202
+ return isPrettierAvailable;
203
+ }
204
+ getPrettierAndConfig.cache = (0,id.id)(undefined);
205
+ async function getPrettierAndConfig() {
206
+ (0,assert/* assert */.v)(getIsPrettierAvailable());
207
+ if (getPrettierAndConfig.cache !== undefined) {
208
+ return getPrettierAndConfig.cache;
209
+ }
210
+ const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 824, 23));
211
+ const prettierAndConfig = {
212
+ prettier,
213
+ config: await prettier.resolveConfig((0,external_path_.join)(getNodeModulesBinDirPath(), '..'))
214
+ };
215
+ getPrettierAndConfig.cache = prettierAndConfig;
216
+ return prettierAndConfig;
217
+ }
218
+ async function runPrettier(params) {
219
+ const { sourceCode, filePath } = params;
220
+ let formattedSourceCode;
221
+ try {
222
+ const { prettier, config } = await getPrettierAndConfig();
223
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
224
+ resolveConfig: true
225
+ });
226
+ if (ignored) {
227
+ return sourceCode;
228
+ }
229
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
230
+ }
231
+ catch (error) {
232
+ console.log(source/* default */.Ay.red(`You probably need to upgrade the version of prettier in your project`));
233
+ throw error;
234
+ }
235
+ return formattedSourceCode;
236
+ }
237
+
238
+
239
+ /***/ })
240
+
241
+ };
242
+ ;
package/bin/338.index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.id = 338;
3
- exports.ids = [338,758];
3
+ exports.ids = [338];
4
4
  exports.modules = {
5
5
 
6
6
  /***/ 338:
@@ -175,67 +175,108 @@ function getThisCodebaseRootDirPath() {
175
175
 
176
176
  /***/ }),
177
177
 
178
- /***/ 49:
178
+ /***/ 199:
179
179
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
180
180
 
181
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
182
- /* harmony export */ J: () => (/* binding */ runFormat)
183
- /* harmony export */ });
184
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
185
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
186
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
187
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
188
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
189
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(797);
190
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(94);
191
- /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(383);
192
- /* harmony import */ var tsafe_is__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(289);
193
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(317);
194
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_4__);
195
181
 
182
+ // EXPORTS
183
+ __webpack_require__.d(__webpack_exports__, {
184
+ L: () => (/* binding */ getIsPrettierAvailable),
185
+ JS: () => (/* binding */ runPrettier)
186
+ });
187
+
188
+ // UNUSED EXPORTS: getPrettierAndConfig
189
+
190
+ // EXTERNAL MODULE: external "path"
191
+ var external_path_ = __webpack_require__(928);
192
+ ;// CONCATENATED MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
193
+
194
+ let cache = undefined;
195
+ function getNodeModulesBinDirPath() {
196
+ if (cache !== undefined) {
197
+ return cache;
198
+ }
199
+ const binPath = process.argv[1];
200
+ const segments = ['.bin'];
201
+ let foundNodeModules = false;
202
+ for (const segment of binPath.split(external_path_.sep).reverse()) {
203
+ skip_segment: {
204
+ if (foundNodeModules) {
205
+ break skip_segment;
206
+ }
207
+ if (segment === 'node_modules') {
208
+ foundNodeModules = true;
209
+ break skip_segment;
210
+ }
211
+ continue;
212
+ }
213
+ segments.unshift(segment);
214
+ }
215
+ const nodeModulesBinDirPath = segments.join(external_path_.sep);
216
+ cache = nodeModulesBinDirPath;
217
+ return nodeModulesBinDirPath;
218
+ }
196
219
 
220
+ // EXTERNAL MODULE: external "fs/promises"
221
+ var promises_ = __webpack_require__(943);
222
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
223
+ var id = __webpack_require__(94);
224
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
225
+ var assert = __webpack_require__(966);
226
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js + 3 modules
227
+ var source = __webpack_require__(797);
228
+ ;// CONCATENATED MODULE: ./dist/bin/tools/runPrettier.js
197
229
 
198
230
 
199
231
 
200
232
 
201
233
 
202
234
 
203
- function runFormat(params) {
204
- const { packageJsonFilePath } = params;
205
- const parsedPackageJson = (() => {
206
- const zParsedPackageJson = (() => {
207
- const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
208
- scripts: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
209
- });
210
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)();
211
- return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
212
- })();
213
- const parsedPackageJson = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(packageJsonFilePath).toString('utf8'));
214
- zParsedPackageJson.parse(parsedPackageJson);
215
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)((0,tsafe_is__WEBPACK_IMPORTED_MODULE_3__.is)(parsedPackageJson));
216
- return parsedPackageJson;
217
- })();
218
- const { scripts } = parsedPackageJson;
219
- if (scripts === undefined) {
220
- return;
235
+ getIsPrettierAvailable.cache = (0,id.id)(undefined);
236
+ async function getIsPrettierAvailable() {
237
+ var _a;
238
+ if (getIsPrettierAvailable.cache !== undefined) {
239
+ return getIsPrettierAvailable.cache;
221
240
  }
222
- for (const scriptName of ['format', 'lint']) {
223
- if (!(scriptName in scripts)) {
224
- continue;
225
- }
226
- const command = `npm run ${scriptName}`;
227
- console.log(chalk__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Ay.grey(`$ ${command}`));
228
- try {
229
- child_process__WEBPACK_IMPORTED_MODULE_4__.execSync(`npm run ${scriptName}`, {
230
- stdio: 'inherit',
231
- cwd: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
232
- });
233
- }
234
- catch (_a) {
235
- console.log(chalk__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Ay.yellow(`\`${command}\` failed, please format your code manually, continuing...`));
241
+ const nodeModulesBinDirPath = getNodeModulesBinDirPath();
242
+ const prettierBinPath = (0,external_path_.join)(nodeModulesBinDirPath, 'prettier');
243
+ const stats = await promises_.stat(prettierBinPath).catch(() => undefined);
244
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
245
+ getIsPrettierAvailable.cache = isPrettierAvailable;
246
+ return isPrettierAvailable;
247
+ }
248
+ getPrettierAndConfig.cache = (0,id.id)(undefined);
249
+ async function getPrettierAndConfig() {
250
+ (0,assert/* assert */.v)(getIsPrettierAvailable());
251
+ if (getPrettierAndConfig.cache !== undefined) {
252
+ return getPrettierAndConfig.cache;
253
+ }
254
+ const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 824, 23));
255
+ const prettierAndConfig = {
256
+ prettier,
257
+ config: await prettier.resolveConfig((0,external_path_.join)(getNodeModulesBinDirPath(), '..'))
258
+ };
259
+ getPrettierAndConfig.cache = prettierAndConfig;
260
+ return prettierAndConfig;
261
+ }
262
+ async function runPrettier(params) {
263
+ const { sourceCode, filePath } = params;
264
+ let formattedSourceCode;
265
+ try {
266
+ const { prettier, config } = await getPrettierAndConfig();
267
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
268
+ resolveConfig: true
269
+ });
270
+ if (ignored) {
271
+ return sourceCode;
236
272
  }
237
- return;
273
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
238
274
  }
275
+ catch (error) {
276
+ console.log(source/* default */.Ay.red(`You probably need to upgrade the version of prettier in your project`));
277
+ throw error;
278
+ }
279
+ return formattedSourceCode;
239
280
  }
240
281
 
241
282
 
@@ -251,14 +292,14 @@ function runFormat(params) {
251
292
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
252
293
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
253
294
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
254
- /* harmony import */ var _tools_runFormat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(49);
295
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(199);
255
296
  /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(982);
256
297
  /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_2__);
257
298
 
258
299
 
259
300
 
260
301
 
261
- function command(params) {
302
+ async function command(params) {
262
303
  const { buildContext } = params;
263
304
  const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, 'kc.gen.ts');
264
305
  const implementedThemeTypes = ['login', 'account'].filter(themeType => buildContext.implementedThemeTypes[themeType].isImplemented);
@@ -380,13 +421,22 @@ function command(params) {
380
421
  }
381
422
  return;
382
423
  }
383
- fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(filePath, Buffer.from([
424
+ let sourceCode = [
384
425
  `// This file is auto-generated by keycloakify. Do not edit it manually.`,
385
426
  `// Hash: ${hash}`,
386
427
  ``,
387
428
  newContent
388
- ].join('\n'), 'utf8'));
389
- (0,_tools_runFormat__WEBPACK_IMPORTED_MODULE_3__/* .runFormat */ .J)({ packageJsonFilePath: buildContext.packageJsonFilePath });
429
+ ].join('\n');
430
+ run_prettier: {
431
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_3__/* .getIsPrettierAvailable */ .L)())) {
432
+ break run_prettier;
433
+ }
434
+ sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_3__/* .runPrettier */ .JS)({
435
+ filePath,
436
+ sourceCode
437
+ });
438
+ }
439
+ fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(filePath, Buffer.from(sourceCode, 'utf8'));
390
440
  }
391
441
 
392
442