@redneckz/wildless-cms-uni-blocks 0.9.2 → 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.
- package/bin/migration-scripts/0.5.14.js +6 -0
- package/bin/migration-scripts/0.8.17.js +6 -0
- package/bin/migration-scripts/0.8.24.js +2 -2
- package/bin/migration-scripts/0.8.8.js +6 -0
- package/bin/migration-scripts/{0.8.31.js → 0.9.3.js} +14 -12
- package/bundle/bundle.umd.js +1 -1
- package/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/bundle.umd.js +1 -1
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/package.json +1 -1
- package/bin/migration-scripts/0.4.5.js +0 -109
- package/bin/migration-scripts/0.5.10.js +0 -36
- package/bin/migration-scripts/0.6.16.js +0 -90
- 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) {
|
|
@@ -22,8 +22,8 @@ function adjustCarouselRecommendationCardBlock(block) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (block.type === 'CarouselRecommendationCard') {
|
|
25
|
-
const carouselRecommendationCard = block?.content
|
|
26
|
-
if (carouselRecommendationCard
|
|
25
|
+
const carouselRecommendationCard = block?.content;
|
|
26
|
+
if (carouselRecommendationCard?.image) {
|
|
27
27
|
renameProp(carouselRecommendationCard, 'image', 'icon');
|
|
28
28
|
}
|
|
29
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 {
|
|
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.
|
|
13
|
+
export const description = 'v0.9.3';
|
|
14
14
|
|
|
15
15
|
export default async (unitPath, content) => {
|
|
16
|
-
|
|
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 = '
|
|
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[
|
|
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
|
|
72
|
+
const srcPath = join(unitPathDir, childNode.src);
|
|
73
|
+
const fileHash = filesHashMap[`./${srcPath}`];
|
|
72
74
|
const filesGroup = filesGroupByHash.get(fileHash);
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
childNode.src =
|
|
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
|
};
|
package/bundle/bundle.umd.js
CHANGED
|
@@ -4820,7 +4820,7 @@
|
|
|
4820
4820
|
return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
|
|
4821
4821
|
}
|
|
4822
4822
|
|
|
4823
|
-
const packageVersion = "0.9.
|
|
4823
|
+
const packageVersion = "0.9.3";
|
|
4824
4824
|
|
|
4825
4825
|
exports.Blocks = Blocks;
|
|
4826
4826
|
exports.ContentPage = ContentPage;
|