keycloakify 11.8.46 → 11.8.47-rc.1

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 (39) hide show
  1. package/bin/254.index.js +283 -0
  2. package/bin/30.index.js +25 -0
  3. package/bin/{864.index.js → 309.index.js} +6944 -28439
  4. package/bin/311.index.js +198 -0
  5. package/bin/{313.index.js → 355.index.js} +101 -147
  6. package/bin/{84.index.js → 502.index.js} +147 -101
  7. package/bin/626.index.js +194 -0
  8. package/bin/{698.index.js → 656.index.js} +101 -147
  9. package/bin/675.index.js +177 -0
  10. package/bin/69.index.js +1 -1
  11. package/bin/762.index.js +1475 -0
  12. package/bin/780.index.js +4 -2
  13. package/bin/786.index.js +115 -0
  14. package/bin/895.index.js +21501 -0
  15. package/bin/{618.index.js → 932.index.js} +117 -163
  16. package/bin/949.index.js +1 -1
  17. package/bin/97.index.js +537 -4
  18. package/bin/init/index.d.ts +1 -0
  19. package/bin/init/init.d.ts +3 -0
  20. package/bin/init/setupEslint.d.ts +4 -0
  21. package/bin/init/setupVitePluginIfNeeded.d.ts +4 -0
  22. package/bin/initialize-login-theme.d.ts +4 -0
  23. package/bin/main.js +19 -30
  24. package/bin/shared/customHandler.d.ts +1 -1
  25. package/bin/shared/customHandler.js.map +1 -1
  26. package/package.json +23 -7
  27. package/src/bin/init/index.ts +1 -0
  28. package/src/bin/init/init.ts +354 -0
  29. package/src/bin/init/setupEslint.ts +80 -0
  30. package/src/bin/init/setupVitePluginIfNeeded.ts +143 -0
  31. package/src/bin/initialize-account-theme/initialize-account-theme.ts +4 -0
  32. package/src/bin/initialize-login-theme.ts +323 -0
  33. package/src/bin/main.ts +14 -0
  34. package/src/bin/shared/buildContext.ts +2 -37
  35. package/src/bin/shared/customHandler.ts +3 -1
  36. package/src/bin/sync-extensions/extensionModuleMeta.ts +89 -73
  37. package/src/bin/sync-extensions/managedGitignoreFiles.ts +32 -2
  38. package/vite-plugin/index.js +1 -24
  39. package/bin/433.index.js +0 -140
@@ -206,92 +206,108 @@ export async function getExtensionModuleMetas(params: {
206
206
  })();
207
207
 
208
208
  const extensionModuleMetas = await Promise.all(
209
- installedExtensionModules.map(
210
- async ({
211
- moduleName,
212
- version,
213
- peerDependencies,
214
- dirPath
215
- }): Promise<ExtensionModuleMeta> => {
216
- use_cache: {
217
- const extensionModuleMeta_cache =
218
- extensionModuleMetas_cacheUpToDate.find(
219
- extensionModuleMeta =>
220
- extensionModuleMeta.moduleName === moduleName
221
- );
222
-
223
- if (extensionModuleMeta_cache === undefined) {
224
- break use_cache;
225
- }
226
-
227
- return extensionModuleMeta_cache;
228
- }
209
+ [...installedExtensionModules]
210
+ .sort((a, b) => a.moduleName.localeCompare(b.moduleName))
211
+ .map(
212
+ async ({
213
+ moduleName,
214
+ version,
215
+ peerDependencies,
216
+ dirPath
217
+ }): Promise<ExtensionModuleMeta> => {
218
+ use_cache: {
219
+ const extensionModuleMeta_cache =
220
+ extensionModuleMetas_cacheUpToDate.find(
221
+ extensionModuleMeta =>
222
+ extensionModuleMeta.moduleName === moduleName
223
+ );
224
+
225
+ if (extensionModuleMeta_cache === undefined) {
226
+ break use_cache;
227
+ }
229
228
 
230
- const files: ExtensionModuleMeta["files"] = [];
229
+ return extensionModuleMeta_cache;
230
+ }
231
231
 
232
- await crawlAsync({
233
- dirPath: pathJoin(dirPath, KEYCLOAK_THEME),
234
- returnedPathsType: "relative to dirPath",
235
- onFileFound: async fileRelativePath_fromReservedDir => {
236
- const isPublic = fileRelativePath_fromReservedDir.startsWith(
237
- `public${pathSep}`
238
- );
232
+ const files: ExtensionModuleMeta["files"] = [];
233
+
234
+ await crawlAsync({
235
+ dirPath: pathJoin(dirPath, KEYCLOAK_THEME),
236
+ returnedPathsType: "relative to dirPath",
237
+ onFileFound: async fileRelativePath_fromReservedDir => {
238
+ const isPublic = fileRelativePath_fromReservedDir.startsWith(
239
+ `public${pathSep}`
240
+ );
241
+
242
+ const fileRelativePath = isPublic
243
+ ? pathRelative("public", fileRelativePath_fromReservedDir)
244
+ : fileRelativePath_fromReservedDir;
245
+
246
+ const sourceCode =
247
+ await getExtensionModuleFileSourceCodeReadyToBeCopied({
248
+ buildContext,
249
+ isPublic,
250
+ fileRelativePath,
251
+ isOwnershipAction: false,
252
+ extensionModuleDirPath: dirPath,
253
+ extensionModuleName: moduleName,
254
+ extensionModuleVersion: version
255
+ });
256
+
257
+ const hash = computeHash(sourceCode);
258
+
259
+ const copyableFilePath = pathJoin(
260
+ pathDirname(cacheFilePath),
261
+ KEYCLOAK_THEME,
262
+ fileRelativePath_fromReservedDir
263
+ );
264
+
265
+ {
266
+ const dirPath = pathDirname(copyableFilePath);
267
+
268
+ if (!(await existsAsync(dirPath))) {
269
+ await fsPr.mkdir(dirPath, { recursive: true });
270
+ }
271
+ }
239
272
 
240
- const fileRelativePath = isPublic
241
- ? pathRelative("public", fileRelativePath_fromReservedDir)
242
- : fileRelativePath_fromReservedDir;
273
+ fsPr.writeFile(copyableFilePath, sourceCode);
243
274
 
244
- const sourceCode =
245
- await getExtensionModuleFileSourceCodeReadyToBeCopied({
246
- buildContext,
275
+ files.push({
247
276
  isPublic,
248
277
  fileRelativePath,
249
- isOwnershipAction: false,
250
- extensionModuleDirPath: dirPath,
251
- extensionModuleName: moduleName,
252
- extensionModuleVersion: version
278
+ hash,
279
+ copyableFilePath
253
280
  });
254
-
255
- const hash = computeHash(sourceCode);
256
-
257
- const copyableFilePath = pathJoin(
258
- pathDirname(cacheFilePath),
259
- KEYCLOAK_THEME,
260
- fileRelativePath_fromReservedDir
261
- );
262
-
263
- {
264
- const dirPath = pathDirname(copyableFilePath);
265
-
266
- if (!(await existsAsync(dirPath))) {
267
- await fsPr.mkdir(dirPath, { recursive: true });
268
- }
269
281
  }
282
+ });
270
283
 
271
- fsPr.writeFile(copyableFilePath, sourceCode);
284
+ {
285
+ const getId = (file: {
286
+ isPublic: boolean;
287
+ fileRelativePath: string;
288
+ }) =>
289
+ `${file.isPublic ? "public" : "src"} - ${file.fileRelativePath}`;
272
290
 
273
- files.push({
274
- isPublic,
275
- fileRelativePath,
276
- hash,
277
- copyableFilePath
278
- });
291
+ files.sort((a, b) => getId(a).localeCompare(getId(b)));
279
292
  }
280
- });
281
293
 
282
- return id<ExtensionModuleMeta>({
283
- moduleName,
284
- version,
285
- files,
286
- peerDependencies: Object.fromEntries(
287
- Object.entries(peerDependencies).filter(
288
- ([moduleName]) =>
289
- !isAmong(["react", "@types/react"], moduleName)
294
+ return id<ExtensionModuleMeta>({
295
+ moduleName,
296
+ version,
297
+ files,
298
+ peerDependencies: Object.fromEntries(
299
+ Object.entries(peerDependencies)
300
+ .filter(
301
+ ([moduleName]) =>
302
+ !isAmong(["react", "@types/react"], moduleName)
303
+ )
304
+ .sort(([moduleName_a], [moduleName_b]) =>
305
+ moduleName_a.localeCompare(moduleName_b)
306
+ )
290
307
  )
291
- )
292
- });
293
- }
294
- )
308
+ });
309
+ }
310
+ )
295
311
  );
296
312
 
297
313
  update_cache: {
@@ -73,10 +73,16 @@ export async function writeManagedGitignoreFiles(params: {
73
73
  ...ownedFilesRelativePaths_ctx
74
74
  .map(({ fileRelativePath }) => fileRelativePath)
75
75
  .map(fileRelativePath => fileRelativePath.split(pathSep).join("/"))
76
+ .sort(posixPathCompareFn)
76
77
  .map(line => `# ${line}`),
77
78
  DELIMITER_END,
78
79
  ``,
79
- ...extensionModuleMetas_ctx
80
+ ...[...extensionModuleMetas_ctx]
81
+ .sort((a, b) => {
82
+ const n = a.moduleName.length - b.moduleName.length;
83
+
84
+ return n !== 0 ? n : a.moduleName.localeCompare(b.moduleName);
85
+ })
80
86
  .map(extensionModuleMeta => [
81
87
  `# === ${extensionModuleMeta.moduleName} v${extensionModuleMeta.version} ===`,
82
88
  ...extensionModuleMeta.files
@@ -90,7 +96,8 @@ export async function writeManagedGitignoreFiles(params: {
90
96
  .map(
91
97
  fileRelativePath =>
92
98
  `/${fileRelativePath.split(pathSep).join("/").replace(/^\.\//, "")}`
93
- ),
99
+ )
100
+ .sort(posixPathCompareFn),
94
101
 
95
102
  ``
96
103
  ])
@@ -187,3 +194,26 @@ export async function readManagedGitignoresFile(params: {
187
194
 
188
195
  return { ownedFilesRelativePaths };
189
196
  }
197
+
198
+ function posixPathCompareFn(a: string, b: string) {
199
+ const aParts = a.split("/");
200
+ const bParts = b.split("/");
201
+
202
+ const diff = aParts.length - bParts.length;
203
+
204
+ if (diff !== 0) {
205
+ return diff;
206
+ }
207
+
208
+ const len = Math.min(aParts.length, bParts.length);
209
+
210
+ for (let i = 0; i < len; i++) {
211
+ const cmp = aParts[i].localeCompare(bParts[i], undefined, {
212
+ numeric: true,
213
+ sensitivity: "base"
214
+ });
215
+ if (cmp !== 0) return cmp;
216
+ }
217
+
218
+ return 0;
219
+ }
@@ -408,30 +408,7 @@ function getBuildContext(params) {
408
408
  if (themeSrcDirPath !== undefined) {
409
409
  return { themeSrcDirPath };
410
410
  }
411
- {
412
- const basenames = external_fs_.readdirSync(srcDirPath);
413
- for (const basename of basenames) {
414
- const path = (0,external_path_.join)(srcDirPath, basename);
415
- if (!external_fs_.statSync(path).isFile()) {
416
- continue;
417
- }
418
- if (external_fs_.readFileSync(path).toString("utf8").includes("./kc.gen")) {
419
- return { themeSrcDirPath: srcDirPath };
420
- }
421
- }
422
- }
423
- for (const themeType of [...constants.THEME_TYPES, "email"]) {
424
- if (!external_fs_.existsSync((0,external_path_.join)(srcDirPath, themeType))) {
425
- continue;
426
- }
427
- return { themeSrcDirPath: srcDirPath };
428
- }
429
- console.log(source_default().red([
430
- `Can't locate your Keycloak theme source directory in .${external_path_.sep}${(0,external_path_.relative)(process.cwd(), srcDirPath)}`,
431
- `Make sure to either use the Keycloakify CLI in the root of your Keycloakify project or use the --project CLI option`,
432
- `If you are collocating your Keycloak theme with your app you must have a directory named '${constants.KEYCLOAK_THEME}' or '${constants.KEYCLOAK_THEME.replace(/-/g, "_")}' in your 'src' directory`
433
- ].join("\n")));
434
- process.exit(1);
411
+ return { themeSrcDirPath: srcDirPath };
435
412
  })();
436
413
  const { resolvedViteConfig } = (() => {
437
414
  if (external_fs_.readdirSync(projectDirPath)
package/bin/433.index.js DELETED
@@ -1,140 +0,0 @@
1
- "use strict";
2
- exports.id = 433;
3
- exports.ids = [433];
4
- exports.modules = {
5
-
6
- /***/ 48433:
7
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "LG": () => (/* binding */ getPrettier),
11
- /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
12
- /* harmony export */ "eY": () => (/* binding */ runPrettier)
13
- /* harmony export */ });
14
- /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
15
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
16
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
17
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
18
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
19
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
20
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
21
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
22
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
23
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
24
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
25
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
26
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
27
- /* module decorator */ module = __webpack_require__.hmd(module);
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
38
- async function getIsPrettierAvailable() {
39
- var _a;
40
- if (getIsPrettierAvailable.cache !== undefined) {
41
- return getIsPrettierAvailable.cache;
42
- }
43
- const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({
44
- packageJsonFilePath: undefined
45
- });
46
- const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
47
- const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
48
- const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
49
- getIsPrettierAvailable.cache = isPrettierAvailable;
50
- return isPrettierAvailable;
51
- }
52
- getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
53
- async function getPrettier() {
54
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
55
- if (getPrettier.cache !== undefined) {
56
- return getPrettier.cache;
57
- }
58
- let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
59
- import_prettier: {
60
- // NOTE: When module is linked we want to make sure we import the correct version
61
- // of prettier, that is the one of the project, not the one of this repo.
62
- // So we do a sketchy eval to bypass ncc.
63
- // We make sure to only do that when linking, otherwise we import properly.
64
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
65
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", "prettier"));
66
- const isCJS = true && module.exports;
67
- if (isCJS) {
68
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${prettierDirPath}")`);
69
- }
70
- else {
71
- prettier = await new Promise(_resolve => {
72
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_1__.join)(prettierDirPath, "index.mjs").replace(/\\/g, "/")}").then(prettier => _resolve(prettier))`);
73
- });
74
- }
75
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
76
- break import_prettier;
77
- }
78
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
79
- }
80
- const configHash = await (async () => {
81
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", ".."));
82
- if (configFilePath === null) {
83
- return "";
84
- }
85
- const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
86
- return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
87
- })();
88
- const prettierAndConfig = {
89
- prettier,
90
- configHash
91
- };
92
- getPrettier.cache = prettierAndConfig;
93
- return prettierAndConfig;
94
- }
95
- async function runPrettier(params) {
96
- const { sourceCode, filePath } = params;
97
- let formattedSourceCode;
98
- try {
99
- const { prettier } = await getPrettier();
100
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
101
- resolveConfig: true
102
- });
103
- if (ignored || inferredParser === null) {
104
- return sourceCode;
105
- }
106
- const config = await prettier.resolveConfig(filePath);
107
- formattedSourceCode = await prettier.format(typeof sourceCode === "string" ? sourceCode : sourceCode.toString("utf8"), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
108
- }
109
- catch (error) {
110
- console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
111
- throw error;
112
- }
113
- return typeof sourceCode === "string"
114
- ? formattedSourceCode
115
- : Buffer.from(formattedSourceCode, "utf8");
116
- }
117
- //# sourceMappingURL=runPrettier.js.map
118
-
119
- /***/ }),
120
-
121
- /***/ 76030:
122
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
123
-
124
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
125
- /* harmony export */ "r": () => (/* binding */ symToStr)
126
- /* harmony export */ });
127
- /** @see <https://docs.tsafe.dev/main/symtostr> */
128
- function symToStr(wrap) {
129
- // @ts-expect-error: We know better
130
- return Object.keys(wrap)[0];
131
- }
132
-
133
-
134
- //# sourceMappingURL=symToStr.mjs.map
135
-
136
-
137
- /***/ })
138
-
139
- };
140
- ;