keycloakify 11.8.3 → 11.8.5

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/363.index.js CHANGED
@@ -352,7 +352,13 @@ function addCommentToSourceCode(params) {
352
352
  return toResult(commentLines.map(line => `# ${line}`).join("\n"));
353
353
  }
354
354
  if (fileRelativePath.endsWith(".ftl")) {
355
- return toResult([`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n"));
355
+ const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n");
356
+ if (sourceCode.trim().startsWith("<#ftl")) {
357
+ const [first, ...rest] = sourceCode.split(">");
358
+ const last = rest.join(">");
359
+ return [`${first}>`, comment, last].join("\n");
360
+ }
361
+ return toResult(comment);
356
362
  }
357
363
  if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
358
364
  const comment = [
package/bin/712.index.js CHANGED
@@ -846,6 +846,7 @@ var isInside = __webpack_require__(90665);
846
846
 
847
847
 
848
848
 
849
+
849
850
  (0,assert/* assert */.h)();
850
851
  async function generateResources(params) {
851
852
  var _a;
@@ -1240,7 +1241,7 @@ async function generateResources(params) {
1240
1241
  ].join("\n\n"), "utf8"));
1241
1242
  }
1242
1243
  }
1243
- for (const themeVariantName of buildContext.themeNames) {
1244
+ for (const themeVariantName of [...buildContext.themeNames].reverse()) {
1244
1245
  for (const themeType of [...constants/* THEME_TYPES */.Jh, "email"]) {
1245
1246
  copy_main_theme_to_theme_variant_theme: {
1246
1247
  let isNative;
@@ -1251,25 +1252,42 @@ async function generateResources(params) {
1251
1252
  }
1252
1253
  isNative = !v.isImplemented && v.isImplemented_native;
1253
1254
  }
1254
- if (themeVariantName === themeName) {
1255
+ if (!isNative && themeVariantName === themeName) {
1255
1256
  break copy_main_theme_to_theme_variant_theme;
1256
1257
  }
1257
1258
  (0,transformCodebase/* transformCodebase */.N)({
1258
- srcDirPath: (0,external_path_.join)(resourcesDirPath, "theme", themeName, themeType),
1259
- destDirPath: (0,external_path_.join)(resourcesDirPath, "theme", themeVariantName, themeType),
1260
- transformSourceCode: isNative
1261
- ? undefined
1262
- : ({ fileRelativePath, sourceCode }) => {
1263
- if ((0,external_path_.extname)(fileRelativePath) === ".ftl" &&
1264
- fileRelativePath.split(external_path_.sep).length === 1) {
1265
- const modifiedSourceCode = Buffer.from(Buffer.from(sourceCode)
1266
- .toString("utf-8")
1267
- .replace(`"themeName": "${themeName}"`, `"themeName": "${themeVariantName}"`), "utf8");
1259
+ srcDirPath: getThemeTypeDirPath({ themeName, themeType }),
1260
+ destDirPath: getThemeTypeDirPath({
1261
+ themeName: themeVariantName,
1262
+ themeType
1263
+ }),
1264
+ transformSourceCode: ({ fileRelativePath, sourceCode }) => {
1265
+ patch_xKeycloakify_themeName: {
1266
+ if (!fileRelativePath.endsWith(".ftl")) {
1267
+ break patch_xKeycloakify_themeName;
1268
+ }
1269
+ if (!isNative &&
1270
+ (0,external_path_.basename)(fileRelativePath) !== fileRelativePath) {
1271
+ break patch_xKeycloakify_themeName;
1272
+ }
1273
+ const modifiedSourceCode = Buffer.from(Buffer.from(sourceCode)
1274
+ .toString("utf-8")
1275
+ .replace(...(0,id.id)(isNative
1276
+ ? [
1277
+ /xKeycloakify\.themeName/g,
1278
+ `"${themeVariantName}"`
1279
+ ]
1280
+ : [
1281
+ `"themeName": "${themeName}"`,
1282
+ `"themeName": "${themeVariantName}"`
1283
+ ])), "utf8");
1284
+ if (!isNative) {
1268
1285
  (0,assert/* assert */.h)(Buffer.compare(modifiedSourceCode, sourceCode) !== 0);
1269
- return { modifiedSourceCode };
1270
1286
  }
1271
- return { modifiedSourceCode: sourceCode };
1287
+ return { modifiedSourceCode };
1272
1288
  }
1289
+ return { modifiedSourceCode: sourceCode };
1290
+ }
1273
1291
  });
1274
1292
  }
1275
1293
  run_writeMessagePropertiesFiles: {
@@ -1282,32 +1300,6 @@ async function generateResources(params) {
1282
1300
  themeName: themeVariantName
1283
1301
  });
1284
1302
  }
1285
- replace_xKeycloakify_themeName_in_native_ftl_files: {
1286
- {
1287
- const v = buildContext.implementedThemeTypes[themeType];
1288
- if (v.isImplemented || !v.isImplemented_native) {
1289
- break replace_xKeycloakify_themeName_in_native_ftl_files;
1290
- }
1291
- }
1292
- const emailThemeDirPath = getThemeTypeDirPath({
1293
- themeName: themeVariantName,
1294
- themeType
1295
- });
1296
- (0,transformCodebase/* transformCodebase */.N)({
1297
- srcDirPath: emailThemeDirPath,
1298
- destDirPath: emailThemeDirPath,
1299
- transformSourceCode: ({ filePath, sourceCode }) => {
1300
- if (!filePath.endsWith(".ftl")) {
1301
- return { modifiedSourceCode: sourceCode };
1302
- }
1303
- return {
1304
- modifiedSourceCode: Buffer.from(sourceCode
1305
- .toString("utf8")
1306
- .replace(/xKeycloakify\.themeName/g, `"${themeVariantName}"`), "utf8")
1307
- };
1308
- }
1309
- });
1310
- }
1311
1303
  }
1312
1304
  }
1313
1305
  console.log(`Generated resources in ${Date.now() - start}ms`);
package/bin/97.index.js CHANGED
@@ -917,7 +917,6 @@ function addOrEditTestUser(params) {
917
917
  return firstUserCopy;
918
918
  })()) !== null && _a !== void 0 ? _a : defaultUser_default);
919
919
  newUser.username = defaultUser_default.username;
920
- newUser.email = defaultUser_default.email;
921
920
  delete_existing_password_credential_if_any: {
922
921
  const i = newUser.credentials.findIndex(credential => credential.type === "password");
923
922
  if (i === -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.8.3",
3
+ "version": "11.8.5",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,8 +6,7 @@ import {
6
6
  join as pathJoin,
7
7
  relative as pathRelative,
8
8
  dirname as pathDirname,
9
- extname as pathExtname,
10
- sep as pathSep
9
+ basename as pathBasename
11
10
  } from "path";
12
11
  import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
13
12
  import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
@@ -37,6 +36,7 @@ import propertiesParser from "properties-parser";
37
36
  import { createObjectThatThrowsIfAccessed } from "../../tools/createObjectThatThrowsIfAccessed";
38
37
  import { listInstalledModules } from "../../tools/listInstalledModules";
39
38
  import { isInside } from "../../tools/isInside";
39
+ import { id } from "tsafe/id";
40
40
 
41
41
  export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
42
42
  BuildContextLike_generateMessageProperties & {
@@ -663,7 +663,7 @@ export async function generateResources(params: {
663
663
  }
664
664
  }
665
665
 
666
- for (const themeVariantName of buildContext.themeNames) {
666
+ for (const themeVariantName of [...buildContext.themeNames].reverse()) {
667
667
  for (const themeType of [...THEME_TYPES, "email"] as const) {
668
668
  copy_main_theme_to_theme_variant_theme: {
669
669
  let isNative: boolean;
@@ -678,44 +678,59 @@ export async function generateResources(params: {
678
678
  isNative = !v.isImplemented && v.isImplemented_native;
679
679
  }
680
680
 
681
- if (themeVariantName === themeName) {
681
+ if (!isNative && themeVariantName === themeName) {
682
682
  break copy_main_theme_to_theme_variant_theme;
683
683
  }
684
684
 
685
685
  transformCodebase({
686
- srcDirPath: pathJoin(resourcesDirPath, "theme", themeName, themeType),
687
- destDirPath: pathJoin(
688
- resourcesDirPath,
689
- "theme",
690
- themeVariantName,
686
+ srcDirPath: getThemeTypeDirPath({ themeName, themeType }),
687
+ destDirPath: getThemeTypeDirPath({
688
+ themeName: themeVariantName,
691
689
  themeType
692
- ),
693
- transformSourceCode: isNative
694
- ? undefined
695
- : ({ fileRelativePath, sourceCode }) => {
696
- if (
697
- pathExtname(fileRelativePath) === ".ftl" &&
698
- fileRelativePath.split(pathSep).length === 1
699
- ) {
700
- const modifiedSourceCode = Buffer.from(
701
- Buffer.from(sourceCode)
702
- .toString("utf-8")
703
- .replace(
704
- `"themeName": "${themeName}"`,
705
- `"themeName": "${themeVariantName}"`
706
- ),
707
- "utf8"
708
- );
709
-
710
- assert(
711
- Buffer.compare(modifiedSourceCode, sourceCode) !== 0
712
- );
713
-
714
- return { modifiedSourceCode };
715
- }
716
-
717
- return { modifiedSourceCode: sourceCode };
718
- }
690
+ }),
691
+ transformSourceCode: ({ fileRelativePath, sourceCode }) => {
692
+ patch_xKeycloakify_themeName: {
693
+ if (!fileRelativePath.endsWith(".ftl")) {
694
+ break patch_xKeycloakify_themeName;
695
+ }
696
+
697
+ if (
698
+ !isNative &&
699
+ pathBasename(fileRelativePath) !== fileRelativePath
700
+ ) {
701
+ break patch_xKeycloakify_themeName;
702
+ }
703
+
704
+ const modifiedSourceCode = Buffer.from(
705
+ Buffer.from(sourceCode)
706
+ .toString("utf-8")
707
+ .replace(
708
+ ...id<[string | RegExp, string]>(
709
+ isNative
710
+ ? [
711
+ /xKeycloakify\.themeName/g,
712
+ `"${themeVariantName}"`
713
+ ]
714
+ : [
715
+ `"themeName": "${themeName}"`,
716
+ `"themeName": "${themeVariantName}"`
717
+ ]
718
+ )
719
+ ),
720
+ "utf8"
721
+ );
722
+
723
+ if (!isNative) {
724
+ assert(
725
+ Buffer.compare(modifiedSourceCode, sourceCode) !== 0
726
+ );
727
+ }
728
+
729
+ return { modifiedSourceCode };
730
+ }
731
+
732
+ return { modifiedSourceCode: sourceCode };
733
+ }
719
734
  });
720
735
  }
721
736
  run_writeMessagePropertiesFiles: {
@@ -734,42 +749,6 @@ export async function generateResources(params: {
734
749
  themeName: themeVariantName
735
750
  });
736
751
  }
737
- replace_xKeycloakify_themeName_in_native_ftl_files: {
738
- {
739
- const v = buildContext.implementedThemeTypes[themeType];
740
-
741
- if (v.isImplemented || !v.isImplemented_native) {
742
- break replace_xKeycloakify_themeName_in_native_ftl_files;
743
- }
744
- }
745
-
746
- const emailThemeDirPath = getThemeTypeDirPath({
747
- themeName: themeVariantName,
748
- themeType
749
- });
750
-
751
- transformCodebase({
752
- srcDirPath: emailThemeDirPath,
753
- destDirPath: emailThemeDirPath,
754
- transformSourceCode: ({ filePath, sourceCode }) => {
755
- if (!filePath.endsWith(".ftl")) {
756
- return { modifiedSourceCode: sourceCode };
757
- }
758
-
759
- return {
760
- modifiedSourceCode: Buffer.from(
761
- sourceCode
762
- .toString("utf8")
763
- .replace(
764
- /xKeycloakify\.themeName/g,
765
- `"${themeVariantName}"`
766
- ),
767
- "utf8"
768
- )
769
- };
770
- }
771
- });
772
- }
773
752
  }
774
753
  }
775
754
 
@@ -101,7 +101,6 @@ function addOrEditTestUser(params: {
101
101
  );
102
102
 
103
103
  newUser.username = defaultUser_default.username;
104
- newUser.email = defaultUser_default.email;
105
104
 
106
105
  delete_existing_password_credential_if_any: {
107
106
  const i = newUser.credentials.findIndex(
@@ -100,9 +100,19 @@ function addCommentToSourceCode(params: {
100
100
  }
101
101
 
102
102
  if (fileRelativePath.endsWith(".ftl")) {
103
- return toResult(
104
- [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n")
103
+ const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join(
104
+ "\n"
105
105
  );
106
+
107
+ if (sourceCode.trim().startsWith("<#ftl")) {
108
+ const [first, ...rest] = sourceCode.split(">");
109
+
110
+ const last = rest.join(">");
111
+
112
+ return [`${first}>`, comment, last].join("\n");
113
+ }
114
+
115
+ return toResult(comment);
106
116
  }
107
117
 
108
118
  if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {