@redneckz/wildless-cms-uni-blocks 0.5.1 → 0.5.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/migrate.js +2 -0
- package/bin/migrateContentUnit.js +26 -0
- package/bin/migration-scripts/0.4.0.js +3 -0
- package/bin/migration-scripts/0.4.1.js +3 -0
- package/bin/migration-scripts/0.4.5.js +109 -0
- package/bin/migration-scripts/0.4.5.spec.ts +352 -0
- package/bin/migration-scripts/index.js +21 -0
- package/bin/utils.js +24 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +27 -25
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/components/CardTransfer/CardTransfer.js +7 -7
- package/dist/components/CardTransfer/CardTransfer.js.map +1 -1
- package/dist/components/CardTransfer/CardTransferContent.d.ts +7 -4
- package/dist/components/PictureText/PictureText.js +1 -1
- package/dist/components/PictureText/PictureText.js.map +1 -1
- package/dist/components/ProductTile/ProductTile.js +2 -2
- package/dist/components/ProductTile/ProductTile.js.map +1 -1
- package/dist/components/SafeDepositRental/RenderRadioButtons.js +1 -1
- package/dist/components/Tabs/TabsContent.d.ts +8 -3
- package/dist/components/Tabs/renderGroupTab.js +1 -1
- package/dist/components/Tabs/renderGroupTab.js.map +1 -1
- package/dist/model/ButtonVersion.d.ts +2 -2
- package/dist/ui-kit/Button/Button.js +4 -1
- package/dist/ui-kit/Button/Button.js.map +1 -1
- package/dist/ui-kit/Button/Button.mobile.js +2 -0
- package/dist/ui-kit/Button/Button.mobile.js.map +1 -1
- package/dist/ui-kit/Button/ButtonInner.js +3 -2
- package/dist/ui-kit/Button/ButtonInner.js.map +1 -1
- package/dist/ui-kit/Button/ButtonSection.js +3 -2
- package/dist/ui-kit/Button/ButtonSection.js.map +1 -1
- package/dist/ui-kit/Button/buttonClassNameConstants.js +2 -0
- package/dist/ui-kit/Button/buttonClassNameConstants.js.map +1 -1
- package/dist/ui-kit/CurrencyInput/CurrencyInput.d.ts +1 -18
- package/dist/ui-kit/CurrencyInput/CurrencyInput.js +2 -7
- package/dist/ui-kit/CurrencyInput/CurrencyInput.js.map +1 -1
- package/dist/ui-kit/CurrencyInput/CurrencyInputProps.d.ts +10 -0
- package/dist/ui-kit/{Tabs/TabsProps.js → CurrencyInput/CurrencyInputProps.js} +1 -1
- package/dist/ui-kit/CurrencyInput/CurrencyInputProps.js.map +1 -0
- package/dist/ui-kit/Select/Select.js +1 -1
- package/dist/ui-kit/Select/Select.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/CardTransfer/CardTransfer.js +7 -7
- package/lib/components/CardTransfer/CardTransfer.js.map +1 -1
- package/lib/components/CardTransfer/CardTransferContent.d.ts +7 -4
- package/lib/components/PictureText/PictureText.js +1 -1
- package/lib/components/PictureText/PictureText.js.map +1 -1
- package/lib/components/ProductTile/ProductTile.js +2 -2
- package/lib/components/ProductTile/ProductTile.js.map +1 -1
- package/lib/components/SafeDepositRental/RenderRadioButtons.js +1 -1
- package/lib/components/Tabs/TabsContent.d.ts +8 -3
- package/lib/components/Tabs/renderGroupTab.js +1 -1
- package/lib/components/Tabs/renderGroupTab.js.map +1 -1
- package/lib/model/ButtonVersion.d.ts +2 -2
- package/lib/ui-kit/Button/Button.js +4 -1
- package/lib/ui-kit/Button/Button.js.map +1 -1
- package/lib/ui-kit/Button/Button.mobile.js +2 -0
- package/lib/ui-kit/Button/Button.mobile.js.map +1 -1
- package/lib/ui-kit/Button/ButtonInner.js +3 -2
- package/lib/ui-kit/Button/ButtonInner.js.map +1 -1
- package/lib/ui-kit/Button/ButtonSection.js +3 -2
- package/lib/ui-kit/Button/ButtonSection.js.map +1 -1
- package/lib/ui-kit/Button/buttonClassNameConstants.js +2 -0
- package/lib/ui-kit/Button/buttonClassNameConstants.js.map +1 -1
- package/lib/ui-kit/CurrencyInput/CurrencyInput.d.ts +1 -18
- package/lib/ui-kit/CurrencyInput/CurrencyInput.js +2 -7
- package/lib/ui-kit/CurrencyInput/CurrencyInput.js.map +1 -1
- package/lib/ui-kit/CurrencyInput/CurrencyInputProps.d.ts +10 -0
- package/lib/ui-kit/CurrencyInput/CurrencyInputProps.js +2 -0
- package/lib/ui-kit/CurrencyInput/CurrencyInputProps.js.map +1 -0
- package/lib/ui-kit/Select/Select.js +1 -1
- package/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +9 -5
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/dist/components/CardTransfer/CardTransfer.js +7 -7
- package/mobile/dist/components/CardTransfer/CardTransfer.js.map +1 -1
- package/mobile/dist/components/CardTransfer/CardTransferContent.d.ts +7 -4
- package/mobile/dist/components/PictureText/PictureText.js +1 -1
- package/mobile/dist/components/PictureText/PictureText.js.map +1 -1
- package/mobile/dist/components/ProductTile/ProductTile.js +2 -2
- package/mobile/dist/components/ProductTile/ProductTile.js.map +1 -1
- package/mobile/dist/components/SafeDepositRental/RenderRadioButtons.js +1 -1
- package/mobile/dist/components/Tabs/TabsContent.d.ts +8 -3
- package/mobile/dist/components/Tabs/renderGroupTab.js +1 -1
- package/mobile/dist/components/Tabs/renderGroupTab.js.map +1 -1
- package/mobile/dist/model/ButtonVersion.d.ts +2 -2
- package/mobile/dist/ui-kit/Button/Button.js +2 -0
- package/mobile/dist/ui-kit/Button/Button.js.map +1 -1
- package/mobile/dist/ui-kit/Button/ButtonInner.js +3 -2
- package/mobile/dist/ui-kit/Button/ButtonInner.js.map +1 -1
- package/mobile/dist/ui-kit/Button/ButtonSection.js +3 -2
- package/mobile/dist/ui-kit/Button/ButtonSection.js.map +1 -1
- package/mobile/dist/ui-kit/Button/buttonClassNameConstants.js +2 -0
- package/mobile/dist/ui-kit/Button/buttonClassNameConstants.js.map +1 -1
- package/mobile/dist/ui-kit/CurrencyInput/CurrencyInput.d.ts +1 -18
- package/mobile/dist/ui-kit/CurrencyInput/CurrencyInput.js +2 -7
- package/mobile/dist/ui-kit/CurrencyInput/CurrencyInput.js.map +1 -1
- package/mobile/dist/ui-kit/CurrencyInput/CurrencyInputProps.d.ts +10 -0
- package/mobile/dist/ui-kit/{Tabs/TabsProps.js → CurrencyInput/CurrencyInputProps.js} +1 -1
- package/mobile/dist/ui-kit/CurrencyInput/CurrencyInputProps.js.map +1 -0
- package/mobile/dist/ui-kit/Select/Select.js +1 -1
- package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
- package/mobile/lib/components/CardTransfer/CardTransfer.js +7 -7
- package/mobile/lib/components/CardTransfer/CardTransfer.js.map +1 -1
- package/mobile/lib/components/CardTransfer/CardTransferContent.d.ts +7 -4
- package/mobile/lib/components/PictureText/PictureText.js +1 -1
- package/mobile/lib/components/PictureText/PictureText.js.map +1 -1
- package/mobile/lib/components/ProductTile/ProductTile.js +2 -2
- package/mobile/lib/components/ProductTile/ProductTile.js.map +1 -1
- package/mobile/lib/components/SafeDepositRental/RenderRadioButtons.js +1 -1
- package/mobile/lib/components/Tabs/TabsContent.d.ts +8 -3
- package/mobile/lib/components/Tabs/renderGroupTab.js +1 -1
- package/mobile/lib/components/Tabs/renderGroupTab.js.map +1 -1
- package/mobile/lib/model/ButtonVersion.d.ts +2 -2
- package/mobile/lib/ui-kit/Button/Button.js +2 -0
- package/mobile/lib/ui-kit/Button/Button.js.map +1 -1
- package/mobile/lib/ui-kit/Button/ButtonInner.js +3 -2
- package/mobile/lib/ui-kit/Button/ButtonInner.js.map +1 -1
- package/mobile/lib/ui-kit/Button/ButtonSection.js +3 -2
- package/mobile/lib/ui-kit/Button/ButtonSection.js.map +1 -1
- package/mobile/lib/ui-kit/Button/buttonClassNameConstants.js +2 -0
- package/mobile/lib/ui-kit/Button/buttonClassNameConstants.js.map +1 -1
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInput.d.ts +1 -18
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInput.js +2 -7
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInput.js.map +1 -1
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInputProps.d.ts +10 -0
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInputProps.js +2 -0
- package/mobile/lib/ui-kit/CurrencyInput/CurrencyInputProps.js.map +1 -0
- package/mobile/lib/ui-kit/Select/Select.js +1 -1
- package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/src/components/CardTransfer/CardTransfer.example.json +6 -0
- package/mobile/src/components/CardTransfer/CardTransfer.tsx +46 -37
- package/mobile/src/components/CardTransfer/CardTransferContent.ts +7 -4
- package/mobile/src/components/ContentPage/ContentPage.page.json +7 -1
- package/mobile/src/components/PictureText/PictureText.tsx +1 -1
- package/mobile/src/components/ProductTile/ProductTile.tsx +4 -2
- package/mobile/src/components/SafeDepositRental/RenderRadioButtons.tsx +1 -1
- package/mobile/src/components/Tabs/TabsContent.ts +8 -3
- package/mobile/src/components/Tabs/renderGroupTab.tsx +2 -1
- package/mobile/src/components/__snapshots__/Blocks.spec.tsx.snap +9 -9
- package/mobile/src/model/ButtonVersion.ts +2 -2
- package/mobile/src/ui-kit/Button/Button.tsx +2 -0
- package/mobile/src/ui-kit/Button/ButtonInner.tsx +3 -2
- package/mobile/src/ui-kit/Button/ButtonSection.tsx +9 -4
- package/mobile/src/ui-kit/Button/buttonClassNameConstants.ts +2 -0
- package/mobile/src/ui-kit/CurrencyInput/CurrencyInput.tsx +5 -29
- package/mobile/src/ui-kit/CurrencyInput/CurrencyInputProps.ts +10 -0
- package/mobile/src/ui-kit/Select/Select.tsx +1 -1
- package/package.json +5 -1
- package/src/components/CardTransfer/CardTransfer.example.json +6 -0
- package/src/components/CardTransfer/CardTransfer.tsx +46 -37
- package/src/components/CardTransfer/CardTransferContent.ts +7 -4
- package/src/components/ContentPage/ContentPage.page.json +7 -1
- package/src/components/PictureText/PictureText.tsx +1 -1
- package/src/components/ProductGallery/ProductGallery.fixture.tsx +1 -1
- package/src/components/ProductTile/ProductTile.tsx +4 -2
- package/src/components/SafeDepositRental/RenderRadioButtons.tsx +1 -1
- package/src/components/StepsBlock/StepsBlock.fixture.tsx +2 -0
- package/src/components/Tabs/TabsContent.ts +8 -3
- package/src/components/Tabs/renderGroupTab.tsx +2 -1
- package/src/components/__snapshots__/Blocks.spec.tsx.snap +9 -9
- package/src/model/ButtonVersion.ts +2 -2
- package/src/ui-kit/Button/Button.mobile.tsx +2 -0
- package/src/ui-kit/Button/Button.tsx +5 -3
- package/src/ui-kit/Button/ButtonInner.tsx +3 -2
- package/src/ui-kit/Button/ButtonSection.tsx +9 -4
- package/src/ui-kit/Button/buttonClassNameConstants.ts +2 -0
- package/src/ui-kit/CurrencyInput/CurrencyInput.tsx +5 -29
- package/src/ui-kit/CurrencyInput/CurrencyInputProps.ts +10 -0
- package/src/ui-kit/Select/Select.tsx +1 -1
- package/dist/ui-kit/Tabs/Tabs.d.ts +0 -2
- package/dist/ui-kit/Tabs/Tabs.js +0 -17
- package/dist/ui-kit/Tabs/Tabs.js.map +0 -1
- package/dist/ui-kit/Tabs/TabsProps.d.ts +0 -17
- package/dist/ui-kit/Tabs/TabsProps.js.map +0 -1
- package/lib/ui-kit/Tabs/Tabs.d.ts +0 -2
- package/lib/ui-kit/Tabs/Tabs.js +0 -15
- package/lib/ui-kit/Tabs/Tabs.js.map +0 -1
- package/lib/ui-kit/Tabs/TabsProps.d.ts +0 -17
- package/lib/ui-kit/Tabs/TabsProps.js +0 -2
- package/lib/ui-kit/Tabs/TabsProps.js.map +0 -1
- package/mobile/dist/ui-kit/Tabs/Tabs.d.ts +0 -2
- package/mobile/dist/ui-kit/Tabs/Tabs.js +0 -17
- package/mobile/dist/ui-kit/Tabs/Tabs.js.map +0 -1
- package/mobile/dist/ui-kit/Tabs/TabsProps.d.ts +0 -17
- package/mobile/dist/ui-kit/Tabs/TabsProps.js.map +0 -1
- package/mobile/lib/ui-kit/Tabs/Tabs.d.ts +0 -2
- package/mobile/lib/ui-kit/Tabs/Tabs.js +0 -15
- package/mobile/lib/ui-kit/Tabs/Tabs.js.map +0 -1
- package/mobile/lib/ui-kit/Tabs/TabsProps.d.ts +0 -17
- package/mobile/lib/ui-kit/Tabs/TabsProps.js +0 -2
- package/mobile/lib/ui-kit/Tabs/TabsProps.js.map +0 -1
- package/mobile/src/ui-kit/Tabs/Tabs.tsx +0 -52
- package/mobile/src/ui-kit/Tabs/TabsProps.ts +0 -20
- package/src/ui-kit/Tabs/Tabs.tsx +0 -52
- package/src/ui-kit/Tabs/TabsProps.ts +0 -20
package/bin/migrate.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
export function migrateContentUnit(migrationScripts) {
|
|
4
|
+
const contentProcessor = migrationScripts.map((_) => _.default).reduce(composeMigrationScripts);
|
|
5
|
+
|
|
6
|
+
return async (unitPath) => {
|
|
7
|
+
console.log('Start processing of:', unitPath);
|
|
8
|
+
try {
|
|
9
|
+
const content = JSON.parse(await readFile(unitPath, 'utf-8'));
|
|
10
|
+
|
|
11
|
+
await writeFile(
|
|
12
|
+
unitPath,
|
|
13
|
+
JSON.stringify(contentProcessor(unitPath, content), undefined, 2),
|
|
14
|
+
'utf-8',
|
|
15
|
+
);
|
|
16
|
+
} catch (ex) {
|
|
17
|
+
console.warn(ex);
|
|
18
|
+
} finally {
|
|
19
|
+
console.log('End processing of:', unitPath);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function composeMigrationScripts(scriptA, scriptB) {
|
|
25
|
+
return (unitPath, content) => scriptB(unitPath, scriptA(unitPath, content));
|
|
26
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { deleteEmptyProps, renameProp } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export const description = 'v0.4.5';
|
|
4
|
+
|
|
5
|
+
export const migrate = (unitPath, content) => {
|
|
6
|
+
if (!content?.blocks) {
|
|
7
|
+
return content;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (const block of content.blocks) {
|
|
11
|
+
adjustNavigatorTabsBlock(block);
|
|
12
|
+
adjustGroupBlock(block);
|
|
13
|
+
adjustTariffsTableBlock(block);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return content;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function adjustNavigatorTabsBlock(block) {
|
|
20
|
+
if (block.type !== 'NavigatorTabs') {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
block.type = 'Tabs';
|
|
25
|
+
|
|
26
|
+
if (block.content) {
|
|
27
|
+
renameProp(block.content, 'navigatorTabs', 'tabs');
|
|
28
|
+
|
|
29
|
+
for (const item in block.content.tabs) {
|
|
30
|
+
item.type = 'link';
|
|
31
|
+
Reflect.deleteProperty(item, 'label');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function adjustGroupBlock(block) {
|
|
37
|
+
if (block.type !== 'GroupBlock') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// GroupBlock переделываем в Tabs
|
|
42
|
+
// Страницы в которых есть GroupBlock credit-cards / debet-cards / deposits / loans / vse-vidy-strahovaniya1
|
|
43
|
+
|
|
44
|
+
block.type = 'Tabs';
|
|
45
|
+
|
|
46
|
+
if (block.content) {
|
|
47
|
+
renameProp(block.content, 'tabs', 'labels');
|
|
48
|
+
renameProp(block.content, 'isShowCounter', 'showCounter');
|
|
49
|
+
|
|
50
|
+
for (const item of block.content.labels) {
|
|
51
|
+
item.type = 'group';
|
|
52
|
+
renameProp(item, 'tag', 'ref');
|
|
53
|
+
Reflect.deleteProperty(item, 'index');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Reflect.deleteProperty(block.content, 'blocks');
|
|
57
|
+
Reflect.deleteProperty(block.content, 'groupBlocks');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function adjustTariffsTableBlock(block) {
|
|
62
|
+
if (block.type !== 'TariffsTable' || !block.content || !block.content.columns) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
renameProp(block.content, 'columns', 'tariffsColumns');
|
|
67
|
+
|
|
68
|
+
for (const column of block.content.tariffsColumns) {
|
|
69
|
+
for (const columnInner of column.data) {
|
|
70
|
+
adjustTariffsColumnsInner(columnInner);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function adjustTariffsColumnsInner(columnInner) {
|
|
76
|
+
for (let index = 0; index < columnInner.length; index++) {
|
|
77
|
+
const cell = columnInner[index];
|
|
78
|
+
|
|
79
|
+
deleteEmptyProps(cell);
|
|
80
|
+
|
|
81
|
+
if (Object.keys(cell).length === 2 && cell?.label && cell.description) {
|
|
82
|
+
addCellType(cell);
|
|
83
|
+
} else if (Object.keys(cell).length < 2) {
|
|
84
|
+
addCellType(cell);
|
|
85
|
+
} else {
|
|
86
|
+
// Если типов два и более и это не labels и description то разносим по разным ячейкам
|
|
87
|
+
const newArr = [];
|
|
88
|
+
for (const key in cell) {
|
|
89
|
+
newArr.push(addCellType({ [key]: cell[key] }));
|
|
90
|
+
}
|
|
91
|
+
columnInner.splice(index, 1, ...newArr);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Добавить тип в ячейку компонента TariffsTable
|
|
97
|
+
function addCellType(cell) {
|
|
98
|
+
if (cell?.label || cell?.description) {
|
|
99
|
+
cell.tableCellType = 'LabelDescription';
|
|
100
|
+
}
|
|
101
|
+
if (cell?.buttons) {
|
|
102
|
+
cell.tableCellType = 'Buttons';
|
|
103
|
+
}
|
|
104
|
+
if (cell?.list) {
|
|
105
|
+
cell.tableCellType = 'List';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return cell;
|
|
109
|
+
}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { migrate } from './0.4.5.js';
|
|
2
|
+
|
|
3
|
+
const content = {
|
|
4
|
+
blocks: [
|
|
5
|
+
{
|
|
6
|
+
content: {
|
|
7
|
+
navigatorTabs: [
|
|
8
|
+
{
|
|
9
|
+
text: 'Как оформить',
|
|
10
|
+
href: '#howto',
|
|
11
|
+
target: '_blank',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
text: 'Частые вопросы',
|
|
15
|
+
href: '#faq',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
text: 'Тарифы',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
style: ['col-span-12'],
|
|
23
|
+
type: 'NavigatorTabs',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
content: {
|
|
27
|
+
groupBlocks: [
|
|
28
|
+
{
|
|
29
|
+
blockType: 'ProductBlock',
|
|
30
|
+
style: ['col-span-12'],
|
|
31
|
+
title: 'Кредитная карта для покупок в рассрочку',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
tabs: [
|
|
35
|
+
{
|
|
36
|
+
title: 'Кобрендинговые',
|
|
37
|
+
index: 1,
|
|
38
|
+
tag: 'tag1',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'Социальные',
|
|
42
|
+
index: 2,
|
|
43
|
+
tag: 'tag2',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
isShowCounter: true,
|
|
47
|
+
blocks: [
|
|
48
|
+
{
|
|
49
|
+
blockType: 'ProductTile',
|
|
50
|
+
title: 'Продуктовая плитка',
|
|
51
|
+
tags: ['tag1'],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
style: ['col-span-12'],
|
|
56
|
+
type: 'GroupBlock',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
content: {
|
|
60
|
+
columns: [
|
|
61
|
+
{
|
|
62
|
+
data: [
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
list: {
|
|
66
|
+
items: [],
|
|
67
|
+
},
|
|
68
|
+
image: {
|
|
69
|
+
size: {},
|
|
70
|
+
},
|
|
71
|
+
buttons: [],
|
|
72
|
+
label: 'Да',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
list: {
|
|
78
|
+
items: [],
|
|
79
|
+
},
|
|
80
|
+
image: {
|
|
81
|
+
size: {},
|
|
82
|
+
},
|
|
83
|
+
label: '₽',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
{
|
|
88
|
+
list: {},
|
|
89
|
+
image: {
|
|
90
|
+
size: {},
|
|
91
|
+
},
|
|
92
|
+
label:
|
|
93
|
+
'100 тыс ₽ — 10 млн ₽ (не более 50% от рыночной стоимости объекта недвижимости, передаваемого в залог).',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
{
|
|
98
|
+
list: {},
|
|
99
|
+
image: {
|
|
100
|
+
size: {},
|
|
101
|
+
},
|
|
102
|
+
label: 'До 10 лет',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
{
|
|
107
|
+
list: {
|
|
108
|
+
items: [
|
|
109
|
+
'Наличие записей в похозяйственной книге органа местного самоуправления о ведении гражданином личного подсобного',
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
image: {
|
|
113
|
+
size: {},
|
|
114
|
+
},
|
|
115
|
+
buttons: [
|
|
116
|
+
{
|
|
117
|
+
version: 'primary',
|
|
118
|
+
icon: {
|
|
119
|
+
size: {},
|
|
120
|
+
},
|
|
121
|
+
text: 'Скрыть',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
label: 'Для граждан, ведущих личное хозяйство',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
rowHeaders: [
|
|
131
|
+
{
|
|
132
|
+
icon: {
|
|
133
|
+
size: {},
|
|
134
|
+
sources: [],
|
|
135
|
+
icon: 'PercentageRoundIcon',
|
|
136
|
+
},
|
|
137
|
+
title: 'Кредит на любые цели',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
icon: {
|
|
141
|
+
size: {},
|
|
142
|
+
icon: 'MoneyIcon',
|
|
143
|
+
},
|
|
144
|
+
title: 'Валюта кредита',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
icon: {
|
|
148
|
+
size: {},
|
|
149
|
+
icon: 'WalletIcon',
|
|
150
|
+
},
|
|
151
|
+
title: 'Сумма кредита',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
icon: {
|
|
155
|
+
size: {},
|
|
156
|
+
icon: 'SmallClockIcon',
|
|
157
|
+
},
|
|
158
|
+
title: 'Срок кредита',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
title: 'Тарифы',
|
|
162
|
+
orientation: 'vertical',
|
|
163
|
+
},
|
|
164
|
+
style: ['col-span-12'],
|
|
165
|
+
type: 'TariffsTable',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
describe('migrate_0_4_5', () => {
|
|
171
|
+
it(`should migrate json to 0.4.5 uni block`, () => {
|
|
172
|
+
expect(migrate('foo.json', { content })).toMatchInlineSnapshot(`
|
|
173
|
+
Object {
|
|
174
|
+
"content": Object {
|
|
175
|
+
"blocks": Array [
|
|
176
|
+
Object {
|
|
177
|
+
"content": Object {
|
|
178
|
+
"navigatorTabs": Array [
|
|
179
|
+
Object {
|
|
180
|
+
"href": "#howto",
|
|
181
|
+
"target": "_blank",
|
|
182
|
+
"text": "Как оформить",
|
|
183
|
+
},
|
|
184
|
+
Object {
|
|
185
|
+
"href": "#faq",
|
|
186
|
+
"text": "Частые вопросы",
|
|
187
|
+
},
|
|
188
|
+
Object {
|
|
189
|
+
"text": "Тарифы",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
"style": Array [
|
|
194
|
+
"col-span-12",
|
|
195
|
+
],
|
|
196
|
+
"type": "NavigatorTabs",
|
|
197
|
+
},
|
|
198
|
+
Object {
|
|
199
|
+
"content": Object {
|
|
200
|
+
"blocks": Array [
|
|
201
|
+
Object {
|
|
202
|
+
"blockType": "ProductTile",
|
|
203
|
+
"tags": Array [
|
|
204
|
+
"tag1",
|
|
205
|
+
],
|
|
206
|
+
"title": "Продуктовая плитка",
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
"groupBlocks": Array [
|
|
210
|
+
Object {
|
|
211
|
+
"blockType": "ProductBlock",
|
|
212
|
+
"style": Array [
|
|
213
|
+
"col-span-12",
|
|
214
|
+
],
|
|
215
|
+
"title": "Кредитная карта для покупок в рассрочку",
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
"isShowCounter": true,
|
|
219
|
+
"tabs": Array [
|
|
220
|
+
Object {
|
|
221
|
+
"index": 1,
|
|
222
|
+
"tag": "tag1",
|
|
223
|
+
"title": "Кобрендинговые",
|
|
224
|
+
},
|
|
225
|
+
Object {
|
|
226
|
+
"index": 2,
|
|
227
|
+
"tag": "tag2",
|
|
228
|
+
"title": "Социальные",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
"style": Array [
|
|
233
|
+
"col-span-12",
|
|
234
|
+
],
|
|
235
|
+
"type": "GroupBlock",
|
|
236
|
+
},
|
|
237
|
+
Object {
|
|
238
|
+
"content": Object {
|
|
239
|
+
"columns": Array [
|
|
240
|
+
Object {
|
|
241
|
+
"data": Array [
|
|
242
|
+
Array [
|
|
243
|
+
Object {
|
|
244
|
+
"buttons": Array [],
|
|
245
|
+
"image": Object {
|
|
246
|
+
"size": Object {},
|
|
247
|
+
},
|
|
248
|
+
"label": "Да",
|
|
249
|
+
"list": Object {
|
|
250
|
+
"items": Array [],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
Array [
|
|
255
|
+
Object {
|
|
256
|
+
"image": Object {
|
|
257
|
+
"size": Object {},
|
|
258
|
+
},
|
|
259
|
+
"label": "₽",
|
|
260
|
+
"list": Object {
|
|
261
|
+
"items": Array [],
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
Array [
|
|
266
|
+
Object {
|
|
267
|
+
"image": Object {
|
|
268
|
+
"size": Object {},
|
|
269
|
+
},
|
|
270
|
+
"label": "100 тыс ₽ — 10 млн ₽ (не более 50% от рыночной стоимости объекта недвижимости, передаваемого в залог).",
|
|
271
|
+
"list": Object {},
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
Array [
|
|
275
|
+
Object {
|
|
276
|
+
"image": Object {
|
|
277
|
+
"size": Object {},
|
|
278
|
+
},
|
|
279
|
+
"label": "До 10 лет",
|
|
280
|
+
"list": Object {},
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
Array [
|
|
284
|
+
Object {
|
|
285
|
+
"buttons": Array [
|
|
286
|
+
Object {
|
|
287
|
+
"icon": Object {
|
|
288
|
+
"size": Object {},
|
|
289
|
+
},
|
|
290
|
+
"text": "Скрыть",
|
|
291
|
+
"version": "primary",
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
"image": Object {
|
|
295
|
+
"size": Object {},
|
|
296
|
+
},
|
|
297
|
+
"label": "Для граждан, ведущих личное хозяйство",
|
|
298
|
+
"list": Object {
|
|
299
|
+
"items": Array [
|
|
300
|
+
"Наличие записей в похозяйственной книге органа местного самоуправления о ведении гражданином личного подсобного",
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
"orientation": "vertical",
|
|
309
|
+
"rowHeaders": Array [
|
|
310
|
+
Object {
|
|
311
|
+
"icon": Object {
|
|
312
|
+
"icon": "PercentageRoundIcon",
|
|
313
|
+
"size": Object {},
|
|
314
|
+
"sources": Array [],
|
|
315
|
+
},
|
|
316
|
+
"title": "Кредит на любые цели",
|
|
317
|
+
},
|
|
318
|
+
Object {
|
|
319
|
+
"icon": Object {
|
|
320
|
+
"icon": "MoneyIcon",
|
|
321
|
+
"size": Object {},
|
|
322
|
+
},
|
|
323
|
+
"title": "Валюта кредита",
|
|
324
|
+
},
|
|
325
|
+
Object {
|
|
326
|
+
"icon": Object {
|
|
327
|
+
"icon": "WalletIcon",
|
|
328
|
+
"size": Object {},
|
|
329
|
+
},
|
|
330
|
+
"title": "Сумма кредита",
|
|
331
|
+
},
|
|
332
|
+
Object {
|
|
333
|
+
"icon": Object {
|
|
334
|
+
"icon": "SmallClockIcon",
|
|
335
|
+
"size": Object {},
|
|
336
|
+
},
|
|
337
|
+
"title": "Срок кредита",
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
"title": "Тарифы",
|
|
341
|
+
},
|
|
342
|
+
"style": Array [
|
|
343
|
+
"col-span-12",
|
|
344
|
+
],
|
|
345
|
+
"type": "TariffsTable",
|
|
346
|
+
},
|
|
347
|
+
],
|
|
348
|
+
},
|
|
349
|
+
}
|
|
350
|
+
`);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readdir } from 'fs/promises';
|
|
2
|
+
import { basename } from 'path';
|
|
3
|
+
|
|
4
|
+
export const migrationScripts = (await readdir(new URL('.', import.meta.url)))
|
|
5
|
+
.filter((_) => !_.startsWith('index'))
|
|
6
|
+
.sort(versionComparator);
|
|
7
|
+
|
|
8
|
+
export const loadedScripts = await Promise.all(
|
|
9
|
+
migrationScripts.map((scriptName) => import(`./${scriptName}`)),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
function versionComparator(scriptA, scriptB) {
|
|
13
|
+
const getVersion = (_) =>
|
|
14
|
+
basename(_, '.js')
|
|
15
|
+
.split('.')
|
|
16
|
+
.map((part) => parseInt(part, 10));
|
|
17
|
+
const versionA = getVersion(scriptA);
|
|
18
|
+
const versionB = getVersion(scriptB);
|
|
19
|
+
|
|
20
|
+
return versionA.reduce((result, partA, i) => (result !== 0 ? result : partA - versionB[i]), 0);
|
|
21
|
+
}
|
package/bin/utils.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function renameProp(obj, oldKey, newKey) {
|
|
2
|
+
if (oldKey in obj) {
|
|
3
|
+
obj[newKey] = obj[oldKey];
|
|
4
|
+
Reflect.deleteProperty(obj, oldKey);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
module.exports = renameProp;
|
|
10
|
+
|
|
11
|
+
export function deleteEmptyProps(obj) {
|
|
12
|
+
const isObj = (_) => _ && typeof _ === 'object';
|
|
13
|
+
const isEmpty = (_) => _ === null || _ === undefined || (isObj(_) && !Object.keys(_).length);
|
|
14
|
+
|
|
15
|
+
const emptyProps = Object.keys(obj).filter((key) => isEmpty(obj[key]));
|
|
16
|
+
for (const key in emptyProps) {
|
|
17
|
+
Reflect.deleteProperty(obj, key);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Object.values(obj).filter(isObj).forEach(deleteEmptyProps);
|
|
21
|
+
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
module.exports = deleteEmptyProps;
|