@coraltravelcenter/b2c-landing-builder 2.6.0 → 2.6.2
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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coraltravelcenter/b2c-landing-builder",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@coraltravelcenter/b2c-landing-builder",
|
|
9
|
-
"version": "2.6.
|
|
9
|
+
"version": "2.6.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@clack/prompts": "1.7.0",
|
package/package.json
CHANGED
|
@@ -90,6 +90,9 @@ export class BackofficeClient {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
reorderWidget(contentWidgetId, order) {
|
|
93
|
+
if (!Number.isInteger(order) || order < 1) {
|
|
94
|
+
throw new Error(`Widget order must be a positive integer, received: ${order}`);
|
|
95
|
+
}
|
|
93
96
|
return this.request("PUT", "/Content/Widget/ChangeOrder", {body: {contentWidgetId, order}});
|
|
94
97
|
}
|
|
95
98
|
|
package/src/deploy/images.mjs
CHANGED
|
@@ -8,6 +8,7 @@ function listFiles(root) {
|
|
|
8
8
|
const files = [];
|
|
9
9
|
const visit = (directory) => {
|
|
10
10
|
for (const entry of fs.readdirSync(directory, {withFileTypes: true})) {
|
|
11
|
+
if (entry.name.startsWith(".")) continue;
|
|
11
12
|
const absolutePath = path.join(directory, entry.name);
|
|
12
13
|
if (entry.isDirectory()) visit(absolutePath);
|
|
13
14
|
if (entry.isFile()) files.push(absolutePath);
|
package/src/deploy/manifest.mjs
CHANGED
|
@@ -17,6 +17,7 @@ function listFiles(root) {
|
|
|
17
17
|
const files = [];
|
|
18
18
|
const visit = (directory) => {
|
|
19
19
|
for (const entry of fs.readdirSync(directory, {withFileTypes: true})) {
|
|
20
|
+
if (entry.name.startsWith(".")) continue;
|
|
20
21
|
const absolutePath = path.join(directory, entry.name);
|
|
21
22
|
if (entry.isDirectory()) visit(absolutePath);
|
|
22
23
|
if (entry.isFile()) files.push(absolutePath);
|
package/src/deploy/page.mjs
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import {HTML_WIDGET_ID, STATUS} from "./backoffice-client.mjs";
|
|
2
2
|
|
|
3
3
|
function suitableAreas(scheme) {
|
|
4
|
-
return scheme.flatMap((row) => row.children || []).
|
|
5
|
-
column
|
|
4
|
+
return scheme.flatMap((row, rowIndex) => (row.children || []).map((column, columnIndex) => ({
|
|
5
|
+
area: column,
|
|
6
|
+
rowIndex,
|
|
7
|
+
columnIndex,
|
|
8
|
+
}))).filter(({area}) =>
|
|
9
|
+
area.usableWidgets?.some((widget) => widget.widgetId === HTML_WIDGET_ID)
|
|
6
10
|
);
|
|
7
11
|
}
|
|
8
12
|
|
|
13
|
+
function widgetNames(area) {
|
|
14
|
+
return (area.usedWidgets || []).map((widget, index) =>
|
|
15
|
+
widget.widgetName || widget.cmsTitle || widget.name || `widget ${index + 1}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function areaLabel({area, rowIndex, columnIndex}) {
|
|
20
|
+
const name = area.name || area.title || "HTML area";
|
|
21
|
+
const width = area.breakPoint?.xxl ? `, width ${area.breakPoint.xxl}/12` : "";
|
|
22
|
+
const contents = widgetNames(area);
|
|
23
|
+
const summary = contents.length ? contents.join(" → ") : "empty";
|
|
24
|
+
return `Row ${rowIndex + 1}, column ${columnIndex + 1}${width}: ${name} — ${summary}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
async function defaultPrompts() {
|
|
10
28
|
const {isCancel, select, text} = await import("@clack/prompts");
|
|
11
29
|
const answer = async (promise) => {
|
|
@@ -51,19 +69,23 @@ export async function createPagePlacement({client, manifest, prompts}) {
|
|
|
51
69
|
});
|
|
52
70
|
const selected = choices.find(({layout}) => layout.layoutId === layoutId);
|
|
53
71
|
const layoutAreaId = await prompts.select({
|
|
54
|
-
message: "
|
|
55
|
-
options: selected.areas.map((
|
|
56
|
-
label:
|
|
57
|
-
value: area.layoutAreaId || area.id,
|
|
72
|
+
message: "Where on the layout should the landing blocks go?",
|
|
73
|
+
options: selected.areas.map((descriptor) => ({
|
|
74
|
+
label: areaLabel(descriptor),
|
|
75
|
+
value: descriptor.area.layoutAreaId || descriptor.area.id,
|
|
58
76
|
})),
|
|
59
77
|
});
|
|
60
|
-
const area = selected.areas.find((candidate) =>
|
|
61
|
-
|
|
78
|
+
const area = selected.areas.find(({area: candidate}) =>
|
|
79
|
+
(candidate.layoutAreaId || candidate.id) === layoutAreaId
|
|
80
|
+
).area;
|
|
81
|
+
const names = widgetNames(area);
|
|
62
82
|
const orderIndex = await prompts.select({
|
|
63
|
-
message: "
|
|
64
|
-
options: Array.from({length:
|
|
65
|
-
label: index === 0
|
|
66
|
-
|
|
83
|
+
message: "Exact insertion point",
|
|
84
|
+
options: Array.from({length: names.length + 1}, (_, index) => ({
|
|
85
|
+
label: index === 0
|
|
86
|
+
? names.length ? `At the beginning, before “${names[0]}”` : "Into the empty area"
|
|
87
|
+
: `After “${names[index - 1]}”`,
|
|
88
|
+
value: index,
|
|
67
89
|
})),
|
|
68
90
|
});
|
|
69
91
|
const created = await client.createPage({applicationId, layoutId, name: pageName.trim()});
|
package/src/deploy/widgets.mjs
CHANGED
|
@@ -50,7 +50,7 @@ export async function syncWidgets({client, manifest, placement, pageContent, roo
|
|
|
50
50
|
added += 1;
|
|
51
51
|
}
|
|
52
52
|
activeIds.add(widget.contentWidgetId);
|
|
53
|
-
const desiredOrder = placement.orderIndex + 1 + index;
|
|
53
|
+
const desiredOrder = Math.max(0, placement.orderIndex) + 1 + index;
|
|
54
54
|
if (widget.order !== desiredOrder) {
|
|
55
55
|
await client.reorderWidget(widget.contentWidgetId, desiredOrder);
|
|
56
56
|
reordered += 1;
|