keycloakify 9.3.1 → 9.4.0-rc.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 (176) hide show
  1. package/README.md +4 -0
  2. package/account/kcContext/getKcContextFromWindow.js +2 -2
  3. package/account/kcContext/getKcContextFromWindow.js.map +1 -1
  4. package/bin/constants.d.ts +4 -1
  5. package/bin/constants.js +5 -2
  6. package/bin/constants.js.map +1 -1
  7. package/bin/copy-keycloak-resources-to-public.js +3 -4
  8. package/bin/copy-keycloak-resources-to-public.js.map +1 -1
  9. package/bin/download-builtin-keycloak-theme.js +98 -31
  10. package/bin/download-builtin-keycloak-theme.js.map +1 -1
  11. package/bin/eject-keycloak-page.js +2 -2
  12. package/bin/eject-keycloak-page.js.map +1 -1
  13. package/bin/{getSrcDirPath.js → getThemeSrcDirPath.js} +1 -1
  14. package/bin/getThemeSrcDirPath.js.map +1 -0
  15. package/bin/initialize-email-theme.js +6 -5
  16. package/bin/initialize-email-theme.js.map +1 -1
  17. package/bin/keycloakify/{BuildOptions.d.ts → buildOptions/buildOptions.d.ts} +2 -1
  18. package/bin/keycloakify/buildOptions/buildOptions.js +136 -0
  19. package/bin/keycloakify/buildOptions/buildOptions.js.map +1 -0
  20. package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.d.ts +7 -0
  21. package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.js +27 -0
  22. package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.js.map +1 -0
  23. package/bin/keycloakify/buildOptions/index.d.ts +1 -0
  24. package/bin/keycloakify/{generateJavaStackFiles → buildOptions}/index.js +1 -1
  25. package/bin/keycloakify/buildOptions/index.js.map +1 -0
  26. package/bin/keycloakify/buildOptions/parsedPackageJson.d.ts +19 -0
  27. package/bin/keycloakify/{parsedPackageJson.js → buildOptions/parsedPackageJson.js} +6 -7
  28. package/bin/keycloakify/buildOptions/parsedPackageJson.js.map +1 -0
  29. package/bin/keycloakify/buildOptions/resolvedViteConfig.d.ts +12 -0
  30. package/bin/keycloakify/buildOptions/resolvedViteConfig.js +82 -0
  31. package/bin/keycloakify/buildOptions/resolvedViteConfig.js.map +1 -0
  32. package/bin/keycloakify/generateFtl/generateFtl.d.ts +4 -1
  33. package/bin/keycloakify/generateFtl/generateFtl.js +5 -5
  34. package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
  35. package/bin/keycloakify/generatePom.d.ts +12 -0
  36. package/bin/keycloakify/generatePom.js +59 -0
  37. package/bin/keycloakify/generatePom.js.map +1 -0
  38. package/bin/keycloakify/{generateJavaStackFiles → generateTheme}/bringInAccountV1.d.ts +2 -1
  39. package/bin/keycloakify/{generateJavaStackFiles → generateTheme}/bringInAccountV1.js +21 -67
  40. package/bin/keycloakify/generateTheme/bringInAccountV1.js.map +1 -0
  41. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.d.ts +0 -3
  42. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js +5 -34
  43. package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js.map +1 -1
  44. package/bin/keycloakify/generateTheme/generateTheme.d.ts +4 -1
  45. package/bin/keycloakify/generateTheme/generateTheme.js +123 -70
  46. package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
  47. package/bin/keycloakify/keycloakify.js +13 -72
  48. package/bin/keycloakify/keycloakify.js.map +1 -1
  49. package/bin/keycloakify/replacers/replaceImportsInCssCode.js +2 -1
  50. package/bin/keycloakify/replacers/replaceImportsInCssCode.js.map +1 -1
  51. package/bin/keycloakify/replacers/replaceImportsInInlineCssCode.js +2 -1
  52. package/bin/keycloakify/replacers/replaceImportsInInlineCssCode.js.map +1 -1
  53. package/bin/keycloakify/replacers/replaceImportsInJsCode/index.d.ts +1 -0
  54. package/bin/keycloakify/replacers/replaceImportsInJsCode/index.js +18 -0
  55. package/bin/keycloakify/replacers/replaceImportsInJsCode/index.js.map +1 -0
  56. package/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.d.ts +12 -0
  57. package/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.js +70 -0
  58. package/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.js.map +1 -0
  59. package/bin/keycloakify/replacers/replaceImportsInJsCode/vite.d.ts +13 -0
  60. package/bin/keycloakify/replacers/replaceImportsInJsCode/vite.js +95 -0
  61. package/bin/keycloakify/replacers/replaceImportsInJsCode/vite.js.map +1 -0
  62. package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.d.ts +12 -0
  63. package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js +108 -0
  64. package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js.map +1 -0
  65. package/bin/promptKeycloakVersion.js +0 -1
  66. package/bin/promptKeycloakVersion.js.map +1 -1
  67. package/bin/tools/OptionalIfCanBeUndefined.d.ts +14 -0
  68. package/bin/tools/OptionalIfCanBeUndefined.js +3 -0
  69. package/bin/tools/OptionalIfCanBeUndefined.js.map +1 -0
  70. package/bin/tools/SemVer.d.ts +26 -0
  71. package/bin/tools/{NpmModuleVersion.js → SemVer.js} +39 -23
  72. package/bin/tools/SemVer.js.map +1 -0
  73. package/bin/tools/String.prototype.replaceAll.d.ts +1 -0
  74. package/bin/tools/String.prototype.replaceAll.js +29 -0
  75. package/bin/tools/String.prototype.replaceAll.js.map +1 -0
  76. package/bin/tools/crawl.js +9 -9
  77. package/bin/tools/crawl.js.map +1 -1
  78. package/bin/tools/downloadAndUnzip.js +30 -19
  79. package/bin/tools/downloadAndUnzip.js.map +1 -1
  80. package/bin/tools/fs.rm.d.ts +8 -0
  81. package/bin/tools/fs.rm.js +151 -0
  82. package/bin/tools/fs.rm.js.map +1 -0
  83. package/bin/tools/fs.rmSync.d.ts +8 -0
  84. package/bin/tools/fs.rmSync.js +58 -0
  85. package/bin/tools/fs.rmSync.js.map +1 -0
  86. package/bin/tools/getAbsoluteAndInOsFormatPath.js +1 -0
  87. package/bin/tools/getAbsoluteAndInOsFormatPath.js.map +1 -1
  88. package/bin/tools/octokit-addons/getLatestsSemVersionedTag.d.ts +2 -3
  89. package/bin/tools/octokit-addons/getLatestsSemVersionedTag.js +6 -6
  90. package/bin/tools/octokit-addons/getLatestsSemVersionedTag.js.map +1 -1
  91. package/bin/tools/transformCodebase.d.ts +5 -1
  92. package/bin/tools/transformCodebase.js +31 -13
  93. package/bin/tools/transformCodebase.js.map +1 -1
  94. package/login/kcContext/getKcContextFromWindow.js +2 -2
  95. package/login/kcContext/getKcContextFromWindow.js.map +1 -1
  96. package/package.json +104 -53
  97. package/src/account/kcContext/getKcContextFromWindow.ts +2 -2
  98. package/src/bin/constants.ts +4 -1
  99. package/src/bin/copy-keycloak-resources-to-public.ts +2 -3
  100. package/src/bin/download-builtin-keycloak-theme.ts +96 -48
  101. package/src/bin/eject-keycloak-page.ts +1 -1
  102. package/src/bin/initialize-email-theme.ts +4 -3
  103. package/src/bin/keycloakify/buildOptions/buildOptions.ts +185 -0
  104. package/src/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.ts +33 -0
  105. package/src/bin/keycloakify/buildOptions/index.ts +1 -0
  106. package/src/bin/keycloakify/{parsedPackageJson.ts → buildOptions/parsedPackageJson.ts} +4 -6
  107. package/src/bin/keycloakify/buildOptions/resolvedViteConfig.ts +85 -0
  108. package/src/bin/keycloakify/generateFtl/generateFtl.ts +12 -8
  109. package/src/bin/keycloakify/generatePom.ts +70 -0
  110. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +1 -1
  111. package/src/bin/keycloakify/generateTheme/bringInAccountV1.ts +83 -0
  112. package/src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts +11 -52
  113. package/src/bin/keycloakify/generateTheme/generateTheme.ts +141 -51
  114. package/src/bin/keycloakify/keycloakify.ts +11 -58
  115. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +3 -2
  116. package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +3 -2
  117. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/index.ts +1 -0
  118. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +66 -0
  119. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +85 -0
  120. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +90 -0
  121. package/src/bin/promptKeycloakVersion.ts +0 -1
  122. package/src/bin/tools/OptionalIfCanBeUndefined.ts +12 -0
  123. package/src/bin/tools/SemVer.ts +99 -0
  124. package/src/bin/tools/String.prototype.replaceAll.ts +30 -0
  125. package/src/bin/tools/crawl.ts +8 -8
  126. package/src/bin/tools/downloadAndUnzip.ts +11 -4
  127. package/src/bin/tools/fs.rm.ts +43 -0
  128. package/src/bin/tools/fs.rmSync.ts +34 -0
  129. package/src/bin/tools/getAbsoluteAndInOsFormatPath.ts +2 -0
  130. package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +9 -9
  131. package/src/bin/tools/transformCodebase.ts +35 -14
  132. package/src/login/kcContext/getKcContextFromWindow.ts +2 -2
  133. package/src/tsconfig.json +1 -1
  134. package/src/vite-plugin/config.json +232 -0
  135. package/src/vite-plugin/index.ts +1 -0
  136. package/src/vite-plugin/tsconfig.json +18 -0
  137. package/src/vite-plugin/vite-plugin.ts +128 -0
  138. package/vite-plugin/index.d.ts +1 -0
  139. package/vite-plugin/index.js +18 -0
  140. package/vite-plugin/index.js.map +1 -0
  141. package/vite-plugin/tsconfig.tsbuildinfo +1 -0
  142. package/vite-plugin/vite-plugin.d.ts +2 -0
  143. package/vite-plugin/vite-plugin.js +118 -0
  144. package/vite-plugin/vite-plugin.js.map +1 -0
  145. package/bin/getSrcDirPath.js.map +0 -1
  146. package/bin/keycloakify/BuildOptions.js +0 -113
  147. package/bin/keycloakify/BuildOptions.js.map +0 -1
  148. package/bin/keycloakify/ftlValuesGlobalName.d.ts +0 -1
  149. package/bin/keycloakify/ftlValuesGlobalName.js +0 -5
  150. package/bin/keycloakify/ftlValuesGlobalName.js.map +0 -1
  151. package/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.js.map +0 -1
  152. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.d.ts +0 -16
  153. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js +0 -205
  154. package/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.js.map +0 -1
  155. package/bin/keycloakify/generateJavaStackFiles/index.d.ts +0 -1
  156. package/bin/keycloakify/generateJavaStackFiles/index.js.map +0 -1
  157. package/bin/keycloakify/generateTheme/readStaticResourcesUsage.d.ts +0 -15
  158. package/bin/keycloakify/generateTheme/readStaticResourcesUsage.js +0 -158
  159. package/bin/keycloakify/generateTheme/readStaticResourcesUsage.js.map +0 -1
  160. package/bin/keycloakify/parsedPackageJson.d.ts +0 -108
  161. package/bin/keycloakify/parsedPackageJson.js.map +0 -1
  162. package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.d.ts +0 -5
  163. package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js +0 -74
  164. package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js.map +0 -1
  165. package/bin/tools/NpmModuleVersion.d.ts +0 -22
  166. package/bin/tools/NpmModuleVersion.js.map +0 -1
  167. package/src/bin/keycloakify/BuildOptions.ts +0 -157
  168. package/src/bin/keycloakify/ftlValuesGlobalName.ts +0 -1
  169. package/src/bin/keycloakify/generateJavaStackFiles/bringInAccountV1.ts +0 -101
  170. package/src/bin/keycloakify/generateJavaStackFiles/generateJavaStackFiles.ts +0 -141
  171. package/src/bin/keycloakify/generateJavaStackFiles/index.ts +0 -1
  172. package/src/bin/keycloakify/generateTheme/readStaticResourcesUsage.ts +0 -76
  173. package/src/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.ts +0 -51
  174. package/src/bin/tools/NpmModuleVersion.ts +0 -73
  175. /package/bin/{getSrcDirPath.d.ts → getThemeSrcDirPath.d.ts} +0 -0
  176. /package/src/bin/{getSrcDirPath.ts → getThemeSrcDirPath.ts} +0 -0
@@ -1,76 +0,0 @@
1
- import { crawl } from "../../tools/crawl";
2
- import { join as pathJoin, sep as pathSep } from "path";
3
- import * as fs from "fs";
4
- import type { ThemeType } from "../../constants";
5
-
6
- /** Assumes the theme type exists */
7
- export function readStaticResourcesUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): {
8
- resourcesCommonFilePaths: string[];
9
- } {
10
- const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params;
11
-
12
- const resourcesCommonFilePaths = new Set<string>();
13
-
14
- for (const srcDirPath of [pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)]) {
15
- const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
16
-
17
- for (const filePath of filePaths) {
18
- const rawSourceFile = fs.readFileSync(filePath).toString("utf8");
19
-
20
- if (!rawSourceFile.includes("resourcesCommonPath") && !rawSourceFile.includes("resourcesPath")) {
21
- continue;
22
- }
23
-
24
- const wrap = readPaths({ rawSourceFile });
25
-
26
- wrap.resourcesCommonFilePaths.forEach(filePath => resourcesCommonFilePaths.add(filePath));
27
- }
28
- }
29
-
30
- return {
31
- "resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths)
32
- };
33
- }
34
-
35
- /** Exported for testing purpose */
36
- export function readPaths(params: { rawSourceFile: string }): {
37
- resourcesCommonFilePaths: string[];
38
- } {
39
- const { rawSourceFile } = params;
40
-
41
- const resourcesCommonFilePaths = new Set<string>();
42
-
43
- {
44
- const regexp = new RegExp(`resourcesCommonPath\\s*}([^\`]+)\``, "g");
45
-
46
- const matches = [...rawSourceFile.matchAll(regexp)];
47
-
48
- for (const match of matches) {
49
- const filePath = match[1];
50
-
51
- resourcesCommonFilePaths.add(filePath);
52
- }
53
- }
54
-
55
- {
56
- const regexp = new RegExp(`resourcesCommonPath\\s*[+,]\\s*["']([^"'\`]+)["'\`]`, "g");
57
-
58
- const matches = [...rawSourceFile.matchAll(regexp)];
59
-
60
- for (const match of matches) {
61
- const filePath = match[1];
62
-
63
- resourcesCommonFilePaths.add(filePath);
64
- }
65
- }
66
-
67
- const normalizePath = (filePath: string) => {
68
- filePath = filePath.startsWith("/") ? filePath.slice(1) : filePath;
69
- filePath = filePath.replace(/\//g, pathSep);
70
- return filePath;
71
- };
72
-
73
- return {
74
- "resourcesCommonFilePaths": Array.from(resourcesCommonFilePaths).map(normalizePath)
75
- };
76
- }
@@ -1,51 +0,0 @@
1
- import { ftlValuesGlobalName } from "../ftlValuesGlobalName";
2
-
3
- export function replaceImportsFromStaticInJsCode(params: { jsCode: string }): { fixedJsCode: string } {
4
- /*
5
- NOTE:
6
-
7
- When we have urlOrigin defined it means that
8
- we are building with --external-assets
9
- so we have to make sur that the fixed js code will run
10
- inside and outside keycloak.
11
-
12
- When urlOrigin isn't defined we can assume the fixedJsCode
13
- will always run in keycloak context.
14
- */
15
-
16
- const { jsCode } = params;
17
-
18
- const getReplaceArgs = (language: "js" | "css"): Parameters<typeof String.prototype.replace> => [
19
- new RegExp(`([a-zA-Z_]+)\\.([a-zA-Z]+)=(function\\(([a-z]+)\\){return|([a-z]+)=>)"static\\/${language}\\/"`, "g"),
20
- (...[, n, u, matchedFunction, eForFunction]) => {
21
- const isArrowFunction = matchedFunction.includes("=>");
22
- const e = isArrowFunction ? matchedFunction.replace("=>", "").trim() : eForFunction;
23
-
24
- return `
25
- ${n}[(function(){
26
- var pd = Object.getOwnPropertyDescriptor(${n}, "p");
27
- if( pd === undefined || pd.configurable ){
28
- Object.defineProperty(${n}, "p", {
29
- get: function() { return window.${ftlValuesGlobalName}.url.resourcesPath; },
30
- set: function() {}
31
- });
32
- }
33
- return "${u}";
34
- })()] = ${isArrowFunction ? `${e} =>` : `function(${e}) { return `} "/build/static/${language}/"`
35
- .replace(/\s+/g, " ")
36
- .trim();
37
- }
38
- ];
39
-
40
- const fixedJsCode = jsCode
41
- .replace(...getReplaceArgs("js"))
42
- .replace(...getReplaceArgs("css"))
43
- .replace(/[a-zA-Z]+\.[a-zA-Z]+\+"static\//g, `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`)
44
- //TODO: Write a test case for this
45
- .replace(
46
- /".chunk.css",([a-zA-Z])+=[a-zA-Z]+\.[a-zA-Z]+\+([a-zA-Z]+),/,
47
- (...[, group1, group2]) => `".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group2},`
48
- );
49
-
50
- return { fixedJsCode };
51
- }
@@ -1,73 +0,0 @@
1
- export type NpmModuleVersion = {
2
- major: number;
3
- minor: number;
4
- patch: number;
5
- betaPreRelease?: number;
6
- };
7
-
8
- export namespace NpmModuleVersion {
9
- export function parse(versionStr: string): NpmModuleVersion {
10
- const match = versionStr.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta.([0-9]+))?/);
11
-
12
- if (!match) {
13
- throw new Error(`${versionStr} is not a valid NPM version`);
14
- }
15
-
16
- return {
17
- "major": parseInt(match[1]),
18
- "minor": parseInt(match[2]),
19
- "patch": parseInt(match[3]),
20
- ...(() => {
21
- const str = match[4];
22
- return str === undefined ? {} : { "betaPreRelease": parseInt(str) };
23
- })()
24
- };
25
- }
26
-
27
- export function stringify(v: NpmModuleVersion) {
28
- return `${v.major}.${v.minor}.${v.patch}${v.betaPreRelease === undefined ? "" : `-beta.${v.betaPreRelease}`}`;
29
- }
30
-
31
- /**
32
- *
33
- * v1 < v2 => -1
34
- * v1 === v2 => 0
35
- * v1 > v2 => 1
36
- *
37
- */
38
- export function compare(v1: NpmModuleVersion, v2: NpmModuleVersion): -1 | 0 | 1 {
39
- const sign = (diff: number): -1 | 0 | 1 => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
40
- const noUndefined = (n: number | undefined) => n ?? Infinity;
41
-
42
- for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
43
- if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
44
- return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
45
- }
46
- }
47
-
48
- return 0;
49
- }
50
-
51
- /*
52
- console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0")) === -1 )
53
- console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0-beta.4")) === -1 )
54
- console.log(compare(parse("3.0.0-beta.3"), parse("4.0.0")) === -1 )
55
- */
56
-
57
- export function bumpType(params: { versionBehindStr: string; versionAheadStr: string }): "major" | "minor" | "patch" | "betaPreRelease" | "same" {
58
- const versionAhead = parse(params.versionAheadStr);
59
- const versionBehind = parse(params.versionBehindStr);
60
-
61
- if (compare(versionBehind, versionAhead) === 1) {
62
- throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`);
63
- }
64
-
65
- for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
66
- if (versionBehind[level] !== versionAhead[level]) {
67
- return level;
68
- }
69
- }
70
-
71
- return "same";
72
- }
73
- }