@keycloakify/angular 0.2.2 → 0.2.3

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.
@@ -0,0 +1,306 @@
1
+ export const id = 942;
2
+ export const ids = [942];
3
+ export const modules = {
4
+
5
+ /***/ 942:
6
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7
+
8
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
+ /* harmony export */ command: () => (/* binding */ command)
10
+ /* harmony export */ });
11
+ /* harmony import */ var _tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(221);
12
+ /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(546);
13
+ /* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cli_select__WEBPACK_IMPORTED_MODULE_0__);
14
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(896);
15
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
16
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(928);
17
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
18
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
19
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(797);
20
+ /* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(915);
21
+ /* harmony import */ var _core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(316);
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ async function command(params) {
31
+ const { buildContext } = params;
32
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.cyan('Theme type:'));
33
+ const themeType = await (async () => {
34
+ const values = _core__WEBPACK_IMPORTED_MODULE_5__/* .THEME_TYPES */ .qA.filter(themeType => {
35
+ switch (themeType) {
36
+ case 'account':
37
+ return buildContext.implementedThemeTypes.account.isImplemented;
38
+ case 'login':
39
+ return buildContext.implementedThemeTypes.login.isImplemented;
40
+ }
41
+ // @ts-ignore
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
+ // @ts-ignore
66
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(false);
67
+ })()
68
+ }).catch(() => {
69
+ process.exit(-1);
70
+ });
71
+ console.log(`→ ${pageId}`);
72
+ const componentBasename = pageId.replace(/ftl$/, 'stories.ts');
73
+ const targetFilePath = (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.themeSrcDirPath, themeType, 'pages', pageId.replace(/\.ftl$/, ''), componentBasename);
74
+ if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(targetFilePath)) {
75
+ console.log(`${(0,path__WEBPACK_IMPORTED_MODULE_2__.relative)(process.cwd(), targetFilePath)} already exists`);
76
+ process.exit(-1);
77
+ }
78
+ 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))
79
+ .toString('utf8')
80
+ .replace(/["']\.\.\/KcPageStory["']/, "'../../KcPageStory'");
81
+ run_prettier: {
82
+ if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__/* .getIsPrettierAvailable */ .L)())) {
83
+ break run_prettier;
84
+ }
85
+ sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__/* .runPrettier */ .JS)({
86
+ filePath: targetFilePath,
87
+ sourceCode: sourceCode
88
+ });
89
+ }
90
+ {
91
+ const targetDirPath = (0,path__WEBPACK_IMPORTED_MODULE_2__.dirname)(targetFilePath);
92
+ if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(targetDirPath)) {
93
+ fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(targetDirPath, { recursive: true });
94
+ }
95
+ }
96
+ fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(targetFilePath, Buffer.from(sourceCode, 'utf8'));
97
+ console.log([
98
+ `${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`,
99
+ `You can start storybook with ${chalk__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.bold('npm run storybook')}`
100
+ ].join('\n'));
101
+ }
102
+
103
+
104
+ /***/ }),
105
+
106
+ /***/ 221:
107
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
108
+
109
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
110
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
111
+ /* harmony export */ });
112
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
113
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
114
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
115
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
116
+
117
+
118
+ function getThisCodebaseRootDirPath_rec(dirPath) {
119
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
120
+ return dirPath;
121
+ }
122
+ return getThisCodebaseRootDirPath_rec(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
123
+ }
124
+ let result = undefined;
125
+ function getThisCodebaseRootDirPath() {
126
+ if (result !== undefined) {
127
+ return result;
128
+ }
129
+ return (result = getThisCodebaseRootDirPath_rec(__dirname));
130
+ }
131
+
132
+
133
+ /***/ }),
134
+
135
+ /***/ 395:
136
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
137
+
138
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
139
+ /* harmony export */ p: () => (/* binding */ getNodeModulesBinDirPath)
140
+ /* harmony export */ });
141
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
142
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
143
+
144
+ let cache = undefined;
145
+ function getNodeModulesBinDirPath() {
146
+ if (cache !== undefined) {
147
+ return cache;
148
+ }
149
+ const binPath = process.argv[1];
150
+ const segments = ['.bin'];
151
+ let foundNodeModules = false;
152
+ for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
153
+ skip_segment: {
154
+ if (foundNodeModules) {
155
+ break skip_segment;
156
+ }
157
+ if (segment === 'node_modules') {
158
+ foundNodeModules = true;
159
+ break skip_segment;
160
+ }
161
+ continue;
162
+ }
163
+ segments.unshift(segment);
164
+ }
165
+ const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
166
+ cache = nodeModulesBinDirPath;
167
+ return nodeModulesBinDirPath;
168
+ }
169
+
170
+
171
+ /***/ }),
172
+
173
+ /***/ 972:
174
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
175
+
176
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
177
+ /* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
178
+ /* harmony export */ });
179
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(221);
180
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(966);
181
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(896);
182
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
183
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(928);
184
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
185
+
186
+
187
+
188
+
189
+ let cache = undefined;
190
+ function readThisNpmPackageVersion() {
191
+ if (cache !== undefined) {
192
+ return cache;
193
+ }
194
+ const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_2__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_3__/* .getThisCodebaseRootDirPath */ .J)(), 'package.json'))
195
+ .toString('utf8'))['version'];
196
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(typeof version === 'string');
197
+ cache = version;
198
+ return version;
199
+ }
200
+
201
+
202
+ /***/ }),
203
+
204
+ /***/ 915:
205
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
206
+
207
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
208
+ /* harmony export */ JS: () => (/* binding */ runPrettier),
209
+ /* harmony export */ L: () => (/* binding */ getIsPrettierAvailable)
210
+ /* harmony export */ });
211
+ /* unused harmony export getPrettier */
212
+ /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(395);
213
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
214
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
215
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(943);
216
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
217
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(94);
218
+ /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
219
+ /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(797);
220
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(982);
221
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_3__);
222
+ /* harmony import */ var tsafe_is__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(289);
223
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
224
+ /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(972);
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
236
+ async function getIsPrettierAvailable() {
237
+ var _a;
238
+ if (getIsPrettierAvailable.cache !== undefined) {
239
+ return getIsPrettierAvailable.cache;
240
+ }
241
+ const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getNodeModulesBinDirPath */ .p)();
242
+ const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(nodeModulesBinDirPath, 'prettier');
243
+ const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.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
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
249
+ async function getPrettier() {
250
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)(getIsPrettierAvailable());
251
+ if (getPrettier.cache !== undefined) {
252
+ return getPrettier.cache;
253
+ }
254
+ let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
255
+ import_prettier: {
256
+ // NOTE: When module is linked we want to make sure we import the correct version
257
+ // of prettier, that is the one of the project, not the one of this repo.
258
+ // So we do a sketchy eval to bypass ncc.
259
+ // We make sure to only do that when linking, otherwise we import properly.
260
+ if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
261
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .I)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_0__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'))}")`);
262
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)(!(0,tsafe_is__WEBPACK_IMPORTED_MODULE_4__.is)(prettier));
263
+ break import_prettier;
264
+ }
265
+ prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 166));
266
+ }
267
+ const configHash = await (async () => {
268
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getNodeModulesBinDirPath */ .p)(), '..'));
269
+ if (configFilePath === null) {
270
+ return '';
271
+ }
272
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile(configFilePath);
273
+ return crypto__WEBPACK_IMPORTED_MODULE_3__.createHash('sha256').update(data).digest('hex');
274
+ })();
275
+ const prettierAndConfig = {
276
+ prettier,
277
+ configHash
278
+ };
279
+ getPrettier.cache = prettierAndConfig;
280
+ return prettierAndConfig;
281
+ }
282
+ async function runPrettier(params) {
283
+ const { sourceCode, filePath } = params;
284
+ let formattedSourceCode;
285
+ try {
286
+ const { prettier } = await getPrettier();
287
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
288
+ resolveConfig: true
289
+ });
290
+ if (ignored) {
291
+ return sourceCode;
292
+ }
293
+ const config = await prettier.resolveConfig(filePath);
294
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
295
+ }
296
+ catch (error) {
297
+ console.log(chalk__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Ay.red(`You probably need to upgrade the version of prettier in your project`));
298
+ throw error;
299
+ }
300
+ return formattedSourceCode;
301
+ }
302
+
303
+
304
+ /***/ })
305
+
306
+ };