@keycloakify/angular 0.2.1 → 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.
- package/bin/187.index.js +508 -0
- package/bin/476.index.js +1085 -0
- package/bin/671.index.js +719 -0
- package/bin/811.index.js +4972 -0
- package/bin/942.index.js +306 -0
- package/bin/986.index.js +1294 -0
- package/bin/index.js +479 -0
- package/package.json +2 -2
- package/src/bin/core.ts +8 -4
- package/src/bin/tsconfig.json +4 -1
- package/bin/197.index.js +0 -13
- package/bin/381.index.js +0 -13
- package/bin/504.index.js +0 -13
- package/bin/87.index.js +0 -13
- package/bin/main.js +0 -230
- package/stories/login/pages/login-device-verify-user-code.stories.ts +0 -14
package/bin/671.index.js
ADDED
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
export const id = 671;
|
|
2
|
+
export const ids = [671];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 671:
|
|
6
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
command: () => (/* binding */ command)
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// EXTERNAL MODULE: ./dist/bin/tools/getThisCodebaseRootDirPath.ts
|
|
15
|
+
var getThisCodebaseRootDirPath = __webpack_require__(221);
|
|
16
|
+
// EXTERNAL MODULE: ./node_modules/cli-select/dist/index.js
|
|
17
|
+
var dist = __webpack_require__(546);
|
|
18
|
+
var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
|
|
19
|
+
// EXTERNAL MODULE: ./node_modules/keycloakify/bin/shared/constants.js
|
|
20
|
+
var constants = __webpack_require__(316);
|
|
21
|
+
// EXTERNAL MODULE: external "fs"
|
|
22
|
+
var external_fs_ = __webpack_require__(896);
|
|
23
|
+
// EXTERNAL MODULE: external "path"
|
|
24
|
+
var external_path_ = __webpack_require__(928);
|
|
25
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
|
26
|
+
var assert = __webpack_require__(966);
|
|
27
|
+
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js + 3 modules
|
|
28
|
+
var source = __webpack_require__(797);
|
|
29
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/crawl.ts
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const crawlRec = (dirPath, filePaths) => {
|
|
33
|
+
for (const basename of external_fs_.readdirSync(dirPath)) {
|
|
34
|
+
const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
|
|
35
|
+
if (external_fs_.lstatSync(fileOrDirPath).isDirectory()) {
|
|
36
|
+
crawlRec(fileOrDirPath, filePaths);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
filePaths.push(fileOrDirPath);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** List all files in a given directory return paths relative to the dir_path */
|
|
43
|
+
function crawl(params) {
|
|
44
|
+
const { dirPath, returnedPathsType } = params;
|
|
45
|
+
const filePaths = [];
|
|
46
|
+
crawlRec(dirPath, filePaths);
|
|
47
|
+
switch (returnedPathsType) {
|
|
48
|
+
case 'absolute':
|
|
49
|
+
return filePaths;
|
|
50
|
+
case 'relative to dirPath':
|
|
51
|
+
return filePaths.map(filePath => (0,external_path_.relative)(dirPath, filePath));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/SemVer.ts
|
|
56
|
+
var SemVer;
|
|
57
|
+
(function (SemVer) {
|
|
58
|
+
const bumpTypes = ['major', 'minor', 'patch', 'rc', 'no bump'];
|
|
59
|
+
function parse(versionStr) {
|
|
60
|
+
const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
|
|
61
|
+
if (!match) {
|
|
62
|
+
throw new Error(`${versionStr} is not a valid semantic version`);
|
|
63
|
+
}
|
|
64
|
+
const semVer = Object.assign({ major: parseInt(match[1]), minor: parseInt(match[2]), patch: (() => {
|
|
65
|
+
const str = match[3];
|
|
66
|
+
return str === undefined ? 0 : parseInt(str);
|
|
67
|
+
})() }, (() => {
|
|
68
|
+
const str = match[4];
|
|
69
|
+
return str === undefined ? {} : { rc: parseInt(str) };
|
|
70
|
+
})());
|
|
71
|
+
const initialStr = stringify(semVer);
|
|
72
|
+
Object.defineProperty(semVer, 'parsedFrom', {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
const currentStr = stringify(this);
|
|
76
|
+
if (currentStr !== initialStr) {
|
|
77
|
+
throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
|
|
78
|
+
}
|
|
79
|
+
return versionStr;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return semVer;
|
|
83
|
+
}
|
|
84
|
+
SemVer.parse = parse;
|
|
85
|
+
function stringify(v) {
|
|
86
|
+
return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? '' : `-rc.${v.rc}`}`;
|
|
87
|
+
}
|
|
88
|
+
SemVer.stringify = stringify;
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* v1 < v2 => -1
|
|
92
|
+
* v1 === v2 => 0
|
|
93
|
+
* v1 > v2 => 1
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
function compare(v1, v2) {
|
|
97
|
+
const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
|
|
98
|
+
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
|
|
99
|
+
for (const level of ['major', 'minor', 'patch', 'rc']) {
|
|
100
|
+
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
|
101
|
+
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
SemVer.compare = compare;
|
|
107
|
+
/*
|
|
108
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
|
|
109
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
|
|
110
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
|
|
111
|
+
*/
|
|
112
|
+
function bumpType(params) {
|
|
113
|
+
const versionAhead = typeof params.versionAhead === 'string'
|
|
114
|
+
? parse(params.versionAhead)
|
|
115
|
+
: params.versionAhead;
|
|
116
|
+
const versionBehind = typeof params.versionBehind === 'string'
|
|
117
|
+
? parse(params.versionBehind)
|
|
118
|
+
: params.versionBehind;
|
|
119
|
+
if (compare(versionBehind, versionAhead) === 1) {
|
|
120
|
+
throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
|
|
121
|
+
}
|
|
122
|
+
for (const level of ['major', 'minor', 'patch', 'rc']) {
|
|
123
|
+
if (versionBehind[level] !== versionAhead[level]) {
|
|
124
|
+
return level;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return 'no bump';
|
|
128
|
+
}
|
|
129
|
+
SemVer.bumpType = bumpType;
|
|
130
|
+
})(SemVer || (SemVer = {}));
|
|
131
|
+
|
|
132
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/fs.rmSync.ts
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Polyfill of fs.rmSync(dirPath, { "recursive": true })
|
|
138
|
+
* For older version of Node
|
|
139
|
+
*/
|
|
140
|
+
function rmSync(dirPath, options) {
|
|
141
|
+
if (SemVer.compare(SemVer.parse(process.version), SemVer.parse('14.14.0')) > 0) {
|
|
142
|
+
external_fs_.rmSync(dirPath, options);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const { force = true } = options;
|
|
146
|
+
if (force && !external_fs_.existsSync(dirPath)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const removeDir_rec = (dirPath) => external_fs_.readdirSync(dirPath).forEach(basename => {
|
|
150
|
+
const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
|
|
151
|
+
if (external_fs_.lstatSync(fileOrDirPath).isDirectory()) {
|
|
152
|
+
removeDir_rec(fileOrDirPath);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
external_fs_.unlinkSync(fileOrDirPath);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
removeDir_rec(dirPath);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/transformCodebase_async.ts
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Apply a transformation function to every file of directory
|
|
169
|
+
* If source and destination are the same this function can be used to apply the transformation in place
|
|
170
|
+
* like filtering out some files or modifying them.
|
|
171
|
+
* */
|
|
172
|
+
async function transformCodebase(params) {
|
|
173
|
+
const { srcDirPath, transformSourceCode } = params;
|
|
174
|
+
const isTargetSameAsSource = external_path_.relative(srcDirPath, params.destDirPath) === '';
|
|
175
|
+
const destDirPath = isTargetSameAsSource
|
|
176
|
+
? external_path_.join(srcDirPath, '..', 'tmp_xOsPdkPsTdzPs34sOkHs')
|
|
177
|
+
: params.destDirPath;
|
|
178
|
+
external_fs_.mkdirSync(destDirPath, {
|
|
179
|
+
recursive: true
|
|
180
|
+
});
|
|
181
|
+
for (const fileRelativePath of crawl({
|
|
182
|
+
dirPath: srcDirPath,
|
|
183
|
+
returnedPathsType: 'relative to dirPath'
|
|
184
|
+
})) {
|
|
185
|
+
const filePath = external_path_.join(srcDirPath, fileRelativePath);
|
|
186
|
+
const destFilePath = external_path_.join(destDirPath, fileRelativePath);
|
|
187
|
+
// NOTE: Optimization, if we don't need to transform the file, just copy
|
|
188
|
+
// it using the lower level implementation.
|
|
189
|
+
if (transformSourceCode === undefined) {
|
|
190
|
+
external_fs_.mkdirSync(external_path_.dirname(destFilePath), {
|
|
191
|
+
recursive: true
|
|
192
|
+
});
|
|
193
|
+
external_fs_.copyFileSync(filePath, destFilePath);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const transformSourceCodeResult = await transformSourceCode({
|
|
197
|
+
sourceCode: external_fs_.readFileSync(filePath),
|
|
198
|
+
filePath,
|
|
199
|
+
fileRelativePath
|
|
200
|
+
});
|
|
201
|
+
if (transformSourceCodeResult === undefined) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
external_fs_.mkdirSync(external_path_.dirname(destFilePath), {
|
|
205
|
+
recursive: true
|
|
206
|
+
});
|
|
207
|
+
const { newFileName, modifiedSourceCode } = transformSourceCodeResult;
|
|
208
|
+
external_fs_.writeFileSync(external_path_.join(external_path_.dirname(destFilePath), newFileName !== null && newFileName !== void 0 ? newFileName : external_path_.basename(destFilePath)), modifiedSourceCode);
|
|
209
|
+
}
|
|
210
|
+
if (isTargetSameAsSource) {
|
|
211
|
+
rmSync(srcDirPath, { recursive: true });
|
|
212
|
+
external_fs_.renameSync(destDirPath, srcDirPath);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
;// CONCATENATED MODULE: ./node_modules/tsafe/esm/capitalize.mjs
|
|
217
|
+
/** @see <https://docs.tsafe.dev/capitalize> */
|
|
218
|
+
function capitalize(str) {
|
|
219
|
+
return (str.charAt(0).toUpperCase() + str.slice(1));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
//# sourceMappingURL=capitalize.mjs.map
|
|
224
|
+
|
|
225
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/kebabCaseToSnakeCase.ts
|
|
226
|
+
|
|
227
|
+
function kebabCaseToCamelCase(kebabCaseString) {
|
|
228
|
+
const [first, ...rest] = kebabCaseString.split('-');
|
|
229
|
+
return [first, ...rest.map(capitalize)].join('');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/String.prototype.replaceAll.ts
|
|
233
|
+
function replaceAll(string, searchValue, replaceValue) {
|
|
234
|
+
if (string.replaceAll !== undefined) {
|
|
235
|
+
return string.replaceAll(searchValue, replaceValue);
|
|
236
|
+
}
|
|
237
|
+
// If the searchValue is a string
|
|
238
|
+
if (typeof searchValue === 'string') {
|
|
239
|
+
// Escape special characters in the string to be used in a regex
|
|
240
|
+
var escapedSearchValue = searchValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
241
|
+
var regex = new RegExp(escapedSearchValue, 'g');
|
|
242
|
+
return string.replace(regex, replaceValue);
|
|
243
|
+
}
|
|
244
|
+
// If the searchValue is a global RegExp, use it directly
|
|
245
|
+
if (searchValue instanceof RegExp && searchValue.global) {
|
|
246
|
+
return string.replace(searchValue, replaceValue);
|
|
247
|
+
}
|
|
248
|
+
// If the searchValue is a non-global RegExp, throw an error
|
|
249
|
+
if (searchValue instanceof RegExp) {
|
|
250
|
+
throw new TypeError('replaceAll must be called with a global RegExp');
|
|
251
|
+
}
|
|
252
|
+
// Convert searchValue to string if it's not a string or RegExp
|
|
253
|
+
var searchString = String(searchValue);
|
|
254
|
+
var regexFromString = new RegExp(searchString.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
|
|
255
|
+
return string.replace(regexFromString, replaceValue);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// EXTERNAL MODULE: ./dist/bin/tools/runPrettier.ts
|
|
259
|
+
var runPrettier = __webpack_require__(915);
|
|
260
|
+
;// CONCATENATED MODULE: ./dist/bin/eject-page.ts
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
async function command(params) {
|
|
274
|
+
const { buildContext } = params;
|
|
275
|
+
console.log(source/* default */.Ay.cyan('Theme type:'));
|
|
276
|
+
const themeType = await (async () => {
|
|
277
|
+
const values = constants/* THEME_TYPES */.qA.filter(themeType => {
|
|
278
|
+
switch (themeType) {
|
|
279
|
+
case 'account':
|
|
280
|
+
return buildContext.implementedThemeTypes.account.isImplemented;
|
|
281
|
+
case 'login':
|
|
282
|
+
return buildContext.implementedThemeTypes.login.isImplemented;
|
|
283
|
+
}
|
|
284
|
+
// @ts-ignore
|
|
285
|
+
(0,assert/* assert */.v)(false);
|
|
286
|
+
});
|
|
287
|
+
(0,assert/* assert */.v)(values.length > 0, 'No theme is implemented in this project');
|
|
288
|
+
if (values.length === 1) {
|
|
289
|
+
return values[0];
|
|
290
|
+
}
|
|
291
|
+
const { value } = await dist_default()({
|
|
292
|
+
values
|
|
293
|
+
}).catch(() => {
|
|
294
|
+
process.exit(-1);
|
|
295
|
+
});
|
|
296
|
+
return value;
|
|
297
|
+
})();
|
|
298
|
+
console.log(`→ ${themeType}`);
|
|
299
|
+
console.log(source/* default */.Ay.cyan('Select the page you want to customize:'));
|
|
300
|
+
const templateValue = 'template.ftl (Layout common to every page)';
|
|
301
|
+
const userProfileFormFieldsValue = 'user-profile-commons.ftl (Renders the form of the register.ftl, login-update-profile.ftl, update-email.ftl and idp-review-user-profile.ftl)';
|
|
302
|
+
const { value: pageIdOrComponent } = await dist_default()({
|
|
303
|
+
values: (() => {
|
|
304
|
+
switch (themeType) {
|
|
305
|
+
case 'login':
|
|
306
|
+
return [
|
|
307
|
+
templateValue,
|
|
308
|
+
userProfileFormFieldsValue,
|
|
309
|
+
...constants/* LOGIN_THEME_PAGE_IDS */.hz
|
|
310
|
+
];
|
|
311
|
+
case 'account':
|
|
312
|
+
return [templateValue, ...constants/* ACCOUNT_THEME_PAGE_IDS */.Hp];
|
|
313
|
+
}
|
|
314
|
+
// @ts-ignore
|
|
315
|
+
(0,assert/* assert */.v)(false);
|
|
316
|
+
})()
|
|
317
|
+
}).catch(() => {
|
|
318
|
+
process.exit(-1);
|
|
319
|
+
});
|
|
320
|
+
console.log(`→ ${pageIdOrComponent}`);
|
|
321
|
+
const componentRelativeDirPath_posix_to_componentRelativeFilePath_posix = (params) => {
|
|
322
|
+
const { componentRelativeDirPath_posix } = params;
|
|
323
|
+
return `${componentRelativeDirPath_posix}/${external_path_.posix.basename(componentRelativeDirPath_posix)}.component`;
|
|
324
|
+
};
|
|
325
|
+
const componentDirRelativeToThemeTypePath = (() => {
|
|
326
|
+
if (pageIdOrComponent === templateValue) {
|
|
327
|
+
return (0,external_path_.join)('template');
|
|
328
|
+
}
|
|
329
|
+
if (pageIdOrComponent === userProfileFormFieldsValue) {
|
|
330
|
+
return (0,external_path_.join)('components', 'user-profile-form-fields');
|
|
331
|
+
}
|
|
332
|
+
return (0,external_path_.join)('pages', pageIdOrComponent.replace(/\.ftl$/, ''));
|
|
333
|
+
})();
|
|
334
|
+
{
|
|
335
|
+
const componentDirRelativeToThemeTypePaths = [
|
|
336
|
+
componentDirRelativeToThemeTypePath
|
|
337
|
+
];
|
|
338
|
+
while (componentDirRelativeToThemeTypePaths.length !== 0) {
|
|
339
|
+
const componentDirRelativeToThemeTypePath_i = componentDirRelativeToThemeTypePaths.pop();
|
|
340
|
+
(0,assert/* assert */.v)(componentDirRelativeToThemeTypePath_i !== undefined);
|
|
341
|
+
const destDirPath = (0,external_path_.join)(buildContext.themeSrcDirPath, themeType, componentDirRelativeToThemeTypePath_i);
|
|
342
|
+
const dirName = (0,external_path_.basename)(destDirPath);
|
|
343
|
+
const tsFilePath = (0,external_path_.join)(destDirPath, `${dirName}.component.ts`);
|
|
344
|
+
if (external_fs_.existsSync(destDirPath) && external_fs_.readdirSync(destDirPath).length !== 0) {
|
|
345
|
+
// Check if the directory contains a .ts file with the same name as the directory
|
|
346
|
+
if (external_fs_.existsSync(tsFilePath)) {
|
|
347
|
+
if (componentDirRelativeToThemeTypePath_i ===
|
|
348
|
+
componentDirRelativeToThemeTypePath) {
|
|
349
|
+
console.log(`${pageIdOrComponent.split('.ftl')[0]} is already ejected, ${(0,external_path_.relative)(process.cwd(), destDirPath)} already exists and contains ${dirName}.ts`);
|
|
350
|
+
process.exit(-1);
|
|
351
|
+
}
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const localThemeTypeDirPath = (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.J)(), 'src', themeType);
|
|
356
|
+
await transformCodebase({
|
|
357
|
+
srcDirPath: (0,external_path_.join)(localThemeTypeDirPath, componentDirRelativeToThemeTypePath_i),
|
|
358
|
+
destDirPath,
|
|
359
|
+
transformSourceCode: async ({ filePath, fileRelativePath, sourceCode }) => {
|
|
360
|
+
if (!filePath.endsWith('.ts')) {
|
|
361
|
+
let modifiedSourceCode_str = sourceCode.toString('utf8');
|
|
362
|
+
run_prettier: {
|
|
363
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
|
|
364
|
+
break run_prettier;
|
|
365
|
+
}
|
|
366
|
+
modifiedSourceCode_str = await (0,runPrettier/* runPrettier */.JS)({
|
|
367
|
+
filePath: (0,external_path_.join)(destDirPath, fileRelativePath),
|
|
368
|
+
sourceCode: modifiedSourceCode_str
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
modifiedSourceCode: Buffer.from(modifiedSourceCode_str, 'utf8')
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (filePath.endsWith('index.ts')) {
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
const fileRelativeToThemeTypePath = (0,external_path_.relative)(localThemeTypeDirPath, filePath);
|
|
379
|
+
let modifiedSourceCode_str = sourceCode.toString();
|
|
380
|
+
const getPosixPathRelativeToFile = (params) => {
|
|
381
|
+
const { pathRelativeToThemeType } = params;
|
|
382
|
+
const path = (0,external_path_.relative)((0,external_path_.dirname)(fileRelativeToThemeTypePath), pathRelativeToThemeType)
|
|
383
|
+
.split(external_path_.sep)
|
|
384
|
+
.join('/');
|
|
385
|
+
return path.startsWith('.') ? path : `./${path}`;
|
|
386
|
+
};
|
|
387
|
+
modifiedSourceCode_str = replaceAll(modifiedSourceCode_str, `@keycloakify/angular/${themeType}/i18n`, getPosixPathRelativeToFile({
|
|
388
|
+
pathRelativeToThemeType: 'i18n'
|
|
389
|
+
}));
|
|
390
|
+
modifiedSourceCode_str = replaceAll(modifiedSourceCode_str, `@keycloakify/angular/${themeType}/KcContext`, getPosixPathRelativeToFile({
|
|
391
|
+
pathRelativeToThemeType: 'KcContext'
|
|
392
|
+
}));
|
|
393
|
+
modifiedSourceCode_str = modifiedSourceCode_str.replace(new RegExp(`@keycloakify/angular/${themeType}/components/([^'"]+)`, 'g'), (...[, componentDirRelativeToComponentsPath]) => {
|
|
394
|
+
const componentDirRelativeToThemeTypePath = (0,external_path_.join)('components', componentDirRelativeToComponentsPath);
|
|
395
|
+
componentDirRelativeToThemeTypePaths.push(componentDirRelativeToThemeTypePath);
|
|
396
|
+
return componentRelativeDirPath_posix_to_componentRelativeFilePath_posix({
|
|
397
|
+
componentRelativeDirPath_posix: getPosixPathRelativeToFile({
|
|
398
|
+
pathRelativeToThemeType: componentDirRelativeToThemeTypePath
|
|
399
|
+
})
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
run_prettier: {
|
|
403
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
|
|
404
|
+
break run_prettier;
|
|
405
|
+
}
|
|
406
|
+
modifiedSourceCode_str = await (0,runPrettier/* runPrettier */.JS)({
|
|
407
|
+
filePath: (0,external_path_.join)(destDirPath, fileRelativePath),
|
|
408
|
+
sourceCode: modifiedSourceCode_str
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
modifiedSourceCode: Buffer.from(modifiedSourceCode_str, 'utf8')
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
console.log(`${source/* default */.Ay.green('✓')} ${source/* default */.Ay.bold(`.${external_path_.sep}` + (0,external_path_.relative)(process.cwd(), destDirPath))} moved from the @keycloakify/angular to your project`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
edit_KcPage: {
|
|
420
|
+
if (pageIdOrComponent !== templateValue &&
|
|
421
|
+
pageIdOrComponent !== userProfileFormFieldsValue) {
|
|
422
|
+
break edit_KcPage;
|
|
423
|
+
}
|
|
424
|
+
const kcAppTsFilePath = (0,external_path_.join)(buildContext.themeSrcDirPath, themeType, 'KcPage.ts');
|
|
425
|
+
const kcAppTsCode = external_fs_.readFileSync(kcAppTsFilePath).toString('utf8');
|
|
426
|
+
const modifiedKcAppTsCode = await (async () => {
|
|
427
|
+
const componentRelativeDirPath_posix = componentDirRelativeToThemeTypePath
|
|
428
|
+
.split(external_path_.sep)
|
|
429
|
+
.join('/');
|
|
430
|
+
let sourceCode = kcAppTsCode.replace(`@keycloakify/angular/${themeType}/${componentRelativeDirPath_posix}`, componentRelativeDirPath_posix_to_componentRelativeFilePath_posix({
|
|
431
|
+
componentRelativeDirPath_posix: `./${componentRelativeDirPath_posix}`
|
|
432
|
+
}));
|
|
433
|
+
run_prettier: {
|
|
434
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
|
|
435
|
+
break run_prettier;
|
|
436
|
+
}
|
|
437
|
+
sourceCode = await (0,runPrettier/* runPrettier */.JS)({
|
|
438
|
+
filePath: kcAppTsFilePath,
|
|
439
|
+
sourceCode
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
return sourceCode;
|
|
443
|
+
})();
|
|
444
|
+
if (modifiedKcAppTsCode === kcAppTsCode) {
|
|
445
|
+
console.log(source/* default */.Ay.red('Unable to automatically update KcPage.ts, please update it manually'));
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
external_fs_.writeFileSync(kcAppTsFilePath, Buffer.from(modifiedKcAppTsCode, 'utf8'));
|
|
449
|
+
console.log(`${source/* default */.Ay.green('✓')} ${source/* default */.Ay.bold(`.${external_path_.sep}` + (0,external_path_.relative)(process.cwd(), kcAppTsFilePath))} Updated`);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const pageId = pageIdOrComponent;
|
|
453
|
+
console.log([
|
|
454
|
+
``,
|
|
455
|
+
`You now need to update your page router:`,
|
|
456
|
+
``,
|
|
457
|
+
`${source/* default */.Ay.bold((0,external_path_.join)('.', (0,external_path_.relative)(process.cwd(), buildContext.themeSrcDirPath), themeType, 'KcPage.ts'))}:`,
|
|
458
|
+
source/* default */.Ay.grey('```'),
|
|
459
|
+
`// ...`,
|
|
460
|
+
``,
|
|
461
|
+
...(() => {
|
|
462
|
+
let inGreenBlock = false;
|
|
463
|
+
return [
|
|
464
|
+
` export async function getKcPage(pageId: KcContext['pageId']): Promise<KcPage> {`,
|
|
465
|
+
` switch (pageId) {`,
|
|
466
|
+
`+`,
|
|
467
|
+
` case '${pageId}':`,
|
|
468
|
+
` return {`,
|
|
469
|
+
` PageComponent: (await import('${componentRelativeDirPath_posix_to_componentRelativeFilePath_posix({
|
|
470
|
+
componentRelativeDirPath_posix: `./${componentDirRelativeToThemeTypePath.split(external_path_.sep).join('/')}`
|
|
471
|
+
})}')).${kebabCaseToCamelCase(capitalize(pageId).replace(/\.ftl$/, ''))}Component,`,
|
|
472
|
+
` TemplateComponent,`,
|
|
473
|
+
...(themeType === 'login'
|
|
474
|
+
? [` UserProfileFormFieldsComponent,`]
|
|
475
|
+
: []),
|
|
476
|
+
...(themeType === 'login'
|
|
477
|
+
? [` doMakeUserConfirmPassword,`]
|
|
478
|
+
: []),
|
|
479
|
+
` doUseDefaultCss,`,
|
|
480
|
+
` classes,`,
|
|
481
|
+
` };`,
|
|
482
|
+
`+`,
|
|
483
|
+
` //...`,
|
|
484
|
+
` default:`,
|
|
485
|
+
` return {`,
|
|
486
|
+
` PageComponent: await getDefaultPageComponent(pageId),`,
|
|
487
|
+
` TemplateComponent,`,
|
|
488
|
+
...(themeType === 'login'
|
|
489
|
+
? [` UserProfileFormFieldsComponent,`]
|
|
490
|
+
: []),
|
|
491
|
+
...(themeType === 'login'
|
|
492
|
+
? [` doMakeUserConfirmPassword,`]
|
|
493
|
+
: []),
|
|
494
|
+
` doUseDefaultCss,`,
|
|
495
|
+
` classes,`,
|
|
496
|
+
` };`,
|
|
497
|
+
` }`,
|
|
498
|
+
` }`
|
|
499
|
+
].map(line => {
|
|
500
|
+
if (line === `+`) {
|
|
501
|
+
inGreenBlock = !inGreenBlock;
|
|
502
|
+
}
|
|
503
|
+
if (inGreenBlock || line.startsWith('+')) {
|
|
504
|
+
return source/* default */.Ay.green(line);
|
|
505
|
+
}
|
|
506
|
+
if (line.startsWith('-')) {
|
|
507
|
+
return source/* default */.Ay.red(line);
|
|
508
|
+
}
|
|
509
|
+
return source/* default */.Ay.grey(line);
|
|
510
|
+
});
|
|
511
|
+
})(),
|
|
512
|
+
source/* default */.Ay.grey('```')
|
|
513
|
+
].join('\n'));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
/***/ }),
|
|
518
|
+
|
|
519
|
+
/***/ 221:
|
|
520
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
521
|
+
|
|
522
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
523
|
+
/* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
|
|
524
|
+
/* harmony export */ });
|
|
525
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
|
|
526
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
|
|
527
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
|
|
528
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
function getThisCodebaseRootDirPath_rec(dirPath) {
|
|
532
|
+
if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
|
|
533
|
+
return dirPath;
|
|
534
|
+
}
|
|
535
|
+
return getThisCodebaseRootDirPath_rec(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
|
|
536
|
+
}
|
|
537
|
+
let result = undefined;
|
|
538
|
+
function getThisCodebaseRootDirPath() {
|
|
539
|
+
if (result !== undefined) {
|
|
540
|
+
return result;
|
|
541
|
+
}
|
|
542
|
+
return (result = getThisCodebaseRootDirPath_rec(__dirname));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
/***/ }),
|
|
547
|
+
|
|
548
|
+
/***/ 395:
|
|
549
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
550
|
+
|
|
551
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
552
|
+
/* harmony export */ p: () => (/* binding */ getNodeModulesBinDirPath)
|
|
553
|
+
/* harmony export */ });
|
|
554
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
|
|
555
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
|
556
|
+
|
|
557
|
+
let cache = undefined;
|
|
558
|
+
function getNodeModulesBinDirPath() {
|
|
559
|
+
if (cache !== undefined) {
|
|
560
|
+
return cache;
|
|
561
|
+
}
|
|
562
|
+
const binPath = process.argv[1];
|
|
563
|
+
const segments = ['.bin'];
|
|
564
|
+
let foundNodeModules = false;
|
|
565
|
+
for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
|
|
566
|
+
skip_segment: {
|
|
567
|
+
if (foundNodeModules) {
|
|
568
|
+
break skip_segment;
|
|
569
|
+
}
|
|
570
|
+
if (segment === 'node_modules') {
|
|
571
|
+
foundNodeModules = true;
|
|
572
|
+
break skip_segment;
|
|
573
|
+
}
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
segments.unshift(segment);
|
|
577
|
+
}
|
|
578
|
+
const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
|
|
579
|
+
cache = nodeModulesBinDirPath;
|
|
580
|
+
return nodeModulesBinDirPath;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
/***/ }),
|
|
585
|
+
|
|
586
|
+
/***/ 972:
|
|
587
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
588
|
+
|
|
589
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
590
|
+
/* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
|
|
591
|
+
/* harmony export */ });
|
|
592
|
+
/* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(221);
|
|
593
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(966);
|
|
594
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(896);
|
|
595
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
|
596
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(928);
|
|
597
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
let cache = undefined;
|
|
603
|
+
function readThisNpmPackageVersion() {
|
|
604
|
+
if (cache !== undefined) {
|
|
605
|
+
return cache;
|
|
606
|
+
}
|
|
607
|
+
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'))
|
|
608
|
+
.toString('utf8'))['version'];
|
|
609
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(typeof version === 'string');
|
|
610
|
+
cache = version;
|
|
611
|
+
return version;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
/***/ }),
|
|
616
|
+
|
|
617
|
+
/***/ 915:
|
|
618
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
619
|
+
|
|
620
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
621
|
+
/* harmony export */ JS: () => (/* binding */ runPrettier),
|
|
622
|
+
/* harmony export */ L: () => (/* binding */ getIsPrettierAvailable)
|
|
623
|
+
/* harmony export */ });
|
|
624
|
+
/* unused harmony export getPrettier */
|
|
625
|
+
/* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(395);
|
|
626
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
|
|
627
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
|
628
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(943);
|
|
629
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
|
|
630
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(94);
|
|
631
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
|
|
632
|
+
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(797);
|
|
633
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(982);
|
|
634
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_3__);
|
|
635
|
+
/* harmony import */ var tsafe_is__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(289);
|
|
636
|
+
/* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
|
|
637
|
+
/* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(972);
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
|
|
649
|
+
async function getIsPrettierAvailable() {
|
|
650
|
+
var _a;
|
|
651
|
+
if (getIsPrettierAvailable.cache !== undefined) {
|
|
652
|
+
return getIsPrettierAvailable.cache;
|
|
653
|
+
}
|
|
654
|
+
const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getNodeModulesBinDirPath */ .p)();
|
|
655
|
+
const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(nodeModulesBinDirPath, 'prettier');
|
|
656
|
+
const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.stat(prettierBinPath).catch(() => undefined);
|
|
657
|
+
const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
|
|
658
|
+
getIsPrettierAvailable.cache = isPrettierAvailable;
|
|
659
|
+
return isPrettierAvailable;
|
|
660
|
+
}
|
|
661
|
+
getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
|
|
662
|
+
async function getPrettier() {
|
|
663
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)(getIsPrettierAvailable());
|
|
664
|
+
if (getPrettier.cache !== undefined) {
|
|
665
|
+
return getPrettier.cache;
|
|
666
|
+
}
|
|
667
|
+
let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
|
|
668
|
+
import_prettier: {
|
|
669
|
+
// NOTE: When module is linked we want to make sure we import the correct version
|
|
670
|
+
// of prettier, that is the one of the project, not the one of this repo.
|
|
671
|
+
// So we do a sketchy eval to bypass ncc.
|
|
672
|
+
// We make sure to only do that when linking, otherwise we import properly.
|
|
673
|
+
if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
|
|
674
|
+
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'))}")`);
|
|
675
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)(!(0,tsafe_is__WEBPACK_IMPORTED_MODULE_4__.is)(prettier));
|
|
676
|
+
break import_prettier;
|
|
677
|
+
}
|
|
678
|
+
prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 166));
|
|
679
|
+
}
|
|
680
|
+
const configHash = await (async () => {
|
|
681
|
+
const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_6__/* .getNodeModulesBinDirPath */ .p)(), '..'));
|
|
682
|
+
if (configFilePath === null) {
|
|
683
|
+
return '';
|
|
684
|
+
}
|
|
685
|
+
const data = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile(configFilePath);
|
|
686
|
+
return crypto__WEBPACK_IMPORTED_MODULE_3__.createHash('sha256').update(data).digest('hex');
|
|
687
|
+
})();
|
|
688
|
+
const prettierAndConfig = {
|
|
689
|
+
prettier,
|
|
690
|
+
configHash
|
|
691
|
+
};
|
|
692
|
+
getPrettier.cache = prettierAndConfig;
|
|
693
|
+
return prettierAndConfig;
|
|
694
|
+
}
|
|
695
|
+
async function runPrettier(params) {
|
|
696
|
+
const { sourceCode, filePath } = params;
|
|
697
|
+
let formattedSourceCode;
|
|
698
|
+
try {
|
|
699
|
+
const { prettier } = await getPrettier();
|
|
700
|
+
const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
|
|
701
|
+
resolveConfig: true
|
|
702
|
+
});
|
|
703
|
+
if (ignored) {
|
|
704
|
+
return sourceCode;
|
|
705
|
+
}
|
|
706
|
+
const config = await prettier.resolveConfig(filePath);
|
|
707
|
+
formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
|
|
708
|
+
}
|
|
709
|
+
catch (error) {
|
|
710
|
+
console.log(chalk__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Ay.red(`You probably need to upgrade the version of prettier in your project`));
|
|
711
|
+
throw error;
|
|
712
|
+
}
|
|
713
|
+
return formattedSourceCode;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
/***/ })
|
|
718
|
+
|
|
719
|
+
};
|