@redneckz/wildless-cms-uni-blocks 0.9.1 → 0.9.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.
Files changed (75) hide show
  1. package/bin/migration-scripts/0.5.14.js +6 -0
  2. package/bin/migration-scripts/0.8.17.js +6 -0
  3. package/bin/migration-scripts/0.8.24.js +8 -2
  4. package/bin/migration-scripts/0.8.8.js +6 -0
  5. package/bin/migration-scripts/{0.8.31.js → 0.9.3.js} +14 -12
  6. package/bundle/blocks.schema.json +1 -1
  7. package/bundle/bundle.umd.js +12 -4
  8. package/bundle/bundle.umd.min.js +1 -1
  9. package/bundle/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  10. package/bundle/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  11. package/bundle/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  12. package/bundle/components/Footer/FooterContent.d.ts +2 -2
  13. package/dist/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  14. package/dist/components/CarouselEventCard/CarouselEventCard.js +9 -3
  15. package/dist/components/CarouselEventCard/CarouselEventCard.js.map +1 -1
  16. package/dist/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  17. package/dist/components/CarouselProductCard/CarouselProductCard.js +9 -5
  18. package/dist/components/CarouselProductCard/CarouselProductCard.js.map +1 -1
  19. package/dist/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  20. package/dist/components/Footer/FooterContent.d.ts +2 -2
  21. package/lib/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  22. package/lib/components/CarouselEventCard/CarouselEventCard.js +9 -3
  23. package/lib/components/CarouselEventCard/CarouselEventCard.js.map +1 -1
  24. package/lib/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  25. package/lib/components/CarouselProductCard/CarouselProductCard.js +9 -5
  26. package/lib/components/CarouselProductCard/CarouselProductCard.js.map +1 -1
  27. package/lib/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  28. package/lib/components/Footer/FooterContent.d.ts +2 -2
  29. package/mobile/bundle/bundle.umd.js +1 -1
  30. package/mobile/bundle/bundle.umd.min.js +1 -1
  31. package/mobile/bundle/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  32. package/mobile/bundle/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  33. package/mobile/bundle/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  34. package/mobile/bundle/components/Footer/FooterContent.d.ts +2 -2
  35. package/mobile/dist/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  36. package/mobile/dist/components/CarouselEventCard/CarouselEventCard.js +9 -3
  37. package/mobile/dist/components/CarouselEventCard/CarouselEventCard.js.map +1 -1
  38. package/mobile/dist/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  39. package/mobile/dist/components/CarouselProductCard/CarouselProductCard.js +9 -5
  40. package/mobile/dist/components/CarouselProductCard/CarouselProductCard.js.map +1 -1
  41. package/mobile/dist/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  42. package/mobile/dist/components/Footer/FooterContent.d.ts +2 -2
  43. package/mobile/lib/components/CarouselEventCard/CarouselEventCard.d.ts +1 -1
  44. package/mobile/lib/components/CarouselEventCard/CarouselEventCard.js +9 -3
  45. package/mobile/lib/components/CarouselEventCard/CarouselEventCard.js.map +1 -1
  46. package/mobile/lib/components/CarouselProductCard/CarouselProductCard.d.ts +1 -1
  47. package/mobile/lib/components/CarouselProductCard/CarouselProductCard.js +9 -5
  48. package/mobile/lib/components/CarouselProductCard/CarouselProductCard.js.map +1 -1
  49. package/mobile/lib/components/CarouselProductCard/CarouselProductCardContent.d.ts +2 -1
  50. package/mobile/lib/components/Footer/FooterContent.d.ts +2 -2
  51. package/mobile/src/components/CarouselCatalogCard/CarouselCatalogCard.example.json +0 -1
  52. package/mobile/src/components/CarouselEventCard/CarouselEventCard.example.json +1 -3
  53. package/mobile/src/components/CarouselEventCard/CarouselEventCard.tsx +19 -9
  54. package/mobile/src/components/CarouselProductCard/CarouselProductCard.example.json +0 -1
  55. package/mobile/src/components/CarouselProductCard/CarouselProductCard.tsx +21 -12
  56. package/mobile/src/components/CarouselProductCard/CarouselProductCardContent.ts +3 -1
  57. package/mobile/src/components/CarouselRecommendationCard/CarouselRecommendationCard.example.json +0 -2
  58. package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.example.json +0 -1
  59. package/mobile/src/components/Footer/Footer.ui.json +1 -11
  60. package/mobile/src/components/Footer/FooterContent.ts +2 -3
  61. package/package.json +1 -1
  62. package/src/components/CarouselCatalogCard/CarouselCatalogCard.example.json +0 -1
  63. package/src/components/CarouselEventCard/CarouselEventCard.example.json +1 -3
  64. package/src/components/CarouselEventCard/CarouselEventCard.tsx +19 -9
  65. package/src/components/CarouselProductCard/CarouselProductCard.example.json +0 -1
  66. package/src/components/CarouselProductCard/CarouselProductCard.tsx +21 -12
  67. package/src/components/CarouselProductCard/CarouselProductCardContent.ts +3 -1
  68. package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.example.json +0 -2
  69. package/src/components/CarouselTariffsCard/CarouselTariffsCard.example.json +0 -1
  70. package/src/components/Footer/Footer.ui.json +1 -11
  71. package/src/components/Footer/FooterContent.ts +2 -3
  72. package/bin/migration-scripts/0.4.5.js +0 -109
  73. package/bin/migration-scripts/0.5.10.js +0 -36
  74. package/bin/migration-scripts/0.6.16.js +0 -90
  75. package/bin/migration-scripts/0.6.34.js +0 -53
@@ -15,6 +15,12 @@ export default (unitPath, content) => {
15
15
  };
16
16
 
17
17
  function adjustGalleryBlock(block) {
18
+ if (block.blocks) {
19
+ for (const childBlock of block.blocks) {
20
+ adjustGalleryBlock(childBlock);
21
+ }
22
+ }
23
+
18
24
  if (block.type !== 'Gallery' || !block.content || !block.content.cards) {
19
25
  return;
20
26
  }
@@ -15,6 +15,12 @@ export default (uniPath, content) => {
15
15
  };
16
16
 
17
17
  function adjustBonusBenefitsBlock(block) {
18
+ if (block.blocks) {
19
+ for (const childBlock of block.blocks) {
20
+ adjustBonusBenefitsBlock(childBlock);
21
+ }
22
+ }
23
+
18
24
  if (block.type === 'BonusBenefitsBlock') {
19
25
  const bonusBenefits = block?.content?.bonusBenefits;
20
26
  if (bonusBenefits) {
@@ -15,9 +15,15 @@ export default (uniPath, content) => {
15
15
  };
16
16
 
17
17
  function adjustCarouselRecommendationCardBlock(block) {
18
+ if (block.blocks) {
19
+ for (const childBlock of block.blocks) {
20
+ adjustCarouselRecommendationCardBlock(childBlock);
21
+ }
22
+ }
23
+
18
24
  if (block.type === 'CarouselRecommendationCard') {
19
- const carouselRecommendationCard = block?.content?.carouselRecommendationCard;
20
- if (carouselRecommendationCard.image) {
25
+ const carouselRecommendationCard = block?.content;
26
+ if (carouselRecommendationCard?.image) {
21
27
  renameProp(carouselRecommendationCard, 'image', 'icon');
22
28
  }
23
29
  }
@@ -17,6 +17,12 @@ export default (unitPath, content) => {
17
17
  };
18
18
 
19
19
  const adjustCarouselBlock = (block) => {
20
+ if (block.blocks) {
21
+ for (const childBlock of block.blocks) {
22
+ adjustCarouselBlock(childBlock);
23
+ }
24
+ }
25
+
20
26
  if (block.type === 'Catalog') {
21
27
  adjustCarousel(block, 'CarouselCatalogCard');
22
28
  }
@@ -1,7 +1,7 @@
1
1
  import crypto from 'crypto';
2
2
  import { createReadStream, promises as fs } from 'fs';
3
3
  import glob from 'glob';
4
- import { basename } from 'path';
4
+ import { join, parse, relative } from 'path';
5
5
  import { promisify } from 'util';
6
6
 
7
7
  const findFiles = promisify(glob);
@@ -10,15 +10,16 @@ const CONTENT_DIR = './content';
10
10
  const IMAGE_EXT_LIST = ['png', 'jpg', 'svg'];
11
11
  const IMAGE_FIELD_KEYS = ['image', 'icon'];
12
12
 
13
- export const description = 'v0.8.31';
13
+ export const description = 'v0.9.3';
14
14
 
15
15
  export default async (unitPath, content) => {
16
- replaceImgSrcRecursive(content);
16
+ const unitPathDir = parse(unitPath).dir;
17
+ replaceImgSrcRecursive(content, unitPathDir);
17
18
 
18
19
  return { ...content };
19
20
  };
20
21
 
21
- const getFileHash = async (filePath, algorithm = 'sha1') => {
22
+ const getFileHash = async (filePath, algorithm = 'sha256') => {
22
23
  return new Promise((resolve, reject) => {
23
24
  const hash = crypto.createHash(algorithm);
24
25
  const stream = createReadStream(filePath);
@@ -35,7 +36,7 @@ const getFilesHashMap = async (paths) => {
35
36
  if (!fileStat.isFile()) {
36
37
  continue;
37
38
  }
38
- fileHashMap[basename(filePath)] = await getFileHash(filePath);
39
+ fileHashMap[filePath] = await getFileHash(filePath);
39
40
  }
40
41
 
41
42
  return fileHashMap;
@@ -60,7 +61,7 @@ const isObject = (value) => {
60
61
  return !!(value && typeof value === 'object' && !Array.isArray(value));
61
62
  };
62
63
 
63
- const replaceImgSrcRecursive = (node) => {
64
+ const replaceImgSrcRecursive = (node, unitPathDir) => {
64
65
  if (isObject(node)) {
65
66
  const entries = Object.entries(node);
66
67
 
@@ -68,19 +69,20 @@ const replaceImgSrcRecursive = (node) => {
68
69
  const [key, childNode] = entries[i];
69
70
 
70
71
  if (IMAGE_FIELD_KEYS.includes(key) && childNode.src) {
71
- const fileHash = filesHashMap[childNode.src];
72
+ const srcPath = join(unitPathDir, childNode.src);
73
+ const fileHash = filesHashMap[`./${srcPath}`];
72
74
  const filesGroup = filesGroupByHash.get(fileHash);
73
- const baseFileSrc = filesGroup ? filesGroup[0] : null;
74
- if (baseFileSrc) {
75
- childNode.src = baseFileSrc;
75
+ const baseFilePath = filesGroup ? filesGroup[0] : null;
76
+ if (baseFilePath) {
77
+ childNode.src = relative(unitPathDir, baseFilePath);
76
78
  }
77
79
  } else {
78
- replaceImgSrcRecursive(childNode);
80
+ replaceImgSrcRecursive(childNode, unitPathDir);
79
81
  }
80
82
  }
81
83
  } else if (Array.isArray(node)) {
82
84
  node.forEach((childNode) => {
83
- replaceImgSrcRecursive(childNode);
85
+ replaceImgSrcRecursive(childNode, unitPathDir);
84
86
  });
85
87
  }
86
88
  };