keycloakify 11.8.2 → 11.8.4

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/712.index.js CHANGED
@@ -846,9 +846,11 @@ 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;
853
+ const start = Date.now();
852
854
  const { resourcesDirPath, buildContext } = params;
853
855
  const [themeName] = buildContext.themeNames;
854
856
  if (external_fs_default().existsSync(resourcesDirPath)) {
@@ -1239,7 +1241,7 @@ async function generateResources(params) {
1239
1241
  ].join("\n\n"), "utf8"));
1240
1242
  }
1241
1243
  }
1242
- for (const themeVariantName of buildContext.themeNames) {
1244
+ for (const themeVariantName of [...buildContext.themeNames].reverse()) {
1243
1245
  for (const themeType of [...constants/* THEME_TYPES */.Jh, "email"]) {
1244
1246
  copy_main_theme_to_theme_variant_theme: {
1245
1247
  let isNative;
@@ -1250,25 +1252,42 @@ async function generateResources(params) {
1250
1252
  }
1251
1253
  isNative = !v.isImplemented && v.isImplemented_native;
1252
1254
  }
1253
- if (themeVariantName === themeName) {
1255
+ if (!isNative && themeVariantName === themeName) {
1254
1256
  break copy_main_theme_to_theme_variant_theme;
1255
1257
  }
1256
1258
  (0,transformCodebase/* transformCodebase */.N)({
1257
- srcDirPath: (0,external_path_.join)(resourcesDirPath, "theme", themeName, themeType),
1258
- destDirPath: (0,external_path_.join)(resourcesDirPath, "theme", themeVariantName, themeType),
1259
- transformSourceCode: isNative
1260
- ? undefined
1261
- : ({ fileRelativePath, sourceCode }) => {
1262
- if ((0,external_path_.extname)(fileRelativePath) === ".ftl" &&
1263
- fileRelativePath.split(external_path_.sep).length === 1) {
1264
- const modifiedSourceCode = Buffer.from(Buffer.from(sourceCode)
1265
- .toString("utf-8")
1266
- .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) {
1267
1285
  (0,assert/* assert */.h)(Buffer.compare(modifiedSourceCode, sourceCode) !== 0);
1268
- return { modifiedSourceCode };
1269
1286
  }
1270
- return { modifiedSourceCode: sourceCode };
1287
+ return { modifiedSourceCode };
1271
1288
  }
1289
+ return { modifiedSourceCode: sourceCode };
1290
+ }
1272
1291
  });
1273
1292
  }
1274
1293
  run_writeMessagePropertiesFiles: {
@@ -1281,34 +1300,9 @@ async function generateResources(params) {
1281
1300
  themeName: themeVariantName
1282
1301
  });
1283
1302
  }
1284
- replace_xKeycloakify_themeName_in_native_ftl_files: {
1285
- {
1286
- const v = buildContext.implementedThemeTypes[themeType];
1287
- if (v.isImplemented || !v.isImplemented_native) {
1288
- break replace_xKeycloakify_themeName_in_native_ftl_files;
1289
- }
1290
- }
1291
- const emailThemeDirPath = getThemeTypeDirPath({
1292
- themeName,
1293
- themeType
1294
- });
1295
- (0,transformCodebase/* transformCodebase */.N)({
1296
- srcDirPath: emailThemeDirPath,
1297
- destDirPath: emailThemeDirPath,
1298
- transformSourceCode: ({ filePath, sourceCode }) => {
1299
- if (!filePath.endsWith(".ftl")) {
1300
- return { modifiedSourceCode: sourceCode };
1301
- }
1302
- return {
1303
- modifiedSourceCode: Buffer.from(sourceCode
1304
- .toString("utf8")
1305
- .replace(/xKeycloakify\.themeName/g, `"${themeName}"`), "utf8")
1306
- };
1307
- }
1308
- });
1309
- }
1310
1303
  }
1311
1304
  }
1305
+ console.log(`Generated resources in ${Date.now() - start}ms`);
1312
1306
  }
1313
1307
  //# sourceMappingURL=generateResources.js.map
1314
1308
  ;// CONCATENATED MODULE: ./dist/bin/keycloakify/generateResources/index.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.8.2",
3
+ "version": "11.8.4",
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 & {
@@ -57,6 +57,8 @@ export async function generateResources(params: {
57
57
  buildContext: BuildContextLike;
58
58
  resourcesDirPath: string;
59
59
  }): Promise<void> {
60
+ const start = Date.now();
61
+
60
62
  const { resourcesDirPath, buildContext } = params;
61
63
 
62
64
  const [themeName] = buildContext.themeNames;
@@ -661,7 +663,7 @@ export async function generateResources(params: {
661
663
  }
662
664
  }
663
665
 
664
- for (const themeVariantName of buildContext.themeNames) {
666
+ for (const themeVariantName of [...buildContext.themeNames].reverse()) {
665
667
  for (const themeType of [...THEME_TYPES, "email"] as const) {
666
668
  copy_main_theme_to_theme_variant_theme: {
667
669
  let isNative: boolean;
@@ -676,44 +678,59 @@ export async function generateResources(params: {
676
678
  isNative = !v.isImplemented && v.isImplemented_native;
677
679
  }
678
680
 
679
- if (themeVariantName === themeName) {
681
+ if (!isNative && themeVariantName === themeName) {
680
682
  break copy_main_theme_to_theme_variant_theme;
681
683
  }
682
684
 
683
685
  transformCodebase({
684
- srcDirPath: pathJoin(resourcesDirPath, "theme", themeName, themeType),
685
- destDirPath: pathJoin(
686
- resourcesDirPath,
687
- "theme",
688
- themeVariantName,
686
+ srcDirPath: getThemeTypeDirPath({ themeName, themeType }),
687
+ destDirPath: getThemeTypeDirPath({
688
+ themeName: themeVariantName,
689
689
  themeType
690
- ),
691
- transformSourceCode: isNative
692
- ? undefined
693
- : ({ fileRelativePath, sourceCode }) => {
694
- if (
695
- pathExtname(fileRelativePath) === ".ftl" &&
696
- fileRelativePath.split(pathSep).length === 1
697
- ) {
698
- const modifiedSourceCode = Buffer.from(
699
- Buffer.from(sourceCode)
700
- .toString("utf-8")
701
- .replace(
702
- `"themeName": "${themeName}"`,
703
- `"themeName": "${themeVariantName}"`
704
- ),
705
- "utf8"
706
- );
707
-
708
- assert(
709
- Buffer.compare(modifiedSourceCode, sourceCode) !== 0
710
- );
711
-
712
- return { modifiedSourceCode };
713
- }
714
-
715
- return { modifiedSourceCode: sourceCode };
716
- }
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
+ }
717
734
  });
718
735
  }
719
736
  run_writeMessagePropertiesFiles: {
@@ -732,42 +749,8 @@ export async function generateResources(params: {
732
749
  themeName: themeVariantName
733
750
  });
734
751
  }
735
- replace_xKeycloakify_themeName_in_native_ftl_files: {
736
- {
737
- const v = buildContext.implementedThemeTypes[themeType];
738
-
739
- if (v.isImplemented || !v.isImplemented_native) {
740
- break replace_xKeycloakify_themeName_in_native_ftl_files;
741
- }
742
- }
743
-
744
- const emailThemeDirPath = getThemeTypeDirPath({
745
- themeName,
746
- themeType
747
- });
748
-
749
- transformCodebase({
750
- srcDirPath: emailThemeDirPath,
751
- destDirPath: emailThemeDirPath,
752
- transformSourceCode: ({ filePath, sourceCode }) => {
753
- if (!filePath.endsWith(".ftl")) {
754
- return { modifiedSourceCode: sourceCode };
755
- }
756
-
757
- return {
758
- modifiedSourceCode: Buffer.from(
759
- sourceCode
760
- .toString("utf8")
761
- .replace(
762
- /xKeycloakify\.themeName/g,
763
- `"${themeName}"`
764
- ),
765
- "utf8"
766
- )
767
- };
768
- }
769
- });
770
- }
771
752
  }
772
753
  }
754
+
755
+ console.log(`Generated resources in ${Date.now() - start}ms`);
773
756
  }